	.file	"extr_bwimac.c_bwi_mac_fw_load.c"
	.intel_syntax noprefix
	.text
	.section	.rodata.str1.8,"aMS",@progbits,1
	.align 8
.LC0:
	.string	"firmware version 4 is not supported yet\n"
	.align 8
.LC1:
	.string	"firmware rev 0x%04x, patch level 0x%04x\n"
	.align 8
.LC2:
	.string	"firmware (ucode&pcm) loading timed out\n"
	.text
	.p2align 4
	.type	bwi_mac_fw_load, @function
bwi_mac_fw_load:
.LFB0:
	.cfi_startproc
	endbr64
	push	r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	movsx	rsi, DWORD PTR BWI_FWHDR_SZ[rip]
	push	r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	push	r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	mov	r12, rdi
	push	rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	push	rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	mov	rdx, QWORD PTR 8[rdi]
	mov	rbp, QWORD PTR 16[rdi]
	mov	edi, DWORD PTR BWI_FW_UCODE_MOBJ[rip]
	mov	rcx, QWORD PTR 8[rdx]
	mov	ebx, DWORD PTR [rdx]
	or	edi, DWORD PTR BWI_WR_MOBJ_AUTOINC[rip]
	sub	ebx, esi
	lea	r14, [rcx+rsi*4]
	xor	esi, esi
	call	BWI_MOBJ_CTRL_VAL@PLT
	movsx	rbx, ebx
	mov	esi, DWORD PTR BWI_MOBJ_CTRL[rip]
	mov	rdi, rbp
	shr	rbx, 3
	mov	edx, eax
	call	CSR_WRITE_4@PLT
	test	ebx, ebx
	jle	.L2
	lea	eax, -1[rbx]
	lea	rbx, 8[r14]
	lea	r13, [rbx+rax*8]
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L19:
	add	rbx, 8
.L3:
	mov	rdi, QWORD PTR [r14]
	mov	r14, rbx
	call	be32toh@PLT
	mov	esi, DWORD PTR BWI_MOBJ_DATA[rip]
	mov	rdi, rbp
	mov	edx, eax
	call	CSR_WRITE_4@PLT
	mov	edi, 10
	call	DELAY@PLT
	cmp	r13, rbx
	jne	.L19
.L2:
	mov	rdx, QWORD PTR [r12]
	movsx	rsi, DWORD PTR BWI_FWHDR_SZ[rip]
	mov	edi, DWORD PTR BWI_FW_PCM_MOBJ[rip]
	mov	rcx, QWORD PTR 8[rdx]
	mov	ebx, DWORD PTR [rdx]
	lea	r14, [rcx+rsi*4]
	sub	ebx, esi
	mov	esi, 490
	call	BWI_MOBJ_CTRL_VAL@PLT
	mov	esi, DWORD PTR BWI_MOBJ_CTRL[rip]
	mov	rdi, rbp
	movsx	rbx, ebx
	mov	edx, eax
	shr	rbx, 3
	call	CSR_WRITE_4@PLT
	mov	esi, DWORD PTR BWI_MOBJ_DATA[rip]
	mov	edx, 16384
	mov	rdi, rbp
	call	CSR_WRITE_4@PLT
	mov	edi, DWORD PTR BWI_FW_PCM_MOBJ[rip]
	mov	esi, 491
	call	BWI_MOBJ_CTRL_VAL@PLT
	mov	esi, DWORD PTR BWI_MOBJ_CTRL[rip]
	mov	rdi, rbp
	mov	edx, eax
	call	CSR_WRITE_4@PLT
	test	ebx, ebx
	jle	.L4
	lea	eax, -1[rbx]
	lea	rbx, 8[r14]
	lea	r13, [rbx+rax*8]
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L20:
	add	rbx, 8
.L5:
	mov	rdi, QWORD PTR [r14]
	mov	r14, rbx
	call	be32toh@PLT
	mov	esi, DWORD PTR BWI_MOBJ_DATA[rip]
	mov	rdi, rbp
	mov	edx, eax
	call	CSR_WRITE_4@PLT
	mov	edi, 10
	call	DELAY@PLT
	cmp	r13, rbx
	jne	.L20
