	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_twl6040_power                  ## -- Begin function twl6040_power
	.p2align	4, 0x90
_twl6040_power:                         ## @twl6040_power
	.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
	movl	%esi, %ebx
	movq	%rdi, %r12
	leaq	12(%rdi), %r14
	movq	%r14, %rdi
	callq	_mutex_lock
	movq	48(%r12), %rax
	testl	%ebx, %ebx
	je	LBB0_12
## %bb.1:
	leaq	1(%rax), %rcx
	movq	%rcx, 48(%r12)
	xorl	%r15d, %r15d
	testq	%rax, %rax
	jne	LBB0_21
## %bb.2:
	movl	16(%r12), %edi
	callq	_clk_prepare_enable
	testl	%eax, %eax
	je	LBB0_4
## %bb.3:
	movl	%eax, %r15d
	movq	$0, 48(%r12)
	jmp	LBB0_21
LBB0_12:
	testq	%rax, %rax
	je	LBB0_13
## %bb.14:
	xorl	%r15d, %r15d
	decq	%rax
	movq	%rax, 48(%r12)
	jne	LBB0_21
## %bb.15:
	movl	40(%r12), %edi
	callq	_gpio_is_valid
	testq	%rax, %rax
	je	LBB0_17
## %bb.16:
	movl	40(%r12), %edi
	xorl	%esi, %esi
	callq	_gpio_set_value
	movl	$500, %edi                      ## imm = 0x1F4
	movl	$700, %esi                      ## imm = 0x2BC
	callq	_usleep_range
	jmp	LBB0_18
LBB0_13:
	movl	56(%r12), %edi
	leaq	L_.str.1(%rip), %rsi
	xorl	%r15d, %r15d
	xorl	%eax, %eax
	callq	_dev_err
	movq	_EPERM@GOTPCREL(%rip), %rax
	subl	(%rax), %r15d
	jmp	LBB0_21
LBB0_4:
	movl	36(%r12), %edi
	xorl	%esi, %esi
	callq	_regcache_cache_only
	movl	40(%r12), %edi
	callq	_gpio_is_valid
	movq	%r12, %rdi
	testq	%rax, %rax
	je	LBB0_8
## %bb.5:
	callq	_twl6040_power_up_automatic
	testl	%eax, %eax
	je	LBB0_9
LBB0_7:
	movl	%eax, %r15d
	movl	16(%r12), %edi
	callq	_clk_disable_unprepare
	movq	$0, 48(%r12)
	jmp	LBB0_21
LBB0_17:
	movq	%r12, %rdi
	callq	_twl6040_power_down_manual
LBB0_18:
	movl	36(%r12), %edi
	movl	$1, %esi
	callq	_regcache_cache_only
	movl	36(%r12), %edi
	callq	_regcache_mark_dirty
	movl	$0, 8(%r12)
	movq	(%r12), %rax
	movq	_TWL6040_SYSCLK_SEL_HPPLL@GOTPCREL(%rip), %rcx
	cmpq	(%rcx), %rax
	jne	LBB0_20
## %bb.19:
	movl	32(%r12), %edi
	callq	_clk_disable_unprepare
	movq	$0, 24(%r12)
LBB0_20:
	movl	16(%r12), %edi
	callq	_clk_disable_unprepare
LBB0_21:
	movq	%r14, %rdi
	callq	_mutex_unlock
	movl	%r15d, %eax
	popq	%rbx
	popq	%r12
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_8:
	callq	_twl6040_power_up_manual
	testl	%eax, %eax
	jne	LBB0_7
LBB0_9:
	movl	$10000, %edi                    ## imm = 0x2710
	movl	$12000, %esi                    ## imm = 0x2EE0
	callq	_usleep_range
	movl	36(%r12), %edi
	callq	_regcache_sync
	testl	%eax, %eax
	je	LBB0_11
## %bb.10:
	movl	%eax, %r15d
	movl	56(%r12), %edi
	leaq	L_.str(%rip), %rsi
	movl	%eax, %edx
	xorl	%eax, %eax
	callq	_dev_err
	jmp	LBB0_21
LBB0_11:
	movq	_TWL6040_SYSCLK_SEL_LPPLL@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rax, (%r12)
	movl	$19200000, 8(%r12)              ## imm = 0x124F800
	xorl	%r15d, %r15d
	jmp	LBB0_21
	.cfi_endproc
                                        ## -- End function
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Failed to sync with the HW: %i\n"

	.comm	_TWL6040_SYSCLK_SEL_LPPLL,8,3   ## @TWL6040_SYSCLK_SEL_LPPLL
L_.str.1:                               ## @.str.1
	.asciz	"device is already powered-off\n"

	.comm	_EPERM,4,2                      ## @EPERM
	.comm	_TWL6040_SYSCLK_SEL_HPPLL,8,3   ## @TWL6040_SYSCLK_SEL_HPPLL
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.globl	_twl6040_power                  ; -- Begin function twl6040_power
	.p2align	2
