	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function davinci_nand_attach_chip
_davinci_nand_attach_chip:              ## @davinci_nand_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
	callq	_nand_to_mtd
	movq	%rax, %r14
	movq	%rax, %rdi
	callq	_to_davinci_nand
	movq	%rax, %r12
	movq	40(%rax), %rdi
	callq	_nand_davinci_get_pdata
	movq	%rax, %rbx
	movq	%rax, %rdi
	callq	_IS_ERR
	testq	%rax, %rax
	je	LBB0_1
## %bb.25:
	movq	%rbx, %rdi
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_PTR_ERR                        ## TAILCALL
LBB0_1:
	movl	(%r12), %eax
	cmpl	$128, %eax
	je	LBB0_5
## %bb.2:
	cmpl	$130, %eax
	je	LBB0_6
## %bb.3:
	cmpl	$129, %eax
	jne	LBB0_15
## %bb.4:
	movl	$0, (%rbx)
	xorl	%r15d, %r15d
	jmp	LBB0_24
LBB0_6:
	movl	(%rbx), %eax
	cmpl	$4, %eax
	jne	LBB0_16
## %bb.7:
	movq	_davinci_nand_lock@GOTPCREL(%rip), %rdi
	callq	_spin_lock_irq
	movq	_ecc4_busy@GOTPCREL(%rip), %rax
	cmpl	$0, (%rax)
	je	LBB0_9
## %bb.8:
	movq	_EBUSY@GOTPCREL(%rip), %rax
	xorl	%r15d, %r15d
	subl	(%rax), %r15d
	jmp	LBB0_10
LBB0_5:
	movl	$0, (%rbx)
	movq	_NAND_ECC_HAMMING@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rax, 16(%r12)
	xorl	%r15d, %r15d
	jmp	LBB0_24
LBB0_16:
	movq	_nand_davinci_calculate_1bit@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	movl	%ecx, 32(%r12)
	movq	_nand_davinci_correct_1bit@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	movl	%ecx, 28(%r12)
	movq	_nand_davinci_hwctl_1bit@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	movl	%ecx, 24(%r12)
	movl	$3, 4(%r12)
	movq	_NAND_ECC_HAMMING@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	movq	%rcx, 16(%r12)
	movl	$512, 8(%r12)                   ## imm = 0x200
	movl	%eax, 12(%r12)
	xorl	%r15d, %r15d
	jmp	LBB0_24
LBB0_9:
	movl	$1, (%rax)
	xorl	%r15d, %r15d
LBB0_10:
	movq	_davinci_nand_lock@GOTPCREL(%rip), %rdi
	callq	_spin_unlock_irq
	movq	_EBUSY@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	addl	%r15d, %eax
	je	LBB0_24
## %bb.11:
	movq	_nand_davinci_calculate_4bit@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 32(%r12)
	movq	_nand_davinci_correct_4bit@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 28(%r12)
	movq	_nand_davinci_hwctl_4bit@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 24(%r12)
	movl	$10, 4(%r12)
	movq	_NAND_ECC_GENERIC_ERASED_CHECK@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 36(%r12)
	movq	_NAND_ECC_BCH@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rax, 16(%r12)
	movl	(%rbx), %eax
	movl	$512, 8(%r12)                   ## imm = 0x200
	movl	%eax, 12(%r12)
	cmpl	$4, %eax
	jne	LBB0_24
## %bb.12:
	movl	(%r14), %eax
	leal	511(%rax), %ecx
	cmpl	$1023, %ecx                     ## imm = 0x3FF
	jb	LBB0_14
## %bb.13:
	cmpl	$15, 4(%r14)
	jg	LBB0_17
LBB0_14:
	movq	40(%r12), %rdi
	leaq	L_.str(%rip), %rsi
	callq	_dev_dbg
LBB0_15:
	movq	_EINVAL@GOTPCREL(%rip), %rax
LBB0_23:
	xorl	%r15d, %r15d
	subl	(%rax), %r15d
LBB0_24:
	movl	%r15d, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_17:
	andl	$-512, %eax                     ## imm = 0xFE00
	cmpl	$4096, %eax                     ## imm = 0x1000
	je	LBB0_21
## %bb.18:
	cmpl	$2048, %eax                     ## imm = 0x800
	je	LBB0_21
## %bb.19:
	cmpl	$512, %eax                      ## imm = 0x200
	jne	LBB0_22
## %bb.20:
	movq	_hwecc4_small_ooblayout_ops@GOTPCREL(%rip), %rsi
	movq	%r14, %rdi
	callq	_mtd_set_ooblayout
	jmp	LBB0_24
