Put the imx8dxl A35 in suspend mode via imx-atf

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Put the imx8dxl A35 in suspend mode via imx-atf

跳至解决方案
2,034 次查看
hojames2025
Contributor II

Hello,

 

HW: imx8dxl

ATF: imx-atf < lf-6.12.3-1.0.0>

 

Our requirement is ,

<1>, config the pad as wake up source.

<2>, put the A35 core in suspend mode.

 

For <1>, we can use the corresponding sc-fw APIs and it seems no issue.

For <2>, there is some issue.

We tried to use the some psci call (imx_psci_call(regx0, regx1, .... regx4)) like below to put the A35 in suspend state: 
    power_state = psci_make_powerstate(0PSTATE_TYPE_POWERDOWN,0);
    imx_psci_call(IMX_PSCI_CPU_SUSPEND_AARCH64power_state,0,0,0);
 
The reason we used 'PSTATE_TYPE_POWERDOWN" was, I checked the code in "
imx_validate_power_state()", it only deals PSTATE_TYPE_POWERDOWN.
 
 

We also added some debug code in imx_domain_suspend() of <plat\imx\imx8dxl\imx8dxl_psci.c>

Then we found out the below if branch (in imx_domain_suspend() ) for setting the suspend did not enter:
    if (is_local_state_retn(target_state->pwr_domain_state[MPIDR_AFFLVL1])) {

....

 

Could you please give some comment on this?

What parameters shall we use for the psci call?

Thank you.

 

 

 

标记 (4)
0 项奖励
回复
1 解答
1,981 次查看
Zhiming_Liu
NXP TechSupport
NXP TechSupport

Hello @hojames2025 

For the Linux suspend, linux is using PSCI_SYSTEM_SUSPEND_AARCH64 as function id and the imx-atf is optimized for this. The PLAT_MAX_PWR_LVL in psci_system_suspend let the imx_domain_suspend run the third if branch. So if you want to let imx_domain_suspend enter second if branch , you need to check the suspend function and make sure that state is OFF state. The default state is RETENTION state. You could try to modify the plat/imx/imx8dx/include/platform_def.h, define PLAT_MAX_PWR_LVL as MPIDR_AFFLVL1.


Best Regards,
Zhiming

在原帖中查看解决方案

0 项奖励
回复
7 回复数
2,013 次查看
Zhiming_Liu
NXP TechSupport
NXP TechSupport

Hello,

You are calling imx-atf right? imx_psci_call is a function I can consider as a kind of smc call?For IMX_PSCI_CPU_SUSPEND_AARCH64,  what is the definition of this function id?

Best Regards,
Zhiming

0 项奖励
回复
1,889 次查看
hojames2025
Contributor II

Hello Zhiming,

Thanks for the information, it's very helpful.
Now we are using the same function id (PSCI_SYSTEM_SUSPEND_AARCH64),
We can see it enters expected code branch, and if we active the wakeup source, the wakeup function (imx_domain_suspend_finish()) in imx-atf is called.

But we have another question regarding the entrypoint parameter (the resume address).

We are making the psci call like below.
imx_psci_call(PSCI_SYSTEM_SUSPEND_AARCH64, entrypoint,0,0,0);

How can we set the entrypoint here ?
Can we use  __builtin_return_address(0)  or a normal function pointer?
It does not work. 

Is our understanding correct?
Could you please give some comments or some example code about this?

Thank you!

Regards,

0 项奖励
回复
1,865 次查看
Zhiming_Liu
NXP TechSupport
NXP TechSupport

Hi @hojames2025 

In Linux, the resume address is phys_addr_t pa_cpu_resume = __pa_symbol(cpu_resume);

__pa_symbol will convert symbolic virtual addresses in kernel code to physical addresses.

//arch/arm64/include/asm/memory.h
#define __pa_symbol(x)		__phys_addr_symbol(RELOC_HIDE((unsigned long)(x), 0))

#define __phys_addr_symbol(x)	__pa_symbol_nodebug(x)
#define __pa_symbol_nodebug(x)	__kimg_to_phys((phys_addr_t)(x))
#define __kimg_to_phys(addr)	((addr) - kimage_voffset)

kimage_voffset
--------------

The offset between the kernel virtual and physical mappings. Used to
translate virtual to physical addresses.

If you want to make the resume work, you need to give correct physical address of  cpu_resume function.



Best Regards,
Zhiming

0 项奖励
回复
1,849 次查看
hojames2025
Contributor II

Hello Zhiming,

Thanks for the reply.

We understood it requires physical address as resume address (the entrypoint parameter).
Actually, the resume address here is physical address (it's under bare mental, without mmu on).

 

So, if the resume address has already been physical,
do we need any other special operation at this resume handler?


For example, do we need to do EL level change stuff, re-initialize the power mode/clock of the prephreials or someting else?
(I suppose the imx-atf/scu handles all these before jumping to the resume addr)

 

We put some very simple code in the resume handler,
(write strings in the LPUARTz TX buff to observe)
but it seems it does not jump to this resume address
(or maybe we need more 'resume operation', the writing to LPUARTx does not work yet, but the jumping works?).


Regards,

0 项奖励
回复
1,834 次查看
Zhiming_Liu
NXP TechSupport
NXP TechSupport

Hi @hojames2025 

All needed operations like restore clocks, prephreials and GIC are in imx_domain_suspend_finish(plat/imx/imx8dxl/imx8dxl_psci.c). For the resume address(ep->pc), the ATF just set it into CTX_ELR_EL3 register. If this address is not correct, the jump is invalid. Please check and verify the address.



Best Regards,
Zhiming

0 项奖励
回复
1,995 次查看
hojames2025
Contributor II

Hello Zhiming,

Thanks for the reply.

Yes, we are calling imx-atf services.
The imx_psci_call() is some kind of smc call.
prototype: imx_psci_call(regx0, regx1, .... regx4).

For IMX_PSCI_CPU_SUSPEND_AARCH64,
the value is 0xC4000001 (PSCI_CPU_SUSPEND_AARCH64)

Sorry I did not make it clear,
all the functions I am using are from:
imx-atf\include\lib\psci\psci.h


Regards,

0 项奖励
回复
1,982 次查看
Zhiming_Liu
NXP TechSupport
NXP TechSupport

Hello @hojames2025 

For the Linux suspend, linux is using PSCI_SYSTEM_SUSPEND_AARCH64 as function id and the imx-atf is optimized for this. The PLAT_MAX_PWR_LVL in psci_system_suspend let the imx_domain_suspend run the third if branch. So if you want to let imx_domain_suspend enter second if branch , you need to check the suspend function and make sure that state is OFF state. The default state is RETENTION state. You could try to modify the plat/imx/imx8dx/include/platform_def.h, define PLAT_MAX_PWR_LVL as MPIDR_AFFLVL1.


Best Regards,
Zhiming

0 项奖励
回复