	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mt7615_load_patch
_mt7615_load_patch:                     ## @mt7615_load_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	%rbx
	pushq	%rax
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %r14
	movq	$0, -32(%rbp)
	movl	$1, %esi
	callq	_mt7615_mcu_patch_sem_ctrl
	cmpl	$129, %eax
	je	LBB0_3
## %bb.1:
	xorl	%ebx, %ebx
	cmpl	$130, %eax
	je	LBB0_18
## %bb.2:
	movl	(%r14), %edi
	leaq	L_.str(%rip), %rsi
	callq	_dev_err
	movq	_EAGAIN@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_18
LBB0_3:
	movq	_MT7615_ROM_PATCH@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	(%r14), %edx
	leaq	-32(%rbp), %rdi
	callq	_request_firmware
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_16
## %bb.4:
	movq	-32(%rbp), %rax
	testq	%rax, %rax
	je	LBB0_7
## %bb.5:
	movq	8(%rax), %rbx
	testq	%rbx, %rbx
	je	LBB0_7
## %bb.6:
	cmpl	$7, (%rax)
	ja	LBB0_8
LBB0_7:
	movl	(%r14), %edi
	leaq	L_.str.1(%rip), %rsi
	callq	_dev_err
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
LBB0_16:
	movq	-32(%rbp), %rdi
	callq	_release_firmware
	xorl	%r15d, %r15d
	movq	%r14, %rdi
	xorl	%esi, %esi
	callq	_mt7615_mcu_patch_sem_ctrl
	cmpl	$128, %eax
	je	LBB0_18
## %bb.17:
	movq	_EAGAIN@GOTPCREL(%rip), %rax
	subl	(%rax), %r15d
	movl	(%r14), %edi
	leaq	L_.str.6(%rip), %rsi
	callq	_dev_err
	movl	%r15d, %ebx
LBB0_18:
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_8:
	movl	(%r14), %r15d
	movl	4(%rbx), %edi
	callq	_be32_to_cpu
	movl	(%rbx), %ecx
	leaq	L_.str.2(%rip), %rsi
	movl	%r15d, %edi
	movl	%eax, %edx
	callq	_dev_info
	movq	-32(%rbp), %rax
	movl	(%rax), %r15d
	addl	$-8, %r15d
	movq	_MCU_PATCH_ADDRESS@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_DL_MODE_NEED_RSP@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movq	%r14, %rdi
	movl	%r15d, %edx
	callq	_mt7615_mcu_init_download
	testl	%eax, %eax
	je	LBB0_10
## %bb.9:
	movl	%eax, %ebx
	movl	(%r14), %edi
	leaq	L_.str.3(%rip), %rsi
	jmp	LBB0_15
LBB0_10:
	movq	-32(%rbp), %rax
	movq	8(%rax), %rsi
	addq	$8, %rsi
	movq	%r14, %rdi
	movl	%r15d, %edx
	callq	_mt7615_mcu_send_firmware
	testl	%eax, %eax
	je	LBB0_12
## %bb.11:
	movl	%eax, %ebx
	movl	(%r14), %edi
	leaq	L_.str.4(%rip), %rsi
	jmp	LBB0_15
LBB0_12:
	movq	%r14, %rdi
	callq	_mt7615_mcu_start_patch
	testl	%eax, %eax
	je	LBB0_13
## %bb.14:
	movl	%eax, %ebx
	movl	(%r14), %edi
	leaq	L_.str.5(%rip), %rsi
LBB0_15:
	callq	_dev_err
	jmp	LBB0_16
LBB0_13:
	xorl	%ebx, %ebx
	jmp	LBB0_16
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Failed to get patch semaphore\n"

	.comm	_EAGAIN,4,2                     ## @EAGAIN
	.comm	_MT7615_ROM_PATCH,4,2           ## @MT7615_ROM_PATCH
L_.str.1:                               ## @.str.1
	.asciz	"Invalid firmware\n"

	.comm	_EINVAL,4,2                     ## @EINVAL
L_.str.2:                               ## @.str.2
	.asciz	"HW/SW Version: 0x%x, Build Time: %.16s\n"

	.comm	_MCU_PATCH_ADDRESS,4,2          ## @MCU_PATCH_ADDRESS
	.comm	_DL_MODE_NEED_RSP,4,2           ## @DL_MODE_NEED_RSP
L_.str.3:                               ## @.str.3
	.asciz	"Download request failed\n"

L_.str.4:                               ## @.str.4
	.asciz	"Failed to send firmware to device\n"

L_.str.5:                               ## @.str.5
	.asciz	"Failed to start patch\n"