_twl6040_power:                         ; @twl6040_power
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #64
	.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
	mov	x21, x1
	mov	x20, x0
	add	x19, x0, #12
	mov	x0, x19
	bl	_mutex_lock
	ldr	x8, [x20, #48]
	cbz	w21, LBB0_4
; %bb.1:
	add	x9, x8, #1
	str	x9, [x20, #48]
	cbnz	x8, LBB0_16
; %bb.2:
	ldr	w0, [x20, #16]
	bl	_clk_prepare_enable
	cbz	w0, LBB0_9
; %bb.3:
	mov	x21, x0
	str	xzr, [x20, #48]
	b	LBB0_17
LBB0_4:
	cbz	x8, LBB0_8
; %bb.5:
	subs	x8, x8, #1
	str	x8, [x20, #48]
	b.ne	LBB0_16
; %bb.6:
	ldr	w0, [x20, #40]
	bl	_gpio_is_valid
	cbz	x0, LBB0_12
; %bb.7:
	ldr	w0, [x20, #40]
	mov	w1, #0
	bl	_gpio_set_value
	mov	w0, #500
	mov	w1, #700
	bl	_usleep_range
	b	LBB0_13
LBB0_8:
	ldr	w0, [x20, #56]
Lloh0:
	adrp	x1, l_.str.1@PAGE
Lloh1:
	add	x1, x1, l_.str.1@PAGEOFF
	bl	_dev_err
Lloh2:
	adrp	x8, _EPERM@GOTPAGE
Lloh3:
	ldr	x8, [x8, _EPERM@GOTPAGEOFF]
Lloh4:
	ldr	w8, [x8]
	neg	w21, w8
	b	LBB0_17
LBB0_9:
	ldr	w0, [x20, #36]
	mov	w1, #0
	bl	_regcache_cache_only
	ldr	w0, [x20, #40]
	bl	_gpio_is_valid
	cbz	x0, LBB0_18
; %bb.10:
	mov	x0, x20
	bl	_twl6040_power_up_automatic
	cbz	w0, LBB0_19
LBB0_11:
	mov	x21, x0
	ldr	w0, [x20, #16]
	bl	_clk_disable_unprepare
	str	xzr, [x20, #48]
	b	LBB0_17
LBB0_12:
	mov	x0, x20
	bl	_twl6040_power_down_manual
LBB0_13:
	ldr	w0, [x20, #36]
	mov	w1, #1
	bl	_regcache_cache_only
	ldr	w0, [x20, #36]
	bl	_regcache_mark_dirty
	str	wzr, [x20, #8]
	ldr	x8, [x20]
Lloh5:
	adrp	x9, _TWL6040_SYSCLK_SEL_HPPLL@GOTPAGE
Lloh6:
	ldr	x9, [x9, _TWL6040_SYSCLK_SEL_HPPLL@GOTPAGEOFF]
Lloh7:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_15
; %bb.14:
	ldr	w0, [x20, #32]
	bl	_clk_disable_unprepare
	str	xzr, [x20, #24]
LBB0_15:
	ldr	w0, [x20, #16]
	bl	_clk_disable_unprepare
LBB0_16:
	mov	w21, #0
LBB0_17:
	mov	x0, x19
	bl	_mutex_unlock
	mov	x0, x21
	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
	add	sp, sp, #64
	ret
LBB0_18:
	mov	x0, x20
	bl	_twl6040_power_up_manual
	cbnz	w0, LBB0_11
LBB0_19:
	mov	w0, #10000
	mov	w1, #12000
	bl	_usleep_range
	ldr	w0, [x20, #36]
	bl	_regcache_sync
	mov	x21, x0
	cbz	w0, LBB0_21
; %bb.20:
	ldr	w0, [x20, #56]
	str	x21, [sp]
Lloh8:
	adrp	x1, l_.str@PAGE
Lloh9:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_err
	b	LBB0_17
LBB0_21:
Lloh10:
	adrp	x8, _TWL6040_SYSCLK_SEL_LPPLL@GOTPAGE
Lloh11:
	ldr	x8, [x8, _TWL6040_SYSCLK_SEL_LPPLL@GOTPAGEOFF]
Lloh12:
	ldr	x8, [x8]
	str	x8, [x20]
	mov	w8, #63488
	movk	w8, #292, lsl #16
	str	w8, [x20, #8]
	b	LBB0_17
	.loh AdrpLdrGotLdr	Lloh2, Lloh3, Lloh4
	.loh AdrpAdd	Lloh0, Lloh1
	.loh AdrpLdrGotLdr	Lloh5, Lloh6, Lloh7
	.loh AdrpAdd	Lloh8, Lloh9
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.cfi_endproc
                                        ; -- End function
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Failed to sync with the HW: %i\n"

	.comm	_TWL6040_SYSCLK_SEL_LPPLL,8,3   ; @TWL6040_SYSCLK_SEL_LPPLL
l_.str.1:                               ; @.str.1
	.asciz	"device is already powered-off\n"

	.comm	_EPERM,4,2                      ; @EPERM
	.comm	_TWL6040_SYSCLK_SEL_HPPLL,8,3   ; @TWL6040_SYSCLK_SEL_HPPLL
.subsections_via_symbols
