	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mtk_cmd_desc_ring_setup
_mtk_cmd_desc_ring_setup:               ## @mtk_cmd_desc_ring_setup
	.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
	movl	(%rdx), %edi
	callq	_MTK_CMD_FIFO_SIZE
	movl	$1, %edx
	movl	%eax, %ecx
	shll	%cl, %edx
	movq	_MTK_DESC_SZ@GOTPCREL(%rip), %rcx
	movl	%edx, %eax
	cltd
	idivl	(%rcx)
                                        ## kill: def $eax killed $eax def $rax
	decl	%eax
	movl	%eax, -44(%rbp)                 ## 4-byte Spill
	movq	(%r15), %rbx
	movl	%r12d, %edi
	callq	_CDR_CFG
	addq	%rax, %rbx
	xorl	%edi, %edi
	movq	%rbx, %rsi
	callq	_writel
	movq	_MTK_CNT_RST@GOTPCREL(%rip), %r14
	movl	(%r14), %r13d
	movq	(%r15), %rbx
	movl	%r12d, %edi
	callq	_CDR_PREP_COUNT
	addq	%rax, %rbx
	movl	%r13d, %edi
	movq	%rbx, %rsi
	callq	_writel
	movl	(%r14), %r13d
	movq	(%r15), %rbx
	movl	%r12d, %edi
	callq	_CDR_PROC_COUNT
	addq	%rax, %rbx
	movl	%r13d, %edi
	movq	%rbx, %rsi
	callq	_writel
	movq	(%r15), %rbx
	movl	%r12d, %edi
	callq	_CDR_PREP_PNTR
	addq	%rax, %rbx
	xorl	%edi, %edi
	movq	%rbx, %rsi
	callq	_writel
	movq	(%r15), %rbx
	movl	%r12d, %edi
	callq	_CDR_PROC_PNTR
	addq	%rax, %rbx
	xorl	%edi, %edi
	movq	%rbx, %rsi
	callq	_writel
	movq	(%r15), %rbx
	movl	%r12d, %edi
	callq	_CDR_DMA_CFG
	addq	%rax, %rbx
	xorl	%edi, %edi
	movq	%rbx, %rsi
	callq	_writel
	movq	(%r15), %rbx
	movl	%r12d, %edi
	callq	_CDR_BASE_ADDR_HI
	addq	%rax, %rbx
	xorl	%edi, %edi
	movq	%rbx, %rsi
	callq	_writel
	movq	(%r15), %rbx
	movq	8(%r15), %rax
	movslq	%r12d, %r12
	movq	(%rax,%r12,8), %rax
	movl	(%rax), %r13d
	movl	%r12d, %edi
	callq	_CDR_BASE_ADDR_LO
	addq	%rax, %rbx
	movl	%r13d, %edi
	movq	%rbx, %rsi
	callq	_writel
	movq	_MTK_DESC_RING_SZ@GOTPCREL(%rip), %rax
	movl	(%rax), %r13d
	movq	(%r15), %rbx
	movl	%r12d, %edi
	callq	_CDR_RING_SIZE
	addq	%rax, %rbx
	movl	%r13d, %edi
	movq	%rbx, %rsi
	callq	_writel
	movq	_MTK_CDR_STAT_CLR@GOTPCREL(%rip), %rax
	movl	(%rax), %r13d
	movq	(%r15), %rbx
	movl	%r12d, %edi
	callq	_CDR_STAT
	addq	%rax, %rbx
	movl	%r13d, %edi
	movq	%rbx, %rsi
	callq	_writel
	movq	_MTK_DESC_SZ@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_MTK_DESC_SIZE
	movl	%eax, %ebx
	movq	_MTK_DESC_OFF@GOTPCREL(%rip), %r14
	movl	(%r14), %edi
	callq	_MTK_DESC_OFFSET
	orl	%eax, %ebx
	movq	_MTK_DESC_ATP_PRESENT@GOTPCREL(%rip), %rax
	orl	(%rax), %ebx
	movq	(%r15), %r13
	movl	%r12d, %edi
	callq	_CDR_DESC_SIZE
	addq	%rax, %r13
	movl	%ebx, %edi
	movq	%r13, %rsi
	callq	_writel
	movl	(%r14), %edi
	movl	-44(%rbp), %ebx                 ## 4-byte Reload
	imull	%ebx, %edi
	callq	_MTK_DESC_FETCH_SIZE
	movl	%eax, %r13d
	movq	_MTK_DESC_SZ@GOTPCREL(%rip), %rax
	imull	(%rax), %ebx
	movl	%ebx, %edi
	callq	_MTK_DESC_FETCH_THRESH
	orl	%eax, %r13d
	movq	(%r15), %rbx
	movl	%r12d, %edi
	callq	_CDR_CFG
	addq	%rax, %rbx
	movl	%r13d, %edi
	movq	%rbx, %rsi
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_writel                         ## TAILCALL
	.cfi_endproc
                                        ## -- End function
	.comm	_MTK_DESC_SZ,4,2                ## @MTK_DESC_SZ
	.comm	_MTK_CNT_RST,4,2                ## @MTK_CNT_RST
	.comm	_MTK_DESC_RING_SZ,4,2           ## @MTK_DESC_RING_SZ
	.comm	_MTK_CDR_STAT_CLR,4,2           ## @MTK_CDR_STAT_CLR
	.comm	_MTK_DESC_OFF,4,2               ## @MTK_DESC_OFF
	.comm	_MTK_DESC_ATP_PRESENT,4,2       ## @MTK_DESC_ATP_PRESENT
	.no_dead_strip	_mtk_cmd_desc_ring_setup
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mtk_cmd_desc_ring_setup
_mtk_cmd_desc_ring_setup:               ; @mtk_cmd_desc_ring_setup
	.cfi_startproc
