Skip to content

Commit 98906f9

Browse files
committed
Merge tag 'rtc-6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux
Pull RTC updates from Alexandre Belloni: "This cycle, we have a new RTC driver, for the SpacemiT P1. The optee driver gets alarm support. We also get a fix for a race condition that was fairly rare unless while stress testing the alarms. Subsystem: - Fix race when setting alarm - Ensure alarm irq is enabled when UIE is enabled - remove unneeded 'fast_io' parameter in regmap_config New driver: - SpacemiT P1 RTC Drivers: - efi: Remove wakeup functionality - optee: add alarms support - s3c: Drop support for S3C2410 - zynqmp: Restore alarm functionality after kexec transition" * tag 'rtc-6.18' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (29 commits) rtc: interface: Ensure alarm irq is enabled when UIE is enabled rtc: tps6586x: Fix initial enable_irq/disable_irq balance rtc: cpcap: Fix initial enable_irq/disable_irq balance rtc: isl12022: Fix initial enable_irq/disable_irq balance rtc: interface: Fix long-standing race when setting alarm rtc: pcf2127: fix watchdog interrupt mask on pcf2131 rtc: zynqmp: Restore alarm functionality after kexec transition rtc: amlogic-a4: Optimize global variables rtc: sd2405al: Add I2C address. rtc: Kconfig: move symbols to proper section rtc: optee: make optee_rtc_pm_ops static rtc: optee: Fix error code in optee_rtc_read_alarm() rtc: optee: fix error code in probe() dt-bindings: rtc: Convert apm,xgene-rtc to DT schema rtc: spacemit: support the SpacemiT P1 RTC rtc: optee: add alarm related rtc ops to optee rtc driver rtc: optee: remove unnecessary memory operations rtc: optee: fix memory leak on driver removal rtc: x1205: Fix Xicor X1205 vendor prefix dt-bindings: rtc: Fix Xicor X1205 vendor prefix ...
2 parents 2a6edd8 + 9db26d5 commit 98906f9

23 files changed

+753
-354
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/rtc/apm,xgene-rtc.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: APM X-Gene Real Time Clock
8+
9+
maintainers:
10+
- Khuong Dinh <khuong@os.amperecomputing.com>
11+
12+
properties:
13+
compatible:
14+
const: apm,xgene-rtc
15+
16+
reg:
17+
maxItems: 1
18+
19+
interrupts:
20+
maxItems: 1
21+
22+
'#clock-cells':
23+
const: 1
24+
25+
clocks:
26+
maxItems: 1
27+
28+
required:
29+
- compatible
30+
- reg
31+
- interrupts
32+
- '#clock-cells'
33+
- clocks
34+
35+
additionalProperties: false
36+
37+
examples:
38+
- |
39+
rtc@10510000 {
40+
compatible = "apm,xgene-rtc";
41+
reg = <0x10510000 0x400>;
42+
interrupts = <0x0 0x46 0x4>;
43+
#clock-cells = <1>;
44+
clocks = <&rtcclk 0>;
45+
};

Documentation/devicetree/bindings/rtc/isil,isl12057.txt

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

Documentation/devicetree/bindings/rtc/nxp,pcf85063.yaml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,6 @@ allOf:
6262
then:
6363
properties:
6464
quartz-load-femtofarads: false
65-
- if:
66-
properties:
67-
compatible:
68-
contains:
69-
enum:
70-
- nxp,pcf85063
71-
then:
72-
properties:
73-
quartz-load-femtofarads:
74-
const: 7000
7565
- if:
7666
properties:
7767
compatible:

Documentation/devicetree/bindings/rtc/s3c-rtc.yaml

Lines changed: 3 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@ properties:
1313
compatible:
1414
oneOf:
1515
- enum:
16-
- samsung,s3c2410-rtc
17-
- samsung,s3c2416-rtc
18-
- samsung,s3c2443-rtc
1916
- samsung,s3c6410-rtc
2017
- items:
2118
- enum:
@@ -29,19 +26,12 @@ properties:
2926
maxItems: 1
3027

3128
clocks:
32-
description:
33-
Must contain a list of phandle and clock specifier for the rtc
34-
clock and in the case of a s3c6410 compatible controller, also
35-
a source clock.
36-
minItems: 1
3729
maxItems: 2
3830

