	.file	"extr_cypress_dpm.c_cypress_convert_power_level_to_smc.c"
	.intel_syntax noprefix
	.text
	.p2align 4
	.globl	cypress_convert_power_level_to_smc
	.type	cypress_convert_power_level_to_smc, @function
cypress_convert_power_level_to_smc:
.LFB0:
	.cfi_startproc
	endbr64
	push	r15
	.cfi_def_cfa_offset 16
	.cfi_offset 15, -16
	mov	r15d, ecx
	push	r14
	.cfi_def_cfa_offset 24
	.cfi_offset 14, -24
	mov	r14, rsi
	push	r13
	.cfi_def_cfa_offset 32
	.cfi_offset 13, -32
	push	r12
	.cfi_def_cfa_offset 40
	.cfi_offset 12, -40
	push	rbp
	.cfi_def_cfa_offset 48
	.cfi_offset 6, -48
	mov	rbp, rdi
	push	rbx
	.cfi_def_cfa_offset 56
	.cfi_offset 3, -56
	mov	rbx, rdx
	sub	rsp, 8
	.cfi_def_cfa_offset 64
	call	rv770_get_pi@PLT
	mov	rdi, rbp
	mov	r13, rax
	call	evergreen_get_pi@PLT
	cmp	QWORD PTR 24[r13], 0
	mov	r12, rax
	mov	eax, DWORD PTR [r14]
	jne	.L2
	mov	ecx, DWORD PTR ATOM_PPLIB_R600_FLAGS_PCIEGEN2[rip]
	and	ecx, eax
.L3:
	xor	edx, edx
.L4:
	mov	DWORD PTR [rbx], edx
	xor	edx, edx
	test	ecx, ecx
	mov	esi, DWORD PTR 24[r14]
	setne	dl
	test	DWORD PTR ATOM_PPLIB_R600_FLAGS_BACKBIASENABLE[rip], eax
	mov	DWORD PTR 44[rbx], r15d
	mov	rdi, rbp
	setne	al
	mov	DWORD PTR 4[rbx], edx
	lea	rdx, 40[rbx]
	movzx	eax, al
	mov	DWORD PTR 8[rbx], eax
	call	rv740_populate_sclk_value@PLT
	test	eax, eax
	jne	.L1
	mov	rax, QWORD PTR 0[r13]
	mov	rsi, QWORD PTR 8[r14]
	mov	DWORD PTR 32[rbx], 0
	test	rax, rax
	je	.L6
	cmp	rax, rsi
	jl	.L6
	mov	eax, DWORD PTR 40[r12]
	test	eax, eax
	jne	.L6
	mov	eax, DWORD PTR SMC_MC_STUTTER_EN[rip]
	cmp	QWORD PTR 32[r12], 0
	mov	edx, DWORD PTR 36[rbx]
	mov	DWORD PTR 32[rbx], eax
	mov	eax, DWORD PTR PPSMC_STATEFLAG_AUTO_PULSE_SKIP[rip]
	je	.L7
	or	eax, edx
	mov	DWORD PTR 36[rbx], eax
	.p2align 4,,10
	.p2align 3
.L6:
	cmp	QWORD PTR 16[r13], 0
	lea	r15, 28[rbx]
	je	.L8
	cmp	QWORD PTR 8[r13], rsi
	jge	.L9
	mov	eax, DWORD PTR SMC_MC_EDC_RD_FLAG[rip]
	or	DWORD PTR 32[rbx], eax
.L9:
	cmp	QWORD PTR [r12], rsi
	jge	.L10
	mov	eax, DWORD PTR SMC_MC_EDC_WR_FLAG[rip]
	or	DWORD PTR 32[rbx], eax
.L10:
	mov	rdi, rbp
	call	cypress_get_strobe_mode_settings@PLT
	mov	DWORD PTR 12[rbx], eax
	and	eax, DWORD PTR SMC_STROBE_ENABLE[rip]
	jne	.L27
	mov	r9d, DWORD PTR 8[r12]
