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/AM4378: Internal RTC, omap_rtc driver, "RTC_RD_TIME: Invalid argument"

Part Number: AM4378
Other Parts Discussed in Thread: AM4372,

Tool/software: Linux

I'm trying to read the internal RTC on the AM4378 on a custom board running Linux, kernel version 4.1.18.  I have set up the device tree using "/arch/arm/boot/dts/am437x-gp-evm.dts" as a guide.  I do not have an external clock source.  This includes "am4372.dtsi" by default, which includes this section, which configures the RTC.

rtc: rtc@44e3e000 {
	compatible = "ti,am4372-rtc", "ti,am3352-rtc", "ti,da830-rtc";
	reg = <0x44e3e000 0x1000>;
	interrupts = <GIC_SPI 75 IRQ_TYPE_LEVEL_HIGH
		      GIC_SPI 76 IRQ_TYPE_LEVEL_HIGH>;
	ti,hwmods = "rtc";
	system-power-controller;
	status = "disabled";
};

In my own custom dts file based on "am437x-gp-evm.dts", I have the following lines.

&rtc {
    status = "okay";
};

My understanding is that this should enable the internal RTC.  During boot I observe the following:

[    1.251581] omap_rtc 44e3e000.rtc: rtc core: registered 44e3e000.rtc as rtc0
...
[    1.472652] omap_rtc 44e3e000.rtc: hctosys: unable to read the hardware clock

I believe this indicates that the "omap_rtc" driver is loading properly.  The RTC appears in the device tree (as /dev/rtc0).

The problem is that I cannot seem to read from this device.  I have reviewed the information regarding "hwclock", and the following shows the results of various commands.


# hwclock --help
BusyBox v1.23.2 (2017-08-09 12:21:48 EDT) multi-call binary.

Usage: hwclock [-r|--show] [-s|--hctosys] [-w|--systohc] [-t|--systz] [-l|--localtime] [-u|--utc] [-f|--rtc FILE]

Query and set hardware clock (RTC)

        -r      Show hardware clock time
        -s      Set system time from hardware clock
        -w      Set hardware clock from system time
        -t      Set in-kernel timezone, correct system time
                if hardware clock is in local time
        -u      Assume hardware clock is kept in UTC
        -l      Assume hardware clock is kept in local time
        -f FILE Use specified device (e.g. /dev/rtc2)

# hwclock -r -f /dev/rtc0
hwclock: RTC_RD_TIME: Invalid argument

This seems to indicate a problem with the ioctl function call within the "omap_rtc" driver.


# hwclock -w -f /dev/rtc0
<no output>

It is unclear from this function call whether or not the write (setting the HW clock) was successful.

  • We're looking into this. Feedback will be posted here.

    Best Regards,
    Yordan
  • Hi Kevin,

    Kevin Sylvestre93 said:
    I do not have an external clock source.

    Kevin Sylvestre93 said:
    rtc: rtc@44e3e000 { compatible = "ti,am4372-rtc", "ti,am3352-rtc", "ti,da830-rtc"; reg = <0x44e3e000 0x1000>; interrupts = <GIC_SPI 75 IRQ_TYPE_LEVEL_HIGH GIC_SPI 76 IRQ_TYPE_LEVEL_HIGH>; ti,hwmods = "rtc"; system-power-controller; status = "disabled"; };

    Kevin Sylvestre93 said:
    &rtc { status = "okay"; };

    Kevin Sylvestre93 said:
    [ 1.472652] omap_rtc 44e3e000.rtc: hctosys: unable to read the hardware clock

    I suspect the main issue is that you do not provide 32KHz clock (neither external nor internal) to the RTC module. In AM437x TI EVM DTS files we have:

    rtc: rtc@44e3e000 {
                compatible = "ti,am4372-rtc", "ti,am3352-rtc",
                         "ti,da830-rtc";
                reg = <0x44e3e000 0x1000>;
                interrupts = <GIC_SPI 75 IRQ_TYPE_LEVEL_HIGH
                          GIC_SPI 76 IRQ_TYPE_LEVEL_HIGH>;
                ti,hwmods = "rtc";
                clocks = <&clk_32768_ck>;
                clock-names = "int-clk";
                status = "disabled";
            };

    clk_32768_ck: clk_32768_ck {
            #clock-cells = <0>;
            compatible = "fixed-clock";
            clock-frequency = <32768>;
        };

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

    I would suggest you to try with providing internal 32K clock. See AM437x documentation (DM and TRM) for more details regarding RTC 32K external/internal clock scheme.

    Regards,
    Pavel