	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function mtk_nfc_do_write_page
_mtk_nfc_do_write_page:                 ## @mtk_nfc_do_write_page
	.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	$24, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movl	%r8d, %r14d
	movq	%rdx, %rbx
	movq	%rsi, %rdi
	movq	%rsi, -64(%rbp)                 ## 8-byte Spill
	callq	_nand_get_controller_data
	movq	%rax, %r12
	movq	(%rax), %r15
	movq	_DMA_TO_DEVICE@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movq	%r15, %rdi
	movq	%rbx, %rsi
	movl	%r14d, %edx
	callq	_dma_map_single
	movl	%eax, %r13d
	movq	(%r12), %rdi
	movl	%eax, %esi
	callq	_dma_mapping_error
	testl	%eax, %eax
	je	LBB0_2
## %bb.1:
	movq	(%r12), %rdi
	leaq	L_.str(%rip), %rsi
	callq	_dev_err
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_8
LBB0_2:
	movq	%r15, -56(%rbp)                 ## 8-byte Spill
	movl	%r14d, -44(%rbp)                ## 4-byte Spill
	movq	_NFI_CNFG@GOTPCREL(%rip), %rbx
	movl	(%rbx), %esi
	movq	%r12, %rdi
	callq	_nfi_readw
	movq	_CNFG_AHB@GOTPCREL(%rip), %rcx
	orl	(%rcx), %eax
	movq	_CNFG_DMA_BURST_EN@GOTPCREL(%rip), %rcx
	orl	(%rcx), %eax
	movl	(%rbx), %edx
	movq	%r12, %rdi
	movl	%eax, %esi
	callq	_nfi_writew
	movq	-64(%rbp), %rax                 ## 8-byte Reload
	movl	(%rax), %esi
	movq	_CON_SEC_SHIFT@GOTPCREL(%rip), %rax
	movb	(%rax), %cl
	shll	%cl, %esi
	movq	_NFI_CON@GOTPCREL(%rip), %r15
	movl	(%r15), %edx
	movq	%r12, %rdi
	callq	_nfi_writel
	movl	%r13d, %edi
	callq	_lower_32_bits
	movq	_NFI_STRADDR@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edx
	movq	%r12, %rdi
	movl	%eax, %esi
	callq	_nfi_writel
	movq	_INTR_AHB_DONE_EN@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_NFI_INTR_EN@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r12, %rdi
	callq	_nfi_writew
	movq	%r12, %rbx
	addq	$16, %rbx
	movq	%rbx, %rdi
	callq	_init_completion
	movl	(%r15), %esi
	movq	%r12, %rdi
	callq	_nfi_readl
	movl	%eax, %r14d
	movq	_CON_BWR@GOTPCREL(%rip), %rax
	orl	(%rax), %r14d
	movl	(%r15), %edx
	movq	%r12, %rdi
	movl	%r14d, %esi
	callq	_nfi_writel
	movq	_STAR_EN@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_NFI_STRDATA@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%r12, %rdi
	callq	_nfi_writew
	movl	$500, %edi                      ## imm = 0x1F4
	callq	_msecs_to_jiffies
	movq	%rbx, %rdi
	movl	%eax, %esi
	callq	_wait_for_completion_timeout
	testl	%eax, %eax
	je	LBB0_3
## %bb.4:
	movq	_NFI_ADDRCNTR@GOTPCREL(%rip), %rax
	movq	(%rax), %rbx
	addq	8(%r12), %rbx
	movl	%r14d, %edi
	callq	_ADDRCNTR_SEC
	xorl	%edx, %edx
	movq	-64(%rbp), %rcx                 ## 8-byte Reload
	cmpl	(%rcx), %eax
	setge	%dl
	movq	_MTK_TIMEOUT@GOTPCREL(%rip), %rax
	movl	(%rax), %r8d
	movq	%rbx, %rdi
	movl	%r14d, %esi
	movl	$10, %ecx
	callq	_readl_poll_timeout_atomic
	testl	%eax, %eax
	je	LBB0_5
## %bb.6:
	movl	%eax, %ebx
	leaq	L_.str.2(%rip), %rsi
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	callq	_dev_err
	jmp	LBB0_7
