	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function dw_mci_rk3288_execute_tuning
_dw_mci_rk3288_execute_tuning:          ## @dw_mci_rk3288_execute_tuning
	.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	$56, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%esi, %r15d
	movq	(%rdi), %r12
	movq	8(%rdi), %rbx
	movq	8(%rbx), %r14
	movl	4(%r14), %edi
	callq	_IS_ERR
	testq	%rax, %rax
	je	LBB0_2
## %bb.1:
	movl	(%rbx), %edi
	leaq	L_.str(%rip), %rsi
	callq	_dev_err
	movq	_EIO@GOTPCREL(%rip), %rax
LBB0_10:
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_29
LBB0_2:
	movl	(%r14), %eax
	movl	%eax, %edi
	shrl	$31, %edi
	addl	%eax, %edi
	sarl	%edi
	incl	%edi
	movq	_GFP_KERNEL@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movl	$8, %esi
	callq	_kmalloc_array
	testq	%rax, %rax
	je	LBB0_9
## %bb.3:
	movq	%rbx, -80(%rbp)                 ## 8-byte Spill
	movq	%rax, -56(%rbp)                 ## 8-byte Spill
	movl	(%r14), %esi
	testl	%esi, %esi
	jle	LBB0_16
## %bb.4:
	movq	%r14, %rdx
	movq	%r12, -88(%rbp)                 ## 8-byte Spill
	movl	%r15d, -60(%rbp)                ## 4-byte Spill
	xorl	%eax, %eax
	movq	%rax, -72(%rbp)                 ## 8-byte Spill
                                        ## implicit-def: $eax
                                        ## kill: killed $eax
	xorl	%ebx, %ebx
	xorl	%r14d, %r14d
	jmp	LBB0_5
	.p2align	4, 0x90
LBB0_8:                                 ##   in Loop: Header=BB0_5 Depth=1
	movq	-72(%rbp), %rax                 ## 8-byte Reload
	decl	%eax
	movq	-56(%rbp), %rcx                 ## 8-byte Reload
	movl	%r14d, 4(%rcx,%rax,8)
	incl	%r14d
	movl	(%rdx), %esi
LBB0_14:                                ##   in Loop: Header=BB0_5 Depth=1
	cmpl	%esi, %r14d
	jge	LBB0_15
LBB0_5:                                 ## =>This Inner Loop Header: Depth=1
	movl	%ebx, %r12d
	movq	%rdx, %r15
	movl	4(%rdx), %ebx
	movl	%r14d, %edi
                                        ## kill: def $esi killed $esi killed $rsi
	callq	_TUNING_ITERATION_TO_PHASE
	movl	%ebx, %edi
	movl	%eax, %esi
	callq	_clk_set_phase
	movq	-88(%rbp), %rdi                 ## 8-byte Reload
	movl	-60(%rbp), %esi                 ## 4-byte Reload
	xorl	%edx, %edx
	callq	_mmc_send_tuning
	movl	%eax, %r13d
	xorl	%ebx, %ebx
	testl	%eax, %eax
	sete	%bl
	testl	%r14d, %r14d
	movl	-44(%rbp), %edi                 ## 4-byte Reload
	cmovel	%ebx, %edi
	orl	%eax, %r12d
	jne	LBB0_7
## %bb.6:                               ##   in Loop: Header=BB0_5 Depth=1
	movq	-72(%rbp), %rcx                 ## 8-byte Reload
	movl	%ecx, %eax
	incl	%ecx
	movq	%rcx, -72(%rbp)                 ## 8-byte Spill
	movq	-56(%rbp), %rcx                 ## 8-byte Reload
	movl	%r14d, (%rcx,%rax,8)
LBB0_7:                                 ##   in Loop: Header=BB0_5 Depth=1
	testl	%r13d, %r13d
	movq	%r15, %rdx
	movl	%edi, -44(%rbp)                 ## 4-byte Spill
	je	LBB0_8
## %bb.11:                              ##   in Loop: Header=BB0_5 Depth=1
	movl	(%rdx), %esi
	leal	-1(%rsi), %eax
	cmpl	%eax, %r14d
	jne	LBB0_13
## %bb.12:                              ##   in Loop: Header=BB0_5 Depth=1
	incl	%r14d
	jmp	LBB0_14
	.p2align	4, 0x90
