Skip to content

Commit eadc4e4

Browse files
committed
Merge tag 'rtc-5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux
Pull RTC updates from Alexandre Belloni: "The VL_READ and VL_CLR ioctls have been reworked to be more useful. This will not break userspace as there are very few users and they are using the integer value as a boolean. Apart from that, two drivers were reworked and a few fixes here and there for a net reduction of number of lines. Summary: Subsystem: - the VL_READ and VL_CLR ioctls are now documented and their behavior is unified across all the drivers. - RTC_I2C_AND_SPI Kconfig option rework to avoid selecting both REGMAP_I2C and REGMAP_SPI unecessarily. Drivers: - at91rm9200: remove deprecated procfs, add sam9x60, sama5d4 and sama5d2 compatibles. - cmos: solve lost interrupts issue on MS Surface 3 - hym8563: return proper errno when time is invalid - rv3029: many fixes, nvram support" * tag 'rtc-5.6' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (63 commits) dt-bindings: rtc: at91rm9200: document clocks property rtc: i2c/spi: Avoid inclusion of REGMAP support when not needed rtc: Kconfig: select REGMAP_I2C when necessary rtc: Kconfig: properly indent sd3078 entry rtc: cmos: Refactor code by using the new dmi_get_bios_year() helper rtc: cmos: Use predefined value for RTC IRQ on legacy x86 rtc: cmos: Stop using shared IRQ rtc: tps6586x: Use IRQ_NOAUTOEN flag rtc: at91rm9200: use FIELD_PREP/FIELD_GET rtc: at91rm9200: avoid time readout in at91_rtc_setalarm rtc: at91rm9200: move register definitions to C file rtc: at91rm9200: add sama5d4 and sama5d2 compatibles dt-bindings: rtc: at91rm9200: convert bindings to json-schema rtc: at91rm9200: remove procfs information dt-bindings: atmel, at91rm9200-rtc: add microchip, sam9x60-rtc rtc: pcf8563: Use BIT rtc: moxart: Convert to SPDX identifier rtc: ds1343: Remove unused struct spi_device in struct ds1343_priv rtc: rx8025: Remove struct i2c_client from struct rx8025_data rtc: hym8563: Read the valid flag directly instead of caching it ...
2 parents 322bf2d + f457192 commit eadc4e4

29 files changed

Lines changed: 415 additions & 558 deletions

‎.mailmap‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ Aleksey Gorelov <aleksey_gorelov@phoenix.com>
1818
Aleksandar Markovic <aleksandar.markovic@mips.com> <aleksandar.markovic@imgtec.com>
1919
Alex Shi <alex.shi@linux.alibaba.com> <alex.shi@intel.com>
2020
Alex Shi <alex.shi@linux.alibaba.com> <alex.shi@linaro.org>
21+
Alexandre Belloni <alexandre.belloni@bootlin.com> <alexandre.belloni@free-electrons.com>
2122
Alexei Starovoitov <ast@kernel.org> <ast@plumgrid.com>
2223
Alexei Starovoitov <ast@kernel.org> <alexei.starovoitov@gmail.com>
2324
Alexei Starovoitov <ast@kernel.org> <ast@fb.com>

‎Documentation/ABI/testing/rtc-cdev‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,14 @@ Description:
3333
Requires a separate RTC_PIE_ON call to enable the periodic
3434
interrupts.
3535

36+
* RTC_VL_READ: Read the voltage inputs status of the RTC when
37+
supported. The value is a bit field of RTC_VL_*, giving the
38+
status of the main and backup voltages.
39+
40+
* RTC_VL_CLEAR: Clear the voltage status of the RTC. Some RTCs
41+
need user interaction when the backup power provider is
42+
replaced or charged to be able to clear the status.
43+
3644
The ioctl() calls supported by the older /dev/rtc interface are
3745
also supported by the newer RTC class framework. However,
3846
because the chips and systems are not standardized, some PC/AT

‎Documentation/devicetree/bindings/rtc/atmel,at91rm9200-rtc.txt‎

