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.

Linux/PROCESSOR-SDK-AM335X: RTC only mode not working

Part Number: PROCESSOR-SDK-AM335X
Other Parts Discussed in Thread: TPS65910, TPS65217, TPS65218, TPS650250

Tool/software: Linux

Hi

We are working on latest TI SDK  ti-am335x-03.02.00.05 and using a custom am335x hardware.

We have a use case in which when the board enters RTC only mode,it should undergo full boot after the time specified by rtcwake command.

We have migrated from the Old SDK 7 to the latest one. In SDK 7 we are having a working RTC-only mode where the current drops upto 10mA when we give rtcwake -d /dev/rtc0 -m standby -s 5.

At this moment the PMIC_POWER_EN bit becomes zero and current drops upto 10mA.

But this is not happening in our latest SDK.

We need the same thing working in the new SDK.

We have done the following changes:

1)This is our configuration in the dtsi file:


&rtc {
        clocks = <&clk_32768_ck>, <&clkdiv32k_ick>;
        clock-names = "ext-clk", "int-clk";
        system-power-controller;
};

&tps {
        /*
         * Configure pmic to enter OFF-state instead of SLEEP-state ("RTC-only
         * mode") at poweroff.  Most BeagleBone versions do not support RTC-only
         * mode and risk hardware damage if this mode is entered.
         *
         * For details, see linux-omap mailing list May 2015 thread
         *      [PATCH] ARM: dts: am335x-bone* enable pmic-shutdown-controller
         * In particular, messages:
         *      www.spinics.net/.../msg118585.html
         *      www.spinics.net/.../msg118615.html
         *
         * You can override this later with
         *      &tps {  /delete-property/ ti,pmic-shutdown-controller;  }
         * if you want to use RTC-only mode and made sure you are not affected
         * by the hardware problems. (Tip: double-check by performing a current
         * measurement after shutdown: it should be less than 1 mA.)
         */

/*      ti,pmic-shutdown-controller;*/           /*Commenting   ti,pmic-shutdown-controller  */

2) In RTC OMAP Driver:

We have added omap_rtc_power_off() inside omap_rtc_suspend . But still this is not working.

