	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mt76pci_load_rom_patch
_mt76pci_load_rom_patch:                ## @mt76pci_load_rom_patch
	.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, %r15
	movq	$0, -48(%rbp)
	callq	_is_mt7612
	movl	%eax, %r14d
	testl	%eax, %eax
	jne	LBB0_3
## %bb.1:
	movq	_MT_MCU_SEMAPHORE_03@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r15, %rdi
	movl	$1, %edx
	movl	$1, %ecx
	movl	$600, %r8d                      ## imm = 0x258
	callq	_mt76_poll
	testl	%eax, %eax
	je	LBB0_2
LBB0_3:
	movq	%r15, %rdi
	callq	_mt76xx_rev
	movq	_MT76XX_REV_E3@GOTPCREL(%rip), %rcx
	xorl	%edi, %edi
	cmpq	(%rcx), %rax
	setl	%dil
	jge	LBB0_4
## %bb.5:
	movq	_MT_MCU_COM_REG0@GOTPCREL(%rip), %rbx
	jmp	LBB0_6
LBB0_4:
	movq	_MT_MCU_CLOCK_CTL@GOTPCREL(%rip), %rbx
LBB0_6:
	callq	_BIT
	movl	%eax, %r12d
	movl	(%rbx), %r13d
	testl	%r14d, %r14d
	je	LBB0_7
LBB0_9:
	movq	_MT7662_ROM_PATCH@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	(%r15), %edx
	leaq	-48(%rbp), %rdi
	callq	_request_firmware
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_16
## %bb.10:
	movq	-48(%rbp), %rcx
	testq	%rcx, %rcx
	je	LBB0_13
## %bb.11:
	movq	8(%rcx), %rax
	testq	%rax, %rax
	je	LBB0_13
## %bb.12:
	cmpl	$4, (%rcx)
	ja	LBB0_14
LBB0_13:
	movq	_EIO@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	movl	(%r15), %edi
	leaq	L_.str.2(%rip), %rsi
	callq	_dev_err
LBB0_16:
	testl	%r14d, %r14d
	jne	LBB0_18
	jmp	LBB0_17
LBB0_7:
	movq	%r15, %rdi
	movl	%r13d, %esi
	callq	_mt76_rr
	testl	%r12d, %eax
	je	LBB0_9
## %bb.8:
	movl	(%r15), %edi
	leaq	L_.str.1(%rip), %rsi
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_dev_info
LBB0_17:
	movq	_MT_MCU_SEMAPHORE_03@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r15, %rdi
	movl	$1, %edx
	callq	_mt76_wr
LBB0_18:
	movq	-48(%rbp), %rdi
	callq	_release_firmware
LBB0_19:
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_2:
	movl	(%r15), %edi
	leaq	L_.str(%rip), %rsi
	callq	_dev_err
	movq	_ETIMEDOUT@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_19
LBB0_14:
	movl	(%r15), %edi
	movl	(%rax), %edx
	leaq	L_.str.3(%rip), %rsi
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_dev_info
	movq	_MT_MCU_PCIE_REMAP_BASE4@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_MT_MCU_ROM_PATCH_OFFSET@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r15, %rdi
	callq	_mt76_wr
	movq	-48(%rbp), %rax
	movq	8(%rax), %rdx
	addq	$4, %rdx
	movl	(%rax), %ecx
	addl	$-4, %ecx
	movq	_MT_MCU_ROM_PATCH_ADDR@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r15, %rdi
	callq	_mt76_wr_copy
	movq	_MT_MCU_PCIE_REMAP_BASE4@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r15, %rdi
	xorl	%edx, %edx
	callq	_mt76_wr
	movq	_MT_MCU_INT_LEVEL@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	%r15, %rdi
	movl	$4, %edx
	callq	_mt76_wr
	movq	%r15, %rdi
	movl	%r13d, %esi
	movl	%r12d, %edx
	movl	%r12d, %ecx
	movl	$2000, %r8d                     ## imm = 0x7D0
	callq	_mt76_poll_msec
	testl	%eax, %eax
	jne	LBB0_16
