	.file	"extr_mtk-sd.c_msdc_cmd_prepare_raw_cmd.c"
	.intel_syntax noprefix
	.text
	.p2align 4
	.type	msdc_cmd_prepare_raw_cmd, @function
msdc_cmd_prepare_raw_cmd:
.LFB0:
	.cfi_startproc
	endbr64
	push	r14
	.cfi_def_cfa_offset 16
	.cfi_offset 14, -16
	push	r13
	.cfi_def_cfa_offset 24
	.cfi_offset 13, -24
	mov	r13, rdi
	push	r12
	.cfi_def_cfa_offset 32
	.cfi_offset 12, -32
	push	rbp
	.cfi_def_cfa_offset 40
	.cfi_offset 6, -40
	mov	rbp, rsi
	push	rbx
	.cfi_def_cfa_offset 48
	.cfi_offset 3, -48
	mov	rbx, rdx
	mov	r14d, DWORD PTR [rdx]
	call	msdc_cmd_find_resp@PLT
	mov	edx, r14d
	mov	r12d, eax
	and	edx, 63
	mov	DWORD PTR 0[r13], eax
	sal	r12d, 7
	and	r12d, 896
	or	r12d, edx
	cmp	DWORD PTR SD_IO_RW_DIRECT[rip], r14d
	je	.L38
.L2:
	cmp	DWORD PTR MMC_STOP_TRANSMISSION[rip], r14d
	je	.L3
	cmp	DWORD PTR SD_SWITCH_VOLTAGE[rip], r14d
	je	.L39
	cmp	DWORD PTR SD_APP_SEND_SCR[rip], r14d
	je	.L8
	cmp	DWORD PTR SD_APP_SEND_NUM_WR_BLKS[rip], r14d
	je	.L8
	cmp	DWORD PTR SD_SWITCH[rip], r14d
	je	.L9
.L12:
	cmp	DWORD PTR SD_APP_SD_STATUS[rip], r14d
	je	.L40
.L11:
	cmp	DWORD PTR MMC_SEND_EXT_CSD[rip], r14d
	jne	.L5
	mov	rdi, rbx
	call	mmc_cmd_type@PLT
	cmp	rax, QWORD PTR MMC_CMD_ADTC[rip]
	jne	.L5
	.p2align 4,,10
	.p2align 3
.L8:
	or	r12d, 2048
.L5:
	mov	rbx, QWORD PTR 8[rbx]
	test	rbx, rbx
	je	.L1
	mov	edi, r14d
	call	mmc_op_multi@PLT
	test	rax, rax
	jne	.L41
.L15:
	mov	eax, DWORD PTR [rbx]
	mov	ecx, DWORD PTR 4[rbx]
	sal	eax, 16
	and	eax, 268369920
	or	eax, r12d
	mov	edx, eax
	or	dh, 32
	test	DWORD PTR MMC_DATA_WRITE[rip], ecx
	cmovne	eax, edx
	mov	r12d, eax
	or	r12d, 2048
	cmp	DWORD PTR 8[rbx], 1
	jle	.L18
	or	ah, 16
	mov	r12d, eax
.L18:
	mov	esi, DWORD PTR MSDC_CFG_PIO[rip]
	mov	rdi, QWORD PTR MSDC_CFG[rip]
	add	rdi, QWORD PTR 24[r13]
	call	sdr_clr_bits@PLT
	mov	rsi, QWORD PTR 16[rbx]
	cmp	QWORD PTR 8[r13], rsi
	mov	rdx, QWORD PTR 24[rbx]
	jne	.L20
	cmp	QWORD PTR 16[r13], rdx
	je	.L21
.L20:
	mov	rdi, r13
	call	msdc_set_timeout@PLT
.L21:
	mov	edi, DWORD PTR 8[rbx]
	mov	rsi, QWORD PTR SDC_BLK_NUM[rip]
	add	rsi, QWORD PTR 24[r13]
	call	writel@PLT
.L1:
	pop	rbx
	.cfi_remember_state
	.cfi_def_cfa_offset 40
	mov	eax, r12d
	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
