	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function olpc_xo175_ec_cmd
_olpc_xo175_ec_cmd:                     ## @olpc_xo175_ec_cmd
	.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	$56, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%r9, %r14
	movq	%r8, %r15
	movq	%rcx, -80(%rbp)                 ## 8-byte Spill
	movq	%rdx, %r12
	movq	%rsi, -88(%rbp)                 ## 8-byte Spill
	movl	%edi, %r13d
	movq	48(%r9), %rbx
	leaq	L_.str(%rip), %rsi
	movq	%rbx, %rdi
	movl	%r13d, %edx
	movq	%r8, %rcx
	callq	_dev_dbg
	cmpq	$6, %r12
	jb	LBB0_3
## %bb.1:
	leaq	L_.str.1(%rip), %rsi
	movq	%rbx, %rdi
	xorl	%ebx, %ebx
LBB0_2:
	movq	%r15, %rdx
	xorl	%eax, %eax
	callq	_dev_err
	movq	_EOVERFLOW@GOTPCREL(%rip), %rax
	subl	(%rax), %ebx
	jmp	LBB0_19
LBB0_3:
	movl	96(%r14), %edi
	callq	_WARN_ON
	testq	%rax, %rax
	je	LBB0_6
## %bb.4:
	movq	_EBUSY@GOTPCREL(%rip), %rax
LBB0_5:
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
	jmp	LBB0_19
LBB0_6:
	movq	%rbx, -48(%rbp)                 ## 8-byte Spill
	movl	%r13d, %edi
	callq	_olpc_xo175_ec_resp_len
	movl	%eax, %ebx
	testl	%eax, %eax
	js	LBB0_7
## %bb.9:
	movl	%ebx, %esi
	xorl	%ebx, %ebx
	jmp	LBB0_10
LBB0_7:
	leaq	L_.str.2(%rip), %rsi
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	movl	%r13d, %edx
	callq	_dev_err_ratelimited
	movq	%r15, %rsi
	cmpq	$9, %r15
	jb	LBB0_10
## %bb.8:
	leaq	L_.str.3(%rip), %rsi
	xorl	%ebx, %ebx
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	jmp	LBB0_2
LBB0_10:
	movq	%rsi, -64(%rbp)                 ## 8-byte Spill
	movq	%r15, %rdi
	callq	_min
	movq	%rax, -56(%rbp)                 ## 8-byte Spill
	leaq	32(%r14), %r15
	movq	%r15, %rdi
	callq	_spin_lock_irqsave
	leaq	56(%r14), %rdi
	movq	%rdi, -72(%rbp)                 ## 8-byte Spill
	callq	_init_completion
	movl	$1, (%r14)
	movq	_CMD_STATE_WAITING_FOR_SWITCH@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rax, 8(%r14)
	leaq	64(%r14), %rdi
	xorl	%esi, %esi
	movl	$32, %edx
	callq	_memset
	movl	%r13d, 88(%r14)
	movq	%r12, 64(%r14)
	movq	$0, 80(%r14)
	movq	72(%r14), %rdi
	movq	-88(%rbp), %rsi                 ## 8-byte Reload
	movq	%r12, %rdx
	movq	%r15, %r12
	callq	_memcpy
	movq	-64(%rbp), %rax                 ## 8-byte Reload
	movq	%rax, %r15
	movq	%rax, 16(%r14)
	movq	$0, 24(%r14)
	movl	36(%r14), %edi
	movl	$1, %esi
	callq	_gpiod_set_value_cansleep
	movq	%r12, %rdi
	callq	_spin_unlock_irqrestore
	movl	$4000, %edi                     ## imm = 0xFA0
	callq	_msecs_to_jiffies
	movq	-72(%rbp), %rdi                 ## 8-byte Reload
	movl	%eax, %esi
	callq	_wait_for_completion_timeout
	testl	%eax, %eax
	je	LBB0_11
## %bb.12:
	movq	%r12, %rdi
	callq	_spin_lock_irqsave
	movq	8(%r14), %rax
	movq	_CMD_STATE_ERROR_RECEIVED@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_14