LBB0_13:                                ##   in Loop: Header=BB0_5 Depth=1
	shll	$2, %esi
	leal	(%rsi,%rsi,4), %edi
	movl	$360, %esi                      ## imm = 0x168
	callq	_DIV_ROUND_UP
	movq	%r15, %rdx
	addl	%eax, %r14d
	movl	(%r15), %esi
	leal	-1(%rsi), %eax
	cmpl	%esi, %r14d
	cmovgel	%eax, %r14d
	jmp	LBB0_14
LBB0_15:
	movq	-72(%rbp), %rcx                 ## 8-byte Reload
	testl	%ecx, %ecx
	je	LBB0_16
## %bb.17:
	cmpl	$1, %ecx
	je	LBB0_20
## %bb.18:
	cmpl	$0, -44(%rbp)                   ## 4-byte Folded Reload
	je	LBB0_20
## %bb.19:
	testl	%r13d, %r13d
	jne	LBB0_20
## %bb.21:
	decl	%ecx
	movq	-56(%rbp), %r14                 ## 8-byte Reload
	movl	(%r14,%rcx,8), %eax
	movl	%eax, (%r14)
	testl	%eax, %eax
	jne	LBB0_25
	jmp	LBB0_23
LBB0_16:
	movq	-80(%rbp), %rax                 ## 8-byte Reload
	movl	(%rax), %edi
	leaq	L_.str.1(%rip), %rsi
	callq	_dev_warn
	movq	_EIO@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	movq	-56(%rbp), %r14                 ## 8-byte Reload
	jmp	LBB0_28
LBB0_9:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	jmp	LBB0_10
LBB0_20:
	movq	-56(%rbp), %r14                 ## 8-byte Reload
	movl	(%r14), %eax
	testl	%eax, %eax
	jne	LBB0_25
LBB0_23:
	decl	%esi
	cmpl	%esi, 4(%r14)
	jne	LBB0_25
## %bb.24:
	movq	%rdx, %rbx
	movl	4(%rdx), %edi
	movl	8(%rdx), %esi
	callq	_clk_set_phase
	movq	-80(%rbp), %rax                 ## 8-byte Reload
	movl	(%rax), %edi
	movl	8(%rbx), %edx
	leaq	L_.str.2(%rip), %rsi
	callq	_dev_info
	xorl	%ebx, %ebx
	jmp	LBB0_28
LBB0_25:
	movl	%ecx, %eax
	movq	%rax, -96(%rbp)                 ## 8-byte Spill
	movl	$-1, %r12d
	xorl	%r13d, %r13d
	movl	$-1, -44(%rbp)                  ## 4-byte Folded Spill
	movq	%rdx, -88(%rbp)                 ## 8-byte Spill
	movq	-56(%rbp), %r14                 ## 8-byte Reload
	movq	-88(%rbp), %r15                 ## 8-byte Reload
	.p2align	4, 0x90
LBB0_26:                                ## =>This Inner Loop Header: Depth=1
	movl	(%r14,%r13,8), %edi
	movl	4(%r14,%r13,8), %eax
	subl	%edi, %eax
	cmpl	$-1, %eax
	movl	(%r15), %esi
	movl	$0, %ecx
	cmovll	%esi, %ecx
	leal	(%rax,%rcx), %ebx
	incl	%ebx
	movl	-44(%rbp), %eax                 ## 4-byte Reload
	cmpl	%ebx, %eax
	cmovlel	%ebx, %eax
	movl	%eax, -44(%rbp)                 ## 4-byte Spill
	cmovll	%r13d, %r12d
	movq	-80(%rbp), %rax                 ## 8-byte Reload
	movl	(%rax), %eax
	movl	%eax, -72(%rbp)                 ## 4-byte Spill
	callq	_TUNING_ITERATION_TO_PHASE
	movl	%eax, -60(%rbp)                 ## 4-byte Spill
	movl	4(%r14,%r13,8), %edi
	movl	(%r15), %esi
	callq	_TUNING_ITERATION_TO_PHASE
	movl	-72(%rbp), %edi                 ## 4-byte Reload
	leaq	L_.str.3(%rip), %rsi
	movl	-60(%rbp), %edx                 ## 4-byte Reload
	movl	%eax, %ecx
	movl	%ebx, %r8d
	callq	_dev_dbg
	incq	%r13
	cmpq	%r13, -96(%rbp)                 ## 8-byte Folded Reload
	jne	LBB0_26