LBB0_21:
	movq	_nand_ooblayout_lp_ops@GOTPCREL(%rip), %rsi
	movq	%r14, %rdi
	callq	_mtd_set_ooblayout
	movq	_NAND_ECC_HW_OOB_FIRST@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, (%r12)
	jmp	LBB0_24
LBB0_22:
	movq	_EIO@GOTPCREL(%rip), %rax
	jmp	LBB0_23
	.cfi_endproc
                                        ## -- End function
	.comm	_NAND_ECC_HAMMING,8,3           ## @NAND_ECC_HAMMING
	.comm	_davinci_nand_lock,4,2          ## @davinci_nand_lock
	.comm	_ecc4_busy,4,2                  ## @ecc4_busy
	.comm	_EBUSY,4,2                      ## @EBUSY
	.comm	_nand_davinci_calculate_4bit,4,2 ## @nand_davinci_calculate_4bit
	.comm	_nand_davinci_correct_4bit,4,2  ## @nand_davinci_correct_4bit
	.comm	_nand_davinci_hwctl_4bit,4,2    ## @nand_davinci_hwctl_4bit
	.comm	_NAND_ECC_GENERIC_ERASED_CHECK,4,2 ## @NAND_ECC_GENERIC_ERASED_CHECK
	.comm	_NAND_ECC_BCH,8,3               ## @NAND_ECC_BCH
	.comm	_nand_davinci_calculate_1bit,4,2 ## @nand_davinci_calculate_1bit
	.comm	_nand_davinci_correct_1bit,4,2  ## @nand_davinci_correct_1bit
	.comm	_nand_davinci_hwctl_1bit,4,2    ## @nand_davinci_hwctl_1bit
	.comm	_EINVAL,4,2                     ## @EINVAL
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"too small\n"

	.comm	_hwecc4_small_ooblayout_ops,4,2 ## @hwecc4_small_ooblayout_ops
	.comm	_nand_ooblayout_lp_ops,4,2      ## @nand_ooblayout_lp_ops
	.comm	_NAND_ECC_HW_OOB_FIRST,4,2      ## @NAND_ECC_HW_OOB_FIRST
	.comm	_EIO,4,2                        ## @EIO
	.no_dead_strip	_davinci_nand_attach_chip
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.section	__TEXT,__literal8,8byte_literals
	.p2align	3                               ; -- Begin function davinci_nand_attach_chip
lCPI0_0:
	.long	3                               ; 0x3
	.long	512                             ; 0x200
lCPI0_1:
	.long	10                              ; 0xa
	.long	512                             ; 0x200
	.section	__TEXT,__text,regular,pure_instructions
	.p2align	2
