	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function rtsx_usb_init_chip
_rtsx_usb_init_chip:                    ## @rtsx_usb_init_chip
	.cfi_startproc
## %bb.0:
	pushq	%rbp
	.cfi_def_cfa_offset 16
	.cfi_offset %rbp, -16
	movq	%rsp, %rbp
	.cfi_def_cfa_register %rbp
	pushq	%rbx
	pushq	%rax
	.cfi_offset %rbx, -24
	movq	%rdi, %rbx
	callq	_rtsx_usb_clear_fsm_err
	movq	_FPDCTL@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_SSC_POWER_MASK@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	_SSC_POWER_ON@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	movq	%rbx, %rdi
	callq	_rtsx_usb_write_register
	testl	%eax, %eax
	jne	LBB0_8
## %bb.1:
	movl	$100, %edi
	movl	$1000, %esi                     ## imm = 0x3E8
	callq	_usleep_range
	movq	_CLK_DIV@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_CLK_CHANGE@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	%rbx, %rdi
	xorl	%ecx, %ecx
	callq	_rtsx_usb_write_register
	testl	%eax, %eax
	jne	LBB0_8
## %bb.2:
	movq	_HW_VERSION@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	-12(%rbp), %rdx
	movq	%rbx, %rdi
	callq	_rtsx_usb_read_register
	testl	%eax, %eax
	jne	LBB0_8
## %bb.3:
	movq	_HW_VER_MASK@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	andl	-12(%rbp), %eax
	movl	%eax, (%rbx)
	movq	_CARD_SHARE_MODE@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	-12(%rbp), %rdx
	movq	%rbx, %rdi
	callq	_rtsx_usb_read_register
	testl	%eax, %eax
	jne	LBB0_8
## %bb.4:
	movq	_CARD_SHARE_LQFP_SEL@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	andl	-12(%rbp), %eax
	leaq	L_.str.1(%rip), %rax
	leaq	L_.str(%rip), %rsi
	cmoveq	%rax, %rsi
	movq	_LQFP48@GOTPCREL(%rip), %rax
	cmoveq	_QFN24@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	movl	%eax, 16(%rbx)
	movq	8(%rbx), %rdi
	callq	_dev_dbg
	movq	_CFG_MODE_1@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	leaq	-12(%rbp), %rdx
	movq	%rbx, %rdi
	callq	_rtsx_usb_read_register
	movq	_RTS5179@GOTPCREL(%rip), %rax
	movl	(%rax), %eax
	testl	%eax, -12(%rbp)
	je	LBB0_6
## %bb.5:
	movl	$1, 4(%rbx)
	movq	8(%rbx), %rdi
	leaq	L_.str.2(%rip), %rsi
	callq	_dev_dbg
	jmp	LBB0_7
LBB0_6:
	movl	$0, 4(%rbx)
LBB0_7:
	movq	%rbx, %rdi
	callq	_rtsx_usb_reset_chip
LBB0_8:
	addq	$8, %rsp
	popq	%rbx
	popq	%rbp
	retq
	.cfi_endproc
                                        ## -- End function
	.comm	_FPDCTL,4,2                     ## @FPDCTL
	.comm	_SSC_POWER_MASK,4,2             ## @SSC_POWER_MASK
	.comm	_SSC_POWER_ON,4,2               ## @SSC_POWER_ON
	.comm	_CLK_DIV,4,2                    ## @CLK_DIV
	.comm	_CLK_CHANGE,4,2                 ## @CLK_CHANGE
	.comm	_HW_VERSION,4,2                 ## @HW_VERSION
	.comm	_HW_VER_MASK,4,2                ## @HW_VER_MASK
	.comm	_CARD_SHARE_MODE,4,2            ## @CARD_SHARE_MODE
	.comm	_CARD_SHARE_LQFP_SEL,4,2        ## @CARD_SHARE_LQFP_SEL
	.comm	_LQFP48,4,2                     ## @LQFP48
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"Package: LQFP48\n"

	.comm	_QFN24,4,2                      ## @QFN24
