	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function cht_wc_extcon_pwrsrc_event
_cht_wc_extcon_pwrsrc_event:            ## @cht_wc_extcon_pwrsrc_event
	.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
	movq	%rdi, %rbx
	movq	_EXTCON_NONE@GOTPCREL(%rip), %rax
	movl	(%rax), %r14d
	movl	(%rdi), %r12d
	movl	16(%rdi), %edi
	movq	_CHT_WC_PWRSRC_STS@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	-44(%rbp), %rdx
	callq	_regmap_read
	testl	%eax, %eax
	je	LBB0_2
## %bb.1:
	movl	12(%rbx), %edi
	leaq	L_.str(%rip), %rsi
	movl	%eax, %edx
	callq	_dev_err
	jmp	LBB0_11
LBB0_2:
	movl	-44(%rbp), %esi
	movq	%rbx, %rdi
	callq	_cht_wc_extcon_get_id
	movl	%eax, %r15d
	movq	_INTEL_USB_ID_GND@GOTPCREL(%rip), %r13
	cmpl	(%r13), %eax
	jne	LBB0_4
## %bb.3:
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	_cht_wc_extcon_enable_charging
	movq	%rbx, %rdi
	movl	$1, %esi
	callq	_cht_wc_extcon_set_otgmode
	jmp	LBB0_7
LBB0_4:
	movq	%rbx, %rdi
	xorl	%esi, %esi
	callq	_cht_wc_extcon_set_otgmode
	movq	%rbx, %rdi
	movl	$1, %esi
	callq	_cht_wc_extcon_enable_charging
	movq	_CHT_WC_PWRSRC_VBUS@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	testl	%eax, -44(%rbp)
	je	LBB0_5
## %bb.6:
	movq	%rbx, %rdi
	movl	%r12d, %esi
	callq	_cht_wc_extcon_get_charger
	testl	%eax, %eax
	cmovnsl	%eax, %r14d
LBB0_7:
	movq	_MUX_SEL_SOC@GOTPCREL(%rip), %rax
	jmp	LBB0_8
LBB0_5:
	movq	_MUX_SEL_PMIC@GOTPCREL(%rip), %rax
LBB0_8:
	movl	(%rax), %esi
	movq	%rbx, %rdi
	callq	_cht_wc_extcon_set_phymux
	cmpl	4(%rbx), %r14d
	je	LBB0_10
## %bb.9:
	movq	%rbx, %rdi
	movl	%r14d, %esi
	movl	$1, %edx
	callq	_cht_wc_extcon_set_state
	movl	4(%rbx), %esi
	movq	%rbx, %rdi
	xorl	%edx, %edx
	callq	_cht_wc_extcon_set_state
	movl	%r14d, 4(%rbx)
LBB0_10:
	cmpl	(%r13), %r15d
	sete	%al
	movq	_INTEL_USB_RID_A@GOTPCREL(%rip), %rcx
	cmpl	(%rcx), %r15d
	sete	%cl
	orb	%al, %cl
	movzbl	%cl, %edx
	movl	%edx, (%rbx)
	movl	8(%rbx), %edi
	movq	_EXTCON_USB_HOST@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_extcon_set_state_sync
