1 From: Daniel González Cabanelas <dgcbueu@gmail.com>
2 Subject: [PATCH 2/2] rtc: rs5c372: let the alarm to be used as wakeup source
4 Currently there is no use for the interrupts on the rs5c372 RTC and the
5 wakealarm isn't enabled. There are some devices like NASes which use this
6 RTC to wake up from the power off state when the INTR pin is activated by
9 Enable the alarm and let to be used as a wakeup source.
11 Tested on a Buffalo LS421DE NAS.
13 Signed-off-by: Daniel González Cabanelas <dgcbueu@gmail.com>
15 drivers/rtc/rtc-rs5c372.c | 16 ++++++++++++++++
16 1 file changed, 16 insertions(+)
18 diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c
19 index 94b778c6e..76775d66e 100644
20 --- a/drivers/rtc/rtc-rs5c372.c
21 +++ b/drivers/rtc/rtc-rs5c372.c
22 @@ -654,6 +654,7 @@ static int rs5c372_probe(struct i2c_client *client,
25 struct rs5c372 *rs5c372;
26 + bool rs5c372_can_wakeup_device = false;
28 dev_dbg(&client->dev, "%s\n", __func__);
30 @@ -689,6 +690,12 @@ static int rs5c372_probe(struct i2c_client *client,
32 rs5c372->type = id->driver_data;
35 + if(of_property_read_bool(client->dev.of_node,
37 + rs5c372_can_wakeup_device = true;
40 /* we read registers 0x0f then 0x00-0x0f; skip the first one */
41 rs5c372->regs = &rs5c372->buf[1];
42 rs5c372->smbus = smbus_mode;
43 @@ -722,6 +729,8 @@ static int rs5c372_probe(struct i2c_client *client,
47 + rs5c372->has_irq = 1;
49 /* if the oscillator lost power and no other software (like
50 * the bootloader) set it up, do it here.
52 @@ -748,6 +757,10 @@ static int rs5c372_probe(struct i2c_client *client,
55 /* REVISIT use client->irq to register alarm irq ... */
56 + if (rs5c372_can_wakeup_device) {
57 + device_init_wakeup(&client->dev, true);
60 rs5c372->rtc = devm_rtc_device_register(&client->dev,
61 rs5c372_driver.driver.name,
62 &rs5c372_rtc_ops, THIS_MODULE);
63 @@ -761,6 +774,9 @@ static int rs5c372_probe(struct i2c_client *client,
67 + /* the rs5c372 alarm only supports a minute accuracy */
68 + rs5c372->rtc->uie_unsupported = 1;