.L4:
	mov	edx, DWORD PTR BWI_ALL_INTRS[rip]
	mov	esi, DWORD PTR BWI_MAC_INTR_STATUS[rip]
	mov	rdi, rbp
	mov	ebx, 200
	call	CSR_WRITE_4@PLT
	mov	esi, DWORD PTR BWI_MAC_STATUS[rip]
	mov	edx, DWORD PTR BWI_MAC_STATUS_UCODE_START[rip]
	mov	rdi, rbp
	or	edx, DWORD PTR BWI_MAC_STATUS_IHREN[rip]
	or	edx, DWORD PTR BWI_MAC_STATUS_INFRA[rip]
	call	CSR_WRITE_4@PLT
	jmp	.L7
	.p2align 4,,10
	.p2align 3
.L22:
	mov	edi, 10
	call	DELAY@PLT
	sub	ebx, 1
	je	.L21
.L7:
	mov	esi, DWORD PTR BWI_MAC_INTR_STATUS[rip]
	mov	rdi, rbp
	call	CSR_READ_4@PLT
	cmp	QWORD PTR BWI_INTR_READY[rip], rax
	jne	.L22
	mov	esi, DWORD PTR BWI_MAC_INTR_STATUS[rip]
	mov	rdi, rbp
	call	CSR_READ_4@PLT
	mov	edx, DWORD PTR BWI_COMM_MOBJ_FWREV[rip]
	mov	esi, DWORD PTR BWI_COMM_MOBJ[rip]
	mov	rdi, r12
	call	MOBJ_READ_2@PLT
	cmp	QWORD PTR BWI_FW_VERSION3_REVMAX[rip], rax
	mov	r13, rax
	jl	.L23
	mov	edx, DWORD PTR BWI_COMM_MOBJ_FWPATCHLV[rip]
	mov	esi, DWORD PTR BWI_COMM_MOBJ[rip]
	mov	rdi, r12
	call	MOBJ_READ_2@PLT
	mov	edi, DWORD PTR 0[rbp]
	mov	rdx, r13
	lea	rsi, .LC1[rip]
	mov	rcx, rax
	xor	eax, eax
	call	device_printf@PLT
	pop	rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	xor	eax, eax
	pop	rbp
	.cfi_def_cfa_offset 32
	pop	r12
	.cfi_def_cfa_offset 24
	pop	r13
	.cfi_def_cfa_offset 16
	pop	r14
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L23:
	.cfi_restore_state
	mov	edi, DWORD PTR 0[rbp]
	lea	rsi, .LC0[rip]
	xor	eax, eax
	call	device_printf@PLT
	pop	rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	mov	eax, DWORD PTR ENODEV[rip]
	pop	rbp
	.cfi_def_cfa_offset 32
	pop	r12
	.cfi_def_cfa_offset 24
	pop	r13
	.cfi_def_cfa_offset 16
	pop	r14
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L21:
	.cfi_restore_state
	mov	edi, DWORD PTR 0[rbp]
	lea	rsi, .LC2[rip]
	xor	eax, eax
	call	device_printf@PLT
	pop	rbx
	.cfi_def_cfa_offset 40
	mov	eax, DWORD PTR ETIMEDOUT[rip]
	pop	rbp
	.cfi_def_cfa_offset 32
	pop	r12
	.cfi_def_cfa_offset 24
	pop	r13
	.cfi_def_cfa_offset 16
	pop	r14
	.cfi_def_cfa_offset 8
	ret
	.cfi_endproc
.LFE0:
	.size	bwi_mac_fw_load, .-bwi_mac_fw_load
	.comm	NRETRY,4,4
	.comm	ETIMEDOUT,4,4
	.comm	ENODEV,4,4
	.comm	BWI_WR_MOBJ_AUTOINC,4,4
	.comm	BWI_MOBJ_DATA,4,4
	.comm	BWI_MOBJ_CTRL,4,4
	.comm	BWI_MAC_STATUS_UCODE_START,4,4
	.comm	BWI_MAC_STATUS_INFRA,4,4
	.comm	BWI_MAC_STATUS_IHREN,4,4
	.comm	BWI_MAC_STATUS,4,4
	.comm	BWI_MAC_INTR_STATUS,4,4
	.comm	BWI_INTR_READY,8,8
	.comm	BWI_FW_VERSION3_REVMAX,8,8
	.comm	BWI_FW_UCODE_MOBJ,4,4
	.comm	BWI_FW_PCM_MOBJ,4,4
	.comm	BWI_FWHDR_SZ,4,4
	.comm	BWI_COMM_MOBJ_FWREV,4,4
	.comm	BWI_COMM_MOBJ_FWPATCHLV,4,4
	.comm	BWI_COMM_MOBJ,4,4
	.comm	BWI_ALL_INTRS,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_bwimac.c_bwi_mac_fw_load.c"
	.text
	.section	.rodata.str1.4,"aMS",%progbits,1
	.align	2
