	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mtk_pcie_hw_rd_cfg
_mtk_pcie_hw_rd_cfg:                    ## @mtk_pcie_hw_rd_cfg
	.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
	subq	$24, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%r9, -56(%rbp)                  ## 8-byte Spill
	movl	%r8d, %r15d
	movl	%ecx, %r12d
	movl	%edx, %r14d
	movl	%esi, %r13d
	movq	%rdi, %rbx
	movq	_CFG_WRRD_TYPE_0@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	_CFG_RD_FMT@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_CFG_HEADER_DW0
	movq	_PCIE_CFG_HEADER0@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rsi
	addq	(%rbx), %rsi
	movl	%eax, %edi
	callq	_writel
	movl	%r12d, %edi
	movl	%r15d, -44(%rbp)                ## 4-byte Spill
	movl	%r15d, %esi
	callq	_CFG_HEADER_DW1
	movq	_PCIE_CFG_HEADER1@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rsi
	addq	(%rbx), %rsi
	movl	%eax, %edi
	callq	_writel
	movl	%r14d, %edi
	callq	_PCI_FUNC
	movl	%eax, %r15d
	movl	%r14d, %edi
	callq	_PCI_SLOT
	movl	%r12d, %edi
	movl	%r15d, %esi
	movl	%eax, %edx
	movl	%r13d, %ecx
	callq	_CFG_HEADER_DW2
	movq	_PCIE_CFG_HEADER2@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rsi
	addq	(%rbx), %rsi
	movl	%eax, %edi
	callq	_writel
	movq	_PCIE_APP_TLP_REQ@GOTPCREL(%rip), %r14
	movq	(%r14), %rdi
	addq	(%rbx), %rdi
	callq	_readl
	movq	_APP_CFG_REQ@GOTPCREL(%rip), %rcx
	orl	(%rcx), %eax
	movq	(%r14), %rsi
	addq	(%rbx), %rsi
	movl	%eax, %edi
	callq	_writel
	movq	%rbx, %rdi
	callq	_mtk_pcie_check_cfg_cpld
	testq	%rax, %rax
	je	LBB0_2
## %bb.1:
	movq	_PCIBIOS_SET_FAILED@GOTPCREL(%rip), %rdx
	jmp	LBB0_7
LBB0_2:
	movq	_PCIE_CFG_RDATA@GOTPCREL(%rip), %rax
	movq	(%rax), %rdi
	addq	(%rbx), %rdi
	callq	_readl
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	movl	%eax, (%rdi)
	movq	_PCIBIOS_SUCCESSFUL@GOTPCREL(%rip), %rdx
	movl	-44(%rbp), %ecx                 ## 4-byte Reload
	cmpl	$1, %ecx
	je	LBB0_3
## %bb.4:
	cmpl	$2, %ecx
	jne	LBB0_7
## %bb.5:
	movl	$65535, %esi                    ## imm = 0xFFFF
	jmp	LBB0_6
LBB0_3:
	movl	$255, %esi
LBB0_6:
	shll	$3, %r12d
	movl	%r12d, %ecx
	sarl	%cl, %eax
	andl	%esi, %eax
	movl	%eax, (%rdi)
LBB0_7:
	movl	(%rdx), %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_CFG_WRRD_TYPE_0,4,2            ## @CFG_WRRD_TYPE_0
	.comm	_CFG_RD_FMT,4,2                 ## @CFG_RD_FMT
	.comm	_PCIE_CFG_HEADER0,8,3           ## @PCIE_CFG_HEADER0
	.comm	_PCIE_CFG_HEADER1,8,3           ## @PCIE_CFG_HEADER1
	.comm	_PCIE_CFG_HEADER2,8,3           ## @PCIE_CFG_HEADER2
	.comm	_PCIE_APP_TLP_REQ,8,3           ## @PCIE_APP_TLP_REQ
	.comm	_APP_CFG_REQ,4,2                ## @APP_CFG_REQ
	.comm	_PCIBIOS_SET_FAILED,4,2         ## @PCIBIOS_SET_FAILED
	.comm	_PCIE_CFG_RDATA,8,3             ## @PCIE_CFG_RDATA
	.comm	_PCIBIOS_SUCCESSFUL,4,2         ## @PCIBIOS_SUCCESSFUL
	.no_dead_strip	_mtk_pcie_hw_rd_cfg
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mtk_pcie_hw_rd_cfg
_mtk_pcie_hw_rd_cfg:                    ; @mtk_pcie_hw_rd_cfg
	.cfi_startproc