## %bb.27:
	movq	-88(%rbp), %r13                 ## 8-byte Reload
	movl	(%r13), %esi
	movslq	%r12d, %r15
	movq	-80(%rbp), %rax                 ## 8-byte Reload
	movl	(%rax), %ebx
	movq	-56(%rbp), %r12                 ## 8-byte Reload
	movl	(%r12,%r15,8), %edi
	callq	_TUNING_ITERATION_TO_PHASE
	movl	%eax, %r14d
	movl	4(%r12,%r15,8), %edi
	movl	(%r13), %esi
	callq	_TUNING_ITERATION_TO_PHASE
	leaq	L_.str.4(%rip), %rsi
	movl	%ebx, %edi
	movl	%r14d, %edx
	movl	%eax, %ecx
	movl	-44(%rbp), %ebx                 ## 4-byte Reload
	movl	%ebx, %r8d
	callq	_dev_dbg
	movl	%ebx, %eax
	shrl	$31, %eax
	addl	%ebx, %eax
	sarl	%eax
	addl	(%r12,%r15,8), %eax
	movl	(%r13), %esi
	cltd
	idivl	%esi
	movl	%edx, %ebx
	movq	-80(%rbp), %rax                 ## 8-byte Reload
	movl	(%rax), %r14d
	movl	%edx, %edi
	callq	_TUNING_ITERATION_TO_PHASE
	leaq	L_.str.5(%rip), %rsi
	movl	%r14d, %edi
	movl	%eax, %edx
	callq	_dev_info
	movl	(%r13), %esi
	movl	4(%r13), %r14d
	movl	%ebx, %edi
	callq	_TUNING_ITERATION_TO_PHASE
	movl	%r14d, %edi
	movl	%eax, %esi
	callq	_clk_set_phase
	xorl	%ebx, %ebx
	movq	%r12, %r14
LBB0_28:
	movq	%r14, %rdi
	callq	_kfree
LBB0_29:
	movl	%ebx, %eax
	addq	$56, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Tuning clock (sample_clk) not defined.\n"

	.comm	_EIO,4,2                        ## @EIO
	.comm	_GFP_KERNEL,4,2                 ## @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ## @ENOMEM
L_.str.1:                               ## @.str.1
	.asciz	"All phases bad!"

L_.str.2:                               ## @.str.2
	.asciz	"All phases work, using default phase %d."

L_.str.3:                               ## @.str.3
	.asciz	"Good phase range %d-%d (%d len)\n"

L_.str.4:                               ## @.str.4
	.asciz	"Best phase range %d-%d (%d len)\n"

