An RTC ds-1371, compatible with the rtc-ds1374.c (Linux kernel 4.19 driver) is wired in the i2C bus on my embedded card. I would like to use the alarm mode for this component, but the problem is :
There is no GPIO interrupt pin wired between rtc and CPU(i.MX6). So as the driver need it to activate the alarm mode, I decided to modify the driver source file "Linux/drivers/rtc/rtc-ds1374.c" by activating the alarm mode whithout interrupt specifier in devicetree.
My modification consist in adding a parameter in the devicetree that the driver will detect to enable alarm mode.
I named this parameter: "wakeup-capable". It's just a boolean.
So my devicetree seems like that:
--------------------------------
ds1374:rtc@68 {
compatible = "dallas,ds1374";
wakeup-capable;
reg = <0x68>;
};
--------------------------------
then, in the probe function of the driver rtc-ds1374.c, I added the "else if" following condition :
----------------------------------------------------------------------------
if (client->irq > 0) {
ret = devm_request_irq(&client->dev, client->irq, ds1374_irq, 0,
"ds1374", client);
if (ret) {
dev_err(&client->dev, "unable to request IRQ\n");
return ret;
}
device_set_wakeup_capable(&client->dev, 1);
}
else if (device_property_read_bool(&client->dev, "wakeup-capable")) {
device_set_wakeup_capable(&client->dev, 1);
}
----------------------------------------------------------------------------
It permit to see the wakealarm file in "/sys/class/rtc/rtc0/wakealarm", but it's not already complete because trying to write 20 seconds in this file cause a value error.
Exemple:
user@machine:~$ echo +20 > /sys/class/rtc/rtc0/wakealarm
“-sh: echo: write error: Invalid argument”
but command "hwclock" works perfectly fine.
To solve the first problem, I discovered it had a link with the driver function "ds1374_set_alarm" and "ds1374_read_alarm".
Specifically the first condition:
--------------------------
if (client->irq <= 0)
return -EINVAL;
-----------------------------
So I decided to comment it in both functions "ds1374_set_alarm" and "ds1374_read_alarm". So the command "echo +20 > /sys/class/rtc/rtc0/wakealarm" worked fine but the command hwclock gived me this error:
"hwclock: select() to /dev/rtc0 to wait for clock tick timed out"
I'm sure it's because I comments the folowing code:
--------------------------
//if (client->irq <= 0)
// return -EINVAL;
-----------------------------
Actually, I would like the command "echo +20 > /sys/class/rtc/rtc0/wakealarm" and "hwclock" working both, but it seems to be possible only by declaring interrupt in devicetree like the following code:
--------------------------------
ds1374:rtc@68 {
compatible = "dallas,ds1374";
interrupt-parent = <&gpio8>;
interrupts = <7 IRQ_TYPE_EDGE_FALLING>;//or interrupts = <7 IRQ_TYPE_LEVEL_LOW>;
reg = <0x68>;
};
--------------------------------
Is there a way to bypass IRQ dependency, just by declaring a boolean like "wakeup-capable" in the devicetree the driver could parse in order to have set alarm and hwclock working both?
Do you know a method to get both commands "hwclock" and "echo +20 > /sys/class/rtc/rtc0/wakealarm" working?
Thanks for all, and best reguards: Anthony.