	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_mtk_ecc_enable                 ## -- Begin function mtk_ecc_enable
	.p2align	4, 0x90
_mtk_ecc_enable:                        ## @mtk_ecc_enable
	.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
	movq	%rsi, %r12
	movq	%rdi, %r15
	movl	(%rsi), %r14d
	leaq	20(%rdi), %r13
	movq	%r13, %rdi
	callq	_mutex_lock_interruptible
	testl	%eax, %eax
	je	LBB0_2
## %bb.1:
	movl	%eax, %ebx
	movl	24(%r15), %edi
	leaq	L_.str(%rip), %rsi
	callq	_dev_err
	jmp	LBB0_14
LBB0_2:
	movq	%r15, %rdi
	movl	%r14d, %esi
	callq	_mtk_ecc_wait_idle
	movq	%r15, %rdi
	movq	%r12, %rsi
	callq	_mtk_ecc_config
	testl	%eax, %eax
	je	LBB0_4
## %bb.3:
	movl	%eax, %ebx
	movq	%r13, %rdi
	callq	_mutex_unlock
	jmp	LBB0_14
LBB0_4:
	movq	8(%r12), %rax
	movq	_ECC_NFI_MODE@GOTPCREL(%rip), %rbx
	movq	_ECC_ENCODE@GOTPCREL(%rip), %r13
	cmpq	(%rbx), %rax
	jne	LBB0_6
## %bb.5:
	cmpl	(%r13), %r14d
	je	LBB0_13
LBB0_6:
	leaq	16(%r15), %rdi
	callq	_init_completion
	movq	_ECC_IRQ_EN@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	movq	8(%r15), %rax
	cmpq	$0, 8(%rax)
	je	LBB0_9
## %bb.7:
	movq	8(%r12), %rcx
	cmpq	(%rbx), %rcx
	jne	LBB0_9
## %bb.8:
	movq	_ECC_PG_IRQ_SEL@GOTPCREL(%rip), %rcx
	orl	(%rcx), %edi
LBB0_9:
	movq	(%rax), %rax
	cmpl	(%r13), %r14d
	jne	LBB0_10
## %bb.11:
	movq	_ECC_ENCIRQ_EN@GOTPCREL(%rip), %rcx
	jmp	LBB0_12
LBB0_10:
	movq	_ECC_DECIRQ_EN@GOTPCREL(%rip), %rcx
LBB0_12:
	movq	(%rcx), %rcx
	movq	(%rax,%rcx,8), %rsi
	addq	(%r15), %rsi
	callq	_writew
LBB0_13:
	movq	_ECC_OP_ENABLE@GOTPCREL(%rip), %rax
	movl	(%rax), %r12d
	movq	(%r15), %rbx
	movl	%r14d, %edi
	callq	_ECC_CTL_REG
	addq	%rax, %rbx
	movl	%r12d, %edi
	movq	%rbx, %rsi
	callq	_writew
	xorl	%ebx, %ebx
LBB0_14:
	movl	%ebx, %eax
	addq	$8, %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	"interrupted when attempting to lock\n"

	.comm	_ECC_NFI_MODE,8,3               ## @ECC_NFI_MODE
	.comm	_ECC_ENCODE,4,2                 ## @ECC_ENCODE
	.comm	_ECC_IRQ_EN,4,2                 ## @ECC_IRQ_EN
	.comm	_ECC_PG_IRQ_SEL,4,2             ## @ECC_PG_IRQ_SEL
	.comm	_ECC_ENCIRQ_EN,8,3              ## @ECC_ENCIRQ_EN
	.comm	_ECC_DECIRQ_EN,8,3              ## @ECC_DECIRQ_EN
	.comm	_ECC_OP_ENABLE,4,2              ## @ECC_OP_ENABLE
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_mtk_ecc_enable                 ; -- Begin function mtk_ecc_enable
	.p2align	2
_mtk_ecc_enable:                        ; @mtk_ecc_enable
	.cfi_startproc
