	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	4, 0x90                         ## -- Begin function iceland_smu_upload_firmware_image
_iceland_smu_upload_firmware_image:     ## @iceland_smu_upload_firmware_image
	.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	$24, %rsp
	.cfi_offset %rbx, -56
	.cfi_offset %r12, -48
	.cfi_offset %r13, -40
	.cfi_offset %r14, -32
	.cfi_offset %r15, -24
	xorps	%xmm0, %xmm0
	movaps	%xmm0, -64(%rbp)
	movq	$0, -48(%rbp)
	testq	%rdi, %rdi
	je	LBB0_7
## %bb.1:
	movq	%rdi, %r14
	movq	(%rdi), %rbx
	testq	%rbx, %rbx
	je	LBB0_7
## %bb.2:
	movq	_UCODE_ID_SMU@GOTPCREL(%rip), %rax
	movl	(%rax), %edi
	callq	_smu7_convert_fw_type_to_cgs
	leaq	-64(%rbp), %rdx
	movq	%rbx, %rdi
	movl	%eax, %esi
	callq	_cgs_get_firmware_info
	movl	-64(%rbp), %eax
	testb	$3, %al
	je	LBB0_4
## %bb.3:
	leaq	L_.str(%rip), %rdi
	jmp	LBB0_6
LBB0_4:
	movq	_ICELAND_SMC_SIZE@GOTPCREL(%rip), %r15
	cmpl	(%r15), %eax
	jle	LBB0_9
## %bb.5:
	leaq	L_.str.1(%rip), %rdi
LBB0_6:
	callq	_pr_err
LBB0_7:
	movq	_EINVAL@GOTPCREL(%rip), %rax
	xorl	%ebx, %ebx
	subl	(%rax), %ebx
LBB0_8:
	movl	%ebx, %eax
	addq	$24, %rsp
	popq	%rbx
	popq	%r12
	popq	%r13
	popq	%r14
	popq	%r15
	popq	%rbp
	retq
LBB0_9:
	movl	-48(%rbp), %eax
	movl	%eax, 8(%r14)
	movq	_SMC_IND@GOTPCREL(%rip), %rax
	movl	(%rax), %esi
	movq	_RCU_UC_EVENTS@GOTPCREL(%rip), %rax
	movl	(%rax), %edx
	movq	_boot_seq_done@GOTPCREL(%rip), %rax
	movl	(%rax), %ecx
	xorl	%ebx, %ebx
	movq	%r14, %rdi
	xorl	%r8d, %r8d
	callq	_PHM_WAIT_INDIRECT_FIELD_UNEQUAL
	movq	(%r14), %rdi
	movq	_CGS_IND_REG__SMC@GOTPCREL(%rip), %r12
	movl	(%r12), %esi
	movq	_ixSMC_SYSCON_MISC_CNTL@GOTPCREL(%rip), %r13
	movl	(%r13), %edx
	callq	_cgs_read_ind_register
	movq	(%r14), %rdi
	movl	(%r12), %esi
	movl	(%r13), %edx
	orl	$1, %eax
	movl	%eax, %ecx
	callq	_cgs_write_ind_register
	movq	%r14, %rdi
	callq	_iceland_stop_smc_clock
	movq	%r14, %rdi
	callq	_iceland_reset_smc
	movq	-56(%rbp), %rdx
	movl	(%r15), %ecx
	movl	-64(%rbp), %esi
	movl	-60(%rbp), %r8d
	movq	%r14, %rdi
	callq	_iceland_upload_smc_firmware_data
	jmp	LBB0_8
	.cfi_endproc
                                        ## -- End function
	.comm	_EINVAL,4,2                     ## @EINVAL
	.comm	_UCODE_ID_SMU,4,2               ## @UCODE_ID_SMU
	.section	__TEXT,__cstring,cstring_literals
L_.str:                                 ## @.str
	.asciz	"[ powerplay ] SMC ucode is not 4 bytes aligned\n"

	.comm	_ICELAND_SMC_SIZE,4,2           ## @ICELAND_SMC_SIZE
L_.str.1:                               ## @.str.1
	.asciz	"[ powerplay ] SMC address is beyond the SMC RAM area\n"

	.comm	_SMC_IND,4,2                    ## @SMC_IND
	.comm	_RCU_UC_EVENTS,4,2              ## @RCU_UC_EVENTS
	.comm	_boot_seq_done,4,2              ## @boot_seq_done
	.comm	_CGS_IND_REG__SMC,4,2           ## @CGS_IND_REG__SMC
	.comm	_ixSMC_SYSCON_MISC_CNTL,4,2     ## @ixSMC_SYSCON_MISC_CNTL
	.no_dead_strip	_iceland_smu_upload_firmware_image
.subsections_via_symbols

	.section	__TEXT,__text,regular,pure_instructions
	.build_version macos, 13, 0	sdk_version 13, 3
	.p2align	2                               ; -- Begin function iceland_smu_upload_firmware_image
_iceland_smu_upload_firmware_image:     ; @iceland_smu_upload_firmware_image
	.cfi_startproc