static int omap_rtc_suspend(struct device *dev)
{

        struct omap_rtc *rtc = dev_get_drvdata(dev);
       printk(KERN_INFO   "***omap_rtc_suspend***\n");
        rtc->interrupts_reg = rtc_read(rtc, OMAP_RTC_INTERRUPTS_REG);
        rtc->type->unlock(rtc);
        /*
         * FIXME: the RTC alarm is not currently acting as a wakeup event
         * source on some platforms, and in fact this enable() call is just
         * saving a flag that's never used...
         */
        if (device_may_wakeup(dev))
                enable_irq_wake(rtc->irq_alarm);
        else
                rtc_write(rtc, OMAP_RTC_INTERRUPTS_REG, 0);
        rtc->type->lock(rtc);
        rtc->is_suspending = true;
omap_rtc_power_off();      /*Added to power off */
return 0;

We are getting  the following logs:

root@ngt:~# rtcwake -d /dev/rtc0 -m standby -s 5
[   43.813401] ***omap_rtc_alarm_irq_enable***
wakeup from "standby" at Sat Jan  1 00:00:49 2000
[   43.979218] PM: Syncing filesystems ... done.
[   43.986685] Freezing user space processes ... (elapsed 0.001 seconds) done.
[   43.995229] Freezing remaining freezable tasks ... (elapsed 0.001 seconds) done.
[   44.004306] Suspending console(s) (use no_console_suspend to debug)
[   44.119603] ***omap_rtc_suspend***
[   44.119618] ***omap_rtc_power_off***
[   44.119631] ***omap_rtc_power_off_program***
[   44.119642] ****The value of OMAP_RTC_PMIC_REG is ****10011
[   44.119647] System will go to power_off state in approx. 1 second
[   47.114778] rtc_power_off failed, bailing out.
[   47.115155] PM: suspend of devices complete after 3102.994 msecs
[   47.117446] PM: late suspend of devices complete after 2.264 msecs
[   47.119423] ***omap_rtc_runtime_suspend***
[   47.119997] PM: noirq suspend of devices complete after 2.528 msecs
[   47.120003] PM: Successfully put all powerdomains to target state
[   47.122669] PM: noirq resume of devices complete after 2.555 msecs
[   47.122801] ***rtc_irq***
[   47.122862] ***omap_rtc_alarm_irq_enable***
[   47.124866] PM: early resume of devices complete after 1.950 msecs
[   47.125447] ***omap_rtc_resume***
[   47.295700] PM: resume of devices complete after 170.804 msecs
[   47.381898] Restarting tasks ... done.
[   47.400425] ***omap_rtc_alarm_irq_enable

Can anyone please give some suggestion


 

  • Hi Deshvir,

    Which PMIC you are using in your AM335x custom board? Whether or not your board enters RTC-Only mode depends on the regulator configuration and whether or not the regulator that supplies the DDR is configured to remain on during suspend. This is supported by the TPS65218, but not the TPS65217 or TPS65910.

    Another important thing to make sure of is that you are using the proper u-boot. A certain u-boot is required in order to support RTC-Onlymode otherwise the following message appears during boot of the kernel:

    PM: bootloader does not support rtc-only!

    See also if the below pointers will be in help:

    e2e.ti.com/.../395613
    e2e.ti.com/.../556431
    e2e.ti.com/.../590685

    processors.wiki.ti.com/.../AM335x_Schematic_Checklist

    https://e2e.ti.com/support/arm/sitara_arm/f/791/t/266741


    Regards,
    Pavel

  • Hi Pavel,

    I'm using TPS650250QRHBRQ1 PMIC and RTC-only mode was supported by this PMIC in ti-sdk-am335x-evm-07.00.00.00. but currently it's not working in ti-am335x-03.02.00.05.

    We are also getting below error as mentioned by you.

    PM: bootloader does not support rtc-only!

    Thanks and Regards

    Deshvir Malik

  • Deshvir Malik said:
    I'm using TPS650250QRHBRQ1 PMIC and RTC-only mode was supported by this PMIC in ti-sdk-am335x-evm-07.00.00.00

    SDK7 is based on kernel 3.12, and there is no RTC-Only support in the 3.12 wiki:

    http://processors.wiki.ti.com/index.php/Linux_Core_Power_Management_User's_Guide_%28v3.12%29

    Could you provide me console log how exactly you enter/exit from RTC-Only mode in SDK7?


    Also TPS650250 do not support RTC-Only mode, you need to have external LDO to power supply CAP_VDD_RTC and VDDS_RTC. Do you have external LDO (external power source) in your custom board?

    e2e.ti.com/.../1087651

    Regards,
    Pavel

  • 3247.working_rtc_log.txtHi Pavel,

    1. Attached working_rtc_log.txt is the log file of working rtc-only mode in kernel 3.12

    2. Conditions to enter into rtc-only mode are given in below schematic and we are satisfying all the preconditions to make the status of EXT_WAKEUP as 0.

    3. Yes we have external LDO connected to power supply.

    4. We also modified the rtc driver /driver/rtc/rtc_omap.c. I'm attaching the modified rtc driver file. Two functions were modified omap_rtc_suspend() and added rtc_power_off().

    4251.rtc-omap.c

    Thanks and Regards,

    Deshvir Malik

  • This is the schematic mentioned in the point no. 2 in above post.

    Regards

    Deshvir Malik

  • Hi Pavel,

    Sorry I forgot to add one very important thing.

    In the below schematic, after satisfying all the preconditions to make external wakeup (EXT_WAKEUP) 0, we can enter into rtc-only mode by giving command rtcwake -d /dev/rtc0 -m standby -s 10 or  rtcwake -d /dev/rtc0 -m mem -s 10. After giving rtcwake command, PMIC_PWR_EN goes to 0 for few seconds and then board restarts.

    But PMIC_PWR_EN is not going to 0 after giving rtcwake command in kernel 4.4, though we are satisfying all the preconditions to make EXT_WAKEUP 0 .

    Below is the schematic

    Thanks and Regards

    Deshvir Malik

  • Deshvir,

    rtc-only is not supported in kernel 3.12 (SDK7), and I am not sure if you were able to port/enable this feature there. But your main request is regarding linux 4.4 (PSDK 3.02) rtc-only mode usage, so let us focus there.

    Note that in kernel 4.4 we have rtc-only support added in some files (this is missing in SDK7 kernel 3.12):

    linux-4.4.32/arch/arm/mach-omap2/sleep43xx.S

    linux-4.4.32/drivers/soc/ti/pm33xx.c
    linux-4.4.32/include/linux/platform_data/pm33xx.h

    linux-4.4.32/drivers/soc/ti/wkup_m3_ipc.c
    linux-4.4.32/include/linux/wkup_m3_ipc.h


    First you should enable rtc-only in u-boot, use CONFIG_SPL_RTC_ONLY_SUPPORT, see u-boot-2016.05/arch/arm/cpu/armv7/am33xx/board.c and clock.c

    In the Linux Core Power Management wiki v4.4, the below sequence should be used to enter RTC-Only mode:

    $ echo 1 > /sys/kernel/debug/pm_debug/enable_off_mode
    $ rtcwake -s 10 -d /dev/rtc0 -m mem

    Please try with these two commands and let me know the result.

    You can also try to enter RTC-Only mode via poweroff command:

    $ poweroff

    To wakeup from RTC-Only mode via an RTC alarm, a separate tool must be used to program an RTC alarm prior to entering poweroff.

    Regards,
    Pavel
  • Hi Pavel,

    We enabled CONFIG_SPL_RTC_ONLY_SUPPORT in defconfig "am335x_evm_defconfig", we are getting compilation errors from u-boot-2016.05/arch/arm/cpu/armv7/am33xx/board.c and clock.c

    This is the the change done in defconfig.

    CONFIG_SYS_EXTRA_OPTIONS="NAND,SPL_RTC_ONLY_SUPPORT"

    Could you let me know the changes to be done in board.c and clock.c . If you have patches, could you please provide to me.

    Thanks and Regards

    Deshvir Malik

  • Deshvir,

    Deshvir Malik said:

    We enabled CONFIG_SPL_RTC_ONLY_SUPPORT in defconfig "am335x_evm_defconfig", we are getting compilation errors from u-boot-2016.05/arch/arm/cpu/armv7/am33xx/board.c and clock.c

    This is the the change done in defconfig.

    CONFIG_SYS_EXTRA_OPTIONS="NAND,SPL_RTC_ONLY_SUPPORT"

    Please update only u-boot-2016.05/arch/arm/cpu/armv7/am33xx/board.c file:

    + #define CONFIG_SPL_RTC_ONLY_SUPPORT

    Then check (with CCS HW breakpoint or with printf) that your flow will go though rtc_only(void) function.

    Note that this approach (enable rtc only support in u-boot) might be valid only for AM43xx device. I will check that with the PRCM team. Meanwhile you can try with this approach.

    One more approach is to work with poweroff command. You need to program an RTC alarm prior to entering poweroff.

    Regards,
    Pavel

  • Hi Pavel,

    I have a doubt regarding enabling RTC only in bootloader for am335x...We see CONFIG_SPL_RTC_ONLY_SUPPORT for am43x ..

    In the file arch/arm/cpu/armv7/am33xx/board.c

    function update_rtc_magic()  we are writing to RTC_SCRATCH1 register. 

     First 16 bits (0:15) are written with RTC_MAGIC value. Once the control gets to kernel, kernel reads the scratchpad register and gets to know that bootloader has rtc_only support.


    Second important thing is the board type  (16:31).

    In writing to (16:31) bit of RTC_SCRATCH1  it checks for rtc_only_get_board_type(). 


    What should we write for am335x ?

    Is it possible to make it work?

    Thanks

    Deep

  • Deep,

    Looks like these functions (rtc_only_get_board_type(), rtc_only_update_board_type(), rtc_only_enable_basic_clocks()) are specific for AM437x device only, can not be used for AM335x. I asked out PRCM team about that, still waiting for feedback.

    Meanwhile I would suggest you to work on the below approach:

    Use poweroff command, program an RTC alarm prior to entering poweroff.

    Regards,
    Pavel
  • The below e2e threads discuss poweroff + rtc only usage, please have a look, might be in help:

    e2e.ti.com/.../511852
    e2e.ti.com/.../332913
    e2e.ti.com/.../556431
    e2e.ti.com/.../266741

    e2e.ti.com/.../418774
  • Hi Pavel

    Use poweroff command, program an RTC alarm prior to entering poweroff.


    poweroff command I understood..How to program the RTC alarm prior turning off

    Thanks

    Deep

  • Deep,

    Once you are inside RTC-only mode, you can go back to active mode through EXT_WAKEUP input pin (connected to push button or interrupt source) OR through RTC ALARM event.

    Programmable ALARM event can be used with external output (PMIC_POWER_EN) to enable the PMIC to restore non-RTC power domains. The PMIC_POWER_EN output is turned on by ALARM event or EXT_WAKEUP event.

    You need to configure the RTCSS (base address 0x44E3E000) ALARM registers (see also RTC_SATUS[6] and RTC_PMIC[16] bits) from user space application or tool (like rtcwake tool). See AM335x TRM, chapter 20.3 RTC_SS. System software should configure this ALARM event before poweroff. To set up ALARM event modify ALARM_x registers for the exact time you want alarm to generate. The RTC will generate a wake-up event and turn on power to the device after the predetermined time has lapsed.

    See also:

    e2e.ti.com/.../507774

    Regarding rtc-only support in u-boot, see the below PDF, section 3.1.2 Configuring U-Boot

    www.ti.com/.../sprac74a.pdf

    Regards,
    Pavel
  • Hi Pavel,

    Thanks for the document. I will read it and let you know.

    Thanks

    Deep

  • Deep,

    See also the below files:

    linux-kernel/Documentation/rtc.txt
    linux-kernel/Documentation/devicetree/bindings/rtc/rtc-omap.txt

    Regards,
    Pavel
  • Hi Pavel,

    rtcwake -d /dev/rtc0 -m poweroff -s 10 is working..It is making the board to poweroff.

    The issue is that when we issue  rtcwake -d /dev/rtc0 -m mem -s 10  command the board should be in RTC-ONLY mode in 10s and at that moment the current should drop to 10ms. If the board doest not get any external interrupt from the EXT_WAKE it should restart. This is not happening in our case. PMIC_PWR_EN is not going low.

    Thanks

    Deep

  • deep ter said:
    The issue is that when we issue  rtcwake -d /dev/rtc0 -m mem -s 10  command the board should be in RTC-ONLY mode

    Why do you think so? From where you get this information? What makes you think this command should put your board in rtc-only (not in DeepSleep) mode?

    Regards,
    Pavel

  • Hi Pavel,

    When we give rtcwake -d /dev/rtc0 -m mem -s 10  the PWR_EN bit should be low as the DDR should not get supply.

    We need the same type of working as described in the  .

    This was done in SDK 7. We tried to implement the same. But it is not working for us.

    We need that current should go under 15mA when  we give  rtcwake -d /dev/rtc0 -m mem -s 10.  And it should restart if there is no external wakeup. It means after  10s PMIC_PWR_EN bit should toggle.

    This is our use case

    Thanks

  • Deep,

    deep ter said:
    When we give rtcwake -d /dev/rtc0 -m mem -s 10  the PWR_EN bit should be low as the DDR should not get supply.

    I can not find PWR_EN bit in AM335x TRM. Do you mean RTC_PMIC[16] PWR_ENABLE_EN bit?

    By default "rtcwake -d /dev/rtc0 -m mem -s 10" command makes the AM335x device to enter into DeepSleep0 mode, not RTC-only mode. What changes you have done so far in PSDK 3.02 to make this command enter RTC-only mode?

    Once you enter the low power mode (DeepSleep0/mem or RTC-Only), how do you verify on which mode you are exactly?

    For being in RTC-Only mode, you need to make sure:

     - VDD_MPU is OFF (0V)

     - VDD_CORE is OFF (0V)

    - PD_WKUP is OFF

    - DDR is NOT in self-refresh

    - PMIC_POWER_EN pin is low (0),

    - RTC_PMIC[16] PWR_ENABLE_EN is 1

    See also the below wiki:

    processors.wiki.ti.com/.../AM335x_StarterWare_Power_management

    Regards,
    Pavel

  • Hi Pavel,

    I was referring to PMIC_PWR_EN signal from the processor. Sorry for creating a confusion.

    Yes,this signal should go low for entering RTC only mode.

    Once PMIC_PWR_EN goes low..VDD_MPU,VDD_CORE will go low as you can see from the schematics.

    We are measuring current and PMIC_PWR_EN signal to check the RTC Only mode. 

    In PSDK 3.02 , i have added rtc_power_off() inside  omap_rtc_suspend(). But still it is not turning off and it is comping out of suspend state.

    Same process was followed by . In this thread also..in suspend function rtc_power_off is being called.

    Also how to check that  DDR is NOT in self-refresh and  PD_WKUP is off?

    Please suggest us so that we can make RTC only to work.

    Thanks

  • Dear Deep Ter,

    Let start with definition for entering in self-refresh mode: The DDR2/3/mDDR memory controller supports self-refresh mode for low power. The memory controller automatically puts the SDRAM into self-refresh after the memory controller is idle for REG_SR_TIM
    number of DDR clock cycles and the REG_LP_MODE field is set to 2. The REG_LP_MODE and REG_SR_TIM fields can be programmed in the Power Management Control register(PMCR).

    Q: Also how to check that DDR is NOT in self-refresh and PD_WKUP is off?

    A: Take attention to the registers described in section: 7.3.3.12.2 Self-Refresh Mode - In self-refresh mode, the memory controller automatically stops the clocks DDR_CLK to the SDRAM. The memory controller maintains DDR_CKE low to maintain the self-refresh state. When the SDRAM is in selfrefresh, the memory controller services register accesses as normal. If the REG_LP_MODE field is set not equal to 2, or an SDRAM access is requested while it is in self-refresh, and T_CKE + 1 cycles have elapsed since the SELF-REFRESH command was issued, the memory controller will bring the SDRAM out of self-refresh.

    In other words check the state of DDR_CKE. It must be high, by exeting from self-refresh mode
    For checking the state of PD_WKUP please observe the state of the listed registers:
    PM_WKUP_PWRSTCTRL[4] LowPowerStateChange - Power state change request when domain has already performed asleep transition.
    Allows going into deeper low power state without waking up the
    power domain.
    0x0 = DIS : Do not request a low power state change.
    0x1 = EN : Request a low power state change. This bit is
    automatically cleared when the power state is effectively changed or
    when power state is ON.
    PM_WKUP_PWRSTST - This register provides a status on the current WKUP power domain state.

    Did you see this application note  during the design of your custome board, HW?

    I assume that the power options such as  omap_rtc_suspend() and rtc_power_off() are desined to be used with PMIC TPS65217x. Please take a look in https://patchwork.ozlabs.org/patch/403663/


    Best regards,
    Yanko

  • deep ter said:

    I was referring to PMIC_PWR_EN signal from the processor. Sorry for creating a confusion.

    Yes,this signal should go low for entering RTC only mode.

    Once PMIC_PWR_EN goes low..VDD_MPU,VDD_CORE will go low as you can see from the schematics.

    Could you please also confirm that PMIC_POWER_EN pin is 1 during active mode, and then make transition from 1 to 0 after executing "rtcwake -d /dev/rtc0 -m mem -s 10" command? You should measure this signal/pin with scope.

    Regards,
    Pavel

  • Hi Pavel

    PMIC_POWER_EN is 1 during active mode...but it is not making transition from 1 to 0 after executing the above rtcwake -d /dev/rtc0 -m -s 10 command. It remains high. This means PMIC_POWER_EN is not going low with this command.

    Thanks
    Deep
  • Deep,

    In SDK7, could you please confirm that PMIC_POWER_EN pin is 1 during active mode, and then make transition from 1 to 0 after executing "rtcwake -d /dev/rtc0 -m mem -s 10" command? You should measure this signal/pin with scope.

    If yes, can you make RTC registers dump in SDK7 and PSDK 3.02 (make that register dump just before executing rtcwake command), and check if there are differences in the registers settings?

    Regards,
    Pavel
  • Hi Pavel,

    In SDK7 PMIC_POWER_EN pin is 1 during active mode, and then make transition from 1 to 0 after executing "rtcwake -d /dev/rtc0 -m mem -s 10" command.
    We can check the register dump after executing rtcwake command in both the SDK. I will check and let you know.

    Thanks for your reply
    Deep
  • Deep,

    I suspect there will be differences in RTC module registers settings between SDK7 and PSDK3.02, mainly in RTC_STATUS_REG, RTC_INTERRUPTS_REG, RTC_PMIC and ALARM2 registers. You can investigate in that direction.

    Regards,
    Pavel