; %bb.0:
	stp	x24, x23, [sp, #-64]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 64
	stp	x22, x21, [sp, #16]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #32]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #48]             ; 16-byte Folded Spill
	add	x29, sp, #48
	.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	x21, x1
	mov	x19, x0
	ldr	w20, [x1]
	add	x23, x0, #20
	mov	x0, x23
	bl	_mutex_lock_interruptible
	cbz	w0, LBB0_2
; %bb.1:
	mov	x22, x0
	ldr	w0, [x19, #24]
Lloh0:
	adrp	x1, l_.str@PAGE
Lloh1:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_err
	b	LBB0_10
LBB0_2:
	mov	x0, x19
	mov	x1, x20
	bl	_mtk_ecc_wait_idle
	mov	x0, x19
	mov	x1, x21
	bl	_mtk_ecc_config
	cbz	w0, LBB0_4
; %bb.3:
	mov	x22, x0
	mov	x0, x23
	bl	_mutex_unlock
	b	LBB0_10
LBB0_4:
	ldr	x8, [x21, #8]
Lloh2:
	adrp	x23, _ECC_NFI_MODE@GOTPAGE
Lloh3:
	ldr	x23, [x23, _ECC_NFI_MODE@GOTPAGEOFF]
	ldr	x9, [x23]
Lloh4:
	adrp	x22, _ECC_ENCODE@GOTPAGE
Lloh5:
	ldr	x22, [x22, _ECC_ENCODE@GOTPAGEOFF]
	ldr	w10, [x22]
	cmp	x8, x9
	ccmp	w20, w10, #0, eq
	b.eq	LBB0_9
; %bb.5:
	add	x0, x19, #16
	bl	_init_completion
Lloh6:
	adrp	x8, _ECC_IRQ_EN@GOTPAGE
Lloh7:
	ldr	x8, [x8, _ECC_IRQ_EN@GOTPAGEOFF]
Lloh8:
	ldr	w0, [x8]
	ldr	x8, [x19, #8]
	ldr	x9, [x8, #8]
	cbz	x9, LBB0_8
; %bb.6:
	ldr	x9, [x21, #8]
	ldr	x10, [x23]
	cmp	x9, x10
	b.ne	LBB0_8
; %bb.7:
Lloh9:
	adrp	x9, _ECC_PG_IRQ_SEL@GOTPAGE
Lloh10:
	ldr	x9, [x9, _ECC_PG_IRQ_SEL@GOTPAGEOFF]
Lloh11:
	ldr	w9, [x9]
	orr	w0, w9, w0
LBB0_8:
	ldr	w9, [x22]
	ldr	x10, [x19]
	ldr	x8, [x8]
Lloh12:
	adrp	x11, _ECC_ENCIRQ_EN@GOTPAGE
Lloh13:
	ldr	x11, [x11, _ECC_ENCIRQ_EN@GOTPAGEOFF]
Lloh14:
	adrp	x12, _ECC_DECIRQ_EN@GOTPAGE
Lloh15:
	ldr	x12, [x12, _ECC_DECIRQ_EN@GOTPAGEOFF]
	cmp	w20, w9
	csel	x9, x11, x12, eq
	ldr	x9, [x9]
	ldr	x8, [x8, x9, lsl #3]
	add	x1, x8, x10
	bl	_writew
LBB0_9:
Lloh16:
	adrp	x8, _ECC_OP_ENABLE@GOTPAGE
Lloh17:
	ldr	x8, [x8, _ECC_OP_ENABLE@GOTPAGEOFF]
Lloh18:
	ldr	w21, [x8]
	ldr	x19, [x19]
	mov	x0, x20
	bl	_ECC_CTL_REG
	add	x1, x0, x19
	mov	x0, x21
	bl	_writew
	mov	w22, #0
LBB0_10:
	mov	x0, x22
	ldp	x29, x30, [sp, #48]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #32]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #16]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp], #64             ; 16-byte Folded Reload
	ret
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGot	Lloh14, Lloh15
	.loh AdrpLdrGot	Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"interrupted when attempting to lock\n"

	.comm	_ECC_NFI_MODE,8,3               ; @ECC_NFI_MODE
	.comm	_ECC_ENCODE,4,2                 ; @ECC_ENCODE
	.comm	_ECC_IRQ_EN,4,2                 ; @ECC_IRQ_EN
	.comm	_ECC_PG_IRQ_SEL,4,2             ; @ECC_PG_IRQ_SEL
	.comm	_ECC_ENCIRQ_EN,8,3              ; @ECC_ENCIRQ_EN
	.comm	_ECC_DECIRQ_EN,8,3              ; @ECC_DECIRQ_EN
	.comm	_ECC_OP_ENABLE,4,2              ; @ECC_OP_ENABLE
.subsections_via_symbols
