	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function spear_smi_erase_sector
_spear_smi_erase_sector:                ## @spear_smi_erase_sector
	.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
	movl	%ecx, %r12d
	movl	%edx, %r14d
	movl	%esi, %ebx
	movq	%rdi, %r13
	movq	_SMI_MAX_TIME_OUT@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	callq	_spear_smi_wait_till_ready
	movl	%eax, %r15d
	testl	%eax, %eax
	jne	LBB0_6
## %bb.1:
	movq	%r13, %rdi
	movl	%ebx, %esi
	callq	_spear_smi_write_enable
	movl	%eax, %r15d
	testl	%eax, %eax
	jne	LBB0_6
## %bb.2:
	leaq	4(%r13), %rdi
	movq	%rdi, -56(%rbp)                 ## 8-byte Spill
	callq	_mutex_lock
	movq	_SMI_CR1@GOTPCREL(%rip), %r15
	movq	(%r15), %rdi
	addq	8(%r13), %rdi
	callq	_readl
	movl	%eax, %ecx
	movq	_SW_MODE@GOTPCREL(%rip), %rax
	movl	%ecx, -44(%rbp)                 ## 4-byte Spill
	orl	(%rax), %ecx
	movq	_WB_MODE@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	notl	%edi
	andl	%ecx, %edi
	movq	(%r15), %rsi
	addq	8(%r13), %rsi
	callq	_writel
	movq	_SMI_TR@GOTPCREL(%rip), %rax
	movq	(%rax), %rsi
	addq	8(%r13), %rsi
	movl	%r14d, %edi
	callq	_writel
	movq	_BANK_SHIFT@GOTPCREL(%rip), %rax
	movb	(%rax), %cl
	shll	%cl, %ebx
	movq	_SEND@GOTPCREL(%rip), %rax
	orl	(%rax), %ebx
	movq	_TFIE@GOTPCREL(%rip), %rax
	orl	(%rax), %ebx
	movq	_TX_LEN_SHIFT@GOTPCREL(%rip), %rax
	movb	(%rax), %cl
	shll	%cl, %r12d
	orl	%ebx, %r12d
	movq	_SMI_CR2@GOTPCREL(%rip), %rbx
	movq	(%rbx), %rsi
	addq	8(%r13), %rsi
	movl	%r12d, %edi
	callq	_writel
	movl	24(%r13), %edi
	movq	_TFF@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	andl	(%r13), %esi
	movq	_SMI_CMD_TIMEOUT@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	callq	_wait_event_interruptible_timeout
	testl	%eax, %eax
	je	LBB0_3
## %bb.4:
	movl	%eax, %r15d
	sarl	$31, %r15d
	andl	%eax, %r15d
	jmp	LBB0_5
LBB0_3:
	movq	_EIO@GOTPCREL(%rip), %rax
	xorl	%r15d, %r15d
	subl	(%rax), %r15d
	movq	16(%r13), %rdi
	leaq	L_.str(%rip), %rsi
	callq	_dev_err
LBB0_5:
	movq	_SMI_CR1@GOTPCREL(%rip), %rax
	movq	(%rax), %rsi
	addq	8(%r13), %rsi
	movl	-44(%rbp), %edi                 ## 4-byte Reload
	callq	_writel
	movq	(%rbx), %rsi
	addq	8(%r13), %rsi
	xorl	%edi, %edi
	callq	_writel
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	callq	_mutex_unlock
LBB0_6:
	movl	%r15d, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_SMI_MAX_TIME_OUT,4,2           ## @SMI_MAX_TIME_OUT
	.comm	_SMI_CR1,8,3                    ## @SMI_CR1
	.comm	_SW_MODE,4,2                    ## @SW_MODE
	.comm	_WB_MODE,4,2                    ## @WB_MODE
	.comm	_SMI_TR,8,3                     ## @SMI_TR
	.comm	_BANK_SHIFT,4,2                 ## @BANK_SHIFT
	.comm	_SEND,4,2                       ## @SEND
	.comm	_TFIE,4,2                       ## @TFIE
	.comm	_TX_LEN_SHIFT,4,2               ## @TX_LEN_SHIFT
	.comm	_SMI_CR2,8,3                    ## @SMI_CR2
	.comm	_TFF,4,2                        ## @TFF
	.comm	_SMI_CMD_TIMEOUT,4,2            ## @SMI_CMD_TIMEOUT
	.comm	_EIO,4,2                        ## @EIO
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"sector erase failed\n"

	.no_dead_strip	_spear_smi_erase_sector
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function spear_smi_erase_sector
_spear_smi_erase_sector:                ; @spear_smi_erase_sector
	.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	x22, x3
	mov	x24, x2
	mov	x23, x1
	mov	x19, x0
Lloh0:
	adrp	x8, _SMI_MAX_TIME_OUT@GOTPAGE
Lloh1:
	ldr	x8, [x8, _SMI_MAX_TIME_OUT@GOTPAGEOFF]
Lloh2:
	ldr	w2, [x8]
	bl	_spear_smi_wait_till_ready
	mov	x25, x0
	cbnz	w0, LBB0_6
; %bb.1:
	mov	x0, x19
	mov	x1, x23
	bl	_spear_smi_write_enable
	mov	x25, x0
	cbnz	w0, LBB0_6