Lines changed: 0 additions & 17 deletions
This file was deleted.
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# SPDX-License-Identifier: GPL-2.0
2+
%YAML 1.2
3+
---
4+
$id: http://devicetree.org/schemas/rtc/atmel,at91rm9200-rtc.yaml#
5+
$schema: http://devicetree.org/meta-schemas/core.yaml#
6+
7+
title: Atmel AT91 RTC Device Tree Bindings
8+
9+
allOf:
10+
- $ref: "rtc.yaml#"
11+
12+
maintainers:
13+
- Alexandre Belloni <alexandre.belloni@bootlin.com>
14+
15+
properties:
16+
compatible:
17+
enum:
18+
- atmel,at91rm9200-rtc
19+
- atmel,at91sam9x5-rtc
20+
- atmel,sama5d4-rtc
21+
- atmel,sama5d2-rtc
22+
- microchip,sam9x60-rtc
23+
24+
reg:
25+
maxItems: 1
26+
27+
interrupts:
28+
maxItems: 1
29+
30+
clocks:
31+
maxItems: 1
32+
33+
required:
34+
- compatible
35+
- reg
36+
- interrupts
37+
- clocks
38+
39+
additionalProperties: false
40+
41+
examples:
42+
- |
43+
rtc@fffffe00 {
44+
compatible = "atmel,at91rm9200-rtc";
45+
reg = <0xfffffe00 0x100>;
46+
interrupts = <1 4 7>;
47+
clocks = <&clk32k>;
48+
};
49+
...

‎drivers/rtc/Kconfig‎

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ config RTC_DRV_AS3722
240240

241241
config RTC_DRV_DS1307
242242
tristate "Dallas/Maxim DS1307/37/38/39/40/41, ST M41T00, EPSON RX-8025, ISL12057"
243+
select REGMAP_I2C
243244
help
244245
If you say yes here you get support for various compatible RTC
245246
chips (often with battery backup) connected with I2C. This driver
@@ -622,6 +623,7 @@ config RTC_DRV_RX8010
622623

623624
config RTC_DRV_RX8581
624625
tristate "Epson RX-8571/RX-8581"
626+
select REGMAP_I2C
625627
help
626628
If you say yes here you will get support for the Epson RX-8571/
627629
RX-8581.
@@ -649,6 +651,7 @@ config RTC_DRV_EM3027
649651

650652
config RTC_DRV_RV3028
651653
tristate "Micro Crystal RV3028"
654+
select REGMAP_I2C
652655
help
653656
If you say yes here you get support for the Micro Crystal
654657
RV3028.
@@ -677,13 +680,14 @@ config RTC_DRV_S5M
677680
will be called rtc-s5m.
678681

679682
config RTC_DRV_SD3078
680-
tristate "ZXW Shenzhen whwave SD3078"
681-
help
682-
If you say yes here you get support for the ZXW Shenzhen whwave
683-
SD3078 RTC chips.
683+
tristate "ZXW Shenzhen whwave SD3078"
684+
select REGMAP_I2C
685+
help
686+
If you say yes here you get support for the ZXW Shenzhen whwave
687+
SD3078 RTC chips.
684688

685-
This driver can also be built as a module. If so, the module
686-
will be called rtc-sd3078
689+
This driver can also be built as a module. If so, the module
690+
will be called rtc-sd3078
687691

688692
endif # I2C
689693

@@ -849,14 +853,14 @@ config RTC_I2C_AND_SPI
849853
default m if I2C=m
850854
default y if I2C=y
851855
default y if SPI_MASTER=y
852-
select REGMAP_I2C if I2C
853-
select REGMAP_SPI if SPI_MASTER
854856

855857
comment "SPI and I2C RTC drivers"
856858

857859
config RTC_DRV_DS3232
858860
tristate "Dallas/Maxim DS3232/DS3234"
859861
depends on RTC_I2C_AND_SPI
862+
select REGMAP_I2C if I2C
863+
select REGMAP_SPI if SPI_MASTER
860864
help
861865
If you say yes here you get support for Dallas Semiconductor
862866
DS3232 and DS3234 real-time clock chips. If an interrupt is associated
@@ -876,6 +880,8 @@ config RTC_DRV_DS3232_HWMON
876880
config RTC_DRV_PCF2127
877881
tristate "NXP PCF2127"
878882
depends on RTC_I2C_AND_SPI
883+
select REGMAP_I2C if I2C
884+
select REGMAP_SPI if SPI_MASTER
879885
select WATCHDOG_CORE if WATCHDOG
880886
help
881887
If you say yes here you get support for the NXP PCF2127/29 RTC
@@ -892,6 +898,8 @@ config RTC_DRV_PCF2127
892898
config RTC_DRV_RV3029C2
893899
tristate "Micro Crystal RV3029/3049"
894900
depends on RTC_I2C_AND_SPI
901+
select REGMAP_I2C if I2C
902+
select REGMAP_SPI if SPI_MASTER
895903
help
896904
If you say yes here you get support for the Micro Crystal
897905
RV3029 and RV3049 RTC chips.