.L13:
	test	eax, eax
	mov	rdx, QWORD PTR 8[r14]
	mov	esi, DWORD PTR 24[r14]
	mov	rcx, r15
	setne	r8b
	mov	rdi, rbp
	movzx	r8d, r8b
	call	cypress_populate_mclk_value@PLT
.L14:
	test	eax, eax
	jne	.L1
	mov	edx, DWORD PTR 20[r14]
	lea	rcx, 24[rbx]
	lea	rsi, 24[r12]
	mov	rdi, rbp
	call	cypress_populate_voltage_value@PLT
	test	eax, eax
	jne	.L1
	cmp	QWORD PTR 16[r12], 0
	je	.L16
	mov	edx, DWORD PTR 16[r14]
	lea	rcx, 20[rbx]
	lea	rsi, 12[r12]
	mov	rdi, rbp
	call	cypress_populate_voltage_value@PLT
	test	eax, eax
	jne	.L1
.L16:
	mov	rsi, QWORD PTR 8[r14]
	add	rsp, 8
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	lea	rdx, 16[rbx]
	mov	rdi, rbp
	pop	rbx
	.cfi_def_cfa_offset 48
	pop	rbp
	.cfi_def_cfa_offset 40
	pop	r12
	.cfi_def_cfa_offset 32
	pop	r13
	.cfi_def_cfa_offset 24
	pop	r14
	.cfi_def_cfa_offset 16
	pop	r15
	.cfi_def_cfa_offset 8
	jmp	cypress_populate_mvdd_value@PLT
	.p2align 4,,10
	.p2align 3
.L1:
	.cfi_restore_state
	add	rsp, 8
	.cfi_remember_state
	.cfi_def_cfa_offset 56
	pop	rbx
	.cfi_def_cfa_offset 48
	pop	rbp
	.cfi_def_cfa_offset 40
	pop	r12
	.cfi_def_cfa_offset 32
	pop	r13
	.cfi_def_cfa_offset 24
	pop	r14
	.cfi_def_cfa_offset 16
	pop	r15
	.cfi_def_cfa_offset 8
	ret
	.p2align 4,,10
	.p2align 3
.L8:
	.cfi_restore_state
	mov	r10d, DWORD PTR 24[r14]
	mov	rdx, rsi
	mov	r9d, 1
	mov	rcx, r15
	mov	r8d, 1
	mov	rdi, rbp
	mov	esi, r10d
	call	cypress_populate_mclk_value@PLT
	jmp	.L14
	.p2align 4,,10
	.p2align 3
.L2:
	mov	edx, 1
	mov	ecx, eax
	and	ecx, DWORD PTR ATOM_PPLIB_R600_FLAGS_PCIEGEN2[rip]
	jne	.L4
	jmp	.L3
	.p2align 4,,10
	.p2align 3
.L27:
	mov	rsi, QWORD PTR 8[r14]
	mov	edx, 1
	mov	rdi, rbp
	call	cypress_get_mclk_frequency_ratio@PLT
	mov	edi, DWORD PTR MC_SEQ_MISC7[rip]
	mov	r13d, eax
	call	RREG32@PLT
	mov	edi, DWORD PTR MC_SEQ_MISC5[rip]
	sar	eax, 16
	and	eax, 15
	cmp	r13d, eax
	jge	.L25
	mov	edi, DWORD PTR MC_SEQ_MISC6[rip]
.L25:
	call	RREG32@PLT
	shr	eax
	mov	r9d, eax
	mov	eax, DWORD PTR SMC_STROBE_ENABLE[rip]
	and	eax, DWORD PTR 12[rbx]
	and	r9d, 1
	jmp	.L13
	.p2align 4,,10
	.p2align 3
.L7:
	not	eax
	and	eax, edx
	mov	DWORD PTR 36[rbx], eax
	jmp	.L6
	.cfi_endproc