; %bb.0:
	stp	x26, x25, [sp, #-80]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.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
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	mov	x19, x1
	mov	x20, x0
	ldr	w0, [x2]
	bl	_MTK_CMD_FIFO_SIZE
	mov	w8, #1
	lsl	w8, w8, w0
Lloh0:
	adrp	x22, _MTK_DESC_SZ@GOTPAGE
Lloh1:
	ldr	x22, [x22, _MTK_DESC_SZ@GOTPAGEOFF]
	ldr	w9, [x22]
	sdiv	w8, w8, w9
	sub	w23, w8, #1
	ldr	x21, [x20]
	mov	x0, x19
	bl	_CDR_CFG
	add	x1, x0, x21
	mov	w0, #0
	bl	_writel
Lloh2:
	adrp	x24, _MTK_CNT_RST@GOTPAGE
Lloh3:
	ldr	x24, [x24, _MTK_CNT_RST@GOTPAGEOFF]
	ldr	w21, [x24]
	ldr	x25, [x20]
	mov	x0, x19
	bl	_CDR_PREP_COUNT
	add	x1, x0, x25
	mov	x0, x21
	bl	_writel
	ldr	w21, [x24]
	ldr	x24, [x20]
	mov	x0, x19
	bl	_CDR_PROC_COUNT
	add	x1, x0, x24
	mov	x0, x21
	bl	_writel
	ldr	x21, [x20]
	mov	x0, x19
	bl	_CDR_PREP_PNTR
	add	x1, x0, x21
	mov	w0, #0
	bl	_writel
	ldr	x21, [x20]
	mov	x0, x19
	bl	_CDR_PROC_PNTR
	add	x1, x0, x21
	mov	w0, #0
	bl	_writel
	ldr	x21, [x20]
	mov	x0, x19
	bl	_CDR_DMA_CFG
	add	x1, x0, x21
	mov	w0, #0
	bl	_writel
	ldr	x21, [x20]
	mov	x0, x19
	bl	_CDR_BASE_ADDR_HI
	add	x1, x0, x21
	mov	w0, #0
	bl	_writel
	ldp	x24, x8, [x20]
	ldr	x8, [x8, w19, sxtw #3]
	ldr	w21, [x8]
	mov	x0, x19
	bl	_CDR_BASE_ADDR_LO
	add	x1, x0, x24
	mov	x0, x21
	bl	_writel
Lloh4:
	adrp	x8, _MTK_DESC_RING_SZ@GOTPAGE
Lloh5:
	ldr	x8, [x8, _MTK_DESC_RING_SZ@GOTPAGEOFF]
Lloh6:
	ldr	w21, [x8]
	ldr	x24, [x20]
	mov	x0, x19
	bl	_CDR_RING_SIZE
	add	x1, x0, x24
	mov	x0, x21
	bl	_writel
Lloh7:
	adrp	x8, _MTK_CDR_STAT_CLR@GOTPAGE
Lloh8:
	ldr	x8, [x8, _MTK_CDR_STAT_CLR@GOTPAGEOFF]
Lloh9:
	ldr	w21, [x8]
	ldr	x24, [x20]
	mov	x0, x19
	bl	_CDR_STAT
	add	x1, x0, x24
	mov	x0, x21
	bl	_writel
	ldr	w0, [x22]
	bl	_MTK_DESC_SIZE
	mov	x21, x0
Lloh10:
	adrp	x24, _MTK_DESC_OFF@GOTPAGE
Lloh11:
	ldr	x24, [x24, _MTK_DESC_OFF@GOTPAGEOFF]
	ldr	w0, [x24]
	bl	_MTK_DESC_OFFSET
	orr	w8, w0, w21
Lloh12:
	adrp	x9, _MTK_DESC_ATP_PRESENT@GOTPAGE
Lloh13:
	ldr	x9, [x9, _MTK_DESC_ATP_PRESENT@GOTPAGEOFF]
Lloh14:
	ldr	w9, [x9]
	orr	w21, w8, w9
	ldr	x25, [x20]
	mov	x0, x19
	bl	_CDR_DESC_SIZE
	add	x1, x0, x25
	mov	x0, x21
	bl	_writel
	ldr	w8, [x24]
	mul	w0, w8, w23
	bl	_MTK_DESC_FETCH_SIZE
	mov	x21, x0
	ldr	w8, [x22]
	mul	w0, w8, w23
	bl	_MTK_DESC_FETCH_THRESH
	orr	w21, w0, w21
	ldr	x20, [x20]
	mov	x0, x19
	bl	_CDR_CFG
	add	x1, x0, x20
	mov	x0, x21
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp], #80             ; 16-byte Folded Reload
	b	_writel
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGot	Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpLdrGotLdr	Lloh4, Lloh5, Lloh6
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.cfi_endproc
                                        ; -- End function
	.comm	_MTK_DESC_SZ,4,2                ; @MTK_DESC_SZ
	.comm	_MTK_CNT_RST,4,2                ; @MTK_CNT_RST
	.comm	_MTK_DESC_RING_SZ,4,2           ; @MTK_DESC_RING_SZ
	.comm	_MTK_CDR_STAT_CLR,4,2           ; @MTK_CDR_STAT_CLR
	.comm	_MTK_DESC_OFF,4,2               ; @MTK_DESC_OFF
	.comm	_MTK_DESC_ATP_PRESENT,4,2       ; @MTK_DESC_ATP_PRESENT
	.no_dead_strip	_mtk_cmd_desc_ring_setup
.subsections_via_symbols