‎drivers/rtc/rtc-abx80x.c‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -523,12 +523,9 @@ static int abx80x_ioctl(struct device *dev, unsigned int cmd, unsigned long arg)
523523
if (status < 0)
524524
return status;
525525

526-
tmp = !!(status & ABX8XX_STATUS_BLF);
526+
tmp = status & ABX8XX_STATUS_BLF ? RTC_VL_BACKUP_LOW : 0;
527527

528-
if (copy_to_user((void __user *)arg, &tmp, sizeof(int)))
529-
return -EFAULT;
530-
531-
return 0;
528+
return put_user(tmp, (unsigned int __user *)arg);
532529

533530
case RTC_VL_CLR:
534531
status = i2c_smbus_read_byte_data(client, ABX8XX_REG_STATUS);

‎drivers/rtc/rtc-asm9260.c‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,9 @@ static int asm9260_rtc_probe(struct platform_device *pdev)
264264
return PTR_ERR(priv->iobase);
265265

266266
priv->clk = devm_clk_get(dev, "ahb");
267+
if (IS_ERR(priv->clk))
268+
return PTR_ERR(priv->clk);
269+
267270
ret = clk_prepare_enable(priv->clk);
268271
if (ret) {
269272
dev_err(dev, "Failed to enable clk!\n");

‎drivers/rtc/rtc-at91rm9200.c‎

Lines changed: 74 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
*/
1515

1616
#include <linux/bcd.h>
17+
#include <linux/bitfield.h>
1718
#include <linux/clk.h>
1819
#include <linux/completion.h>
1920
#include <linux/interrupt.h>
@@ -30,7 +31,51 @@
3031
#include <linux/time.h>
3132
#include <linux/uaccess.h>
3233

33-
#include "rtc-at91rm9200.h"
34+
#define AT91_RTC_CR 0x00 /* Control Register */
35+
#define AT91_RTC_UPDTIM BIT(0) /* Update Request Time Register */
36+
#define AT91_RTC_UPDCAL BIT(1) /* Update Request Calendar Register */
37+
38+
#define AT91_RTC_MR 0x04 /* Mode Register */
39+
40+
#define AT91_RTC_TIMR 0x08 /* Time Register */
41+
#define AT91_RTC_SEC GENMASK(6, 0) /* Current Second */
42+
#define AT91_RTC_MIN GENMASK(14, 8) /* Current Minute */
43+
#define AT91_RTC_HOUR GENMASK(21, 16) /* Current Hour */
44+
#define AT91_RTC_AMPM BIT(22) /* Ante Meridiem Post Meridiem Indicator */
45+
46+
#define AT91_RTC_CALR 0x0c /* Calendar Register */
47+
#define AT91_RTC_CENT GENMASK(6, 0) /* Current Century */
48+
#define AT91_RTC_YEAR GENMASK(15, 8) /* Current Year */
49+
#define AT91_RTC_MONTH GENMASK(20, 16) /* Current Month */
50+
#define AT91_RTC_DAY GENMASK(23, 21) /* Current Day */
51+
#define AT91_RTC_DATE GENMASK(29, 24) /* Current Date */
52+
53+
#define AT91_RTC_TIMALR 0x10 /* Time Alarm Register */
54+
#define AT91_RTC_SECEN BIT(7) /* Second Alarm Enable */
55+
#define AT91_RTC_MINEN BIT(15) /* Minute Alarm Enable */
56+
#define AT91_RTC_HOUREN BIT(23) /* Hour Alarm Enable */
57+
58+
#define AT91_RTC_CALALR 0x14 /* Calendar Alarm Register */
59+
#define AT91_RTC_MTHEN BIT(23) /* Month Alarm Enable */
60+
#define AT91_RTC_DATEEN BIT(31) /* Date Alarm Enable */
61+
62+
#define AT91_RTC_SR 0x18 /* Status Register */
63+
#define AT91_RTC_ACKUPD BIT(0) /* Acknowledge for Update */
64+
#define AT91_RTC_ALARM BIT(1) /* Alarm Flag */
65+
#define AT91_RTC_SECEV BIT(2) /* Second Event */
66+
#define AT91_RTC_TIMEV BIT(3) /* Time Event */
67+
#define AT91_RTC_CALEV BIT(4) /* Calendar Event */
68+
69+
#define AT91_RTC_SCCR 0x1c /* Status Clear Command Register */
70+
#define AT91_RTC_IER 0x20 /* Interrupt Enable Register */
71+
#define AT91_RTC_IDR 0x24 /* Interrupt Disable Register */
72+
#define AT91_RTC_IMR 0x28 /* Interrupt Mask Register */
73+
74+
#define AT91_RTC_VER 0x2c /* Valid Entry Register */
75+
#define AT91_RTC_NVTIM BIT(0) /* Non valid Time */
76+
#define AT91_RTC_NVCAL BIT(1) /* Non valid Calendar */
77+
#define AT91_RTC_NVTIMALR BIT(2) /* Non valid Time Alarm */
78+
#define AT91_RTC_NVCALALR BIT(3) /* Non valid Calendar Alarm */
3479

3580
#define at91_rtc_read(field) \
3681
readl_relaxed(at91_rtc_regs + field)
@@ -117,20 +162,20 @@ static void at91_rtc_decodetime(unsigned int timereg, unsigned int calreg,
117162
} while ((time != at91_rtc_read(timereg)) ||
118163
(date != at91_rtc_read(calreg)));
119164

120-
tm->tm_sec = bcd2bin((time & AT91_RTC_SEC) >> 0);
121-
tm->tm_min = bcd2bin((time & AT91_RTC_MIN) >> 8);
122-
tm->tm_hour = bcd2bin((time & AT91_RTC_HOUR) >> 16);
165+
tm->tm_sec = bcd2bin(FIELD_GET(AT91_RTC_SEC, time));
166+
tm->tm_min = bcd2bin(FIELD_GET(AT91_RTC_MIN, time));
167+
tm->tm_hour = bcd2bin(FIELD_GET(AT91_RTC_HOUR, time));
123168

124169
/*
125170
* The Calendar Alarm register does not have a field for
126171
* the year - so these will return an invalid value.
127172
*/
128173
tm->tm_year = bcd2bin(date & AT91_RTC_CENT) * 100; /* century */
129-
tm->tm_year += bcd2bin((date & AT91_RTC_YEAR) >> 8); /* year */
174+
tm->tm_year += bcd2bin(FIELD_GET(AT91_RTC_YEAR, date)); /* year */
130175

131-
tm->tm_wday = bcd2bin((date & AT91_RTC_DAY) >> 21) - 1; /* day of the week [0-6], Sunday=0 */
132-
tm->tm_mon = bcd2bin((date & AT91_RTC_MONTH) >> 16) - 1;
133-
tm->tm_mday = bcd2bin((date & AT91_RTC_DATE) >> 24);
176+
tm->tm_wday = bcd2bin(FIELD_GET(AT91_RTC_DAY, date)) - 1; /* day of the week [0-6], Sunday=0 */
177+
tm->tm_mon = bcd2bin(FIELD_GET(AT91_RTC_MONTH, date)) - 1;
178+
tm->tm_mday = bcd2bin(FIELD_GET(AT91_RTC_DATE, date));
134179
}
135180