.L38:
	.cfi_restore_state
	cmp	DWORD PTR 4[rbx], -1
	jne	.L2
.L3:
	or	r12d, 16384
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L39:
	or	r12d, 1073741824
	jmp	.L5
	.p2align 4,,10
	.p2align 3
.L41:
	mov	rax, QWORD PTR 32[r13]
	mov	edi, DWORD PTR [rax]
	call	mmc_card_mmc@PLT
	test	rax, rax
	je	.L15
	mov	rax, QWORD PTR 0[rbp]
	test	rax, rax
	je	.L15
	mov	edx, r12d
	or	edx, 536870912
	test	DWORD PTR [rax], -65536
	cmove	r12d, edx
	jmp	.L15
	.p2align 4,,10
	.p2align 3
.L9:
	mov	rdi, rbx
	call	mmc_cmd_type@PLT
	cmp	rax, QWORD PTR MMC_CMD_ADTC[rip]
	jne	.L12
	jmp	.L8
	.p2align 4,,10
	.p2align 3
.L40:
	mov	rdi, rbx
	call	mmc_cmd_type@PLT
	cmp	rax, QWORD PTR MMC_CMD_ADTC[rip]
	jne	.L11
	jmp	.L8
	.cfi_endproc
.LFE0:
	.size	msdc_cmd_prepare_raw_cmd, .-msdc_cmd_prepare_raw_cmd
	.comm	SD_SWITCH_VOLTAGE,4,4
	.comm	SD_SWITCH,4,4
	.comm	SD_IO_RW_DIRECT,4,4
	.comm	SD_APP_SEND_SCR,4,4
	.comm	SD_APP_SEND_NUM_WR_BLKS,4,4
	.comm	SD_APP_SD_STATUS,4,4
	.comm	SDC_BLK_NUM,8,8
	.comm	MSDC_CFG_PIO,4,4
	.comm	MSDC_CFG,8,8
	.comm	MMC_STOP_TRANSMISSION,4,4
	.comm	MMC_SEND_EXT_CSD,4,4
	.comm	MMC_DATA_WRITE,4,4
	.comm	MMC_CMD_ADTC,8,8
	.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_mtk-sd.c_msdc_cmd_prepare_raw_cmd.c"
	.text
	.align	2
	.syntax unified
	.arm
	.fpu softvfp
	.type	msdc_cmd_prepare_raw_cmd, %function
msdc_cmd_prepare_raw_cmd:
	@ args = 0, pretend = 0, frame = 0
	@ frame_needed = 0, uses_anonymous_args = 0
	push	{r4, r5, r6, r7, r8, lr}
	ldr	r8, [r2]
	mov	r6, r0
	mov	r5, r2
	mov	r7, r1
	bl	msdc_cmd_find_resp
	ldr	r3, .L46
	lsl	r4, r0, #7
	ldr	r3, [r3]
	and	r4, r4, #896
	cmp	r3, r8
	and	r3, r8, #63
	str	r0, [r6]
	orr	r4, r4, r3
	beq	.L42
.L2:
	ldr	r3, .L46+4
	ldr	r3, [r3]
	cmp	r3, r8
	beq	.L3
	ldr	r3, .L46+8
	ldr	r3, [r3]
	cmp	r3, r8
	orreq	r4, r4, #1073741824
	beq	.L5
	ldr	r3, .L46+12
	ldr	r3, [r3]
	cmp	r3, r8
	beq	.L8
	ldr	r3, .L46+16
	ldr	r3, [r3]
	cmp	r3, r8
	beq	.L8
	ldr	r3, .L46+20
	ldr	r3, [r3]
	cmp	r3, r8
	beq	.L9
.L12:
	ldr	r3, .L46+24
	ldr	r3, [r3]
	cmp	r3, r8
	beq	.L43
.L11:
	ldr	r3, .L46+28
	ldr	r3, [r3]
	cmp	r3, r8
	beq	.L44
