drivers/rtc/rtc-as3722: add RTC driver
Subsystems (2)
PATCH v6 3/3 drivers/rtc/rtc-as3722: add RTC driver
The ams AS3722 is a compact system PMU suitable for mobile phones, tablets etc.
Add a driver to support accessing the RTC found on the ams AS3722 PMIC using RTC framework.
---
Changes from V1:
- Get rid of clk32k out configuration from RTC. Will add clock driver.
Changes from V2:
- None.
Changes form V3:
- Change AMS to ams.
Changes form V4:
- None
Changes from V5:
- Use CONFIG_PM_SLEEP instead of CONFIG_PM
- Remove compatiable as it is not used.
- use masked updates for bit enable in place of write to avoid unintentional change.
drivers/rtc/Kconfig | 10 ++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-as3722.c | 280 ++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 291 insertions(+), 0 deletions(-) create mode 100644 drivers/rtc/rtc-as3722.c
drivers/rtc/Kconfig +10 -0
@@ -153,6 +153,16 @@ config RTC_DRV_88PM80X This driver can also be built as a module. If so, the module will be called rtc-88pm80x. +config RTC_DRV_AS3722 + tristate "ams AS3722 RTC driver" + depends on MFD_AS3722 + help + If you say yes here you get support for the RTC of ams AS3722 PMIC + chips. + + This driver can also be built as a module. If so, the module + will be called rtc-as3722. + config RTC_DRV_DS1307 tristate "Dallas/Maxim DS1307/37/38/39/40, ST M41T00, EPSON RX-8025" help
drivers/rtc/Makefile +1 -0
@@ -20,6 +20,7 @@ obj-$(CONFIG_RTC_DRV_88PM860X) += rtc-88pm860x.o obj-$(CONFIG_RTC_DRV_88PM80X) += rtc-88pm80x.o obj-$(CONFIG_RTC_DRV_AB3100) += rtc-ab3100.o obj-$(CONFIG_RTC_DRV_AB8500) += rtc-ab8500.o +obj-$(CONFIG_RTC_DRV_AS3722) += rtc-as3722.o obj-$(CONFIG_RTC_DRV_AT32AP700X)+= rtc-at32ap700x.o obj-$(CONFIG_RTC_DRV_AT91RM9200)+= rtc-at91rm9200.o obj-$(CONFIG_RTC_DRV_AT91SAM9) += rtc-at91sam9.o
drivers/rtc/rtc-as3722.c new file +280 -0
280 lines not on this page · raw message
Signature · 1 line
1.7.1.1
Hi Andrew,
Can you please review this patch?
If it is lost then I will be happy to repost it.
Thanks,
Laxman
Quoted 9 lines · Laxman Dewangan
The ams AS3722 is a compact system PMU suitable for mobile phones, tablets etc.
Add a driver to support accessing the RTC found on the ams AS3722 PMIC using RTC framework.
Signed-off-by Laxman Dewangan <[email protected]>Signed-off-by Florian Lobmaier <[email protected]>
Quoted 25 lines · On Mon, 21 Oct 2013 17:17:21 +0530 Laxman Dewangan <[email protected]> wrote:
The ams AS3722 is a compact system PMU suitable for mobile phones, tablets etc.
Add a driver to support accessing the RTC found on the ams AS3722 PMIC using RTC framework.
...
drivers/rtc/rtc-as3722.c new file +17
-0+static int as3722_rtc_probe (struct platform_device *pdev) +{ +struct as3722 *as3722 =dev_get_drvdata (pdev->dev.parent); +struct as3722_rtc *as3722_rtc; +int ret; + + as3722_rtc =devm_kzalloc (&pdev->dev,sizeof (*as3722_rtc),GFP_KERNEL ); +if (!as3722_rtc) +return -ENOMEM ; + + as3722_rtc->as3722 = as3722; + as3722_rtc->dev = &pdev->dev; +platform_set_drvdata (pdev, as3722_rtc); + +/* Enable the RTC to make sure it is running. */ + ret = as3722_update_bits(as3722, AS3722_RTC_CONTROL_REG, + AS3722_RTC_ON | AS3722_RTC_ALARM_WAKEUP_EN,
drivers/rtc/rtc-as3722.c line 207
Quoted 10 lines
drivers/rtc/rtc-as3722.c new file +10
-0+ AS3722_RTC_ON | AS3722_RTC_ALARM_WAKEUP_EN); +if (ret <0 ) { +dev_err (&pdev->dev,"RTC_CONTROL reg write failed: %d\n" , ret); +return ret; + } + +device_init_wakeup (&pdev->dev,1 ); + + as3722_rtc->rtc =rtc_device_register ("as3722" , &pdev->dev, + &as3722_rtc_ops,THIS_MODULE );
Could use devm_rtc_device_register() here.
drivers/rtc/rtc-as3722.c line 219
Quoted 12 lines
drivers/rtc/rtc-as3722.c new file +12
-0+if (IS_ERR (as3722_rtc->rtc)) { + ret =PTR_ERR (as3722_rtc->rtc); +dev_err (&pdev->dev,"RTC register failed: %d\n" , ret); +return ret; + } + + as3722_rtc->alarm_irq =platform_get_irq (pdev,0 ); +dev_info (&pdev->dev,"RTC interrupt %d\n" , as3722_rtc->alarm_irq); + + ret =request_threaded_irq (as3722_rtc->alarm_irq,NULL , + as3722_alarm_irq,IRQF_ONESHOT |IRQF_EARLY_RESUME , +"rtc-alarm" , as3722_rtc);
devm_request_threaded_irq()?
drivers/rtc/rtc-as3722.c line 225
Quoted 6 lines
drivers/rtc/rtc-as3722.c new file +6
-0+if (ret <0 ) { +dev_err (&pdev->dev,"Failed to request alarm IRQ %d: %d\n" , + as3722_rtc->alarm_irq, ret); + goto scrub; + } +disable_irq (as3722_rtc->alarm_irq);
Why is this necessary?
Would it be safer to do this before the request_threaded_irq()?
Quoted 6 lines
drivers/rtc/rtc-as3722.c new file +6
-0+return 0 ; +scrub: +rtc_device_unregister (as3722_rtc->rtc); +return ret; +} +