* [PATCH] drivers/rtc/rtc-ds1307.c: Support optional wakeup interrupt source
@ 2014-08-21 16:12 ` Nishanth Menon
0 siblings, 0 replies; 9+ messages in thread
From: Nishanth Menon @ 2014-08-21 16:12 UTC (permalink / raw)
To: Alessandro Zummo
Cc: rtc-linux, Tony Lindgren, linux-omap, linux-kernel, Nishanth Menon
With the recent pinctrl-single changes, SoCs such as Texas
Instrument's OMAP processors can treat wake-up events from deeper idle
states as interrupts.
Let's add support for the optional second interrupt for wake-up
events. And then SoC can wakeup and handle the event using it's
regular handler.
Finally, to pass the wake-up interrupt in the dts file,
interrupts-extended property needs to be passed.
This is similar in approach to commit 2a0b965cfb6e ("serial: omap: Add
support for optional wake-up")
Signed-off-by: Nishanth Menon <nm@ti.com>
---
drivers/rtc/rtc-ds1307.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index f03d5ba..5feedfc 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -15,6 +15,8 @@
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/i2c.h>
+#include <linux/of_device.h>
+#include <linux/of_irq.h>
#include <linux/string.h>
#include <linux/rtc.h>
#include <linux/bcd.h>
@@ -115,6 +117,7 @@ struct ds1307 {
struct i2c_client *client;
struct rtc_device *rtc;
struct work_struct work;
+ int wakeirq;
s32 (*read_block_data)(const struct i2c_client *client, u8 command,
u8 length, u8 *values);
s32 (*write_block_data)(const struct i2c_client *client, u8 command,
@@ -835,6 +838,34 @@ ds1307_nvram_write(struct file *filp, struct kobject *kobj,
/*----------------------------------------------------------------------*/
+static int ds1307_i2c_suspend(struct i2c_client *client, pm_message_t mesg)
+{
+ struct ds1307 *ds1307 = i2c_get_clientdata(client);
+ struct device *dev = &client->dev;
+
+ if (!ds1307->wakeirq)
+ return 0;
+
+ if (device_may_wakeup(dev))
+ enable_irq(ds1307->wakeirq);
+
+ return 0;
+}
+
+static int ds1307_i2c_resume(struct i2c_client *client)
+{
+ struct ds1307 *ds1307 = i2c_get_clientdata(client);
+ struct device *dev = &client->dev;
+
+ if (!ds1307->wakeirq)
+ return 0;
+
+ if (device_may_wakeup(dev))
+ disable_irq_nosync(ds1307->wakeirq);
+
+ return 0;
+}
+
static int ds1307_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -1116,6 +1147,8 @@ read_rtc:
}
if (want_irq) {
+ struct device_node *node = client->dev.of_node;
+
err = request_irq(client->irq, ds1307_irq, IRQF_SHARED,
ds1307->rtc->name, client);
if (err) {
@@ -1125,6 +1158,28 @@ read_rtc:
set_bit(HAS_ALARM, &ds1307->flags);
dev_dbg(&client->dev, "got IRQ %d\n", client->irq);
+ if (node)
+ ds1307->wakeirq = irq_of_parse_and_map(node, 1);
+
+ if (ds1307->wakeirq <= 0)
+ ds1307->wakeirq = 0;
+ else
+ err = devm_request_irq(&client->dev,
+ ds1307->wakeirq,
+ ds1307_irq,
+ IRQF_ONESHOT,
+ ds1307->rtc->name,
+ client);
+ if (err) {
+ dev_err(&client->dev, "unable to get wakeIRQ %d\n",
+ err);
+ free_irq(client->irq, client);
+ goto exit;
+ }
+
+ /* We enable the interrupt only during suspend path */
+ if (ds1307->wakeirq)
+ disable_irq_nosync(ds1307->wakeirq);
}
}
@@ -1189,6 +1244,8 @@ static struct i2c_driver ds1307_driver = {
},
.probe = ds1307_probe,
.remove = ds1307_remove,
+ .suspend = ds1307_i2c_suspend,
+ .resume = ds1307_i2c_resume,
.id_table = ds1307_id,
};
--
1.7.9.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* drivers/rtc/rtc-ds1307.c: Support optional wakeup interrupt source
@ 2014-08-21 16:12 ` Nishanth Menon
0 siblings, 0 replies; 9+ messages in thread
From: Nishanth Menon @ 2014-08-21 16:12 UTC (permalink / raw)
To: Alessandro Zummo
Cc: rtc-linux, Tony Lindgren, linux-omap, linux-kernel, Nishanth Menon
With the recent pinctrl-single changes, SoCs such as Texas
Instrument's OMAP processors can treat wake-up events from deeper idle
states as interrupts.
Let's add support for the optional second interrupt for wake-up
events. And then SoC can wakeup and handle the event using it's
regular handler.
Finally, to pass the wake-up interrupt in the dts file,
interrupts-extended property needs to be passed.
This is similar in approach to commit 2a0b965cfb6e ("serial: omap: Add
support for optional wake-up")
Signed-off-by: Nishanth Menon <nm@ti.com>
---
drivers/rtc/rtc-ds1307.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index f03d5ba..5feedfc 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -15,6 +15,8 @@
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/i2c.h>
+#include <linux/of_device.h>
+#include <linux/of_irq.h>
#include <linux/string.h>
#include <linux/rtc.h>
#include <linux/bcd.h>
@@ -115,6 +117,7 @@ struct ds1307 {
struct i2c_client *client;
struct rtc_device *rtc;
struct work_struct work;
+ int wakeirq;
s32 (*read_block_data)(const struct i2c_client *client, u8 command,
u8 length, u8 *values);
s32 (*write_block_data)(const struct i2c_client *client, u8 command,
@@ -835,6 +838,34 @@ ds1307_nvram_write(struct file *filp, struct kobject *kobj,
/*----------------------------------------------------------------------*/
+static int ds1307_i2c_suspend(struct i2c_client *client, pm_message_t mesg)
+{
+ struct ds1307 *ds1307 = i2c_get_clientdata(client);
+ struct device *dev = &client->dev;
+
+ if (!ds1307->wakeirq)
+ return 0;
+
+ if (device_may_wakeup(dev))
+ enable_irq(ds1307->wakeirq);
+
+ return 0;
+}
+
+static int ds1307_i2c_resume(struct i2c_client *client)
+{
+ struct ds1307 *ds1307 = i2c_get_clientdata(client);
+ struct device *dev = &client->dev;
+
+ if (!ds1307->wakeirq)
+ return 0;
+
+ if (device_may_wakeup(dev))
+ disable_irq_nosync(ds1307->wakeirq);
+
+ return 0;
+}
+
static int ds1307_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -1116,6 +1147,8 @@ read_rtc:
}
if (want_irq) {
+ struct device_node *node = client->dev.of_node;
+
err = request_irq(client->irq, ds1307_irq, IRQF_SHARED,
ds1307->rtc->name, client);
if (err) {
@@ -1125,6 +1158,28 @@ read_rtc:
set_bit(HAS_ALARM, &ds1307->flags);
dev_dbg(&client->dev, "got IRQ %d\n", client->irq);
+ if (node)
+ ds1307->wakeirq = irq_of_parse_and_map(node, 1);
+
+ if (ds1307->wakeirq <= 0)
+ ds1307->wakeirq = 0;
+ else
+ err = devm_request_irq(&client->dev,
+ ds1307->wakeirq,
+ ds1307_irq,
+ IRQF_ONESHOT,
+ ds1307->rtc->name,
+ client);
+ if (err) {
+ dev_err(&client->dev, "unable to get wakeIRQ %d\n",
+ err);
+ free_irq(client->irq, client);
+ goto exit;
+ }
+
+ /* We enable the interrupt only during suspend path */
+ if (ds1307->wakeirq)
+ disable_irq_nosync(ds1307->wakeirq);
}
}
@@ -1189,6 +1244,8 @@ static struct i2c_driver ds1307_driver = {
},
.probe = ds1307_probe,
.remove = ds1307_remove,
+ .suspend = ds1307_i2c_suspend,
+ .resume = ds1307_i2c_resume,
.id_table = ds1307_id,
};
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH] drivers/rtc/rtc-ds1307.c: Support optional wakeup interrupt source
@ 2014-08-21 16:12 ` Nishanth Menon
0 siblings, 0 replies; 9+ messages in thread
From: Nishanth Menon @ 2014-08-21 16:12 UTC (permalink / raw)
To: Alessandro Zummo
Cc: rtc-linux, Tony Lindgren, linux-omap, linux-kernel, Nishanth Menon
With the recent pinctrl-single changes, SoCs such as Texas
Instrument's OMAP processors can treat wake-up events from deeper idle
states as interrupts.
Let's add support for the optional second interrupt for wake-up
events. And then SoC can wakeup and handle the event using it's
regular handler.
Finally, to pass the wake-up interrupt in the dts file,
interrupts-extended property needs to be passed.
This is similar in approach to commit 2a0b965cfb6e ("serial: omap: Add
support for optional wake-up")
Signed-off-by: Nishanth Menon <nm@ti.com>
---
drivers/rtc/rtc-ds1307.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 57 insertions(+)
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
index f03d5ba..5feedfc 100644
--- a/drivers/rtc/rtc-ds1307.c
+++ b/drivers/rtc/rtc-ds1307.c
@@ -15,6 +15,8 @@
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/i2c.h>
+#include <linux/of_device.h>
+#include <linux/of_irq.h>
#include <linux/string.h>
#include <linux/rtc.h>
#include <linux/bcd.h>
@@ -115,6 +117,7 @@ struct ds1307 {
struct i2c_client *client;
struct rtc_device *rtc;
struct work_struct work;
+ int wakeirq;
s32 (*read_block_data)(const struct i2c_client *client, u8 command,
u8 length, u8 *values);
s32 (*write_block_data)(const struct i2c_client *client, u8 command,
@@ -835,6 +838,34 @@ ds1307_nvram_write(struct file *filp, struct kobject *kobj,
/*----------------------------------------------------------------------*/
+static int ds1307_i2c_suspend(struct i2c_client *client, pm_message_t mesg)
+{
+ struct ds1307 *ds1307 = i2c_get_clientdata(client);
+ struct device *dev = &client->dev;
+
+ if (!ds1307->wakeirq)
+ return 0;
+
+ if (device_may_wakeup(dev))
+ enable_irq(ds1307->wakeirq);
+
+ return 0;
+}
+
+static int ds1307_i2c_resume(struct i2c_client *client)
+{
+ struct ds1307 *ds1307 = i2c_get_clientdata(client);
+ struct device *dev = &client->dev;
+
+ if (!ds1307->wakeirq)
+ return 0;
+
+ if (device_may_wakeup(dev))
+ disable_irq_nosync(ds1307->wakeirq);
+
+ return 0;
+}
+
static int ds1307_probe(struct i2c_client *client,
const struct i2c_device_id *id)
{
@@ -1116,6 +1147,8 @@ read_rtc:
}
if (want_irq) {
+ struct device_node *node = client->dev.of_node;
+
err = request_irq(client->irq, ds1307_irq, IRQF_SHARED,
ds1307->rtc->name, client);
if (err) {
@@ -1125,6 +1158,28 @@ read_rtc:
set_bit(HAS_ALARM, &ds1307->flags);
dev_dbg(&client->dev, "got IRQ %d\n", client->irq);
+ if (node)
+ ds1307->wakeirq = irq_of_parse_and_map(node, 1);
+
+ if (ds1307->wakeirq <= 0)
+ ds1307->wakeirq = 0;
+ else
+ err = devm_request_irq(&client->dev,
+ ds1307->wakeirq,
+ ds1307_irq,
+ IRQF_ONESHOT,
+ ds1307->rtc->name,
+ client);
+ if (err) {
+ dev_err(&client->dev, "unable to get wakeIRQ %d\n",
+ err);
+ free_irq(client->irq, client);
+ goto exit;
+ }
+
+ /* We enable the interrupt only during suspend path */
+ if (ds1307->wakeirq)
+ disable_irq_nosync(ds1307->wakeirq);
}
}
@@ -1189,6 +1244,8 @@ static struct i2c_driver ds1307_driver = {
},
.probe = ds1307_probe,
.remove = ds1307_remove,
+ .suspend = ds1307_i2c_suspend,
+ .resume = ds1307_i2c_resume,
.id_table = ds1307_id,
};
--
1.7.9.5
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: [PATCH] drivers/rtc/rtc-ds1307.c: Support optional wakeup interrupt source
2014-08-21 16:12 ` Nishanth Menon
@ 2014-09-03 13:38 ` Nishanth Menon
-1 siblings, 0 replies; 9+ messages in thread
From: Nishanth Menon @ 2014-09-03 13:38 UTC (permalink / raw)
To: Alessandro Zummo; +Cc: rtc-linux, Tony Lindgren, linux-omap, linux-kernel
On 08/21/2014 11:12 AM, Nishanth Menon wrote:
> With the recent pinctrl-single changes, SoCs such as Texas
> Instrument's OMAP processors can treat wake-up events from deeper idle
> states as interrupts.
>
> Let's add support for the optional second interrupt for wake-up
> events. And then SoC can wakeup and handle the event using it's
> regular handler.
>
> Finally, to pass the wake-up interrupt in the dts file,
> interrupts-extended property needs to be passed.
>
> This is similar in approach to commit 2a0b965cfb6e ("serial: omap: Add
> support for optional wake-up")
>
> Signed-off-by: Nishanth Menon <nm@ti.com>
> ---
Hi,
Gentle Ping.
Regards,
Nishanth Menon
> drivers/rtc/rtc-ds1307.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 57 insertions(+)
>
> diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
> index f03d5ba..5feedfc 100644
> --- a/drivers/rtc/rtc-ds1307.c
> +++ b/drivers/rtc/rtc-ds1307.c
> @@ -15,6 +15,8 @@
> #include <linux/init.h>
> #include <linux/slab.h>
> #include <linux/i2c.h>
> +#include <linux/of_device.h>
> +#include <linux/of_irq.h>
> #include <linux/string.h>
> #include <linux/rtc.h>
> #include <linux/bcd.h>
> @@ -115,6 +117,7 @@ struct ds1307 {
> struct i2c_client *client;
> struct rtc_device *rtc;
> struct work_struct work;
> + int wakeirq;
> s32 (*read_block_data)(const struct i2c_client *client, u8 command,
> u8 length, u8 *values);
> s32 (*write_block_data)(const struct i2c_client *client, u8 command,
> @@ -835,6 +838,34 @@ ds1307_nvram_write(struct file *filp, struct kobject *kobj,
>
> /*----------------------------------------------------------------------*/
>
> +static int ds1307_i2c_suspend(struct i2c_client *client, pm_message_t mesg)
> +{
> + struct ds1307 *ds1307 = i2c_get_clientdata(client);
> + struct device *dev = &client->dev;
> +
> + if (!ds1307->wakeirq)
> + return 0;
> +
> + if (device_may_wakeup(dev))
> + enable_irq(ds1307->wakeirq);
> +
> + return 0;
> +}
> +
> +static int ds1307_i2c_resume(struct i2c_client *client)
> +{
> + struct ds1307 *ds1307 = i2c_get_clientdata(client);
> + struct device *dev = &client->dev;
> +
> + if (!ds1307->wakeirq)
> + return 0;
> +
> + if (device_may_wakeup(dev))
> + disable_irq_nosync(ds1307->wakeirq);
> +
> + return 0;
> +}
> +
> static int ds1307_probe(struct i2c_client *client,
> const struct i2c_device_id *id)
> {
> @@ -1116,6 +1147,8 @@ read_rtc:
> }
>
> if (want_irq) {
> + struct device_node *node = client->dev.of_node;
> +
> err = request_irq(client->irq, ds1307_irq, IRQF_SHARED,
> ds1307->rtc->name, client);
> if (err) {
> @@ -1125,6 +1158,28 @@ read_rtc:
>
> set_bit(HAS_ALARM, &ds1307->flags);
> dev_dbg(&client->dev, "got IRQ %d\n", client->irq);
> + if (node)
> + ds1307->wakeirq = irq_of_parse_and_map(node, 1);
> +
> + if (ds1307->wakeirq <= 0)
> + ds1307->wakeirq = 0;
> + else
> + err = devm_request_irq(&client->dev,
> + ds1307->wakeirq,
> + ds1307_irq,
> + IRQF_ONESHOT,
> + ds1307->rtc->name,
> + client);
> + if (err) {
> + dev_err(&client->dev, "unable to get wakeIRQ %d\n",
> + err);
> + free_irq(client->irq, client);
> + goto exit;
> + }
> +
> + /* We enable the interrupt only during suspend path */
> + if (ds1307->wakeirq)
> + disable_irq_nosync(ds1307->wakeirq);
> }
> }
>
> @@ -1189,6 +1244,8 @@ static struct i2c_driver ds1307_driver = {
> },
> .probe = ds1307_probe,
> .remove = ds1307_remove,
> + .suspend = ds1307_i2c_suspend,
> + .resume = ds1307_i2c_resume,
> .id_table = ds1307_id,
> };
>
>
--
Regards,
Nishanth Menon
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [PATCH] drivers/rtc/rtc-ds1307.c: Support optional wakeup interrupt source
@ 2014-09-03 13:38 ` Nishanth Menon
0 siblings, 0 replies; 9+ messages in thread
From: Nishanth Menon @ 2014-09-03 13:38 UTC (permalink / raw)
To: Alessandro Zummo; +Cc: rtc-linux, Tony Lindgren, linux-omap, linux-kernel
On 08/21/2014 11:12 AM, Nishanth Menon wrote:
> With the recent pinctrl-single changes, SoCs such as Texas
> Instrument's OMAP processors can treat wake-up events from deeper idle
> states as interrupts.
>
> Let's add support for the optional second interrupt for wake-up
> events. And then SoC can wakeup and handle the event using it's
> regular handler.
>
> Finally, to pass the wake-up interrupt in the dts file,
> interrupts-extended property needs to be passed.
>
> This is similar in approach to commit 2a0b965cfb6e ("serial: omap: Add
> support for optional wake-up")
>
> Signed-off-by: Nishanth Menon <nm@ti.com>
> ---
Hi,
Gentle Ping.
Regards,
Nishanth Menon
> drivers/rtc/rtc-ds1307.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 57 insertions(+)
>
> diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
> index f03d5ba..5feedfc 100644
> --- a/drivers/rtc/rtc-ds1307.c
> +++ b/drivers/rtc/rtc-ds1307.c
> @@ -15,6 +15,8 @@
> #include <linux/init.h>
> #include <linux/slab.h>
> #include <linux/i2c.h>
> +#include <linux/of_device.h>
> +#include <linux/of_irq.h>
> #include <linux/string.h>
> #include <linux/rtc.h>
> #include <linux/bcd.h>
> @@ -115,6 +117,7 @@ struct ds1307 {
> struct i2c_client *client;
> struct rtc_device *rtc;
> struct work_struct work;
> + int wakeirq;
> s32 (*read_block_data)(const struct i2c_client *client, u8 command,
> u8 length, u8 *values);
> s32 (*write_block_data)(const struct i2c_client *client, u8 command,
> @@ -835,6 +838,34 @@ ds1307_nvram_write(struct file *filp, struct kobject *kobj,
>
> /*----------------------------------------------------------------------*/
>
> +static int ds1307_i2c_suspend(struct i2c_client *client, pm_message_t mesg)
> +{
> + struct ds1307 *ds1307 = i2c_get_clientdata(client);
> + struct device *dev = &client->dev;
> +
> + if (!ds1307->wakeirq)
> + return 0;
> +
> + if (device_may_wakeup(dev))
> + enable_irq(ds1307->wakeirq);
> +
> + return 0;
> +}
> +
> +static int ds1307_i2c_resume(struct i2c_client *client)
> +{
> + struct ds1307 *ds1307 = i2c_get_clientdata(client);
> + struct device *dev = &client->dev;
> +
> + if (!ds1307->wakeirq)
> + return 0;
> +
> + if (device_may_wakeup(dev))
> + disable_irq_nosync(ds1307->wakeirq);
> +
> + return 0;
> +}
> +
> static int ds1307_probe(struct i2c_client *client,
> const struct i2c_device_id *id)
> {
> @@ -1116,6 +1147,8 @@ read_rtc:
> }
>
> if (want_irq) {
> + struct device_node *node = client->dev.of_node;
> +
> err = request_irq(client->irq, ds1307_irq, IRQF_SHARED,
> ds1307->rtc->name, client);
> if (err) {
> @@ -1125,6 +1158,28 @@ read_rtc:
>
> set_bit(HAS_ALARM, &ds1307->flags);
> dev_dbg(&client->dev, "got IRQ %d\n", client->irq);
> + if (node)
> + ds1307->wakeirq = irq_of_parse_and_map(node, 1);
> +
> + if (ds1307->wakeirq <= 0)
> + ds1307->wakeirq = 0;
> + else
> + err = devm_request_irq(&client->dev,
> + ds1307->wakeirq,
> + ds1307_irq,
> + IRQF_ONESHOT,
> + ds1307->rtc->name,
> + client);
> + if (err) {
> + dev_err(&client->dev, "unable to get wakeIRQ %d\n",
> + err);
> + free_irq(client->irq, client);
> + goto exit;
> + }
> +
> + /* We enable the interrupt only during suspend path */
> + if (ds1307->wakeirq)
> + disable_irq_nosync(ds1307->wakeirq);
> }
> }
>
> @@ -1189,6 +1244,8 @@ static struct i2c_driver ds1307_driver = {
> },
> .probe = ds1307_probe,
> .remove = ds1307_remove,
> + .suspend = ds1307_i2c_suspend,
> + .resume = ds1307_i2c_resume,
> .id_table = ds1307_id,
> };
>
>
--
Regards,
Nishanth Menon
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: drivers/rtc/rtc-ds1307.c: Support optional wakeup interrupt source
2014-08-21 16:12 ` Nishanth Menon
` (2 preceding siblings ...)
(?)
@ 2015-05-28 13:06 ` Alexandre Belloni
2015-05-28 13:09 ` [rtc-linux] " Nishanth Menon
-1 siblings, 1 reply; 9+ messages in thread
From: Alexandre Belloni @ 2015-05-28 13:06 UTC (permalink / raw)
To: Nishanth Menon
Cc: Alessandro Zummo, rtc-linux, Tony Lindgren, linux-omap, linux-kernel
Hi Nishanth,
Do you mind rebasing that one so I can apply it?
On 21/08/2014 at 11:12:01 -0500, Nishanth Menon wrote :
> With the recent pinctrl-single changes, SoCs such as Texas
> Instrument's OMAP processors can treat wake-up events from deeper idle
> states as interrupts.
>
> Let's add support for the optional second interrupt for wake-up
> events. And then SoC can wakeup and handle the event using it's
> regular handler.
>
> Finally, to pass the wake-up interrupt in the dts file,
> interrupts-extended property needs to be passed.
>
> This is similar in approach to commit 2a0b965cfb6e ("serial: omap: Add
> support for optional wake-up")
>
> Signed-off-by: Nishanth Menon <nm@ti.com>
> ---
> drivers/rtc/rtc-ds1307.c | 57 ++++++++++++++++++++++++++++++++++++++++++++++
> 1 file changed, 57 insertions(+)
>
> diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c
> index f03d5ba..5feedfc 100644
> --- a/drivers/rtc/rtc-ds1307.c
> +++ b/drivers/rtc/rtc-ds1307.c
> @@ -15,6 +15,8 @@
> #include <linux/init.h>
> #include <linux/slab.h>
> #include <linux/i2c.h>
> +#include <linux/of_device.h>
> +#include <linux/of_irq.h>
> #include <linux/string.h>
> #include <linux/rtc.h>
> #include <linux/bcd.h>
> @@ -115,6 +117,7 @@ struct ds1307 {
> struct i2c_client *client;
> struct rtc_device *rtc;
> struct work_struct work;
> + int wakeirq;
> s32 (*read_block_data)(const struct i2c_client *client, u8 command,
> u8 length, u8 *values);
> s32 (*write_block_data)(const struct i2c_client *client, u8 command,
> @@ -835,6 +838,34 @@ ds1307_nvram_write(struct file *filp, struct kobject *kobj,
>
> /*----------------------------------------------------------------------*/
>
> +static int ds1307_i2c_suspend(struct i2c_client *client, pm_message_t mesg)
> +{
> + struct ds1307 *ds1307 = i2c_get_clientdata(client);
> + struct device *dev = &client->dev;
> +
> + if (!ds1307->wakeirq)
> + return 0;
> +
> + if (device_may_wakeup(dev))
> + enable_irq(ds1307->wakeirq);
> +
> + return 0;
> +}
> +
> +static int ds1307_i2c_resume(struct i2c_client *client)
> +{
> + struct ds1307 *ds1307 = i2c_get_clientdata(client);
> + struct device *dev = &client->dev;
> +
> + if (!ds1307->wakeirq)
> + return 0;
> +
> + if (device_may_wakeup(dev))
> + disable_irq_nosync(ds1307->wakeirq);
> +
> + return 0;
> +}
> +
> static int ds1307_probe(struct i2c_client *client,
> const struct i2c_device_id *id)
> {
> @@ -1116,6 +1147,8 @@ read_rtc:
> }
>
> if (want_irq) {
> + struct device_node *node = client->dev.of_node;
> +
> err = request_irq(client->irq, ds1307_irq, IRQF_SHARED,
> ds1307->rtc->name, client);
> if (err) {
> @@ -1125,6 +1158,28 @@ read_rtc:
>
> set_bit(HAS_ALARM, &ds1307->flags);
> dev_dbg(&client->dev, "got IRQ %d\n", client->irq);
> + if (node)
> + ds1307->wakeirq = irq_of_parse_and_map(node, 1);
> +
> + if (ds1307->wakeirq <= 0)
> + ds1307->wakeirq = 0;
> + else
> + err = devm_request_irq(&client->dev,
> + ds1307->wakeirq,
> + ds1307_irq,
> + IRQF_ONESHOT,
> + ds1307->rtc->name,
> + client);
> + if (err) {
> + dev_err(&client->dev, "unable to get wakeIRQ %d\n",
> + err);
> + free_irq(client->irq, client);
> + goto exit;
> + }
> +
> + /* We enable the interrupt only during suspend path */
> + if (ds1307->wakeirq)
> + disable_irq_nosync(ds1307->wakeirq);
> }
> }
>
> @@ -1189,6 +1244,8 @@ static struct i2c_driver ds1307_driver = {
> },
> .probe = ds1307_probe,
> .remove = ds1307_remove,
> + .suspend = ds1307_i2c_suspend,
> + .resume = ds1307_i2c_resume,
> .id_table = ds1307_id,
> };
>
--
Alexandre Belloni, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: drivers/rtc/rtc-ds1307.c: Support optional wakeup interrupt source
2015-05-28 13:06 ` Alexandre Belloni
2015-05-28 13:09 ` [rtc-linux] " Nishanth Menon
@ 2015-05-28 13:09 ` Nishanth Menon
0 siblings, 0 replies; 9+ messages in thread
From: Nishanth Menon @ 2015-05-28 13:09 UTC (permalink / raw)
To: Alexandre Belloni
Cc: Alessandro Zummo, rtc-linux, Tony Lindgren, linux-omap, linux-kernel
Hi Alexandre,
On 05/28/2015 08:06 AM, Alexandre Belloni wrote:
> Do you mind rebasing that one so I can apply it?
>
Thanks for responding. I see Tony has done a changes in [1] -> So, I
will respin my series and repost.
[1] http://marc.info/?l=linux-omap&m=143156023023154&w=2
--
Regards,
Nishanth Menon
^ permalink raw reply [flat|nested] 9+ messages in thread
* [rtc-linux] Re: drivers/rtc/rtc-ds1307.c: Support optional wakeup interrupt source
@ 2015-05-28 13:09 ` Nishanth Menon
0 siblings, 0 replies; 9+ messages in thread
From: Nishanth Menon @ 2015-05-28 13:09 UTC (permalink / raw)
To: Alexandre Belloni
Cc: Alessandro Zummo, rtc-linux, Tony Lindgren, linux-omap, linux-kernel
Hi Alexandre,
On 05/28/2015 08:06 AM, Alexandre Belloni wrote:
> Do you mind rebasing that one so I can apply it?
>
Thanks for responding. I see Tony has done a changes in [1] -> So, I
will respin my series and repost.
[1] http://marc.info/?l=linux-omap&m=143156023023154&w=2
--
Regards,
Nishanth Menon
--
--
You received this message because you are subscribed to "rtc-linux".
Membership options at http://groups.google.com/group/rtc-linux .
Please read http://groups.google.com/group/rtc-linux/web/checklist
before submitting a driver.
---
You received this message because you are subscribed to the Google Groups "rtc-linux" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rtc-linux+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: drivers/rtc/rtc-ds1307.c: Support optional wakeup interrupt source
@ 2015-05-28 13:09 ` Nishanth Menon
0 siblings, 0 replies; 9+ messages in thread
From: Nishanth Menon @ 2015-05-28 13:09 UTC (permalink / raw)
To: Alexandre Belloni
Cc: Alessandro Zummo, rtc-linux, Tony Lindgren, linux-omap, linux-kernel
Hi Alexandre,
On 05/28/2015 08:06 AM, Alexandre Belloni wrote:
> Do you mind rebasing that one so I can apply it?
>
Thanks for responding. I see Tony has done a changes in [1] -> So, I
will respin my series and repost.
[1] http://marc.info/?l=linux-omap&m=143156023023154&w=2
--
Regards,
Nishanth Menon
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2015-05-28 13:11 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-08-21 16:12 [PATCH] drivers/rtc/rtc-ds1307.c: Support optional wakeup interrupt source Nishanth Menon
2014-08-21 16:12 ` Nishanth Menon
2014-08-21 16:12 ` Nishanth Menon
2014-09-03 13:38 ` [PATCH] " Nishanth Menon
2014-09-03 13:38 ` Nishanth Menon
2015-05-28 13:06 ` Alexandre Belloni
2015-05-28 13:09 ` Nishanth Menon
2015-05-28 13:09 ` Nishanth Menon
2015-05-28 13:09 ` [rtc-linux] " Nishanth Menon
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.