	.file	"extr_atl2.c_atl2_spi_read.c"
	.intel_syntax noprefix
	.text
	.p2align 4
	.type	atl2_spi_read, @function
atl2_spi_read:
.LFB0:
	.cfi_startproc
	endbr64
	push	r13
	.cfi_def_cfa_offset 16
	.cfi_offset 13, -16
	mov	r13d, esi
	push	r12
	.cfi_def_cfa_offset 24
	.cfi_offset 12, -24
	mov	r12, rdx
	xor	edx, edx
	push	rbp
	.cfi_def_cfa_offset 32
	.cfi_offset 6, -32
	mov	rbp, rdi
	push	rbx
	.cfi_def_cfa_offset 40
	.cfi_offset 3, -40
	sub	rsp, 8
	.cfi_def_cfa_offset 48
	mov	esi, DWORD PTR REG_SPI_DATA[rip]
	call	ATL2_WRITE_REG@PLT
	mov	esi, DWORD PTR REG_SPI_ADDR[rip]
	mov	edx, r13d
	mov	rdi, rbp
	call	ATL2_WRITE_REG@PLT
	mov	ecx, DWORD PTR SPI_FLASH_CTRL_CS_SETUP_SHIFT[rip]
	mov	rdi, rbp
	mov	ebx, DWORD PTR CUSTOM_SPI_CS_SETUP[rip]
	and	ebx, DWORD PTR SPI_FLASH_CTRL_CS_SETUP_MASK[rip]
	mov	eax, DWORD PTR CUSTOM_SPI_CLK_HI[rip]
	sal	ebx, cl
	mov	ecx, DWORD PTR SPI_FLASH_CTRL_CLK_HI_SHIFT[rip]
	and	eax, DWORD PTR SPI_FLASH_CTRL_CLK_HI_MASK[rip]
	mov	edx, DWORD PTR CUSTOM_SPI_CS_HOLD[rip]
	and	edx, DWORD PTR SPI_FLASH_CTRL_CS_HOLD_MASK[rip]
	sal	eax, cl
	mov	ecx, DWORD PTR SPI_FLASH_CTRL_CLK_LO_SHIFT[rip]
	mov	esi, DWORD PTR REG_SPI_FLASH_CTRL[rip]
	or	ebx, eax
	mov	eax, DWORD PTR CUSTOM_SPI_CLK_LO[rip]
	and	eax, DWORD PTR SPI_FLASH_CTRL_CLK_LO_MASK[rip]
	sal	eax, cl
	mov	ecx, DWORD PTR SPI_FLASH_CTRL_CS_HOLD_SHIFT[rip]
	or	ebx, DWORD PTR SPI_FLASH_CTRL_WAIT_READY[rip]
	or	ebx, eax
	sal	edx, cl
	mov	ecx, DWORD PTR SPI_FLASH_CTRL_CS_HI_SHIFT[rip]
	or	ebx, edx
	mov	edx, DWORD PTR CUSTOM_SPI_CS_HI[rip]
	and	edx, DWORD PTR SPI_FLASH_CTRL_CS_HI_MASK[rip]
	sal	edx, cl
	mov	ecx, DWORD PTR SPI_FLASH_CTRL_INS_SHIFT[rip]
	or	ebx, edx
	mov	edx, DWORD PTR SPI_FLASH_CTRL_INS_MASK[rip]
	and	edx, 1
	sal	edx, cl
	or	ebx, edx
	mov	edx, ebx
	call	ATL2_WRITE_REG@PLT
	or	ebx, DWORD PTR SPI_FLASH_CTRL_START[rip]
	mov	esi, DWORD PTR REG_SPI_FLASH_CTRL[rip]
	mov	rdi, rbp
	mov	edx, ebx
	mov	ebx, 10
	call	ATL2_WRITE_REG@PLT
	.p2align 4,,10
	.p2align 3