LBB0_3:
	leaq	L_.str.1(%rip), %rsi
	movq	-56(%rbp), %rdi                 ## 8-byte Reload
	callq	_dev_err
	movq	_NFI_INTR_EN@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	xorl	%ebx, %ebx
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	_nfi_writew
	movq	_ETIMEDOUT@GOTPCREL(%rip), %rax
	subl	(%rax), %ebx
	jmp	LBB0_7
LBB0_5:
	xorl	%ebx, %ebx
LBB0_7:
	movl	-44(%rbp), %edx                 ## 4-byte Reload
	movq	_DMA_TO_DEVICE@GOTPCREL(%rip), %rax
	movq	(%r12), %rdi
	movl	(%rax), %ecx
	movl	%r13d, %esi
	callq	_dma_unmap_single
	movl	(%r15), %edx
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	_nfi_writel
LBB0_8:
	movl	%ebx, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_DMA_TO_DEVICE,4,2              ## @DMA_TO_DEVICE
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"dma mapping error\n"

	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_NFI_CNFG,4,2                   ## @NFI_CNFG
	.comm	_CNFG_AHB,4,2                   ## @CNFG_AHB
	.comm	_CNFG_DMA_BURST_EN,4,2          ## @CNFG_DMA_BURST_EN
	.comm	_CON_SEC_SHIFT,4,2              ## @CON_SEC_SHIFT
	.comm	_NFI_CON,4,2                    ## @NFI_CON
	.comm	_NFI_STRADDR,4,2                ## @NFI_STRADDR
	.comm	_INTR_AHB_DONE_EN,4,2           ## @INTR_AHB_DONE_EN
	.comm	_NFI_INTR_EN,4,2                ## @NFI_INTR_EN
	.comm	_CON_BWR,4,2                    ## @CON_BWR
	.comm	_STAR_EN,4,2                    ## @STAR_EN
	.comm	_NFI_STRDATA,4,2                ## @NFI_STRDATA
L_.str.1:                               ## @.str.1
	.asciz	"program ahb done timeout\n"

	.comm	_ETIMEDOUT,4,2                  ## @ETIMEDOUT
	.comm	_NFI_ADDRCNTR,8,3               ## @NFI_ADDRCNTR
	.comm	_MTK_TIMEOUT,4,2                ## @MTK_TIMEOUT
L_.str.2:                               ## @.str.2
	.asciz	"hwecc write timeout\n"

	.no_dead_strip	_mtk_nfc_do_write_page
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function mtk_nfc_do_write_page
_mtk_nfc_do_write_page:                 ; @mtk_nfc_do_write_page
	.cfi_startproc