.LC0:
	.ascii	"firmware version 4 is not supported yet\012\000"
	.align	2
.LC1:
	.ascii	"firmware rev 0x%04x, patch level 0x%04x\012\000"
	.align	2
.LC2:
	.ascii	"firmware (ucode&pcm) loading timed out\012\000"
	.text
	.align	2
	.syntax unified
	.arm
	.fpu softvfp
	.type	bwi_mac_fw_load, %function
bwi_mac_fw_load:
	@ args = 0, pretend = 0, frame = 0
	@ frame_needed = 0, uses_anonymous_args = 0
	push	{r3, r4, r5, r6, r7, r8, r9, r10, fp, lr}
	mov	r7, r0
	ldr	r2, [r0, #4]
	ldr	r1, .L28
	ldr	r0, .L28+4
	ldr	fp, .L28+8
	ldr	r1, [r1]
	ldr	r0, [r0]
	ldr	r3, [fp]
	ldr	r9, [r2]
	ldr	r4, [r2, #4]
	ldr	r10, .L28+12
	orr	r0, r0, r1
	mov	r1, #0
	ldr	r6, [r10]
	sub	r9, r9, r3
	add	r4, r4, r3, lsl #2
	ldr	r5, [r7, #8]
	bl	BWI_MOBJ_CTRL_VAL
	lsr	r9, r9, #2
	mov	r2, r0
	mov	r1, r6
	mov	r0, r5
	bl	CSR_WRITE_4
	cmp	r9, #0
	ldr	r6, .L28+16
	addne	r9, r4, r9, lsl #2
	beq	.L2
.L3:
	ldr	r0, [r4], #4
	ldr	r8, [r6]
	bl	be32toh
	mov	r1, r8
	mov	r2, r0
	mov	r0, r5
	bl	CSR_WRITE_4
	mov	r0, #10
	bl	DELAY
	cmp	r9, r4
	bne	.L3
.L2:
	ldr	r2, [r7]
	ldr	r8, .L28+20
	ldr	r3, [fp]
	ldr	r9, [r2]
	ldr	r4, [r2, #4]
	ldr	r0, [r8]
	ldr	r1, .L28+24
	sub	r9, r9, r3
	add	r4, r4, r3, lsl #2
	ldr	fp, [r10]
	bl	BWI_MOBJ_CTRL_VAL
	mov	r1, fp
	mov	r2, r0
	mov	r0, r5
	bl	CSR_WRITE_4
	mov	r2, #16384
	ldr	r1, [r6]
	mov	r0, r5
	bl	CSR_WRITE_4
	ldr	r0, [r8]
	ldr	r1, .L28+28
	ldr	r8, [r10]
	bl	BWI_MOBJ_CTRL_VAL
	lsr	r9, r9, #2
	mov	r2, r0
	mov	r1, r8
	mov	r0, r5
	bl	CSR_WRITE_4
	cmp	r9, #0
	beq	.L4
	add	r9, r4, r9, lsl #2
.L5:
	ldr	r0, [r4], #4
	ldr	r8, [r6]
	bl	be32toh
	mov	r1, r8
	mov	r2, r0
	mov	r0, r5
	bl	CSR_WRITE_4
	mov	r0, #10
	bl	DELAY
	cmp	r9, r4
	bne	.L5
.L4:
	ldr	r3, .L28+32
	ldr	r6, .L28+36
	ldr	r2, [r3]
	ldr	r1, [r6]
	mov	r0, r5
	bl	CSR_WRITE_4
	ldr	r1, .L28+40
	ldr	r3, .L28+44
	ldr	r2, .L28+48
	ldr	r0, [r1]
	ldr	r3, [r3]
	ldr	r2, [r2]
	ldr	r1, .L28+52
	orr	r3, r3, r0
	ldr	r1, [r1]
	mov	r0, r5
	orr	r2, r3, r2
	bl	CSR_WRITE_4
	mov	r4, #200
	ldr	r8, .L28+56
	b	.L7
.L26:
	mov	r0, #10
	bl	DELAY
	subs	r4, r4, #1
	beq	.L25
.L7:
	mov	r0, r5
	ldr	r1, [r6]
	bl	CSR_READ_4
	ldr	r3, [r8]
	cmp	r3, r0
	bne	.L26
	ldr	r1, [r6]
	mov	r0, r5
	bl	CSR_READ_4
	ldr	r6, .L28+60
	ldr	r3, .L28+64
	mov	r0, r7
	ldr	r2, [r3]
	ldr	r1, [r6]
	bl	MOBJ_READ_2
	ldr	r3, .L28+68
	mov	r4, r0
	ldr	r3, [r3]
	cmp	r3, r0
	blt	.L27
	ldr	r3, .L28+72
	ldr	r1, [r6]
	ldr	r2, [r3]
	mov	r0, r7
	ldr	r5, [r5]
	bl	MOBJ_READ_2
	mov	r2, r4
	mov	r3, r0
	ldr	r1, .L28+76
	mov	r0, r5
	bl	device_printf
	mov	r0, #0
	pop	{r3, r4, r5, r6, r7, r8, r9, r10, fp, pc}
.L27:
	ldr	r0, [r5]
	ldr	r1, .L28+80
	bl	device_printf
	ldr	r3, .L28+84
	ldr	r0, [r3]
	pop	{r3, r4, r5, r6, r7, r8, r9, r10, fp, pc}
.L25:
	ldr	r0, [r5]
	ldr	r1, .L28+88
	bl	device_printf
	ldr	r3, .L28+92
	ldr	r0, [r3]
	pop	{r3, r4, r5, r6, r7, r8, r9, r10, fp, pc}
.L29:
	.align	2
.L28:
	.word	BWI_WR_MOBJ_AUTOINC
	.word	BWI_FW_UCODE_MOBJ
	.word	BWI_FWHDR_SZ
	.word	BWI_MOBJ_CTRL
	.word	BWI_MOBJ_DATA
	.word	BWI_FW_PCM_MOBJ
	.word	490
	.word	491
	.word	BWI_ALL_INTRS
	.word	BWI_MAC_INTR_STATUS
	.word	BWI_MAC_STATUS_IHREN
	.word	BWI_MAC_STATUS_UCODE_START
	.word	BWI_MAC_STATUS_INFRA
	.word	BWI_MAC_STATUS
	.word	BWI_INTR_READY
	.word	BWI_COMM_MOBJ
	.word	BWI_COMM_MOBJ_FWREV
	.word	BWI_FW_VERSION3_REVMAX
	.word	BWI_COMM_MOBJ_FWPATCHLV
	.word	.LC1
	.word	.LC0
	.word	ENODEV
	.word	.LC2
	.word	ETIMEDOUT
	.size	bwi_mac_fw_load, .-bwi_mac_fw_load
	.comm	NRETRY,4,4
	.comm	ETIMEDOUT,4,4
	.comm	ENODEV,4,4
	.comm	BWI_WR_MOBJ_AUTOINC,4,4
	.comm	BWI_MOBJ_DATA,4,4
	.comm	BWI_MOBJ_CTRL,4,4
	.comm	BWI_MAC_STATUS_UCODE_START,4,4
	.comm	BWI_MAC_STATUS_INFRA,4,4
	.comm	BWI_MAC_STATUS_IHREN,4,4
	.comm	BWI_MAC_STATUS,4,4
	.comm	BWI_MAC_INTR_STATUS,4,4
	.comm	BWI_INTR_READY,4,4
	.comm	BWI_FW_VERSION3_REVMAX,4,4
	.comm	BWI_FW_UCODE_MOBJ,4,4
	.comm	BWI_FW_PCM_MOBJ,4,4
	.comm	BWI_FWHDR_SZ,4,4
	.comm	BWI_COMM_MOBJ_FWREV,4,4
	.comm	BWI_COMM_MOBJ_FWPATCHLV,4,4
	.comm	BWI_COMM_MOBJ,4,4
	.comm	BWI_ALL_INTRS,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
