aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDenis Osterland <Denis.Osterland@diehl.com>2018-07-24 07:31:21 -0400
committerAlexandre Belloni <alexandre.belloni@bootlin.com>2018-08-14 17:03:19 -0400
commit9ece7cd833a3e5e0740e2b681abe6ce5e6af6885 (patch)
treec7b15f7b52a75088a10a7ae7c2cef9d83e9adfab
parentdd35bdb0768f1d03b043c4ba704fe9760eaa5891 (diff)
rtc: isl1208: Add "evdet" interrupt source for isl1219
Add support for "evdet" named interrupt source. The check if i2c client irq matches evdet irq is needed for the case that there is only one interrupt named "evdet". In this case i2c client code handles this like an unnamed interrupt souce and assigns the value. Signed-off-by: Denis Osterland <Denis.Osterland@diehl.com> Reviewed-by: Michael Grzeschik <m.grzeschik@pengutronix.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
-rw-r--r--drivers/rtc/rtc-isl1208.c46
1 files changed, 30 insertions, 16 deletions
diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c
index d426eac965e9..f4eb3e11de28 100644
--- a/drivers/rtc/rtc-isl1208.c
+++ b/drivers/rtc/rtc-isl1208.c
@@ -15,6 +15,7 @@
15#include <linux/bcd.h> 15#include <linux/bcd.h>
16#include <linux/rtc.h> 16#include <linux/rtc.h>
17#include "rtc-core.h" 17#include "rtc-core.h"
18#include <linux/of_irq.h>
18 19
19/* Register map */ 20/* Register map */
20/* rtc section */ 21/* rtc section */
@@ -725,11 +726,30 @@ static const struct attribute_group isl1219_rtc_sysfs_files = {
725 .attrs = isl1219_rtc_attrs, 726 .attrs = isl1219_rtc_attrs,
726}; 727};
727 728
729static int isl1208_setup_irq(struct i2c_client *client, int irq)
730{
731 int rc = devm_request_threaded_irq(&client->dev, irq, NULL,
732 isl1208_rtc_interrupt,
733 IRQF_SHARED | IRQF_ONESHOT,
734 isl1208_driver.driver.name,
735 client);
736 if (!rc) {
737 device_init_wakeup(&client->dev, 1);
738 enable_irq_wake(irq);
739 } else {
740 dev_err(&client->dev,
741 "Unable to request irq %d, no alarm support\n",
742 irq);
743 }
744 return rc;
745}
746
728static int 747static int
729isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id) 748isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id)
730{ 749{
731 int rc = 0; 750 int rc = 0;
732 struct rtc_device *rtc; 751 struct rtc_device *rtc;
752 int evdet_irq = -1;
733 753
734 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) 754 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
735 return -ENODEV; 755 return -ENODEV;
@@ -766,28 +786,22 @@ isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id)
766 rc = rtc_add_group(rtc, &isl1219_rtc_sysfs_files); 786 rc = rtc_add_group(rtc, &isl1219_rtc_sysfs_files);
767 if (rc) 787 if (rc)
768 return rc; 788 return rc;
789 evdet_irq = of_irq_get_byname(client->dev.of_node, "evdet");
769 } 790 }
770 791
771 rc = sysfs_create_group(&client->dev.kobj, &isl1208_rtc_sysfs_files); 792 rc = sysfs_create_group(&client->dev.kobj, &isl1208_rtc_sysfs_files);
772 if (rc) 793 if (rc)
773 return rc; 794 return rc;
774 795
775 if (client->irq > 0) { 796 if (client->irq > 0)
776 rc = devm_request_threaded_irq(&client->dev, client->irq, NULL, 797 rc = isl1208_setup_irq(client, client->irq);
777 isl1208_rtc_interrupt, 798 if (rc)
778 IRQF_SHARED | IRQF_ONESHOT, 799 return rc;
779 isl1208_driver.driver.name, 800
780 client); 801 if (evdet_irq > 0 && evdet_irq != client->irq)
781 if (!rc) { 802 rc = isl1208_setup_irq(client, evdet_irq);
782 device_init_wakeup(&client->dev, 1); 803 if (rc)
783 enable_irq_wake(client->irq); 804 return rc;
784 } else {
785 dev_err(&client->dev,
786 "Unable to request irq %d, no alarm support\n",
787 client->irq);
788 client->irq = 0;
789 }
790 }
791 805
792 return rtc_register_device(rtc); 806 return rtc_register_device(rtc);
793} 807}