	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function jz4740_mmc_start_dma_transfer
_jz4740_mmc_start_dma_transfer:         ## @jz4740_mmc_start_dma_transfer
	.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	$40, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rsi, %r12
	movq	%rdi, %r14
	callq	_jz4740_mmc_get_dma_chan
	xorps	%xmm0, %xmm0
	movaps	%xmm0, -80(%rbp)
	movq	$0, -64(%rbp)
	movq	_JZ4740_MMC_FIFO_HALF_SIZE@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	movl	%ecx, -56(%rbp)
	movl	%ecx, -52(%rbp)
	movq	_DMA_SLAVE_BUSWIDTH_4_BYTES@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	movl	%ecx, -48(%rbp)
	movl	%ecx, -44(%rbp)
	movq	_MMC_DATA_WRITE@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	xorl	%edx, %edx
	andl	(%r12), %ecx
	setne	%dl
	movq	_DMA_DEV_TO_MEM@GOTPCREL(%rip), %rcx
	cmovneq	_DMA_MEM_TO_DEV@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	movq	%rcx, -80(%rbp)
	movq	_JZ_REG_MMC_TXFIFO@GOTPCREL(%rip), %rcx
	cmoveq	_JZ_REG_MMC_RXFIFO@GOTPCREL(%rip), %rcx
	movq	8(%r14), %rsi
	movq	(%rcx), %rcx
	addq	(%rsi), %rcx
	movq	%rax, %r15
	movq	%rcx, -72(%rbp,%rdx,8)
	movq	_COOKIE_MAPPED@GOTPCREL(%rip), %r13
	movq	(%r13), %rdx
	movq	%r14, %rdi
	movq	%r12, %rsi
	callq	_jz4740_mmc_prepare_dma_data
	movl	%eax, %ebx
	testl	%eax, %eax
	js	LBB0_5
## %bb.1:
	leaq	-80(%rbp), %rsi
	movq	%r15, %rdi
	callq	_dmaengine_slave_config
	movl	16(%r12), %esi
	movq	-80(%rbp), %rcx
	movq	_DMA_PREP_INTERRUPT@GOTPCREL(%rip), %rax
	movq	_DMA_CTRL_ACK@GOTPCREL(%rip), %rdx
	movl	(%rdx), %r8d
	orl	(%rax), %r8d
	movq	%r15, %rdi
	movl	%ebx, %edx
	callq	_dmaengine_prep_slave_sg
	testq	%rax, %rax
	je	LBB0_2
## %bb.6:
	movq	%rax, %rdi
	callq	_dmaengine_submit
	movq	%r15, %rdi
	callq	_dma_async_issue_pending
	xorl	%ebx, %ebx
	jmp	LBB0_5
LBB0_2:
	movl	(%r14), %edi
	callq	_mmc_dev
	movq	-80(%rbp), %rcx
	movq	_DMA_MEM_TO_DEV@GOTPCREL(%rip), %rdx
	cmpq	(%rdx), %rcx
	leaq	L_.str.1(%rip), %rcx
	leaq	L_.str.2(%rip), %rdx
	cmoveq	%rcx, %rdx
	leaq	L_.str(%rip), %rsi
	movl	%eax, %edi
	callq	_dev_err
	movq	8(%r12), %rax
	cmpq	(%r13), %rax
	jne	LBB0_4
## %bb.3:
	movq	%r14, %rdi
	movq	%r12, %rsi
	callq	_jz4740_mmc_dma_unmap
LBB0_4:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
LBB0_5:
	movl	%ebx, %eax
	addq	$40, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_JZ4740_MMC_FIFO_HALF_SIZE,4,2  ## @JZ4740_MMC_FIFO_HALF_SIZE
	.comm	_DMA_SLAVE_BUSWIDTH_4_BYTES,4,2 ## @DMA_SLAVE_BUSWIDTH_4_BYTES
	.comm	_MMC_DATA_WRITE,4,2             ## @MMC_DATA_WRITE
	.comm	_DMA_MEM_TO_DEV,8,3             ## @DMA_MEM_TO_DEV
	.comm	_JZ_REG_MMC_TXFIFO,8,3          ## @JZ_REG_MMC_TXFIFO
	.comm	_DMA_DEV_TO_MEM,8,3             ## @DMA_DEV_TO_MEM
	.comm	_JZ_REG_MMC_RXFIFO,8,3          ## @JZ_REG_MMC_RXFIFO
	.comm	_COOKIE_MAPPED,8,3              ## @COOKIE_MAPPED
	.comm	_DMA_PREP_INTERRUPT,4,2         ## @DMA_PREP_INTERRUPT
	.comm	_DMA_CTRL_ACK,4,2               ## @DMA_CTRL_ACK
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Failed to allocate DMA %s descriptor"

