Skip to content

Commit

Permalink
Merge tag 'rtc-6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/…
Browse files Browse the repository at this point in the history
…abelloni/linux

Pull RTC updates from Alexandre Belloni:
 "Subsystem:

   - Add a way for drivers to tell the core the supported alarm range is
     smaller than the date range. This is not used yet but will be
     useful for the alarmtimers in the next release.

   - fix Wvoid-pointer-to-enum-cast warnings

   - remove redundant of_match_ptr()

   - stop warning for invalid alarms when the alarm is disabled

  Drivers:

   - isl12022: allow setting the trip level for battery level detection

   - pcf2127: add support for PCF2131 and multiple timestamps

   - stm32: time precision improvement, many fixes

   - twl: NVRAM support"

* tag 'rtc-6.6' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (73 commits)
  dt-bindings: rtc: ds3231: Remove text binding
  rtc: wm8350: remove unnecessary messages
  rtc: twl: remove unnecessary messages
  rtc: sun6i: remove unnecessary message
  rtc: stop warning for invalid alarms when the alarm is disabled
  rtc: twl: add NVRAM support
  rtc: pcf85363: Allow to wake up system without IRQ
  rtc: m48t86: add DT support for m48t86
  dt-bindings: rtc: Add ST M48T86
  rtc: pcf2127: remove useless check
  rtc: rzn1: Report maximum alarm limit to rtc core
  rtc: ds1305: Report maximum alarm limit to rtc core
  rtc: tps6586x: Report maximum alarm limit to rtc core
  rtc: cmos: Report supported alarm limit to rtc infrastructure
  rtc: cros-ec: Detect and report supported alarm window size
  rtc: Add support for limited alarm timer offsets
  rtc: isl1208: Fix incorrect logic in isl1208_set_xtoscb()
  MAINTAINERS: remove obsolete pattern in RTC SUBSYSTEM section
  rtc: tps65910: Remove redundant dev_warn() and do not check for 0 return after calling platform_get_irq()
  rtc: omap: Do not check for 0 return after calling platform_get_irq()
  ...
  • Loading branch information
Linus Torvalds committed Sep 7, 2023
2 parents e59a698 + ce41348 commit ff6e6de
Show file tree
Hide file tree
Showing 59 changed files with 1,334 additions and 616 deletions.
18 changes: 11 additions & 7 deletions Documentation/devicetree/bindings/rtc/atmel,at91rm9200-rtc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,17 @@ maintainers:

properties:
compatible:
enum:
- atmel,at91rm9200-rtc
- atmel,at91sam9x5-rtc
- atmel,sama5d4-rtc
- atmel,sama5d2-rtc
- microchip,sam9x60-rtc
- microchip,sama7g5-rtc
oneOf:
- enum:
- atmel,at91rm9200-rtc
- atmel,at91sam9x5-rtc
- atmel,sama5d4-rtc
- atmel,sama5d2-rtc
- microchip,sam9x60-rtc
- microchip,sama7g5-rtc
- items:
- const: microchip,sam9x7-rtc
- const: microchip,sam9x60-rtc

reg:
maxItems: 1
Expand Down
64 changes: 64 additions & 0 deletions Documentation/devicetree/bindings/rtc/intersil,isl12022.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
# SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause
%YAML 1.2
---
$id: http://devicetree.org/schemas/rtc/intersil,isl12022.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: Intersil ISL12022 Real-time Clock

maintainers:
- Alexandre Belloni <alexandre.belloni@bootlin.com>

properties:
compatible:
const: isil,isl12022

reg:
maxItems: 1

interrupts:
maxItems: 1

'#clock-cells':
const: 0

isil,battery-trip-levels-microvolt:
description:
The battery voltages at which the first alarm and second alarm
should trigger (normally ~85% and ~75% of nominal V_BAT).
items:
- enum: [2125000, 2295000, 2550000, 2805000, 3060000, 4250000, 4675000]
- enum: [1875000, 2025000, 2250000, 2475000, 2700000, 3750000, 4125000]

required:
- compatible
- reg

allOf:
- $ref: rtc.yaml#
# If #clock-cells is present, interrupts must not be present
- if:
required:
- '#clock-cells'
then:
properties:
interrupts: false

unevaluatedProperties: false

examples:
- |
#include <dt-bindings/interrupt-controller/irq.h>
i2c {
#address-cells = <1>;
#size-cells = <0>;
rtc@6f {
compatible = "isil,isl12022";
reg = <0x6f>;
interrupts-extended = <&gpio1 5 IRQ_TYPE_LEVEL_LOW>;
isil,battery-trip-levels-microvolt = <2550000>, <2250000>;
};
};
...
38 changes: 0 additions & 38 deletions Documentation/devicetree/bindings/rtc/maxim,ds3231.txt

This file was deleted.

1 change: 1 addition & 0 deletions Documentation/devicetree/bindings/rtc/nxp,pcf2127.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ properties:
- nxp,pca2129
- nxp,pcf2127
- nxp,pcf2129
- nxp,pcf2131

