	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function aml8726_usb_phy_attach
_aml8726_usb_phy_attach:                ## @aml8726_usb_phy_attach
	.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
	movl	%edi, %r12d
	callq	_device_get_softc
	movq	%rax, %r14
	movl	%r12d, 40(%rax)
	movq	_aml8726_usb_phy_spec@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	4(%r14), %edx
	movl	%r12d, %edi
	callq	_bus_alloc_resources
	testq	%rax, %rax
	je	LBB0_2
## %bb.1:
	leaq	L_.str(%rip), %rsi
	movl	%r12d, %edi
	callq	_device_printf
	jmp	LBB0_43
LBB0_2:
	movl	%r12d, %edi
	callq	_ofw_bus_get_node
	movl	%eax, %r15d
	leaq	L_.str.1(%rip), %rsi
	leaq	-88(%rbp), %rdx
	movl	%eax, %edi
	callq	_OF_getprop_alloc
	movq	_FALSE@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	movq	%rcx, 32(%r14)
	testl	%eax, %eax
	jle	LBB0_5
## %bb.3:
	movq	-88(%rbp), %rdi
	leaq	L_.str.2(%rip), %rsi
	movl	%eax, %edx
	callq	_strncmp
	testq	%rax, %rax
	jne	LBB0_5
## %bb.4:
	movq	_TRUE@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	movq	%rax, 32(%r14)
LBB0_5:
	movq	-88(%rbp), %rdi
	callq	_OF_prop_free
	leaq	L_.str.3(%rip), %rsi
	leaq	-64(%rbp), %rcx
	movl	%r15d, %edi
	movl	$3, %edx
	callq	_OF_getencprop_alloc_multi
	movl	%eax, %r13d
	xorl	%ebx, %ebx
	testl	%eax, %eax
	cmovgl	%eax, %ebx
	movl	$0, (%r14)
	movl	%ebx, %edi
	shll	$4, %edi
	movq	_M_DEVBUF@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_M_WAITOK@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	callq	_malloc
	movq	%rax, 8(%r14)
	testl	%r13d, %r13d
	movq	%r14, -56(%rbp)                 ## 8-byte Spill
	movl	%r12d, -44(%rbp)                ## 4-byte Spill
	movl	%r15d, -76(%rbp)                ## 4-byte Spill
	movl	%ebx, -68(%rbp)                 ## 4-byte Spill
	movl	%r13d, -72(%rbp)                ## 4-byte Spill
	jle	LBB0_6
## %bb.7:
	movl	%ebx, %r15d
	movq	-64(%rbp), %rdi
	leaq	(%r15,%r15,2), %rax
	movq	%rax, -96(%rbp)                 ## 8-byte Spill
	movb	$1, %r14b
	movl	$8, %ebx
	movl	$1, %r13d
	xorl	%r12d, %r12d
	.p2align	4, 0x90
LBB0_9:                                 ## =>This Inner Loop Header: Depth=1
	movsbl	(%rdi,%r12), %edi
	callq	_OF_device_from_xref
	movq	-56(%rbp), %rcx                 ## 8-byte Reload
	movq	8(%rcx), %rcx
	movq	%rax, (%rcx,%rbx)
	movq	-64(%rbp), %rdi
	movzbl	1(%rdi,%r12), %edx
	movb	%dl, -8(%rcx,%rbx)
	movzbl	2(%rdi,%r12), %edx
	movb	%dl, -7(%rcx,%rbx)
	testq	%rax, %rax
	je	LBB0_10
## %bb.8:                               ##   in Loop: Header=BB0_9 Depth=1
	cmpq	%r15, %r13
	setb	%r14b
	addq	$3, %r12
	addq	$16, %rbx
	incq	%r13
	cmpq	%r12, -96(%rbp)                 ## 8-byte Folded Reload
	jne	LBB0_9
	jmp	LBB0_10
LBB0_6:
	movq	-64(%rbp), %rdi
	xorl	%r14d, %r14d
LBB0_10:
	callq	_OF_prop_free
	leaq	L_.str.4(%rip), %rsi
	leaq	-64(%rbp), %rcx
	movl	-76(%rbp), %edi                 ## 4-byte Reload
	movl	$3, %edx
	callq	_OF_getencprop_alloc_multi
	movq	-64(%rbp), %rdi
	testl	%eax, %eax
	jle	LBB0_13
## %bb.11:
	movl	%eax, %r15d
	movsbl	(%rdi), %edi
	callq	_OF_device_from_xref
	movq	-56(%rbp), %rdx                 ## 8-byte Reload
	movq	%rax, 24(%rdx)
	movq	-64(%rbp), %rdi
	movb	1(%rdi), %cl
	movb	%cl, 16(%rdx)
	movb	2(%rdi), %cl
	movb	%cl, 17(%rdx)
	cmpl	$1, %r15d
	jne	LBB0_45
## %bb.12:
	testq	%rax, %rax
	je	LBB0_45
LBB0_13:
	movl	-44(%rbp), %r13d                ## 4-byte Reload
	callq	_OF_prop_free
	testb	$1, %r14b
	je	LBB0_15
## %bb.14:
	leaq	L_.str.5(%rip), %rsi
	jmp	LBB0_39
LBB0_15:
	cmpl	$0, -72(%rbp)                   ## 4-byte Folded Reload
	movq	-56(%rbp), %r15                 ## 8-byte Reload
	jle	LBB0_21
## %bb.16:
	movl	-68(%rbp), %r14d                ## 4-byte Reload
	shlq	$4, %r14
	xorl	%ebx, %ebx
	.p2align	4, 0x90
