Skip to content

Commit bdabb68

Browse files
committed
Merge tag 'rtc-5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux
Pull RTC updates from Alexandre Belloni: "More cleanup this cycle, with the final goal of removing the rtc_time_to_tm and rtc_tm_to_time wrappers. All the drivers that have been modified for this now are ready for the end of times (whether it happens in 2033, 2038, 2106, 2127 or even 4052). There is also a single new driver and the usual fixes and features. Summary: Subsystem: - The rtc_time_to_tm and rtc_tm_to_time wrappers have finally been removed and only the 64bit version remain. - hctosys now works with drivers compiled as modules New driver: - MediaTek MT2712 SoC based RTC Drivers: - set range for 88pm860x, au1xxx, cpcap, da9052, davinci, ds1305, ds1374, mcp5121, pl030, pl031, pm8xxx, puv3, sa1100, sirfsoc, starfire, sun6i - ds1307: DS1388 oscillator failure detection and watchdog support - jz4740: JZ4760 support - pcf85063: clock out pin support - sun6i: external 32k oscillator is now optional, the range is now handled by the core, providing a solution for 2034" * tag 'rtc-5.7' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (87 commits) rtc: ds1307: check for failed memory allocation on wdt rtc: class: remove redundant assignment to variable err rtc: remove rtc_time_to_tm and rtc_tm_to_time rtc: sun6i: let the core handle rtc range rtc: sun6i: switch to rtc_time64_to_tm/rtc_tm_to_time64 rtc: ds1307: add support for watchdog timer on ds1388 rtc: da9052: switch to rtc_time64_to_tm/rtc_tm_to_time64 rtc: da9052: set range rtc: da9052: convert to devm_rtc_allocate_device rtc: imx-sc: Align imx sc msg structs to 4 rtc: fsl-ftm-alarm: report alarm to core rtc: pcf85063: Add pcf85063 clkout control to common clock framework rtc: make definitions in include/uapi/linux/rtc.h actually useful for user space rtc: class: avoid unnecessary lookup in hctosys dt-bindings: rtc: Convert and update jz4740-rtc doc to YAML rtc: jz4740: Rename vendor-specific DT properties rtc: jz4740: Add support for JZ4760 SoC rtc: class: support hctosys from modular RTC drivers rtc: pm8xxx: clear alarm register when alarm is not enabled rtc: omap: drop unused dt-bindings header ...
2 parents 828907e + 1821b79 commit bdabb68

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+1191
-573
lines changed

Documentation/devicetree/bindings/rtc/ingenic,jz4740-rtc.txt

Lines changed: 0 additions & 37 deletions
This file was deleted.
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/rtc/ingenic,rtc.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Ingenic SoCs Real-Time Clock DT bindings
8+
9+
maintainers:
10+
- Paul Cercueil <[email protected]>
11+
12+
allOf:
13+
- $ref: rtc.yaml#
14+
15+
properties:
16+
compatible:
17+
oneOf:
18+
- enum:
19+
- ingenic,jz4740-rtc
20+
- ingenic,jz4760-rtc
21+
- items:
22+
- const: ingenic,jz4725b-rtc
23+
- const: ingenic,jz4740-rtc
24+
- items:
25+
- enum:
26+
- ingenic,jz4770-rtc
27+
- ingenic,jz4780-rtc
28+
- const: ingenic,jz4760-rtc
29+
30+
reg:
31+
maxItems: 1
32+
33+
interrupts:
34+
maxItems: 1
35+
36+
clocks:
37+
maxItems: 1
38+
39+
clock-names:
40+
const: rtc
41+
42+
system-power-controller:
43+
description: |
44+
Indicates that the RTC is responsible for powering OFF
45+
the system.
46+
type: boolean
47+
48+
ingenic,reset-pin-assert-time-ms:
49+
minimum: 0
50+
maximum: 125
51+
default: 60
52+
description: |
53+
Reset pin low-level assertion time after wakeup
54+
(assuming RTC clock at 32 kHz)
55+
56+
ingenic,min-wakeup-pin-assert-time-ms:
57+
minimum: 0
58+
maximum: 2000
59+
default: 100
60+
description: |
61+
Minimum wakeup pin assertion time
62+
(assuming RTC clock at 32 kHz)
63+
64+
required:
65+
- compatible
66+
- reg
67+
- interrupts
68+
- clocks
69+
- clock-names
70+
71+
examples:
72+
- |
73+
#include <dt-bindings/clock/jz4740-cgu.h>
74+
rtc_dev: rtc@10003000 {
75+
compatible = "ingenic,jz4740-rtc";
76+
reg = <0x10003000 0x40>;
77+
78+
interrupt-parent = <&intc>;
79+
interrupts = <15>;
80+
81+
clocks = <&cgu JZ4740_CLK_RTC>;
82+
clock-names = "rtc";
83+
};
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
Device-Tree bindings for MediaTek SoC based RTC
2+
3+
Required properties:
4+
- compatible : Should be "mediatek,mt2712-rtc" : for MT2712 SoC
5+
- reg : Specifies base physical address and size of the registers;
6+
- interrupts : Should contain the interrupt for RTC alarm;
7+
8+
Example:
9+
10+
rtc: rtc@10011000 {
11+
compatible = "mediatek,mt2712-rtc";
12+
reg = <0 0x10011000 0 0x1000>;
13+
interrupts = <GIC_SPI 239 IRQ_TYPE_LEVEL_LOW>;
14+
};

