rtc: tps65910: Add RTC driver for TPS65910 PMIC RTC
Subsystems (2)
PATCH v2 1/1 rtc: tps65910: Add RTC driver for TPS65910 PMIC RTC
TPS65910 PMIC is a MFD with RTC as one of the device. Adding RTC driver for supporting RTC device present inside TPS65910 PMIC.
Only support for RTC alarm is implemented as part of this patch.
---
delta from patch v1:
1. Added const qualifier to rtc_class_ops
2. Removed some of the local variables initialization
3. Passing string "rtc-tps65910" to devm_request_threaded_irq.
4. Changed driver name from "tps65910-rtc" to "rtc-tps65910"
drivers/rtc/Kconfig | 10 ++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-tps65910.c | 353 ++++++++++++++++++++++++++++++++++++++++++ include/linux/mfd/tps65910.h | 10 ++ 4 files changed, 374 insertions(+), 0 deletions(-) create mode 100644 drivers/rtc/rtc-tps65910.c
drivers/rtc/Kconfig +10 -0
@@ -333,6 +333,16 @@ config RTC_DRV_TWL4030 This driver can also be built as a module. If so, the module will be called rtc-twl. +config RTC_DRV_TPS65910 + tristate "TI TPS65910 RTC driver" + depends on RTC_CLASS && MFD_TPS65910 + help + If you say yes here you get support for the RTC on the + TPS65910 chips. + + This driver can also be built as a module. If so, the module + will be called rtc-tps65910. + config RTC_DRV_S35390A tristate "Seiko Instruments S-35390A" select BITREVERSE
drivers/rtc/Makefile +1 -0
@@ -105,6 +105,7 @@ obj-$(CONFIG_RTC_DRV_TEGRA) += rtc-tegra.o obj-$(CONFIG_RTC_DRV_TEST) += rtc-test.o obj-$(CONFIG_RTC_DRV_TILE) += rtc-tile.o obj-$(CONFIG_RTC_DRV_TWL4030) += rtc-twl.o +obj-$(CONFIG_RTC_DRV_TPS65910) += rtc-tps65910.o obj-$(CONFIG_RTC_DRV_TX4939) += rtc-tx4939.o obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o
drivers/rtc/rtc-tps65910.c new file +353 -0
353 lines not on this page · raw message
include/linux/mfd/tps65910.h +10 -0
@@ -132,6 +132,16 @@* */ +/* RTC_CTRL_REG bitfields */ +#define TPS65910_RTC_CTRL_STOP_RTC 0x01/*0=stop, 1=run */ +#define TPS65910_RTC_CTRL_GET_TIME 0x40 + +/* RTC_STATUS_REG bitfields */ +#define TPS65910_RTC_STATUS_ALARM 0x40 + +/* RTC_INTERRUPTS_REG bitfields */ +#define TPS65910_RTC_INTERRUPTS_EVERY 0x03 +#define TPS65910_RTC_INTERRUPTS_IT_ALARM 0x08/*Register BCK1 (0x80) register.RegisterDescription */ #define BCK1_BCKUP_MASK 0xFF
Signature · 1 line
1.7.1.1
hi,
El Wed, Aug 01, 2012 at 11:52:37AM +0530 Venu Byravarasu ha dit:
Quoted 8 lines
TPS65910 PMIC is a MFD with RTC as one of the device. Adding RTC driver for supporting RTC device present inside TPS65910 PMIC.
Only support for RTC alarm is implemented as part of this patch.
Signed-off-by Venu Byravarasu <[email protected]>---
...
Quoted 22 lines
drivers/rtc/rtc-tps65910.c new file +16
-0+static irqreturn_t tps65910_rtc_interrupt (int irq,void *rtc) +{ +struct device *dev = rtc; +unsigned long events =0 ; +struct tps65910 *tps =dev_get_drvdata (dev->parent); +struct tps65910_rtc *tps_rtc =dev_get_drvdata (dev); +static int __devinit tps65910_rtc_probe (struct platform_device *pdev) +{ + ret =devm_request_threaded_irq (&pdev->dev, irq,NULL , + tps65910_rtc_interrupt,IRQF_TRIGGER_LOW , +"rtc-tps65910" , &pdev->dev); +if (ret <0 ) { +dev_err (&pdev->dev,"IRQ is not free.\n" ); +return ret; + } +device_init_wakeup (&pdev->dev,1 );
drivers/rtc/rtc-tps65910.c line 282
Quoted 10 lines
drivers/rtc/rtc-tps65910.c new file +10
-0+ + tps_rtc->rtc =rtc_device_register (pdev->name, &pdev->dev, + &tps65910_rtc_ops,THIS_MODULE ); +if (IS_ERR (tps_rtc->rtc)) { + ret =PTR_ERR (tps_rtc->rtc); +dev_err (&pdev->dev,"RTC device register: err %d\n" , ret); +return ret; + } + +platform_set_drvdata (pdev, tps_rtc);
the interrupt should be requested after this call. otherwise tps65910_rtc_interrupt() could be executed before the RTC device is registered and the driver data set. normally this shouldn't happen as the RTC interrupts are disabled after reset, but the interrupts could have been enabled for example by the bootloader
best regards
Signature · 10 lines
Matthias Kaehlcke
Embedded Linux Developer
Amsterdam
Anyone who has never made a mistake has never tried anything new
(Albert Einstein)
.''`.
using free software / Debian GNU/Linux | http://debian.org : :' :
`. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4 `-Quoted 55 lines
-----Original Message-----
From: Matthias Kaehlcke [mailto:[email protected]]
Sent: Thursday, August 02, 2012 1:48 AM
To: Venu Byravarasu
Cc: [email protected]; [email protected]; [email protected]; Laxman Dewangan; [email protected]; [email protected]; rtc- [email protected]; [email protected]
Subject: Re: [PATCH v2] rtc: tps65910: Add RTC driver for TPS65910 PMIC RTChi,
El Wed, Aug 01, 2012 at 11:52:37AM +0530 Venu Byravarasu ha dit:
Quoted 8 lines
TPS65910 PMIC is a MFD with RTC as one of the device. Adding RTC driver for supporting RTC device present inside TPS65910 PMIC.
Only support for RTC alarm is implemented as part of this patch.
Signed-off-by Venu Byravarasu <[email protected]>---
...
Quoted 30 lines
drivers/rtc/rtc-tps65910.c new file +24
-0+static irqreturn_t tps65910_rtc_interrupt (int irq,void *rtc) +{ +struct device *dev = rtc; +unsigned long events =0 ; +struct tps65910 *tps =dev_get_drvdata (dev->parent); +struct tps65910_rtc *tps_rtc =dev_get_drvdata (dev); +static int __devinit tps65910_rtc_probe (struct platform_device *pdev) +{ + ret =devm_request_threaded_irq (&pdev->dev, irq,NULL , + tps65910_rtc_interrupt,IRQF_TRIGGER_LOW , +"rtc-tps65910" , &pdev->dev); +if (ret <0 ) { +dev_err (&pdev->dev,"IRQ is not free.\n" ); +return ret; + } +device_init_wakeup (&pdev->dev,1 ); + + tps_rtc->rtc =rtc_device_register (pdev->name, &pdev->dev, + &tps65910_rtc_ops,THIS_MODULE ); +if (IS_ERR (tps_rtc->rtc)) { + ret =PTR_ERR (tps_rtc->rtc); +dev_err (&pdev->dev,"RTC device register: err %d\n" , ret); +return ret; + }
Quoted 8 lines
drivers/rtc/rtc-tps65910.c line 282
Quoted 2 lines
drivers/rtc/rtc-tps65910.c new file +2
-0+ +platform_set_drvdata (pdev, tps_rtc);the interrupt should be requested after this call. otherwise
tps65910_rtc_interrupt()could be executed before the RTC device is registered and the driver data set. normally this shouldn't happen as the RTC interrupts are disabled after reset, but the interrupts could have been enabled for example by the bootloader
Hi Matthias,
Thanks for your comments.
All pending RTC interrupts are being cleared in probe, before enabling RTC itself. Hence chances of stray interrupts from boot loader cannot cause any trouble here.
The only possible way of getting interrupt by kernel driver is by enabling tps65910_rtc_alarm_irq_enable() && setting alarm time using tps65910_rtc_set_alarm. However before probe gets completed as these two APIs will not get called together by the client, I do not see any false interrupt getting generated.
Please let me know if I miss something.
Thanks,
Venu
Quoted 14 lines
best regards
--
Matthias Kaehlcke
Embedded Linux Developer
AmsterdamAnyone who has never made a mistake has never tried anything new
(Albert Einstein)
.''`.
using free software / Debian GNU/Linux | http://debian.org : :' :
.'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4 `-
Hi Venu,
thanks for you reply
El Thu, Aug 02, 2012 at 10:28:47AM +0530 Venu Byravarasu ha dit:
Quoted 66 lines
Quoted 55 lines
-----Original Message-----
From: Matthias Kaehlcke [mailto:[email protected]]
Sent: Thursday, August 02, 2012 1:48 AM
To: Venu Byravarasu
Cc: [email protected]; [email protected]; [email protected]; Laxman Dewangan; [email protected]; [email protected]; rtc- [email protected]; [email protected]
Subject: Re: [PATCH v2] rtc: tps65910: Add RTC driver for TPS65910 PMIC RTChi,
El Wed, Aug 01, 2012 at 11:52:37AM +0530 Venu Byravarasu ha dit:
Quoted 8 lines
TPS65910 PMIC is a MFD with RTC as one of the device. Adding RTC driver for supporting RTC device present inside TPS65910 PMIC.
Only support for RTC alarm is implemented as part of this patch.
Signed-off-by Venu Byravarasu <[email protected]>---
...
Quoted 30 lines
drivers/rtc/rtc-tps65910.c new file +24
-0+static irqreturn_t tps65910_rtc_interrupt (int irq,void *rtc) +{ +struct device *dev = rtc; +unsigned long events =0 ; +struct tps65910 *tps =dev_get_drvdata (dev->parent); +struct tps65910_rtc *tps_rtc =dev_get_drvdata (dev); +static int __devinit tps65910_rtc_probe (struct platform_device *pdev) +{ + ret =devm_request_threaded_irq (&pdev->dev, irq,NULL , + tps65910_rtc_interrupt,IRQF_TRIGGER_LOW , +"rtc-tps65910" , &pdev->dev); +if (ret <0 ) { +dev_err (&pdev->dev,"IRQ is not free.\n" ); +return ret; + } +device_init_wakeup (&pdev->dev,1 ); + + tps_rtc->rtc =rtc_device_register (pdev->name, &pdev->dev, + &tps65910_rtc_ops,THIS_MODULE ); +if (IS_ERR (tps_rtc->rtc)) { + ret =PTR_ERR (tps_rtc->rtc); +dev_err (&pdev->dev,"RTC device register: err %d\n" , ret); +return ret; + }Quoted 8 lines
drivers/rtc/rtc-tps65910.c line 282
Quoted 2 lines
drivers/rtc/rtc-tps65910.c new file +2
-0+ +platform_set_drvdata (pdev, tps_rtc);the interrupt should be requested after this call. otherwise
tps65910_rtc_interrupt()could be executed before the RTC device is registered and the driver data set. normally this shouldn't happen as the RTC interrupts are disabled after reset, but the interrupts could have been enabled for example by the bootloaderHi Matthias,
Quoted 8 lines
Thanks for your comments.
All pending RTC interrupts are being cleared in probe, before enabling RTC itself. Hence chances of stray interrupts from boot loader cannot cause any trouble here.The only possible way of getting interrupt by kernel driver is by enabling
tps65910_rtc_alarm_irq_enable()&& setting alarm time usingtps65910_rtc_set_alarm. However before probe gets completed as these two APIs will not get called together by the client, I do not see any false interrupt getting generated.
i was thinking in the periodic interrupts, but now noticed that the driver only registers to the alarm interrupts, so this is not a problem
kind regards
Signature · 9 lines
Matthias Kaehlcke
Embedded Linux Developer
Amsterdam
El optimista tiene siempre un proyecto; el pesimista, una excusa
.''`.
using free software / Debian GNU/Linux | http://debian.org : :' :
`. `'`
gpg --keyserver pgp.mit.edu --recv-keys 47D8E5D4 `-