LBB0_17:                                ## =>This Inner Loop Header: Depth=1
	movq	8(%r15), %rax
	movq	8(%rax,%rbx), %r13
	movsbl	(%rax,%rbx), %r12d
	movsbl	1(%rax,%rbx), %edi
	callq	_PIN_ON_FLAG
	movq	%r13, %rdi
	movl	%r12d, %esi
	movl	%eax, %edx
	callq	_GPIO_PIN_SET
	testq	%rax, %rax
	jne	LBB0_18
## %bb.19:                              ##   in Loop: Header=BB0_17 Depth=1
	movq	8(%r15), %rax
	movq	8(%rax,%rbx), %rdi
	movsbl	(%rax,%rbx), %esi
	movq	_GPIO_PIN_OUTPUT@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	callq	_GPIO_PIN_SETFLAGS
	testq	%rax, %rax
	jne	LBB0_18
## %bb.20:                              ##   in Loop: Header=BB0_17 Depth=1
	incl	(%r15)
	addq	$16, %rbx
	cmpq	%rbx, %r14
	jne	LBB0_17
LBB0_21:
	movq	_AML_USB_PHY_CFG_REG@GOTPCREL(%rip), %rbx
	movl	(%rbx), %esi
	movq	%r15, %rdi
	callq	_CSR_READ_4
	movq	_AML_USB_PHY_CFG_CLK_SEL_32K_ALT@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	movq	_AML_USB_PHY_CFG_CLK_DIV_MASK@GOTPCREL(%rip), %rdx
	movl	(%rdx), %esi
	movl	%esi, %edx
	orl	%ecx, %edx
	movq	_AML_USB_PHY_CFG_CLK_SEL_MASK@GOTPCREL(%rip), %rdi
	orl	(%rdi), %edx
	movq	_AML_USB_PHY_CFG_CLK_EN@GOTPCREL(%rip), %rdi
	movl	(%rdi), %edi
	orl	%edi, %edx
	notl	%edx
	andl	%eax, %edx
	movq	_aml8726_soc_hw_rev@GOTPCREL(%rip), %r14
	movl	(%r14), %eax
	andl	$-2, %eax
	cmpl	$128, %eax
	jne	LBB0_23
## %bb.22:
	orl	%ecx, %edx
	jmp	LBB0_24
LBB0_45:
	callq	_OF_prop_free
	leaq	L_.str.5(%rip), %rsi
	movl	-44(%rbp), %r13d                ## 4-byte Reload
	jmp	LBB0_39
LBB0_18:
	movl	-44(%rbp), %r13d                ## 4-byte Reload
	leaq	L_.str.6(%rip), %rsi
	jmp	LBB0_39
LBB0_23:
	movq	_AML_USB_PHY_CFG_CLK_SEL_XTAL@GOTPCREL(%rip), %r8
	movq	_AML_USB_PHY_CFG_CLK_DIV_SHIFT@GOTPCREL(%rip), %rcx
	movb	(%rcx), %cl
	movl	$1, %eax
	shll	%cl, %eax
	andl	%esi, %eax
	orl	%edi, %edx
	orl	(%r8), %edx
	orl	%eax, %edx
LBB0_24:
	movl	-44(%rbp), %r13d                ## 4-byte Reload
	movl	(%rbx), %esi
	movq	%r15, %rdi
	callq	_CSR_WRITE_4
	movl	(%rbx), %esi
	movq	%r15, %rdi
	callq	_CSR_BARRIER
	movq	_AML_USB_PHY_CTRL_REG@GOTPCREL(%rip), %r12
	movl	(%r12), %esi
	movq	%r15, %rdi
	callq	_CSR_READ_4
	movq	_AML_USB_PHY_CTRL_FSEL_MASK@GOTPCREL(%rip), %rcx
	movl	(%rcx), %r15d
	notl	%r15d
	andl	%eax, %r15d
	movl	(%r14), %eax
	andl	$-2, %eax
	cmpl	$128, %eax
	jne	LBB0_25
## %bb.26:
	movq	_AML_USB_PHY_CTRL_FSEL_24M@GOTPCREL(%rip), %rax
	jmp	LBB0_27
LBB0_25:
	movq	_AML_USB_PHY_CTRL_FSEL_12M@GOTPCREL(%rip), %rax
LBB0_27:
	orl	(%rax), %r15d
	movq	_AML_USB_PHY_CTRL_POR@GOTPCREL(%rip), %r14
	orl	(%r14), %r15d
	movl	(%r12), %esi
	movq	-56(%rbp), %rbx                 ## 8-byte Reload
	movq	%rbx, %rdi
	movl	%r15d, %edx
	callq	_CSR_WRITE_4
	movl	(%r12), %esi
	movq	%rbx, %rdi
	callq	_CSR_BARRIER
	movl	$500, %edi                      ## imm = 0x1F4
	callq	_DELAY
	movl	(%r14), %edx
	notl	%edx
	andl	%r15d, %edx
	movl	(%r12), %esi
	movq	%rbx, %rdi
	callq	_CSR_WRITE_4
	movl	(%r12), %esi
	movq	%rbx, %rdi
	callq	_CSR_BARRIER
	movl	$1000, %edi                     ## imm = 0x3E8
	callq	_DELAY
	movl	(%r12), %esi
	movq	%rbx, %rdi
	callq	_CSR_READ_4
	movq	_AML_USB_PHY_CTRL_CLK_DETECTED@GOTPCREL(%rip), %rcx
	testl	%eax, (%rcx)
	jne	LBB0_29
## %bb.28:
	leaq	L_.str.7(%rip), %rsi
	movl	%r13d, %edi
	callq	_device_printf
LBB0_29:
	cmpq	$0, 32(%rbx)
	je	LBB0_32
