rtc: max8997: Add driver for max8997 rtc.
PATCH 1/1 rtc: max8997: Add driver for max8997 rtc.
This patch adds rtc driver for Maxim 8997 multifunction chip. Max8997 has rtc module in it. and it can be used for timekeeping clock and system alarm. It provide various operational mode those are BCD/binary, 24/12hour, am/pm. Driver sets binary/24/ for default. Maxim 8997 also supports SMPL(Sudden Momentary Power Loss), WTSR (Watchdog Timeout and Software Reset).
--- drivers/rtc/Kconfig | 30 +++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-max8997.c | 542 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 573 insertions(+) create mode 100644 drivers/rtc/rtc-max8997.c
drivers/rtc/Kconfig +30 -0
@@ -233,6 +233,36 @@ config RTC_DRV_MAX8998 This driver can also be built as a module. If so, the module will be called rtc-max8998. +config RTC_DRV_MAX8997 + tristate "Maxim MAX8997" + depends on MFD_MAX8997 + help + If you say yes here you will get support for the + RTC of Maxim MAX8997 PMIC. + + This driver can also be built as a module. If so, the module + will be called rtc-max8997. + +config MAX8997_RTC_WTSR + bool "MAX8997_RTC_WTSR" + depends on RTC_DRV_MAX8997 + help + MAX8997 rtc can supports WTSR(Watchdog Timeout and Software Reset). + WTSR event would keep the PMIC on regardless of PWRHOLD signal. + When PWRHOLD signal is falling, it turns on WTSR timer rather executes + reset imidiately. After timer expiring, it determine to reset the PMIC + depends on PWRHOLD state. + +config MAX8997_RTC_SMPL + bool "MAX8997_RTC_SMPL" + depends on RTC_DRV_MAX8997 + help + MAX8997 rtc can supports SMPL(Sudden Momentary Power Loss). + SMPL function can be used to intiate a power up sequence after momentarily + loosing contact to the battery pack. If battery goes under UVLO(Under + Lock Out) it starts SMPL timer. After timer exipiring, it checks battery + whether its state recovers from UVLO or not to make power supplies keep on. + config RTC_DRV_MAX77686 tristate "Maxim MAX77686" depends on MFD_MAX77686
drivers/rtc/Makefile +1 -0
@@ -69,6 +69,7 @@ obj-$(CONFIG_RTC_DRV_MAX6900) += rtc-max6900.o obj-$(CONFIG_RTC_DRV_MAX8907) += rtc-max8907.o obj-$(CONFIG_RTC_DRV_MAX8925) += rtc-max8925.o obj-$(CONFIG_RTC_DRV_MAX8998) += rtc-max8998.o +obj-$(CONFIG_RTC_DRV_MAX8997) += rtc-max8997.o obj-$(CONFIG_RTC_DRV_MAX6902) += rtc-max6902.o obj-$(CONFIG_RTC_DRV_MAX77686) += rtc-max77686.o obj-$(CONFIG_RTC_DRV_MC13XXX) += rtc-mc13xxx.o
drivers/rtc/rtc-max8997.c new file +542 -0
542 lines not on this page · raw message
Signature · 1 line
1.7.9.5
Quoted 34 lines · On Wed, 06 Feb 2013 20:23:05 +0900 Jonghwa Lee <[email protected]> wrote:
This patch adds rtc driver for Maxim 8997 multifunction chip. Max8997 has rtc module in it. and it can be used for timekeeping clock and system alarm. It provide various operational mode those are BCD/binary, 24/12hour, am/pm. Driver sets binary/24/ for default. Maxim 8997 also supports SMPL(Sudden Momentary Power Loss), WTSR (Watchdog Timeout and Software Reset).
...
drivers/rtc/Kconfig +19
-0@@ -233,6 +233,36 @@ config RTC_DRV_MAX8998 This driver can also be built as a module. If so, the module will be called rtc-max8998. +config RTC_DRV_MAX8997 + tristate "Maxim MAX8997" + depends on MFD_MAX8997 + help + If you say yes here you will get support for the + RTC of Maxim MAX8997 PMIC. + + This driver can also be built as a module. If so, the module + will be called rtc-max8997. + +config MAX8997_RTC_WTSR + bool "MAX8997_RTC_WTSR" + depends on RTC_DRV_MAX8997 + help + MAX8997 rtc can supports WTSR(Watchdog Timeout and Software Reset). + WTSR event would keep the PMIC on regardless of PWRHOLD signal. + When PWRHOLD signal is falling, it turns on WTSR timer rather executes + reset imidiately. After timer expiring, it determine to reset the PMIC + depends on PWRHOLD state.
drivers/rtc/Kconfig config RTC_DRV_MAX8998 · line 264
Quoted 10 lines
drivers/rtc/Kconfig +10
-0+ +config MAX8997_RTC_SMPL + bool "MAX8997_RTC_SMPL" + depends on RTC_DRV_MAX8997 + help + MAX8997 rtc can supports SMPL(Sudden Momentary Power Loss). + SMPL function can be used to intiate a power up sequence after momentarily + loosing contact to the battery pack. If battery goes under UVLO(Under + Lock Out) it starts SMPL timer. After timer exipiring, it checks battery + whether its state recovers from UVLO or not to make power supplies keep on.
Can we avoid creating CONFIG_MAX8997_RTC_WTSR and CONFIG_MAX8997_RTC_SMPL? It would be much better for the users if these features were always available in all kernel builds.
The best way of handling this sort of thing is for the driver to probe the hardware, work out its capabilities and "do the right thing".
The second best way is to require that the user add certain module parameters to enable the functionality.
The worst way is to require the user to make the decision at kernel build time!
Quoted 43 lines · Andrew Morton
Quoted 40 lines · On Wed, 06 Feb 2013 20:23:05 +0900 Jonghwa Lee <[email protected]> wrote:
This patch adds rtc driver for Maxim 8997 multifunction chip. Max8997 has rtc module in it. and it can be used for timekeeping clock and system alarm. It provide various operational mode those are BCD/binary, 24/12hour, am/pm. Driver sets binary/24/ for default. Maxim 8997 also supports SMPL(Sudden Momentary Power Loss), WTSR (Watchdog Timeout and Software Reset).
...
drivers/rtc/Kconfig +25
-0@@ -233,6 +233,36 @@ config RTC_DRV_MAX8998 This driver can also be built as a module. If so, the module will be called rtc-max8998. +config RTC_DRV_MAX8997 + tristate "Maxim MAX8997" + depends on MFD_MAX8997 + help + If you say yes here you will get support for the + RTC of Maxim MAX8997 PMIC. + + This driver can also be built as a module. If so, the module + will be called rtc-max8997. + +config MAX8997_RTC_WTSR + bool "MAX8997_RTC_WTSR" + depends on RTC_DRV_MAX8997 + help + MAX8997 rtc can supports WTSR(Watchdog Timeout and Software Reset). + WTSR event would keep the PMIC on regardless of PWRHOLD signal. + When PWRHOLD signal is falling, it turns on WTSR timer rather executes + reset imidiately. After timer expiring, it determine to reset the PMIC + depends on PWRHOLD state. + +config MAX8997_RTC_SMPL + bool "MAX8997_RTC_SMPL" + depends on RTC_DRV_MAX8997 + help + MAX8997 rtc can supports SMPL(Sudden Momentary Power Loss).
Quoted 9 lines
drivers/rtc/Kconfig config RTC_DRV_MAX8998 · line 264
Quoted 4 lines
drivers/rtc/Kconfig +4
-0+ SMPL function can be used to intiate a power up sequence after momentarily + loosing contact to the battery pack. If battery goes under UVLO(Under + Lock Out) it starts SMPL timer. After timer exipiring, it checks battery + whether its state recovers from UVLO or not to make power supplies keep on.Can we avoid creating
CONFIG_MAX8997_RTC_WTSRandCONFIG_MAX8997_RTC_SMPL? It would be much better for the users if these features were always available in all kernel builds.
Okay, I'll apply it.
Quoted 6 lines
The best way of handling this sort of thing is for the driver to probe the hardware, work out its capabilities and "do the right thing".
The second best way is to require that the user add certain module parameters to enable the functionality.
How do we create sysfs node for enabling these options?
Thanks,
Jonghwa
Quoted 4 lines
The worst way is to require the user to make the decision at kernel build time!
Quoted 8 lines · On Thu, 07 Feb 2013 10:43:23 +0900 [email protected] wrote:
Quoted 6 lines
The best way of handling this sort of thing is for the driver to probe the hardware, work out its capabilities and "do the right thing".
The second best way is to require that the user add certain module parameters to enable the functionality.
How do we create sysfs node for enabling these options?
I suggest using module_param[_named](), so users can execute "modprobe max8997 wtsr=1". Or, if the driver is built into vmlinux, add "max8997.wtsr=1" to the kernel boot command line.
Documentation/kernel-parameters.txt mentions this.
Quoted 9 lines · Andrew Morton
Quoted 7 lines · On Thu, 07 Feb 2013 10:43:23 +0900 [email protected] wrote:
Quoted 6 lines
The best way of handling this sort of thing is for the driver to probe the hardware, work out its capabilities and "do the right thing".
The second best way is to require that the user add certain module parameters to enable the functionality.
Quoted 8 lines
Quoted 1 line
How do we create sysfs node for enabling these options?
I suggest using module_param[_named](), so users can execute "modprobe max8997 wtsr=1". Or, if the driver is built into vmlinux, add "max8997.wtsr=1" to the kernel boot command line.
Documentation/kernel-parameters.txtmentions this.
Sorry, my question was incorrect, I meant to suggest to create sysfs node not to ask you to let me know how to implement sysfs node. Anyway I'll apply your comment and re-patch it soon.
Thanks,
Jonghwa
Hello,
Quoted 48 lines · Jonghwa Lee
This patch adds rtc driver for Maxim 8997 multifunction chip. Max8997 has rtc module in it. and it can be used for timekeeping clock and system alarm. It provide various operational mode those are BCD/binary, 24/12hour, am/pm. Driver sets binary/24/ for default. Maxim 8997 also supports SMPL(Sudden Momentary Power Loss), WTSR (Watchdog Timeout and Software Reset).
Signed-off-by Jonghwa Lee <[email protected]>--- drivers/rtc/Kconfig | 30 +++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-max8997.c | 542 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 573 insertions(+) create mode 100644 drivers/rtc/rtc-max8997.cdrivers/rtc/rtc-max8997.c new file +33
-0+ +static int max8997_rtc_probe (struct platform_device *pdev) +{ +struct max8997_dev *max8997 =dev_get_drvdata (pdev->dev.parent); +struct max8997_rtc_info *info; +int ret, virq; + + info =devm_kzalloc (&pdev->dev,sizeof (struct max8997_rtc_info ), +GFP_KERNEL ); +if (!info) +return -ENOMEM ; + +mutex_init (&info->lock); + info->dev = &pdev->dev; + info->max8997 = max8997; + info->rtc = max8997->rtc; + +platform_set_drvdata (pdev, info); + + ret =max8997_rtc_init_reg (info); + +if (ret <0 ) { +dev_err (&pdev->dev,"Failed to initialize RTC reg:%d\n" , ret); +return ret; + } + +max8997_rtc_enable_wtsr (info, true); +max8997_rtc_enable_smpl (info, true); + +device_init_wakeup (&pdev->dev,1 ); + + info->rtc_dev =rtc_device_register ("max8997-rtc" , &pdev->dev, + &max8997_rtc_ops,THIS_MODULE );
drivers/rtc/rtc-max8997.c line 486
Quoted 10 lines
drivers/rtc/rtc-max8997.c new file +10
-0+ +if (IS_ERR (info->rtc_dev)) { + ret =PTR_ERR (info->rtc_dev); +dev_err (&pdev->dev,"Failed to register RTC device: %d\n" , ret); +return ret; + } + + virq =irq_create_mapping (max8997->irq_domain,MAX8997_PMICIRQ_RTCA1 ); +if (!virq) { +dev_err (&pdev->dev,"Failed to create mapping alarm IRQ\n" );
+ rtc_device_unregister(&pdev->dev, &max8997_rtc_ops) ?
drivers/rtc/rtc-max8997.c line 495
Quoted 9 lines
drivers/rtc/rtc-max8997.c new file +9
-0+return ret; + } + info->virq = virq; + + ret =request_threaded_irq (virq,NULL , max8997_rtc_alarm_irq,0 , +"rtc-alarm0" , info); +if (ret <0 ) { +dev_err (&pdev->dev,"Failed to request alarm IRQ: %d: %d\n" , + info->virq, ret);
+ here unregistering the rtc dev too?
drivers/rtc/rtc-max8997.c line 142
Quoted 6 lines
drivers/rtc/rtc-max8997.c new file +6
-0+return ret; + } + +return ret; +} +
Thanks,
Quoted 54 lines · devendra.aaru
Hello,
Quoted 51 lines · Jonghwa Lee
This patch adds rtc driver for Maxim 8997 multifunction chip. Max8997 has rtc module in it. and it can be used for timekeeping clock and system alarm. It provide various operational mode those are BCD/binary, 24/12hour, am/pm. Driver sets binary/24/ for default. Maxim 8997 also supports SMPL(Sudden Momentary Power Loss), WTSR (Watchdog Timeout and Software Reset).
Signed-off-by Jonghwa Lee <[email protected]>--- drivers/rtc/Kconfig | 30 +++ drivers/rtc/Makefile | 1 + drivers/rtc/rtc-max8997.c | 542 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 573 insertions(+) create mode 100644 drivers/rtc/rtc-max8997.cdrivers/rtc/rtc-max8997.c new file +36
-0+ +static int max8997_rtc_probe (struct platform_device *pdev) +{ +struct max8997_dev *max8997 =dev_get_drvdata (pdev->dev.parent); +struct max8997_rtc_info *info; +int ret, virq; + + info =devm_kzalloc (&pdev->dev,sizeof (struct max8997_rtc_info ), +GFP_KERNEL ); +if (!info) +return -ENOMEM ; + +mutex_init (&info->lock); + info->dev = &pdev->dev; + info->max8997 = max8997; + info->rtc = max8997->rtc; + +platform_set_drvdata (pdev, info); + + ret =max8997_rtc_init_reg (info); + +if (ret <0 ) { +dev_err (&pdev->dev,"Failed to initialize RTC reg:%d\n" , ret); +return ret; + } + +max8997_rtc_enable_wtsr (info, true); +max8997_rtc_enable_smpl (info, true); + +device_init_wakeup (&pdev->dev,1 ); + + info->rtc_dev =rtc_device_register ("max8997-rtc" , &pdev->dev, + &max8997_rtc_ops,THIS_MODULE ); + +if (IS_ERR (info->rtc_dev)) { + ret =PTR_ERR (info->rtc_dev);
Quoted 8 lines
drivers/rtc/rtc-max8997.c line 486
Quoted 7 lines
drivers/rtc/rtc-max8997.c new file +7
-0+dev_err (&pdev->dev,"Failed to register RTC device: %d\n" , ret); +return ret; + } + + virq =irq_create_mapping (max8997->irq_domain,MAX8997_PMICIRQ_RTCA1 ); +if (!virq) { +dev_err (&pdev->dev,"Failed to create mapping alarm IRQ\n" );+
rtc_device_unregister(&pdev->dev, &max8997_rtc_ops)?
Yes, It should be,,
Quoted 10 lines
drivers/rtc/rtc-max8997.c line 495
Quoted 9 lines
drivers/rtc/rtc-max8997.c new file +9
-0+return ret; + } + info->virq = virq; + + ret =request_threaded_irq (virq,NULL , max8997_rtc_alarm_irq,0 , +"rtc-alarm0" , info); +if (ret <0 ) { +dev_err (&pdev->dev,"Failed to request alarm IRQ: %d: %d\n" , + info->virq, ret);+ here unregistering the rtc dev too?
also
Quoted 7 lines
drivers/rtc/rtc-max8997.c line 142
Quoted 6 lines
drivers/rtc/rtc-max8997.c new file +6
-0+return ret; + } + +return ret; +} +
Thanks for reviewing, I'll fix it.
Thanks,
Jonghwa
Quoted 3 lines
Thanks,