3931
clock-names:
40-
description:
41-
Must contain "rtc" and for a s3c6410 compatible controller
42-
also "rtc_src".
43-
minItems: 1
44-
maxItems: 2
32+
items:
33+
- const: rtc
34+
- const: rtc_src
4535

4636
interrupts:
4737
description:
@@ -54,30 +44,6 @@ properties:
5444

5545
allOf:
5646
- $ref: rtc.yaml#
57-
- if:
58-
properties:
59-
compatible:
60-
contains:
61-
enum:
62-
- samsung,s3c6410-rtc
63-
- samsung,exynos3250-rtc
64-
then:
65-
properties:
66-
clocks:
67-
minItems: 2
68-
maxItems: 2
69-
clock-names:
70-
items:
71-
- const: rtc
72-
- const: rtc_src
73-
else:
74-
properties:
75-
clocks:
76-
minItems: 1
77-
maxItems: 1
78-
clock-names:
79-
items:
80-
- const: rtc
8147

8248
unevaluatedProperties: false
8349

Documentation/devicetree/bindings/rtc/trivial-rtc.yaml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ properties:
3838
- dallas,ds1672
3939
# Extremely Accurate I²C RTC with Integrated Crystal and SRAM
4040
- dallas,ds3232
41+
# Dallas m41t00 Real-time Clock
42+
- dallas,m41t00
4143
# SD2405AL Real-Time Clock
4244
- dfrobot,sd2405al
4345
# EM Microelectronic EM3027 RTC
@@ -83,8 +85,8 @@ properties:
8385
- via,vt8500-rtc
8486
# I2C bus SERIAL INTERFACE REAL-TIME CLOCK IC
8587
- whwave,sd3078
86-
# Xircom X1205 I2C RTC
87-
- xircom,x1205
88+
# Xicor/Intersil X1205 I2C RTC
89+
- xicor,x1205
8890

8991
reg:
9092
maxItems: 1

Documentation/devicetree/bindings/rtc/xgene-rtc.txt

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

drivers/rtc/Kconfig

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -406,6 +406,16 @@ config RTC_DRV_MAX77686
406406
This driver can also be built as a module. If so, the module
407407
will be called rtc-max77686.
408408

409+
config RTC_DRV_SPACEMIT_P1
410+
tristate "SpacemiT P1 RTC"
411+
depends on ARCH_SPACEMIT || COMPILE_TEST
412+
select MFD_SPACEMIT_P1
413+
default ARCH_SPACEMIT
414+
help
415+
Enable support for the RTC function in the SpacemiT P1 PMIC.
416+
This driver can also be built as a module, which will be called
417+
"spacemit-p1-rtc".
418+
409419
config RTC_DRV_NCT3018Y
410420
tristate "Nuvoton NCT3018Y"
411421
depends on OF
@@ -2044,20 +2054,6 @@ config RTC_DRV_RENESAS_RTCA3
20442054
This driver can also be built as a module, if so, the module
20452055
will be called "rtc-rtca3".
20462056

2047-
comment "HID Sensor RTC drivers"
2048-
2049-
config RTC_DRV_HID_SENSOR_TIME
2050-
tristate "HID Sensor Time"
2051-
depends on USB_HID
2052-
depends on HID_SENSOR_HUB && IIO
2053-
select HID_SENSOR_IIO_COMMON
2054-
help
2055-
Say yes here to build support for the HID Sensors of type Time.
2056-
This drivers makes such sensors available as RTCs.
2057-
2058-
If this driver is compiled as a module, it will be named
2059-
rtc-hid-sensor-time.
2060-
20612057
config RTC_DRV_GOLDFISH
20622058
tristate "Goldfish Real Time Clock"
20632059
depends on HAS_IOMEM
@@ -2132,4 +2128,18 @@ config RTC_DRV_S32G
21322128
This RTC module can be used as a wakeup source.
21332129
Please note that it is not battery-powered.
21342130

