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/AM3352: Device tree settings for TPS65910 RTC

Part Number: AM3352
Other Parts Discussed in Thread: TPS65910,

Tool/software: Linux

I am working on a design with AM3352 and TPS65910 PMIC.   I am looking for the LInux device tree configuration to load the tps65910-rtc driver at boot.

I can get the driver to load after booting the system with

# modprobe rtc-tps65910

Then I can see it as rtc1.

[ 59.357679] tps65910-rtc tps65910-rtc: rtc core: registered tps65910-rtc as rtc1
# cat /sys/class/rtc/rtc1/time
00:02:48

Is there a way to get this to load automatically by changing the device tree?

Some additional background information

The system was designed to use the PMIC RTC during standby and when sitara is powered off instead of the AM3352 RTC.

The TPS65910 is using the internal 32-kHz RC oscillator.

The AM3352 RTC is needed when Linux is running.   It is assigned rtc0 at boot automatically.  It needs to be the system-power-controller so ALARM2 can control PMIC_POWER_EN for the poweroff command.  This is working currently.

A related thread is

e2e.ti.com/.../407269

  • Hello Aaron,

    If you just want to automatically load the tps65910-rtc driver at boot, execute this command on your target board:
    echo rtc-tps65910 > /etc/modules-load.d/rtc-tps65910.conf

    Best regards,
    Kemal

  • That changed the order of loading so rtc0 is tps65910-rtc and rtc1 is omap_rtc. Can I ensure that they are always loaded in the same order so I can just use rtc1 and rtc0 in boot scripts and know which driver it refers to?

    # dmesg | grep rtc
    [ 1.285360] vrtc: supplied by vbat
    [ 1.403947] hctosys: unable to open rtc device (rtc0)
    [ 3.493050] tps65910-rtc tps65910-rtc: Enabling rtc-tps65910.
    [ 3.501514] rtc rtc0: tps65910-rtc: dev (253:0)
    [ 3.501557] tps65910-rtc tps65910-rtc: rtc core: registered tps65910-rtc as 0
    [ 6.331188] omap_rtc 44e3e000.rtc: omap_rtc_probe: rtc is_pmic_controller
    [ 6.371432] rtc rtc1: 44e3e000.rtc: dev (253:1)
    [ 6.371448] omap_rtc 44e3e000.rtc: rtc core: registered 44e3e000.rtc as rtc1

  • I just noticed the error hctosys: unable to open rtc device (rtc0)

    I would like to see tps6910-rtc loaded earlier as rtc0 so hctosys can use it. I assumed that would be accomplished by the device tree. If that isn't the I need to have hctosys load after tps65910-rtc. That would load the system time from the PMIC rtc at boot, correct?
  • Please, see this post.

  • Thanks that is useful for setting the load order of the rtc.

    I think there still may be an issue with the device tree. When I try to set the tps65910-rtc hw clock from system time the command hangs.

    # dmesg | grep 'as rtc'
    [ 3.501557] tps65910-rtc tps65910-rtc: rtc core: registered tps65910-rtc as rtc0
    [ 6.371448] omap_rtc 44e3e000.rtc: rtc core: registered 44e3e000.rtc as rtc1

    # date --set="27 JAN 2018 10:09"
    Sat Jan 27 10:09:00 UTC 2018
    # hwclock -f /dev/rtc1 -w
    # cat /sys/class/rtc/rtc1/time
    10:09:24
    # hwclock -f /dev/rtc0 -w <--------------------- this command hangs
    ^C
    # cat /sys/class/rtc/rtc0/time
    01:08:29


    Here is the tree node for the TPS65910:
    &tps {
    reg = <0x2d>;
    interrupt-parent = <&intc>;
    interrupts = < 0 118 0x04 >;

    #gpio-cells = <2>;
    gpio-controller;

    #interrupt-cells = <2>;
    interrupt-controller;

    ti,en-ck32k-xtal;

    vcc1-supply = <&vbat>;
    vcc2-supply = <&vbat>;
    vcc3-supply = <&vbat>;
    vcc4-supply = <&vbat>;
    vcc5-supply = <&vbat>;
    vcc6-supply = <&vbat>;
    vcc7-supply = <&vbat>;
    vccio-supply = <&vbat>;

    regulators {
    vrtc_reg: regulator@0 {
    regulator-always-on;
    };

    vio_reg: regulator@1 {
    regulator-name = "vio,vdds_ddr";
    regulator-always-on;
    };

    vdd1_reg: regulator@2 {
    /* VDD_MPU voltage limits 0.95V - 1.325V with +/-4% tolerance */
    regulator-name = "vdd_mpu,vdd1";
    regulator-min-microvolt = <925000>;
    regulator-max-microvolt = <1378000>;
    regulator-boot-on;
    regulator-always-on;
    };

    vdd2_reg: regulator@3 {
    /* VDD_CORE voltage limits 1.056V - 1.144V with +/-4% tolerance */
    regulator-name = "vdd_core";
    regulator-min-microvolt = <1056000>;
    regulator-max-microvolt = <1144000>;
    regulator-boot-on;
    regulator-always-on;
    };

    vdd3_reg: regulator@4 {
    regulator-always-off;
    };

    vdig1_reg: regulator@5 {
    regulator-always-on;
    };

    vdig2_reg: regulator@6 {
    regulator-always-on;
    };

    vpll_reg: regulator@7 {
    regulator-always-on;
    };

    vdac_reg: regulator@8 {
    regulator-always-on;
    };

    vaux1_reg: regulator@9 {
    regulator-always-on;
    };

    vaux2_reg: regulator@10 {
    regulator-always-on;
    };

    vaux33_reg: regulator@11 {
    regulator-always-on;
    };

    vmmc_reg: regulator@12 {
    regulator-min-microvolt = <1800000>;
    regulator-max-microvolt = <3300000>;
    regulator-always-on;
    };
    };
    };
  • I found that the command that I said hangs was just very slow to complete. It takes almost 10 seconds to set the tps65910-rtc hw clock while the omap_rtc hw clock is set in less than a second.

    [ 3.049489] tps65910-rtc tps65910-rtc: rtc core: registered tps65910-rtc as rtc0
    [ 6.403069] omap_rtc 44e3e000.rtc: rtc core: registered 44e3e000.rtc as rtc1

    # cat /sys/class/rtc/rtc0/time
    11:41:56
    # date --set="27 JAN 2018 11:11"
    Sat Jan 27 11:11:00 UTC 2018
    # hwclock -f /dev/rtc1 -w # This takes about a second to complete
    # cat /sys/class/rtc/rtc1/time
    11:11:16
    # cat /sys/class/rtc/rtc0/time
    11:42:33
    # hwclock -f /dev/rtc0 -w # This takes 10 seconds to complete
    # cat /sys/class/rtc/rtc0/time
    11:11:51

    Is there a problem or should the PMIC i2c communication cause it to take so long?
  • I was able to eliminate the error with time hctosys:

    hctosys: unable to open rtc device (rtc0) 

    I saw the error when the rtc driver was a loadable module, I configured the rtc driver as a built-in kernel module instead and it loaded earlier in the boot process.  I could not find a way to delay the time synchronization instead.

    I have this working with omap_rtc as rtc0.  Now the time looks correct after powering up the board.  I'm still working to control the order the drivers are loaded.

  • In addition to setting the load order, I needed to solve the hctosys error. I couldn't find a way to delay the time sync to happen after the rtc driver module is loaded.

    I found a workaround is to make the RTC driver you want to load first a built-in module, and the other, rtc_omap, a loadable module. The built-in loads much earlier in the boot and also it eliminates a problem I had with time not syncing correctly from the RTC when both were loadable modules.

    This is working

    # dmesg | grep rtc
    [ 1.285058] vrtc: supplied by vbat
    [ 1.382157] tps65910-rtc tps65910-rtc: Enabling rtc-tps65910.
    [ 1.389681] rtc rtc0: tps65910-rtc: dev (253:0)
    [ 1.389701] tps65910-rtc tps65910-rtc: rtc core: registered tps65910-rtc as rtc0
    [ 1.422088] tps65910-rtc tps65910-rtc: setting system clock to 2018-01-29 05:05:02 UTC (1517202302)
    [ 6.356774] omap_rtc 44e3e000.rtc: already running
    [ 6.412659] omap_rtc 44e3e000.rtc: omap_rtc_probe: rtc is_pmic_controller
    [ 6.493127] rtc rtc1: 44e3e000.rtc: dev (253:1)
    [ 6.493144] omap_rtc 44e3e000.rtc: rtc core: registered 44e3e000.rtc as rtc1


    I was getting this (hctosys error) when both were modules:

    # dmesg | grep rtc
    [ 1.285360] vrtc: supplied by vbat
    [ 1.403947] hctosys: unable to open rtc device (rtc0)
    [ 3.493050] tps65910-rtc tps65910-rtc: Enabling rtc-tps65910.
    [ 3.501514] rtc rtc0: tps65910-rtc: dev (253:0)
    [ 3.501557] tps65910-rtc tps65910-rtc: rtc core: registered tps65910-rtc as 0
    [ 6.331188] omap_rtc 44e3e000.rtc: omap_rtc_probe: rtc is_pmic_controller
    [ 6.371432] rtc rtc1: 44e3e000.rtc: dev (253:1)
    [ 6.371448] omap_rtc 44e3e000.rtc: rtc core: registered 44e3e000.rtc as rtc1
  • Are you still having any problems? If not we can close this.

    Steve K.
  • Code changes were merged into the next release which is being tested, I'm waiting for the results from the product test engineer. Please do not close yet.
  • Hi Aaron,
    Any results for the test engineer?

    Steve K.
  • Not yet, it's crunch time on a large project so there is a lot of testing in the queue, production is scheduled to start in a few weeks so I should know soon.