summaryrefslogtreecommitdiffstats
path: root/drivers/rtc
Commit message (Collapse)AuthorAgeFilesLines
* Merge tag 'm68k-for-v5.19-tag1' of ↵Linus Torvalds2022-05-231-27/+17
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k Pull m68k updates from Geert Uytterhoeven: - Introduce virtual m68k machine based on Android Goldfish devices - defconfig updates - Minor fixes and improvements * tag 'm68k-for-v5.19-tag1' of git://git.kernel.org/pub/scm/linux/kernel/git/geert/linux-m68k: m68k: atari: Make Atari ROM port I/O write macros return void m68k: math-emu: Fix dependencies of math emulation support m68k: math-emu: Fix typos in comments m68k: Wire up syscall_trace_enter/leave for m68k m68k: defconfig: Update defconfigs for v5.18-rc1 m68k: Introduce a virtual m68k machine clocksource/drivers: Add a goldfish-timer clocksource rtc: goldfish: Use gf_ioread32()/gf_iowrite32() tty: goldfish: Introduce gf_ioread32()/gf_iowrite32()
| * clocksource/drivers: Add a goldfish-timer clocksourceLaurent Vivier2022-04-111-12/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add a clocksource based on the goldfish-rtc device. Move the timer register definition to <clocksource/timer-goldfish.h> This kernel implementation is based on the QEMU upstream implementation: https://git.qemu.org/?p=qemu.git;a=blob_plain;f=hw/rtc/goldfish_rtc.c goldfish-timer is a high-precision signed 64-bit nanosecond timer. It is part of the 'goldfish' virtual hardware platform used to run some emulated Android systems under QEMU. This timer only supports oneshot event. Signed-off-by: Laurent Vivier <laurent@vivier.eu> Acked-by: Daniel Lezcano <daniel.lezcano@linaro.org> Link: https://lore.kernel.org/r/20220406201523.243733-4-laurent@vivier.eu Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
| * rtc: goldfish: Use gf_ioread32()/gf_iowrite32()Laurent Vivier2022-04-111-15/+16
| | | | | | | | | | | | | | | | | | | | Replace readl()/writel() by gf_ioread32()/gf_iowrite32() as done for goldfish-tty. Signed-off-by: Laurent Vivier <laurent@vivier.eu> Acked-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220406201523.243733-3-laurent@vivier.eu Signed-off-by: Geert Uytterhoeven <geert@linux-m68k.org>
* | Revert "clk: sunxi-ng: sun6i-rtc: Add support for H6"Jernej Skrabec2022-05-171-0/+17
|/ | | | | | | | | | | | | | This reverts commit 1738890a3165ccd0da98ebd3e2d5f9b230d5afa8. Commit 1738890a3165 ("clk: sunxi-ng: sun6i-rtc: Add support for H6") breaks HDMI output on Tanix TX6 mini board. Exact reason isn't known, but because that commit doesn't actually improve anything, let's just revert it. Cc: stable@vger.kernel.org Signed-off-by: Jernej Skrabec <jernej.skrabec@gmail.com> Link: https://lore.kernel.org/r/20220511200206.2458274-1-jernej.skrabec@gmail.com Signed-off-by: Stephen Boyd <sboyd@kernel.org>
* Merge tag 'rtc-5.18' of ↵Linus Torvalds2022-04-0125-202/+617
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux Pull RTC updates from Alexandre Belloni: "The bulk of the patches are about replacing the uie_unsupported struct rtc_device member by a feature bit. Subsystem: - remove uie_unsupported, all users have been converted to clear RTC_FEATURE_UPDATE_INTERRUPT and provide a reason - RTCs with an alarm with a resolution of a minute are now letting the core handle rounding down the alarm time - fix use-after-free on device removal New driver: - OP-TEE RTC PTA Drivers: - sun6i: Add H616 support - cmos: Fix the AltCentury for AMD platforms - spear: set range" * tag 'rtc-5.18' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (56 commits) rtc: check if __rtc_read_time was successful rtc: gamecube: Fix refcount leak in gamecube_rtc_read_offset_from_sram rtc: mc146818-lib: Fix the AltCentury for AMD platforms rtc: optee: add RTC driver for OP-TEE RTC PTA rtc: pm8xxx: Return -ENODEV if set_time disallowed rtc: pm8xxx: Attach wake irq to device clk: sunxi-ng: sun6i-rtc: include clk/sunxi-ng.h rtc: remove uie_unsupported rtc: xgene: stop using uie_unsupported rtc: hym8563: switch to RTC_FEATURE_UPDATE_INTERRUPT rtc: hym8563: let the core handle the alarm resolution rtc: hym8563: switch to devm_rtc_allocate_device rtc: efi: switch to RTC_FEATURE_UPDATE_INTERRUPT rtc: efi: switch to devm_rtc_allocate_device rtc: add new RTC_FEATURE_ALARM_WAKEUP_ONLY feature rtc: spear: fix spear_rtc_read_time rtc: spear: drop uie_unsupported rtc: spear: set range rtc: spear: switch to devm_rtc_allocate_device rtc: pcf8563: switch to RTC_FEATURE_UPDATE_INTERRUPT ...
| * rtc: check if __rtc_read_time was successfulTom Rix2022-03-291-2/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Clang static analysis reports this issue interface.c:810:8: warning: Passed-by-value struct argument contains uninitialized data now = rtc_tm_to_ktime(tm); ^~~~~~~~~~~~~~~~~~~ tm is set by a successful call to __rtc_read_time() but its return status is not checked. Check if it was successful before setting the enabled flag. Move the decl of err to function scope. Fixes: 2b2f5ff00f63 ("rtc: interface: ignore expired timers when enqueuing new timers") Signed-off-by: Tom Rix <trix@redhat.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220326194236.2916310-1-trix@redhat.com
| * rtc: gamecube: Fix refcount leak in gamecube_rtc_read_offset_from_sramMiaoqian Lin2022-03-291-0/+1
| | | | | | | | | | | | | | | | | | | | | | The of_find_compatible_node() function returns a node pointer with refcount incremented, We should use of_node_put() on it when done Add the missing of_node_put() to release the refcount. Fixes: 86559400b3ef ("rtc: gamecube: Add a RTC driver for the GameCube, Wii and Wii U") Signed-off-by: Miaoqian Lin <linmq006@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220309092225.6930-1-linmq006@gmail.com
| * rtc: mc146818-lib: Fix the AltCentury for AMD platformsMario Limonciello2022-03-291-1/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Setting the century forward has been failing on AMD platforms. There was a previous attempt at fixing this for family 0x17 as part of commit 7ad295d5196a ("rtc: Fix the AltCentury value on AMD/Hygon platform") but this was later reverted due to some problems reported that appeared to stem from an FW bug on a family 0x17 desktop system. The same comments mentioned in the previous commit continue to apply to the newer platforms as well. ``` MC146818 driver use function mc146818_set_time() to set register RTC_FREQ_SELECT(RTC_REG_A)'s bit4-bit6 field which means divider stage reset value on Intel platform to 0x7. While AMD/Hygon RTC_REG_A(0Ah)'s bit4 is defined as DV0 [Reference]: DV0 = 0 selects Bank 0, DV0 = 1 selects Bank 1. Bit5-bit6 is defined as reserved. DV0 is set to 1, it will select Bank 1, which will disable AltCentury register(0x32) access. As UEFI pass acpi_gbl_FADT.century 0x32 (AltCentury), the CMOS write will be failed on code: CMOS_WRITE(century, acpi_gbl_FADT.century). Correct RTC_REG_A bank select bit(DV0) to 0 on AMD/Hygon CPUs, it will enable AltCentury(0x32) register writing and finally setup century as expected. ``` However in closer examination the change previously submitted was also modifying bits 5 & 6 which are declared reserved in the AMD documentation. So instead modify just the DV0 bank selection bit. Being cognizant that there was a failure reported before, split the code change out to a static function that can also be used for exclusions if any regressions such as Mikhail's pop up again. Cc: Jinke Fan <fanjinke@hygon.cn> Cc: Mikhail Gavrilov <mikhail.v.gavrilov@gmail.com> Link: https://lore.kernel.org/all/CABXGCsMLob0DC25JS8wwAYydnDoHBSoMh2_YLPfqm3TTvDE-Zw@mail.gmail.com/ Link: https://www.amd.com/system/files/TechDocs/51192_Bolton_FCH_RRG.pdf Signed-off-by: Raul E Rangel <rrangel@chromium.org> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220111225750.1699-1-mario.limonciello@amd.com
| * rtc: optee: add RTC driver for OP-TEE RTC PTAClément Léger2022-03-253-0/+373
| | | | | | | | | | | | | | | | | | | | | | | | | | This drivers allows to communicate with a RTC PTA handled by OP-TEE [1]. This PTA allows to query RTC information, set/get time and set/get offset depending on the supported features. [1] https://github.com/OP-TEE/optee_os/pull/5179 Signed-off-by: Clément Léger <clement.leger@bootlin.com> Reviewed-by: Jens Wiklander <jens.wiklander@linaro.org> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220308133505.471601-1-clement.leger@bootlin.com
| * rtc: pm8xxx: Return -ENODEV if set_time disallowedLoic Poulain2022-03-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Having !allow_set_time is equivalent to non-implemented set_time function, which is normally represented with -ENODEV error in RTC subsystem. Today we are returning -EACCES error code, which is not considered by RTC clients as a 'non implemented' feature, and which causes NTP to retry hw clk sync (update_rtc) indefinitely. Signed-off-by: Loic Poulain <loic.poulain@linaro.org> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/1645090578-20734-1-git-send-email-loic.poulain@linaro.org
| * rtc: pm8xxx: Attach wake irq to deviceLoic Poulain2022-03-251-21/+10
| | | | | | | | | | | | | | | | | | | | | | | | Attach the interrupt as a wake-irq to the device, so that: - A corresponding wakeup source is created (and reported in e.g /sys/kernel/debug/wakeup_sources). - The power subsystem take cares of arming/disarming irq-wake automatically on suspend/resume. Signed-off-by: Loic Poulain <loic.poulain@linaro.org> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/1645025082-6138-1-git-send-email-loic.poulain@linaro.org
| * rtc: remove uie_unsupportedAlexandre Belloni2022-03-231-3/+0
| | | | | | | | | | | | | | uie_unsupported is not used by any drivers anymore, remove it. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220309162301.61679-29-alexandre.belloni@bootlin.com
| * rtc: xgene: stop using uie_unsupportedAlexandre Belloni2022-03-231-2/+0
| | | | | | | | | | | | | | Remove bogus use of uie_unsupported. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220309162301.61679-28-alexandre.belloni@bootlin.com
| * rtc: hym8563: switch to RTC_FEATURE_UPDATE_INTERRUPTAlexandre Belloni2022-03-231-2/+1
| | | | | | | | | | | | | | Stop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220309162301.61679-27-alexandre.belloni@bootlin.com
| * rtc: hym8563: let the core handle the alarm resolutionAlexandre Belloni2022-03-231-18/+1
| | | | | | | | | | | | | | | | | | Set RTC_FEATURE_ALARM_RES_MINUTE, so the core knows alarms have a resolution of a minute. Also, the core will properly round down the alarm instead of up. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220309162301.61679-26-alexandre.belloni@bootlin.com
| * rtc: hym8563: switch to devm_rtc_allocate_deviceAlexandre Belloni2022-03-231-6/+6
| | | | | | | | | | | | | | | | Switch to devm_rtc_allocate_device/devm_rtc_register_device, this allows for further improvement of the driver. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220309162301.61679-25-alexandre.belloni@bootlin.com
| * rtc: efi: switch to RTC_FEATURE_UPDATE_INTERRUPTAlexandre Belloni2022-03-231-1/+2
| | | | | | | | | | | | | | | | | | Stop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead. Also the driver doesn't supports UIE because it doesn't handle interrupts so set RTC_FEATURE_ALARM_WAKEUP_ONLY,. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220309162301.61679-24-alexandre.belloni@bootlin.com
| * rtc: efi: switch to devm_rtc_allocate_deviceAlexandre Belloni2022-03-231-4/+5
| | | | | | | | | | | | | | | | Switch to devm_rtc_allocate_device/devm_rtc_register_device, this allows for further improvement of the driver. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220309162301.61679-23-alexandre.belloni@bootlin.com
| * rtc: spear: fix spear_rtc_read_timeAlexandre Belloni2022-03-231-2/+4
| | | | | | | | | | | | | | | | | | The reference manual doesn't specify whether the registers are latched and they probably aren't, ensure the read time and date are consistent. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Link: https://lore.kernel.org/r/20220309162301.61679-21-alexandre.belloni@bootlin.com
| * rtc: spear: drop uie_unsupportedAlexandre Belloni2022-03-231-1/+0
| | | | | | | | | | | | | | | | | | | | Since commitc9f5c7e7a84f ("rtc: rtc-spear: Provide flag for no support of UIE mode") which was in 2012, the core changed a lot and UIE are now supported using regular alarms. Drop uie_unsupported now to reflect that. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Link: https://lore.kernel.org/r/20220309162301.61679-20-alexandre.belloni@bootlin.com
| * rtc: spear: set rangeAlexandre Belloni2022-03-231-0/+2
| | | | | | | | | | | | | | | | | | | | While the RTC can store dates from year 0000 to 9999, leap years where not tested fro 2100. The driver currently stores tm_year directly which will probably fail at that time or more probably in 2300. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Link: https://lore.kernel.org/r/20220309162301.61679-19-alexandre.belloni@bootlin.com
| * rtc: spear: switch to devm_rtc_allocate_deviceAlexandre Belloni2022-03-231-9/+9
| | | | | | | | | | | | | | | | | | Switch to devm_rtc_allocate_device/devm_rtc_register_device, this allows for further improvement of the driver. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Acked-by: Viresh Kumar <viresh.kumar@linaro.org> Link: https://lore.kernel.org/r/20220309162301.61679-18-alexandre.belloni@bootlin.com
| * rtc: pcf8563: switch to RTC_FEATURE_UPDATE_INTERRUPTAlexandre Belloni2022-03-231-1/+1
| | | | | | | | | | | | | | Stop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220309162301.61679-17-alexandre.belloni@bootlin.com
| * rtc: pcf8563: let the core handle the alarm resolutionAlexandre Belloni2022-03-231-13/+1
| | | | | | | | | | | | | | | | | | Set RTC_FEATURE_ALARM_RES_MINUTE, so the core knows alarms have a resolution of a minute. Also, the core will properly round down the alarm instead of up. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220309162301.61679-16-alexandre.belloni@bootlin.com
| * rtc: pcf8523: let the core handle the alarm resolutionAlexandre Belloni2022-03-231-8/+1
| | | | | | | | | | | | | | | | | | Set RTC_FEATURE_ALARM_RES_MINUTE, so the core knows alarms have a resolution of a minute. Also, the core will properly round down the alarm instead of up. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220309162301.61679-15-alexandre.belloni@bootlin.com
| * rtc: pcf8523: switch to RTC_FEATURE_UPDATE_INTERRUPTAlexandre Belloni2022-03-231-1/+1
| | | | | | | | | | | | | | Stop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220309162301.61679-14-alexandre.belloni@bootlin.com
| * rtc: pcf85063: set RTC_FEATURE_ALARM_RES_2SAlexandre Belloni2022-03-231-0/+1
| | | | | | | | | | | | | | | | | | The PCF85063 doesn't support UIE because setting an alarm to fire every second confuses the chip and the fastest we can go is an alarm every 2 seconds. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220309162301.61679-13-alexandre.belloni@bootlin.com
| * rtc: pcf85063: switch to RTC_FEATURE_UPDATE_INTERRUPTAlexandre Belloni2022-03-231-1/+1
| | | | | | | | | | | | | | Stop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220309162301.61679-12-alexandre.belloni@bootlin.com
| * rtc: pcf2127: set RTC_FEATURE_ALARM_RES_2SAlexandre Belloni2022-03-231-0/+1
| | | | | | | | | | | | | | | | | | The PCF2127 doesn't support UIE because setting an alarm to fire every second confuses the chip and the fastest we can go is an alarm every 2 seconds. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220309162301.61679-11-alexandre.belloni@bootlin.com
| * rtc: pcf2127: switch to RTC_FEATURE_UPDATE_INTERRUPTAlexandre Belloni2022-03-231-1/+1
| | | | | | | | | | | | | | Stop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220309162301.61679-10-alexandre.belloni@bootlin.com
| * rtc: pcf2123: set RTC_FEATURE_ALARM_RES_MINUTEAlexandre Belloni2022-03-231-0/+1
| | | | | | | | | | | | | | Alarms have a resolution of a minute. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220309162301.61679-9-alexandre.belloni@bootlin.com
| * rtc: pcf2123: switch to RTC_FEATURE_UPDATE_INTERRUPTAlexandre Belloni2022-03-231-1/+1
| | | | | | | | | | | | | | Stop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220309162301.61679-8-alexandre.belloni@bootlin.com
| * rtc: opal: switch to RTC_FEATURE_UPDATE_INTERRUPTAlexandre Belloni2022-03-231-1/+1
| | | | | | | | | | | | | | Stop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220309162301.61679-7-alexandre.belloni@bootlin.com
| * rtc: m41t80: switch to RTC_FEATURE_UPDATE_INTERRUPTAlexandre Belloni2022-03-231-4/+2
| | | | | | | | | | | | | | Stop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220309162301.61679-6-alexandre.belloni@bootlin.com
| * rtc: mpc5121: switch to RTC_FEATURE_UPDATE_INTERRUPTAlexandre Belloni2022-03-231-1/+1
| | | | | | | | | | | | | | Stop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220309162301.61679-5-alexandre.belloni@bootlin.com
| * rtc: mpc5121: let the core handle the alarm resolutionAlexandre Belloni2022-03-231-14/+1
| | | | | | | | | | | | | | | | | | Set RTC_FEATURE_ALARM_RES_MINUTE, so the core knows alarms have a resolution of a minute. Also, the core will properly round down the alarm instead of up. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220309162301.61679-4-alexandre.belloni@bootlin.com
| * rtc: ds1307: switch to RTC_FEATURE_UPDATE_INTERRUPTAlexandre Belloni2022-03-231-1/+1
| | | | | | | | | | | | | | Stop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220309162301.61679-3-alexandre.belloni@bootlin.com
| * rtc: ds1685: drop no_irqAlexandre Belloni2022-03-231-9/+5
| | | | | | | | | | | | | | | | | | No platforms are currently setting no_irq. Anyway, letting platform_get_irq fail is fine as this means that there is no IRQ. In that case, clear RTC_FEATURE_ALARM so the core knows there are no alarms. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220309162301.61679-2-alexandre.belloni@bootlin.com
| * rtc: ds1685: switch to RTC_FEATURE_UPDATE_INTERRUPTAlexandre Belloni2022-03-231-1/+1
| | | | | | | | | | | | | | | | | | Stop using uie_unsupported and clear RTC_FEATURE_UPDATE_INTERRUPT instead. There is currently a missing information as to why this is not supported on ioc3. Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220309162301.61679-1-alexandre.belloni@bootlin.com
| * clk: sunxi-ng: sun6i-rtc: Add support for H6Samuel Holland2022-03-231-17/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | H6 supports IOSC calibration and an ext-osc32k input. Unlike newer SoCs, it has a single parent for its fanout clock. Add support for H6 in the CCU driver, replacing the support in the existing early OF clock provider. Signed-off-by: Samuel Holland <samuel@sholland.org> Acked-by: Stephen Boyd <sboyd@kernel.org> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220203021736.13434-7-samuel@sholland.org
| * clk: sunxi-ng: Add support for the sun6i RTC clocksSamuel Holland2022-03-231-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The RTC power domain in sun6i and newer SoCs manages the 16 MHz RC oscillator (called "IOSC" or "osc16M") and the optional 32 kHz crystal oscillator (called "LOSC" or "osc32k"). Starting with the H6, this power domain also handles the 24 MHz DCXO (called variously "HOSC", "dcxo24M", or "osc24M") as well. The H6 also adds a calibration circuit for IOSC. Later SoCs introduce further variations on the design: - H616 adds an additional mux for the 32 kHz fanout source. - R329 adds an additional mux for the RTC timekeeping clock, a clock for the SPI bus between power domains inside the RTC, and removes the IOSC calibration functionality. Take advantage of the CCU framework to handle this increased complexity. This driver is intended to be a drop-in replacement for the existing RTC clock provider. So some runtime adjustment of the clock parents is needed, both to handle hardware differences, and to support the old binding which omitted some of the input clocks. Signed-off-by: Samuel Holland <samuel@sholland.org> Acked-by: Stephen Boyd <sboyd@kernel.org> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220203021736.13434-6-samuel@sholland.org
| * rtc: wm8350: Handle error for wm8350_register_irqJiasheng Jiang2022-03-231-2/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | As the potential failure of the wm8350_register_irq(), it should be better to check it and return error if fails. Also, it need not free 'wm_rtc->rtc' since it will be freed automatically. Fixes: 077eaf5b40ec ("rtc: rtc-wm8350: add support for WM8350 RTC") Signed-off-by: Jiasheng Jiang <jiasheng@iscas.ac.cn> Acked-by: Charles Keepax <ckeepax@opensource.cirrus.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220303085030.291793-1-jiasheng@iscas.ac.cn
| * rtc: sun6i: Add Allwinner H616 supportAndre Przywara2022-03-231-0/+2
| | | | | | | | | | | | | | | | | | | | | | The H616 RTC changes its day storage to the newly introduced linear day scheme, so pair the new compatible string with this feature flag. The RTC clock parts are handled in a separate driver now, so we skip the clock parts in this driver completely. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220211122643.1343315-7-andre.przywara@arm.com
| * rtc: sun6i: Add support for broken-down alarm registersAndre Przywara2022-03-231-17/+40
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Newer versions of the Allwinner RTC, for instance as found in the H616 SoC, not only store the current day as a linear number, but also change the way the alarm is handled: There are now two registers, that explicitly store the wakeup time, in the same format as the current time. Add support for that variant by writing the requested wakeup time directly into the registers, instead of programming the seconds left, as the old SoCs required. Reviewed by: Jernej Skrabec <jernej.skrabec@gmail.com> Signed-off-by: Andre Przywara <andre.przywara@arm.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220211122643.1343315-6-andre.przywara@arm.com
| * rtc: sun6i: Add support for linear day storageAndre Przywara2022-03-231-23/+46
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Newer versions of the Allwinner RTC, as for instance found in the H616 SoC, no longer store a broken-down day/month/year representation in the RTC_DAY_REG, but just a linear day number. The user manual does not give any indication about the expected epoch time of this day count, but the BSP kernel uses the UNIX epoch, which allows easy support due to existing conversion functions in the kernel. Allow tagging a compatible string with a flag, and use that to mark those new RTCs. Then convert between a UNIX day number (converted into seconds) and the broken-down day representation using mktime64() and time64_to_tm() in the set_time/get_time functions. That enables support for the RTC in those new chips. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220211122643.1343315-5-andre.przywara@arm.com
| * rtc: sun6i: Fix time overflow handlingAndre Przywara2022-03-231-9/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using "unsigned long" for UNIX timestamps is never a good idea, and comparing the value of such a variable against U32_MAX does not do anything useful on 32-bit systems. Use the proper time64_t type when dealing with timestamps, and avoid cutting down the time range unnecessarily. This also fixes the flawed check for the alarm time being too far into the future. The check for this condition is actually somewhat theoretical, as the RTC counts till 2033 only anyways, and 2^32 seconds from now is not before the year 2157 - at which point I hope nobody will be using this hardware anymore. Signed-off-by: Andre Przywara <andre.przywara@arm.com> Reviewed-by: Jernej Skrabec <jernej.skrabec@gmail.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220211122643.1343315-4-andre.przywara@arm.com
| * rtc: pl031: fix rtc features null pointer dereferenceAli Pouladi2022-03-231-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When there is no interrupt line, rtc alarm feature is disabled. The clearing of the alarm feature bit was being done prior to allocations of ldata->rtc device, resulting in a null pointer dereference. Clear RTC_FEATURE_ALARM after the rtc device is allocated. Fixes: d9b0dd54a194 ("rtc: pl031: use RTC_FEATURE_ALARM") Cc: stable@vger.kernel.org Signed-off-by: Ali Pouladi <quic_apouladi@quicinc.com> Signed-off-by: Elliot Berman <quic_eberman@quicinc.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220225161924.274141-1-quic_eberman@quicinc.com
| * rtc: mc146818-lib: fix locking in mc146818_set_timeMateusz Jończyk2022-03-231-2/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | In mc146818_set_time(), CMOS_READ(RTC_CONTROL) was performed without the rtc_lock taken, which is required for CMOS accesses. Fix this. Nothing in kernel modifies RTC_DM_BINARY, so a separate critical section is allowed here. Fixes: dcf257e92622 ("rtc: mc146818: Reduce spinlock section in mc146818_set_time()") Signed-off-by: Mateusz Jończyk <mat.jonczyk@o2.pl> Cc: Alessandro Zummo <a.zummo@towertech.it> Cc: Alexandre Belloni <alexandre.belloni@bootlin.com> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: stable@vger.kernel.org Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220220090403.153928-1-mat.jonczyk@o2.pl
| * rtc: pcf2127: fix bug when reading alarm registersHugo Villeneuve2022-02-151-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The first bug is that reading the 5 alarm registers results in a read operation of 20 bytes. The reason is because the destination buffer is defined as an array of "unsigned int", and we use the sizeof() operator on this array to define the bulk read count. The second bug is that the read value is invalid, because we are indexing the destination buffer as integers (4 bytes), instead of indexing it as u8. Changing the destination buffer type to u8 fixes both problems. Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220208162908.3182581-1-hugo@hugovil.com
| * rtc: pcf2127: use IRQ flags obtained from device tree if availableHugo Villeneuve2022-02-151-1/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | If the interrupt pin of the PCF2127 is routed to the input of a GPIO expander using the pca953x driver, the later will only accept an IRQ of type IRQ_TYPE_EDGE_FALLING or IRQ_TYPE_EDGE_RISING, and the IRQ request will fail. Therefore, allow the IRQ type to be passed from the device tree data if available. Signed-off-by: Hugo Villeneuve <hvilleneuve@dimonoff.com> Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com> Link: https://lore.kernel.org/r/20220117225742.1252362-1-hugo@hugovil.com