; %bb.2:
	add	x20, x19, #4
	mov	x0, x20
	bl	_mutex_lock
	ldr	x8, [x19, #8]
Lloh3:
	adrp	x26, _SMI_CR1@GOTPAGE
Lloh4:
	ldr	x26, [x26, _SMI_CR1@GOTPAGEOFF]
	ldr	x9, [x26]
	add	x0, x9, x8
	bl	_readl
	mov	x21, x0
Lloh5:
	adrp	x8, _SW_MODE@GOTPAGE
Lloh6:
	ldr	x8, [x8, _SW_MODE@GOTPAGEOFF]
Lloh7:
	ldr	w8, [x8]
Lloh8:
	adrp	x9, _WB_MODE@GOTPAGE
Lloh9:
	ldr	x9, [x9, _WB_MODE@GOTPAGEOFF]
	orr	w8, w8, w0
Lloh10:
	ldr	w9, [x9]
	bic	w0, w8, w9
	ldr	x8, [x19, #8]
	ldr	x9, [x26]
	add	x1, x9, x8
	bl	_writel
	ldr	x8, [x19, #8]
Lloh11:
	adrp	x9, _SMI_TR@GOTPAGE
Lloh12:
	ldr	x9, [x9, _SMI_TR@GOTPAGEOFF]
Lloh13:
	ldr	x9, [x9]
	add	x1, x9, x8
	mov	x0, x24
	bl	_writel
Lloh14:
	adrp	x8, _BANK_SHIFT@GOTPAGE
Lloh15:
	ldr	x8, [x8, _BANK_SHIFT@GOTPAGEOFF]
Lloh16:
	ldr	w8, [x8]
	lsl	w8, w23, w8
Lloh17:
	adrp	x9, _SEND@GOTPAGE
Lloh18:
	ldr	x9, [x9, _SEND@GOTPAGEOFF]
Lloh19:
	ldr	w9, [x9]
	orr	w8, w8, w9
Lloh20:
	adrp	x9, _TFIE@GOTPAGE
Lloh21:
	ldr	x9, [x9, _TFIE@GOTPAGEOFF]
Lloh22:
	ldr	w9, [x9]
	orr	w8, w8, w9
Lloh23:
	adrp	x9, _TX_LEN_SHIFT@GOTPAGE
Lloh24:
	ldr	x9, [x9, _TX_LEN_SHIFT@GOTPAGEOFF]
Lloh25:
	ldr	w9, [x9]
	lsl	w9, w22, w9
	orr	w0, w8, w9
	ldr	x8, [x19, #8]
Lloh26:
	adrp	x22, _SMI_CR2@GOTPAGE
Lloh27:
	ldr	x22, [x22, _SMI_CR2@GOTPAGEOFF]
	ldr	x9, [x22]
	add	x1, x9, x8
	bl	_writel
	ldr	w0, [x19, #24]
Lloh28:
	adrp	x8, _TFF@GOTPAGE
Lloh29:
	ldr	x8, [x8, _TFF@GOTPAGEOFF]
	ldr	w9, [x19]
Lloh30:
	ldr	w8, [x8]
	and	w1, w8, w9
Lloh31:
	adrp	x8, _SMI_CMD_TIMEOUT@GOTPAGE
Lloh32:
	ldr	x8, [x8, _SMI_CMD_TIMEOUT@GOTPAGEOFF]
Lloh33:
	ldr	w2, [x8]
	bl	_wait_event_interruptible_timeout
	cbz	w0, LBB0_4
; %bb.3:
	cmp	w0, #0
	csel	w25, w0, wzr, lt
	b	LBB0_5
LBB0_4:
Lloh34:
	adrp	x8, _EIO@GOTPAGE
Lloh35:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
Lloh36:
	ldr	w8, [x8]
	neg	w25, w8
	ldr	x0, [x19, #16]
Lloh37:
	adrp	x1, l_.str@PAGE
Lloh38:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_err
LBB0_5:
	ldr	x8, [x19, #8]
	ldr	x9, [x26]
	add	x1, x9, x8
	mov	x0, x21
	bl	_writel
	ldr	x8, [x19, #8]
	ldr	x9, [x22]
	add	x1, x9, x8
	mov	w0, #0
	bl	_writel
	mov	x0, x20
	bl	_mutex_unlock
LBB0_6:
	mov	x0, x25
	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	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh31, Lloh32, Lloh33
	.loh AdrpLdrGotLdr	Lloh28, Lloh29, Lloh30
	.loh AdrpLdrGot	Lloh26, Lloh27
	.loh AdrpLdrGotLdr	Lloh23, Lloh24, Lloh25
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpAdd	Lloh37, Lloh38
	.loh AdrpLdrGotLdr	Lloh34, Lloh35, Lloh36
	.cfi_endproc
                                        ; -- End function
	.comm	_SMI_MAX_TIME_OUT,4,2           ; @SMI_MAX_TIME_OUT
	.comm	_SMI_CR1,8,3                    ; @SMI_CR1
	.comm	_SW_MODE,4,2                    ; @SW_MODE
	.comm	_WB_MODE,4,2                    ; @WB_MODE
	.comm	_SMI_TR,8,3                     ; @SMI_TR
	.comm	_BANK_SHIFT,4,2                 ; @BANK_SHIFT
	.comm	_SEND,4,2                       ; @SEND
	.comm	_TFIE,4,2                       ; @TFIE
	.comm	_TX_LEN_SHIFT,4,2               ; @TX_LEN_SHIFT
	.comm	_SMI_CR2,8,3                    ; @SMI_CR2
	.comm	_TFF,4,2                        ; @TFF
	.comm	_SMI_CMD_TIMEOUT,4,2            ; @SMI_CMD_TIMEOUT
	.comm	_EIO,4,2                        ; @EIO
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"sector erase failed\n"

	.no_dead_strip	_spear_smi_erase_sector
.subsections_via_symbols