reg:
maxItems: 1
Expand Down
38 changes: 38 additions & 0 deletions Documentation/devicetree/bindings/rtc/st,m48t86.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause)
%YAML 1.2
---
$id: http://devicetree.org/schemas/rtc/st,m48t86.yaml#
$schema: http://devicetree.org/meta-schemas/core.yaml#

title: ST M48T86 / Dallas DS12887 RTC with SRAM

maintainers:
- Alexandre Belloni <alexandre.belloni@bootlin.com>

allOf:
- $ref: rtc.yaml

properties:
compatible:
enum:
- st,m48t86

reg:
items:
- description: index register
- description: data register

required:
- compatible
- reg

unevaluatedProperties: false

examples:
- |
rtc@10800000 {
compatible = "st,m48t86";
reg = <0x10800000 0x1>, <0x11700000 0x1>;
};
...
2 changes: 0 additions & 2 deletions Documentation/devicetree/bindings/rtc/trivial-rtc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,6 @@ properties:
- isil,isl1208
# Intersil ISL1218 Low Power RTC with Battery Backed SRAM
- isil,isl1218
# Intersil ISL12022 Real-time Clock
- isil,isl12022
# Real Time Clock Module with I2C-Bus
- microcrystal,rv3029
# Real Time Clock
Expand Down
1 change: 0 additions & 1 deletion MAINTAINERS
Original file line number Diff line number Diff line change
Expand Up @@ -18084,7 +18084,6 @@ T: git git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux.git
F: Documentation/admin-guide/rtc.rst
F: Documentation/devicetree/bindings/rtc/
F: drivers/rtc/
F: include/linux/platform_data/rtc-*
F: include/linux/rtc.h
F: include/linux/rtc/
F: include/uapi/linux/rtc.h
Expand Down
5 changes: 3 additions & 2 deletions drivers/rtc/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -904,9 +904,9 @@ config RTC_DRV_PCF2127
select REGMAP_SPI if SPI_MASTER
select WATCHDOG_CORE if WATCHDOG
help
If you say yes here you get support for the NXP PCF2127/29 RTC
If you say yes here you get support for the NXP PCF2127/29/31 RTC
chips with integrated quartz crystal for industrial applications.
Both chips also have watchdog timer and tamper switch detection
These chips also have watchdog timer and tamper switch detection
features.

PCF2127 has an additional feature of 512 bytes battery backed
Expand Down Expand Up @@ -1196,6 +1196,7 @@ config RTC_DRV_MSM6242
config RTC_DRV_BQ4802
tristate "TI BQ4802"
depends on HAS_IOMEM && HAS_IOPORT
depends on SPARC || COMPILE_TEST
help
If you say Y here you will get support for the TI
BQ4802 RTC chip.
Expand Down
2 changes: 1 addition & 1 deletion drivers/rtc/interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm)
err = rtc_valid_tm(&alarm->time);

done:
if (err)
if (err && alarm->enabled)
dev_warn(&rtc->dev, "invalid alarm value: %ptR\n",
&alarm->time);

Expand Down
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-abx80x.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <linux/i2c.h>
#include <linux/kstrtox.h>
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/of.h>
#include <linux/rtc.h>
#include <linux/watchdog.h>

Expand Down
5 changes: 1 addition & 4 deletions drivers/rtc/rtc-armada38x.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#include <linux/io.h>
#include <linux/module.h>
#include <linux/of.h>
#include <linux/of_device.h>
#include <linux/platform_device.h>
#include <linux/rtc.h>

Expand Down Expand Up @@ -474,7 +473,6 @@ static const struct armada38x_rtc_data armada8k_data = {
.alarm = ALARM2,
};