MAINTAINERS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2015,7 +2015,9 @@ M: Sean Wang <[email protected]>
20152015
L: [email protected] (moderated for non-subscribers)
20162016
L: [email protected] (moderated for non-subscribers)
20172017
S: Maintained
2018+
F: Documentation/devicetree/bindings/rtc/rtc-mt2712.txt
20182019
F: Documentation/devicetree/bindings/rtc/rtc-mt7622.txt
2020+
F: drivers/rtc/rtc-mt2712.c
20192021
F: drivers/rtc/rtc-mt6397.c
20202022
F: drivers/rtc/rtc-mt7622.c
20212023

drivers/rtc/Kconfig

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,6 @@ config RTC_HCTOSYS_DEVICE
4141
device should record time in UTC, since the kernel won't do
4242
timezone correction.
4343

44-
The driver for this RTC device must be loaded before late_initcall
45-
functions run, so it must usually be statically linked.
46-
4744
This clock should be battery-backed, so that it reads the correct
4845
time when the system boots from a power-off state. Otherwise, your
4946
system will need an external clock source (like an NTP server).
@@ -241,6 +238,7 @@ config RTC_DRV_AS3722
241238
config RTC_DRV_DS1307
242239
tristate "Dallas/Maxim DS1307/37/38/39/40/41, ST M41T00, EPSON RX-8025, ISL12057"
243240
select REGMAP_I2C
241+
select WATCHDOG_CORE if WATCHDOG
244242
help
245243
If you say yes here you get support for various compatible RTC
246244
chips (often with battery backup) connected with I2C. This driver
@@ -1335,7 +1333,7 @@ config RTC_DRV_IMXDI
13351333

13361334
config RTC_DRV_FSL_FTM_ALARM
13371335
tristate "Freescale FlexTimer alarm timer"
1338-
depends on ARCH_LAYERSCAPE || SOC_LS1021A
1336+
depends on ARCH_LAYERSCAPE || SOC_LS1021A || COMPILE_TEST
13391337
help
13401338
For the FlexTimer in LS1012A, LS1021A, LS1028A, LS1043A, LS1046A,
13411339
LS1088A, LS208xA, we can use FTM as the wakeup source.
@@ -1762,6 +1760,7 @@ config RTC_DRV_MXC_V2
17621760
config RTC_DRV_SNVS
17631761
tristate "Freescale SNVS RTC support"
17641762
select REGMAP_MMIO
1763+
depends on ARCH_MXC || COMPILE_TEST
17651764
depends on HAS_IOMEM
17661765
depends on OF
17671766
help
@@ -1807,6 +1806,16 @@ config RTC_DRV_MOXART
18071806
This driver can also be built as a module. If so, the module
18081807
will be called rtc-moxart
18091808

1809+
config RTC_DRV_MT2712
1810+
tristate "MediaTek MT2712 SoC based RTC"
1811+
depends on ARCH_MEDIATEK || COMPILE_TEST
1812+
help
1813+
This enables support for the real time clock built in the MediaTek
1814+
SoCs for MT2712.
1815+
1816+
This drive can also be built as a module. If so, the module
1817+
will be called rtc-mt2712.
1818+
18101819
config RTC_DRV_MT6397
18111820
tristate "MediaTek PMIC based RTC"
18121821
depends on MFD_MT6397 || (COMPILE_TEST && IRQ_DOMAIN)