; %bb.0:
	sub	sp, sp, #80
	.cfi_def_cfa_offset 80
	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
	stp	xzr, xzr, [sp, #8]
	str	xzr, [sp, #24]
	cbz	x0, LBB0_7
; %bb.1:
	mov	x19, x0
	ldr	x20, [x0]
	cbz	x20, LBB0_7
; %bb.2:
Lloh0:
	adrp	x8, _UCODE_ID_SMU@GOTPAGE
Lloh1:
	ldr	x8, [x8, _UCODE_ID_SMU@GOTPAGEOFF]
Lloh2:
	ldr	w0, [x8]
	bl	_smu7_convert_fw_type_to_cgs
	mov	x1, x0
	add	x2, sp, #8
	mov	x0, x20
	bl	_cgs_get_firmware_info
	ldr	w8, [sp, #8]
	tst	w8, #0x3
	b.eq	LBB0_4
; %bb.3:
Lloh3:
	adrp	x0, l_.str@PAGE
Lloh4:
	add	x0, x0, l_.str@PAGEOFF
	b	LBB0_6
LBB0_4:
Lloh5:
	adrp	x20, _ICELAND_SMC_SIZE@GOTPAGE
Lloh6:
	ldr	x20, [x20, _ICELAND_SMC_SIZE@GOTPAGEOFF]
	ldr	w9, [x20]
	cmp	w8, w9
	b.le	LBB0_9
; %bb.5:
Lloh7:
	adrp	x0, l_.str.1@PAGE
Lloh8:
	add	x0, x0, l_.str.1@PAGEOFF
LBB0_6:
	bl	_pr_err
LBB0_7:
Lloh9:
	adrp	x8, _EINVAL@GOTPAGE
Lloh10:
	ldr	x8, [x8, _EINVAL@GOTPAGEOFF]
Lloh11:
	ldr	w8, [x8]
	neg	w0, w8
LBB0_8:
	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
	add	sp, sp, #80
	ret
LBB0_9:
	ldr	w8, [sp, #24]
	str	w8, [x19, #8]
Lloh12:
	adrp	x8, _SMC_IND@GOTPAGE
Lloh13:
	ldr	x8, [x8, _SMC_IND@GOTPAGEOFF]
Lloh14:
	ldr	w1, [x8]
Lloh15:
	adrp	x8, _RCU_UC_EVENTS@GOTPAGE
Lloh16:
	ldr	x8, [x8, _RCU_UC_EVENTS@GOTPAGEOFF]
Lloh17:
	ldr	w2, [x8]
Lloh18:
	adrp	x8, _boot_seq_done@GOTPAGE
Lloh19:
	ldr	x8, [x8, _boot_seq_done@GOTPAGEOFF]
Lloh20:
	ldr	w3, [x8]
	mov	x0, x19
	mov	w4, #0
	bl	_PHM_WAIT_INDIRECT_FIELD_UNEQUAL
	ldr	x0, [x19]
Lloh21:
	adrp	x21, _CGS_IND_REG__SMC@GOTPAGE
Lloh22:
	ldr	x21, [x21, _CGS_IND_REG__SMC@GOTPAGEOFF]
	ldr	w1, [x21]
Lloh23:
	adrp	x22, _ixSMC_SYSCON_MISC_CNTL@GOTPAGE
Lloh24:
	ldr	x22, [x22, _ixSMC_SYSCON_MISC_CNTL@GOTPAGEOFF]
	ldr	w2, [x22]
	bl	_cgs_read_ind_register
	ldr	x8, [x19]
	ldr	w1, [x21]
	ldr	w2, [x22]
	orr	w3, w0, #0x1
	mov	x0, x8
	bl	_cgs_write_ind_register
	mov	x0, x19
	bl	_iceland_stop_smc_clock
	mov	x0, x19
	bl	_iceland_reset_smc
	ldr	x2, [sp, #16]
	ldr	w3, [x20]
	ldp	w1, w4, [sp, #8]
	mov	x0, x19
	bl	_iceland_upload_smc_firmware_data
	mov	w0, #0
	b	LBB0_8
	.loh AdrpLdrGotLdr	Lloh0, Lloh1, Lloh2
	.loh AdrpAdd	Lloh3, Lloh4
	.loh AdrpLdrGot	Lloh5, Lloh6
	.loh AdrpAdd	Lloh7, Lloh8
	.loh AdrpLdrGotLdr	Lloh9, Lloh10, Lloh11
	.loh AdrpLdrGot	Lloh23, Lloh24
	.loh AdrpLdrGot	Lloh21, Lloh22
	.loh AdrpLdrGotLdr	Lloh18, Lloh19, Lloh20
	.loh AdrpLdrGotLdr	Lloh15, Lloh16, Lloh17
	.loh AdrpLdrGotLdr	Lloh12, Lloh13, Lloh14
	.cfi_endproc
                                        ; -- End function
	.comm	_EINVAL,4,2                     ; @EINVAL
	.comm	_UCODE_ID_SMU,4,2               ; @UCODE_ID_SMU
	.section	__TEXT,__cstring,cstring_literals
l_.str:                                 ; @.str
	.asciz	"[ powerplay ] SMC ucode is not 4 bytes aligned\n"

	.comm	_ICELAND_SMC_SIZE,4,2           ; @ICELAND_SMC_SIZE
l_.str.1:                               ; @.str.1
	.asciz	"[ powerplay ] SMC address is beyond the SMC RAM area\n"

	.comm	_SMC_IND,4,2                    ; @SMC_IND
	.comm	_RCU_UC_EVENTS,4,2              ; @RCU_UC_EVENTS
	.comm	_boot_seq_done,4,2              ; @boot_seq_done
	.comm	_CGS_IND_REG__SMC,4,2           ; @CGS_IND_REG__SMC
	.comm	_ixSMC_SYSCON_MISC_CNTL,4,2     ; @ixSMC_SYSCON_MISC_CNTL
	.no_dead_strip	_iceland_smu_upload_firmware_image
.subsections_via_symbols