L_.str.1:                               ## @.str.1
	.asciz	"Package: QFN24\n"

	.comm	_CFG_MODE_1,4,2                 ## @CFG_MODE_1
	.comm	_RTS5179,4,2                    ## @RTS5179
L_.str.2:                               ## @.str.2
	.asciz	"Device is rts5179\n"

	.no_dead_strip	_rtsx_usb_init_chip
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function rtsx_usb_init_chip
_rtsx_usb_init_chip:                    ; @rtsx_usb_init_chip
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #48
	.cfi_def_cfa_offset 48
	stp	x20, x19, [sp, #16]             ; 16-byte Folded Spill
	stp	x29, x30, [sp, #32]             ; 16-byte Folded Spill
	add	x29, sp, #32
	.cfi_def_cfa w29, 16
	.cfi_offset w30, -8
	.cfi_offset w29, -16
	.cfi_offset w19, -24
	.cfi_offset w20, -32
	mov	x19, x0
	bl	_rtsx_usb_clear_fsm_err
Lloh0:
	adrp	x8, _FPDCTL@GOTPAGE
Lloh1:
	ldr	x8, [x8, _FPDCTL@GOTPAGEOFF]
Lloh2:
	ldr	w1, [x8]
Lloh3:
	adrp	x8, _SSC_POWER_MASK@GOTPAGE
Lloh4:
	ldr	x8, [x8, _SSC_POWER_MASK@GOTPAGEOFF]
Lloh5:
	ldr	w2, [x8]
Lloh6:
	adrp	x8, _SSC_POWER_ON@GOTPAGE
Lloh7:
	ldr	x8, [x8, _SSC_POWER_ON@GOTPAGEOFF]
Lloh8:
	ldr	w3, [x8]
	mov	x0, x19
	bl	_rtsx_usb_write_register
	cbnz	w0, LBB0_8
; %bb.1:
	mov	w0, #100
	mov	w1, #1000
	bl	_usleep_range
Lloh9:
	adrp	x8, _CLK_DIV@GOTPAGE
Lloh10:
	ldr	x8, [x8, _CLK_DIV@GOTPAGEOFF]
Lloh11:
	ldr	w1, [x8]
Lloh12:
	adrp	x8, _CLK_CHANGE@GOTPAGE
Lloh13:
	ldr	x8, [x8, _CLK_CHANGE@GOTPAGEOFF]
Lloh14:
	ldr	w2, [x8]
	mov	x0, x19
	mov	w3, #0
	bl	_rtsx_usb_write_register
	cbnz	w0, LBB0_8
; %bb.2:
Lloh15:
	adrp	x8, _HW_VERSION@GOTPAGE
Lloh16:
	ldr	x8, [x8, _HW_VERSION@GOTPAGEOFF]
Lloh17:
	ldr	w1, [x8]
	add	x2, sp, #12
	mov	x0, x19
	bl	_rtsx_usb_read_register
	cbnz	w0, LBB0_8
; %bb.3:
	ldr	w8, [sp, #12]
Lloh18:
	adrp	x9, _HW_VER_MASK@GOTPAGE
Lloh19:
	ldr	x9, [x9, _HW_VER_MASK@GOTPAGEOFF]
Lloh20:
	ldr	w9, [x9]
	and	w8, w9, w8
	str	w8, [x19]
Lloh21:
	adrp	x8, _CARD_SHARE_MODE@GOTPAGE
Lloh22:
	ldr	x8, [x8, _CARD_SHARE_MODE@GOTPAGEOFF]
Lloh23:
	ldr	w1, [x8]
	add	x2, sp, #12
	mov	x0, x19
	bl	_rtsx_usb_read_register
	cbnz	w0, LBB0_8
; %bb.4:
	ldr	w8, [sp, #12]
Lloh24:
	adrp	x9, _CARD_SHARE_LQFP_SEL@GOTPAGE
Lloh25:
	ldr	x9, [x9, _CARD_SHARE_LQFP_SEL@GOTPAGEOFF]
Lloh26:
	ldr	w9, [x9]
Lloh27:
	adrp	x10, l_.str@PAGE
Lloh28:
	add	x10, x10, l_.str@PAGEOFF
Lloh29:
	adrp	x11, l_.str.1@PAGE
Lloh30:
	add	x11, x11, l_.str.1@PAGEOFF
	tst	w9, w8
	csel	x1, x11, x10, eq
Lloh31:
	adrp	x8, _QFN24@GOTPAGE
Lloh32:
	ldr	x8, [x8, _QFN24@GOTPAGEOFF]
Lloh33:
	adrp	x9, _LQFP48@GOTPAGE
Lloh34:
	ldr	x9, [x9, _LQFP48@GOTPAGEOFF]
	csel	x8, x8, x9, eq
	ldr	w8, [x8]
	str	w8, [x19, #16]
	ldr	x0, [x19, #8]
	bl	_dev_dbg
Lloh35:
	adrp	x8, _CFG_MODE_1@GOTPAGE
Lloh36:
	ldr	x8, [x8, _CFG_MODE_1@GOTPAGEOFF]
Lloh37:
	ldr	w1, [x8]
	add	x2, sp, #12
	mov	x0, x19
	bl	_rtsx_usb_read_register
	ldr	w8, [sp, #12]
Lloh38:
	adrp	x9, _RTS5179@GOTPAGE
Lloh39:
	ldr	x9, [x9, _RTS5179@GOTPAGEOFF]
Lloh40:
	ldr	w9, [x9]
	tst	w9, w8
	b.eq	LBB0_6
; %bb.5:
	mov	w8, #1
	str	w8, [x19, #4]
	ldr	x0, [x19, #8]
Lloh41:
	adrp	x1, l_.str.2@PAGE
Lloh42:
	add	x1, x1, l_.str.2@PAGEOFF
	bl	_dev_dbg
	b	LBB0_7
LBB0_6:
	str	wzr, [x19, #4]
LBB0_7:
	mov	x0, x19
	bl	_rtsx_usb_reset_chip
LBB0_8:
	ldp	x29, x30, [sp, #32]             ; 16-byte Folded Reload
	ldp	x20, x19, [sp, #16]             ; 16-byte Folded Reload
	add	sp, sp, #48
	ret
	.loh AdrpLdrGotLdr	Lloh6, Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh3, Lloh4, Lloh5
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpLdrGotLdr	Lloh21, Lloh22, Lloh23
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh38, Lloh39, Lloh40
	.loh AdrpLdrGotLdr	Lloh35, Lloh36, Lloh37
	.loh AdrpLdrGot	Lloh33, Lloh34
	.loh AdrpLdrGot	Lloh31, Lloh32
	.loh AdrpAdd	Lloh29, Lloh30
	.loh AdrpAdd	Lloh27, Lloh28
	.loh AdrpLdrGotLdr	Lloh24, Lloh25, Lloh26
	.loh AdrpAdd	Lloh41, Lloh42
	.cfi_endproc
                                        ; -- End function
	.comm	_FPDCTL,4,2                     ; @FPDCTL
	.comm	_SSC_POWER_MASK,4,2             ; @SSC_POWER_MASK
	.comm	_SSC_POWER_ON,4,2               ; @SSC_POWER_ON
	.comm	_CLK_DIV,4,2                    ; @CLK_DIV
	.comm	_CLK_CHANGE,4,2                 ; @CLK_CHANGE
	.comm	_HW_VERSION,4,2                 ; @HW_VERSION
	.comm	_HW_VER_MASK,4,2                ; @HW_VER_MASK
	.comm	_CARD_SHARE_MODE,4,2            ; @CARD_SHARE_MODE
	.comm	_CARD_SHARE_LQFP_SEL,4,2        ; @CARD_SHARE_LQFP_SEL
	.comm	_LQFP48,4,2                     ; @LQFP48
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"Package: LQFP48\n"

	.comm	_QFN24,4,2                      ; @QFN24
l_.str.1:                               ; @.str.1
	.asciz	"Package: QFN24\n"

	.comm	_CFG_MODE_1,4,2                 ; @CFG_MODE_1
	.comm	_RTS5179,4,2                    ; @RTS5179
l_.str.2:                               ; @.str.2
	.asciz	"Device is rts5179\n"

	.no_dead_strip	_rtsx_usb_init_chip
.subsections_via_symbols
