aboutsummaryrefslogtreecommitdiff
path: root/drivers/rtc/rtc-ds3232.c
AgeCommit message (Collapse)AuthorFilesLines
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 <[email protected]> Reviewed-by: Allison Randal <[email protected]> Cc: [email protected] Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
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 <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
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 <[email protected]>
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 <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
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 <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
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 <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
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 <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
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 <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
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 <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
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 <[email protected]> Reviewed-by: Akinobu Mita <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
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 <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
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 <[email protected]> Suggested-by: Alexandre Belloni <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
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 <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
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 <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
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 <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
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 <[email protected]> Suggested-by: Alexandre Belloni <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
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 <[email protected]> Cc: Alessandro Zummo <[email protected]> Cc: Alexandre Belloni <[email protected]> Cc: Dennis Aberilla <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
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 <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
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 <[email protected]> Reviewed-by: Mika Westerberg <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
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 <[email protected]> Signed-off-by: Alexandre Belloni <[email protected]>
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 <[email protected]> Acked-by: Alexandre Belloni <[email protected]> Cc: Alessandro Zummo <[email protected]> Cc: Joshua Kinard <[email protected]> Cc: Chanwoo Choi <[email protected]> Reviewed-by: Krzysztof Kozlowski <[email protected]> Tested-by: Krzysztof Kozlowski <[email protected]> Cc: Aaro Koskinen <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
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 <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
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 <[email protected]> Cc: Scott Wood <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
2014-04-03rtc: fix potential race conditionAlessandro Zummo1-2/+0
RTC drivers must not return an error after device registration. [[email protected]: coding-style fixes] Signed-off-by: Alessandro Zummo <[email protected]> Reported-by: Ales Novak <[email protected]> Cc: Alexander Shiyan <[email protected]> Cc: Atsushi Nemoto <[email protected]> Cc: Jiri Kosina <[email protected]> Cc: Srikanth Srinivasan <[email protected]> Cc: Lee Jones <[email protected]> Cc: Sascha Hauer <[email protected]> Cc: Joonsoo Kim <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
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 <[email protected]> Cc: Srikanth Srinivasan <[email protected]> Cc: Jingoo Han <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
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 <[email protected]> Cc: Alessandro Zummo <[email protected]> Cc: Srinidhi Kasagar <[email protected]> Cc: Linus Walleij <[email protected]> Cc: Mike Frysinger <[email protected]> Cc: Wan ZongShun <[email protected]> Cc: Guan Xuetao <[email protected]> Cc: Mark Brown <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
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 <[email protected]> Cc: Piotr Ziecik <[email protected]> Cc: Alessandro Zummo <[email protected]> Cc: Scott Wood <[email protected]> Cc: Srikanth Srinivasan <[email protected]> Cc: Mike Rapoport <[email protected]> Cc: Sergey Lapin <[email protected]> Cc: Roman Fietze <[email protected]> Cc: Herbert Valerio Riedel <[email protected]> Cc: Alexander Bigga <[email protected]> Cc: Dale Farnsworth <[email protected]> Cc: Gregory Hermant <[email protected]> Cc: Wolfgang Grandegger <[email protected]> Cc: Martyn Welch <[email protected]> Cc: Byron Bradley <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
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 <[email protected]> CC: Alessandro Zummo <[email protected]> CC: Marcelo Roberto Jimenez <[email protected]> CC: [email protected] Signed-off-by: John Stultz <[email protected]>
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 <[email protected]> Cc: Alessandro Zummo <[email protected]> Cc: john stultz <[email protected]> Cc: Jack Lan <[email protected]> Cc: <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
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 <[email protected]> Cc: Alessandro Zummo <[email protected]> Cc: [email protected]
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 <[email protected]> Cc: Alessandro Zummo <[email protected]> Cc: Wan ZongShun <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>
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 <[email protected]> Acked-by: Mark Brown <[email protected]> Signed-off-by: Jean Delvare <[email protected]>
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. [[email protected]: fix Kconfig help text] Signed-off-by: Mingkai Hu <[email protected]> Signed-off-by: Jingchang Lu <[email protected]> Signed-off-by: Srikanth Srinivasan <[email protected]> Signed-off-by: Roy Zang <[email protected]> Acked-by: Wan ZongShun <[email protected]> Cc: Kumar Gala <[email protected]> Cc: Alessandro Zummo <[email protected]> Signed-off-by: Andrew Morton <[email protected]> Signed-off-by: Linus Torvalds <[email protected]>