.LFE0:
	.size	cypress_convert_power_level_to_smc, .-cypress_convert_power_level_to_smc
	.comm	SMC_STROBE_ENABLE,4,4
	.comm	SMC_MC_STUTTER_EN,4,4
	.comm	SMC_MC_EDC_WR_FLAG,4,4
	.comm	SMC_MC_EDC_RD_FLAG,4,4
	.comm	PPSMC_STATEFLAG_AUTO_PULSE_SKIP,4,4
	.comm	MC_SEQ_MISC7,4,4
	.comm	MC_SEQ_MISC6,4,4
	.comm	MC_SEQ_MISC5,4,4
	.comm	ATOM_PPLIB_R600_FLAGS_PCIEGEN2,4,4
	.comm	ATOM_PPLIB_R600_FLAGS_BACKBIASENABLE,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",@progbits
	.section	.note.gnu.property,"a"
	.align 8
	.long	 1f - 0f
	.long	 4f - 1f
	.long	 5
0:
	.string	 "GNU"
1:
	.align 8
	.long	 0xc0000002
	.long	 3f - 2f
2:
	.long	 0x3
3:
	.align 8
4:

	.arch armv5t
	.eabi_attribute 20, 1
	.eabi_attribute 21, 1
	.eabi_attribute 23, 3
	.eabi_attribute 24, 1
	.eabi_attribute 25, 1
	.eabi_attribute 26, 2
	.eabi_attribute 30, 2
	.eabi_attribute 34, 0
	.eabi_attribute 18, 4
	.file	"extr_cypress_dpm.c_cypress_convert_power_level_to_smc.c"
	.text
	.align	2
	.global	cypress_convert_power_level_to_smc
	.syntax unified
	.arm
	.fpu softvfp
	.type	cypress_convert_power_level_to_smc, %function
