disabling RTC irq during release
Hello,
Looking at other rtc drivers I noticed that during the release() method we should disable IRQs as follow:
static void ds1307_release(struct device *dev)
{
struct ds1307 *ds1307 = dev_get_drvdata(dev);
if (ds1307->irq >= 0) {
ds1307->irqen = 0;
ds1307_update_alarm(ds1307);
}
}that's the code I put into my patch for ds1339.
But if I wish using RTC IRQ line to turn also the board ON, not just to put to sleep it, I should leave the IRQ line on!
I think we should add a configuration option who allows developers to choose if the RTC IRQ line should be disabled or not during release().
Ciao,
Rodolfo
Signature · 4 lines
GNU/Linux Solutions e-mail: [email protected] Linux Device Driver [email protected] Embedded Systems [email protected] UNIX programming phone: +39 349 2432127
Quoted 6 lines · Rodolfo Giometti
Hello,
Looking at other rtc drivers I noticed that during the
release()method we should disable IRQs as follow:static void
ds1307_release(struct device *dev)
Quoted 8 lines
{
struct ds1307 *ds1307 = dev_get_drvdata(dev);
if (ds1307->irq >= 0) {
ds1307->irqen = 0;
ds1307_update_alarm(ds1307);
}
}On the RTC list, the outcome of that discussion was that the release() method -- not generally implemented at this time, and only supporting the /dev/rtcN access mode -- should only disable the IRQs enabled through that /dev/rtcN file.
Now, it turns out that of the three kinds of RTC IRQ (alarm, once-per-second, and 2^N-per-second), two of those modes can be accessed through in-kernel APIs outside /dev/rtcN calls:
- 2^N-per-second "periodic" irqs, using rtc_irq_set_freq() and rtc_irq_set_state()
- alarm irqs, using rtc_set_alarm()
So it would be incorrect to disable those IRQs, when some other kernel activity had enabled them. But for now it would be correct to always disable once-per-second "update" IRQs in a release() method.
There's a separate issue -- longstanding, not new to the RTC framework -- of how several consumers of RTC IRQs ought to share the different kinds of IRQ.
Quoted 2 lines
But if I wish using RTC IRQ line to turn also the board ON, not just to put to sleep it, I should leave the IRQ line on!
That can be done with /sys/class/rtcN/device/power/wakealarm, writing it to the time (in seconds) the RTC alarm should kick the board's power-on circuitry.
- Dave