## %bb.30:
	movq	_AML_USB_PHY_ADP_BC_REG@GOTPCREL(%rip), %r14
	movl	(%r14), %esi
	movq	%rbx, %rdi
	callq	_CSR_READ_4
	movq	_AML_USB_PHY_ADP_BC_ACA_EN@GOTPCREL(%rip), %rcx
	orl	(%rcx), %eax
	movl	(%r14), %esi
	movq	%rbx, %rdi
	movl	%eax, %edx
	callq	_CSR_WRITE_4
	movl	(%r14), %esi
	movq	%rbx, %rdi
	callq	_CSR_BARRIER
	movl	$50, %edi
	callq	_DELAY
	movl	(%r14), %esi
	movq	%rbx, %rdi
	callq	_CSR_READ_4
	movq	_AML_USB_PHY_ADP_BC_ACA_FLOATING@GOTPCREL(%rip), %rcx
	testl	%eax, (%rcx)
	je	LBB0_32
## %bb.31:
	leaq	L_.str.8(%rip), %rsi
	jmp	LBB0_39
LBB0_32:
	movq	24(%rbx), %r12
	xorl	%r15d, %r15d
	testq	%r12, %r12
	je	LBB0_44
## %bb.33:
	movq	%rbx, %rax
	movsbl	16(%rbx), %ebx
	movsbl	17(%rax), %edi
	callq	_PIN_ON_FLAG
	movq	%r12, %rdi
	movl	%ebx, %esi
	movl	%eax, %edx
	callq	_GPIO_PIN_SET
	testq	%rax, %rax
	jne	LBB0_36
## %bb.34:
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	movq	24(%rax), %rdi
	movsbl	16(%rax), %esi
	movq	_GPIO_PIN_OUTPUT@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	callq	_GPIO_PIN_SETFLAGS
	testq	%rax, %rax
	je	LBB0_35
LBB0_36:
	xorl	%r14d, %r14d
LBB0_37:
	movl	$30, %edi
	callq	_DELAY
	movq	-56(%rbp), %rax                 ## 8-byte Reload
	movq	24(%rax), %rbx
	movsbl	16(%rax), %r12d
	movsbl	17(%rax), %edi
	callq	_PIN_OFF_FLAG
	movq	%rbx, %rdi
	movl	%r12d, %esi
	movl	%eax, %edx
	callq	_GPIO_PIN_SET
	movq	%rax, %rbx
	movl	$60000, %edi                    ## imm = 0xEA60
	callq	_DELAY
	leaq	L_.str.9(%rip), %rsi
	testb	%r14b, %r14b
	je	LBB0_39
## %bb.38:
	testq	%rbx, %rbx
	je	LBB0_44
LBB0_39:
	movl	%r13d, %edi
	callq	_device_printf
	movq	-56(%rbp), %r14                 ## 8-byte Reload
	movslq	(%r14), %r12
	testq	%r12, %r12
	je	LBB0_42
## %bb.40:
	movq	%r12, %rbx
	shlq	$4, %rbx
	addq	$-16, %rbx
	.p2align	4, 0x90
LBB0_41:                                ## =>This Inner Loop Header: Depth=1
	movq	8(%r14), %rax
	movq	8(%rax,%rbx), %r14
	movsbl	(%rax,%rbx), %r15d
	movsbl	1(%rax,%rbx), %edi
	callq	_PIN_OFF_FLAG
	movq	%r14, %rdi
	movl	%r15d, %esi
	movq	-56(%rbp), %r14                 ## 8-byte Reload
	movl	%eax, %edx
	callq	_GPIO_PIN_SET
	addq	$-16, %rbx
	decl	%r12d
	jne	LBB0_41
LBB0_42:
	movq	8(%r14), %rdi
	movq	_M_DEVBUF@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	callq	_free
	movq	$0, 8(%r14)
	movq	_aml8726_usb_phy_spec@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movl	4(%r14), %edx
	movl	%r13d, %edi
	callq	_bus_release_resources
LBB0_43:
	movq	_ENXIO@GOTPCREL(%rip), %rax
	movl	(%rax), %r15d
LBB0_44:
	movl	%r15d, %eax
	addq	$56, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_35:
	movb	$1, %r14b
	jmp	LBB0_37
	.cfi_endproc
                                        ## -- End function
	.comm	_aml8726_usb_phy_spec,4,2       ## @aml8726_usb_phy_spec
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"can not allocate resources for device\n"

	.comm	_ENXIO,4,2                      ## @ENXIO
L_.str.1:                               ## @.str.1
	.asciz	"force-aca"

	.comm	_FALSE,8,3                      ## @FALSE
L_.str.2:                               ## @.str.2
	.asciz	"true"

	.comm	_TRUE,8,3                       ## @TRUE
L_.str.3:                               ## @.str.3
	.asciz	"usb-pwr-en"

	.comm	_M_DEVBUF,4,2                   ## @M_DEVBUF
	.comm	_M_WAITOK,4,2                   ## @M_WAITOK
L_.str.4:                               ## @.str.4
	.asciz	"usb-hub-rst"

L_.str.5:                               ## @.str.5
	.asciz	"unable to parse gpio\n"

	.comm	_GPIO_PIN_OUTPUT,4,2            ## @GPIO_PIN_OUTPUT
