	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function brcmnand_wp
_brcmnand_wp:                           ## @brcmnand_wp
	.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
	movl	%esi, %r15d
	callq	_mtd_to_nand
	movq	%rax, %r12
	movq	%rax, %rdi
	callq	_nand_get_controller_data
	movq	%rax, %r14
	movq	8(%rax), %rbx
	movq	_BRCMNAND_HAS_WP@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	testl	%eax, (%rbx)
	je	LBB0_6
## %bb.1:
	movq	_wp_on@GOTPCREL(%rip), %rax
	cmpl	$1, (%rax)
	jne	LBB0_6
## %bb.2:
	cmpl	%r15d, _brcmnand_wp.old_wp(%rip)
	je	LBB0_4
## %bb.3:
	movl	4(%rbx), %edi
	testl	%r15d, %r15d
	leaq	L_.str.2(%rip), %rax
	leaq	L_.str.1(%rip), %rdx
	cmoveq	%rax, %rdx
	leaq	L_.str(%rip), %rsi
	callq	_dev_dbg
	movl	%r15d, _brcmnand_wp.old_wp(%rip)
LBB0_4:
	movq	_NAND_CTRL_RDY@GOTPCREL(%rip), %rax
	movq	_NAND_STATUS_READY@GOTPCREL(%rip), %r13
	movl	(%r13), %edx
	orl	(%rax), %edx
	movq	%rbx, %rdi
	movl	%edx, %esi
	xorl	%ecx, %ecx
	callq	_bcmnand_ctrl_poll_status
	testl	%eax, %eax
	je	LBB0_5
LBB0_6:
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_5:
	movq	%rbx, %rdi
	movl	%r15d, %esi
	callq	_brcmnand_set_wp
	movq	%r12, %rdi
	xorl	%esi, %esi
	callq	_nand_status_op
	movl	(%r13), %eax
	movq	_NAND_CTRL_RDY@GOTPCREL(%rip), %rcx
	orl	(%rcx), %eax
	movq	_NAND_STATUS_WP@GOTPCREL(%rip), %rcx
	movl	(%rcx), %edx
	movl	%eax, %esi
	orl	%edx, %esi
	testl	%r15d, %r15d
	movl	$0, %ecx
	cmovnel	%ecx, %edx
	orl	%eax, %edx
	movq	%rbx, %rdi
	xorl	%ecx, %ecx
	callq	_bcmnand_ctrl_poll_status
	testl	%eax, %eax
	je	LBB0_6
## %bb.7:
	testl	%r15d, %r15d
	movq	(%r14), %rdi
	leaq	L_.str.2(%rip), %rax
	leaq	L_.str.1(%rip), %rdx
	cmoveq	%rax, %rdx
	leaq	L_.str.3(%rip), %rsi
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	jmp	_dev_err_ratelimited            ## TAILCALL
	.cfi_endproc
                                        ## -- End function
	.comm	_BRCMNAND_HAS_WP,4,2            ## @BRCMNAND_HAS_WP
	.comm	_wp_on,4,2                      ## @wp_on
	.section	__DATA,__data
	.p2align	2                               ## @brcmnand_wp.old_wp
_brcmnand_wp.old_wp:
	.long	4294967295                      ## 0xffffffff

	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"WP %s\n"

L_.str.1:                               ## @.str.1
	.asciz	"on"

L_.str.2:                               ## @.str.2
	.asciz	"off"

	.comm	_NAND_CTRL_RDY,4,2              ## @NAND_CTRL_RDY
	.comm	_NAND_STATUS_READY,4,2          ## @NAND_STATUS_READY
	.comm	_NAND_STATUS_WP,4,2             ## @NAND_STATUS_WP
