	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function kirin_pcie_establish_link
_kirin_pcie_establish_link:             ## @kirin_pcie_establish_link
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%r15
	pushq	%r14
	pushq	%r13
	pushq	%r12
	pushq	%rbx
	pushq	%rax
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %r12
	callq	_to_dw_pcie_from_pp
	movq	%rax, %r15
	movq	%rax, %rdi
	callq	_to_kirin_pcie
	movq	%rax, %r13
	movq	(%rax), %rax
	movq	(%rax), %rbx
	movq	%r15, %rdi
	callq	_kirin_pcie_link_up
	xorl	%r14d, %r14d
	testq	%rax, %rax
	jne	LBB0_5
## %bb.1:
	movq	%rbx, -48(%rbp)                 ## 8-byte Spill
	movq	%r12, %rdi
	callq	_dw_pcie_setup_rc
	movq	_PCIE_LTSSM_ENABLE_BIT@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_PCIE_APP_LTSSM_ENABLE@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r13, %rdi
	callq	_kirin_apb_ctrl_writel
	movl	$1000, %ebx                     ## imm = 0x3E8
	movq	_LINK_WAIT_MIN@GOTPCREL(%rip), %r12
	movq	_LINK_WAIT_MAX@GOTPCREL(%rip), %r13
	.p2align	4, 0x90
LBB0_2:                                 ## =>This Inner Loop Header: Depth=1
	movq	%r15, %rdi
	callq	_kirin_pcie_link_up
	testq	%rax, %rax
	jne	LBB0_5
## %bb.3:                               ##   in Loop: Header=BB0_2 Depth=1
	movl	(%r12), %edi
	movl	(%r13), %esi
	callq	_usleep_range
	decl	%ebx
	jne	LBB0_2
## %bb.4:
	leaq	L_.str(%rip), %rsi
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	callq	_dev_err
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%r14d, %r14d
	subl	(%rax), %r14d
LBB0_5:
	movl	%r14d, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_PCIE_LTSSM_ENABLE_BIT,4,2      ## @PCIE_LTSSM_ENABLE_BIT
	.comm	_PCIE_APP_LTSSM_ENABLE,4,2      ## @PCIE_APP_LTSSM_ENABLE
	.comm	_LINK_WAIT_MIN,4,2              ## @LINK_WAIT_MIN
	.comm	_LINK_WAIT_MAX,4,2              ## @LINK_WAIT_MAX
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Link Fail\n"

	.comm	_EINVAL,4,2                     ## @EINVAL
	.no_dead_strip	_kirin_pcie_establish_link
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function kirin_pcie_establish_link
_kirin_pcie_establish_link:             ; @kirin_pcie_establish_link
	.cfi_startproc
; %bb.0:
	stp	x24, x23, [sp, #-64]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 64
	stp	x22, x21, [sp, #16]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	.cfi_offset w21, -40
	.cfi_offset w22, -48
	.cfi_offset w23, -56
	.cfi_offset w24, -64
	mov	x21, x0
	bl	_to_dw_pcie_from_pp
	mov	x19, x0
	bl	_to_kirin_pcie
	mov	x22, x0
	ldr	x8, [x0]
	ldr	x20, [x8]
	mov	x0, x19
	bl	_kirin_pcie_link_up
	cbz	x0, LBB0_3
LBB0_1:
	mov	w0, #0
LBB0_2:
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #16]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp], #64             ; 16-byte Folded Reload
	ret
LBB0_3:
	mov	x0, x21
	bl	_dw_pcie_setup_rc
Lloh0:
	adrp	x8, _PCIE_LTSSM_ENABLE_BIT@GOTPAGE
Lloh1:
	ldr	x8, [x8, _PCIE_LTSSM_ENABLE_BIT@GOTPAGEOFF]
Lloh2:
	ldr	w1, [x8]
Lloh3:
	adrp	x8, _PCIE_APP_LTSSM_ENABLE@GOTPAGE
Lloh4:
	ldr	x8, [x8, _PCIE_APP_LTSSM_ENABLE@GOTPAGEOFF]
Lloh5:
	ldr	w2, [x8]
	mov	x0, x22
	bl	_kirin_apb_ctrl_writel
	mov	w21, #1000
Lloh6:
	adrp	x22, _LINK_WAIT_MIN@GOTPAGE
Lloh7:
	ldr	x22, [x22, _LINK_WAIT_MIN@GOTPAGEOFF]
Lloh8:
	adrp	x23, _LINK_WAIT_MAX@GOTPAGE
Lloh9:
	ldr	x23, [x23, _LINK_WAIT_MAX@GOTPAGEOFF]
LBB0_4:                                 ; =>This Inner Loop Header: Depth=1
	mov	x0, x19
	bl	_kirin_pcie_link_up
	cbnz	x0, LBB0_1
; %bb.5:                                ;   in Loop: Header=BB0_4 Depth=1
	ldr	w0, [x22]
	ldr	w1, [x23]
	bl	_usleep_range
	subs	w21, w21, #1
	b.ne	LBB0_4
; %bb.6:
Lloh10:
	adrp	x1, l_.str@PAGE
Lloh11:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x20
	bl	_dev_err
Lloh12:
	adrp	x8, _EINVAL@GOTPAGE
Lloh13:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh14:
	ldr	w8, [x8]
	neg	w0, w8
	b	LBB0_2
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpAdd	Lloh10, Lloh11
	.cfi_endproc
                                        ; -- End function
	.comm	_PCIE_LTSSM_ENABLE_BIT,4,2      ; @PCIE_LTSSM_ENABLE_BIT
	.comm	_PCIE_APP_LTSSM_ENABLE,4,2      ; @PCIE_APP_LTSSM_ENABLE
	.comm	_LINK_WAIT_MIN,4,2              ; @LINK_WAIT_MIN
	.comm	_LINK_WAIT_MAX,4,2              ; @LINK_WAIT_MAX
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Link Fail\n"

	.comm	_EINVAL,4,2                     ; @EINVAL
	.no_dead_strip	_kirin_pcie_establish_link
.subsections_via_symbols
