	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function sm501_init_dev
_sm501_init_dev:                        ## @sm501_init_dev
	.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	%rbx
	pushq	%rax
	.cfi_offset %rbx, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	movq	%rdi, %rbx
	addq	$48, %rdi
	callq	_mutex_init
	leaq	44(%rbx), %rdi
	callq	_spin_lock_init
	leaq	40(%rbx), %rdi
	callq	_INIT_LIST_HEAD
	movq	_SM501_DEVICEID@GOTPCREL(%rip), %rax
	movq	(%rax), %rdi
	addq	32(%rbx), %rdi
	callq	_smc501_readl
	movq	%rax, %r14
	movq	_SM501_DEVICEID_IDMASK@GOTPCREL(%rip), %rax
	movq	%r14, %rcx
	andq	(%rax), %rcx
	movq	_SM501_DEVICEID_SM501@GOTPCREL(%rip), %rax
	cmpq	(%rax), %rcx
	jne	LBB0_1
## %bb.2:
	movq	_SM501_IRQ_MASK@GOTPCREL(%rip), %rax
	movq	(%rax), %rsi
	addq	32(%rbx), %rsi
	xorl	%edi, %edi
	callq	_smc501_writel
	movq	_SM501_DRAM_CONTROL@GOTPCREL(%rip), %rax
	movq	(%rax), %rdi
	addq	32(%rbx), %rdi
	callq	_smc501_readl
	movq	_sm501_mem_local@GOTPCREL(%rip), %rcx
	movq	(%rcx), %rcx
	shrq	$10, %rax
	andl	$56, %eax
	movq	(%rcx,%rax), %r8
	movq	%r8, -32(%rbp)
	movq	32(%rbx), %rdx
	shrq	$20, %r8
	movl	8(%rbx), %edi
	movl	24(%rbx), %r9d
	leaq	L_.str.1(%rip), %rsi
	movq	%r14, %rcx
	callq	_dev_info
	movq	_SM501_DEVICEID_REVMASK@GOTPCREL(%rip), %rax
	movq	(%rax), %rax
	andq	%r14, %rax
	movq	%rax, (%rbx)
	movq	%rbx, %rdi
	callq	_sm501_dump_gate
	movl	8(%rbx), %edi
	movq	_dev_attr_dbg_regs@GOTPCREL(%rip), %rsi
	callq	_device_create_file
	testl	%eax, %eax
	je	LBB0_4
## %bb.3:
	movl	8(%rbx), %edi
	leaq	L_.str.2(%rip), %rsi
	xorl	%eax, %eax
	callq	_dev_err
LBB0_4:
	movq	%rbx, %rdi
	callq	_sm501_dump_clk
	movq	16(%rbx), %r14
	testq	%r14, %r14
	je	LBB0_17
## %bb.5:
	movq	16(%r14), %r15
	testq	%r15, %r15
	je	LBB0_12
## %bb.6:
	movq	%rbx, %rdi
	movq	%r15, %rsi
	callq	_sm501_init_regs
	movl	(%r15), %esi
	movq	_SM501_USE_USB_HOST@GOTPCREL(%rip), %rax
	testl	%esi, (%rax)
	je	LBB0_8
## %bb.7:
	leaq	-32(%rbp), %rsi
	movq	%rbx, %rdi
	callq	_sm501_register_usbhost
	movl	(%r15), %esi
LBB0_8:
	movq	_SM501_USE_UART0@GOTPCREL(%rip), %rax
	movq	_SM501_USE_UART1@GOTPCREL(%rip), %rcx
	movl	(%rcx), %ecx
	orl	(%rax), %ecx
	testl	%esi, %ecx
	je	LBB0_10
## %bb.9:
	movq	%rbx, %rdi
	callq	_sm501_register_uart
	movl	(%r15), %esi
LBB0_10:
	movq	_SM501_USE_GPIO@GOTPCREL(%rip), %rax
	testl	%esi, (%rax)
	je	LBB0_12
## %bb.11:
	movq	%rbx, %rdi
	callq	_sm501_register_gpio
LBB0_12:
	cmpq	$0, 8(%r14)
	je	LBB0_17
## %bb.13:
	cmpq	$0, (%r14)
	jle	LBB0_17
## %bb.14:
	movq	%rbx, %rdi
	callq	_sm501_gpio_isregistered
	testl	%eax, %eax
	je	LBB0_15