L_.str.3:                               ## @.str.3
	.asciz	"nand #WP expected %s\n"

	.no_dead_strip	_brcmnand_wp
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function brcmnand_wp
_brcmnand_wp:                           ; @brcmnand_wp
	.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	x19, x1
	bl	_mtd_to_nand
	mov	x22, x0
	bl	_nand_get_controller_data
	ldr	x21, [x0, #8]
	ldr	w8, [x21]
Lloh0:
	adrp	x9, _BRCMNAND_HAS_WP@GOTPAGE
Lloh1:
	ldr	x9, [x9, _BRCMNAND_HAS_WP@GOTPAGEOFF]
Lloh2:
	ldr	w9, [x9]
	and	w8, w9, w8
Lloh3:
	adrp	x9, _wp_on@GOTPAGE
Lloh4:
	ldr	x9, [x9, _wp_on@GOTPAGEOFF]
Lloh5:
	ldr	w9, [x9]
	cmp	w8, #0
	ccmp	w9, #1, #0, ne
	b.ne	LBB0_4
; %bb.1:
	mov	x20, x0
	adrp	x23, _brcmnand_wp.old_wp@PAGE
	ldr	w8, [x23, _brcmnand_wp.old_wp@PAGEOFF]
	cmp	w8, w19
	b.eq	LBB0_3
; %bb.2:
	ldr	w0, [x21, #4]
Lloh6:
	adrp	x8, l_.str.1@PAGE
Lloh7:
	add	x8, x8, l_.str.1@PAGEOFF
Lloh8:
	adrp	x9, l_.str.2@PAGE
Lloh9:
	add	x9, x9, l_.str.2@PAGEOFF
	cmp	w19, #0
	csel	x2, x9, x8, eq
Lloh10:
	adrp	x1, l_.str@PAGE
Lloh11:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_dbg
	str	w19, [x23, _brcmnand_wp.old_wp@PAGEOFF]
LBB0_3:
Lloh12:
	adrp	x23, _NAND_CTRL_RDY@GOTPAGE
Lloh13:
	ldr	x23, [x23, _NAND_CTRL_RDY@GOTPAGEOFF]
	ldr	w8, [x23]
Lloh14:
	adrp	x24, _NAND_STATUS_READY@GOTPAGE
Lloh15:
	ldr	x24, [x24, _NAND_STATUS_READY@GOTPAGEOFF]
	ldr	w9, [x24]
	orr	w1, w9, w8
	mov	x0, x21
	mov	x2, x1
	mov	w3, #0
	bl	_bcmnand_ctrl_poll_status
	cbz	w0, LBB0_5
LBB0_4:
	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_5:
	mov	x0, x21
	mov	x1, x19
	bl	_brcmnand_set_wp
	mov	x0, x22
	mov	x1, #0
	bl	_nand_status_op
	ldr	w8, [x23]
	ldr	w9, [x24]
Lloh16:
	adrp	x10, _NAND_STATUS_WP@GOTPAGE
Lloh17:
	ldr	x10, [x10, _NAND_STATUS_WP@GOTPAGEOFF]
	orr	w8, w9, w8
Lloh18:
	ldr	w9, [x10]
	orr	w1, w8, w9
	cmp	w19, #0
	csel	w9, w9, wzr, eq
	orr	w2, w9, w8
	mov	x0, x21
	mov	w3, #0
	bl	_bcmnand_ctrl_poll_status
	cbz	w0, LBB0_4
; %bb.6:
	ldr	x0, [x20]
Lloh19:
	adrp	x8, l_.str.1@PAGE
Lloh20:
	add	x8, x8, l_.str.1@PAGEOFF
Lloh21:
	adrp	x9, l_.str.2@PAGE
Lloh22:
	add	x9, x9, l_.str.2@PAGEOFF
	cmp	w19, #0
	csel	x2, x9, x8, eq
Lloh23:
	adrp	x1, l_.str.3@PAGE
Lloh24:
	add	x1, x1, l_.str.3@PAGEOFF
	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	_dev_err_ratelimited
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh10, Lloh11
	.loh AdrpAdd	Lloh8, Lloh9
	.loh AdrpAdd	Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh14, Lloh15
	.loh AdrpLdrGot	Lloh12, Lloh13
	.loh AdrpLdrGotLdr	Lloh16, Lloh17, Lloh18
	.loh AdrpAdd	Lloh23, Lloh24
	.loh AdrpAdd	Lloh21, Lloh22
	.loh AdrpAdd	Lloh19, Lloh20
	.cfi_endproc
                                        ; -- End function
	.comm	_BRCMNAND_HAS_WP,4,2            ; @BRCMNAND_HAS_WP
	.comm	_wp_on,4,2                      ; @wp_on
	.section	__DATA,__data
	.p2align	2                               ; @brcmnand_wp.old_wp
_brcmnand_wp.old_wp:
	.long	4294967295                      ; 0xffffffff

	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"WP %s\n"

l_.str.1:                               ; @.str.1
	.asciz	"on"

l_.str.2:                               ; @.str.2
	.asciz	"off"

	.comm	_NAND_CTRL_RDY,4,2              ; @NAND_CTRL_RDY
	.comm	_NAND_STATUS_READY,4,2          ; @NAND_STATUS_READY
	.comm	_NAND_STATUS_WP,4,2             ; @NAND_STATUS_WP
l_.str.3:                               ; @.str.3
	.asciz	"nand #WP expected %s\n"

	.no_dead_strip	_brcmnand_wp
.subsections_via_symbols