cypress_convert_power_level_to_smc:
	@ args = 0, pretend = 0, frame = 0
	@ frame_needed = 0, uses_anonymous_args = 0
	push	{r4, r5, r6, r7, r8, r9, r10, lr}
	sub	sp, sp, #8
	mov	r5, r1
	mov	r4, r2
	mov	r9, r3
	mov	r6, r0
	bl	rv770_get_pi
	mov	r8, r0
	mov	r0, r6
	bl	evergreen_get_pi
	ldr	r3, [r8, #12]
	ldr	r2, .L28
	cmp	r3, #0
	ldr	r2, [r2]
	ldr	r3, [r5]
	mov	r7, r0
	andeq	r2, r2, r3
	beq	.L3
	ands	r2, r3, r2
	movne	r1, #1
	beq	.L3
.L4:
	ldr	r0, .L28+4
	subs	r2, r2, #0
	ldr	r0, [r0]
	movne	r2, #1
	tst	r3, r0
	movne	r3, #1
	moveq	r3, #0
	str	r2, [r4, #4]
	str	r1, [r4]
	mov	r0, r6
	ldr	r1, [r5, #16]
	str	r9, [r4, #44]
	str	r3, [r4, #8]
	add	r2, r4, #40
	bl	rv740_populate_sclk_value
	cmp	r0, #0
	bne	.L1
	ldr	r3, [r8]
	ldr	r1, [r5, #4]
	cmp	r3, #0
	str	r0, [r4, #32]
	beq	.L6
	cmp	r3, r1
	blt	.L6
	ldr	r3, [r7, #24]
	cmp	r3, #0
	bne	.L6
	ldr	r3, .L28+8
	ldr	r0, [r7, #20]
	ldr	r2, [r3]
	ldr	r3, .L28+12
	str	r2, [r4, #32]
	ldr	r2, [r3]
	ldr	r3, [r4, #36]
	cmp	r0, #0
	orrne	r3, r2, r3
	biceq	r3, r3, r2
	str	r3, [r4, #36]
.L6:
	ldr	r3, [r8, #8]
	add	r9, r4, #28
	cmp	r3, #0
	beq	.L8
	ldr	r3, [r8, #4]
	mov	r0, r6
	cmp	r3, r1
	ldrlt	r2, .L28+16
	ldrlt	r3, [r4, #32]
	ldrlt	r2, [r2]
	ldr	r8, .L28+20
	orrlt	r3, r3, r2
	strlt	r3, [r4, #32]
	ldr	r3, [r7]
	cmp	r3, r1
	ldrlt	r2, .L28+24
	ldrlt	r3, [r4, #32]
	ldrlt	r2, [r2]
	orrlt	r3, r3, r2
	strlt	r3, [r4, #32]
	bl	cypress_get_strobe_mode_settings
	ldr	r3, [r8]
	str	r0, [r4, #12]
	ands	r0, r0, r3
	ldreq	r2, [r7, #4]
	bne	.L27
.L13:
	subs	r0, r0, #0
	movne	r0, #1
	stm	sp, {r0, r2}
	mov	r3, r9
	mov	r0, r6
	ldr	r2, [r5, #4]
	ldr	r1, [r5, #16]
	bl	cypress_populate_mclk_value
.L14:
	cmp	r0, #0
	bne	.L1
	mov	r0, r6
	ldr	r2, [r5, #12]
	add	r3, r4, #24
	add	r1, r7, #16
	bl	cypress_populate_voltage_value
	cmp	r0, #0
	bne	.L1
	ldr	r3, [r7, #12]
	cmp	r3, #0
	beq	.L16
	mov	r0, r6
	ldr	r2, [r5, #8]
	add	r1, r7, #8
	add	r3, r4, #20
	bl	cypress_populate_voltage_value
	cmp	r0, #0
	bne	.L1
.L16:
	mov	r0, r6
	ldr	r1, [r5, #4]
	add	r2, r4, #16
	add	sp, sp, #8
	@ sp needed
	pop	{r4, r5, r6, r7, r8, r9, r10, lr}
	b	cypress_populate_mvdd_value
.L3:
	mov	r1, #0
	b	.L4
.L1:
	add	sp, sp, #8
	@ sp needed
	pop	{r4, r5, r6, r7, r8, r9, r10, pc}
.L8:
	mov	r0, #1
	str	r0, [sp, #4]
	str	r0, [sp]
	mov	r2, r1
	mov	r3, r9
	mov	r0, r6
	ldr	r1, [r5, #16]
	bl	cypress_populate_mclk_value
	b	.L14
.L27:
	mov	r2, #1
	ldr	r1, [r5, #4]
	mov	r0, r6
	bl	cypress_get_mclk_frequency_ratio
	ldr	r3, .L28+28
	mov	r10, r0
	ldr	r0, [r3]
	bl	RREG32
	asr	r3, r0, #16
	and	r3, r3, #15
	cmp	r10, r3
	ldrge	r3, .L28+32
	ldrlt	r3, .L28+36
	ldr	r0, [r3]
	bl	RREG32
	ldr	r3, [r8]
	ldr	r1, [r4, #12]
	lsr	r2, r0, #1
	and	r2, r2, #1
	and	r0, r3, r1
	b	.L13
.L29:
	.align	2
.L28:
	.word	ATOM_PPLIB_R600_FLAGS_PCIEGEN2
	.word	ATOM_PPLIB_R600_FLAGS_BACKBIASENABLE
	.word	SMC_MC_STUTTER_EN
	.word	PPSMC_STATEFLAG_AUTO_PULSE_SKIP
	.word	SMC_MC_EDC_RD_FLAG
	.word	SMC_STROBE_ENABLE
	.word	SMC_MC_EDC_WR_FLAG
	.word	MC_SEQ_MISC7
	.word	MC_SEQ_MISC5
	.word	MC_SEQ_MISC6
	.size	cypress_convert_power_level_to_smc, .-cypress_convert_power_level_to_smc
	.comm	SMC_STROBE_ENABLE,4,4
	.comm	SMC_MC_STUTTER_EN,4,4
	.comm	SMC_MC_EDC_WR_FLAG,4,4
	.comm	SMC_MC_EDC_RD_FLAG,4,4
	.comm	PPSMC_STATEFLAG_AUTO_PULSE_SKIP,4,4
	.comm	MC_SEQ_MISC7,4,4
	.comm	MC_SEQ_MISC6,4,4
	.comm	MC_SEQ_MISC5,4,4
	.comm	ATOM_PPLIB_R600_FLAGS_PCIEGEN2,4,4
	.comm	ATOM_PPLIB_R600_FLAGS_BACKBIASENABLE,4,4
	.ident	"GCC: (Ubuntu 9.4.0-1ubuntu1~20.04.2) 9.4.0"
	.section	.note.GNU-stack,"",%progbits
