	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function hisi_nfc_attach_chip
_hisi_nfc_attach_chip:                  ## @hisi_nfc_attach_chip
	.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	%r12
	pushq	%rbx
	.cfi_offset %rbx, -48
	.cfi_offset %r12, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %r14
	callq	_nand_to_mtd
	movq	%rax, %rbx
	movq	%r14, %rdi
	callq	_nand_get_controller_data
	movq	%rax, %r15
	movslq	(%rbx), %rsi
	addq	8(%rbx), %rsi
	movl	(%rax), %edi
	leaq	8(%rax), %rdx
	movq	_GFP_KERNEL@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	callq	_dmam_alloc_coherent
	movl	%eax, 4(%r15)
	testl	%eax, %eax
	je	LBB0_1
## %bb.3:
	movslq	(%rbx), %rdx
	movq	8(%r15), %rcx
	addq	%rdx, %rcx
	movq	%rcx, 16(%r15)
	addq	8(%rbx), %rdx
	movl	%eax, %edi
	movl	$255, %esi
	callq	_memset
	movq	_HINFC504_CON@GOTPCREL(%rip), %r12
	movl	(%r12), %esi
	movq	%r15, %rdi
	callq	_hinfc_read
	cmpl	$2048, (%rbx)                   ## imm = 0x800
	jne	LBB0_7
## %bb.4:
	movq	_HINFC504_CON_PAGESIZE_MASK@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edx
	movq	_HINFC504_CON_PAGEISZE_SHIFT@GOTPCREL(%rip), %rcx
	movb	(%rcx), %cl
	shll	%cl, %edx
	notl	%edx
	andl	%edx, %eax
	btsl	%ecx, %eax
	movl	(%r12), %edx
	movq	%r15, %rdi
	movl	%eax, %esi
	callq	_hinfc_write
	movq	(%r14), %rax
	movq	_NAND_ECC_HW@GOTPCREL(%rip), %rcx
	xorl	%ebx, %ebx
	cmpq	(%rcx), %rax
	jne	LBB0_6
## %bb.5:
	movq	%r15, %rdi
	callq	_hisi_nfc_ecc_probe
	jmp	LBB0_6
LBB0_1:
	movq	_ENOMEM@GOTPCREL(%rip), %rax
	jmp	LBB0_2
LBB0_7:
	movl	(%r15), %edi
	leaq	L_.str(%rip), %rsi
	callq	_dev_err
	movq	_EINVAL@GOTPCREL(%rip), %rax
LBB0_2:
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
LBB0_6:
	movl	%ebx, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_GFP_KERNEL,4,2                 ## @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ## @ENOMEM
	.comm	_HINFC504_CON,4,2               ## @HINFC504_CON
	.comm	_HINFC504_CON_PAGESIZE_MASK,4,2 ## @HINFC504_CON_PAGESIZE_MASK
	.comm	_HINFC504_CON_PAGEISZE_SHIFT,4,2 ## @HINFC504_CON_PAGEISZE_SHIFT
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"NON-2KB page size nand flash\n"

	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_NAND_ECC_HW,8,3                ## @NAND_ECC_HW
	.no_dead_strip	_hisi_nfc_attach_chip
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function hisi_nfc_attach_chip
_hisi_nfc_attach_chip:                  ; @hisi_nfc_attach_chip
	.cfi_startproc
