	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function spear_smi_probe_flash
_spear_smi_probe_flash:                 ## @spear_smi_probe_flash
	.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
	movl	%esi, %r12d
	movq	%rdi, %r15
	movq	_SMI_PROBE_TIMEOUT@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	callq	_spear_smi_wait_till_ready
	movl	%eax, %ebx
	testl	%eax, %eax
	jne	LBB0_5
## %bb.1:
	leaq	4(%r15), %r14
	movq	%r14, %rdi
	callq	_mutex_lock
	movl	$0, (%r15)
	movq	_SMI_CR1@GOTPCREL(%rip), %r13
	movq	(%r13), %rdi
	addq	8(%r15), %rdi
	callq	_readl
	movq	_SW_MODE@GOTPCREL(%rip), %rcx
	orl	(%rcx), %eax
	movq	(%r13), %rsi
	addq	8(%r15), %rsi
	movl	%eax, %edi
	callq	_writel
	movq	_OPCODE_RDID@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	_SMI_TR@GOTPCREL(%rip), %rax
	movq	(%rax), %rsi
	addq	8(%r15), %rsi
	callq	_writel
	movq	_BANK_SHIFT@GOTPCREL(%rip), %rax
	movb	(%rax), %cl
	shll	%cl, %r12d
	movq	_SEND@GOTPCREL(%rip), %rax
	orl	(%rax), %r12d
	movq	_TX_LEN_SHIFT@GOTPCREL(%rip), %rax
	movb	(%rax), %al
	btsl	%eax, %r12d
	movq	_RX_LEN_SHIFT@GOTPCREL(%rip), %rax
	movb	(%rax), %cl
	movl	$3, %edi
	shll	%cl, %edi
	orl	%r12d, %edi
	movq	_TFIE@GOTPCREL(%rip), %rax
	orl	(%rax), %edi
	movq	_SMI_CR2@GOTPCREL(%rip), %rax
	movq	(%rax), %rsi
	addq	8(%r15), %rsi
	callq	_writel
	movl	16(%r15), %edi
	movq	_TFF@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	andl	(%r15), %esi
	movq	_SMI_CMD_TIMEOUT@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	callq	_wait_event_interruptible_timeout
	testl	%eax, %eax
	jle	LBB0_2
## %bb.3:
	movq	_SMI_RR@GOTPCREL(%rip), %rax
	movq	(%rax), %rdi
	addq	8(%r15), %rdi
	callq	_readl
	andl	$16777215, %eax                 ## imm = 0xFFFFFF
	movl	%eax, %edi
	callq	_get_flash_index
	movl	%eax, %ebx
	jmp	LBB0_4
LBB0_2:
	movq	_ENODEV@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
LBB0_4:
	movq	(%r13), %rdi
	addq	8(%r15), %rdi
	callq	_readl
	movq	_SW_MODE@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edi
	notl	%edi
	andl	%eax, %edi
	movq	(%r13), %rsi
	addq	8(%r15), %rsi
	callq	_writel
	movq	%r14, %rdi
	callq	_mutex_unlock
LBB0_5:
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_SMI_PROBE_TIMEOUT,4,2          ## @SMI_PROBE_TIMEOUT
	.comm	_SMI_CR1,8,3                    ## @SMI_CR1
	.comm	_SW_MODE,4,2                    ## @SW_MODE
	.comm	_OPCODE_RDID,4,2                ## @OPCODE_RDID
	.comm	_SMI_TR,8,3                     ## @SMI_TR
	.comm	_BANK_SHIFT,4,2                 ## @BANK_SHIFT
	.comm	_SEND,4,2                       ## @SEND
	.comm	_TX_LEN_SHIFT,4,2               ## @TX_LEN_SHIFT
	.comm	_RX_LEN_SHIFT,4,2               ## @RX_LEN_SHIFT
	.comm	_TFIE,4,2                       ## @TFIE
	.comm	_SMI_CR2,8,3                    ## @SMI_CR2
	.comm	_TFF,4,2                        ## @TFF
	.comm	_SMI_CMD_TIMEOUT,4,2            ## @SMI_CMD_TIMEOUT
	.comm	_ENODEV,4,2                     ## @ENODEV
	.comm	_SMI_RR,8,3                     ## @SMI_RR
	.no_dead_strip	_spear_smi_probe_flash
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function spear_smi_probe_flash
_spear_smi_probe_flash:                 ; @spear_smi_probe_flash
	.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, x1
	mov	x19, x0