LBB0_11:
	addq	$8, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_EXTCON_NONE,4,2                ## @EXTCON_NONE
	.comm	_CHT_WC_PWRSRC_STS,4,2          ## @CHT_WC_PWRSRC_STS
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Error reading pwrsrc status: %d\n"

	.comm	_INTEL_USB_ID_GND,4,2           ## @INTEL_USB_ID_GND
	.comm	_CHT_WC_PWRSRC_VBUS,4,2         ## @CHT_WC_PWRSRC_VBUS
	.comm	_MUX_SEL_PMIC,4,2               ## @MUX_SEL_PMIC
	.comm	_MUX_SEL_SOC,4,2                ## @MUX_SEL_SOC
	.comm	_INTEL_USB_RID_A,4,2            ## @INTEL_USB_RID_A
	.comm	_EXTCON_USB_HOST,4,2            ## @EXTCON_USB_HOST
	.no_dead_strip	_cht_wc_extcon_pwrsrc_event
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function cht_wc_extcon_pwrsrc_event
_cht_wc_extcon_pwrsrc_event:            ; @cht_wc_extcon_pwrsrc_event
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #80
	.cfi_def_cfa_offset 80
	stp	x24, x23, [sp, #16]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #32]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #48]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #64]             ; 16-byte Folded Spill
	add	x29, sp, #64
	.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, x0
Lloh0:
	adrp	x8, _EXTCON_NONE@GOTPAGE
Lloh1:
	ldr	x8, [x8, _EXTCON_NONE@GOTPAGEOFF]
Lloh2:
	ldr	w20, [x8]
	ldr	w22, [x0]
	ldr	w0, [x0, #16]
Lloh3:
	adrp	x8, _CHT_WC_PWRSRC_STS@GOTPAGE
Lloh4:
	ldr	x8, [x8, _CHT_WC_PWRSRC_STS@GOTPAGEOFF]
Lloh5:
	ldr	w1, [x8]
	add	x2, sp, #12
	bl	_regmap_read
	cbz	w0, LBB0_2
; %bb.1:
	mov	x2, x0
	ldr	w0, [x19, #12]
Lloh6:
	adrp	x1, l_.str@PAGE
Lloh7:
	add	x1, x1, l_.str@PAGEOFF
	bl	_dev_err
	b	LBB0_11
LBB0_2:
	ldr	w1, [sp, #12]
	mov	x0, x19
	bl	_cht_wc_extcon_get_id
	mov	x21, x0
Lloh8:
	adrp	x23, _INTEL_USB_ID_GND@GOTPAGE
Lloh9:
	ldr	x23, [x23, _INTEL_USB_ID_GND@GOTPAGEOFF]
	ldr	w8, [x23]
	cmp	w0, w8
	b.ne	LBB0_4
; %bb.3:
	mov	x0, x19
	mov	w1, #0
	bl	_cht_wc_extcon_enable_charging
	mov	x0, x19
	mov	w1, #1
	bl	_cht_wc_extcon_set_otgmode
	b	LBB0_6
LBB0_4:
	mov	x0, x19
	mov	w1, #0
	bl	_cht_wc_extcon_set_otgmode
	mov	x0, x19
	mov	w1, #1
	bl	_cht_wc_extcon_enable_charging
	ldr	w8, [sp, #12]
Lloh10:
	adrp	x9, _CHT_WC_PWRSRC_VBUS@GOTPAGE
Lloh11:
	ldr	x9, [x9, _CHT_WC_PWRSRC_VBUS@GOTPAGEOFF]
Lloh12:
	ldr	w9, [x9]
	tst	w9, w8
	b.eq	LBB0_7
; %bb.5:
	mov	x0, x19
	mov	x1, x22
	bl	_cht_wc_extcon_get_charger
	cmp	w0, #0
	csel	w20, w20, w0, lt
LBB0_6:
Lloh13:
	adrp	x8, _MUX_SEL_SOC@GOTPAGE
Lloh14:
	ldr	x8, [x8, _MUX_SEL_SOC@GOTPAGEOFF]
	b	LBB0_8
LBB0_7:
Lloh15:
	adrp	x8, _MUX_SEL_PMIC@GOTPAGE
Lloh16:
	ldr	x8, [x8, _MUX_SEL_PMIC@GOTPAGEOFF]
LBB0_8:
	ldr	w1, [x8]
	mov	x0, x19
	bl	_cht_wc_extcon_set_phymux
	ldr	w8, [x19, #4]
	cmp	w20, w8
	b.eq	LBB0_10
; %bb.9:
	mov	x0, x19
	mov	x1, x20
	mov	w2, #1
	bl	_cht_wc_extcon_set_state
	ldr	w1, [x19, #4]
	mov	x0, x19
	mov	w2, #0
	bl	_cht_wc_extcon_set_state
	str	w20, [x19, #4]
LBB0_10:
	ldr	w8, [x23]
	cmp	w21, w8
Lloh17:
	adrp	x8, _INTEL_USB_RID_A@GOTPAGE
Lloh18:
	ldr	x8, [x8, _INTEL_USB_RID_A@GOTPAGEOFF]
Lloh19:
	ldr	w8, [x8]
	ccmp	w21, w8, #4, ne
	cset	w2, eq
	str	w2, [x19]
	ldr	w0, [x19, #8]
Lloh20:
	adrp	x8, _EXTCON_USB_HOST@GOTPAGE
Lloh21:
	ldr	x8, [x8, _EXTCON_USB_HOST@GOTPAGEOFF]
Lloh22:
	ldr	w1, [x8]
	bl	_extcon_set_state_sync
LBB0_11:
	ldp	x29, x30, [sp, #64]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #48]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #32]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #80
	ret
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh6, Lloh7
	.loh AdrpLdrGot	Lloh8, Lloh9
	.loh AdrpLdrGotLdr	Lloh10, Lloh11, Lloh12
	.loh AdrpLdrGot	Lloh13, Lloh14
	.loh AdrpLdrGot	Lloh15, Lloh16
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.cfi_endproc
                                        ; -- End function
	.comm	_EXTCON_NONE,4,2                ; @EXTCON_NONE
	.comm	_CHT_WC_PWRSRC_STS,4,2          ; @CHT_WC_PWRSRC_STS
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Error reading pwrsrc status: %d\n"

	.comm	_INTEL_USB_ID_GND,4,2           ; @INTEL_USB_ID_GND
	.comm	_CHT_WC_PWRSRC_VBUS,4,2         ; @CHT_WC_PWRSRC_VBUS
	.comm	_MUX_SEL_PMIC,4,2               ; @MUX_SEL_PMIC
	.comm	_MUX_SEL_SOC,4,2                ; @MUX_SEL_SOC
	.comm	_INTEL_USB_RID_A,4,2            ; @INTEL_USB_RID_A
	.comm	_EXTCON_USB_HOST,4,2            ; @EXTCON_USB_HOST
	.no_dead_strip	_cht_wc_extcon_pwrsrc_event
.subsections_via_symbols
