summaryrefslogtreecommitdiffstats
path: root/drivers/rtc/rtc-ds3232.c
AgeCommit message (Collapse)AuthorFilesLines
2021-02-06rtc: ds3232: quiet maybe-unused variable warningAlexandre Belloni1-1/+1
When CONFIG_OF is disabled then the matching table is not referenced. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20210202112219.3610853-8-alexandre.belloni@bootlin.com
2021-01-25rtc: ds3232: use rtc_lock/rtc_unlockAlexandre Belloni1-3/+2
Avoid accessing directly rtc->ops_lock and use the RTC core helpers. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20210119220653.677750-6-alexandre.belloni@bootlin.com
2020-11-19rtc: add devm_ prefix to rtc_nvmem_register()Bartosz Golaszewski1-1/+1
rtc_nvmem_register() is a managed interface. It doesn't require any release function to be called at driver detach. To avoid confusing driver authors, let's rename it to devm_rtc_nvmem_register() and add it to the list of managed interfaces in Documentation/. Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20201109163409.24301-6-brgl@bgdev.pl
2019-05-30treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 152Thomas Gleixner1-5/+1
Based on 1 normalized pattern(s): this program is free software you can redistribute it and or modify it under the terms of the gnu general public license as published by the free software foundation either version 2 of the license or at your option any later version extracted by the scancode license scanner the SPDX license identifier GPL-2.0-or-later has been chosen to replace the boilerplate/reference in 3029 file(s). Signed-off-by: Thomas Gleixner <tglx@linutronix.de> Reviewed-by: Allison Randal <allison@lohutok.net> Cc: linux-spdx@vger.kernel.org Link: https://lkml.kernel.org/r/20190527070032.746973796@linutronix.de Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-04-19rtc: ds3232: get SRAM access using NVMEM FrameworkHan Nandor1-2/+38
DS3232 RTC has 236 bytes of persistent memory. Add RTC SRAM read and write access using the NVMEM Framework. Signed-off-by: Han Nandor <nandor.han@vaisala.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2018-03-02rtc: stop validating rtc_time in .read_timeAlexandre Belloni1-1/+1
The RTC core is always calling rtc_valid_tm after the read_time callback. It is not necessary to call it just before returning from the callback. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
2017-07-06rtc: ds3232: add temperature supportKirill Esipov1-0/+119
DS3232/DS3234 has the temperature registers with a resolution of 0.25 degree celsius. This enables to get the value through hwmon. # cat /sys/class/hwmon/hwmon0/temp1_input 37250 Signed-off-by: Kirill Esipov <yesipov@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-03-09rtc: ds3232: Add OF device ID tableJavier Martinez Canillas1-0/+7
The driver doesn't have a struct of_device_id table but supported devices are registered via Device Trees. This is working on the assumption that a I2C device registered via OF will always match a legacy I2C device ID and that the MODALIAS reported will always be of the form i2c:<device>. But this could change in the future so the correct approach is to have an OF device ID table if the devices are registered via OF. Signed-off-by: Javier Martinez Canillas <javier@osg.samsung.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-02-24rtc: ds3232: Call device_init_wakeup before device_registerPhil Reid1-2/+5
The wakealarm attribute is currently not exposed in the sysfs interface as the device has not been set as doing wakealarm when device_register is called. Changing the order of the calls fixes that problem. Interrupts are cleared in check_rtc_status prior to requesting the interrupt. This is only set if an irq is defined. If irq registration fails then set wakeup_capable to false. With this change the sysfs wakealarm attribute will be left visible but it is non functional. rtcwake still returns that the device is not enabled for wakeup. Signed-off-by: Phil Reid <preid@electromag.com.au> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-02-21rtc: ds3232: Add regmap max_register definition.Phil Reid1-0/+2
Add the max_register to the regmap_config definition. This allows dumping of the device's registers via the regmap debugfs interface. Signed-off-by: Phil Reid <preid@electromag.com.au> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2017-02-21rtc: ds3232: Cleanup whitespace around register and bit definitions.Phil Reid1-22/+22
Whitespace was a combination of spaces and tabs. Use spaces and align register / bit definitions. Signed-off-by: Phil Reid <preid@electromag.com.au> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-07-09rtc: simplify implementations of read_alarmUwe Kleine-König1-6/+0
Since commit d68778b80dd7 ("rtc: initialize output parameter for read alarm to "uninitialized"") there is no need to explicitly set unsupported members to -1. So drop the respective assignments from drivers. Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-05-20rtc: ds3232: fix call trace when rtc->ops_lock is used as NULLQianyu Gong1-3/+6
The rtc->ops_lock would be accessed in ds3232_irq() without being initialized as rtc_device_register() is called too late. So move devm_rtc_device_register() just before registering irq handler to initialize rtc->ops_lock earlier. Signed-off-by: Gong Qianyu <Qianyu.Gong@nxp.com> Reviewed-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-03-14rtc: ds3232: use rtc->ops_lock to protect alarm operationsAkinobu Mita1-21/+4
ds3232->mutex is used to protect for alarm operations which need to access status and control registers. But we can use rtc->ops_lock instead. rtc->ops_lock is held when most of rtc_class_ops methods are called, so we only need to explicitly acquire it from irq handler in order to protect form concurrent accesses. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-03-14rtc: ds3232: fix issue when irq is shared several devicesAkinobu Mita1-69/+12
ds3232-core requests irq with IRQF_SHARED, so irq can be shared by several devices. But the irq handler for ds3232 unconditionally disables the irq at first and the irq is re-enabled only when the interrupt source was the ds3232's alarm. This behaviour breaks the devices sharing the same irq in the various scenarios. This converts to use threaded irq and remove outdated code in suspend/resume paths. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Suggested-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-03-14rtc: ds3232: remove unused UIE codeAkinobu Mita1-19/+1
UIE mode irqs are handled by the generic rtc core now. But there are remaining unused code fragments for it. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-03-14rtc: ds3232: add register access error checksAkinobu Mita1-7/+22
Add missing register access error checks and make it return error code or print error message. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-03-14rtc: ds3232: fix read on /dev/rtc after RTC_AIE_ONAkinobu Mita1-7/+3
The rtctest (tools/testing/selftests/timers/rtctest.c) found that reading ds3232 rtc device immediately return the value 0x20 (RTC_AF) without waiting alarm interrupt. This is because alarm_irq_enable() of ds3232 driver changes RTC_AF flag in rtc->irq_data. So calling ioctl with RTC_AIE_ON generates invalid value in rtc device. The lower-level driver should not touch rtc->irq_data directly. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-03-14rtc: merge ds3232 and ds3234Akinobu Mita1-3/+164
According to "Feature Comparison of the DS323x Real-Time Clocks" (http://pdfserv.maximintegrated.com/en/an/AN5143.pdf), DS3232 and DS3234 are very similar. This merges rtc-ds3232 and rtc-ds3234 with using regmap. This change also enables to support alarm for ds3234. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Suggested-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-03-14rtc: ds3232: convert to use regmapAkinobu Mita1-103/+113
This is preparation for merging rtc-ds3232 i2c driver and rtc-ds3234 spi driver. Signed-off-by: Akinobu Mita <akinobu.mita@gmail.com> Cc: Alessandro Zummo <a.zummo@towertech.it> Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com> Cc: Dennis Aberilla <denzzzhome@yahoo.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2015-09-05rtc: ds3232: fix WARNING trace in resume functionWang Dongsheng1-1/+4
If ds3232 work on some platform that is not implementing irq_set_wake, ds3232 will get a WARNING trace in resume. So fix ds3232->suspended state to false when irq_set_irq_wake return error. WARNING: CPU: 0 PID: 729 at kernel/irq/manage.c:604 irq_set_irq_wake+0x4b/0x8c() Unbalanced IRQ 201 wake disable Modules linked in: CPU: 0 PID: 729 Comm: sh Not tainted 3.12.19-rt30+ #25 [<800107d9>] (unwind_backtrace+0x1/0x88) from [<8000e4ef>] (show_stack+0xb/0xc) [<8000e4ef>] (show_stack+0xb/0xc) from [<802b5fa9>] (dump_stack+0x4d/0x60) [<802b5fa9>] (dump_stack+0x4d/0x60) from [<800186dd>] (warn_slowpath_common+0x45/0x64) [<800186dd>] (warn_slowpath_common+0x45/0x64) from [<80018717>] (warn_slowpath_fmt+0x1b/0x24) [<80018717>] (warn_slowpath_fmt+0x1b/0x24) from [<8003a8d3>] (irq_set_irq_wake+0x4b/0x8c) [<8003a8d3>] (irq_set_irq_wake+0x4b/0x8c) from [<80204fcb>] (ds3232_resume+0x2d/0x36) [<80204fcb>] (ds3232_resume+0x2d/0x36) from [<801954c7>] (dpm_run_callback.isra.13+0xb/0x28) [<801954c7>] (dpm_run_callback.isra.13+0xb/0x28) from [<80195b1b>] (device_resume+0x7b/0xa2) [<80195b1b>] (device_resume+0x7b/0xa2) from [<80195f0f>] (dpm_resume+0xbb/0x19c) [<80195f0f>] (dpm_resume+0xbb/0x19c) from [<801960d9>] (dpm_resume_end+0x9/0x12) [<801960d9>] (dpm_resume_end+0x9/0x12) from [<80037e1d>] (suspend_devices_and_enter+0x17d/0x1d0) [<80037e1d>] (suspend_devices_and_enter+0x17d/0x1d0) from [<80037ee1>] (pm_suspend+0x71/0x128) [<80037ee1>] (pm_suspend+0x71/0x128) from [<80037449>] (state_store+0x6d/0x80) [<80037449>] (state_store+0x6d/0x80) from [<800af4d5>] (sysfs_write_file+0x9f/0xde) [<800af4d5>] (sysfs_write_file+0x9f/0xde) from [<8007a437>] (vfs_write+0x7b/0x104) [<8007a437>] (vfs_write+0x7b/0x104) from [<8007a7f7>] (SyS_write+0x27/0x48) [<8007a7f7>] (SyS_write+0x27/0x48) from [<8000c121>] (ret_fast_syscall+0x1/0x44) Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2015-09-05rtc: fix drivers that consider 0 as a valid IRQ in client->irqOctavian Purdila1-1/+1
Since dab472eb931b ("i2c / ACPI: Use 0 to indicate that device does not have interrupt assigned"), 0 is not a valid i2c client irq anymore, so change all driver's checks accordingly. The same issue occurs when the device is instantiated via device tree with no IRQ, or from the i2c sysfs interface, even before the patch above. Signed-off-by: Octavian Purdila <octavian.purdila@intel.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2015-09-05rtc: Drop owner assignment from i2c_driverKrzysztof Kozlowski1-1/+0
i2c_driver does not need to set an owner because i2c_register_driver() will set it. Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2015-04-17rtc: use more standard kernel logging stylesJoe Perches1-2/+4
Neaten the logging a bit by adding #define pr_fmt Miscellanea: o Remove __FILE__/__func__ uses o Coalesce formats adding missing spaces o Align arguments o (rtc-cmos) Integrated 2 consecutive messages Signed-off-by: Joe Perches <joe@perches.com> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Cc: Alessandro Zummo <a.zummo@towertech.it> Cc: Joshua Kinard <kumba@gentoo.org> Cc: Chanwoo Choi <cw00.choi@samsung.com> Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Tested-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Cc: Aaro Koskinen <aaro.koskinen@iki.fi> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2014-04-03drivers/rtc/rtc-ds3232.c: enable ds3232 to work as wakeup sourceWang Dongsheng1-24/+70
Add suspend/resume and device_init_wakeup to enable ds3232 as wakeup source, /sys/class/rtc/rtcX/wakealarm for set wakeup alarm. Signed-off-by: Wang Dongsheng <dongsheng.wang@freescale.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2014-04-03drivers/rtc/rtc-ds3232.c: make it possible to share an irqBharat Bhushan1-2/+2
It's possible to have RTC irq shared with other device (e.g. t4240qds board shares ds3232irq with phy one). Handle this in driver. Signed-off-by: Bharat Bhushan <Bharat.Bhushan@freescale.com> Cc: Scott Wood <scottwood@freescale.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2014-04-03rtc: fix potential race conditionAlessandro Zummo1-2/+0
RTC drivers must not return an error after device registration. [akpm@linux-foundation.org: coding-style fixes] Signed-off-by: Alessandro Zummo <a.zummo@towertech.it> Reported-by: Ales Novak <alnovak@suse.cz> Cc: Alexander Shiyan <shc_work@mail.ru> Cc: Atsushi Nemoto <anemo@mba.ocn.ne.jp> Cc: Jiri Kosina <jkosina@suse.cz> Cc: Srikanth Srinivasan <srikanth.srinivasan@freescale.com> Cc: Lee Jones <lee.jones@linaro.org> Cc: Sascha Hauer <s.hauer@pengutronix.de> Cc: Joonsoo Kim <iamjoonsoo.kim@lge.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-04-29drivers/rtc/rtc-ds3232.c: use devm_* APIsSachin Kamat1-18/+7
devm_* functions are device managed and make cleanup code simpler. Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org> Cc: Srikanth Srinivasan <srikanth.srinivasan@freescale.com> Cc: Jingoo Han <jg1.han@samsung.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-01-03Drivers: rtc: remove __dev* attributes.Greg Kroah-Hartman1-4/+4
CONFIG_HOTPLUG is going away as an option. As a result, the __dev* markings need to be removed. This change removes the use of __devinit, __devexit_p, __devinitdata, __devinitconst, and __devexit from these drivers. Based on patches originally written by Bill Pemberton, but redone by me in order to handle some of the coding style issues better, by hand. Cc: Bill Pemberton <wfp5p@virginia.edu> Cc: Alessandro Zummo <a.zummo@towertech.it> Cc: Srinidhi Kasagar <srinidhi.kasagar@stericsson.com> Cc: Linus Walleij <linus.walleij@linaro.org> Cc: Mike Frysinger <vapier.adi@gmail.com> Cc: Wan ZongShun <mcuos.com@gmail.com> Cc: Guan Xuetao <gxt@mprc.pku.edu.cn> Cc: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-03-23rtc: convert rtc i2c drivers to module_i2c_driverAxel Lin1-12/+1
Factor out some boilerplate code for i2c driver registration into module_i2c_driver. Signed-off-by: Axel Lin <axel.lin@gmail.com> Cc: Piotr Ziecik <kosmo@semihalf.com> Cc: Alessandro Zummo <a.zummo@towertech.it> Cc: Scott Wood <scottwood@freescale.com> Cc: Srikanth Srinivasan <srikanth.srinivasan@freescale.com> Cc: Mike Rapoport <mike@compulab.co.il> Cc: Sergey Lapin <slapin@ossfans.org> Cc: Roman Fietze <roman.fietze@telemotive.de> Cc: Herbert Valerio Riedel <hvr@gnu.org> Cc: Alexander Bigga <ab@mycable.de> Cc: Dale Farnsworth <dale@farnsworth.org> Cc: Gregory Hermant <gregory.hermant@calao-systems.com> Cc: Wolfgang Grandegger <wg@grandegger.com> Cc: Martyn Welch <martyn.welch@ge.com> Cc: Byron Bradley <byron.bbradley@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-03-09RTC: Cleanup rtc_class_ops->update_irq_enable()John Stultz1-18/+0
Now that the generic code handles UIE mode irqs via periodic alarm interrupts, no one calls the rtc_class_ops->update_irq_enable() method anymore. This patch removes the driver hooks and implementations of update_irq_enable if no one else is calling it. CC: Thomas Gleixner <tglx@linutronix.de> CC: Alessandro Zummo <a.zummo@towertech.it> CC: Marcelo Roberto Jimenez <mroberto@cpti.cetuc.puc-rio.br> CC: rtc-linux@googlegroups.com Signed-off-by: John Stultz <john.stultz@linaro.org>
2011-02-25drivers/rtc/rtc-ds3232.c: fix time range difference between linux and RTC chipLei Xu1-5/+9
In linux rtc_time struct, tm_mon range is 0~11, tm_wday range is 0~6, while in RTC HW REG, month range is 1~12, day of the week range is 1~7, this patch adjusts difference of them. The efect of this bug was that most of month will be operated on as the next month by the hardware (When in Jan it maybe even worse). For example, if in May, software wrote 4 to the hardware, which handled it as April. Then the logic would be different between software and hardware, which would cause weird things to happen. Signed-off-by: Lei Xu <B33228@freescale.com> Cc: Alessandro Zummo <a.zummo@towertech.it> Cc: john stultz <johnstul@us.ibm.com> Cc: Jack Lan <jack.lan@freescale.com> Cc: <stable@kernel.org> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-12-24rtc: don't use flush_scheduled_work()Tejun Heo1-1/+1
flush_scheduled_work() is deprecated and scheduled to be removed. On removal, directly cancel the work, and flush the uie_task in rtc-dev.c::clear_uie(). Signed-off-by: Tejun Heo <tj@kernel.org> Cc: Alessandro Zummo <a.zummo@towertech.it> Cc: rtc-linux@googlegroups.com
2010-10-27drivers/rtc/rtc-ds3232.c: add alarm functionLan Chunhe-B258061-0/+181
The DS3232 RTC driver only has the tick function. Add an alarm function so the driver is complete. Signed-off-by: Lan Chunhe-B25806 <b25806@freescale.com> Cc: Alessandro Zummo <a.zummo@towertech.it> Cc: Wan ZongShun <mcuos.com@gmail.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2010-09-30i2c: Remove obsolete cleanup for clientdataWolfram Sang1-2/+0
A few new i2c-drivers came into the kernel which clear the clientdata-pointer on exit. This is obsolete meanwhile, so fix it and hope the word will spread. Signed-off-by: Wolfram Sang <w.sang@pengutronix.de> Acked-by: Mark Brown <broonie@opensource.wolfsonmicro.com> Signed-off-by: Jean Delvare <khali@linux-fr.org>
2010-08-11rtc: add support for DS3232 RTCRoy Zang1-0/+326
Add a driver for the DS3232 RTC chip via the I2C bus. Alarms are not supported in this version of the driver. [akpm@linux-foundation.org: fix Kconfig help text] Signed-off-by: Mingkai Hu <Mingkai.hu@freescale.com> Signed-off-by: Jingchang Lu <b22599@freescale.com> Signed-off-by: Srikanth Srinivasan <srikanth.srinivasan@freescale.com> Signed-off-by: Roy Zang <tie-fei.zang@freescale.com> Acked-by: Wan ZongShun <mcuos.com@gmail.com> Cc: Kumar Gala <kumar.gala@freescale.com> Cc: Alessandro Zummo <a.zummo@towertech.it> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>