; %bb.0:
	stp	x28, x27, [sp, #-96]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 96
	stp	x26, x25, [sp, #16]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #32]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #48]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #64]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #80]             ; 16-byte Folded Spill
	add	x29, sp, #80
	.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, x4
	mov	x21, x2
	mov	x23, x1
	mov	x0, x1
	bl	_nand_get_controller_data
	mov	x19, x0
	ldr	x22, [x0]
Lloh0:
	adrp	x26, _DMA_TO_DEVICE@GOTPAGE
Lloh1:
	ldr	x26, [x26, _DMA_TO_DEVICE@GOTPAGEOFF]
	ldr	w3, [x26]
	mov	x0, x22
	mov	x1, x21
	mov	x2, x20
	bl	_dma_map_single
	mov	x21, x0
	ldr	x0, [x19]
	mov	x1, x21
	bl	_dma_mapping_error
	cbz	w0, LBB0_2
; %bb.1:
	ldr	x0, [x19]
Lloh2:
	adrp	x1, l_.str@PAGE
Lloh3:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_err
Lloh4:
	adrp	x8, _EINVAL@GOTPAGE
Lloh5:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh6:
	ldr	w8, [x8]
	neg	w23, w8
	b	LBB0_7
LBB0_2:
Lloh7:
	adrp	x24, _NFI_CNFG@GOTPAGE
Lloh8:
	ldr	x24, [x24, _NFI_CNFG@GOTPAGEOFF]
	ldr	w1, [x24]
	mov	x0, x19
	bl	_nfi_readw
Lloh9:
	adrp	x8, _CNFG_AHB@GOTPAGE
Lloh10:
	ldr	x8, [x8, _CNFG_AHB@GOTPAGEOFF]
Lloh11:
	ldr	w8, [x8]
	orr	w8, w8, w0
Lloh12:
	adrp	x9, _CNFG_DMA_BURST_EN@GOTPAGE
Lloh13:
	ldr	x9, [x9, _CNFG_DMA_BURST_EN@GOTPAGEOFF]
Lloh14:
	ldr	w9, [x9]
	orr	w1, w8, w9
	ldr	w2, [x24]
	mov	x0, x19
	bl	_nfi_writew
Lloh15:
	adrp	x8, _CON_SEC_SHIFT@GOTPAGE
Lloh16:
	ldr	x8, [x8, _CON_SEC_SHIFT@GOTPAGEOFF]
	ldr	w9, [x23]
Lloh17:
	ldr	w8, [x8]
	lsl	w1, w9, w8
Lloh18:
	adrp	x27, _NFI_CON@GOTPAGE
Lloh19:
	ldr	x27, [x27, _NFI_CON@GOTPAGEOFF]
	ldr	w2, [x27]
	mov	x0, x19
	bl	_nfi_writel
	mov	x0, x21
	bl	_lower_32_bits
	mov	x1, x0
Lloh20:
	adrp	x8, _NFI_STRADDR@GOTPAGE
Lloh21:
	ldr	x8, [x8, _NFI_STRADDR@GOTPAGEOFF]
Lloh22:
	ldr	w2, [x8]
	mov	x0, x19
	bl	_nfi_writel
Lloh23:
	adrp	x8, _INTR_AHB_DONE_EN@GOTPAGE
Lloh24:
	ldr	x8, [x8, _INTR_AHB_DONE_EN@GOTPAGEOFF]
Lloh25:
	ldr	w1, [x8]
Lloh26:
	adrp	x28, _NFI_INTR_EN@GOTPAGE
Lloh27:
	ldr	x28, [x28, _NFI_INTR_EN@GOTPAGEOFF]
	ldr	w2, [x28]
	mov	x0, x19
	bl	_nfi_writew
	add	x25, x19, #16
	mov	x0, x25
	bl	_init_completion
	ldr	w1, [x27]
	mov	x0, x19
	bl	_nfi_readl
Lloh28:
	adrp	x8, _CON_BWR@GOTPAGE
Lloh29:
	ldr	x8, [x8, _CON_BWR@GOTPAGEOFF]
Lloh30:
	ldr	w8, [x8]
	orr	w24, w8, w0
	ldr	w2, [x27]
	mov	x0, x19
	mov	x1, x24
	bl	_nfi_writel
Lloh31:
	adrp	x8, _STAR_EN@GOTPAGE
Lloh32:
	ldr	x8, [x8, _STAR_EN@GOTPAGEOFF]
Lloh33:
	ldr	w1, [x8]
Lloh34:
	adrp	x8, _NFI_STRDATA@GOTPAGE
Lloh35:
	ldr	x8, [x8, _NFI_STRDATA@GOTPAGEOFF]
Lloh36:
	ldr	w2, [x8]
	mov	x0, x19
	bl	_nfi_writew
	mov	w0, #500
	bl	_msecs_to_jiffies
	mov	x1, x0
	mov	x0, x25
	bl	_wait_for_completion_timeout
	cbz	w0, LBB0_5
; %bb.3:
	ldr	x8, [x19, #8]
Lloh37:
	adrp	x9, _NFI_ADDRCNTR@GOTPAGE
Lloh38:
	ldr	x9, [x9, _NFI_ADDRCNTR@GOTPAGEOFF]
Lloh39:
	ldr	x9, [x9]
	add	x25, x9, x8
	mov	x0, x24
	bl	_ADDRCNTR_SEC
	ldr	w8, [x23]
	cmp	w0, w8
	cset	w2, ge
Lloh40:
	adrp	x8, _MTK_TIMEOUT@GOTPAGE
Lloh41:
	ldr	x8, [x8, _MTK_TIMEOUT@GOTPAGEOFF]
Lloh42:
	ldr	w4, [x8]
	mov	x0, x25
	mov	x1, x24
	mov	w3, #10
	bl	_readl_poll_timeout_atomic
	mov	x23, x0
	cbz	w0, LBB0_6
; %bb.4:
Lloh43:
	adrp	x1, l_.str.2@PAGE
Lloh44:
	add	x1, x1, l_.str.2@PAGEOFF
	mov	x0, x22
	bl	_dev_err
	b	LBB0_6
LBB0_5:
Lloh45:
	adrp	x1, l_.str.1@PAGE
Lloh46:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x0, x22
	bl	_dev_err
	ldr	w2, [x28]
	mov	x0, x19
	mov	w1, #0
	bl	_nfi_writew
Lloh47:
	adrp	x8, _ETIMEDOUT@GOTPAGE
Lloh48:
	ldr	x8, [x8, _ETIMEDOUT@GOTPAGEOFF]
Lloh49:
	ldr	w8, [x8]
	neg	w23, w8
LBB0_6:
	ldr	x0, [x19]
	ldr	w3, [x26]
	mov	x1, x21
	mov	x2, x20
	bl	_dma_unmap_single
	ldr	w2, [x27]
	mov	x0, x19
	mov	w1, #0
	bl	_nfi_writel
LBB0_7:
	mov	x0, x23
	ldp	x29, x30, [sp, #80]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #64]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #48]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #32]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #16]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp], #96             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh4, Lloh5, Lloh6
	.loh AdrpAdd	Lloh2, Lloh3
	.loh AdrpLdrGotLdr	Lloh34, Lloh35, Lloh36
	.loh AdrpLdrGotLdr	Lloh31, Lloh32, Lloh33
	.loh AdrpLdrGotLdr	Lloh28, Lloh29, Lloh30
	.loh AdrpLdrGot	Lloh26, Lloh27
	.loh AdrpLdrGotLdr	Lloh23, Lloh24, Lloh25
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpLdrGot	Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGot	Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh40, Lloh41, Lloh42
	.loh AdrpLdrGotLdr	Lloh37, Lloh38, Lloh39
	.loh AdrpAdd	Lloh43, Lloh44
	.loh AdrpLdrGotLdr	Lloh47, Lloh48, Lloh49
	.loh AdrpAdd	Lloh45, Lloh46
	.cfi_endproc
                                        ; -- End function
	.comm	_DMA_TO_DEVICE,4,2              ; @DMA_TO_DEVICE
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"dma mapping error\n"

	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_NFI_CNFG,4,2                   ; @NFI_CNFG
	.comm	_CNFG_AHB,4,2                   ; @CNFG_AHB
	.comm	_CNFG_DMA_BURST_EN,4,2          ; @CNFG_DMA_BURST_EN
	.comm	_CON_SEC_SHIFT,4,2              ; @CON_SEC_SHIFT
	.comm	_NFI_CON,4,2                    ; @NFI_CON
	.comm	_NFI_STRADDR,4,2                ; @NFI_STRADDR
	.comm	_INTR_AHB_DONE_EN,4,2           ; @INTR_AHB_DONE_EN
	.comm	_NFI_INTR_EN,4,2                ; @NFI_INTR_EN
	.comm	_CON_BWR,4,2                    ; @CON_BWR
	.comm	_STAR_EN,4,2                    ; @STAR_EN
	.comm	_NFI_STRDATA,4,2                ; @NFI_STRDATA
l_.str.1:                               ; @.str.1
	.asciz	"program ahb done timeout\n"

	.comm	_ETIMEDOUT,4,2                  ; @ETIMEDOUT
	.comm	_NFI_ADDRCNTR,8,3               ; @NFI_ADDRCNTR
	.comm	_MTK_TIMEOUT,4,2                ; @MTK_TIMEOUT
l_.str.2:                               ; @.str.2
	.asciz	"hwecc write timeout\n"

	.no_dead_strip	_mtk_nfc_do_write_page
.subsections_via_symbols