136181
/*
@@ -167,16 +212,17 @@ static int at91_rtc_settime(struct device *dev, struct rtc_time *tm)
167212
at91_rtc_write_idr(AT91_RTC_ACKUPD);
168213

169214
at91_rtc_write(AT91_RTC_TIMR,
170-
bin2bcd(tm->tm_sec) << 0
171-
| bin2bcd(tm->tm_min) << 8
172-
| bin2bcd(tm->tm_hour) << 16);
215+
FIELD_PREP(AT91_RTC_SEC, bin2bcd(tm->tm_sec))
216+
| FIELD_PREP(AT91_RTC_MIN, bin2bcd(tm->tm_min))
217+
| FIELD_PREP(AT91_RTC_HOUR, bin2bcd(tm->tm_hour)));
173218

174219
at91_rtc_write(AT91_RTC_CALR,
175-
bin2bcd((tm->tm_year + 1900) / 100) /* century */
176-
| bin2bcd(tm->tm_year % 100) << 8 /* year */
177-
| bin2bcd(tm->tm_mon + 1) << 16 /* tm_mon starts at zero */
178-
| bin2bcd(tm->tm_wday + 1) << 21 /* day of the week [0-6], Sunday=0 */
179-
| bin2bcd(tm->tm_mday) << 24);
220+
FIELD_PREP(AT91_RTC_CENT,
221+
bin2bcd((tm->tm_year + 1900) / 100))
222+
| FIELD_PREP(AT91_RTC_YEAR, bin2bcd(tm->tm_year % 100))
223+
| FIELD_PREP(AT91_RTC_MONTH, bin2bcd(tm->tm_mon + 1))
224+
| FIELD_PREP(AT91_RTC_DAY, bin2bcd(tm->tm_wday + 1))
225+
| FIELD_PREP(AT91_RTC_DATE, bin2bcd(tm->tm_mday)));
180226