; %bb.0:
	stp	x22, x21, [sp, #-48]!           ; 16-byte Folded Spill
	.cfi_def_cfa_offset 48
	stp	x20, x19, [sp, #16]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #32]             ; 16-byte Folded Spill
	add	x29, sp, #32
	.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
	mov	x19, x0
	bl	_nand_to_mtd
	mov	x21, x0
	mov	x0, x19
	bl	_nand_get_controller_data
	mov	x20, x0
	ldr	w0, [x0]
	ldrsw	x8, [x21]
	ldr	x9, [x21, #8]
	add	x1, x9, x8
	add	x2, x20, #8
Lloh0:
	adrp	x8, _GFP_KERNEL@GOTPAGE
Lloh1:
	ldr	x8, [x8, _GFP_KERNEL@GOTPAGEOFF]
Lloh2:
	ldr	w3, [x8]
	bl	_dmam_alloc_coherent
	str	w0, [x20, #4]
	cbz	w0, LBB0_5
; %bb.1:
	ldr	x8, [x20, #8]
	ldrsw	x9, [x21]
	add	x8, x8, x9
	str	x8, [x20, #16]
	ldr	x8, [x21, #8]
	add	x2, x8, x9
	mov	w1, #255
	bl	_memset
Lloh3:
	adrp	x22, _HINFC504_CON@GOTPAGE
Lloh4:
	ldr	x22, [x22, _HINFC504_CON@GOTPAGEOFF]
	ldr	w1, [x22]
	mov	x0, x20
	bl	_hinfc_read
	ldr	w8, [x21]
	cmp	w8, #2048
	b.ne	LBB0_6
; %bb.2:
Lloh5:
	adrp	x8, _HINFC504_CON_PAGESIZE_MASK@GOTPAGE
Lloh6:
	ldr	x8, [x8, _HINFC504_CON_PAGESIZE_MASK@GOTPAGEOFF]
Lloh7:
	ldr	w8, [x8]
Lloh8:
	adrp	x9, _HINFC504_CON_PAGEISZE_SHIFT@GOTPAGE
Lloh9:
	ldr	x9, [x9, _HINFC504_CON_PAGEISZE_SHIFT@GOTPAGEOFF]
Lloh10:
	ldr	w9, [x9]
	lsl	w8, w8, w9
	bic	w8, w0, w8
	mov	w10, #1
	lsl	w9, w10, w9
	orr	w1, w8, w9
	ldr	w2, [x22]
	mov	x0, x20
	bl	_hinfc_write
	ldr	x8, [x19]
Lloh11:
	adrp	x9, _NAND_ECC_HW@GOTPAGE
Lloh12:
	ldr	x9, [x9, _NAND_ECC_HW@GOTPAGEOFF]
Lloh13:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_4
; %bb.3:
	mov	x0, x20
	bl	_hisi_nfc_ecc_probe
LBB0_4:
	mov	w0, #0
	b	LBB0_8
LBB0_5:
Lloh14:
	adrp	x8, _ENOMEM@GOTPAGE
Lloh15:
	ldr	x8, [x8, _ENOMEM@GOTPAGEOFF]
	b	LBB0_7
LBB0_6:
	ldr	w0, [x20]
Lloh16:
	adrp	x1, l_.str@PAGE
Lloh17:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_err
Lloh18:
	adrp	x8, _EINVAL@GOTPAGE
Lloh19:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
LBB0_7:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_8:
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp], #48             ; 16-byte Folded Reload
	ret
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh11, Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh8, Lloh9, Lloh10
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh14, Lloh15
	.loh AdrpLdrGot	Lloh18, Lloh19
	.loh AdrpAdd	Lloh16, Lloh17
	.cfi_endproc
                                        ; -- End function
	.comm	_GFP_KERNEL,4,2                 ; @GFP_KERNEL
	.comm	_ENOMEM,4,2                     ; @ENOMEM
	.comm	_HINFC504_CON,4,2               ; @HINFC504_CON
	.comm	_HINFC504_CON_PAGESIZE_MASK,4,2 ; @HINFC504_CON_PAGESIZE_MASK
	.comm	_HINFC504_CON_PAGEISZE_SHIFT,4,2 ; @HINFC504_CON_PAGEISZE_SHIFT
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"NON-2KB page size nand flash\n"

	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_NAND_ECC_HW,8,3                ; @NAND_ECC_HW
	.no_dead_strip	_hisi_nfc_attach_chip
.subsections_via_symbols