## %bb.15:
	movl	(%r15), %edi
	leaq	L_.str.4(%rip), %rsi
	callq	_dev_err
	movq	_ETIMEDOUT@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_16
	.cfi_endproc
                                        ## -- End function
	.comm	_MT_MCU_SEMAPHORE_03,4,2        ## @MT_MCU_SEMAPHORE_03
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Could not get hardware semaphore for ROM PATCH\n"

	.comm	_ETIMEDOUT,4,2                  ## @ETIMEDOUT
	.comm	_MT76XX_REV_E3,8,3              ## @MT76XX_REV_E3
	.comm	_MT_MCU_CLOCK_CTL,4,2           ## @MT_MCU_CLOCK_CTL
	.comm	_MT_MCU_COM_REG0,4,2            ## @MT_MCU_COM_REG0
L_.str.1:                               ## @.str.1
	.asciz	"ROM patch already applied\n"

	.comm	_MT7662_ROM_PATCH,4,2           ## @MT7662_ROM_PATCH
	.comm	_EIO,4,2                        ## @EIO
L_.str.2:                               ## @.str.2
	.asciz	"Failed to load firmware\n"

L_.str.3:                               ## @.str.3
	.asciz	"ROM patch build: %.15s\n"

	.comm	_MT_MCU_PCIE_REMAP_BASE4,4,2    ## @MT_MCU_PCIE_REMAP_BASE4
	.comm	_MT_MCU_ROM_PATCH_OFFSET,4,2    ## @MT_MCU_ROM_PATCH_OFFSET
	.comm	_MT_MCU_ROM_PATCH_ADDR,4,2      ## @MT_MCU_ROM_PATCH_ADDR
	.comm	_MT_MCU_INT_LEVEL,4,2           ## @MT_MCU_INT_LEVEL