## %bb.16:
	movq	%rbx, %rdi
	movq	%r14, %rsi
	callq	_sm501_register_gpio_i2c
	jmp	LBB0_17
LBB0_1:
	movl	8(%rbx), %edi
	leaq	L_.str(%rip), %rsi
	xorl	%ebx, %ebx
	movq	%r14, %rdx
	xorl	%eax, %eax
	callq	_dev_err
	jmp	LBB0_19
LBB0_15:
	movl	8(%rbx), %edi
	leaq	L_.str.3(%rip), %rsi
	xorl	%eax, %eax
	callq	_dev_err
LBB0_17:
	movq	%rbx, %rdi
	callq	_sm501_check_clocks
	testl	%eax, %eax
	je	LBB0_20
## %bb.18:
	movl	8(%rbx), %edi
	leaq	L_.str.4(%rip), %rsi
	xorl	%ebx, %ebx
	xorl	%eax, %eax
	callq	_dev_err
LBB0_19:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	subl	(%rax), %ebx
LBB0_21:
	movl	%ebx, %eax
	addq	$8, %rsp
	popq	%rbx
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_20:
	leaq	-32(%rbp), %rsi
	movq	%rbx, %rdi
	callq	_sm501_register_display
	xorl	%ebx, %ebx
	jmp	LBB0_21
	.cfi_endproc
                                        ## -- End function
	.comm	_SM501_DEVICEID,8,3             ## @SM501_DEVICEID
	.comm	_SM501_DEVICEID_IDMASK,8,3      ## @SM501_DEVICEID_IDMASK
	.comm	_SM501_DEVICEID_SM501,8,3       ## @SM501_DEVICEID_SM501
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"incorrect device id %08lx\n"

	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_SM501_IRQ_MASK,8,3             ## @SM501_IRQ_MASK
	.comm	_SM501_DRAM_CONTROL,8,3         ## @SM501_DRAM_CONTROL
	.comm	_sm501_mem_local,8,3            ## @sm501_mem_local
L_.str.1:                               ## @.str.1
	.asciz	"SM501 At %p: Version %08lx, %ld Mb, IRQ %d\n"

	.comm	_SM501_DEVICEID_REVMASK,8,3     ## @SM501_DEVICEID_REVMASK
	.comm	_dev_attr_dbg_regs,4,2          ## @dev_attr_dbg_regs
L_.str.2:                               ## @.str.2
	.asciz	"failed to create debug regs file\n"

	.comm	_SM501_USE_USB_HOST,4,2         ## @SM501_USE_USB_HOST
	.comm	_SM501_USE_UART0,4,2            ## @SM501_USE_UART0
	.comm	_SM501_USE_UART1,4,2            ## @SM501_USE_UART1
	.comm	_SM501_USE_GPIO,4,2             ## @SM501_USE_GPIO
L_.str.3:                               ## @.str.3
	.asciz	"no gpio available for i2c gpio.\n"

