summaryrefslogtreecommitdiffstats
path: root/drivers/rtc
AgeCommit message (Collapse)AuthorFilesLines
2016-01-18Merge tag 'rtc-4.5' of ↵Linus Torvalds21-130/+892
git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux Pull RTC updates from Alexandre Belloni: "Core: - fix module reference count in rtc-proc - Replace simple_strtoul by kstrtoul New driver: - Epson RX8010SJ Subsystem wide cleanups: - use %ph for short hex dumps - constify *_chip_ops structures Drivers: - abx80x: Microcrystal rv1805 support, alarm support - cmos: prevent kernel warning on IRQ flags mismatch - s5m: various cleanups - rv8803: rx8900 compatibility, small error path fix - sunxi: various cleanups - lpc32xx: remove irq > NR_IRQS check from probe() - imxdi: fix spelling mistake in warning message - ds1685: don't try to micromanage sysfs output size - da9063: avoid writing undefined data to rtc - gemini: Remove unnecessary platform_set_drvdata() - efi: add efi_procfs in efi_rtc_ops - pcf8523: refuse to write dates later than 2099" * tag 'rtc-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (24 commits) rtc: cmos: prevent kernel warning on IRQ flags mismatch rtc: rtc-ds2404: constify ds2404_chip_ops structures rtc: s5m: Make register configuration per S2MPS device to remove exceptions rtc: s5m: Add separate field for storing auto-cleared mask in register config rtc: s5m: Cleanup by removing useless 'rtc' prefix from fields rtc: Replace simple_strtoul by kstrtoul rtc: abx80x: add alarm support rtc: abx80x: Add Microcrystal rv1805 support rtc: v3020: constify v3020_chip_ops structures rtc: rv8803: Extend compatibility with the rx8900 rtc: rv8803: fix handling return value of i2c_smbus_read_byte_data rtc: Add Epson RX8010SJ RTC driver rtc: lpc32xx: remove irq > NR_IRQS check from probe() rtc: imxdi: fix spelling mistake in warning message rtc: ds1685: don't try to micromanage sysfs output size rtc: use %ph for short hex dumps rtc: da9063: avoid writing undefined data to rtc rtc: sunxi: use of_device_get_match_data rtc: sunxi: constify the data_year_param structure rtc: sunxi: fix signedness issues ...
2016-01-15Merge tag 'powerpc-4.5-1' of ↵Linus Torvalds1-1/+1
git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux Pull powerpc updates from Michael Ellerman: "Core: - Ground work for the new Power9 MMU from Aneesh Kumar K.V - Optimise FP/VMX/VSX context switching from Anton Blanchard Misc: - Various cleanups from Krzysztof Kozlowski, John Ogness, Rashmica Gupta, Russell Currey, Gavin Shan, Daniel Axtens, Michael Neuling, Andrew Donnellan - Allow wrapper to work on non-english system from Laurent Vivier - Add rN aliases to the pt_regs_offset table from Rashmica Gupta - Fix module autoload for rackmeter & axonram drivers from Luis de Bethencourt - Include KVM guest test in all interrupt vectors from Paul Mackerras - Fix DSCR inheritance over fork() from Anton Blanchard - Make value-returning atomics & {cmp}xchg* & their atomic_ versions fully ordered from Boqun Feng - Print MSR TM bits in oops messages from Michael Neuling - Add TM signal return & invalid stack selftests from Michael Neuling - Limit EPOW reset event warnings from Vipin K Parashar - Remove the Cell QPACE code from Rashmica Gupta - Append linux_banner to exception information in xmon from Rashmica Gupta - Add selftest to check if VSRs are corrupted from Rashmica Gupta - Remove broken GregorianDay() from Daniel Axtens - Import Anton's context_switch2 benchmark into selftests from Michael Ellerman - Add selftest script to test HMI functionality from Daniel Axtens - Remove obsolete OPAL v2 support from Stewart Smith - Make enter_rtas() private from Michael Ellerman - PPR exception cleanups from Michael Ellerman - Add page soft dirty tracking from Laurent Dufour - Add support for Nvlink NPUs from Alistair Popple - Add support for kexec on 476fpe from Alistair Popple - Enable kernel CPU dlpar from sysfs from Nathan Fontenot - Copy only required pieces of the mm_context_t to the paca from Michael Neuling - Add a kmsg_dumper that flushes OPAL console output on panic from Russell Currey - Implement save_stack_trace_regs() to enable kprobe stack tracing from Steven Rostedt - Add HWCAP bits for Power9 from Michael Ellerman - Fix _PAGE_PTE breaking swapoff from Aneesh Kumar K.V - Fix _PAGE_SWP_SOFT_DIRTY breaking swapoff from Hugh Dickins - scripts/recordmcount.pl: support data in text section on powerpc from Ulrich Weigand - Handle R_PPC64_ENTRY relocations in modules from Ulrich Weigand cxl: - cxl: Fix possible idr warning when contexts are released from Vaibhav Jain - cxl: use correct operator when writing pcie config space values from Andrew Donnellan - cxl: Fix DSI misses when the context owning task exits from Vaibhav Jain - cxl: fix build for GCC 4.6.x from Brian Norris - cxl: use -Werror only with CONFIG_PPC_WERROR from Brian Norris - cxl: Enable PCI device ID for future IBM CXL adapter from Uma Krishnan Freescale: - Freescale updates from Scott: Highlights include moving QE code out of arch/powerpc (to be shared with arm), device tree updates, and minor fixes" * tag 'powerpc-4.5-1' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: (149 commits) powerpc/module: Handle R_PPC64_ENTRY relocations scripts/recordmcount.pl: support data in text section on powerpc powerpc/powernv: Fix OPAL_CONSOLE_FLUSH prototype and usages powerpc/mm: fix _PAGE_SWP_SOFT_DIRTY breaking swapoff powerpc/mm: Fix _PAGE_PTE breaking swapoff cxl: Enable PCI device ID for future IBM CXL adapter cxl: use -Werror only with CONFIG_PPC_WERROR cxl: fix build for GCC 4.6.x powerpc: Add HWCAP bits for Power9 powerpc/powernv: Reserve PE#0 on NPU powerpc/powernv: Change NPU PE# assignment powerpc/powernv: Fix update of NVLink DMA mask powerpc/powernv: Remove misleading comment in pci.c powerpc: Implement save_stack_trace_regs() to enable kprobe stack tracing powerpc: Fix build break due to paca mm_context_t changes cxl: Fix DSI misses when the context owning task exits MAINTAINERS: Update Scott Wood's e-mail address powerpc/powernv: Fix minor off-by-one error in opal_mce_check_early_recovery() powerpc: Fix style of self-test config prompts powerpc/powernv: Only delay opal_rtc_read() retry when necessary ...
2016-01-14Merge tag 'mfd-for-linus-4.5' of ↵Linus Torvalds1-4/+33
git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd Pull MFD updates from Lee Jones: "New Device Support: - Add support for s2mps15; sec-core - Add support for Lewisburg; lpc_ich - Add support for cs47l24 and wm1831; arizona New Functionality: - Allow user to select syscon register width; syscon Fix-ups: - Lots of Checkpatch fixes - Rename -pmic/-regulator; s2mps11 - Build driver components into a single module; wm8994-* - Better handing of IRQ during suspend/resume; as3722 - Constify things; da903x - Remove unused code; ab8500-core - Improve error handing; qcom_rpm - Simplify code: wm831x-otp, sta2x11-mfd - Improve locking; cros_ec_spi - Fix incorrect DT binding filename reference; arizona, palmas, snps-dwapb-gpio, wm8994 Bug Fixes: - Fix broken SYSFS 'show ID' call; wm831x-otp - Protect reads from non-existent registers; qcom-spmi-pmic - Repair build warnings; as3722 - Fix IRQ request ordering; arizona-irq - Ensure return value is boolean; ucb1x00-core, tps65010, tc6393xb, htc-egpio, dm355evm_msp, asic3" * tag 'mfd-for-linus-4.5' of git://git.kernel.org/pub/scm/linux/kernel/git/lee/mfd: (58 commits) mfd: davinci_voicecodec: Remove pointless 'out of memory' error message mfd: da9052-irq: Fix trivial 'space before comma' error mfd: da9052-i2c: Fix tabbing/whitespace issue mfd: da903x: Fix white space and split string issues mfd: cs5535-mfd: Add missing line spacing and make local array static mfd: cros_ec_spi: Repair comparison ordering issue mfd: cros_ec_i2c: Fix trivial 'tabs before spaces' whitespace issue. mfd: asic3: Fix a plethora of Checkpatch errors and warnings mfd: as3711: Repair OOM and 'line over 80 chars' formatting warnings mfd: arizona-i2c: Add blank line formatting after declaration mfd: arizona-core: msleep() is unreliable for anything <20ms use usleep_range() instead mfd: adp5520: Some trivial 'no space before tab' fixes mfd: ab8500-sysctrl: Fix Constify, printk => pr_info and formatting issues mfd: ab8500-gpadc: Squash a whole bunch of Checkpatch warnings and one error mfd: ab8500-debugfs: Clean-up non-conforming commenting and print formatting mfd: ab8500-core: Fix many warnings reported by Checkpatch mfd: ab2100-otp: Remove pointless 'out of memory' error message mfd: ab3100-core.c: Fix multiple warnings reported by Checkpatch mfd: aat2870-core: Remove unnecessary 'out of memory' message mfd: 88pm860x-core: Fix commenting and declaration spacing ...
2016-01-11rtc: cmos: prevent kernel warning on IRQ flags mismatchAndy Shevchenko1-1/+1
The Microsoft Surface 3 tablet shares interrupt line between RTC and one of SPI controllers. However, the rtc_cmos driver doesn't allow shared interrupts and user sees the following warning genirq: Flags mismatch irq 8. 00000080 (8086228E:02) vs. 00000000 (rtc0) ... [<ffffffffa004eb01>] pxa2xx_spi_probe+0x151/0x600 [spi_pxa2xx_platform] Allow RTC driver to use shared interrupts. Seems we are on the safe side to do just this simple change since cmos_interrupt() handler checks for the actual hardware status anyway. Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-01-11rtc: rtc-ds2404: constify ds2404_chip_ops structuresJulia Lawall1-2/+2
The ds2404_chip_ops structure is never modified, so declare it as const. Done with the help of Coccinelle. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-01-11rtc: s5m: Make register configuration per S2MPS device to remove exceptionsKrzysztof Kozlowski1-35/+75
Before updating time and alarm the driver must set appropriate mask in UDR register. For that purpose the driver uses common register configuration and a lot of exceptions per device in the code. The exceptions are not obvious, for example except the change in the logic sometimes the fields are swapped (WUDR and AUDR between S2MPS14 and S2MPS15). This leads to quite complicated code. Try to make it more obvious by: 1. Documenting the UDR masks for devices and operations. 2. Adding fields in register configuration structure for each operation (read time, write time and alarm). 3. Splitting the configuration per S2MPS13, S2MPS14 and S2MPS15 thus removing exceptions for them. Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com> Tested-by: Alim Akhtar <alim.akhtar@samsung.com> Acked-by: Lee Jones <lee.jones@linaro.org> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-01-11rtc: s5m: Add separate field for storing auto-cleared mask in register configKrzysztof Kozlowski1-1/+5
Some devices from S2M/S5M family use different register update masks for different operations (alarm and register update). Now the driver uses common register configuration and a lot of exceptions per device in code. Before eliminating the exceptions and using specific register configuration for given device, make the auto-cleared mask a separate field. This is merely a refactoring. Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com> Tested-by: Alim Akhtar <alim.akhtar@samsung.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-01-11rtc: s5m: Cleanup by removing useless 'rtc' prefix from fieldsKrzysztof Kozlowski1-21/+19
Remove the 'rtc' prefix from some of the fields in struct s5m_rtc_reg_config because it is obvious - this is a RTC driver. No functional changes. Signed-off-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Reviewed-by: Alim Akhtar <alim.akhtar@samsung.com> Tested-by: Alim Akhtar <alim.akhtar@samsung.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-01-11rtc: Replace simple_strtoul by kstrtoulLABBE Corentin1-2/+9
The simple_strtoul function is obsolete. This patch replace it by kstrtoul. Since kstrtoul is more strict, it permits to filter some invalid input that simple_strtoul accept. For example: echo '1022xxx' > /sys/devices/pnp0/00:03/rtc/rtc0/max_user_freq cat /sys/devices/pnp0/00:03/rtc/rtc0/max_user_freq 1022 Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-01-11rtc: abx80x: add alarm supportAlexandre Belloni1-4/+141
Add alarm support to the abx80x driver. Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-01-11rtc: abx80x: Add Microcrystal rv1805 supportAlexandre Belloni1-0/+1
Microcrystal RV-1805 is compatible with Abracon 1805. Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-01-11rtc: v3020: constify v3020_chip_ops structuresJulia Lawall1-3/+3
The v3020_chip_ops structures are never modified, so declare them as const. Done with the help of Coccinelle. Signed-off-by: Julia Lawall <Julia.Lawall@lip6.fr> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-01-11rtc: rv8803: Extend compatibility with the rx8900Gregory CLEMENT1-0/+1
The Seiko Epson's RTC RX8900 layout register is compatible with the RV8803. So let's add its ID in order to reuse the same driver. Signed-off-by: Gregory CLEMENT <gregory.clement@free-electrons.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-01-11rtc: rv8803: fix handling return value of i2c_smbus_read_byte_dataAndrzej Hajda1-1/+1
The function can return negative values, so its result should be assigned to signed variable. The problem has been detected using proposed semantic patch scripts/coccinelle/tests/assign_signed_to_unsigned.cocci [1]. [1]: http://permalink.gmane.org/gmane.linux.kernel/2046107 Signed-off-by: Andrzej Hajda <a.hajda@samsung.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-01-11rtc: Add Epson RX8010SJ RTC driverAkshay Bhat3-0/+534
This driver supports the following functions: - reading and setting time - alarms when connected to an IRQ - reading and clearing the voltage low flags Datasheet: http://www.epsondevice.com/docs/qd/en/DownloadServlet?id=ID000956 Signed-off-by: Akshay Bhat <akshay.bhat@timesys.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-01-11rtc: lpc32xx: remove irq > NR_IRQS check from probe()Vladimir Zapolskiy1-1/+1
If the driver is used on an ARM platform with SPARSE_IRQ defined, semantics of NR_IRQS is different (minimal value of virtual irqs) and by default it is set to 16, see arch/arm/include/asm/irq.h. This value may be less than the actual number of virtual irqs, which may break the driver initialization. The check removal allows to use the driver on such a platform, and, if irq controller driver works correctly, the check is not needed on legacy platforms. Fixes a runtime problem: rtc-lpc32xx 40024000.rtc: Can't get interrupt resource Signed-off-by: Vladimir Zapolskiy <vz@mleia.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-01-11rtc: imxdi: fix spelling mistake in warning messageColin Ian King1-1/+1
Minor issue, fix spelling mistake, happend -> happened Signed-off-by: Colin Ian King <colin.king@canonical.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-01-11rtc: ds1685: don't try to micromanage sysfs output sizeRasmus Villemoes1-7/+5
...and don't do it wrong. "not ok or N/A" has length 13. Add the trailing newline, and the snprintf return value will be 14. However, we lied to snprintf and told it that only 13 bytes were available. Hence snprintf has only written "not ok or N/" and a trailing '\0' to the buffer. Next we continue lying, this time to the upper sysfs layer, claiming that we wrote 14 meaningful bytes to the buffer. That'll make the upper layer copy "not ok or N/" plus two nul bytes to user space (one nul byte from snprintf, the other since sysfs takes care to clear the buffer before giving it to the ->show method). In the other cases, the claimed buffer size is closer to sufficient, but we'll still get a nul byte instead of a newline written to user space. There's absolutely no reason to try to predict the output size, and there's plenty of room in the buffer, so just use sprintf. Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-01-11rtc: use %ph for short hex dumpsRasmus Villemoes3-26/+11
This makes the generated code slightly smaller. Signed-off-by: Rasmus Villemoes <linux@rasmusvillemoes.dk> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-01-11rtc: da9063: avoid writing undefined data to rtcEnrico Scholz1-17/+6
driver did | static void da9063_tm_to_data(struct rtc_time *tm, u8 *data, | { | const struct da9063_compatible_rtc_regmap *config = rtc->config; | | data[RTC_SEC] &= ~config->rtc_count_sec_mask; | data[RTC_SEC] |= tm->tm_sec & config->rtc_count_sec_mask; | ... | } | ... | static int da9063_rtc_set_time(struct device *dev, struct rtc_time *tm) | { | ... | u8 data[RTC_DATA_LEN]; | int ret; | | da9063_tm_to_data(tm, data, rtc); which means that some bits of stack content (in 'data[]') was masked out and written to the RTC. Because da9063_tm_to_data() is used only by da9063_rtc_set_time() and da9063_rtc_set_alarm(), we can write fields directly. Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de> Acked-by: Steve Twiss <stwiss.opensource@diasemi.com> Tested-by: Steve Twiss <stwiss.opensource@diasemi.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-01-11rtc: sunxi: use of_device_get_match_dataLABBE Corentin1-4/+2
The usage of of_device_get_match_data reduce the code size a bit. Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com> Acked-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-01-11rtc: sunxi: constify the data_year_param structureLABBE Corentin1-3/+3
The data_year_param struct is never modified, so lets constify it. This permit to remove cast since of_device_id is const also. Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com> Acked-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-01-11rtc: sunxi: fix signedness issuesLABBE Corentin1-4/+4
The variable year must be set as unsigned since it is used with sunxi_rtc_data_year{.min|.max} and as parameter of is_leap_year() which wait for unsigned int. Only tm_year is not unsigned, but it is long. This patch fix also the format of printing of min/max. (must use %u since they are unsigned) The parameter to of sunxi_rtc_setaie() must be set to uint since callers give always uint data. Signed-off-by: LABBE Corentin <clabbe.montjoie@gmail.com> Acked-by: Chen-Yu Tsai <wens@csie.org> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-01-11rtc: gemini: Remove unnecessary platform_set_drvdata()Nizam Haider1-1/+0
The driver core clears the driver data to NULL after device_release or on probe failure Signed-off-by: Nizam Haider <nijamh@cdac.in> Acked-by: Hans Ulli Kroll <ulli.kroll@googlemail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-01-11rtc: efi: add efi_procfs in efi_rtc_opsGeliang Tang1-4/+62
Add efi_procfs in efi_rtc_ops to show rtc-efi info in /proc/driver/rtc. Most of the code comes from efi_rtc_proc_show() in efirtc. Signed-off-by: Geliang Tang <geliangtang@163.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-01-11rtc: fix module reference count in rtc-procGeliang Tang1-3/+5
rtc-proc.c is not built as a module. Thus, rather than dealing with THIS_MODULE's reference count, we should deal with rtc->owner's reference count. Signed-off-by: Geliang Tang <geliangtang@163.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-01-11rtc: pcf8523: refuse to write dates later than 2099Uwe Kleine-König1-0/+11
When the chip increments the YEAR register and it already holds bin2bcd(99) it reads as 0 afterwards. With this behaviour the last valid day (without trickery) that has a representation is 2099-12-31 23:59:59. So refuse to write later dates. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2016-01-11Merge tag 'ib-mfd-regulator-rtc-v4.5' into rtc-nextAlexandre Belloni1-4/+33
Immutable branch between MFD, Regulator and RTC for the v4.5 merge window
2015-12-20rtc: da9063: fix access ordering error during RTC interrupt at system power onSteve Twiss1-10/+9
This fix alters the ordering of the IRQ and device registrations in the RTC driver probe function. This change will apply to the RTC driver that supports both DA9063 and DA9062 PMICs. A problem could occur with the existing RTC driver if: A system is started from a cold boot using the PMIC RTC IRQ to initiate a power on operation. For instance, if an RTC alarm is used to start a platform from power off. The existing driver IRQ is requested before the device has been properly registered. i.e. ret = devm_request_threaded_irq() comes before rtc->rtc_dev = devm_rtc_device_register(); In this case, the interrupt can be called before the device has been registered and the handler can be called immediately. The IRQ handler da9063_alarm_event() contains the function call rtc_update_irq(rtc->rtc_dev, 1, RTC_IRQF | RTC_AF); which in turn tries to access the unavailable rtc->rtc_dev. The fix is to reorder the functions inside the RTC probe. The IRQ is requested after the RTC device resource has been registered so that get_irq_byname is the last thing to happen. Signed-off-by: Steve Twiss <stwiss.opensource@diasemi.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2015-12-20rtc: rk808: Compensate for Rockchip calendar deviation on November 31stJulius Werner1-4/+44
In A.D. 1582 Pope Gregory XIII found that the existing Julian calendar insufficiently represented reality, and changed the rules about calculating leap years to account for this. Similarly, in A.D. 2013 Rockchip hardware engineers found that the new Gregorian calendar still contained flaws, and that the month of November should be counted up to 31 days instead. Unfortunately it takes a long time for calendar changes to gain widespread adoption, and just like more than 300 years went by before the last Protestant nation implemented Greg's proposal, we will have to wait a while until all religions and operating system kernels acknowledge the inherent advantages of the Rockchip system. Until then we need to translate dates read from (and written to) Rockchip hardware back to the Gregorian format. This patch works by defining Jan 1st, 2016 as the arbitrary anchor date on which Rockchip and Gregorian calendars are in sync. From that we can translate arbitrary later dates back and forth by counting the number of November/December transitons since the anchor date to determine the offset between the calendars. We choose this method (rather than trying to regularly "correct" the date stored in hardware) since it's the only way to ensure perfect time-keeping even if the system may be shut down for an unknown number of years. The drawback is that other software reading the same hardware (e.g. mainboard firmware) must use the same translation convention (including the same anchor date) to be able to read and write correct timestamps from/to the RTC. Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-by: Douglas Anderson <dianders@chromium.org> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2015-12-16powerpc: Remove broken GregorianDay()Daniel Axtens1-1/+1
GregorianDay() is supposed to calculate the day of the week (tm->tm_wday) for a given day/month/year. In that calcuation it indexed into an array called MonthOffset using tm->tm_mon-1. However tm_mon is zero-based, not one-based, so this is off-by-one. It also means that every January, GregoiranDay() will access element -1 of the MonthOffset array. It also doesn't appear to be a correct algorithm either: see in contrast kernel/time/timeconv.c's time_to_tm function. It's been broken forever, which suggests no-one in userland uses this. It looks like no-one in the kernel uses tm->tm_wday either (see e.g. drivers/rtc/rtc-ds1305.c:319). tm->tm_wday is conventionally set to -1 when not available in hardware so we can simply set it to -1 and drop the function. (There are over a dozen other drivers in drivers/rtc that do this.) Found using UBSAN. Cc: Andrey Ryabinin <aryabinin@virtuozzo.com> Cc: Andrew Morton <akpm@linux-foundation.org> # as an example of what UBSan finds. Cc: Alessandro Zummo <a.zummo@towertech.it> Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com> Cc: rtc-linux@googlegroups.com Signed-off-by: Daniel Axtens <dja@axtens.net> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
2015-11-26rtc: ds1307: fix alarm reading at probe timeSimon Guinot1-5/+7
With the actual code, read_alarm() always returns -EINVAL when called during the RTC device registration. This prevents from retrieving an already configured alarm in hardware. This patch fixes the issue by moving the HAS_ALARM bit configuration (if supported by the hardware) above the rtc_device_register() call. Signed-off-by: Simon Guinot <simon.guinot@sequanux.org> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2015-11-25rtc: ds1307: fix kernel splat due to wakeup irq handlingFelipe Balbi1-33/+3
Since commit 3fffd1283927 ("i2c: allow specifying separate wakeup interrupt in device tree") we have automatic wakeup irq support for i2c devices. That commit missed the fact that rtc-1307 had its own wakeup irq handling and ended up introducing a kernel splat for at least Beagle x15 boards. Fix that by reverting original commit _and_ passing correct interrupt names on DTS so i2c-core can choose correct IRQ as wakeup. Now that we have automatic wakeirq support, we can revert the original commit which did it manually. Fixes the following warning: [ 10.346582] WARNING: CPU: 1 PID: 263 at linux/drivers/base/power/wakeirq.c:43 dev_pm_attach_wake_irq+0xbc/0xd4() [ 10.359244] rtc-ds1307 2-006f: wake irq already initialized Cc: Tony Lindgren <tony@atomide.com> Cc: Nishanth Menon <nm@ti.com> Signed-off-by: Felipe Balbi <balbi@ti.com> Acked-by: Tony Lindgren <tony@atomide.com> Acked-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2015-11-23rtc: s5m.c: Add support for S2MPS15 RTCAlim Akhtar1-4/+33
RTC found in s2mps15 is almost same as one found on s2mps13 with few differences in RTC_UPDATE register fields, like: 1> Bit[4] and Bit[1] are reversed - On s2mps13 WUDR -> bit[4], AUDR -> bit[1] - On s2mps15 WUDR -> bit[1], AUDR -> bit[4] 2> In case of s2mps13, for alarm register, need to set both WDUR and ADUR high, whereas for s2mps15 only set AUDR to high. 3> On s2mps15, WUDR, RUDR and AUDR functions should never be used at the same time. This patch add required changes to enable s2mps15 rtc timer. Signed-off-by: Alim Akhtar <alim.akhtar@samsung.com> Reviewed-by: Krzysztof Kozlowski <k.kozlowski@samsung.com> Acked-by: Alexandre Belloni <alexandre.belloni@free-electrons.com> Signed-off-by: Lee Jones <lee.jones@linaro.org>
2015-11-10Merge tag 'rtc-v4.4' of ↵Linus Torvalds20-82/+864
git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux Pull RTC updates from Alexandre Belloni: "Core: - Fix rtctest error path New drivers: - Microcrystal RV8803 Subsystem wide cleanups: - remove misuse of IRQF_NO_SUSPEND flag Drivers: - at91rm9200: clear RTC alarm status flag prior to suspending - davinci: remove incorrect reference to probe function - ds1307: Fix alarm programming for mcp794xx - ds1390: trickle charger support, fix ds1390_get_reg - isl1208: Pass the IRQF_ONESHOT flag - opal: fix type of token - pcf2127: fix RTC_READ_VL, remove useless driver version - pcf85063: return an error when date is invalid - pcf8563: add CLKOUT to common clock framework - rx8025: remove unnecessary braces - s3c: Set year, month, day value for setting alarm - stmp3xxx: unify register access macros - License fixes: pcf2127, da9063 - wakeup-source support for isl12057 and opal" * tag 'rtc-v4.4' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (23 commits) rtc: Add a driver for Micro Crystal RV8803 rtc: s3c: Set year, month, day value for setting alarm rtc: ds1307: Fix alarm programming for mcp794xx rtc: isl12057: enable support for the standard "wakeup-source" property rtc: opal: enable support for the stardard "wakeup-source" property rtc: isl1208: Pass the IRQF_ONESHOT flag rtc: pcf8563: add CLKOUT to common clock framework rtc: davinci: remove incorrect reference to probe function rtc: at91rm9200: clear RTC alarm status flag prior to suspending rtc: pcf2127: remove useless driver version rtc: pcf2127: fix reading uninitialized value on RTC_READ_VL ioctl rtc: stmp3xxx: unify register access macros rtc: da9063: GPL copyright inconsistency fix rtc: pcf85063: return an error when date is invalid rtc: rx8025: remove unnecessary braces rtc: ds1343: remove misuse of IRQF_NO_SUSPEND flag rtc: ab8500: remove misuse of IRQF_NO_SUSPEND flag rtc: pl031: remove misuse of IRQF_NO_SUSPEND flag rtc: opal: fix type of token rtc: ds1390: Add trickle charger device tree binding ...
2015-11-08rtc: Add a driver for Micro Crystal RV8803Alexandre Belloni3-0/+531
This driver supports the following functions: - reading and settings time - alarms when connected to an IRQ - reading and clearing the voltage low flags - nvram Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2015-11-08rtc: s3c: Set year, month, day value for setting alarmKrzysztof Kozlowski1-0/+16
This patch sets year, month, day value for set_alarm function. The current driver omits to set the values. This fixes setting wake alarm for dates different than current day. Without the patch the alarm scheduled for tomorrow would fire today on chosen time. Signed-off-by: Donggeun Kim <dg77.kim@samsung.com> Signed-off-by: MyungJoo Ham <myungjoo.kim@samsung.com> Signed-off-by: KyungMin Park <kyungmin.park@samsung.com> [k.kozlowski: Rebase and test the patch, update commit message] Signed-off-by: Krzysztof Kozlowski <k.kozlowski.k@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2015-11-08rtc: ds1307: Fix alarm programming for mcp794xxTero Kristo1-2/+2
mcp794xx alarm registers must be written in BCD format. However, the alarm programming logic neglected this by adding one to the value after bin2bcd conversion has been already done, writing bad values to month register in case the alarm being set is in October. In this case, the alarm month value becomes 0x0a instead of the expected 0x10. Fix by moving the +1 addition within the bin2bcd call also. Fixes: 1d1945d261a2 ("drivers/rtc/rtc-ds1307.c: add alarm support for mcp7941x chips") Signed-off-by: Tero Kristo <t-kristo@ti.com> Acked-by: Nishanth Menon <nm@ti.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2015-11-08rtc: isl12057: enable support for the standard "wakeup-source" propertySudeep Holla1-5/+5
Though the isl12057 rtc driver should and will continue to support the legacy "isil,irq2-can-wakeup-machine" property to enable RTC as the wakeup source, we need to add support for the new standard property "wakeup-source". This patch adds support for "wakeup-source" property in addition to the existing "isil,irq2-can-wakeup-machine" property. Cc: Alessandro Zummo <a.zummo@towertech.it> Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com> Cc: rtc-linux@googlegroups.com Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2015-11-08rtc: opal: enable support for the stardard "wakeup-source" propertySudeep Holla1-2/+3
Though the opal rtc driver should and will continue to support the legacy "has-tpo" property to enable RTC as the wakeup source, we need to add support for the new standard property "wakeup-source" This patch adds support for "wakeup-source" property in addition to the existing "has-tpo" property. Cc: Alessandro Zummo <a.zummo@towertech.it> Cc: Alexandre Belloni <alexandre.belloni@free-electrons.com> Cc: rtc-linux@googlegroups.com Signed-off-by: Sudeep Holla <sudeep.holla@arm.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2015-11-08rtc: isl1208: Pass the IRQF_ONESHOT flagFabio Estevam1-1/+1
Since commit 1c6c69525b40eb76de8adf039409722015927dc3 ("genirq: Reject bogus threaded irq requests") threaded IRQs without a primary handler need to be requested with IRQF_ONESHOT, otherwise the request will fail. So pass the IRQF_ONESHOT flag in this case. The semantic patch that makes this change is available in scripts/coccinelle/misc/irqf_oneshot.cocci Signed-off-by: Fabio Estevam <fabio.estevam@freescale.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2015-11-08rtc: pcf8563: add CLKOUT to common clock frameworkHeiko Schocher1-1/+169
Add the clkout output clk to the common clock framework. Disable the CLKOUT of the RTC after power-up. After power-up/reset of the RTC, CLKOUT is enabled by default, with CLKOUT enabled the RTC chip has 2-3 times higher power consumption. Signed-off-by: Heiko Schocher <hs@denx.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2015-11-08rtc: davinci: remove incorrect reference to probe functionArnd Bergmann1-1/+0
The davinci rtc driver uses the module_platform_driver_probe() helper to call the probe function and mark it as __init, but it also puts a reference into its davinci_rtc_driver function. This will crash if we ever get a deferred probe and the probe function is called again after the init section has been removed. kbuild warns about this: WARNING: vmlinux.o(.data+0x1aa2b4): Section mismatch in reference from the variable davinci_rtc_driver to the function .init.text:davinci_rtc_probe() The variable davinci_rtc_driver references the function __init davinci_rtc_probe() This patch removes the .probe callback from the platform driver, which avoids those problems. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2015-11-08rtc: at91rm9200: clear RTC alarm status flag prior to suspendingWenyou Yang1-0/+2
As said in the SAMA5D2 datasheet, "Prior to instructing the device to enter ULP mode 1, ... and the internal sources of wake-up must be cleared." This patch is to clear the RTC alarm status flag prior to suspending to avoid the erroneous wake-up activity, as it is often used as the wake-up source for the ULP mode 1. Signed-off-by: Wenyou Yang <wenyou.yang@atmel.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2015-11-08rtc: pcf2127: remove useless driver versionUwe Kleine-König1-5/+0
A driver version is only really sensible for oot drivers. Also the dev_info about having found a chip only signals that allocating the driver data succeeded and so isn't worth much. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2015-11-08rtc: pcf2127: fix reading uninitialized value on RTC_READ_VL ioctlUwe Kleine-König1-18/+22
The flag reported on the RTC_READ_VL ioctl is only initialized when the date is read out. So the voltage low value doesn't represent reality but the status at the time the date was read (or 0 if the date was not read yet). Moreover when userspace requests a value via an ioctl there is no added benefit to also make a prosa representation of this (and other) values appear in the kernel log so remove the calls to dev_info and the driver data members to track their state. Signed-off-by: Uwe Kleine-König <u.kleine-koenig@pengutronix.de> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2015-11-08rtc: stmp3xxx: unify register access macrosHarald Geyer1-14/+13
Use STMP_OFFSET_REG_(SET|CLR) instead of defining _SET and _CLR for STMP3XXX_RTC_CTRL and STMP3XXX_RTC_PERSISTENT0 - no functional changes. Signed-off-by: Harald Geyer <harald@ccbib.org> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2015-11-08rtc: da9063: GPL copyright inconsistency fixSteve Twiss1-9/+9
Fix misleading and inconsistent copyright header wording. Alter the copyright header text and MODULE_LICENSE macro to ensure the GPL v2 licence description is correctly represented. It will remove the incorrectly LGPL worded text. Words such as "Library" from the line "GNU Library General Public License"; and replace the word "library" with "program" in several other places. The copyright should match the GPL v2 description as specified in the GNU license found here: http://www.gnu.org/licenses/gpl-2.0.html It should also match this copyright text with the correct MODULE_LICENSE macro text as found in the kernel: include/linux/module.h In this case "GNU Public License v2 or later" is linked with "GPL". Signed-off-by: Steve Twiss <stwiss.opensource@diasemi.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2015-11-08rtc: pcf85063: return an error when date is invalidAlexandre Belloni1-7/+1
Return an error when the date is invalid as the policy should be implemented there. Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>
2015-11-08rtc: rx8025: remove unnecessary bracesAlexandre Belloni1-2/+2
braces {} are not necessary for single statement blocks Signed-off-by: Alexandre Belloni <alexandre.belloni@free-electrons.com>