.L5:
	ldr	r5, [r5, #8]
	cmp	r5, #0
	beq	.L1
	mov	r0, r8
	bl	mmc_op_multi
	cmp	r0, #0
	bne	.L45
.L15:
	ldr	r3, .L46+32
	ldr	r1, [r5, #4]
	ldr	r3, [r3]
	ldr	r2, [r5]
	tst	r1, r3
	ldr	r3, .L46+36
	ldr	r0, [r6, #12]
	and	r3, r3, r2, lsl #16
	orr	r4, r3, r4
	ldr	r3, [r5, #8]
	orrne	r4, r4, #8192
	cmp	r3, #1
	ldr	r3, .L46+40
	orrgt	r4, r4, #4096
	ldr	r2, [r3]
	ldr	r3, .L46+44
	add	r0, r0, r2
	ldr	r1, [r3]
	orrle	r4, r4, #2048
	bl	sdr_clr_bits
	ldr	r1, [r5, #12]
	ldr	r3, [r6, #4]
	ldr	r2, [r5, #16]
	cmp	r3, r1
	bne	.L20
	ldr	r3, [r6, #8]
	cmp	r3, r2
	beq	.L21
.L20:
	mov	r0, r6
	bl	msdc_set_timeout
.L21:
	ldr	r3, .L46+48
	ldr	r1, [r6, #12]
	ldr	r3, [r3]
	ldr	r0, [r5, #8]
	add	r1, r1, r3
	bl	writel
.L1:
	mov	r0, r4
	pop	{r4, r5, r6, r7, r8, pc}
.L44:
	mov	r0, r5
	bl	mmc_cmd_type
	ldr	r3, .L46+52
	ldr	r3, [r3]
	cmp	r0, r3
	bne	.L5
.L8:
	orr	r4, r4, #2048
	b	.L5
.L42:
	ldr	r3, [r5, #4]
	cmn	r3, #1
	bne	.L2
.L3:
	orr	r4, r4, #16384
	b	.L5
.L45:
	ldr	r3, [r6, #16]
	ldr	r0, [r3]
	bl	mmc_card_mmc
	cmp	r0, #0
	beq	.L15
	ldr	r3, [r7]
	cmp	r3, #0
	beq	.L15
	ldr	r3, [r3]
	lsr	r3, r3, #16
	lsl	r3, r3, #16
	cmp	r3, #0
	orreq	r4, r4, #536870912
	b	.L15
.L9:
	mov	r0, r5
	bl	mmc_cmd_type
	ldr	r3, .L46+52
	ldr	r3, [r3]
	cmp	r0, r3
	bne	.L12
	b	.L8
.L43:
	mov	r0, r5
	bl	mmc_cmd_type
	ldr	r3, .L46+52
	ldr	r3, [r3]
	cmp	r0, r3
	bne	.L11
	b	.L8
.L47:
	.align	2
.L46:
	.word	SD_IO_RW_DIRECT
	.word	MMC_STOP_TRANSMISSION
	.word	SD_SWITCH_VOLTAGE
	.word	SD_APP_SEND_SCR
	.word	SD_APP_SEND_NUM_WR_BLKS
	.word	SD_SWITCH
	.word	SD_APP_SD_STATUS
	.word	MMC_SEND_EXT_CSD
	.word	MMC_DATA_WRITE
	.word	268369920
	.word	MSDC_CFG
	.word	MSDC_CFG_PIO
	.word	SDC_BLK_NUM
	.word	MMC_CMD_ADTC
	.size	msdc_cmd_prepare_raw_cmd, .-msdc_cmd_prepare_raw_cmd
	.comm	SD_SWITCH_VOLTAGE,4,4
	.comm	SD_SWITCH,4,4
	.comm	SD_IO_RW_DIRECT,4,4
	.comm	SD_APP_SEND_SCR,4,4
	.comm	SD_APP_SEND_NUM_WR_BLKS,4,4
	.comm	SD_APP_SD_STATUS,4,4
	.comm	SDC_BLK_NUM,4,4
	.comm	MSDC_CFG_PIO,4,4
	.comm	MSDC_CFG,4,4
	.comm	MMC_STOP_TRANSMISSION,4,4
	.comm	MMC_SEND_EXT_CSD,4,4
	.comm	MMC_DATA_WRITE,4,4
	.comm	MMC_CMD_ADTC,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
