This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
Hello Team,
We are trying to implement Sleep and Wakeup on our custom board, we are trying to use MCU GPIO for waking up the device from Sleep (Suspend-to-RAM (Deep Sleep)).
We have connected MCU_GPIO0_3 to an external switch on our board and we are using this to generate interrupt on device while in Deep Sleep. When we press the switch we get high to low signal on the MCU_GPIO but we observe that the device is not waking up from sleep. We have attached the changes we did in device tree.
We tried keeping the status of mcu_gpio0 node as both 'okay' and 'reserved' in device tree. but we did not get any success in waking the device from sleep.
Can you guide us how to wake up the device and let us know if any other changes need to be done for same.
+++ b/arch/arm64/boot/dts/msc/am62xx/msc-sm2s-am62x-qc-14402C1I-module.dts @@ -16,6 +16,8 @@ #include <dt-bindings/leds/common.h> #include <dt-bindings/gpio/gpio.h> #include <dt-bindings/net/ti-dp83867.h> +#include <dt-bindings/interrupt-controller/irq.h> +#include "../../ti/k3-pinctrl.h" #include "../../ti/k3-am625.dtsi" / { @@ -320,6 +322,22 @@ }; }; }; */ + + mcu_gpio_key { + compatible = "gpio-keys"; + autorepeat; + pinctrl-names = "default"; + pinctrl-0 = <&wake_mcugpio1_pins_default>; + interrupt-parent = <&mcu_gpio0>; + interrupts = <03 IRQ_TYPE_EDGE_RISING>; + switch { + label = "MCUGPIO"; + linux,code = <143>; + gpios = <&mcu_gpio0 03 GPIO_ACTIVE_LOW>; + wakeup-source; + }; + }; + }; &mcu_pmx0 { @@ -359,6 +377,13 @@ AM62X_IOPAD(0x03C, PIN_OUTPUT, 0) /* (E5) MCU_MCAN1_TX */ >; }; + + wake_mcugpio1_pins_default: wake-mcugpio1-pins-default { + pinctrl-single,pins = < + AM62X_MCU_IOPAD(0x00C, PIN_INPUT, 7) /* (D9) MCU_GPIO0_03 */ + >; + }; + }; &main_pmx0 { @@ -926,6 +951,13 @@ compatible= "ricoh,r2221tl"; reg=<0x32>; }; + + tpm: st33tphf20@2e { + compatible = "st,st33htpm-i2c"; + reg = <0x2e>; + status = "okay"; + }; + }; &main_i2c3 {
Thanks,
Nilesh
Hello Nilesh,
I am suspecting that your MCU GPIO pin interrupt is not working.
Can you please confirm whether you are able to get a GPIO interrupt or not?
You are routing the MCU GPIO interrupt to the A53 core on Linux. So, I am forwarding this thread to Linux experts as well.
For the first level, we can verify whether the GPIO interrupt is working or not.
Regards,
S.Anil.
Hello Swargam Anil,
Yes we are able to get the GPIO interrupt we tested it by getting output of /proc/interrupts entry. But the device is not able to wakeup when kept in deep sleep mode.
root@sm2s-am6254:~# root@sm2s-am6254:~# cat /proc/interrupts | grep "MCUGPIO" 330: 0 0 0 0 GPIO 11 Edge -davinci_gpio MCUGPIO root@sm2s-am6254:~# cat /proc/interrupts | grep "MCUGPIO" 330: 401 0 0 0 GPIO 11 Edge -davinci_gpio MCUGPIO root@sm2s-am6254:~#
Can you let me know if any extra changes we need to do other than what is mentioned in https://software-dl.ti.com/processor-sdk-linux/esd/AM62X/09_00_00_03/exports/docs/linux/Foundational_Components/Kernel/Kernel_Drivers/Power_Management/pm_wakeup_sources.html#pm-wakeup-sources
Thanks
Nilesh
Hi Nilesh,
We have connected MCU_GPIO0_3
From the log you provided, the interrupt is set for MCU_GPIO0_11, not 3.
Also, the device tree pinmux (wake_mcugpio1_pins_default) is pointing to the wrong address. I believe you meant 0x000c not 0x00c.
Best Regards,
Anshu
Hello Anshu,
In last comment i forgot to mention that as per our hardware team on our device MCU_GPIO_3 is used for other function, so we tried with MCU_GPIO_11 and we observe same result with that GPIO also. Yes i also had tried with the address as you mentioned 0x002C for MCU_GPIO_11.
Below are the changes we did for using MCU_GPIO_11.
@@ -320,6 +322,22 @@ }; }; }; */ + + mcu_gpio_key { + compatible = "gpio-keys"; + autorepeat; + pinctrl-names = "default"; + pinctrl-0 = <&wake_mcugpio1_pins_default>; + interrupt-parent = <&mcu_gpio0>; + interrupts = <11 IRQ_TYPE_EDGE_FALLING>; + switch { + label = "MCUGPIO"; + linux,code = <143>; + gpios = <&mcu_gpio0 11 GPIO_ACTIVE_LOW>; + wakeup-source; + }; + }; + }; &mcu_pmx0 { @@ -359,6 +377,13 @@ AM62X_IOPAD(0x03C, PIN_OUTPUT, 0) /* (E5) MCU_MCAN1_TX */ >; }; + + wake_mcugpio1_pins_default: wake-mcugpio1-pins-default { + pinctrl-single,pins = < + AM62X_MCU_IOPAD(0x02C, PIN_INPUT, 7) /* (C6) MCU_GPIO0_11 */ + >; + }; + }; &main_pmx0 {
Thanks,
Nilesh
Hi Nilesh,
Do you have a reference node to "&mcu_gpio0"? Under mcu_gpio_key, the interrupt parent is looking for <&mcu_gpio0> and in the switch node, but I don't see one in the code you provided.
A simple reference after &mcu_pmx0 should work since the other pinctrl parameters are done in mcu_gpio_key.
&mcu_gpio0 { status = "okay"; };
Anshu
Hello Anshu,
Yes i have this node in my dts file, i also tried changing the status to 'reserved' as well.
&mcu_gpio_intr { status = "okay"; }; &mcu_gpio0 { status = "okay"; };
Other than this nodes do i need to add any other node like below, i have added this too.
&cbass_mcu { status = "okay"; };
Thanks,
Nilesh
Hi Nilesh,
I was able to confirm that this setup works for MCU_GPIO0_15 and 16 for the TI EVM I am using.
I noticed that the interrupt is set for IRQ_TYPE_EDGE_FALLING, instead of IRQ_TYPE_EDGE_RISING. I don't think it matters since it works for both. Just to verify, change it to rising edge and see if there are any differences.
Are there any errors in the logs when the device moves into deep sleep?
Best Regards,
Anshu
Hi Anshu,
We tried changing the interrupt from IRQ_TYPE_EDGE_FALLING to IRQ_TYPE_EDGE_RISING. There is no effect, device does not wake up from sleep.
Here is the logs we get when we put the device in sleep with the command
# echo mem > /sys/power/state
root@sm2s-am6254:~# echo mem > /sys/power/state [ 497.983406] PM: suspend entry (deep) [ 497.992091] Filesystems sync: 0.004 seconds [ 501.133982] k3-m4-rproc 5000000.m4fss: k3_m4_rproc_stop: timedout waiting for rproc completion event [ 501.143306] remoteproc remoteproc0: can't stop rproc: -16 [ 501.149006] Freezing user space processes [ 501.156178] Freezing user space processes completed (elapsed 0.003 seconds) [ 501.163253] OOM killer disabled. [ 501.166557] Freezing remaining freezable tasks [ 501.173149] Freezing remaining freezable tasks completed (elapsed 0.002 seconds) [ 501.180699] printk: Suspending console(s) (use no_console_suspend to debug)
Below we get interrupt in normal state.
root@sm2s-am6254:~# root@sm2s-am6254:~# cat /proc/interrupts | grep "MCUGPIO" 330: 0 0 0 0 GPIO 11 Edge -davinci_gpio MCUGPIO root@sm2s-am6254:~# cat /proc/interrupts | grep "MCUGPIO" 330: 418 0 0 0 GPIO 11 Edge -davinci_gpio MCUGPIO root@sm2s-am6254:~#
Thanks,
Nilesh
Hi Nilesh,
Thank you for the logs.
One noticeable difference in the logs you provided is the CPUs are not turning off as can be seen in the example output: software-dl.ti.com/.../pm_low_power_modes.html
Just to confirm, does the CPUs turn off when going into Deep Sleep?
Best Regards,
Anshu
Hi Anshu,
We tried to test this on EVM with default image of 9.0 SDK in that we were are getting below logs
root@am62xx-evm:~# cat /proc/interrupts CPU0 CPU1 CPU2 CPU3 11: 4648 3975 4599 4287 GICv3 30 Level arch_timer 14: 8 0 0 0 GICv3 108 Level mbox-m4-0, mbox-r5-0 15: 0 0 0 0 GICv3 23 Level arm-pmu 16: 0 0 0 0 GICv3 130 Level pinctrl 17: 3742 0 0 0 GICv3 66 Level 4d000000.mailbox thr_012 26: 586 0 0 0 GICv3 193 Level 20000000.i2c 27: 280 0 0 0 GICv3 194 Level 20010000.i2c 28: 0 0 0 0 GICv3 195 Level 20020000.i2c 29: 2 0 0 0 GICv3 171 Level fc40000.spi 30: 1464 0 0 0 MSI-INTA 1713152 Level 485c0100.dma-controller chan0 48: 0 0 0 0 MSI-INTA 1714176 Edge 485c0100.dma-controller chan1 60: 1 0 0 0 MSI-INTA 1714688 Level 485c0100.dma-controller chan1 78: 0 0 0 0 MSI-INTA 1715718 Edge 485c0100.dma-controller chan2 96: 1 0 0 0 MSI-INTA 1716230 Level 485c0100.dma-controller chan2 118: 0 0 0 0 MSI-INTA 1970707 Level 8000000.ethernet-tx0 190: 0 0 0 0 MSI-INTA 1970779 Level 485c0000.dma-controller chan2 208: 0 0 0 0 MSI-INTA 1971731 Level 8000000.ethernet 232: 0 0 0 0 MSI-INTA 1971755 Level 485c0000.dma-controller chan0 233: 0 0 0 0 MSI-INTA 1971756 Level 485c0000.dma-controller chan1 240: 567 0 0 0 GICv3 210 Level 2800000.serial 241: 0 0 0 0 pinctrl 456 Edge 2800000.serial:wakeup 242: 0 0 0 0 GICv3 134 Level 8000000.ethernet 245: 281 0 0 0 GICv3 165 Level mmc0 324: 7 0 0 0 GPIO 72 Edge -davinci_gpio wl18xx 371: 0 0 0 0 GPIO 23 Edge -davinci_gpio 1-0022 401: 14622 0 0 0 GICv3 115 Level mmc1 402: 2498 0 0 0 GICv3 114 Level mmc2 403: 0 0 0 0 GICv3 269 Level 2b10000.audio-controller_rx 404: 0 0 0 0 GICv3 270 Level 2b10000.audio-controller_tx 409: 0 0 0 0 1-0022 16 Edge 1-003b 413: 0 0 0 0 GICv3 132 Level 2b1f0000.rtc 414: 0 0 0 0 GICv3 116 Level tidss 415: 50 0 0 0 GICv3 118 Level pvrsrvkm 429: 0 0 0 0 GICv3 258 Level xhci-hcd:usb1 IPI0: 1156 2939 1379 2715 Rescheduling interrupts IPI1: 3013 6902 5082 5097 Function call interrupts IPI2: 0 0 0 0 CPU stop interrupts IPI3: 0 0 0 0 CPU stop (for crash dump) interrupts IPI4: 0 0 0 0 Timer broadcast interrupts IPI5: 231 152 284 185 IRQ work interrupts IPI6: 0 0 0 0 CPU wake-up interrupts Err: 0 root@am62xx-evm:~# echo mem > /sys/power/state [ 67.841531] PM: suspend entry (deep) [ 67.862049] Filesystems sync: 0.016 seconds [ 67.912336] remoteproc remoteproc0: stopped remote processor 5000000.m4fss [ 67.919707] Freezing user space processes [ 67.926054] Freezing user space processes completed (elapsed 0.002 seconds) [ 67.933099] OOM killer disabled. [ 67.936331] Freezing remaining freezable tasks [ 67.942360] Freezing remaining freezable tasks completed (elapsed 0.001 seconds) [ 67.949788] printk: Suspending console(s) (use no_console_suspend to debug)
As mentioned in section 3.2.2.11.4.2. Suspend-to-RAM (Deep Sleep) of https://software-dl.ti.com/processor-sdk-linux/esd/AM62X/09_00_00_03/exports/docs/linux/Foundational_Components/Kernel/Kernel_Drivers/Power_Management/pm_low_power_modes.html#suspend-to-ram-deep-sleep we checked TP25/PMIC_LPM_EN pin on the EVM if the pin is 3.3V when active and 0V when in deep sleep. but it's voltage is High at 3.3V.
Is it that we need to set it as mentioned (after programming the PMCTRL_SYS register (0x43018080) to 0x15) or it is done by default in 9.0 SDK
Thanks,
Nilesh
Hi Nilesh,
Thanks for checking the test point. That indicates the device isn't moving into deep sleep and thus the wakeup sources are not working.
Is it that we need to set it as mentioned (after programming the PMCTRL_SYS register (0x43018080) to 0x15) or it is done by default in 9.0 SDK
The PMCTRL_SYS register can be found in Table 14-4667 in the TRM which is linked here: https://www.ti.com/lit/ug/spruiv7b/spruiv7b.pdf
It should be done by default, but if not, a Linux Command you can run is "devmem2 0x43018080" which will read the register and "devmem2 0x43018080 w 0x15" to write to the register.
Based on the logs you provided, I think the device is hanging at some point before the CPUs are turned off in the Sleep Sequence.
Can you try using/provide logs for RTC deep sleep? This command should put the device into deep sleep then wakes up in 30 seconds:
rtcwake -s 30 -m mem
On a different point, there is no mention of the "MCUGPIO" or MCU_GPIO0_11 in the cat /proc/interrupts log you provided.
Best Regards,
Anshu
Hi Anshu,
The logs in above comment was from EVM and i have used default image from 9.0 SDK provided by TI. By following the steps mentioned in below ticket i was able to do the sleep and wakeup on EVM kit. And also using the RTC deep sleep on EVM it is working fine. https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1261500/am623-gpio-wake-up-time-from-linux-suspend-to-ram
While in our device when i run the commands for enabling deep sleep mode i get the following error logs
[ 316.049822] k3-m4-rproc 5000000.m4fss: k3_m4_rproc_stop: timedout waiting for rproc completion event
[ 316.059242] remoteproc remoteproc0: can't stop rproc: -16
root@sm2s-am6254:~# echo mem > /sys/power/state [ 312.934988] PM: suspend entry (deep) [ 312.943663] Filesystems sync: 0.004 seconds [ 316.049822] k3-m4-rproc 5000000.m4fss: k3_m4_rproc_stop: timedout waiting for rproc completion event [ 316.059242] remoteproc remoteproc0: can't stop rproc: -16 [ 316.064939] Freezing user space processes [ 316.072190] Freezing user space processes completed (elapsed 0.003 seconds) [ 316.079283] OOM killer disabled. [ 316.082565] Freezing remaining freezable tasks [ 316.089331] Freezing remaining freezable tasks completed (elapsed 0.002 seconds) [ 316.096900] printk: Suspending console(s) (use no_console_suspend to debug)
I'm not able to change the state of the remoteproc extermally from sysfs by using below command
echo stop > /sys/class/remoteproc/remoteproc0/state
it gives the same error as above
root@sm2s-am6254:~# echo stop > /sys/class/remoteproc/remoteproc0/state [ 62.605993] k3-m4-rproc 5000000.m4fss: k3_m4_rproc_stop: timedout waiting for rproc completion event [ 62.615312] remoteproc remoteproc0: can't stop rproc: -16 echo: write error: device or resource busy root@sm2s-am6254:~#
Thanks,
Nilesh
Hi Nilesh,
Just to clarify my understanding,
Please correct me if my understanding is wrong.
Remoteproc is not a topic I am familiar with but the two errors point to the following files: remoteproc_core.c (can't stop rproc) & ti_k3_m4_remoteproc.c (timedout ...). Looks like the peripheral maybe busy with another process. Does your custom hardware have an M4 Core and is it being used by another device driver or process?
Thanks,
Anshu
Hi Anshu,
Yes for first point you are wright
For second point
For our custom board we have made changes in the Linux BSP it is not the Default image from TI.
Yes our board has M4 Core and we have not made any changes reated to it in our BSP.
Thanks,
Nilesh
Hi Nilesh,
Can you try using MCU Only mode? The documentation can be seen here: https://software-dl.ti.com/processor-sdk-linux/esd/AM62X/09_00_00_03/exports/docs/linux/Foundational_Components/Kernel/Kernel_Drivers/Power_Management/pm_low_power_modes.html#mcu-only-mode
I understand that its not within the scope of what you need, but it may give some insight on the M4's response in LPMs. Please share the logs of MCU Only Mode.
Thanks,
Anshu
Hi Anshu,
Thanks for your reply, i looked into MCU only mode, it looks like it needs MCU UART for waking device form sleep mode and in our device we have used MCU UART with other interface.
I tried MCU only mode commands mentioned, but device is not going into Sleep mode. I checked PMIC_LPM_EN pin it is high means device is not going into sleep mode.
Can you point the changes need to be done in Device Tree, or do we need to enable any drivers from defconfig for enabling Deep Sleep mode.
Thanks,
Nilesh
Hi Nilesh,
The config file should support the PM Options. By default, the SDK should have this enabled. If there are doubts about if the all needed PM Options are not enabled, we can go deeper into that topic.
The relevant device tree changes are for wakeup sources, not necessarily enabling Deep Sleep.
Does the R5F Core perform any other applications other than run the DM Firmware? If so, there will be errors entering Deep Sleep. Here is the documentation for this in the Introduction section: https://software-dl.ti.com/mcu-plus-sdk/esd/AM62X/09_01_00_39/exports/docs/api_guide_am62x/DEVELOP_AND_DEBUG_DMR5.html
Best Regards,
Anshu
Hi Anshu,
As you mentioned that the changes we did are for wakeup source, are there any changes need to be done for enabling Deep Sleep.
> Does the R5F Core perform any other applications other than run the DM Firmware?
We checked for this we see same firmware on our device as of the EVM.
We could not find the '-CONFIG_LPM_DM=y' in our source as mentioned in the link you provided. Can you help let us know if any specific source needed for R5F Core.
And also if any changes required to enable Deep sleep mode.
Thanks,
Nilesh
Hi Nilesh,
Thanks for the information. I'll be discussing this with the software development team and will get back to you.
Best Regards,
Anshu
Hi Nilesh,
Can you go through this FAQ I created: https://e2e.ti.com/support/processors-group/processors/f/processors-forum/1323581/faq-processor-sdk-am62x-how-can-we-debug-deep-sleep-on-am62x-using-sysfw-trace
Lets see if the DM Firmware logs shows something.
Best Regards,
Anshu