L_.str.1:                               ## @.str.1
	.asciz	"TX"

L_.str.2:                               ## @.str.2
	.asciz	"RX"

	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.no_dead_strip	_jz4740_mmc_start_dma_transfer
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function jz4740_mmc_start_dma_transfer
_jz4740_mmc_start_dma_transfer:         ; @jz4740_mmc_start_dma_transfer
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.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	x19, x1
	mov	x20, x0
	bl	_jz4740_mmc_get_dma_chan
	mov	x21, x0
	stp	xzr, xzr, [sp, #16]
	str	xzr, [sp, #8]
Lloh0:
	adrp	x8, _JZ4740_MMC_FIFO_HALF_SIZE@GOTPAGE
Lloh1:
	ldr	x8, [x8, _JZ4740_MMC_FIFO_HALF_SIZE@GOTPAGEOFF]
Lloh2:
	ldr	w8, [x8]
	stp	w8, w8, [sp, #32]
Lloh3:
	adrp	x8, _DMA_SLAVE_BUSWIDTH_4_BYTES@GOTPAGE
Lloh4:
	ldr	x8, [x8, _DMA_SLAVE_BUSWIDTH_4_BYTES@GOTPAGEOFF]
Lloh5:
	ldr	w8, [x8]
	stp	w8, w8, [sp, #40]
	ldr	w8, [x19]
Lloh6:
	adrp	x9, _MMC_DATA_WRITE@GOTPAGE
Lloh7:
	ldr	x9, [x9, _MMC_DATA_WRITE@GOTPAGEOFF]
Lloh8:
	ldr	w9, [x9]
	tst	w9, w8
	mov	w8, #16
	mov	w9, #8
	csel	x8, x9, x8, eq
Lloh9:
	adrp	x9, _DMA_DEV_TO_MEM@GOTPAGE
Lloh10:
	ldr	x9, [x9, _DMA_DEV_TO_MEM@GOTPAGEOFF]
Lloh11:
	adrp	x23, _DMA_MEM_TO_DEV@GOTPAGE
Lloh12:
	ldr	x23, [x23, _DMA_MEM_TO_DEV@GOTPAGEOFF]
	csel	x9, x9, x23, eq
	ldr	x9, [x9]
	str	x9, [sp, #8]
	ldr	x9, [x20, #8]
Lloh13:
	adrp	x10, _JZ_REG_MMC_RXFIFO@GOTPAGE
Lloh14:
	ldr	x10, [x10, _JZ_REG_MMC_RXFIFO@GOTPAGEOFF]
	ldr	x9, [x9]
Lloh15:
	adrp	x11, _JZ_REG_MMC_TXFIFO@GOTPAGE
Lloh16:
	ldr	x11, [x11, _JZ_REG_MMC_TXFIFO@GOTPAGEOFF]
	csel	x10, x10, x11, eq
	ldr	x10, [x10]
	add	x9, x10, x9
	add	x10, sp, #8
	str	x9, [x10, x8]
Lloh17:
	adrp	x24, _COOKIE_MAPPED@GOTPAGE
Lloh18:
	ldr	x24, [x24, _COOKIE_MAPPED@GOTPAGEOFF]
	ldr	x2, [x24]
	mov	x0, x20
	mov	x1, x19
	bl	_jz4740_mmc_prepare_dma_data
	mov	x22, x0
	tbnz	w0, #31, LBB0_6
; %bb.1:
	add	x1, sp, #8
	mov	x0, x21
	bl	_dmaengine_slave_config
	ldr	w1, [x19, #16]
Lloh19:
	adrp	x8, _DMA_PREP_INTERRUPT@GOTPAGE
Lloh20:
	ldr	x8, [x8, _DMA_PREP_INTERRUPT@GOTPAGEOFF]
	ldr	x3, [sp, #8]
Lloh21:
	ldr	w8, [x8]
Lloh22:
	adrp	x9, _DMA_CTRL_ACK@GOTPAGE
Lloh23:
	ldr	x9, [x9, _DMA_CTRL_ACK@GOTPAGEOFF]
Lloh24:
	ldr	w9, [x9]
	orr	w4, w9, w8
	mov	x0, x21
	mov	x2, x22
	bl	_dmaengine_prep_slave_sg
	cbz	x0, LBB0_3
; %bb.2:
	bl	_dmaengine_submit
	mov	x0, x21
	bl	_dma_async_issue_pending
	mov	w22, #0
	b	LBB0_6
LBB0_3:
	ldr	w0, [x20]
	bl	_mmc_dev
	ldr	x8, [sp, #8]
	ldr	x9, [x23]
Lloh25:
	adrp	x10, l_.str.2@PAGE
Lloh26:
	add	x10, x10, l_.str.2@PAGEOFF
Lloh27:
	adrp	x11, l_.str.1@PAGE
Lloh28:
	add	x11, x11, l_.str.1@PAGEOFF
	cmp	x8, x9
	csel	x2, x11, x10, eq
Lloh29:
	adrp	x1, l_.str@PAGE
Lloh30:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_err
	ldr	x8, [x19, #8]
	ldr	x9, [x24]
	cmp	x8, x9
	b.ne	LBB0_5
; %bb.4:
	mov	x0, x20
	mov	x1, x19
	bl	_jz4740_mmc_dma_unmap
LBB0_5:
Lloh31:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh32:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
Lloh33:
	ldr	w8, [x8]
	neg	w22, w8
LBB0_6:
	mov	x0, x22
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
	.loh AdrpLdrGot	Lloh17, Lloh18
	.loh AdrpLdrGot	Lloh15, Lloh16
	.loh AdrpLdrGot	Lloh13, Lloh14
	.loh AdrpLdrGot	Lloh11, Lloh12
	.loh AdrpLdrGot	Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh22, Lloh23, Lloh24
	.loh AdrpLdrGotLdr	Lloh19, Lloh20, Lloh21
	.loh AdrpAdd	Lloh29, Lloh30
	.loh AdrpAdd	Lloh27, Lloh28
	.loh AdrpAdd	Lloh25, Lloh26
	.loh AdrpLdrGotLdr	Lloh31, Lloh32, Lloh33
	.cfi_endproc
                                        ; -- End function
	.comm	_JZ4740_MMC_FIFO_HALF_SIZE,4,2  ; @JZ4740_MMC_FIFO_HALF_SIZE
	.comm	_DMA_SLAVE_BUSWIDTH_4_BYTES,4,2 ; @DMA_SLAVE_BUSWIDTH_4_BYTES
	.comm	_MMC_DATA_WRITE,4,2             ; @MMC_DATA_WRITE
	.comm	_DMA_MEM_TO_DEV,8,3             ; @DMA_MEM_TO_DEV
	.comm	_JZ_REG_MMC_TXFIFO,8,3          ; @JZ_REG_MMC_TXFIFO
	.comm	_DMA_DEV_TO_MEM,8,3             ; @DMA_DEV_TO_MEM
	.comm	_JZ_REG_MMC_RXFIFO,8,3          ; @JZ_REG_MMC_RXFIFO
	.comm	_COOKIE_MAPPED,8,3              ; @COOKIE_MAPPED
	.comm	_DMA_PREP_INTERRUPT,4,2         ; @DMA_PREP_INTERRUPT
	.comm	_DMA_CTRL_ACK,4,2               ; @DMA_CTRL_ACK
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Failed to allocate DMA %s descriptor"

l_.str.1:                               ; @.str.1
	.asciz	"TX"

l_.str.2:                               ; @.str.2
	.asciz	"RX"

	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.no_dead_strip	_jz4740_mmc_start_dma_transfer
.subsections_via_symbols