L_.str.5:                               ## @.str.5
	.asciz	"Successfully tuned phase to %d\n"

	.no_dead_strip	_dw_mci_rk3288_execute_tuning
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function dw_mci_rk3288_execute_tuning
_dw_mci_rk3288_execute_tuning:          ; @dw_mci_rk3288_execute_tuning
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x28, x27, [sp, #16]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	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
	.cfi_offset w25, -72
	.cfi_offset w26, -80
	.cfi_offset w27, -88
	.cfi_offset w28, -96
	mov	x20, x1
	ldp	x21, x26, [x0]
	ldr	x25, [x26, #8]
	ldr	w0, [x25, #4]
	bl	_IS_ERR
	cbz	x0, LBB0_3
; %bb.1:
	ldr	w0, [x26]
Lloh0:
	adrp	x1, l_.str@PAGE
Lloh1:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_err
Lloh2:
	adrp	x8, _EIO@GOTPAGE
Lloh3:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
LBB0_2:
	ldr	w8, [x8]
	neg	w20, w8
	b	LBB0_29
LBB0_3:
	ldr	w8, [x25]
	cmp	w8, #0
	cinc	w8, w8, lt
	asr	w8, w8, #1
	add	w0, w8, #1
Lloh4:
	adrp	x8, _GFP_KERNEL@GOTPAGE
Lloh5:
	ldr	x8, [x8, _GFP_KERNEL@GOTPAGEOFF]
Lloh6:
	ldr	w2, [x8]
	mov	w1, #8
	bl	_kmalloc_array
	str	x0, [sp, #8]                    ; 8-byte Folded Spill
	cbz	x0, LBB0_20
; %bb.4:
	ldr	w1, [x25]
	cmp	w1, #1
	b.lt	LBB0_19
; %bb.5:
	mov	w24, #0
	mov	w28, #0
	mov	w22, #0
                                        ; implicit-def: $w27
	b	LBB0_8
LBB0_6:                                 ;   in Loop: Header=BB0_8 Depth=1
	sub	w8, w24, #1
	ldr	x9, [sp, #8]                    ; 8-byte Folded Reload
	add	x8, x9, w8, uxtw #3
	str	w22, [x8, #4]
	add	w22, w22, #1
	ldr	w1, [x25]
LBB0_7:                                 ;   in Loop: Header=BB0_8 Depth=1
	cmp	w22, w1
	b.ge	LBB0_14
LBB0_8:                                 ; =>This Inner Loop Header: Depth=1
	mov	x19, x28
	ldr	w23, [x25, #4]
	mov	x0, x22
	bl	_TUNING_ITERATION_TO_PHASE
	mov	x1, x0
	mov	x0, x23
	bl	_clk_set_phase
	mov	x0, x21
	mov	x1, x20
	mov	x2, #0
	bl	_mmc_send_tuning
	mov	x23, x0
	cmp	w0, #0
	cset	w28, eq
	cmp	w22, #0
	csel	w27, w28, w27, eq
	orr	w8, w19, w0
	cbnz	w8, LBB0_10
; %bb.9:                                ;   in Loop: Header=BB0_8 Depth=1
	mov	w8, w24
	add	w24, w24, #1
	lsl	x8, x8, #3
	ldr	x9, [sp, #8]                    ; 8-byte Folded Reload
	str	w22, [x9, x8]
LBB0_10:                                ;   in Loop: Header=BB0_8 Depth=1
	cbz	w23, LBB0_6
; %bb.11:                               ;   in Loop: Header=BB0_8 Depth=1
	ldr	w1, [x25]
	sub	w8, w1, #1
	cmp	w22, w8
	b.ne	LBB0_13
; %bb.12:                               ;   in Loop: Header=BB0_8 Depth=1
	add	w22, w22, #1
	b	LBB0_7
LBB0_13:                                ;   in Loop: Header=BB0_8 Depth=1
	add	w8, w1, w1, lsl #2
	lsl	w0, w8, #2
	mov	w1, #360
	bl	_DIV_ROUND_UP
	ldr	w1, [x25]
	sub	w8, w1, #1
	add	w9, w22, w0
	cmp	w9, w1
	csel	w22, w9, w8, lt
	b	LBB0_7
LBB0_14:
	cbz	w24, LBB0_19
; %bb.15:
	subs	w8, w24, #1
	b.eq	LBB0_21
; %bb.16:
	cbz	w27, LBB0_21
; %bb.17:
	cbnz	w23, LBB0_21
; %bb.18:
	lsl	x9, x8, #3
	ldr	x10, [sp, #8]                   ; 8-byte Folded Reload
	ldr	w9, [x10, x9]
	str	w9, [x10]
	mov	x24, x8
	cbnz	w9, LBB0_24
	b	LBB0_22
LBB0_19:
	ldr	w0, [x26]
Lloh7:
	adrp	x1, l_.str.1@PAGE
Lloh8:
	add	x1, x1, l_.str.1@PAGEOFF
	bl	_dev_warn
Lloh9:
	adrp	x8, _EIO@GOTPAGE
Lloh10:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
Lloh11:
	ldr	w8, [x8]
	neg	w20, w8
	b	LBB0_28
LBB0_20:
Lloh12:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh13:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
	b	LBB0_2
LBB0_21:
	ldr	x8, [sp, #8]                    ; 8-byte Folded Reload
	ldr	w9, [x8]
	cbnz	w9, LBB0_24
LBB0_22:
	ldr	x8, [sp, #8]                    ; 8-byte Folded Reload
	ldr	w8, [x8, #4]
	sub	w9, w1, #1
	cmp	w8, w9
	b.ne	LBB0_24
; %bb.23:
	ldp	w0, w1, [x25, #4]
	bl	_clk_set_phase
	ldr	w0, [x26]
	ldr	w2, [x25, #8]
Lloh14:
	adrp	x1, l_.str.2@PAGE
Lloh15:
	add	x1, x1, l_.str.2@PAGEOFF
	bl	_dev_info
	b	LBB0_27
LBB0_24:
	mov	x27, #0
	mov	w19, w24
	ldr	x8, [sp, #8]                    ; 8-byte Folded Reload
	add	x21, x8, #4
	mov	w28, #-1
	mov	w20, #-1
LBB0_25:                                ; =>This Inner Loop Header: Depth=1
	ldp	w0, w8, [x21, #-4]
	ldr	w1, [x25]
	sub	w8, w8, w0
	cmn	w8, #1
	csel	w9, w1, wzr, lt
	add	w8, w8, w9
	add	w22, w8, #1
	cmp	w20, w22
	csel	w28, w27, w28, lt
	csinc	w20, w20, w8, gt
	ldr	w23, [x26]
	bl	_TUNING_ITERATION_TO_PHASE
	mov	x24, x0
	ldr	w0, [x21], #8
	ldr	w1, [x25]
	bl	_TUNING_ITERATION_TO_PHASE
	mov	x3, x0
	mov	x0, x23
Lloh16:
	adrp	x1, l_.str.3@PAGE
Lloh17:
	add	x1, x1, l_.str.3@PAGEOFF
	mov	x2, x24
	mov	x4, x22
	bl	_dev_dbg
	add	x27, x27, #1
	cmp	x19, x27
	b.ne	LBB0_25
; %bb.26:
	ldr	w1, [x25]
	ldr	w21, [x26]
	ldr	x8, [sp, #8]                    ; 8-byte Folded Reload
	add	x19, x8, w28, sxtw #3
	ldr	w0, [x19]
	bl	_TUNING_ITERATION_TO_PHASE
	mov	x22, x0
	ldr	w0, [x19, #4]
	ldr	w1, [x25]
	bl	_TUNING_ITERATION_TO_PHASE
	mov	x3, x0
Lloh18:
	adrp	x1, l_.str.4@PAGE
Lloh19:
	add	x1, x1, l_.str.4@PAGEOFF
	mov	x0, x21
	mov	x2, x22
	mov	x4, x20
	bl	_dev_dbg
	ldr	w8, [x19]
	cmp	w20, #0
	cinc	w9, w20, lt
	add	w8, w8, w9, asr #1
	ldr	w1, [x25]
	sdiv	w9, w8, w1
	msub	w20, w9, w1, w8
	ldr	w21, [x26]
	mov	x0, x20
	bl	_TUNING_ITERATION_TO_PHASE
	mov	x2, x0
Lloh20:
	adrp	x1, l_.str.5@PAGE
Lloh21:
	add	x1, x1, l_.str.5@PAGEOFF
	mov	x0, x21
	bl	_dev_info
	ldp	w1, w21, [x25]
	mov	x0, x20
	bl	_TUNING_ITERATION_TO_PHASE
	mov	x1, x0
	mov	x0, x21
	bl	_clk_set_phase
LBB0_27:
	mov	w20, #0
LBB0_28:
	ldr	x0, [sp, #8]                    ; 8-byte Folded Reload
	bl	_kfree
LBB0_29:
	mov	x0, x20
	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
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh4, Lloh5, Lloh6
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpAdd	Lloh7, Lloh8
	.loh AdrpLdrGot	Lloh12, Lloh13
	.loh AdrpAdd	Lloh14, Lloh15
	.loh AdrpAdd	Lloh16, Lloh17
	.loh AdrpAdd	Lloh20, Lloh21
	.loh AdrpAdd	Lloh18, Lloh19
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Tuning clock (sample_clk) not defined.\n"

	.comm	_EIO,4,2                        ; @EIO
	.comm	_GFP_KERNEL,4,2                 ; @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ; @ENOMEM
l_.str.1:                               ; @.str.1
	.asciz	"All phases bad!"

l_.str.2:                               ; @.str.2
	.asciz	"All phases work, using default phase %d."

l_.str.3:                               ; @.str.3
	.asciz	"Good phase range %d-%d (%d len)\n"

l_.str.4:                               ; @.str.4
	.asciz	"Best phase range %d-%d (%d len)\n"

l_.str.5:                               ; @.str.5
	.asciz	"Successfully tuned phase to %d\n"

	.no_dead_strip	_dw_mci_rk3288_execute_tuning
.subsections_via_symbols