.L3:
	mov	edi, 1
	call	msleep@PLT
	mov	esi, DWORD PTR REG_SPI_FLASH_CTRL[rip]
	mov	rdi, rbp
	call	ATL2_READ_REG@PLT
	test	DWORD PTR SPI_FLASH_CTRL_START[rip], eax
	je	.L2
	sub	ebx, 1
	jne	.L3
	add	rsp, 8
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xor	eax, eax
	pop	rbx
	.cfi_def_cfa_offset 32
	pop	rbp
	.cfi_def_cfa_offset 24
	pop	r12
	.cfi_def_cfa_offset 16
	pop	r13
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L2:
	.cfi_restore_state
	mov	esi, DWORD PTR REG_SPI_DATA[rip]
	mov	rdi, rbp
	call	ATL2_READ_REG@PLT
	mov	DWORD PTR [r12], eax
	add	rsp, 8
	.cfi_def_cfa_offset 40
	mov	eax, 1
	pop	rbx
	.cfi_def_cfa_offset 32
	pop	rbp
	.cfi_def_cfa_offset 24
	pop	r12
	.cfi_def_cfa_offset 16
	pop	r13
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE0:
	.size	atl2_spi_read, .-atl2_spi_read
	.comm	SPI_FLASH_CTRL_WAIT_READY,4,4
	.comm	SPI_FLASH_CTRL_START,4,4
	.comm	SPI_FLASH_CTRL_INS_SHIFT,4,4
	.comm	SPI_FLASH_CTRL_INS_MASK,4,4
	.comm	SPI_FLASH_CTRL_CS_SETUP_SHIFT,4,4
	.comm	SPI_FLASH_CTRL_CS_SETUP_MASK,4,4
	.comm	SPI_FLASH_CTRL_CS_HOLD_SHIFT,4,4
	.comm	SPI_FLASH_CTRL_CS_HOLD_MASK,4,4
	.comm	SPI_FLASH_CTRL_CS_HI_SHIFT,4,4
	.comm	SPI_FLASH_CTRL_CS_HI_MASK,4,4
	.comm	SPI_FLASH_CTRL_CLK_LO_SHIFT,4,4
	.comm	SPI_FLASH_CTRL_CLK_LO_MASK,4,4
	.comm	SPI_FLASH_CTRL_CLK_HI_SHIFT,4,4
	.comm	SPI_FLASH_CTRL_CLK_HI_MASK,4,4
	.comm	REG_SPI_FLASH_CTRL,4,4
	.comm	REG_SPI_DATA,4,4
	.comm	REG_SPI_ADDR,4,4
	.comm	CUSTOM_SPI_CS_SETUP,4,4
	.comm	CUSTOM_SPI_CS_HOLD,4,4
	.comm	CUSTOM_SPI_CS_HI,4,4
	.comm	CUSTOM_SPI_CLK_LO,4,4
	.comm	CUSTOM_SPI_CLK_HI,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	 1f - 0f
	.long	 4f - 1f
	.long	 5
0:
	.string	 "GNU"
1:
	.align 8
	.long	 0xc0000002
	.long	 3f - 2f
2:
	.long	 0x3
3:
	.align 8
4:

	.arch armv5t
	.eabi_attribute 20, 1
	.eabi_attribute 21, 1
	.eabi_attribute 23, 3
	.eabi_attribute 24, 1
	.eabi_attribute 25, 1
	.eabi_attribute 26, 2
	.eabi_attribute 30, 2
	.eabi_attribute 34, 0
	.eabi_attribute 18, 4
	.file	"extr_atl2.c_atl2_spi_read.c"
	.text
	.align	2
	.syntax unified
	.arm
	.fpu softvfp
	.type	atl2_spi_read, %function
atl2_spi_read:
	@ args = 0, pretend = 0, frame = 0
	@ frame_needed = 0, uses_anonymous_args = 0
	push	{r4, r5, r6, r7, r8, r9, r10, lr}
	mov	r5, r0
	mov	r4, r1
	ldr	r7, .L8
	mov	r6, r2
	ldr	r1, [r7]
	mov	r2, #0
	bl	ATL2_WRITE_REG
	ldr	r3, .L8+4
	mov	r2, r4
	ldr	r1, [r3]
	mov	r0, r5
	bl	ATL2_WRITE_REG
	ldr	r0, .L8+8
	ldr	r3, .L8+12
	ldr	r1, .L8+16
	ldr	ip, .L8+20
	ldr	r2, .L8+24
	ldr	lr, [r0]
	ldr	ip, [ip]
	ldr	r3, [r3]
	ldr	r1, [r1]
	ldr	r2, [r2]
	and	r1, r1, ip
	and	r3, r3, lr
	ldr	ip, .L8+28
	ldr	r0, .L8+32
	lsl	r3, r3, r2
	ldr	lr, .L8+36
	ldr	r2, .L8+40
	ldr	r4, [ip]
	ldr	r0, [r0]
	ldr	ip, .L8+44
	ldr	lr, [lr]
	ldr	r2, [r2]
	ldr	ip, [ip]
	orr	r3, r3, r1, lsl r0
	ldr	r1, .L8+48
	ldr	r0, .L8+52
	and	r2, r2, r4
	orr	r3, r3, lr
	ldr	lr, .L8+56
	ldr	r0, [r0]
	orr	r3, r3, r2, lsl ip
	ldr	r1, [r1]
	ldr	r2, .L8+60
	ldr	lr, [lr]
	ldr	r4, .L8+64
	ldr	ip, [r2]
	and	r1, r1, r0
	ldr	r2, .L8+68
	ldr	r0, .L8+72
	orr	r3, r3, r1, lsl lr
	ldr	r4, [r4]
	ldr	r1, .L8+76
	ldr	r0, [r0]
	ldr	r2, [r2]
	ldr	r1, [r1]
	and	r4, r4, ip
	orr	r4, r3, r4, lsl r0
	ldr	r8, .L8+80
	and	r2, r2, #1
	orr	r4, r4, r2, lsl r1
	ldr	r9, .L8+84
	mov	r2, r4
	ldr	r1, [r8]
	mov	r0, r5
	bl	ATL2_WRITE_REG
	ldr	r2, [r9]
	mov	r0, r5
	orr	r2, r4, r2
	ldr	r1, [r8]
	bl	ATL2_WRITE_REG
	mov	r4, #10