_davinci_nand_attach_chip:              ; @davinci_nand_attach_chip
	.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
	bl	_nand_to_mtd
	mov	x21, x0
	bl	_to_davinci_nand
	mov	x20, x0
	ldr	x0, [x0, #40]
	bl	_nand_davinci_get_pdata
	mov	x22, x0
	bl	_IS_ERR
	cbz	x0, LBB0_2
; %bb.1:
	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
	b	_PTR_ERR
LBB0_2:
	ldr	w8, [x20]
	cmp	w8, #128
	b.eq	LBB0_9
; %bb.3:
	cmp	w8, #130
	b.eq	LBB0_6
; %bb.4:
	cmp	w8, #129
	b.ne	LBB0_17
; %bb.5:
	mov	w19, #0
	str	wzr, [x22]
	b	LBB0_19
LBB0_6:
	ldr	w8, [x22]
	cmp	w8, #4
	b.ne	LBB0_10
; %bb.7:
Lloh0:
	adrp	x0, _davinci_nand_lock@GOTPAGE
Lloh1:
	ldr	x0, [x0, _davinci_nand_lock@GOTPAGEOFF]
	bl	_spin_lock_irq
Lloh2:
	adrp	x8, _ecc4_busy@GOTPAGE
Lloh3:
	ldr	x8, [x8, _ecc4_busy@GOTPAGEOFF]
	ldr	w9, [x8]
Lloh4:
	adrp	x23, _EBUSY@GOTPAGE
Lloh5:
	ldr	x23, [x23, _EBUSY@GOTPAGEOFF]
	cbz	w9, LBB0_11
; %bb.8:
	ldr	w8, [x23]
	neg	w19, w8
	b	LBB0_12
LBB0_9:
	mov	w19, #0
	str	wzr, [x22]
Lloh6:
	adrp	x8, _NAND_ECC_HAMMING@GOTPAGE
Lloh7:
	ldr	x8, [x8, _NAND_ECC_HAMMING@GOTPAGEOFF]
Lloh8:
	ldr	x8, [x8]
	str	x8, [x20, #16]
	b	LBB0_19
LBB0_10:
	mov	w19, #0
Lloh9:
	adrp	x9, _nand_davinci_calculate_1bit@GOTPAGE
Lloh10:
	ldr	x9, [x9, _nand_davinci_calculate_1bit@GOTPAGEOFF]
Lloh11:
	ldr	w9, [x9]
	str	w9, [x20, #32]
Lloh12:
	adrp	x9, _nand_davinci_correct_1bit@GOTPAGE
Lloh13:
	ldr	x9, [x9, _nand_davinci_correct_1bit@GOTPAGEOFF]
Lloh14:
	adrp	x10, _nand_davinci_hwctl_1bit@GOTPAGE
Lloh15:
	ldr	x10, [x10, _nand_davinci_hwctl_1bit@GOTPAGEOFF]
Lloh16:
	ldr	w9, [x9]
Lloh17:
	ldr	w10, [x10]
	stp	w10, w9, [x20, #24]
Lloh18:
	adrp	x9, _NAND_ECC_HAMMING@GOTPAGE
Lloh19:
	ldr	x9, [x9, _NAND_ECC_HAMMING@GOTPAGEOFF]
Lloh20:
	ldr	x9, [x9]
	str	x9, [x20, #16]
Lloh21:
	adrp	x9, lCPI0_0@PAGE
Lloh22:
	ldr	d0, [x9, lCPI0_0@PAGEOFF]
	stur	d0, [x20, #4]
	str	w8, [x20, #12]
	b	LBB0_19
LBB0_11:
	mov	w19, #0
	mov	w9, #1
	str	w9, [x8]
LBB0_12:
Lloh23:
	adrp	x0, _davinci_nand_lock@GOTPAGE
Lloh24:
	ldr	x0, [x0, _davinci_nand_lock@GOTPAGEOFF]
	bl	_spin_unlock_irq
	ldr	w8, [x23]
	cmn	w19, w8
	b.eq	LBB0_19
; %bb.13:
Lloh25:
	adrp	x8, _nand_davinci_calculate_4bit@GOTPAGE
Lloh26:
	ldr	x8, [x8, _nand_davinci_calculate_4bit@GOTPAGEOFF]
Lloh27:
	ldr	w8, [x8]
Lloh28:
	adrp	x9, _nand_davinci_correct_4bit@GOTPAGE
Lloh29:
	ldr	x9, [x9, _nand_davinci_correct_4bit@GOTPAGEOFF]
Lloh30:
	ldr	w9, [x9]
Lloh31:
	adrp	x10, _nand_davinci_hwctl_4bit@GOTPAGE
Lloh32:
	ldr	x10, [x10, _nand_davinci_hwctl_4bit@GOTPAGEOFF]
Lloh33:
	ldr	w10, [x10]
	stp	w10, w9, [x20, #24]
Lloh34:
	adrp	x9, _NAND_ECC_GENERIC_ERASED_CHECK@GOTPAGE
Lloh35:
	ldr	x9, [x9, _NAND_ECC_GENERIC_ERASED_CHECK@GOTPAGEOFF]
Lloh36:
	ldr	w9, [x9]
	stp	w8, w9, [x20, #32]
Lloh37:
	adrp	x8, _NAND_ECC_BCH@GOTPAGE
Lloh38:
	ldr	x8, [x8, _NAND_ECC_BCH@GOTPAGEOFF]
Lloh39:
	ldr	x8, [x8]
	str	x8, [x20, #16]
	ldr	w8, [x22]
Lloh40:
	adrp	x9, lCPI0_1@PAGE
Lloh41:
	ldr	d0, [x9, lCPI0_1@PAGEOFF]
	stur	d0, [x20, #4]
	str	w8, [x20, #12]
	cmp	w8, #4
	b.ne	LBB0_19
; %bb.14:
	ldr	w8, [x21]
	add	w9, w8, #511
	cmp	w9, #1023
	b.lo	LBB0_16
; %bb.15:
	ldr	w9, [x21, #4]
	cmp	w9, #15
	b.gt	LBB0_20
LBB0_16:
	ldr	x0, [x20, #40]
Lloh42:
	adrp	x1, l_.str@PAGE
Lloh43:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_dbg
LBB0_17:
Lloh44:
	adrp	x8, _EINVAL@GOTPAGE
Lloh45:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
LBB0_18:
	ldr	w8, [x8]
	neg	w19, w8
LBB0_19:
	mov	x0, x19
	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
LBB0_20:
	and	w8, w8, #0xfffffe00
	cmp	w8, #1, lsl #12                 ; =4096
	b.eq	LBB0_24
; %bb.21:
	cmp	w8, #2048
	b.eq	LBB0_24
; %bb.22:
	cmp	w8, #512
	b.ne	LBB0_25
; %bb.23:
Lloh46:
	adrp	x1, _hwecc4_small_ooblayout_ops@GOTPAGE
Lloh47:
	ldr	x1, [x1, _hwecc4_small_ooblayout_ops@GOTPAGEOFF]
	mov	x0, x21
	bl	_mtd_set_ooblayout
	b	LBB0_19
LBB0_24:
Lloh48:
	adrp	x1, _nand_ooblayout_lp_ops@GOTPAGE
Lloh49:
	ldr	x1, [x1, _nand_ooblayout_lp_ops@GOTPAGEOFF]
	mov	x0, x21
	bl	_mtd_set_ooblayout
Lloh50:
	adrp	x8, _NAND_ECC_HW_OOB_FIRST@GOTPAGE
Lloh51:
	ldr	x8, [x8, _NAND_ECC_HW_OOB_FIRST@GOTPAGEOFF]
Lloh52:
	ldr	w8, [x8]
	str	w8, [x20]
	b	LBB0_19
LBB0_25:
Lloh53:
	adrp	x8, _EIO@GOTPAGE
Lloh54:
	ldr	x8, [x8, _EIO@GOTPAGEOFF]
	b	LBB0_18
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdr	Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh14, Lloh15, Lloh17
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh16
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGot	Lloh23, Lloh24
	.loh AdrpLdr	Lloh40, Lloh41
	.loh AdrpLdrGotLdr	Lloh37, Lloh38, Lloh39
	.loh AdrpLdrGotLdr	Lloh34, Lloh35, Lloh36
	.loh AdrpLdrGotLdr	Lloh31, Lloh32, Lloh33
	.loh AdrpLdrGotLdr	Lloh28, Lloh29, Lloh30
	.loh AdrpLdrGotLdr	Lloh25, Lloh26, Lloh27
	.loh AdrpAdd	Lloh42, Lloh43
	.loh AdrpLdrGot	Lloh44, Lloh45
	.loh AdrpLdrGot	Lloh46, Lloh47
	.loh AdrpLdrGotLdr	Lloh50, Lloh51, Lloh52
	.loh AdrpLdrGot	Lloh48, Lloh49
	.loh AdrpLdrGot	Lloh53, Lloh54
	.cfi_endproc
                                        ; -- End function
	.comm	_NAND_ECC_HAMMING,8,3           ; @NAND_ECC_HAMMING
	.comm	_davinci_nand_lock,4,2          ; @davinci_nand_lock
	.comm	_ecc4_busy,4,2                  ; @ecc4_busy
	.comm	_EBUSY,4,2                      ; @EBUSY
	.comm	_nand_davinci_calculate_4bit,4,2 ; @nand_davinci_calculate_4bit
	.comm	_nand_davinci_correct_4bit,4,2  ; @nand_davinci_correct_4bit
	.comm	_nand_davinci_hwctl_4bit,4,2    ; @nand_davinci_hwctl_4bit
	.comm	_NAND_ECC_GENERIC_ERASED_CHECK,4,2 ; @NAND_ECC_GENERIC_ERASED_CHECK
	.comm	_NAND_ECC_BCH,8,3               ; @NAND_ECC_BCH
	.comm	_nand_davinci_calculate_1bit,4,2 ; @nand_davinci_calculate_1bit
	.comm	_nand_davinci_correct_1bit,4,2  ; @nand_davinci_correct_1bit
	.comm	_nand_davinci_hwctl_1bit,4,2    ; @nand_davinci_hwctl_1bit
	.comm	_EINVAL,4,2                     ; @EINVAL
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"too small\n"

	.comm	_hwecc4_small_ooblayout_ops,4,2 ; @hwecc4_small_ooblayout_ops
	.comm	_nand_ooblayout_lp_ops,4,2      ; @nand_ooblayout_lp_ops
	.comm	_NAND_ECC_HW_OOB_FIRST,4,2      ; @NAND_ECC_HW_OOB_FIRST
	.comm	_EIO,4,2                        ; @EIO
	.no_dead_strip	_davinci_nand_attach_chip
.subsections_via_symbols