## %bb.13:
	movslq	%r13d, %rdx
	movq	40(%r14), %rax
	movl	(%rax), %ecx
	leaq	L_.str.5(%rip), %rsi
	xorl	%ebx, %ebx
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	xorl	%eax, %eax
	callq	_dev_err
	jmp	LBB0_16
LBB0_11:
	movq	8(%r14), %rdx
	leaq	L_.str.4(%rip), %rsi
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	xorl	%eax, %eax
	callq	_dev_err
	movl	36(%r14), %edi
	xorl	%esi, %esi
	callq	_gpiod_set_value_cansleep
	movq	48(%r14), %rdi
	callq	_spi_slave_abort
	movq	%r14, %rdi
	callq	_olpc_xo175_ec_read_packet
	movq	_ETIMEDOUT@GOTPCREL(%rip), %rax
	jmp	LBB0_5
LBB0_14:
	movq	24(%r14), %rcx
	cmpq	%r15, %rcx
	jne	LBB0_15
## %bb.17:
	movq	40(%r14), %rsi
	movq	-80(%rbp), %rdi                 ## 8-byte Reload
	movq	-56(%rbp), %rdx                 ## 8-byte Reload
	callq	_memcpy
	jmp	LBB0_18
LBB0_15:
	movq	%r15, %r8
	movslq	%r13d, %rdx
	leaq	L_.str.6(%rip), %rsi
	xorl	%ebx, %ebx
	movq	-48(%rbp), %rdi                 ## 8-byte Reload
	xorl	%eax, %eax
	callq	_dev_err
LBB0_16:
	movq	_EREMOTEIO@GOTPCREL(%rip), %rax
	subl	(%rax), %ebx
LBB0_18:
	movl	36(%r14), %edi
	xorl	%esi, %esi
	callq	_gpiod_set_value_cansleep
	movl	$0, (%r14)
	movq	%r12, %rdi
	callq	_spin_unlock_irqrestore
LBB0_19:
	movl	%ebx, %eax
	addq	$56, %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	"CMD %x, %zd bytes expected\n"

L_.str.1:                               ## @.str.1
	.asciz	"command len %zd too big!\n"

	.comm	_EOVERFLOW,4,2                  ## @EOVERFLOW
	.comm	_EBUSY,4,2                      ## @EBUSY
L_.str.2:                               ## @.str.2
	.asciz	"unknown command 0x%x\n"

L_.str.3:                               ## @.str.3
	.asciz	"response too big: %zd!\n"

	.comm	_CMD_STATE_WAITING_FOR_SWITCH,8,3 ## @CMD_STATE_WAITING_FOR_SWITCH
L_.str.4:                               ## @.str.4
	.asciz	"EC cmd error: timeout in STATE %d\n"

	.comm	_ETIMEDOUT,4,2                  ## @ETIMEDOUT
	.comm	_CMD_STATE_ERROR_RECEIVED,8,3   ## @CMD_STATE_ERROR_RECEIVED
L_.str.5:                               ## @.str.5
	.asciz	"command 0x%x returned error 0x%x\n"

	.comm	_EREMOTEIO,4,2                  ## @EREMOTEIO