Lloh0:
	adrp	x8, _SMI_PROBE_TIMEOUT@GOTPAGE
Lloh1:
	ldr	x8, [x8, _SMI_PROBE_TIMEOUT@GOTPAGEOFF]
Lloh2:
	ldr	w2, [x8]
	bl	_spear_smi_wait_till_ready
	mov	x22, x0
	cbnz	w0, LBB0_5
; %bb.1:
	add	x20, x19, #4
	mov	x0, x20
	bl	_mutex_lock
	str	wzr, [x19]
	ldr	x8, [x19, #8]
Lloh3:
	adrp	x23, _SMI_CR1@GOTPAGE
Lloh4:
	ldr	x23, [x23, _SMI_CR1@GOTPAGEOFF]
	ldr	x9, [x23]
	add	x0, x9, x8
	bl	_readl
Lloh5:
	adrp	x24, _SW_MODE@GOTPAGE
Lloh6:
	ldr	x24, [x24, _SW_MODE@GOTPAGEOFF]
	ldr	w8, [x24]
	orr	w0, w8, w0
	ldr	x8, [x19, #8]
	ldr	x9, [x23]
	add	x1, x9, x8
	bl	_writel
Lloh7:
	adrp	x8, _OPCODE_RDID@GOTPAGE
Lloh8:
	ldr	x8, [x8, _OPCODE_RDID@GOTPAGEOFF]
Lloh9:
	ldr	w0, [x8]
	ldr	x8, [x19, #8]
Lloh10:
	adrp	x9, _SMI_TR@GOTPAGE
Lloh11:
	ldr	x9, [x9, _SMI_TR@GOTPAGEOFF]
Lloh12:
	ldr	x9, [x9]
	add	x1, x9, x8
	bl	_writel
Lloh13:
	adrp	x8, _BANK_SHIFT@GOTPAGE
Lloh14:
	ldr	x8, [x8, _BANK_SHIFT@GOTPAGEOFF]
Lloh15:
	ldr	w8, [x8]
Lloh16:
	adrp	x9, _SEND@GOTPAGE
Lloh17:
	ldr	x9, [x9, _SEND@GOTPAGEOFF]
	lsl	w8, w21, w8
Lloh18:
	ldr	w9, [x9]
	orr	w8, w8, w9
Lloh19:
	adrp	x9, _TX_LEN_SHIFT@GOTPAGE
Lloh20:
	ldr	x9, [x9, _TX_LEN_SHIFT@GOTPAGEOFF]
Lloh21:
	ldr	w9, [x9]
	mov	w10, #1
	lsl	w9, w10, w9
	orr	w8, w8, w9
Lloh22:
	adrp	x9, _RX_LEN_SHIFT@GOTPAGE
Lloh23:
	ldr	x9, [x9, _RX_LEN_SHIFT@GOTPAGEOFF]
Lloh24:
	ldr	w9, [x9]
	mov	w10, #3
	lsl	w9, w10, w9
	orr	w8, w8, w9
Lloh25:
	adrp	x9, _TFIE@GOTPAGE
Lloh26:
	ldr	x9, [x9, _TFIE@GOTPAGEOFF]
Lloh27:
	ldr	w9, [x9]
	orr	w0, w8, w9
	ldr	x8, [x19, #8]
Lloh28:
	adrp	x9, _SMI_CR2@GOTPAGE
Lloh29:
	ldr	x9, [x9, _SMI_CR2@GOTPAGEOFF]
Lloh30:
	ldr	x9, [x9]
	add	x1, x9, x8
	bl	_writel
	ldr	w0, [x19, #16]
Lloh31:
	adrp	x8, _TFF@GOTPAGE
Lloh32:
	ldr	x8, [x8, _TFF@GOTPAGEOFF]
	ldr	w9, [x19]
Lloh33:
	ldr	w8, [x8]
	and	w1, w8, w9
Lloh34:
	adrp	x8, _SMI_CMD_TIMEOUT@GOTPAGE
Lloh35:
	ldr	x8, [x8, _SMI_CMD_TIMEOUT@GOTPAGEOFF]
Lloh36:
	ldr	w2, [x8]
	bl	_wait_event_interruptible_timeout
	cmp	w0, #0
	b.le	LBB0_3
; %bb.2:
	ldr	x8, [x19, #8]
Lloh37:
	adrp	x9, _SMI_RR@GOTPAGE
Lloh38:
	ldr	x9, [x9, _SMI_RR@GOTPAGEOFF]
Lloh39:
	ldr	x9, [x9]
	add	x0, x9, x8
	bl	_readl
	and	w0, w0, #0xffffff
	bl	_get_flash_index
	mov	x22, x0
	b	LBB0_4
LBB0_3:
Lloh40:
	adrp	x8, _ENODEV@GOTPAGE
Lloh41:
	ldr	x8, [x8, _ENODEV@GOTPAGEOFF]
Lloh42:
	ldr	w8, [x8]
	neg	w22, w8
LBB0_4:
	ldr	x8, [x19, #8]
	ldr	x9, [x23]
	add	x0, x9, x8
	bl	_readl
	ldr	w8, [x24]
	bic	w0, w0, w8
	ldr	x8, [x19, #8]
	ldr	x9, [x23]
	add	x1, x9, x8
	bl	_writel
	mov	x0, x20
	bl	_mutex_unlock
LBB0_5:
	mov	x0, x22
	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
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh34, Lloh35, Lloh36
	.loh AdrpLdrGotLdr	Lloh31, Lloh32, Lloh33
	.loh AdrpLdrGotLdr	Lloh28, Lloh29, Lloh30
	.loh AdrpLdrGotLdr	Lloh25, Lloh26, Lloh27
	.loh AdrpLdrGotLdr	Lloh22, Lloh23, Lloh24
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpLdrGotLdr	Lloh13, Lloh14, Lloh15
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh37, Lloh38, Lloh39
	.loh AdrpLdrGotLdr	Lloh40, Lloh41, Lloh42
	.cfi_endproc
                                        ; -- End function
	.comm	_SMI_PROBE_TIMEOUT,4,2          ; @SMI_PROBE_TIMEOUT
	.comm	_SMI_CR1,8,3                    ; @SMI_CR1
	.comm	_SW_MODE,4,2                    ; @SW_MODE
	.comm	_OPCODE_RDID,4,2                ; @OPCODE_RDID
	.comm	_SMI_TR,8,3                     ; @SMI_TR
	.comm	_BANK_SHIFT,4,2                 ; @BANK_SHIFT
	.comm	_SEND,4,2                       ; @SEND
	.comm	_TX_LEN_SHIFT,4,2               ; @TX_LEN_SHIFT
	.comm	_RX_LEN_SHIFT,4,2               ; @RX_LEN_SHIFT
	.comm	_TFIE,4,2                       ; @TFIE
	.comm	_SMI_CR2,8,3                    ; @SMI_CR2
	.comm	_TFF,4,2                        ; @TFF
	.comm	_SMI_CMD_TIMEOUT,4,2            ; @SMI_CMD_TIMEOUT
	.comm	_ENODEV,4,2                     ; @ENODEV
	.comm	_SMI_RR,8,3                     ; @SMI_RR
	.no_dead_strip	_spear_smi_probe_flash
.subsections_via_symbols