L_.str.6:                               ## @.str.6
	.asciz	"could not use gpio to control power\n"

	.comm	_AML_USB_PHY_CFG_REG,4,2        ## @AML_USB_PHY_CFG_REG
	.comm	_AML_USB_PHY_CFG_CLK_SEL_32K_ALT,4,2 ## @AML_USB_PHY_CFG_CLK_SEL_32K_ALT
	.comm	_AML_USB_PHY_CFG_CLK_DIV_MASK,4,2 ## @AML_USB_PHY_CFG_CLK_DIV_MASK
	.comm	_AML_USB_PHY_CFG_CLK_SEL_MASK,4,2 ## @AML_USB_PHY_CFG_CLK_SEL_MASK
	.comm	_AML_USB_PHY_CFG_CLK_EN,4,2     ## @AML_USB_PHY_CFG_CLK_EN
	.comm	_aml8726_soc_hw_rev,4,2         ## @aml8726_soc_hw_rev
	.comm	_AML_USB_PHY_CFG_CLK_SEL_XTAL,4,2 ## @AML_USB_PHY_CFG_CLK_SEL_XTAL
	.comm	_AML_USB_PHY_CFG_CLK_DIV_SHIFT,4,2 ## @AML_USB_PHY_CFG_CLK_DIV_SHIFT
	.comm	_AML_USB_PHY_CTRL_REG,4,2       ## @AML_USB_PHY_CTRL_REG
	.comm	_AML_USB_PHY_CTRL_FSEL_MASK,4,2 ## @AML_USB_PHY_CTRL_FSEL_MASK
	.comm	_AML_USB_PHY_CTRL_FSEL_24M,4,2  ## @AML_USB_PHY_CTRL_FSEL_24M
	.comm	_AML_USB_PHY_CTRL_FSEL_12M,4,2  ## @AML_USB_PHY_CTRL_FSEL_12M
	.comm	_AML_USB_PHY_CTRL_POR,4,2       ## @AML_USB_PHY_CTRL_POR
	.comm	_AML_USB_PHY_CTRL_CLK_DETECTED,4,2 ## @AML_USB_PHY_CTRL_CLK_DETECTED
L_.str.7:                               ## @.str.7
	.asciz	"PHY Clock not detected\n"

	.comm	_AML_USB_PHY_ADP_BC_REG,4,2     ## @AML_USB_PHY_ADP_BC_REG
	.comm	_AML_USB_PHY_ADP_BC_ACA_EN,4,2  ## @AML_USB_PHY_ADP_BC_ACA_EN
	.comm	_AML_USB_PHY_ADP_BC_ACA_FLOATING,4,2 ## @AML_USB_PHY_ADP_BC_ACA_FLOATING
L_.str.8:                               ## @.str.8
	.asciz	"force-aca requires newer silicon\n"