2131+
comment "HID Sensor RTC drivers"
2132+
2133+
config RTC_DRV_HID_SENSOR_TIME
2134+
tristate "HID Sensor Time"
2135+
depends on USB_HID
2136+
depends on HID_SENSOR_HUB && IIO
2137+
select HID_SENSOR_IIO_COMMON
2138+
help
2139+
Say yes here to build support for the HID Sensors of type Time.
2140+
This drivers makes such sensors available as RTCs.
2141+
2142+
If this driver is compiled as a module, it will be named
2143+
rtc-hid-sensor-time.
2144+
21352145
endif # RTC_CLASS

drivers/rtc/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -172,6 +172,7 @@ obj-$(CONFIG_RTC_DRV_SD2405AL) += rtc-sd2405al.o
172172
obj-$(CONFIG_RTC_DRV_SD3078) += rtc-sd3078.o
173173
obj-$(CONFIG_RTC_DRV_SH) += rtc-sh.o
174174
obj-$(CONFIG_RTC_DRV_SNVS) += rtc-snvs.o
175+
obj-$(CONFIG_RTC_DRV_SPACEMIT_P1) += rtc-spacemit-p1.o
175176
obj-$(CONFIG_RTC_DRV_SPEAR) += rtc-spear.o
176177
obj-$(CONFIG_RTC_DRV_STARFIRE) += rtc-starfire.o
177178
obj-$(CONFIG_RTC_DRV_STK17TA8) += rtc-stk17ta8.o

drivers/rtc/interface.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,29 @@ static int __rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
443443
else
444444
err = rtc->ops->set_alarm(rtc->dev.parent, alarm);
445445

446+
/*
447+
* Check for potential race described above. If the waiting for next
448+
* second, and the second just ticked since the check above, either
449+
*
450+
* 1) It ticked after the alarm was set, and an alarm irq should be
451+
* generated.
452+
*
453+
* 2) It ticked before the alarm was set, and alarm irq most likely will
454+
* not be generated.
455+
*
456+
* While we cannot easily check for which of these two scenarios we
457+
* are in, we can return -ETIME to signal that the timer has already
458+
* expired, which is true in both cases.
459+
*/
460+
if ((scheduled - now) <= 1) {
461+
err = __rtc_read_time(rtc, &tm);
462+
if (err)
463+
return err;
464+
now = rtc_tm_to_time64(&tm);
465+
if (scheduled <= now)
466+
return -ETIME;
467+
}
468+
446469
trace_rtc_set_alarm(rtc_tm_to_time64(&alarm->time), err);
447470
return err;
448471
}
@@ -594,6 +617,10 @@ int rtc_update_irq_enable(struct rtc_device *rtc, unsigned int enabled)
594617
rtc->uie_rtctimer.node.expires = ktime_add(now, onesec);
595618
rtc->uie_rtctimer.period = ktime_set(1, 0);
596619
err = rtc_timer_enqueue(rtc, &rtc->uie_rtctimer);
620+
if (!err && rtc->ops && rtc->ops->alarm_irq_enable)
621+
err = rtc->ops->alarm_irq_enable(rtc->dev.parent, 1);
622+
if (err)
623+
goto out;
597624
} else {
598625
rtc_timer_remove(rtc, &rtc->uie_rtctimer);
599626
}

drivers/rtc/rtc-amlogic-a4.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -72,13 +72,6 @@ struct aml_rtc_data {
7272
const struct aml_rtc_config *config;
7373
};
7474

75-
static const struct regmap_config aml_rtc_regmap_config = {
76-
.reg_bits = 32,
77-
.val_bits = 32,
78-
.reg_stride = 4,
79-
.max_register = RTC_REAL_TIME,
80-
};
81-
8275
static inline u32 gray_to_binary(u32 gray)
8376
{
8477
u32 bcd = gray;
@@ -328,6 +321,13 @@ static int aml_rtc_probe(struct platform_device *pdev)
328321
void __iomem *base;
329322
int ret = 0;
330323

324+
const struct regmap_config aml_rtc_regmap_config = {
325+
.reg_bits = 32,
326+
.val_bits = 32,
327+
.reg_stride = 4,
328+
.max_register = RTC_REAL_TIME,
329+
};
330+
331331
rtc = devm_kzalloc(dev, sizeof(*rtc), GFP_KERNEL);
332332
if (!rtc)
333333
return -ENOMEM;

0 commit comments

Comments
 (0)