#ifdef CONFIG_OF
static const struct of_device_id armada38x_rtc_of_match_table[] = {
{
.compatible = "marvell,armada-380-rtc",
Expand All @@ -487,7 +485,6 @@ static const struct of_device_id armada38x_rtc_of_match_table[] = {
{}
};
MODULE_DEVICE_TABLE(of, armada38x_rtc_of_match_table);
#endif

static __init int armada38x_rtc_probe(struct platform_device *pdev)
{
Expand Down Expand Up @@ -577,7 +574,7 @@ static struct platform_driver armada38x_rtc_driver = {
.driver = {
.name = "armada38x-rtc",
.pm = &armada38x_rtc_pm_ops,
.of_match_table = of_match_ptr(armada38x_rtc_of_match_table),
.of_match_table = armada38x_rtc_of_match_table,
},
};

Expand Down
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-aspeed.c
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ MODULE_DEVICE_TABLE(of, aspeed_rtc_match);
static struct platform_driver aspeed_rtc_driver = {
.driver = {
.name = "aspeed-rtc",
.of_match_table = of_match_ptr(aspeed_rtc_match),
.of_match_table = aspeed_rtc_match,
},
};

Expand Down
3 changes: 1 addition & 2 deletions drivers/rtc/rtc-at91rm9200.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <linux/io.h>
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/of_device.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/rtc.h>
Expand Down Expand Up @@ -642,7 +641,7 @@ static struct platform_driver at91_rtc_driver = {
.driver = {
.name = "at91_rtc",
.pm = &at91_rtc_pm_ops,
.of_match_table = of_match_ptr(at91_rtc_dt_ids),
.of_match_table = at91_rtc_dt_ids,
},
};

Expand Down
2 changes: 1 addition & 1 deletion drivers/rtc/rtc-at91sam9.c
Original file line number Diff line number Diff line change
Expand Up @@ -534,7 +534,7 @@ static struct platform_driver at91_rtc_driver = {
.driver = {
.name = "rtc-at91sam9",
.pm = &at91_rtc_pm_ops,
.of_match_table = of_match_ptr(at91_rtc_dt_ids),
.of_match_table = at91_rtc_dt_ids,
},
};

Expand Down
11 changes: 11 additions & 0 deletions drivers/rtc/rtc-cmos.c
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,10 @@ static inline void cmos_check_acpi_rtc_status(struct device *dev,
#define INITSECTION __init
#endif

#define SECS_PER_DAY (24 * 60 * 60)
#define SECS_PER_MONTH (28 * SECS_PER_DAY)
#define SECS_PER_YEAR (365 * SECS_PER_DAY)

static int INITSECTION
cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
{
Expand Down Expand Up @@ -1019,6 +1023,13 @@ cmos_do_probe(struct device *dev, struct resource *ports, int rtc_irq)
goto cleanup0;
}

if (cmos_rtc.mon_alrm)
cmos_rtc.rtc->alarm_offset_max = SECS_PER_YEAR - 1;
else if (cmos_rtc.day_alrm)
cmos_rtc.rtc->alarm_offset_max = SECS_PER_MONTH - 1;
else
cmos_rtc.rtc->alarm_offset_max = SECS_PER_DAY - 1;

rename_region(ports, dev_name(&cmos_rtc.rtc->dev));

if (!mc146818_does_rtc_work()) {
Expand Down
38 changes: 23 additions & 15 deletions drivers/rtc/rtc-cros-ec.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,21 +182,15 @@ static int cros_ec_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm)

ret = cros_ec_rtc_set(cros_ec, EC_CMD_RTC_SET_ALARM, alarm_offset);
if (ret < 0) {
if (ret == -EINVAL && alarm_offset >= SECS_PER_DAY) {
/*
* RTC chips on some older Chromebooks can only handle
* alarms up to 24h in the future. Try to set an alarm
* below that limit to avoid suspend failures.
*/
ret = cros_ec_rtc_set(cros_ec, EC_CMD_RTC_SET_ALARM,
SECS_PER_DAY - 1);
}

if (ret < 0) {
dev_err(dev, "error setting alarm in %u seconds: %d\n",
alarm_offset, ret);
return ret;
}
dev_err(dev, "error setting alarm in %u seconds: %d\n",
alarm_offset, ret);
/*
* The EC code returns -EINVAL if the alarm time is too
* far in the future. Convert it to the expected error code.
*/
if (ret == -EINVAL)
ret = -ERANGE;
return ret;
}

return 0;
Expand Down Expand Up @@ -355,6 +349,20 @@ static int cros_ec_rtc_probe(struct platform_device *pdev)
cros_ec_rtc->rtc->ops = &cros_ec_rtc_ops;
cros_ec_rtc->rtc->range_max = U32_MAX;

/*
* The RTC on some older Chromebooks can only handle alarms less than
* 24 hours in the future. The only way to find out is to try to set an
* alarm further in the future. If that fails, assume that the RTC
* connected to the EC can only handle less than 24 hours of alarm
* window.
*/
ret = cros_ec_rtc_set(cros_ec, EC_CMD_RTC_SET_ALARM, SECS_PER_DAY * 2);
if (ret == -EINVAL)
cros_ec_rtc->rtc->alarm_offset_max = SECS_PER_DAY - 1;

(void)cros_ec_rtc_set(cros_ec, EC_CMD_RTC_SET_ALARM,
EC_RTC_ALARM_CLEAR);

ret = devm_rtc_register_device(cros_ec_rtc->rtc);
if (ret)
return ret;
Expand Down
7 changes: 7 additions & 0 deletions drivers/rtc/rtc-da9063.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <linux/module.h>
#include <linux/of.h>
#include <linux/platform_device.h>
#include <linux/pm_wakeirq.h>
#include <linux/regmap.h>
#include <linux/rtc.h>
#include <linux/slab.h>
Expand Down Expand Up @@ -496,6 +497,12 @@ static int da9063_rtc_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "Failed to request ALARM IRQ %d: %d\n",
irq_alarm, ret);

ret = dev_pm_set_wake_irq(&pdev->dev, irq_alarm);
if (ret)
dev_warn(&pdev->dev,
"Failed to set IRQ %d as a wake IRQ: %d\n",
irq_alarm, ret);

device_init_wakeup(&pdev->dev, true);

return devm_rtc_register_device(rtc->rtc_dev);
Expand Down
Loading

0 comments on commit ff6e6de

Please sign in to comment.