.L3:
	mov	r0, #1
	bl	msleep
	mov	r0, r5
	ldr	r1, [r8]
	bl	ATL2_READ_REG
	ldr	r3, [r9]
	tst	r0, r3
	beq	.L2
	subs	r4, r4, #1
	bne	.L3
	mov	r0, r4
	pop	{r4, r5, r6, r7, r8, r9, r10, pc}
.L2:
	mov	r0, r5
	ldr	r1, [r7]
	bl	ATL2_READ_REG
	mov	r3, r0
	mov	r0, #1
	str	r3, [r6]
	pop	{r4, r5, r6, r7, r8, r9, r10, pc}
.L9:
	.align	2
.L8:
	.word	REG_SPI_DATA
	.word	REG_SPI_ADDR
	.word	SPI_FLASH_CTRL_CLK_HI_MASK
	.word	CUSTOM_SPI_CLK_HI
	.word	CUSTOM_SPI_CS_SETUP
	.word	SPI_FLASH_CTRL_CS_SETUP_MASK
	.word	SPI_FLASH_CTRL_CLK_HI_SHIFT
	.word	SPI_FLASH_CTRL_CLK_LO_MASK
	.word	SPI_FLASH_CTRL_CS_SETUP_SHIFT
	.word	SPI_FLASH_CTRL_WAIT_READY
	.word	CUSTOM_SPI_CLK_LO
	.word	SPI_FLASH_CTRL_CLK_LO_SHIFT
	.word	CUSTOM_SPI_CS_HOLD
	.word	SPI_FLASH_CTRL_CS_HOLD_MASK
	.word	SPI_FLASH_CTRL_CS_HOLD_SHIFT
	.word	SPI_FLASH_CTRL_CS_HI_MASK
	.word	CUSTOM_SPI_CS_HI
	.word	SPI_FLASH_CTRL_INS_MASK
	.word	SPI_FLASH_CTRL_CS_HI_SHIFT
	.word	SPI_FLASH_CTRL_INS_SHIFT
	.word	REG_SPI_FLASH_CTRL
	.word	SPI_FLASH_CTRL_START
	.size	atl2_spi_read, .-atl2_spi_read
	.comm	SPI_FLASH_CTRL_WAIT_READY,4,4
	.comm	SPI_FLASH_CTRL_START,4,4
	.comm	SPI_FLASH_CTRL_INS_SHIFT,4,4
	.comm	SPI_FLASH_CTRL_INS_MASK,4,4
	.comm	SPI_FLASH_CTRL_CS_SETUP_SHIFT,4,4
	.comm	SPI_FLASH_CTRL_CS_SETUP_MASK,4,4
	.comm	SPI_FLASH_CTRL_CS_HOLD_SHIFT,4,4
	.comm	SPI_FLASH_CTRL_CS_HOLD_MASK,4,4
	.comm	SPI_FLASH_CTRL_CS_HI_SHIFT,4,4
	.comm	SPI_FLASH_CTRL_CS_HI_MASK,4,4
	.comm	SPI_FLASH_CTRL_CLK_LO_SHIFT,4,4
	.comm	SPI_FLASH_CTRL_CLK_LO_MASK,4,4
	.comm	SPI_FLASH_CTRL_CLK_HI_SHIFT,4,4
	.comm	SPI_FLASH_CTRL_CLK_HI_MASK,4,4
	.comm	REG_SPI_FLASH_CTRL,4,4
	.comm	REG_SPI_DATA,4,4
	.comm	REG_SPI_ADDR,4,4
	.comm	CUSTOM_SPI_CS_SETUP,4,4
	.comm	CUSTOM_SPI_CS_HOLD,4,4
	.comm	CUSTOM_SPI_CS_HI,4,4
	.comm	CUSTOM_SPI_CLK_LO,4,4
	.comm	CUSTOM_SPI_CLK_HI,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