drivers/rtc/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
ccflags-$(CONFIG_RTC_DEBUG) := -DDEBUG
77

88
obj-$(CONFIG_RTC_LIB) += lib.o
9-
obj-$(CONFIG_RTC_HCTOSYS) += hctosys.o
109
obj-$(CONFIG_RTC_SYSTOHC) += systohc.o
1110
obj-$(CONFIG_RTC_CLASS) += rtc-core.o
1211
obj-$(CONFIG_RTC_MC146818_LIB) += rtc-mc146818-lib.o
@@ -106,6 +105,7 @@ obj-$(CONFIG_RTC_DRV_MESON) += rtc-meson.o
106105
obj-$(CONFIG_RTC_DRV_MOXART) += rtc-moxart.o
107106
obj-$(CONFIG_RTC_DRV_MPC5121) += rtc-mpc5121.o
108107
obj-$(CONFIG_RTC_DRV_MSM6242) += rtc-msm6242.o
108+
obj-$(CONFIG_RTC_DRV_MT2712) += rtc-mt2712.o
109109
obj-$(CONFIG_RTC_DRV_MT6397) += rtc-mt6397.o
110110
obj-$(CONFIG_RTC_DRV_MT7622) += rtc-mt7622.o
111111
obj-$(CONFIG_RTC_DRV_MV) += rtc-mv.o

drivers/rtc/class.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,50 @@ static void rtc_device_release(struct device *dev)
3434
#ifdef CONFIG_RTC_HCTOSYS_DEVICE
3535
/* Result of the last RTC to system clock attempt. */
3636
int rtc_hctosys_ret = -ENODEV;
37+
38+
/* IMPORTANT: the RTC only stores whole seconds. It is arbitrary
39+
* whether it stores the most close value or the value with partial
40+
* seconds truncated. However, it is important that we use it to store
41+
* the truncated value. This is because otherwise it is necessary,
42+
* in an rtc sync function, to read both xtime.tv_sec and
43+
* xtime.tv_nsec. On some processors (i.e. ARM), an atomic read
44+
* of >32bits is not possible. So storing the most close value would
45+
* slow down the sync API. So here we have the truncated value and
46+
* the best guess is to add 0.5s.
47+
*/
48+
49+
static void rtc_hctosys(struct rtc_device *rtc)
50+
{
51+
int err;
52+
struct rtc_time tm;
53+
struct timespec64 tv64 = {
54+
.tv_nsec = NSEC_PER_SEC >> 1,
55+
};
56+
57+
err = rtc_read_time(rtc, &tm);
58+
if (err) {
59+
dev_err(rtc->dev.parent,
60+
"hctosys: unable to read the hardware clock\n");
61+
goto err_read;
62+
}
63+
64+
tv64.tv_sec = rtc_tm_to_time64(&tm);
65+
66+
#if BITS_PER_LONG == 32
67+
if (tv64.tv_sec > INT_MAX) {
68+
err = -ERANGE;
69+
goto err_read;
70+
}
71+
#endif
72+
73+
err = do_settimeofday64(&tv64);
74+
75+
dev_info(rtc->dev.parent, "setting system clock to %ptR UTC (%lld)\n",
76+
&tm, (long long)tv64.tv_sec);
77+
78+
err_read:
79+
rtc_hctosys_ret = err;
80+
}
3781
#endif
3882

3983
#if defined(CONFIG_PM_SLEEP) && defined(CONFIG_RTC_HCTOSYS_DEVICE)
@@ -375,6 +419,11 @@ int __rtc_register_device(struct module *owner, struct rtc_device *rtc)
375419
dev_info(rtc->dev.parent, "registered as %s\n",
376420
dev_name(&rtc->dev));
377421

422+
#ifdef CONFIG_RTC_HCTOSYS_DEVICE
423+
if (!strcmp(dev_name(&rtc->dev), CONFIG_RTC_HCTOSYS_DEVICE))
424+
rtc_hctosys(rtc);
425+
#endif
426+
378427
return 0;
379428
}
380429
EXPORT_SYMBOL_GPL(__rtc_register_device);

drivers/rtc/hctosys.c

Lines changed: 0 additions & 69 deletions
This file was deleted.

0 commit comments

Comments
 (0)