]> git.proxmox.com Git - mirror_ubuntu-eoan-kernel.git/commitdiff
rtc: set wakeup capability for I2C and SPI RTC drivers
authorAnton Vorontsov <avorontsov@ru.mvista.com>
Thu, 17 Dec 2009 23:27:23 +0000 (15:27 -0800)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 17 Dec 2009 23:45:32 +0000 (15:45 -0800)
RTC core won't allow wakeup alarms to be set if RTC devices' parent (i.e.
i2c_client or spi_device) isn't wakeup capable.

For I2C devices there is I2C_CLIENT_WAKE flag exists that we can pass via
board info, and if set, I2C core will initialize wakeup capability.  For
SPI devices there is no such flag at all.

I believe that it's not platform code responsibility to allow or disallow
wakeups, instead, drivers themselves should set the capability if a device
can trigger wakeups.

That's what drivers/base/power/sysfs.c says:

 * It is the responsibility of device drivers to enable (or disable)
 * wakeup signaling as part of changing device power states, respecting
 * the policy choices provided through the driver model.

I2C and SPI RTC devices send wakeup events via interrupt lines, so we
should set the wakeup capability if IRQ is routed.

Ideally we should also check irq for wakeup capability before setting
device's capability, i.e.

if (can_irq_wake(irq))
device_set_wakeup_capable(&client->dev, 1);

But there is no can_irq_wake() call exist, and it is not that trivial to
implement it for all interrupts controllers and complex/cascaded setups.

drivers/base/power/sysfs.c also covers these cases:

 * Devices may not be able to generate wakeup events from all power
 * states.  Also, the events may be ignored in some configurations;
 * for example, they might need help from other devices that aren't
 * active

So there is no guarantee that wakeup will actually work, and so I think
there is no point in being pedantic wrt checking IRQ wakeup capability.

Signed-off-by: Anton Vorontsov <avorontsov@ru.mvista.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Cc: Ben Dooks <ben-linux@fluff.org>
Cc: Jean Delvare <khali@linux-fr.org>
Cc: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/rtc/rtc-ds1305.c
drivers/rtc/rtc-ds1307.c
drivers/rtc/rtc-ds1374.c

index 259db7f3535b4754b3fe2d95e9a92d722e75a4ec..9630e7d3314e59d19dd9e94be9f917cab7307f16 100644 (file)
@@ -778,6 +778,8 @@ static int __devinit ds1305_probe(struct spi_device *spi)
                                        spi->irq, status);
                        goto fail1;
                }
+
+               device_set_wakeup_capable(&spi->dev, 1);
        }
 
        /* export NVRAM */
index 8a99da6f2f2439fba20b9e6bd3772dafc639eedd..c4ec5c158aa14f81ca355c9c0b0366ffa383e11c 100644 (file)
@@ -881,6 +881,8 @@ read_rtc:
                                "unable to request IRQ!\n");
                        goto exit_irq;
                }
+
+               device_set_wakeup_capable(&client->dev, 1);
                set_bit(HAS_ALARM, &ds1307->flags);
                dev_dbg(&client->dev, "got IRQ %d\n", client->irq);
        }
index 713f7bf5afb330c508b5d2482804f97ed0083470..5317bbcbc7a0c7cb3f60e16e6bafac483327a666 100644 (file)
@@ -383,6 +383,8 @@ static int ds1374_probe(struct i2c_client *client,
                        dev_err(&client->dev, "unable to request IRQ\n");
                        goto out_free;
                }
+
+               device_set_wakeup_capable(&client->dev, 1);
        }
 
        ds1374->rtc = rtc_device_register(client->name, &client->dev,