L_.str.6:                               ## @.str.6
	.asciz	"Failed to release patch semaphore\n"

	.no_dead_strip	_mt7615_load_patch
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mt7615_load_patch
_mt7615_load_patch:                     ; @mt7615_load_patch
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #64
	.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
	mov	x19, x0
	str	xzr, [sp, #8]
	mov	w1, #1
	bl	_mt7615_mcu_patch_sem_ctrl
	cmp	w0, #129
	b.eq	LBB0_3
; %bb.1:
	cmp	w0, #130
	b.ne	LBB0_10
; %bb.2:
	mov	w20, #0
	b	LBB0_11
LBB0_3:
Lloh0:
	adrp	x8, _MT7615_ROM_PATCH@GOTPAGE
Lloh1:
	ldr	x8, [x8, _MT7615_ROM_PATCH@GOTPAGEOFF]
Lloh2:
	ldr	w1, [x8]
	ldr	w2, [x19]
	add	x0, sp, #8
	bl	_request_firmware
	mov	x20, x0
	cbnz	w0, LBB0_8
; %bb.4:
	ldr	x8, [sp, #8]
	cbz	x8, LBB0_7
; %bb.5:
	ldr	x21, [x8, #8]
	cbz	x21, LBB0_7
; %bb.6:
	ldr	w8, [x8]
	cmp	w8, #7
	b.hi	LBB0_12
LBB0_7:
	ldr	w0, [x19]
Lloh3:
	adrp	x1, l_.str.1@PAGE
Lloh4:
	add	x1, x1, l_.str.1@PAGEOFF
	bl	_dev_err
Lloh5:
	adrp	x8, _EINVAL@GOTPAGE
Lloh6:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh7:
	ldr	w8, [x8]
	neg	w20, w8
LBB0_8:
	ldr	x0, [sp, #8]
	bl	_release_firmware
	mov	x0, x19
	mov	w1, #0
	bl	_mt7615_mcu_patch_sem_ctrl
	cmp	w0, #128
	b.eq	LBB0_11
; %bb.9:
Lloh8:
	adrp	x8, _EAGAIN@GOTPAGE
Lloh9:
	ldr	x8, [x8, _EAGAIN@GOTPAGEOFF]
Lloh10:
	ldr	w8, [x8]
	neg	w20, w8
	ldr	w0, [x19]
Lloh11:
	adrp	x1, l_.str.6@PAGE
Lloh12:
	add	x1, x1, l_.str.6@PAGEOFF
	bl	_dev_err
	b	LBB0_11
LBB0_10:
	ldr	w0, [x19]
Lloh13:
	adrp	x1, l_.str@PAGE
Lloh14:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_err
Lloh15:
	adrp	x8, _EAGAIN@GOTPAGE
Lloh16:
	ldr	x8, [x8, _EAGAIN@GOTPAGEOFF]
Lloh17:
	ldr	w8, [x8]
	neg	w20, w8
LBB0_11:
	mov	x0, x20
	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
	add	sp, sp, #64
	ret
LBB0_12:
	ldr	w20, [x19]
	ldr	w0, [x21, #4]
	bl	_be32_to_cpu
	mov	x2, x0
	ldr	w3, [x21]
Lloh18:
	adrp	x1, l_.str.2@PAGE
Lloh19:
	add	x1, x1, l_.str.2@PAGEOFF
	mov	x0, x20
	bl	_dev_info
	ldr	x8, [sp, #8]
	ldr	w8, [x8]
	sub	w21, w8, #8
Lloh20:
	adrp	x8, _MCU_PATCH_ADDRESS@GOTPAGE
Lloh21:
	ldr	x8, [x8, _MCU_PATCH_ADDRESS@GOTPAGEOFF]
Lloh22:
	ldr	w1, [x8]
Lloh23:
	adrp	x8, _DL_MODE_NEED_RSP@GOTPAGE
Lloh24:
	ldr	x8, [x8, _DL_MODE_NEED_RSP@GOTPAGEOFF]
Lloh25:
	ldr	w3, [x8]
	mov	x0, x19
	mov	x2, x21
	bl	_mt7615_mcu_init_download
	cbz	w0, LBB0_14
; %bb.13:
	mov	x20, x0
	ldr	w0, [x19]
Lloh26:
	adrp	x1, l_.str.3@PAGE
Lloh27:
	add	x1, x1, l_.str.3@PAGEOFF
	b	LBB0_18
LBB0_14:
	ldr	x8, [sp, #8]
	ldr	x8, [x8, #8]
	add	x1, x8, #8
	mov	x0, x19
	mov	x2, x21
	bl	_mt7615_mcu_send_firmware
	cbz	w0, LBB0_16
; %bb.15:
	mov	x20, x0
	ldr	w0, [x19]
Lloh28:
	adrp	x1, l_.str.4@PAGE
Lloh29:
	add	x1, x1, l_.str.4@PAGEOFF
	b	LBB0_18
LBB0_16:
	mov	x0, x19
	bl	_mt7615_mcu_start_patch
	mov	x20, x0
	cbz	w0, LBB0_8
; %bb.17:
	ldr	w0, [x19]
Lloh30:
	adrp	x1, l_.str.5@PAGE
Lloh31:
	add	x1, x1, l_.str.5@PAGEOFF
LBB0_18:
	bl	_dev_err
	b	LBB0_8
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpAdd	Lloh3, Lloh4
	.loh AdrpAdd	Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpAdd	Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh23, Lloh24, Lloh25
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpAdd	Lloh18, Lloh19
	.loh AdrpAdd	Lloh26, Lloh27
	.loh AdrpAdd	Lloh28, Lloh29
	.loh AdrpAdd	Lloh30, Lloh31
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Failed to get patch semaphore\n"

	.comm	_EAGAIN,4,2                     ; @EAGAIN
	.comm	_MT7615_ROM_PATCH,4,2           ; @MT7615_ROM_PATCH
l_.str.1:                               ; @.str.1
	.asciz	"Invalid firmware\n"

	.comm	_EINVAL,4,2                     ; @EINVAL
l_.str.2:                               ; @.str.2
	.asciz	"HW/SW Version: 0x%x, Build Time: %.16s\n"

	.comm	_MCU_PATCH_ADDRESS,4,2          ; @MCU_PATCH_ADDRESS
	.comm	_DL_MODE_NEED_RSP,4,2           ; @DL_MODE_NEED_RSP
l_.str.3:                               ; @.str.3
	.asciz	"Download request failed\n"

l_.str.4:                               ; @.str.4
	.asciz	"Failed to send firmware to device\n"

l_.str.5:                               ; @.str.5
	.asciz	"Failed to start patch\n"

l_.str.6:                               ; @.str.6
	.asciz	"Failed to release patch semaphore\n"

	.no_dead_strip	_mt7615_load_patch
.subsections_via_symbols
