How to enable RTC on Dragonboard 410c With Linaro 15.07?


#1

Is there anyway to enable RTC on Dragonboard 410c flashed with Linaro 15.07 release ?


#2

Are you seeing this message on the kernel log?

[ 3.092406] …/drivers/rtc/hctosys.c: unable to open rtc device (rtc0)


#3

Yes. Same kernel log. Do we have a work around for this ?


#4

I didn’t find the compatible string in the device tree or interrupts registered to the real time clock. let me come back to you on this.


#5

The RTC is in the PMIC.

Please enable CONFIG_RTC_DRV_PM8XXX in the config

And apply the following patch to the device tree:

[jramirez@calypso linux.git (ubuntu-qcom-dragonboard410c-15.07 *$%)]$ git diff arch/arm64/boot/dts/qcom/pm8916.dtsi
diff --git a/arch/arm64/boot/dts/qcom/pm8916.dtsi b/arch/arm64/boot/dts/qcom/pm8916.dtsi
index 7c85949…faabdb7 100644
— a/arch/arm64/boot/dts/qcom/pm8916.dtsi
+++ b/arch/arm64/boot/dts/qcom/pm8916.dtsi
@@ -9,6 +9,14 @@
#address-cells = <1>;
#size-cells = <0>;

  •          rtc@6000 {
    
  •                     compatible = "qcom,pm8941-rtc";
    
  •                     reg = <0x6000 0x6100>;
    
  •                     reg-names = "rtc", "alarm";
    
  •                     interrupts = <0x0 0x61 0x1 IRQ_TYPE_EDGE_RISING>;
    
  •           };
    
  •           pm8916_gpios: gpios@c000 {
                      compatible = "qcom,pm8916-gpio";
                      reg = <0xc000 0x400>;
    

During boot you should see something like this:

[ 2.091908] rtc-pm8xxx 200f000.spmi:pm8916@0:rtc@6000: rtc core: registered pm8xxx_rtc as rtc0
[ 3.118293] rtc-pm8xxx 200f000.spmi:pm8916@0:rtc@6000: setting system clock to 1970-01-01 00:02:01 UTC (121)

root@linaro-alip:~# hwclock
Thu 01 Jan 1970 12:06:33 AM UTC -1.321749 seconds

I still can see some issues though.

root@linaro-alip:~# hwclock --set --date 09/04/2015
hwclock: ioctl(RTC_SET_TIME) to /dev/rtc to set the time failed.: Permission denied


#6

Please checkout these changes (will probably need merging)

https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/drivers/rtc/rtc-pm8xxx.c?id=c8d523a4b053d1678adb92976b5ef84d9bc481e8


#7

Thanks , i got the rtc0 node under /dev/. My kernel source already have all changes you suggested in your last post.

Still on executing date -s “2015-09-09 11:40:00” and on executing “hwclock -w” its still gives error as shown below.

root@linaro-alip:~# date -s "2015-09-09 11:40:00"
Wed Sep 9 11:40:00 UTC 2015
root@linaro-alip:~# hwclock -w
hwclock: ioctl(RTC_SET_TIME) to /dev/rtc to set the time failed.: Permission denied

Any workaround available ?


#8

Hi anyone can suggest a workaround ?


#9

I have done following changes

diff --git a/arch/arm64/boot/dts/qcom/pm8916.dtsi b/arch/arm64/boot/dts/qcom/pm8916.dtsi
index 008e856…985d162 100644
— a/arch/arm64/boot/dts/qcom/pm8916.dtsi
+++ b/arch/arm64/boot/dts/qcom/pm8916.dtsi
@@ -15,6 +15,7 @@
reg = <0x6000 0x6100>;
reg-names = “rtc”, “alarm”;
interrupts = <0x0 0x61 0x1 IRQ_TYPE_EDGE_RISING>;

  •                   <strong>allow-set-time;</strong>
              };
    

and on doing “hwclock -w” am not getting “hwclock: ioctl(RTC_SET_TIME) to /dev/rtc to set the time failed.: Permission denied” instead it is rebooting while disabling the alarm. Any workaround available ?


#10

It seems to me that its rebooting on calling regmap_write function. Cause i comment the “disabling of alarm” code and checked. It fails on next regmap_write call. Is there any workaround ?


#11

I also tried this patch https://patches.linaro.org/46624/. But its rebooting on “hwclock -w” command.


#12

Can anyone help me to solve this ?


#13

If you look at the driver code, once you enable (properly) allow-set-time to a valid boolean, you should be getting write access to the device.

After doing that I am also seeing the reboots you mention so I suppose the register mapping is somehow different to what we are asking for (the device tree asks for pm8941_regs which might not be the right choice for this device).

Let us look into this.


#14

Unfortunately, the aarch64 cores can NOT change the RTC time (only consume it)

As a matter of fact, the write registers are not defined in the PM8916 register map.

Changing the RTC could be done from the GPS/DSP hosts.

I’ll try to get that information if it still of interest.


#15

Can we define write register map for PM8916 ? If not, Can you please provide us the steps to change RTC using DSP host ?


#16

Hi ldts,

Can you please provide update on this?


#17

sorry it is not good news: I haven’t been able to find out how to do this.


#18

there are two somewhat floating downstream patches that simulate RTC write via offset usage:

  1. https://source.codeaurora.org/quic/imm/imm/kernel/commit/drivers/rtc/rtc-pm8xxx.c?h=IMM.LE.1.0&id=200420edea57e7f4a6fce27c81092da0bb63c5dd

  2. https://source.codeaurora.org/quic/imm/imm/kernel/commit/drivers/rtc/rtc-pm8xxx.c?h=IMM.LE.1.0&id=6f283ad81d146d32b676c0b5587e4d915fe42b9d


#19

Hi ce1,

Thanks for the reply.
This is useful for the cases in which RTC write is not possible.