I test the power management feature by following "11.1 Power management user manual" of LSDK User Guide 1909 on FRWY-LS1046A board. But I don't see ASLEEP LED is turned on when I run the following command:
echo 0 > /sys/class/rtc/rtc1/wakealarm && echo +10 > /sys/class/rtc/rtc1/wakealarm && echo mem > /sys/power/state
I expect that LS1046A enters LPM20 state by echo mem > /sys/power/state . Am I wrong? If so, how to put LS1046A into LPM20?
Best regards,
Solved! Go to Solution.
Please check whether the following section has been executed.
_soc_sys_pwrdn_wfi:
mov x4, x30
/* request LPM20 */
mov x0, #RCPM_POWMGTCSR_OFFSET
bl read_reg_rcpm
orr x1, x0, #RCPM_POWMGTCSR_LPM20_REQ
mov x0, #RCPM_POWMGTCSR_OFFSET
bl write_reg_rcpm
dsb sy
isb
wfi
mov x30, x4
ret
Hi yipingwang,
To make sure that the function _soc_sys_off in plat/nxp/soc-ls1046/aarch64/ls1046.S is called and LPM20_REQ bit is set, I added the following code before the line of /* request LPM20 */ to toggle GPIO3[17] pin which is connected to the GPIO expansion header (J67) of LS1046A-FRWY board.
/* toggle GPIO3[17] */
mov x0, #GPDIR_REG_OFFSET
bl read_reg_gpio3
orr x1, x0, 0x00004000
mov x0, #GPDIR_REG_OFFSET
bl write_reg_gpio3
mov x0, #GPDAT_REG_OFFSET
bl read_reg_gpio3
eor x1, x0, 0x00004000
mov x0, #GPDAT_REG_OFFSET
bl write_reg_gpio3
/* request LPM20 */
mov x0, #RCPM_POWMGTCSR_OFFSET
bl read_reg_rcpm
orr x1, x0, #RCPM_POWMGTCSR_LPM20_REQ
mov x0, #RCPM_POWMGTCSR_OFFSET
bl write_reg_rcpm
However, I don't observe any toggling on GPIO3[17] pin when I execute "# echo mem > /sys/power/state" on the command prompt.
Could you please review the attached source code and check if this code will toggle GPIO3[17] pin?
I see it is toggled by using /sys/class/gpio in Linux, so the pin and my oscilloscope are working.
Best regards,
Ando
Please check whether the following section has been executed.
_soc_sys_pwrdn_wfi:
mov x4, x30
/* request LPM20 */
mov x0, #RCPM_POWMGTCSR_OFFSET
bl read_reg_rcpm
orr x1, x0, #RCPM_POWMGTCSR_LPM20_REQ
mov x0, #RCPM_POWMGTCSR_OFFSET
bl write_reg_rcpm
dsb sy
isb
wfi
mov x30, x4
ret
Thank you for pointing out the correct function. I confirm that _soc_sys_pwrdn_wfi is called after # echo mem > /sys/power/state
However, I still don't see ASLEEP assertion on my board even though the function _soc_sys_pwrdn_wfi is executed. I am wandering if LS1046A does not go to LPM20 state by unknown reason though LPM20_REQ bit is set, or if LS1046A does not assert ASLEEP signal even when it goes to LPM20 state.
I will ask it to our application engineer.
Thank you very much for your support.
Hello Yutaka Ando,
Please configure Linux Kernel configuration as the following
CONFIG_SUSPEND=y
CONFIG_RTC_DRV_FSL_FTM_ALARM=y
CONFIG_ARM_CPUIDLE=y
CONFIG_PCI is not set
Please refer to my attached log verified with Image built from LSDK1909.
Thanks,
Yiping
Hi yipingwang
Thank you for your comment.
I modified the config file to have "CONFIG_PCI is not set" and test it again. I could get a similar log with you sent me previously, but ASLEEP LED on my FRWY-LS1046A board is still kept OFF during the low power mode.
In addition, I can't find a code that sets POWMGTCSR[LPM20_REQ] bit in the Linux source tree. Could you check if there are any source codes that set LPM20_REQ bit?
Best regards,
Ando
Hello Ando,
Please refer to the following in atf source code plat/nxp/soc-ls1046/aarch64/ls1046.S. You could run command "flex-builder -c atf -a arm64" in LSDK to get atf source code in packages/firmware/atf.
/* request LPM20 */
mov x0, #RCPM_POWMGTCSR_OFFSET
bl read_reg_rcpm
orr x1, x0, #RCPM_POWMGTCSR_LPM20_REQ
mov x0, #RCPM_POWMGTCSR_OFFSET
bl write_reg_rcpm
Thanks,
Yiping
Hello yipingwang
Thank you for the comment above.
The source code shown in your previous comment is a part of _soc_sys_off function. I find the note of this function and it says:
Note: this function is not intended to return, and the only allowable recovery is POR
So I am afraid that this function is not called by the Linux command:
# echo mem > /sys/power/state
In my understanding, ATF functions are called by __arm_smccc_smc function in arch/arm64/kernel/smccc-call.S of the kernel source code. But I cannot find the function flow from __arm_smccc_smc to _soc_sys_off.
I would like to see the ASLEEP LED is turned on during LPM20 state so that I can measure the time from setting POWMGTCSR[LPM20_REQ] to entering LPM20 state. If there is any other way to measure it, that should be helpful.
Hello Yutaka Ando,
Kernel calling stack
user space :
echo mem > /sys/power/state
Kernel space:
kernel/power/main.c
state_store();
pm_suspend(state);
kernel/power/suspend.c:
pm_suspend(){
enter_state(state);
suspend_devices_and_enter(state);
suspend_enter()
suspend_ops->enter(state); ();---------------------------Here system begin to suspend
syscore_resume();-------------------------------------------Here system begin to resume
system_state = SYSTEM_RUNNING;
enable_nonboot_cpus();
…
drivers/firmware/psci.c:
struct platform_suspend_ops psci_suspend_ops = {
.enter = psci_system_suspend_enter,
psci_system_suspend_enter() {
cpu_suspend(0, psci_system_suspend)
psci_system_suspend()
psci_cpu_suspend()
fn = psci_fuanction_id[PSCI_FN_CPU_SUSPEND]
invoke_psci_fn(… vir_to_phys(cpu_resume),…)
__invoke_psci_fn_smc()
smc---------------------------------------------Here TF-A/atf will take over, and will jump back to cpu_resume() when system wake up.
arch/arm64/kernel/sleep.S:
ENTRY(cpu_resume)
_cpu_resume
cpu_do_resume
arch/arm64/mm/proc.S:
ENTRY(cpu_do_resume)
…
ret
ASLEEP:
Please refer to LS1046 Reference Manual, RCW of pin mux.
LPM20 entry related programming
Thanks,
Yiping
Hello yipingwang,
Thank you for the detailed explanation.
I see the point where TF-A / atf takes over in Linux source code. I am assuming that TF-A / atf will set PWRMGTCSR[LPM20_REQ] bit after that, though I don't find the flow of TF-A / atf...
I have checked the value of RCW[ASLEEP] is "0" on my FRWY board so I believe ASLEEP should be asserted and the LED should be turned on in LPM20 mode.
If you have FRWY board, could you check if the LED is turned on after echo mem > /sys/power/state please?