L_.str.4:                               ## @.str.4
	.asciz	"Failed to load ROM patch\n"

	.no_dead_strip	_mt76pci_load_rom_patch
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mt76pci_load_rom_patch
_mt76pci_load_rom_patch:                ; @mt76pci_load_rom_patch
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #80
	.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
	mov	x19, x0
	str	xzr, [sp, #8]
	bl	_is_mt7612
	mov	x20, x0
	cbnz	w0, LBB0_2
; %bb.1:
Lloh0:
	adrp	x8, _MT_MCU_SEMAPHORE_03@GOTPAGE
Lloh1:
	ldr	x8, [x8, _MT_MCU_SEMAPHORE_03@GOTPAGEOFF]
Lloh2:
	ldr	w1, [x8]
	mov	x0, x19
	mov	w2, #1
	mov	w3, #1
	mov	w4, #600
	bl	_mt76_poll
	cbz	w0, LBB0_14
LBB0_2:
	mov	x0, x19
	bl	_mt76xx_rev
Lloh3:
	adrp	x8, _MT76XX_REV_E3@GOTPAGE
Lloh4:
	ldr	x8, [x8, _MT76XX_REV_E3@GOTPAGEOFF]
Lloh5:
	ldr	x8, [x8]
	cmp	x0, x8
	cset	w0, lt
Lloh6:
	adrp	x8, _MT_MCU_COM_REG0@GOTPAGE
Lloh7:
	ldr	x8, [x8, _MT_MCU_COM_REG0@GOTPAGEOFF]
Lloh8:
	adrp	x9, _MT_MCU_CLOCK_CTL@GOTPAGE
Lloh9:
	ldr	x9, [x9, _MT_MCU_CLOCK_CTL@GOTPAGEOFF]
	csel	x22, x8, x9, lt
	bl	_BIT
	mov	x21, x0
	ldr	w22, [x22]
	cbz	w20, LBB0_9
LBB0_3:
Lloh10:
	adrp	x8, _MT7662_ROM_PATCH@GOTPAGE
Lloh11:
	ldr	x8, [x8, _MT7662_ROM_PATCH@GOTPAGEOFF]
Lloh12:
	ldr	w1, [x8]
	ldr	w2, [x19]
	add	x0, sp, #8
	bl	_request_firmware
	mov	x23, x0
	cbnz	w0, LBB0_8
; %bb.4:
	ldr	x9, [sp, #8]
	cbz	x9, LBB0_7
; %bb.5:
	ldr	x8, [x9, #8]
	cbz	x8, LBB0_7
; %bb.6:
	ldr	w9, [x9]
	cmp	w9, #4
	b.hi	LBB0_15
LBB0_7:
Lloh13:
	adrp	x8, _EIO@GOTPAGE
Lloh14:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
Lloh15:
	ldr	w8, [x8]
	neg	w23, w8
	ldr	w0, [x19]
Lloh16:
	adrp	x1, l_.str.2@PAGE
Lloh17:
	add	x1, x1, l_.str.2@PAGEOFF
	bl	_dev_err
LBB0_8:
	cbnz	w20, LBB0_12
	b	LBB0_11
LBB0_9:
	mov	x0, x19
	mov	x1, x22
	bl	_mt76_rr
	tst	w0, w21
	b.eq	LBB0_3
; %bb.10:
	ldr	w0, [x19]
Lloh18:
	adrp	x1, l_.str.1@PAGE
Lloh19:
	add	x1, x1, l_.str.1@PAGEOFF
	bl	_dev_info
	mov	w23, #0
LBB0_11:
Lloh20:
	adrp	x8, _MT_MCU_SEMAPHORE_03@GOTPAGE
Lloh21:
	ldr	x8, [x8, _MT_MCU_SEMAPHORE_03@GOTPAGEOFF]
Lloh22:
	ldr	w1, [x8]
	mov	x0, x19
	mov	w2, #1
	bl	_mt76_wr
LBB0_12:
	ldr	x0, [sp, #8]
	bl	_release_firmware
LBB0_13:
	mov	x0, x23
	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
	add	sp, sp, #80
	ret
LBB0_14:
	ldr	w0, [x19]
Lloh23:
	adrp	x1, l_.str@PAGE
Lloh24:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_err
Lloh25:
	adrp	x8, _ETIMEDOUT@GOTPAGE
Lloh26:
	ldr	x8, [x8, _ETIMEDOUT@GOTPAGEOFF]
Lloh27:
	ldr	w8, [x8]
	neg	w23, w8
	b	LBB0_13
LBB0_15:
	ldr	w0, [x19]
	ldr	w8, [x8]
	str	x8, [sp]
Lloh28:
	adrp	x1, l_.str.3@PAGE
Lloh29:
	add	x1, x1, l_.str.3@PAGEOFF
	bl	_dev_info
Lloh30:
	adrp	x23, _MT_MCU_PCIE_REMAP_BASE4@GOTPAGE
Lloh31:
	ldr	x23, [x23, _MT_MCU_PCIE_REMAP_BASE4@GOTPAGEOFF]
	ldr	w1, [x23]
Lloh32:
	adrp	x8, _MT_MCU_ROM_PATCH_OFFSET@GOTPAGE
Lloh33:
	ldr	x8, [x8, _MT_MCU_ROM_PATCH_OFFSET@GOTPAGEOFF]
Lloh34:
	ldr	w2, [x8]
	mov	x0, x19
	bl	_mt76_wr
	ldr	x8, [sp, #8]
	ldr	x9, [x8, #8]
	add	x2, x9, #4
	ldr	w8, [x8]
	sub	w3, w8, #4
Lloh35:
	adrp	x8, _MT_MCU_ROM_PATCH_ADDR@GOTPAGE
Lloh36:
	ldr	x8, [x8, _MT_MCU_ROM_PATCH_ADDR@GOTPAGEOFF]
Lloh37:
	ldr	w1, [x8]
	mov	x0, x19
	bl	_mt76_wr_copy
	ldr	w1, [x23]
	mov	x0, x19
	mov	w2, #0
	bl	_mt76_wr
Lloh38:
	adrp	x8, _MT_MCU_INT_LEVEL@GOTPAGE
Lloh39:
	ldr	x8, [x8, _MT_MCU_INT_LEVEL@GOTPAGEOFF]
Lloh40:
	ldr	w1, [x8]
	mov	x0, x19
	mov	w2, #4
	bl	_mt76_wr
	mov	x0, x19
	mov	x1, x22
	mov	x2, x21
	mov	x3, x21
	mov	w4, #2000
	bl	_mt76_poll_msec
	mov	w23, #0
	cbnz	w0, LBB0_8
; %bb.16:
	ldr	w0, [x19]
Lloh41:
	adrp	x1, l_.str.4@PAGE
Lloh42:
	add	x1, x1, l_.str.4@PAGEOFF
	bl	_dev_err
Lloh43:
	adrp	x8, _ETIMEDOUT@GOTPAGE
Lloh44:
	ldr	x8, [x8, _ETIMEDOUT@GOTPAGEOFF]
Lloh45:
	ldr	w8, [x8]
	neg	w23, w8
	b	LBB0_8
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpAdd	Lloh16, Lloh17
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpAdd	Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh25, Lloh26, Lloh27
	.loh AdrpAdd	Lloh23, Lloh24
	.loh AdrpLdrGotLdr	Lloh38, Lloh39, Lloh40
	.loh AdrpLdrGotLdr	Lloh35, Lloh36, Lloh37
	.loh AdrpLdrGotLdr	Lloh32, Lloh33, Lloh34
	.loh AdrpLdrGot	Lloh30, Lloh31
	.loh AdrpAdd	Lloh28, Lloh29
	.loh AdrpLdrGotLdr	Lloh43, Lloh44, Lloh45
	.loh AdrpAdd	Lloh41, Lloh42
	.cfi_endproc
                                        ; -- End function
	.comm	_MT_MCU_SEMAPHORE_03,4,2        ; @MT_MCU_SEMAPHORE_03
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Could not get hardware semaphore for ROM PATCH\n"

	.comm	_ETIMEDOUT,4,2                  ; @ETIMEDOUT
	.comm	_MT76XX_REV_E3,8,3              ; @MT76XX_REV_E3
	.comm	_MT_MCU_CLOCK_CTL,4,2           ; @MT_MCU_CLOCK_CTL
	.comm	_MT_MCU_COM_REG0,4,2            ; @MT_MCU_COM_REG0
l_.str.1:                               ; @.str.1
	.asciz	"ROM patch already applied\n"

	.comm	_MT7662_ROM_PATCH,4,2           ; @MT7662_ROM_PATCH
	.comm	_EIO,4,2                        ; @EIO
l_.str.2:                               ; @.str.2
	.asciz	"Failed to load firmware\n"

l_.str.3:                               ; @.str.3
	.asciz	"ROM patch build: %.15s\n"

	.comm	_MT_MCU_PCIE_REMAP_BASE4,4,2    ; @MT_MCU_PCIE_REMAP_BASE4
	.comm	_MT_MCU_ROM_PATCH_OFFSET,4,2    ; @MT_MCU_ROM_PATCH_OFFSET
	.comm	_MT_MCU_ROM_PATCH_ADDR,4,2      ; @MT_MCU_ROM_PATCH_ADDR
	.comm	_MT_MCU_INT_LEVEL,4,2           ; @MT_MCU_INT_LEVEL
l_.str.4:                               ; @.str.4
	.asciz	"Failed to load ROM patch\n"

	.no_dead_strip	_mt76pci_load_rom_patch
.subsections_via_symbols