L_.str.6:                               ## @.str.6
	.asciz	"command 0x%x returned %d bytes, expected %zd bytes\n"

	.no_dead_strip	_olpc_xo175_ec_cmd
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function olpc_xo175_ec_cmd
_olpc_xo175_ec_cmd:                     ; @olpc_xo175_ec_cmd
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #128
	.cfi_def_cfa_offset 128
	stp	x28, x27, [sp, #32]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #48]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #64]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #80]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #96]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #112]            ; 16-byte Folded Spill
	add	x29, sp, #112
	.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	x19, x5
	mov	x24, x4
	mov	x22, x3
	mov	x26, x2
	mov	x27, x1
	mov	x23, x0
	ldr	x20, [x5, #48]
Lloh0:
	adrp	x1, l_.str@PAGE
Lloh1:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x20
	mov	x2, x23
	mov	x3, x4
	bl	_dev_dbg
	cmp	x26, #6
	b.lo	LBB0_3
; %bb.1:
Lloh2:
	adrp	x1, l_.str.1@PAGE
Lloh3:
	add	x1, x1, l_.str.1@PAGEOFF
LBB0_2:
	mov	x0, x20
	mov	x2, x24
	bl	_dev_err
Lloh4:
	adrp	x8, _EOVERFLOW@GOTPAGE
Lloh5:
	ldr	x8, [x8, _EOVERFLOW@GOTPAGEOFF]
	b	LBB0_5
LBB0_3:
	ldr	w0, [x19, #96]
	bl	_WARN_ON
	cbz	x0, LBB0_7
; %bb.4:
Lloh6:
	adrp	x8, _EBUSY@GOTPAGE
Lloh7:
	ldr	x8, [x8, _EBUSY@GOTPAGEOFF]
LBB0_5:
	ldr	w8, [x8]
	neg	w21, w8
LBB0_6:
	mov	x0, x21
	ldp	x29, x30, [sp, #112]            ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #96]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #80]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #64]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #48]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #32]             ; 16-byte Folded Reload
	add	sp, sp, #128
	ret
LBB0_7:
	mov	x0, x23
	bl	_olpc_xo175_ec_resp_len
	mov	x21, x0
	tbnz	w0, #31, LBB0_9
; %bb.8:
	mov	w25, w21
	mov	w21, #0
	b	LBB0_11
LBB0_9:
Lloh8:
	adrp	x1, l_.str.2@PAGE
Lloh9:
	add	x1, x1, l_.str.2@PAGEOFF
	mov	x0, x20
	mov	x2, x23
	bl	_dev_err_ratelimited
	mov	x25, x24
	cmp	x24, #9
	b.lo	LBB0_11
; %bb.10:
Lloh10:
	adrp	x1, l_.str.3@PAGE
Lloh11:
	add	x1, x1, l_.str.3@PAGEOFF
	b	LBB0_2
LBB0_11:
	mov	x0, x24
	mov	x1, x25
	bl	_min
	str	x0, [sp, #24]                   ; 8-byte Folded Spill
	add	x24, x19, #32
	mov	x0, x24
	bl	_spin_lock_irqsave
	add	x28, x19, #56
	mov	x0, x28
	bl	_init_completion
	mov	w8, #1
	str	w8, [x19]
Lloh12:
	adrp	x8, _CMD_STATE_WAITING_FOR_SWITCH@GOTPAGE
Lloh13:
	ldr	x8, [x8, _CMD_STATE_WAITING_FOR_SWITCH@GOTPAGEOFF]
Lloh14:
	ldr	x8, [x8]
	str	x8, [x19, #8]
	add	x0, x19, #64
	mov	w1, #0
	mov	w2, #32
	bl	_memset
	str	w23, [x19, #88]
	str	x26, [x19, #64]
	str	xzr, [x19, #80]
	ldr	x0, [x19, #72]
	mov	x1, x27
	mov	x2, x26
	bl	_memcpy
	stp	x25, xzr, [x19, #16]
	ldr	w0, [x19, #36]
	mov	w1, #1
	bl	_gpiod_set_value_cansleep
	mov	x0, x24
	bl	_spin_unlock_irqrestore
	mov	w0, #4000
	bl	_msecs_to_jiffies
	mov	x1, x0
	mov	x0, x28
	bl	_wait_for_completion_timeout
	cbz	w0, LBB0_14
; %bb.12:
	mov	x0, x24
	bl	_spin_lock_irqsave
	ldr	x8, [x19, #8]
Lloh15:
	adrp	x9, _CMD_STATE_ERROR_RECEIVED@GOTPAGE
Lloh16:
	ldr	x9, [x9, _CMD_STATE_ERROR_RECEIVED@GOTPAGEOFF]
Lloh17:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_15
; %bb.13:
	sxtw	x2, w23
	ldr	x8, [x19, #40]
	ldr	w8, [x8]
	str	x8, [sp]
Lloh18:
	adrp	x1, l_.str.5@PAGE
Lloh19:
	add	x1, x1, l_.str.5@PAGEOFF
	b	LBB0_18
LBB0_14:
	ldr	x2, [x19, #8]
Lloh20:
	adrp	x1, l_.str.4@PAGE
Lloh21:
	add	x1, x1, l_.str.4@PAGEOFF
	mov	x0, x20
	bl	_dev_err
	ldr	w0, [x19, #36]
	mov	w1, #0
	bl	_gpiod_set_value_cansleep
	ldr	x0, [x19, #48]
	bl	_spi_slave_abort
	mov	x0, x19
	bl	_olpc_xo175_ec_read_packet
Lloh22:
	adrp	x8, _ETIMEDOUT@GOTPAGE
Lloh23:
	ldr	x8, [x8, _ETIMEDOUT@GOTPAGEOFF]
	b	LBB0_5
LBB0_15:
	ldr	x8, [x19, #24]
	cmp	x8, x25
	b.ne	LBB0_17
; %bb.16:
	ldr	x1, [x19, #40]
	mov	x0, x22
	ldr	x2, [sp, #24]                   ; 8-byte Folded Reload
	bl	_memcpy
	b	LBB0_19
LBB0_17:
                                        ; kill: def $w23 killed $w23 killed $x23 def $x23
	sxtw	x2, w23
	stp	x8, x25, [sp]
Lloh24:
	adrp	x1, l_.str.6@PAGE
Lloh25:
	add	x1, x1, l_.str.6@PAGEOFF
LBB0_18:
	mov	x0, x20
	bl	_dev_err
Lloh26:
	adrp	x8, _EREMOTEIO@GOTPAGE
Lloh27:
	ldr	x8, [x8, _EREMOTEIO@GOTPAGEOFF]
Lloh28:
	ldr	w8, [x8]
	neg	w21, w8
LBB0_19:
	ldr	w0, [x19, #36]
	mov	w1, #0
	bl	_gpiod_set_value_cansleep
	str	wzr, [x19]
	mov	x0, x24
	bl	_spin_unlock_irqrestore
	b	LBB0_6
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpAdd	Lloh2, Lloh3
	.loh AdrpLdrGot	Lloh4, Lloh5
	.loh AdrpLdrGot	Lloh6, Lloh7
	.loh AdrpAdd	Lloh8, Lloh9
	.loh AdrpAdd	Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpAdd	Lloh18, Lloh19
	.loh AdrpLdrGot	Lloh22, Lloh23
	.loh AdrpAdd	Lloh20, Lloh21
	.loh AdrpAdd	Lloh24, Lloh25
	.loh AdrpLdrGotLdr	Lloh26, Lloh27, Lloh28
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"CMD %x, %zd bytes expected\n"

l_.str.1:                               ; @.str.1
	.asciz	"command len %zd too big!\n"

	.comm	_EOVERFLOW,4,2                  ; @EOVERFLOW
	.comm	_EBUSY,4,2                      ; @EBUSY
l_.str.2:                               ; @.str.2
	.asciz	"unknown command 0x%x\n"

l_.str.3:                               ; @.str.3
	.asciz	"response too big: %zd!\n"

	.comm	_CMD_STATE_WAITING_FOR_SWITCH,8,3 ; @CMD_STATE_WAITING_FOR_SWITCH
l_.str.4:                               ; @.str.4
	.asciz	"EC cmd error: timeout in STATE %d\n"

	.comm	_ETIMEDOUT,4,2                  ; @ETIMEDOUT
	.comm	_CMD_STATE_ERROR_RECEIVED,8,3   ; @CMD_STATE_ERROR_RECEIVED
l_.str.5:                               ; @.str.5
	.asciz	"command 0x%x returned error 0x%x\n"

	.comm	_EREMOTEIO,4,2                  ; @EREMOTEIO
l_.str.6:                               ; @.str.6
	.asciz	"command 0x%x returned %d bytes, expected %zd bytes\n"

	.no_dead_strip	_olpc_xo175_ec_cmd
.subsections_via_symbols
