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.

AM6411: Sleep mode

Part Number: AM6411
Other Parts Discussed in Thread: AM62P, SK-AM62

Couple of questions on AM6411 sleep mode operation:

  1. I can enter sleep mode with “echo mem >> /sys/power/state” command, but how do exit from this mode?  Currently I am resetting the board for startup.  Only supported sleep mode is s2idle in AM64xx.
  2. Power management modes are disabled for Linux RT kernel, and enabled only in general purpose kernel, any specific reason for that?

Regards,

Harsha

  • Hi Harsha,

    I can enter sleep mode with “echo mem >> /sys/power/state” command, but how do exit from this mode?  Currently I am resetting the board for startup.  Only supported sleep mode is s2idle in AM64xx.

    Unless other devices such as AM62x/AM62Ax/AM62P, AM64x doesn't support any Low Power mode, so Low Power mode operations such as command 'echo mem > /sys/power/state' are not supported on AM64x devices.

    Power management modes are disabled for Linux RT kernel, and enabled only in general purpose kernel, any specific reason for that?

    Power management often adjusts the CPU frequency which would impact interrupt latency. The main goal in RT kernel is to control the interrupt latency, so PM is disabled in RT kernel.

  • Hi Bin Liu,

    Thanks for the reply.

    Regarding sleep mode, does it mean, even s2idle (state S0) is not supported by AM64xx?  Because as per kernel documentation, this is minimum that should be supported by all systems, whereas state S1 (standby), S3 (suspend to RAM / deep) and S4 (suspend to disk / disk) are platform dependent.

    root@am64xx-evm:/sys/power# cat mem_sleep
    [s2idle]

    root@am64xx-evm:/sys/power# echo mem >> state
    [ 3663.031177] PM: suspend entry (s2idle)
    [ 3663.035320] Filesystems sync: 0.000 seconds
    [ 3666.278658] k3-m4-rproc 5000000.m4fss: k3_m4_rproc_stop: timedout waiting for rproc completion event
    [ 3666.287856] remoteproc remoteproc0: can't stop rproc: -16
    [ 3666.293338] Freezing user space processes
    [ 3666.299712] Freezing user space processes completed (elapsed 0.002 seconds)
    [ 3666.306755] OOM killer disabled.
    [ 3666.309974] Freezing remaining freezable tasks
    [ 3666.315898] Freezing remaining freezable tasks completed (elapsed 0.001 seconds)
    [ 3666.323331] printk: Suspending console(s) (use no_console_suspend to debug)

    After this step, eth0 and eth1 stopped working, and system appears to be in sleep / freeze state.

    Regards,

    Harsha

  • Hi Harsha,

    s2idle is not validated in the Processor SDK for AM64x. Since the AM64x device doesn't support any Low Power mode, there is no software requirement in the Processor SDK to support any power mode.

    From your s2idle log, it seems the system is in sleep, now the question is how/what event to trigger resume.

  • Hi Bin Liu,

    Yes, that was my first question.  Maybe I give MCU WAKEUP GPIO a try?  Similar to 3.2.2.11.6. Wakeup Sources — Processor SDK AM62x Documentation.

    Regards,

    Harsha

  • Hi Harsha,

    You might first try to use RTC for wakeup:

    # rtcwake -m mem -s 5

    You might also want to measure the power consumption before "echo mem > /sys/power/state" and after entered s2idle, to see how much power it saves. If not much, it doesn't make sense to figure out wakeup events.

  • Hi Bin Liu,

    I have SK-AM64, which does not have RTC, so cannot use rtcwake option to wake up, but I do agree with measuring power consumption, will try that first.

    Regards,

    Harsha

  • Hi Bin Liu,

    On the SK-AM64, power consumption reduced from 3W to 1W after executing "echo mem > /sys/power/state".  So, only question is, does it support wakeup events to resume from s2idle case, for which I would need your input.

    Regards,

    Harsha

  • Hi Harsha,

    Any Low Power mode function has not been exercised in Processor SDK for AM64x. I don't know what could wake up from s2idle.

    What wakeup event do you plan to use in your project? So that I can check with our sw dev team.

  • Hi Bin Liu,

    We plan to use wakeup via GPIO.

    Regards,

    Harsha

  • Hi Harsha,

    Again, since don't exercise LPM on AM64x, I am not sure if this will work, but can you please try the instruction in the link below for MCU GPIO wakeup for AM62x to see if also works for s2idle on AM64x?

    https://software-dl.ti.com/processor-sdk-linux/esd/AM62X/09_02_01_09/exports/docs/linux/Foundational_Components/Kernel/Kernel_Drivers/Power_Management/pm_wakeup_sources.html#mcu-gpio

  • Hi Bin Liu,

    Tried using GPIO0_8 of MCU as wakeup:

    diff --git a/arch/arm64/boot/dts/ti/k3-am642-sk.dts b/arch/arm64/boot/dts/ti/k3-am642-sk.dts
    index de0ff5af5..73f4319a0 100644
    --- a/arch/arm64/boot/dts/ti/k3-am642-sk.dts
    +++ b/arch/arm64/boot/dts/ti/k3-am642-sk.dts
    @@ -231,6 +231,21 @@ led-7 {
     			gpios = <&exp2 7 GPIO_ACTIVE_HIGH>;
     		};
     	};
    +
    +	mcu_gpio_key {
    +		compatible = "gpio-keys";
    +		autorepeat;
    +		pinctrl-names = "default";
    +		pinctrl-0 = <&wake_mcugpio1_pins_default>;
    +		interrupt-parent = <&mcu_gpio0>;
    +		interrupts = <8 IRQ_TYPE_EDGE_RISING>;
    +		switch {
    +			label = "MCUGPIO";
    +			linux,code = <143>;
    +			gpios = <&mcu_gpio0 8 GPIO_ACTIVE_LOW>;
    +			wakeup-source;
    +		};
    +	};
     };
     
     &main_pmx0 {
    @@ -350,6 +365,14 @@ AM64X_IOPAD(0x00bc, PIN_INPUT, 7) /* (U8) GPIO0_46 */
     	};
     };
     
    +&mcu_pmx0 {
    +	wake_mcugpio1_pins_default: wake-mcugpio1-pins-default {
    +		pinctrl-single,pins = <
    +			AM64X_MCU_IOPAD(0x0020, PIN_INPUT, 7) /* (C7) MCU_GPIO0_8 */
    +		>;
    +	};
    +};
    +
     &main_uart0 {
     	status = "okay";
     	pinctrl-names = "default";
    @@ -387,9 +410,12 @@ exp2: gpio@60 {
     	};
     };
     
    -/* mcu_gpio0 is reserved for mcu firmware usage */
     &mcu_gpio0 {
    -	status = "reserved";
    +	status = "okay";
    +};
    +
    +&mcu_gpio_intr {
    +	status = "okay";
     };
     
     &sdhci0 {
    

    GPIO0_8 is pin 3 on SK-AM64 MCU connector.  When I short GPIO0_8 (pin 3) with pin 1 on MCU connector, I don't see wakeup trigger.

    root@am64xx-evm:~# cat /proc/interrupts | grep MCUGPIO
    318: 0 0 GPIO 8 Edge -davinci_gpio MCUGPIO

    Using gpio utilities:

    root@am64xx-evm:~# gpiodetect
    gpiochip0 [0-0070] (8 lines)
    gpiochip1 [4201000.gpio] (23 lines)
    gpiochip2 [600000.gpio] (87 lines)
    gpiochip3 [601000.gpio] (88 lines)

    I see MCU GPIO's are mapped to gpiochip1.  Below is output of gpioinfo command.

    gpiochip0 - 8 lines:
    line 0: "GPIO_CPSW2_RST" unused input active-high
    line 1: "GPIO_CPSW1_RST" unused input active-high
    line 2: "PRU_DETECT" unused input active-high
    line 3: "MMC1_SD_EN" "fixed-regulator-sd" output active-high [used]
    line 4: "VPP_LDO_EN" unused input active-high
    line 5: "RPI_PS_3V3_En" unused input active-high
    line 6: "RPI_PS_5V0_En" unused input active-high
    line 7: "RPI_HAT_DETECT" unused input active-high
    gpiochip1 - 23 lines:
    line 0: unnamed unused input active-high
    line 1: unnamed unused input active-high
    line 2: unnamed unused input active-high
    line 3: unnamed unused input active-high
    line 4: unnamed unused input active-high
    line 5: unnamed unused input active-high
    line 6: unnamed unused input active-high
    line 7: unnamed unused input active-high
    line 8: unnamed "MCUGPIO" input active-low [used]
    line 9: unnamed unused input active-high
    line 10: unnamed unused input active-high
    line 11: unnamed unused input active-high
    line 12: unnamed unused input active-high
    line 13: unnamed unused input active-high
    line 14: unnamed unused input active-high
    line 15: unnamed unused input active-high
    line 16: unnamed unused input active-high
    line 17: unnamed unused input active-high
    line 18: unnamed unused input active-high
    line 19: unnamed unused input active-high
    line 20: unnamed unused input active-high
    line 21: unnamed unused input active-high
    line 22: unnamed unused input active-high

    When I try to read GPIO status from gpioget, it throws an error:

    root@am64xx-evm:~# gpioget 1 8
    gpioget: error reading GPIO values: Device or resource busy

    I believe since gpioget and gpioset are failing from main domain, mcu wakeup is also not detected.

    Regards,

    Harsha

  • Hi Harsha,

    Once a GPIO pin is defined as "gpio-keys" in device tree, the GPIO is then used by the gpio-keys driver, you cannot use user space gpio* commands on this pin. You just need to manually drive the pin to 3.3v or GND to trigger interrupts. Hopefully its interrupt can wakeup from s2idle.

  • GPIO0_8 is pin 3 on SK-AM64 MCU connector.  When I short GPIO0_8 (pin 3) with pin 1 on MCU connector, I don't see wakeup trigger.

    The schematics shows GPIO0_8 is pin5 on MCU connector, isn't it?

  • Hi Bin Liu,

    Sorry for the earlier typo on my part on GPIO0_8 pin, I am working with pin 5 on MCU connector.  I connected pin 5 to pin 1, I don't see wakeup trigger, and on pin 1, I see 3.3V.

    Regards,

    Harsha

  • Hi Harsha,

    Can you please try to connect pin 5 to pin 2 which is GND to see if it triggers the wakeup event?

  • Hi Bin Liu,

    Wakeup event is detected on rising edge, it is triggering after I remove connection between pin 5 and 2 (or 27), but detection was intermittent, works only 2 out of 5 times.  I connected a weak pull up of 12K between pin 1 and 5, and added debounce-interval of 20ms in DTS file, post which detection is consistent, on every rising edge, I see system is trying to resume.  On system resume, I encountered 3 failures:

    1. Failure by CDNS driver startup:

    [   36.778243] PM: suspend entry (s2idle)
    [   36.782421] Filesystems sync: 0.000 seconds
    [   36.795424] Freezing user space processes
    [   36.801888] Freezing user space processes completed (elapsed 0.002 seconds)
    [   36.808934] OOM killer disabled.
    [   36.812223] Freezing remaining freezable tasks
    [   36.817738] Freezing remaining freezable tasks completed (elapsed 0.001 seconds)
    [   36.860205] am65-cpsw-nuss 8000000.ethernet eth1: Link is Down
    [   41.604686] am65-cpsw-nuss 8000000.ethernet: set new flow-id-base 16
    [   41.620992] am65-cpsw-nuss 8000000.ethernet eth0: PHY [8000f00.mdio:00] driver [TI DP83867] (irq=POLL)
    [   41.630353] am65-cpsw-nuss 8000000.ethernet eth0: configuring for phy/rgmii-rxid link mode
    [   41.645383] am65-cpsw-nuss 8000000.ethernet eth1: PHY [8000f00.mdio:01] driver [TI DP83867] (irq=POLL)
    [   41.654704] am65-cpsw-nuss 8000000.ethernet eth1: configuring for phy/rgmii-rxid link mode
    [   41.663463] Internal error: synchronous external abort: 0000000096000010 [#1] PREEMPT SMP
    [   41.671634] Modules linked in: wl18xx wlcore mac80211 libarc4 cfg80211 rfkill pru_rproc irq_pruss_intc icss_iep crct10dif_ce wlcore_sdio ti_k3_r5_remoteproc ti_k3_m4_remoteproc ti_k3_common sa2ul lm75 pruss omap_mailbox pwm_tiecap optee_rng rng_core fuse drm drm_panel_orientation_quirks ipv6
    [   41.703489] Hardware name: Texas Instruments AM642 SK (DT)
    [   41.708962] pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
    [   41.715912] pc : cdns_power_is_lost+0x1c/0x50
    [   41.720276] lr : cdns3_controller_resume.isra.0+0x48/0x154
    [   41.725757] sp : ffff80000af73a80
    [   41.729061] x29: ffff80000af73a80 x28: ffff000002ee4cf8 x27: ffff800009a84238
    [   41.736190] x26: ffff8000092764d8 x25: ffff80000990f31c x24: ffff800009b39e60
    [   41.743318] x23: 0000000000000010 x22: ffff000000f0ec90 x21: 0000000000000010
    [   41.750448] x20: 0000000000000000 x19: ffff0000033c7c80 x18: ffffffffffffffff
    [   41.757576] x17: 2d69696d67722f79 x16: 687020726f662067 x15: 6e6972756769666e
    [   41.764704] x14: 6f63203a31687465 x13: 65646f6d206b6e69 x12: 6c20646978722d69
    [   41.771833] x11: 0000000000000040 x10: ffff80000997fe10 x9 : ffff800008a727c8
    [   41.778962] x8 : ffff80000af739d8 x7 : 0000000000000000 x6 : 0000000000000815
    [   41.786090] x5 : 0000000000000815 x4 : 0000000000000000 x3 : ffff800008fe2800
    [   41.793219] x2 : 0000000000000001 x1 : 0000000000000001 x0 : ffff80000acd0040
    [   41.800347] Call trace:
    [   41.802784]  cdns_power_is_lost+0x1c/0x50
    [   41.806789]  cdns3_plat_resume+0x20/0x2c
    [   41.810707]  platform_pm_resume+0x34/0x70
    [   41.814714]  dpm_run_callback+0x38/0x170
    [   41.818632]  device_resume+0x90/0x1c0
    [   41.822287]  dpm_resume+0x100/0x350
    [   41.825771]  dpm_resume_end+0x20/0x40
    [   41.829426]  suspend_devices_and_enter+0x1cc/0x7f0
    [   41.834212]  pm_suspend+0x284/0x310
    [   41.837694]  state_store+0x94/0x120
    [   41.841176]  kobj_attr_store+0x18/0x30
    [   41.844922]  sysfs_kf_write+0x4c/0x5c
    [   41.848579]  kernfs_fop_write_iter+0x120/0x1b0
    [   41.853014]  vfs_write+0x2bc/0x360
    [   41.856414]  ksys_write+0x74/0x10c
    [   41.859811]  __arm64_sys_write+0x24/0x30
    [   41.863729]  invoke_syscall+0x50/0x120
    [   41.867474]  el0_svc_common.constprop.0+0xdc/0x100
    [   41.872259]  do_el0_svc+0x38/0xe0
    [   41.875570]  el0_svc+0x2c/0x84
    [   41.878624]  el0t_64_sync_handler+0xbc/0x140
    [   41.882889]  el0t_64_sync+0x18c/0x190
    [   41.886552] Code: d503233f 35000181 f9406c00 91010000 (b9400000)
    [   41.892633] ---[ end trace 0000000000000000 ]---
    [   43.698549] am65-cpsw-nuss 8000000.ethernet eth1: Link is Up - 100Mbps/Full - flow control rx/tx

    2. Failure by LM75 and OMAP I2C driver startup:

    [   34.814346] PM: suspend entry (s2idle)
    [   34.818526] Filesystems sync: 0.000 seconds
    [   34.825542] Freezing user space processes
    [   34.835625] Freezing user space processes completed (elapsed 0.002 seconds)
    [   34.842683] OOM killer disabled.
    [   34.845974] Freezing remaining freezable tasks
    [   34.851814] Freezing remaining freezable tasks completed (elapsed 0.001 seconds)
    [   34.892285] am65-cpsw-nuss 8000000.ethernet eth1: Link is Down
    [   39.825683] omap_i2c 20010000.i2c: controller timed out
    [   39.831012] lm75 0-0048: PM: dpm_run_callback(): lm75_resume+0x0/0x50 [lm75] returns -110
    [   39.839229] lm75 0-0048: PM: failed to resume async: error -110
    [   40.881660] omap_i2c 20010000.i2c: controller timed out
    [   40.886923] pca953x 0-0070: Unable to sync register 0x3. -110
    [   40.892673] pca953x 0-0070: Failed to sync GPIO dir registers: -110
    [   40.898939] pca953x 0-0070: PM: dpm_run_callback(): pca953x_resume+0x0/0x22c returns -110
    [   40.907130] pca953x 0-0070: PM: failed to resume async: error -110
    [   41.937661] omap_i2c 20010000.i2c: controller timed out
    [   41.942891] lm75 0-0049: PM: dpm_run_callback(): lm75_resume+0x0/0x50 [lm75] returns -110
    [   41.951082] lm75 0-0049: PM: failed to resume async: error -110
    [   60.561673] rcu: INFO: rcu_preempt detected expedited stalls on CPUs/tasks: { 0-.... } 5439 jiffies s: 201 root: 0x1/.
    [   60.572402] rcu: blocking rcu_node structures (internal RCU debug):
    [   60.578669] Task dump for CPU 0:
    [   60.581899] task:swapper/0       state:R  running task     stack:0     pid:0     ppid:0      flags:0x0000000a
    [   60.591814] Call trace:
    [   60.594266]  __switch_to+0xf0/0x170
    [   60.597768]  0xffed080c

    For now, I worked around CDNS and LM75 drivers by unloading their respective kernel modules before issuing sleep command, whereas I still see OMAP I2C timing out on resume:

    [   43.227138] PM: suspend entry (s2idle)
    [   43.520922] Filesystems sync: 0.289 seconds
    [   43.527331] Freezing user space processes
    [   43.534205] Freezing user space processes completed (elapsed 0.002 seconds)
    [   43.541295] OOM killer disabled.
    [   43.544535] Freezing remaining freezable tasks
    [   43.550373] Freezing remaining freezable tasks completed (elapsed 0.001 seconds)
    [   43.564270] am65-cpsw-nuss 8000000.ethernet eth1: Link is Down
    [   48.530497] omap_i2c 20010000.i2c: controller timed out
    [   48.535772] pca953x 0-0070: Unable to sync register 0x3. -110
    [   48.541532] pca953x 0-0070: Failed to sync GPIO dir registers: -110
    [   48.547798] pca953x 0-0070: PM: dpm_run_callback(): pca953x_resume+0x0/0x22c returns -110
    [   48.555996] pca953x 0-0070: PM: failed to resume async: error -110
    [   68.754480] rcu: INFO: rcu_preempt detected expedited stalls on CPUs/tasks: { 0-.... } 5311 jiffies s: 201 root: 0x1/.
    [   68.765190] rcu: blocking rcu_node structures (internal RCU debug):
    [   68.771458] Task dump for CPU 0:
    [   68.774686] task:swapper/0       state:R  running task     stack:0     pid:0     ppid:0      flags:0x0000000a
    [   68.784601] Call trace:
    [   68.787053]  __switch_to+0xf0/0x170
    [   68.790555]  0xffed080c

    When comparing k3-am62-main.dtsi and k3-am64-main.dtsi, I see both use same drivers for I2C1, so have you encountered such failures from OMAP I2C driver after exiting sleep / low power mode in AM62 boards?

    Regards,

    Harsha

  • Harsha,

    Wakeup event is detected on rising edge, it is triggering after I remove connection between pin 5 and 2 (or 27), but detection was intermittent, works only 2 out of 5 times.  I connected a weak pull up of 12K between pin 1 and 5, and added debounce-interval of 20ms in DTS file, post which detection is consistent, on every rising edge, I see system is trying to resume. 

    This is great progress!

    When comparing k3-am62-main.dtsi and k3-am64-main.dtsi, I see both use same drivers for I2C1, so have you encountered such failures from OMAP I2C driver after exiting sleep / low power mode in AM62 boards?

    It appears the the i2c failure is not caused by the i2c controller but the i2c device - pca953x driver. SK-AM64 and SK-AM62 use different I/O expander devices, so different i2c device drivers are used for both boards. It seems the pca953x driver doesn't support suspend/resume.