181227
/* Restart Time/Calendar */
182228
cr = at91_rtc_read(AT91_RTC_CR);
@@ -211,25 +257,17 @@ static int at91_rtc_readalarm(struct device *dev, struct rtc_wkalrm *alrm)
211257
*/
212258
static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm)
213259
{
214-
struct rtc_time tm;
215-
216-
at91_rtc_decodetime(AT91_RTC_TIMR, AT91_RTC_CALR, &tm);
217-
218-
tm.tm_mon = alrm->time.tm_mon;
219-
tm.tm_mday = alrm->time.tm_mday;
220-
tm.tm_hour = alrm->time.tm_hour;
221-
tm.tm_min = alrm->time.tm_min;
222-
tm.tm_sec = alrm->time.tm_sec;
260+
struct rtc_time tm = alrm->time;
223261

224262
at91_rtc_write_idr(AT91_RTC_ALARM);
225263
at91_rtc_write(AT91_RTC_TIMALR,
226-
bin2bcd(tm.tm_sec) << 0
227-
| bin2bcd(tm.tm_min) << 8
228-
| bin2bcd(tm.tm_hour) << 16
264+
FIELD_PREP(AT91_RTC_SEC, bin2bcd(alrm->time.tm_sec))
265+
| FIELD_PREP(AT91_RTC_MIN, bin2bcd(alrm->time.tm_min))
266+
| FIELD_PREP(AT91_RTC_HOUR, bin2bcd(alrm->time.tm_hour))
229267
| AT91_RTC_HOUREN | AT91_RTC_MINEN | AT91_RTC_SECEN);
230268
at91_rtc_write(AT91_RTC_CALALR,
231-
bin2bcd(tm.tm_mon + 1) << 16 /* tm_mon starts at zero */
232-
| bin2bcd(tm.tm_mday) << 24
269+
FIELD_PREP(AT91_RTC_MONTH, bin2bcd(alrm->time.tm_mon + 1))
270+
| FIELD_PREP(AT91_RTC_DATE, bin2bcd(alrm->time.tm_mday))
233271
| AT91_RTC_DATEEN | AT91_RTC_MTHEN);
234272

235273
if (alrm->enabled) {
@@ -254,20 +292,6 @@ static int at91_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled)
254292

255293
return 0;
256294
}
257-
/*
258-
* Provide additional RTC information in /proc/driver/rtc
259-
*/
260-
static int at91_rtc_proc(struct device *dev, struct seq_file *seq)
261-
{
262-
unsigned long imr = at91_rtc_read_imr();
263-
264-
seq_printf(seq, "update_IRQ\t: %s\n",
265-
(imr & AT91_RTC_ACKUPD) ? "yes" : "no");
266-
seq_printf(seq, "periodic_IRQ\t: %s\n",
267-
(imr & AT91_RTC_SECEV) ? "yes" : "no");
268-
269-
return 0;
270-
}
271295

272296
/*
273297
* IRQ handler for the RTC
@@ -326,6 +350,12 @@ static const struct of_device_id at91_rtc_dt_ids[] = {
326350
}, {
327351
.compatible = "atmel,at91sam9x5-rtc",
328352
.data = &at91sam9x5_config,
353+
}, {
354+
.compatible = "atmel,sama5d4-rtc",
355+
.data = &at91rm9200_config,
356+
}, {
357+
.compatible = "atmel,sama5d2-rtc",
358+
.data = &at91rm9200_config,
329359
}, {
330360
/* sentinel */
331361
}
@@ -337,7 +367,6 @@ static const struct rtc_class_ops at91_rtc_ops = {
337367
.set_time = at91_rtc_settime,
338368
.read_alarm = at91_rtc_readalarm,
339369
.set_alarm = at91_rtc_setalarm,
340-
.proc = at91_rtc_proc,
341370
.alarm_irq_enable = at91_rtc_alarm_irq_enable,
342371
};
343372

0 commit comments

Comments
 (0)