; %bb.0:
	stp	x26, x25, [sp, #-80]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.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
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	mov	x19, x5
	mov	x21, x4
	mov	x20, x3
	mov	x23, x2
	mov	x24, x1
	mov	x22, x0
Lloh0:
	adrp	x8, _CFG_WRRD_TYPE_0@GOTPAGE
Lloh1:
	ldr	x8, [x8, _CFG_WRRD_TYPE_0@GOTPAGEOFF]
Lloh2:
	ldr	w0, [x8]
Lloh3:
	adrp	x8, _CFG_RD_FMT@GOTPAGE
Lloh4:
	ldr	x8, [x8, _CFG_RD_FMT@GOTPAGEOFF]
Lloh5:
	ldr	w1, [x8]
	bl	_CFG_HEADER_DW0
	ldr	x8, [x22]
Lloh6:
	adrp	x9, _PCIE_CFG_HEADER0@GOTPAGE
Lloh7:
	ldr	x9, [x9, _PCIE_CFG_HEADER0@GOTPAGEOFF]
Lloh8:
	ldr	x9, [x9]
	add	x1, x9, x8
	bl	_writel
	mov	x0, x20
	mov	x1, x21
	bl	_CFG_HEADER_DW1
	ldr	x8, [x22]
Lloh9:
	adrp	x9, _PCIE_CFG_HEADER1@GOTPAGE
Lloh10:
	ldr	x9, [x9, _PCIE_CFG_HEADER1@GOTPAGEOFF]
Lloh11:
	ldr	x9, [x9]
	add	x1, x9, x8
	bl	_writel
	mov	x0, x23
	bl	_PCI_FUNC
	mov	x25, x0
	mov	x0, x23
	bl	_PCI_SLOT
	mov	x2, x0
	mov	x0, x20
	mov	x1, x25
	mov	x3, x24
	bl	_CFG_HEADER_DW2
	ldr	x8, [x22]
Lloh12:
	adrp	x9, _PCIE_CFG_HEADER2@GOTPAGE
Lloh13:
	ldr	x9, [x9, _PCIE_CFG_HEADER2@GOTPAGEOFF]
Lloh14:
	ldr	x9, [x9]
	add	x1, x9, x8
	bl	_writel
	ldr	x8, [x22]
Lloh15:
	adrp	x23, _PCIE_APP_TLP_REQ@GOTPAGE
Lloh16:
	ldr	x23, [x23, _PCIE_APP_TLP_REQ@GOTPAGEOFF]
	ldr	x9, [x23]
	add	x0, x9, x8
	bl	_readl
Lloh17:
	adrp	x8, _APP_CFG_REQ@GOTPAGE
Lloh18:
	ldr	x8, [x8, _APP_CFG_REQ@GOTPAGEOFF]
Lloh19:
	ldr	w8, [x8]
	orr	w0, w8, w0
	ldr	x8, [x22]
	ldr	x9, [x23]
	add	x1, x9, x8
	bl	_writel
	mov	x0, x22
	bl	_mtk_pcie_check_cfg_cpld
	cbz	x0, LBB0_2
; %bb.1:
Lloh20:
	adrp	x8, _PCIBIOS_SET_FAILED@GOTPAGE
Lloh21:
	ldr	x8, [x8, _PCIBIOS_SET_FAILED@GOTPAGEOFF]
	b	LBB0_8
LBB0_2:
	ldr	x8, [x22]
Lloh22:
	adrp	x9, _PCIE_CFG_RDATA@GOTPAGE
Lloh23:
	ldr	x9, [x9, _PCIE_CFG_RDATA@GOTPAGEOFF]
Lloh24:
	ldr	x9, [x9]
	add	x0, x9, x8
	bl	_readl
	str	w0, [x19]
	cmp	w21, #1
	b.eq	LBB0_5
; %bb.3:
	cmp	w21, #2
	b.ne	LBB0_7
; %bb.4:
	mov	w8, #65535
	b	LBB0_6
LBB0_5:
	mov	w8, #255
LBB0_6:
	ubfiz	w9, w20, #3, #2
	asr	w9, w0, w9
	and	w8, w9, w8
	str	w8, [x19]
LBB0_7:
Lloh25:
	adrp	x8, _PCIBIOS_SUCCESSFUL@GOTPAGE
Lloh26:
	ldr	x8, [x8, _PCIBIOS_SUCCESSFUL@GOTPAGEOFF]
LBB0_8:
	ldr	w0, [x8]
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp], #80             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpLdrGot	Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh20, Lloh21
	.loh AdrpLdrGotLdr	Lloh22, Lloh23, Lloh24
	.loh AdrpLdrGot	Lloh25, Lloh26
	.cfi_endproc
                                        ; -- End function
	.comm	_CFG_WRRD_TYPE_0,4,2            ; @CFG_WRRD_TYPE_0
	.comm	_CFG_RD_FMT,4,2                 ; @CFG_RD_FMT
	.comm	_PCIE_CFG_HEADER0,8,3           ; @PCIE_CFG_HEADER0
	.comm	_PCIE_CFG_HEADER1,8,3           ; @PCIE_CFG_HEADER1
	.comm	_PCIE_CFG_HEADER2,8,3           ; @PCIE_CFG_HEADER2
	.comm	_PCIE_APP_TLP_REQ,8,3           ; @PCIE_APP_TLP_REQ
	.comm	_APP_CFG_REQ,4,2                ; @APP_CFG_REQ
	.comm	_PCIBIOS_SET_FAILED,4,2         ; @PCIBIOS_SET_FAILED
	.comm	_PCIE_CFG_RDATA,8,3             ; @PCIE_CFG_RDATA
	.comm	_PCIBIOS_SUCCESSFUL,4,2         ; @PCIBIOS_SUCCESSFUL
	.no_dead_strip	_mtk_pcie_hw_rd_cfg
.subsections_via_symbols