L_.str.4:                               ## @.str.4
	.asciz	"M1X and M clocks sourced from different PLLs\n"

	.no_dead_strip	_sm501_init_dev
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function sm501_init_dev
_sm501_init_dev:                        ; @sm501_init_dev
	.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	x19, x0
	add	x0, x0, #48
	bl	_mutex_init
	add	x0, x19, #44
	bl	_spin_lock_init
	add	x0, x19, #40
	bl	_INIT_LIST_HEAD
	ldr	x8, [x19, #32]
Lloh0:
	adrp	x9, _SM501_DEVICEID@GOTPAGE
Lloh1:
	ldr	x9, [x9, _SM501_DEVICEID@GOTPAGEOFF]
Lloh2:
	ldr	x9, [x9]
	add	x0, x9, x8
	bl	_smc501_readl
	mov	x20, x0
Lloh3:
	adrp	x8, _SM501_DEVICEID_IDMASK@GOTPAGE
Lloh4:
	ldr	x8, [x8, _SM501_DEVICEID_IDMASK@GOTPAGEOFF]
Lloh5:
	ldr	x8, [x8]
	and	x8, x8, x0
Lloh6:
	adrp	x9, _SM501_DEVICEID_SM501@GOTPAGE
Lloh7:
	ldr	x9, [x9, _SM501_DEVICEID_SM501@GOTPAGEOFF]
Lloh8:
	ldr	x9, [x9]
	cmp	x8, x9
	b.ne	LBB0_15
; %bb.1:
	ldr	x8, [x19, #32]
Lloh9:
	adrp	x9, _SM501_IRQ_MASK@GOTPAGE
Lloh10:
	ldr	x9, [x9, _SM501_IRQ_MASK@GOTPAGEOFF]
Lloh11:
	ldr	x9, [x9]
	add	x1, x9, x8
	mov	w0, #0
	bl	_smc501_writel
	ldr	x8, [x19, #32]
Lloh12:
	adrp	x9, _SM501_DRAM_CONTROL@GOTPAGE
Lloh13:
	ldr	x9, [x9, _SM501_DRAM_CONTROL@GOTPAGEOFF]
Lloh14:
	ldr	x9, [x9]
	add	x0, x9, x8
	bl	_smc501_readl
Lloh15:
	adrp	x8, _sm501_mem_local@GOTPAGE
Lloh16:
	ldr	x8, [x8, _sm501_mem_local@GOTPAGEOFF]
Lloh17:
	ldr	x8, [x8]
	ubfx	x9, x0, #13, #3
	ldr	x8, [x8, x9, lsl #3]
	str	x8, [sp, #8]
	ldr	w0, [x19, #8]
	ldr	x2, [x19, #32]
	lsr	x4, x8, #20
	ldr	w5, [x19, #24]
Lloh18:
	adrp	x1, l_.str.1@PAGE
Lloh19:
	add	x1, x1, l_.str.1@PAGEOFF
	mov	x3, x20
	bl	_dev_info
Lloh20:
	adrp	x8, _SM501_DEVICEID_REVMASK@GOTPAGE
Lloh21:
	ldr	x8, [x8, _SM501_DEVICEID_REVMASK@GOTPAGEOFF]
Lloh22:
	ldr	x8, [x8]
	and	x8, x8, x20
	str	x8, [x19]
	mov	x0, x19
	bl	_sm501_dump_gate
	ldr	w0, [x19, #8]
Lloh23:
	adrp	x1, _dev_attr_dbg_regs@GOTPAGE
Lloh24:
	ldr	x1, [x1, _dev_attr_dbg_regs@GOTPAGEOFF]
	bl	_device_create_file
	cbz	w0, LBB0_3
; %bb.2:
	ldr	w0, [x19, #8]
Lloh25:
	adrp	x1, l_.str.2@PAGE
Lloh26:
	add	x1, x1, l_.str.2@PAGEOFF
	bl	_dev_err
LBB0_3:
	mov	x0, x19
	bl	_sm501_dump_clk
	ldr	x20, [x19, #16]
	cbz	x20, LBB0_17
; %bb.4:
	ldr	x21, [x20, #16]
	cbz	x21, LBB0_11
; %bb.5:
	mov	x0, x19
	mov	x1, x21
	bl	_sm501_init_regs
	ldr	w1, [x21]
Lloh27:
	adrp	x8, _SM501_USE_USB_HOST@GOTPAGE
Lloh28:
	ldr	x8, [x8, _SM501_USE_USB_HOST@GOTPAGEOFF]
Lloh29:
	ldr	w8, [x8]
	tst	w8, w1
	b.eq	LBB0_7
; %bb.6:
	add	x1, sp, #8
	mov	x0, x19
	bl	_sm501_register_usbhost
	ldr	w1, [x21]
LBB0_7:
Lloh30:
	adrp	x8, _SM501_USE_UART0@GOTPAGE
Lloh31:
	ldr	x8, [x8, _SM501_USE_UART0@GOTPAGEOFF]
Lloh32:
	ldr	w8, [x8]
Lloh33:
	adrp	x9, _SM501_USE_UART1@GOTPAGE
Lloh34:
	ldr	x9, [x9, _SM501_USE_UART1@GOTPAGEOFF]
Lloh35:
	ldr	w9, [x9]
	orr	w8, w9, w8
	tst	w8, w1
	b.eq	LBB0_9
; %bb.8:
	mov	x0, x19
	bl	_sm501_register_uart
	ldr	w1, [x21]
LBB0_9:
Lloh36:
	adrp	x8, _SM501_USE_GPIO@GOTPAGE
Lloh37:
	ldr	x8, [x8, _SM501_USE_GPIO@GOTPAGEOFF]
Lloh38:
	ldr	w8, [x8]
	tst	w8, w1
	b.eq	LBB0_11
; %bb.10:
	mov	x0, x19
	bl	_sm501_register_gpio
LBB0_11:
	ldr	x8, [x20, #8]
	cbz	x8, LBB0_17
; %bb.12:
	ldr	x8, [x20]
	cmp	x8, #1
	b.lt	LBB0_17
; %bb.13:
	mov	x0, x19
	bl	_sm501_gpio_isregistered
	cbz	w0, LBB0_16
; %bb.14:
	mov	x0, x19
	mov	x1, x20
	bl	_sm501_register_gpio_i2c
	b	LBB0_17
LBB0_15:
	ldr	w0, [x19, #8]
	str	x20, [sp]
Lloh39:
	adrp	x1, l_.str@PAGE
Lloh40:
	add	x1, x1, l_.str@PAGEOFF
	b	LBB0_19
LBB0_16:
	ldr	w0, [x19, #8]
Lloh41:
	adrp	x1, l_.str.3@PAGE
Lloh42:
	add	x1, x1, l_.str.3@PAGEOFF
	bl	_dev_err
LBB0_17:
	mov	x0, x19
	bl	_sm501_check_clocks
	cbz	w0, LBB0_21
; %bb.18:
	ldr	w0, [x19, #8]
Lloh43:
	adrp	x1, l_.str.4@PAGE
Lloh44:
	add	x1, x1, l_.str.4@PAGEOFF
LBB0_19:
	bl	_dev_err
Lloh45:
	adrp	x8, _EINVAL@GOTPAGE
Lloh46:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh47:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_20:
	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_21:
	add	x1, sp, #8
	mov	x0, x19
	bl	_sm501_register_display
	mov	w0, #0
	b	LBB0_20
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGot	Lloh23, Lloh24
	.loh AdrpLdrGotLdr	Lloh20, Lloh21, Lloh22
	.loh AdrpAdd	Lloh18, Lloh19
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpAdd	Lloh25, Lloh26
	.loh AdrpLdrGotLdr	Lloh27, Lloh28, Lloh29
	.loh AdrpLdrGotLdr	Lloh33, Lloh34, Lloh35
	.loh AdrpLdrGotLdr	Lloh30, Lloh31, Lloh32
	.loh AdrpLdrGotLdr	Lloh36, Lloh37, Lloh38
	.loh AdrpAdd	Lloh39, Lloh40
	.loh AdrpAdd	Lloh41, Lloh42
	.loh AdrpAdd	Lloh43, Lloh44
	.loh AdrpLdrGotLdr	Lloh45, Lloh46, Lloh47
	.cfi_endproc
                                        ; -- End function
	.comm	_SM501_DEVICEID,8,3             ; @SM501_DEVICEID
	.comm	_SM501_DEVICEID_IDMASK,8,3      ; @SM501_DEVICEID_IDMASK
	.comm	_SM501_DEVICEID_SM501,8,3       ; @SM501_DEVICEID_SM501
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"incorrect device id %08lx\n"

	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_SM501_IRQ_MASK,8,3             ; @SM501_IRQ_MASK
	.comm	_SM501_DRAM_CONTROL,8,3         ; @SM501_DRAM_CONTROL
	.comm	_sm501_mem_local,8,3            ; @sm501_mem_local
l_.str.1:                               ; @.str.1
	.asciz	"SM501 At %p: Version %08lx, %ld Mb, IRQ %d\n"

	.comm	_SM501_DEVICEID_REVMASK,8,3     ; @SM501_DEVICEID_REVMASK
	.comm	_dev_attr_dbg_regs,4,2          ; @dev_attr_dbg_regs
l_.str.2:                               ; @.str.2
	.asciz	"failed to create debug regs file\n"

	.comm	_SM501_USE_USB_HOST,4,2         ; @SM501_USE_USB_HOST
	.comm	_SM501_USE_UART0,4,2            ; @SM501_USE_UART0
	.comm	_SM501_USE_UART1,4,2            ; @SM501_USE_UART1
	.comm	_SM501_USE_GPIO,4,2             ; @SM501_USE_GPIO
l_.str.3:                               ; @.str.3
	.asciz	"no gpio available for i2c gpio.\n"

l_.str.4:                               ; @.str.4
	.asciz	"M1X and M clocks sourced from different PLLs\n"

	.no_dead_strip	_sm501_init_dev
.subsections_via_symbols