L_.str.9:                               ## @.str.9
	.asciz	"could not use gpio to reset hub\n"

	.no_dead_strip	_aml8726_usb_phy_attach
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function aml8726_usb_phy_attach
_aml8726_usb_phy_attach:                ; @aml8726_usb_phy_attach
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #112
	.cfi_def_cfa_offset 112
	stp	x28, x27, [sp, #16]             ; 16-byte Folded Spill
	stp	x26, x25, [sp, #32]             ; 16-byte Folded Spill
	stp	x24, x23, [sp, #48]             ; 16-byte Folded Spill
	stp	x22, x21, [sp, #64]             ; 16-byte Folded Spill
	stp	x20, x19, [sp, #80]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #96]             ; 16-byte Folded Spill
	add	x29, sp, #96
	.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, x0
	bl	_device_get_softc
	mov	x20, x0
	str	w19, [x0, #40]
Lloh0:
	adrp	x8, _aml8726_usb_phy_spec@GOTPAGE
Lloh1:
	ldr	x8, [x8, _aml8726_usb_phy_spec@GOTPAGEOFF]
Lloh2:
	ldr	w1, [x8]
	ldr	w2, [x0, #4]
	mov	x0, x19
	bl	_bus_alloc_resources
	cbz	x0, LBB0_2
; %bb.1:
Lloh3:
	adrp	x1, l_.str@PAGE
Lloh4:
	add	x1, x1, l_.str@PAGEOFF
	mov	x0, x19
	bl	_device_printf
	b	LBB0_27
LBB0_2:
	mov	x0, x19
	bl	_ofw_bus_get_node
	mov	x21, x0
Lloh5:
	adrp	x1, l_.str.1@PAGE
Lloh6:
	add	x1, x1, l_.str.1@PAGEOFF
	add	x2, sp, #8
	bl	_OF_getprop_alloc
Lloh7:
	adrp	x8, _FALSE@GOTPAGE
Lloh8:
	ldr	x8, [x8, _FALSE@GOTPAGEOFF]
Lloh9:
	ldr	x8, [x8]
	str	x8, [x20, #32]
	cmp	w0, #1
	b.lt	LBB0_5
; %bb.3:
	mov	x2, x0
	ldr	x0, [sp, #8]
Lloh10:
	adrp	x1, l_.str.2@PAGE
Lloh11:
	add	x1, x1, l_.str.2@PAGEOFF
	bl	_strncmp
	cbnz	x0, LBB0_5
; %bb.4:
Lloh12:
	adrp	x8, _TRUE@GOTPAGE
Lloh13:
	ldr	x8, [x8, _TRUE@GOTPAGEOFF]
Lloh14:
	ldr	x8, [x8]
	str	x8, [x20, #32]
LBB0_5:
	ldr	x0, [sp, #8]
	bl	_OF_prop_free
Lloh15:
	adrp	x1, l_.str.3@PAGE
Lloh16:
	add	x1, x1, l_.str.3@PAGEOFF
	mov	x3, sp
	mov	x0, x21
	mov	w2, #3
	bl	_OF_getencprop_alloc_multi
	mov	x22, x0
	cmp	w0, #0
	csel	w23, w0, wzr, gt
	str	wzr, [x20]
	lsl	w0, w23, #4
Lloh17:
	adrp	x8, _M_DEVBUF@GOTPAGE
Lloh18:
	ldr	x8, [x8, _M_DEVBUF@GOTPAGEOFF]
Lloh19:
	ldr	w1, [x8]
Lloh20:
	adrp	x8, _M_WAITOK@GOTPAGE
Lloh21:
	ldr	x8, [x8, _M_WAITOK@GOTPAGEOFF]
Lloh22:
	ldr	w2, [x8]
	bl	_malloc
	str	x0, [x20, #8]
	cmp	w22, #0
	b.le	LBB0_9
; %bb.6:
	mov	x27, #0
	ldr	x0, [sp]
	lsl	x28, x23, #4
	mov	w25, #1
	mov	w24, #1
	mov	w26, #1
LBB0_7:                                 ; =>This Inner Loop Header: Depth=1
	add	x8, x0, x24
	ldursb	w0, [x8, #-1]
	bl	_OF_device_from_xref
	mov	x8, x0
	ldr	x9, [x20, #8]
	add	x9, x9, x27
	str	x0, [x9, #8]
	ldr	x0, [sp]
	add	x10, x0, x24
	ldrb	w11, [x10]
	strb	w11, [x9]
	ldrb	w10, [x10, #1]
	strb	w10, [x9, #1]
	cbz	x8, LBB0_10
; %bb.8:                                ;   in Loop: Header=BB0_7 Depth=1
	cmp	x25, x23
	cset	w26, lo
	add	x24, x24, #3
	add	x27, x27, #16
	add	x25, x25, #1
	cmp	x28, x27
	b.ne	LBB0_7
	b	LBB0_10
LBB0_9:
	mov	w26, #0
	ldr	x0, [sp]
LBB0_10:
	bl	_OF_prop_free
Lloh23:
	adrp	x1, l_.str.4@PAGE
Lloh24:
	add	x1, x1, l_.str.4@PAGEOFF
	mov	x3, sp
	mov	x0, x21
	mov	w2, #3
	bl	_OF_getencprop_alloc_multi
	mov	x21, x0
	ldr	x0, [sp]
	cmp	w21, #1
	b.lt	LBB0_13
; %bb.11:
	ldrsb	w0, [x0]
	bl	_OF_device_from_xref
	mov	x8, x0
	str	x0, [x20, #24]
	ldr	x0, [sp]
	ldrb	w9, [x0, #1]
	strb	w9, [x20, #16]
	ldrb	w9, [x0, #2]
	strb	w9, [x20, #17]
	cmp	w21, #1
	b.ne	LBB0_21
; %bb.12:
	cbz	x8, LBB0_21
LBB0_13:
	bl	_OF_prop_free
	tbnz	w26, #0, LBB0_22
; %bb.14:
	cmp	w22, #1
	b.lt	LBB0_19
; %bb.15:
	mov	x25, #0
	lsl	x26, x23, #4
Lloh25:
	adrp	x24, _GPIO_PIN_OUTPUT@GOTPAGE
Lloh26:
	ldr	x24, [x24, _GPIO_PIN_OUTPUT@GOTPAGEOFF]
Lloh27:
	adrp	x21, l_.str.6@PAGE
Lloh28:
	add	x21, x21, l_.str.6@PAGEOFF
LBB0_16:                                ; =>This Inner Loop Header: Depth=1
	ldr	x8, [x20, #8]
	add	x8, x8, x25
	ldr	x22, [x8, #8]
	ldrsb	w23, [x8]
	ldrsb	w0, [x8, #1]
	bl	_PIN_ON_FLAG
	mov	x2, x0
	mov	x0, x22
	mov	x1, x23
	bl	_GPIO_PIN_SET
	cbnz	x0, LBB0_23
; %bb.17:                               ;   in Loop: Header=BB0_16 Depth=1
	ldr	x8, [x20, #8]
	add	x8, x8, x25
	ldr	x0, [x8, #8]
	ldrsb	w1, [x8]
	ldr	w2, [x24]
	bl	_GPIO_PIN_SETFLAGS
	cbnz	x0, LBB0_23
; %bb.18:                               ;   in Loop: Header=BB0_16 Depth=1
	ldr	w8, [x20]
	add	w8, w8, #1
	str	w8, [x20]
	add	x25, x25, #16
	cmp	x26, x25
	b.ne	LBB0_16
LBB0_19:
Lloh29:
	adrp	x21, _AML_USB_PHY_CFG_REG@GOTPAGE
Lloh30:
	ldr	x21, [x21, _AML_USB_PHY_CFG_REG@GOTPAGEOFF]
	ldr	w1, [x21]
	mov	x0, x20
	bl	_CSR_READ_4
Lloh31:
	adrp	x8, _AML_USB_PHY_CFG_CLK_SEL_32K_ALT@GOTPAGE
Lloh32:
	ldr	x8, [x8, _AML_USB_PHY_CFG_CLK_SEL_32K_ALT@GOTPAGEOFF]
Lloh33:
	ldr	w11, [x8]
Lloh34:
	adrp	x8, _AML_USB_PHY_CFG_CLK_DIV_MASK@GOTPAGE
Lloh35:
	ldr	x8, [x8, _AML_USB_PHY_CFG_CLK_DIV_MASK@GOTPAGEOFF]
Lloh36:
	ldr	w8, [x8]
	orr	w9, w8, w11
Lloh37:
	adrp	x10, _AML_USB_PHY_CFG_CLK_SEL_MASK@GOTPAGE
Lloh38:
	ldr	x10, [x10, _AML_USB_PHY_CFG_CLK_SEL_MASK@GOTPAGEOFF]
Lloh39:
	ldr	w10, [x10]
	orr	w10, w9, w10
Lloh40:
	adrp	x9, _AML_USB_PHY_CFG_CLK_EN@GOTPAGE
Lloh41:
	ldr	x9, [x9, _AML_USB_PHY_CFG_CLK_EN@GOTPAGEOFF]
Lloh42:
	ldr	w9, [x9]
	orr	w10, w10, w9
	bic	w10, w0, w10
Lloh43:
	adrp	x23, _aml8726_soc_hw_rev@GOTPAGE
Lloh44:
	ldr	x23, [x23, _aml8726_soc_hw_rev@GOTPAGEOFF]
	ldr	w12, [x23]
	and	w12, w12, #0xfffffffe
	cmp	w12, #128
	b.ne	LBB0_29
; %bb.20:
	orr	w2, w10, w11
	b	LBB0_30
LBB0_21:
	bl	_OF_prop_free
LBB0_22:
Lloh45:
	adrp	x21, l_.str.5@PAGE
Lloh46:
	add	x21, x21, l_.str.5@PAGEOFF
LBB0_23:
	mov	x0, x19
	mov	x1, x21
	bl	_device_printf
	ldr	w23, [x20]
	cbz	w23, LBB0_26
; %bb.24:
	sxtw	x8, w23
	lsl	x24, x8, #4
LBB0_25:                                ; =>This Inner Loop Header: Depth=1
	ldr	x8, [x20, #8]
	add	x8, x8, x24
	ldur	x21, [x8, #-8]
	ldursb	w22, [x8, #-16]
	ldursb	w0, [x8, #-15]
	bl	_PIN_OFF_FLAG
	mov	x2, x0
	mov	x0, x21
	mov	x1, x22
	bl	_GPIO_PIN_SET
	sub	x24, x24, #16
	sub	w23, w23, #1
	cbnz	w23, LBB0_25
LBB0_26:
	ldr	x0, [x20, #8]
Lloh47:
	adrp	x8, _M_DEVBUF@GOTPAGE
Lloh48:
	ldr	x8, [x8, _M_DEVBUF@GOTPAGEOFF]
Lloh49:
	ldr	w1, [x8]
	bl	_free
	str	xzr, [x20, #8]
Lloh50:
	adrp	x8, _aml8726_usb_phy_spec@GOTPAGE
Lloh51:
	ldr	x8, [x8, _aml8726_usb_phy_spec@GOTPAGEOFF]
Lloh52:
	ldr	w1, [x8]
	ldr	w2, [x20, #4]
	mov	x0, x19
	bl	_bus_release_resources
LBB0_27:
Lloh53:
	adrp	x8, _ENXIO@GOTPAGE
Lloh54:
	ldr	x8, [x8, _ENXIO@GOTPAGEOFF]
Lloh55:
	ldr	w0, [x8]
LBB0_28:
	ldp	x29, x30, [sp, #96]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #80]             ; 16-byte Folded Reload
	ldp	x22, x21, [sp, #64]             ; 16-byte Folded Reload
	ldp	x24, x23, [sp, #48]             ; 16-byte Folded Reload
	ldp	x26, x25, [sp, #32]             ; 16-byte Folded Reload
	ldp	x28, x27, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #112
	ret
LBB0_29:
Lloh56:
	adrp	x11, _AML_USB_PHY_CFG_CLK_SEL_XTAL@GOTPAGE
Lloh57:
	ldr	x11, [x11, _AML_USB_PHY_CFG_CLK_SEL_XTAL@GOTPAGEOFF]
Lloh58:
	ldr	w11, [x11]
Lloh59:
	adrp	x12, _AML_USB_PHY_CFG_CLK_DIV_SHIFT@GOTPAGE
Lloh60:
	ldr	x12, [x12, _AML_USB_PHY_CFG_CLK_DIV_SHIFT@GOTPAGEOFF]
Lloh61:
	ldr	w12, [x12]
	mov	w13, #1
	lsl	w12, w13, w12
	and	w8, w12, w8
	orr	w9, w10, w9
	orr	w9, w9, w11
	orr	w2, w9, w8
LBB0_30:
	ldr	w1, [x21]
	mov	x0, x20
	bl	_CSR_WRITE_4
	ldr	w1, [x21]
	mov	x0, x20
	bl	_CSR_BARRIER
Lloh62:
	adrp	x22, _AML_USB_PHY_CTRL_REG@GOTPAGE
Lloh63:
	ldr	x22, [x22, _AML_USB_PHY_CTRL_REG@GOTPAGEOFF]
	ldr	w1, [x22]
	mov	x0, x20
	bl	_CSR_READ_4
Lloh64:
	adrp	x8, _AML_USB_PHY_CTRL_FSEL_MASK@GOTPAGE
Lloh65:
	ldr	x8, [x8, _AML_USB_PHY_CTRL_FSEL_MASK@GOTPAGEOFF]
Lloh66:
	ldr	w8, [x8]
	bic	w8, w0, w8
	ldr	w9, [x23]
Lloh67:
	adrp	x10, _AML_USB_PHY_CTRL_FSEL_24M@GOTPAGE
Lloh68:
	ldr	x10, [x10, _AML_USB_PHY_CTRL_FSEL_24M@GOTPAGEOFF]
	and	w9, w9, #0xfffffffe
Lloh69:
	adrp	x11, _AML_USB_PHY_CTRL_FSEL_12M@GOTPAGE
Lloh70:
	ldr	x11, [x11, _AML_USB_PHY_CTRL_FSEL_12M@GOTPAGEOFF]
	cmp	w9, #128
	csel	x9, x10, x11, eq
	ldr	w9, [x9]
	orr	w8, w9, w8
Lloh71:
	adrp	x23, _AML_USB_PHY_CTRL_POR@GOTPAGE
Lloh72:
	ldr	x23, [x23, _AML_USB_PHY_CTRL_POR@GOTPAGEOFF]
	ldr	w9, [x23]
	orr	w21, w8, w9
	ldr	w1, [x22]
	mov	x0, x20
	mov	x2, x21
	bl	_CSR_WRITE_4
	ldr	w1, [x22]
	mov	x0, x20
	bl	_CSR_BARRIER
	mov	w0, #500
	bl	_DELAY
	ldr	w8, [x23]
	bic	w2, w21, w8
	ldr	w1, [x22]
	mov	x0, x20
	bl	_CSR_WRITE_4
	ldr	w1, [x22]
	mov	x0, x20
	bl	_CSR_BARRIER
	mov	w0, #1000
	bl	_DELAY
	ldr	w1, [x22]
	mov	x0, x20
	bl	_CSR_READ_4
Lloh73:
	adrp	x8, _AML_USB_PHY_CTRL_CLK_DETECTED@GOTPAGE
Lloh74:
	ldr	x8, [x8, _AML_USB_PHY_CTRL_CLK_DETECTED@GOTPAGEOFF]
Lloh75:
	ldr	w8, [x8]
	tst	w8, w0
	b.ne	LBB0_32
; %bb.31:
Lloh76:
	adrp	x1, l_.str.7@PAGE
Lloh77:
	add	x1, x1, l_.str.7@PAGEOFF
	mov	x0, x19
	bl	_device_printf
LBB0_32:
	ldr	x8, [x20, #32]
	cbz	x8, LBB0_35
; %bb.33:
Lloh78:
	adrp	x21, _AML_USB_PHY_ADP_BC_REG@GOTPAGE
Lloh79:
	ldr	x21, [x21, _AML_USB_PHY_ADP_BC_REG@GOTPAGEOFF]
	ldr	w1, [x21]
	mov	x0, x20
	bl	_CSR_READ_4
Lloh80:
	adrp	x8, _AML_USB_PHY_ADP_BC_ACA_EN@GOTPAGE
Lloh81:
	ldr	x8, [x8, _AML_USB_PHY_ADP_BC_ACA_EN@GOTPAGEOFF]
Lloh82:
	ldr	w8, [x8]
	orr	w2, w8, w0
	ldr	w1, [x21]
	mov	x0, x20
	bl	_CSR_WRITE_4
	ldr	w1, [x21]
	mov	x0, x20
	bl	_CSR_BARRIER
	mov	w0, #50
	bl	_DELAY
	ldr	w1, [x21]
	mov	x0, x20
	bl	_CSR_READ_4
Lloh83:
	adrp	x8, _AML_USB_PHY_ADP_BC_ACA_FLOATING@GOTPAGE
Lloh84:
	ldr	x8, [x8, _AML_USB_PHY_ADP_BC_ACA_FLOATING@GOTPAGEOFF]
Lloh85:
	ldr	w8, [x8]
	tst	w8, w0
	b.eq	LBB0_35
; %bb.34:
Lloh86:
	adrp	x21, l_.str.8@PAGE
Lloh87:
	add	x21, x21, l_.str.8@PAGEOFF
	b	LBB0_23
LBB0_35:
	ldr	x21, [x20, #24]
	cbz	x21, LBB0_41
; %bb.36:
	ldrsb	w22, [x20, #16]
	ldrsb	w0, [x20, #17]
	bl	_PIN_ON_FLAG
	mov	x2, x0
	mov	x0, x21
	mov	x1, x22
	bl	_GPIO_PIN_SET
	cbnz	x0, LBB0_38
; %bb.37:
	ldr	x0, [x20, #24]
	ldrsb	w1, [x20, #16]
Lloh88:
	adrp	x8, _GPIO_PIN_OUTPUT@GOTPAGE
Lloh89:
	ldr	x8, [x8, _GPIO_PIN_OUTPUT@GOTPAGEOFF]
Lloh90:
	ldr	w2, [x8]
	bl	_GPIO_PIN_SETFLAGS
	cbz	x0, LBB0_42
LBB0_38:
	mov	w23, #0
LBB0_39:
	mov	w0, #30
	bl	_DELAY
	ldr	x21, [x20, #24]
	ldrsb	w22, [x20, #16]
	ldrsb	w0, [x20, #17]
	bl	_PIN_OFF_FLAG
	mov	x2, x0
	mov	x0, x21
	mov	x1, x22
	bl	_GPIO_PIN_SET
	mov	x22, x0
	mov	w0, #60000
	bl	_DELAY
Lloh91:
	adrp	x21, l_.str.9@PAGE
Lloh92:
	add	x21, x21, l_.str.9@PAGEOFF
	cbz	w23, LBB0_23
; %bb.40:
	cbnz	x22, LBB0_23
LBB0_41:
	mov	w0, #0
	b	LBB0_28
LBB0_42:
	mov	w23, #1
	b	LBB0_39
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh3, Lloh4
	.loh AdrpLdrGotLdr	Lloh7, Lloh8, Lloh9
	.loh AdrpAdd	Lloh5, Lloh6
	.loh AdrpAdd	Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh17, Lloh18, Lloh19
	.loh AdrpAdd	Lloh15, Lloh16
	.loh AdrpAdd	Lloh23, Lloh24
	.loh AdrpAdd	Lloh27, Lloh28
	.loh AdrpLdrGot	Lloh25, Lloh26
	.loh AdrpLdrGot	Lloh43, Lloh44
	.loh AdrpLdrGotLdr	Lloh40, Lloh41, Lloh42
	.loh AdrpLdrGotLdr	Lloh37, Lloh38, Lloh39
	.loh AdrpLdrGotLdr	Lloh34, Lloh35, Lloh36
	.loh AdrpLdrGotLdr	Lloh31, Lloh32, Lloh33
	.loh AdrpLdrGot	Lloh29, Lloh30
	.loh AdrpAdd	Lloh45, Lloh46
	.loh AdrpLdrGotLdr	Lloh50, Lloh51, Lloh52
	.loh AdrpLdrGotLdr	Lloh47, Lloh48, Lloh49
	.loh AdrpLdrGotLdr	Lloh53, Lloh54, Lloh55
	.loh AdrpLdrGotLdr	Lloh59, Lloh60, Lloh61
	.loh AdrpLdrGotLdr	Lloh56, Lloh57, Lloh58
	.loh AdrpLdrGotLdr	Lloh73, Lloh74, Lloh75
	.loh AdrpLdrGot	Lloh71, Lloh72
	.loh AdrpLdrGot	Lloh69, Lloh70
	.loh AdrpLdrGot	Lloh67, Lloh68
	.loh AdrpLdrGotLdr	Lloh64, Lloh65, Lloh66
	.loh AdrpLdrGot	Lloh62, Lloh63
	.loh AdrpAdd	Lloh76, Lloh77
	.loh AdrpLdrGotLdr	Lloh83, Lloh84, Lloh85
	.loh AdrpLdrGotLdr	Lloh80, Lloh81, Lloh82
	.loh AdrpLdrGot	Lloh78, Lloh79
	.loh AdrpAdd	Lloh86, Lloh87
	.loh AdrpLdrGotLdr	Lloh88, Lloh89, Lloh90
	.loh AdrpAdd	Lloh91, Lloh92
	.cfi_endproc
                                        ; -- End function
	.comm	_aml8726_usb_phy_spec,4,2       ; @aml8726_usb_phy_spec
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"can not allocate resources for device\n"

	.comm	_ENXIO,4,2                      ; @ENXIO
l_.str.1:                               ; @.str.1
	.asciz	"force-aca"

	.comm	_FALSE,8,3                      ; @FALSE
l_.str.2:                               ; @.str.2
	.asciz	"true"

	.comm	_TRUE,8,3                       ; @TRUE
l_.str.3:                               ; @.str.3
	.asciz	"usb-pwr-en"

	.comm	_M_DEVBUF,4,2                   ; @M_DEVBUF
	.comm	_M_WAITOK,4,2                   ; @M_WAITOK
l_.str.4:                               ; @.str.4
	.asciz	"usb-hub-rst"

l_.str.5:                               ; @.str.5
	.asciz	"unable to parse gpio\n"

	.comm	_GPIO_PIN_OUTPUT,4,2            ; @GPIO_PIN_OUTPUT
l_.str.6:                               ; @.str.6
	.asciz	"could not use gpio to control power\n"

	.comm	_AML_USB_PHY_CFG_REG,4,2        ; @AML_USB_PHY_CFG_REG
	.comm	_AML_USB_PHY_CFG_CLK_SEL_32K_ALT,4,2 ; @AML_USB_PHY_CFG_CLK_SEL_32K_ALT
	.comm	_AML_USB_PHY_CFG_CLK_DIV_MASK,4,2 ; @AML_USB_PHY_CFG_CLK_DIV_MASK
	.comm	_AML_USB_PHY_CFG_CLK_SEL_MASK,4,2 ; @AML_USB_PHY_CFG_CLK_SEL_MASK
	.comm	_AML_USB_PHY_CFG_CLK_EN,4,2     ; @AML_USB_PHY_CFG_CLK_EN
	.comm	_aml8726_soc_hw_rev,4,2         ; @aml8726_soc_hw_rev
	.comm	_AML_USB_PHY_CFG_CLK_SEL_XTAL,4,2 ; @AML_USB_PHY_CFG_CLK_SEL_XTAL
	.comm	_AML_USB_PHY_CFG_CLK_DIV_SHIFT,4,2 ; @AML_USB_PHY_CFG_CLK_DIV_SHIFT
	.comm	_AML_USB_PHY_CTRL_REG,4,2       ; @AML_USB_PHY_CTRL_REG
	.comm	_AML_USB_PHY_CTRL_FSEL_MASK,4,2 ; @AML_USB_PHY_CTRL_FSEL_MASK
	.comm	_AML_USB_PHY_CTRL_FSEL_24M,4,2  ; @AML_USB_PHY_CTRL_FSEL_24M
	.comm	_AML_USB_PHY_CTRL_FSEL_12M,4,2  ; @AML_USB_PHY_CTRL_FSEL_12M
	.comm	_AML_USB_PHY_CTRL_POR,4,2       ; @AML_USB_PHY_CTRL_POR
	.comm	_AML_USB_PHY_CTRL_CLK_DETECTED,4,2 ; @AML_USB_PHY_CTRL_CLK_DETECTED
l_.str.7:                               ; @.str.7
	.asciz	"PHY Clock not detected\n"

	.comm	_AML_USB_PHY_ADP_BC_REG,4,2     ; @AML_USB_PHY_ADP_BC_REG
	.comm	_AML_USB_PHY_ADP_BC_ACA_EN,4,2  ; @AML_USB_PHY_ADP_BC_ACA_EN
	.comm	_AML_USB_PHY_ADP_BC_ACA_FLOATING,4,2 ; @AML_USB_PHY_ADP_BC_ACA_FLOATING
l_.str.8:                               ; @.str.8
	.asciz	"force-aca requires newer silicon\n"

l_.str.9:                               ; @.str.9
	.asciz	"could not use gpio to reset hub\n"

	.no_dead_strip	_aml8726_usb_phy_attach
.subsections_via_symbols
