Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'rtc-6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux

Pull RTC updates from Alexandre Belloni:
"Subsytem:
- rtc_class is now const

Drivers:
- ds1511: cleanup, set date and time range and alarm offset limit
- max31335: fix interrupt handler
- pcf8523: improve suspend support"

* tag 'rtc-6.9' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (28 commits)
MAINTAINER: Include linux-arm-msm for Qualcomm RTC patches
dt-bindings: rtc: zynqmp: Add support for Versal/Versal NET SoCs
rtc: class: make rtc_class constant
dt-bindings: rtc: abx80x: Improve checks on trickle charger constraints
MAINTAINERS: adjust file entry in ARM/Mediatek RTC DRIVER
rtc: nct3018y: fix possible NULL dereference
rtc: max31335: fix interrupt status reg
rtc: mt6397: select IRQ_DOMAIN instead of depending on it
dt-bindings: rtc: abx80x: convert to yaml
rtc: m41t80: Use the unified property API get the wakeup-source property
dt-bindings: at91rm9260-rtt: add sam9x7 compatible
dt-bindings: rtc: convert MT7622 RTC to the json-schema
dt-bindings: rtc: convert MT2717 RTC to the json-schema
rtc: pcf8523: add suspend handlers for alarm IRQ
rtc: ds1511: set alarm offset limit
rtc: ds1511: set range
rtc: ds1511: drop inline/noinline hints
rtc: ds1511: rename pdata
rtc: ds1511: implement ds1511_rtc_read_alarm properly
rtc: ds1511: remove partial alarm support
...

+359 -328
-31
Documentation/devicetree/bindings/rtc/abracon,abx80x.txt
··· 1 - Abracon ABX80X I2C ultra low power RTC/Alarm chip 2 - 3 - The Abracon ABX80X family consist of the ab0801, ab0803, ab0804, ab0805, ab1801, 4 - ab1803, ab1804 and ab1805. The ab0805 is the superset of ab080x and the ab1805 5 - is the superset of ab180x. 6 - 7 - Required properties: 8 - 9 - - "compatible": should one of: 10 - "abracon,abx80x" 11 - "abracon,ab0801" 12 - "abracon,ab0803" 13 - "abracon,ab0804" 14 - "abracon,ab0805" 15 - "abracon,ab1801" 16 - "abracon,ab1803" 17 - "abracon,ab1804" 18 - "abracon,ab1805" 19 - "microcrystal,rv1805" 20 - Using "abracon,abx80x" will enable chip autodetection. 21 - - "reg": I2C bus address of the device 22 - 23 - Optional properties: 24 - 25 - The abx804 and abx805 have a trickle charger that is able to charge the 26 - connected battery or supercap. Both the following properties have to be defined 27 - and valid to enable charging: 28 - 29 - - "abracon,tc-diode": should be "standard" (0.6V) or "schottky" (0.3V) 30 - - "abracon,tc-resistor": should be <0>, <3>, <6> or <11>. 0 disables the output 31 - resistor, the other values are in kOhm.
+98
Documentation/devicetree/bindings/rtc/abracon,abx80x.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/rtc/abracon,abx80x.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Abracon ABX80X I2C ultra low power RTC/Alarm chip 8 + 9 + maintainers: 10 + - linux-rtc@vger.kernel.org 11 + 12 + properties: 13 + compatible: 14 + description: 15 + The wildcard 'abracon,abx80x' may be used to support a mix 16 + of different abracon rtc`s. In this case the driver 17 + must perform auto-detection from ID register. 18 + enum: 19 + - abracon,abx80x 20 + - abracon,ab0801 21 + - abracon,ab0803 22 + - abracon,ab0804 23 + - abracon,ab0805 24 + - abracon,ab1801 25 + - abracon,ab1803 26 + - abracon,ab1804 27 + - abracon,ab1805 28 + - microcrystal,rv1805 29 + 30 + reg: 31 + maxItems: 1 32 + 33 + interrupts: 34 + maxItems: 1 35 + 36 + abracon,tc-diode: 37 + description: 38 + Trickle-charge diode type. 39 + Required to enable charging backup battery. 40 + 41 + Supported are 'standard' diodes with a 0.6V drop 42 + and 'schottky' diodes with a 0.3V drop. 43 + $ref: /schemas/types.yaml#/definitions/string 44 + enum: 45 + - standard 46 + - schottky 47 + 48 + abracon,tc-resistor: 49 + description: 50 + Trickle-charge resistor value in kOhm. 51 + Required to enable charging backup battery. 52 + $ref: /schemas/types.yaml#/definitions/uint32 53 + enum: [0, 3, 6, 11] 54 + 55 + dependentRequired: 56 + abracon,tc-diode: ["abracon,tc-resistor"] 57 + abracon,tc-resistor: ["abracon,tc-diode"] 58 + 59 + required: 60 + - compatible 61 + - reg 62 + 63 + allOf: 64 + - $ref: rtc.yaml# 65 + - if: 66 + properties: 67 + compatible: 68 + not: 69 + contains: 70 + enum: 71 + - abracon,abx80x 72 + - abracon,ab0804 73 + - abracon,ab1804 74 + - abracon,ab0805 75 + - abracon,ab1805 76 + then: 77 + properties: 78 + abracon,tc-diode: false 79 + abracon,tc-resistor: false 80 + 81 + unevaluatedProperties: false 82 + 83 + examples: 84 + - | 85 + #include <dt-bindings/interrupt-controller/irq.h> 86 + 87 + i2c { 88 + #address-cells = <1>; 89 + #size-cells = <0>; 90 + 91 + rtc@69 { 92 + compatible = "abracon,abx80x"; 93 + reg = <0x69>; 94 + abracon,tc-diode = "schottky"; 95 + abracon,tc-resistor = <3>; 96 + interrupts = <44 IRQ_TYPE_EDGE_FALLING>; 97 + }; 98 + };
+3 -1
Documentation/devicetree/bindings/rtc/atmel,at91sam9260-rtt.yaml
··· 19 19 - items: 20 20 - const: atmel,at91sam9260-rtt 21 21 - items: 22 - - const: microchip,sam9x60-rtt 22 + - enum: 23 + - microchip,sam9x60-rtt 24 + - microchip,sam9x7-rtt 23 25 - const: atmel,at91sam9260-rtt 24 26 - items: 25 27 - const: microchip,sama7g5-rtt
+39
Documentation/devicetree/bindings/rtc/mediatek,mt2712-rtc.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/rtc/mediatek,mt2712-rtc.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: MediaTek MT2712 on-SoC RTC 8 + 9 + allOf: 10 + - $ref: rtc.yaml# 11 + 12 + maintainers: 13 + - Ran Bi <ran.bi@mediatek.com> 14 + 15 + properties: 16 + compatible: 17 + const: mediatek,mt2712-rtc 18 + 19 + reg: 20 + maxItems: 1 21 + 22 + interrupts: 23 + maxItems: 1 24 + 25 + required: 26 + - reg 27 + - interrupts 28 + 29 + unevaluatedProperties: false 30 + 31 + examples: 32 + - | 33 + #include <dt-bindings/interrupt-controller/arm-gic.h> 34 + 35 + rtc@10011000 { 36 + compatible = "mediatek,mt2712-rtc"; 37 + reg = <0x10011000 0x1000>; 38 + interrupts = <GIC_SPI 239 IRQ_TYPE_LEVEL_LOW>; 39 + };
+52
Documentation/devicetree/bindings/rtc/mediatek,mt7622-rtc.yaml
··· 1 + # SPDX-License-Identifier: GPL-2.0-only OR BSD-2-Clause 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/rtc/mediatek,mt7622-rtc.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: MediaTek MT7622 on-SoC RTC 8 + 9 + allOf: 10 + - $ref: rtc.yaml# 11 + 12 + maintainers: 13 + - Sean Wang <sean.wang@mediatek.com> 14 + 15 + properties: 16 + compatible: 17 + items: 18 + - const: mediatek,mt7622-rtc 19 + - const: mediatek,soc-rtc 20 + 21 + reg: 22 + maxItems: 1 23 + 24 + interrupts: 25 + maxItems: 1 26 + 27 + clocks: 28 + maxItems: 1 29 + 30 + clock-names: 31 + const: rtc 32 + 33 + required: 34 + - reg 35 + - interrupts 36 + - clocks 37 + - clock-names 38 + 39 + unevaluatedProperties: false 40 + 41 + examples: 42 + - | 43 + #include <dt-bindings/clock/mt7622-clk.h> 44 + #include <dt-bindings/interrupt-controller/arm-gic.h> 45 + 46 + rtc@10212800 { 47 + compatible = "mediatek,mt7622-rtc", "mediatek,soc-rtc"; 48 + reg = <0x10212800 0x200>; 49 + interrupts = <GIC_SPI 129 IRQ_TYPE_LEVEL_LOW>; 50 + clocks = <&topckgen CLK_TOP_RTC>; 51 + clock-names = "rtc"; 52 + };
-14
Documentation/devicetree/bindings/rtc/rtc-mt2712.txt
··· 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 - };
-21
Documentation/devicetree/bindings/rtc/rtc-mt7622.txt
··· 1 - Device-Tree bindings for MediaTek SoC based RTC 2 - 3 - Required properties: 4 - - compatible : Should be 5 - "mediatek,mt7622-rtc", "mediatek,soc-rtc" : for MT7622 SoC 6 - - reg : Specifies base physical address and size of the registers; 7 - - interrupts : Should contain the interrupt for RTC alarm; 8 - - clocks : Specifies list of clock specifiers, corresponding to 9 - entries in clock-names property; 10 - - clock-names : Should contain "rtc" entries 11 - 12 - Example: 13 - 14 - rtc: rtc@10212800 { 15 - compatible = "mediatek,mt7622-rtc", 16 - "mediatek,soc-rtc"; 17 - reg = <0 0x10212800 0 0x200>; 18 - interrupts = <GIC_SPI 129 IRQ_TYPE_LEVEL_LOW>; 19 - clocks = <&topckgen CLK_TOP_RTC>; 20 - clock-names = "rtc"; 21 - };
+10 -1
Documentation/devicetree/bindings/rtc/xlnx,zynqmp-rtc.yaml
··· 18 18 19 19 properties: 20 20 compatible: 21 - const: xlnx,zynqmp-rtc 21 + oneOf: 22 + - const: xlnx,zynqmp-rtc 23 + - items: 24 + - enum: 25 + - xlnx,versal-rtc 26 + - xlnx,versal-net-rtc 27 + - const: xlnx,zynqmp-rtc 22 28 23 29 reg: 24 30 maxItems: 1 ··· 53 47 maximum: 0x1FFFFF 54 48 default: 0x198233 55 49 deprecated: true 50 + 51 + power-domains: 52 + maxItems: 1 56 53 57 54 required: 58 55 - compatible
+3 -2
MAINTAINERS
··· 2377 2377 L: linux-arm-kernel@lists.infradead.org (moderated for non-subscribers) 2378 2378 L: linux-mediatek@lists.infradead.org (moderated for non-subscribers) 2379 2379 S: Maintained 2380 - F: Documentation/devicetree/bindings/rtc/rtc-mt2712.txt 2381 - F: Documentation/devicetree/bindings/rtc/rtc-mt7622.txt 2380 + F: Documentation/devicetree/bindings/rtc/mediatek,mt2712-rtc.yaml 2381 + F: Documentation/devicetree/bindings/rtc/mediatek,mt7622-rtc.yaml 2382 2382 F: drivers/rtc/rtc-mt2712.c 2383 2383 F: drivers/rtc/rtc-mt6397.c 2384 2384 F: drivers/rtc/rtc-mt7622.c ··· 2617 2617 F: drivers/phy/qualcomm/ 2618 2618 F: drivers/power/*/msm* 2619 2619 F: drivers/reset/reset-qcom-* 2620 + F: drivers/rtc/rtc-pm8xxx.c 2620 2621 F: drivers/spi/spi-geni-qcom.c 2621 2622 F: drivers/spi/spi-qcom-qspi.c 2622 2623 F: drivers/spi/spi-qup.c
+2 -1
drivers/rtc/Kconfig
··· 1858 1858 1859 1859 config RTC_DRV_MT6397 1860 1860 tristate "MediaTek PMIC based RTC" 1861 - depends on MFD_MT6397 || (COMPILE_TEST && IRQ_DOMAIN) 1861 + depends on MFD_MT6397 || COMPILE_TEST 1862 + select IRQ_DOMAIN 1862 1863 help 1863 1864 This selects the MediaTek(R) RTC driver. RTC is part of MediaTek 1864 1865 MT6397 PMIC. You should enable MT6397 PMIC MFD before select
+13 -8
drivers/rtc/class.c
··· 21 21 #include "rtc-core.h" 22 22 23 23 static DEFINE_IDA(rtc_ida); 24 - struct class *rtc_class; 25 24 26 25 static void rtc_device_release(struct device *dev) 27 26 { ··· 198 199 #define RTC_CLASS_DEV_PM_OPS NULL 199 200 #endif 200 201 202 + const struct class rtc_class = { 203 + .name = "rtc", 204 + .pm = RTC_CLASS_DEV_PM_OPS, 205 + }; 206 + 201 207 /* Ensure the caller will set the id before releasing the device */ 202 208 static struct rtc_device *rtc_allocate_device(void) 203 209 { ··· 224 220 225 221 rtc->irq_freq = 1; 226 222 rtc->max_user_freq = 64; 227 - rtc->dev.class = rtc_class; 223 + rtc->dev.class = &rtc_class; 228 224 rtc->dev.groups = rtc_get_dev_attribute_groups(); 229 225 rtc->dev.release = rtc_device_release; 230 226 ··· 479 475 480 476 static int __init rtc_init(void) 481 477 { 482 - rtc_class = class_create("rtc"); 483 - if (IS_ERR(rtc_class)) { 484 - pr_err("couldn't create class\n"); 485 - return PTR_ERR(rtc_class); 486 - } 487 - rtc_class->pm = RTC_CLASS_DEV_PM_OPS; 478 + int err; 479 + 480 + err = class_register(&rtc_class); 481 + if (err) 482 + return err; 483 + 488 484 rtc_dev_init(); 485 + 489 486 return 0; 490 487 } 491 488 subsys_initcall(rtc_init);
+1 -1
drivers/rtc/interface.c
··· 696 696 struct device *dev; 697 697 struct rtc_device *rtc = NULL; 698 698 699 - dev = class_find_device_by_name(rtc_class, name); 699 + dev = class_find_device_by_name(&rtc_class, name); 700 700 if (dev) 701 701 rtc = to_rtc_device(dev); 702 702
+105 -237
drivers/rtc/rtc-ds1511.c
··· 22 22 #include <linux/io.h> 23 23 #include <linux/module.h> 24 24 25 - enum ds1511reg { 26 - DS1511_SEC = 0x0, 27 - DS1511_MIN = 0x1, 28 - DS1511_HOUR = 0x2, 29 - DS1511_DOW = 0x3, 30 - DS1511_DOM = 0x4, 31 - DS1511_MONTH = 0x5, 32 - DS1511_YEAR = 0x6, 33 - DS1511_CENTURY = 0x7, 34 - DS1511_AM1_SEC = 0x8, 35 - DS1511_AM2_MIN = 0x9, 36 - DS1511_AM3_HOUR = 0xa, 37 - DS1511_AM4_DATE = 0xb, 38 - DS1511_WD_MSEC = 0xc, 39 - DS1511_WD_SEC = 0xd, 40 - DS1511_CONTROL_A = 0xe, 41 - DS1511_CONTROL_B = 0xf, 42 - DS1511_RAMADDR_LSB = 0x10, 43 - DS1511_RAMDATA = 0x13 44 - }; 25 + #define DS1511_SEC 0x0 26 + #define DS1511_MIN 0x1 27 + #define DS1511_HOUR 0x2 28 + #define DS1511_DOW 0x3 29 + #define DS1511_DOM 0x4 30 + #define DS1511_MONTH 0x5 31 + #define DS1511_YEAR 0x6 32 + #define DS1511_CENTURY 0x7 33 + #define DS1511_AM1_SEC 0x8 34 + #define DS1511_AM2_MIN 0x9 35 + #define DS1511_AM3_HOUR 0xa 36 + #define DS1511_AM4_DATE 0xb 37 + #define DS1511_WD_MSEC 0xc 38 + #define DS1511_WD_SEC 0xd 39 + #define DS1511_CONTROL_A 0xe 40 + #define DS1511_CONTROL_B 0xf 41 + #define DS1511_RAMADDR_LSB 0x10 42 + #define DS1511_RAMDATA 0x13 45 43 46 44 #define DS1511_BLF1 0x80 47 45 #define DS1511_BLF2 0x40 ··· 59 61 #define DS1511_WDS 0x01 60 62 #define DS1511_RAM_MAX 0x100 61 63 62 - #define RTC_CMD DS1511_CONTROL_B 63 - #define RTC_CMD1 DS1511_CONTROL_A 64 - 65 - #define RTC_ALARM_SEC DS1511_AM1_SEC 66 - #define RTC_ALARM_MIN DS1511_AM2_MIN 67 - #define RTC_ALARM_HOUR DS1511_AM3_HOUR 68 - #define RTC_ALARM_DATE DS1511_AM4_DATE 69 - 70 - #define RTC_SEC DS1511_SEC 71 - #define RTC_MIN DS1511_MIN 72 - #define RTC_HOUR DS1511_HOUR 73 - #define RTC_DOW DS1511_DOW 74 - #define RTC_DOM DS1511_DOM 75 - #define RTC_MON DS1511_MONTH 76 - #define RTC_YEAR DS1511_YEAR 77 - #define RTC_CENTURY DS1511_CENTURY 78 - 79 - #define RTC_TIE DS1511_TIE 80 - #define RTC_TE DS1511_TE 81 - 82 - struct rtc_plat_data { 64 + struct ds1511_data { 83 65 struct rtc_device *rtc; 84 66 void __iomem *ioaddr; /* virtual base address */ 85 67 int irq; 86 - unsigned int irqen; 87 - int alrm_sec; 88 - int alrm_min; 89 - int alrm_hour; 90 - int alrm_mday; 91 68 spinlock_t lock; 92 69 }; 93 70 ··· 71 98 static __iomem char *ds1511_base; 72 99 static u32 reg_spacing = 1; 73 100 74 - static noinline void 75 - rtc_write(uint8_t val, uint32_t reg) 101 + static void rtc_write(uint8_t val, uint32_t reg) 76 102 { 77 103 writeb(val, ds1511_base + (reg * reg_spacing)); 78 104 } 79 105 80 - static noinline uint8_t 81 - rtc_read(enum ds1511reg reg) 106 + static uint8_t rtc_read(uint32_t reg) 82 107 { 83 108 return readb(ds1511_base + (reg * reg_spacing)); 84 109 } 85 110 86 - static inline void 87 - rtc_disable_update(void) 111 + static void rtc_disable_update(void) 88 112 { 89 - rtc_write((rtc_read(RTC_CMD) & ~RTC_TE), RTC_CMD); 113 + rtc_write((rtc_read(DS1511_CONTROL_B) & ~DS1511_TE), DS1511_CONTROL_B); 90 114 } 91 115 92 - static void 93 - rtc_enable_update(void) 116 + static void rtc_enable_update(void) 94 117 { 95 - rtc_write((rtc_read(RTC_CMD) | RTC_TE), RTC_CMD); 118 + rtc_write((rtc_read(DS1511_CONTROL_B) | DS1511_TE), DS1511_CONTROL_B); 96 119 } 97 120 98 - /* 99 - * #define DS1511_WDOG_RESET_SUPPORT 100 - * 101 - * Uncomment this if you want to use these routines in 102 - * some platform code. 103 - */ 104 - #ifdef DS1511_WDOG_RESET_SUPPORT 105 - /* 106 - * just enough code to set the watchdog timer so that it 107 - * will reboot the system 108 - */ 109 - void 110 - ds1511_wdog_set(unsigned long deciseconds) 111 - { 112 - /* 113 - * the wdog timer can take 99.99 seconds 114 - */ 115 - deciseconds %= 10000; 116 - /* 117 - * set the wdog values in the wdog registers 118 - */ 119 - rtc_write(bin2bcd(deciseconds % 100), DS1511_WD_MSEC); 120 - rtc_write(bin2bcd(deciseconds / 100), DS1511_WD_SEC); 121 - /* 122 - * set wdog enable and wdog 'steering' bit to issue a reset 123 - */ 124 - rtc_write(rtc_read(RTC_CMD) | DS1511_WDE | DS1511_WDS, RTC_CMD); 125 - } 126 - 127 - void 128 - ds1511_wdog_disable(void) 129 - { 130 - /* 131 - * clear wdog enable and wdog 'steering' bits 132 - */ 133 - rtc_write(rtc_read(RTC_CMD) & ~(DS1511_WDE | DS1511_WDS), RTC_CMD); 134 - /* 135 - * clear the wdog counter 136 - */ 137 - rtc_write(0, DS1511_WD_MSEC); 138 - rtc_write(0, DS1511_WD_SEC); 139 - } 140 - #endif 141 - 142 - /* 143 - * set the rtc chip's idea of the time. 144 - * stupidly, some callers call with year unmolested; 145 - * and some call with year = year - 1900. thanks. 146 - */ 147 121 static int ds1511_rtc_set_time(struct device *dev, struct rtc_time *rtc_tm) 148 122 { 149 123 u8 mon, day, dow, hrs, min, sec, yrs, cen; 150 124 unsigned long flags; 151 125 152 - /* 153 - * won't have to change this for a while 154 - */ 155 - if (rtc_tm->tm_year < 1900) 156 - rtc_tm->tm_year += 1900; 157 - 158 - if (rtc_tm->tm_year < 1970) 159 - return -EINVAL; 160 - 161 126 yrs = rtc_tm->tm_year % 100; 162 - cen = rtc_tm->tm_year / 100; 127 + cen = 19 + rtc_tm->tm_year / 100; 163 128 mon = rtc_tm->tm_mon + 1; /* tm_mon starts at zero */ 164 129 day = rtc_tm->tm_mday; 165 130 dow = rtc_tm->tm_wday & 0x7; /* automatic BCD */ 166 131 hrs = rtc_tm->tm_hour; 167 132 min = rtc_tm->tm_min; 168 133 sec = rtc_tm->tm_sec; 169 - 170 - if ((mon > 12) || (day == 0)) 171 - return -EINVAL; 172 - 173 - if (day > rtc_month_days(rtc_tm->tm_mon, rtc_tm->tm_year)) 174 - return -EINVAL; 175 - 176 - if ((hrs >= 24) || (min >= 60) || (sec >= 60)) 177 - return -EINVAL; 178 134 179 135 /* 180 136 * each register is a different number of valid bits ··· 118 216 119 217 spin_lock_irqsave(&ds1511_lock, flags); 120 218 rtc_disable_update(); 121 - rtc_write(cen, RTC_CENTURY); 122 - rtc_write(yrs, RTC_YEAR); 123 - rtc_write((rtc_read(RTC_MON) & 0xe0) | mon, RTC_MON); 124 - rtc_write(day, RTC_DOM); 125 - rtc_write(hrs, RTC_HOUR); 126 - rtc_write(min, RTC_MIN); 127 - rtc_write(sec, RTC_SEC); 128 - rtc_write(dow, RTC_DOW); 219 + rtc_write(cen, DS1511_CENTURY); 220 + rtc_write(yrs, DS1511_YEAR); 221 + rtc_write((rtc_read(DS1511_MONTH) & 0xe0) | mon, DS1511_MONTH); 222 + rtc_write(day, DS1511_DOM); 223 + rtc_write(hrs, DS1511_HOUR); 224 + rtc_write(min, DS1511_MIN); 225 + rtc_write(sec, DS1511_SEC); 226 + rtc_write(dow, DS1511_DOW); 129 227 rtc_enable_update(); 130 228 spin_unlock_irqrestore(&ds1511_lock, flags); 131 229 ··· 140 238 spin_lock_irqsave(&ds1511_lock, flags); 141 239 rtc_disable_update(); 142 240 143 - rtc_tm->tm_sec = rtc_read(RTC_SEC) & 0x7f; 144 - rtc_tm->tm_min = rtc_read(RTC_MIN) & 0x7f; 145 - rtc_tm->tm_hour = rtc_read(RTC_HOUR) & 0x3f; 146 - rtc_tm->tm_mday = rtc_read(RTC_DOM) & 0x3f; 147 - rtc_tm->tm_wday = rtc_read(RTC_DOW) & 0x7; 148 - rtc_tm->tm_mon = rtc_read(RTC_MON) & 0x1f; 149 - rtc_tm->tm_year = rtc_read(RTC_YEAR) & 0x7f; 150 - century = rtc_read(RTC_CENTURY); 241 + rtc_tm->tm_sec = rtc_read(DS1511_SEC) & 0x7f; 242 + rtc_tm->tm_min = rtc_read(DS1511_MIN) & 0x7f; 243 + rtc_tm->tm_hour = rtc_read(DS1511_HOUR) & 0x3f; 244 + rtc_tm->tm_mday = rtc_read(DS1511_DOM) & 0x3f; 245 + rtc_tm->tm_wday = rtc_read(DS1511_DOW) & 0x7; 246 + rtc_tm->tm_mon = rtc_read(DS1511_MONTH) & 0x1f; 247 + rtc_tm->tm_year = rtc_read(DS1511_YEAR) & 0x7f; 248 + century = rtc_read(DS1511_CENTURY); 151 249 152 250 rtc_enable_update(); 153 251 spin_unlock_irqrestore(&ds1511_lock, flags); ··· 173 271 return 0; 174 272 } 175 273 176 - /* 177 - * write the alarm register settings 178 - * 179 - * we only have the use to interrupt every second, otherwise 180 - * known as the update interrupt, or the interrupt if the whole 181 - * date/hours/mins/secs matches. the ds1511 has many more 182 - * permutations, but the kernel doesn't. 183 - */ 184 - static void 185 - ds1511_rtc_update_alarm(struct rtc_plat_data *pdata) 274 + static void ds1511_rtc_alarm_enable(unsigned int enabled) 186 275 { 276 + rtc_write(rtc_read(DS1511_CONTROL_B) | (enabled ? DS1511_TIE : 0), DS1511_CONTROL_B); 277 + } 278 + 279 + static int ds1511_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) 280 + { 281 + struct ds1511_data *ds1511 = dev_get_drvdata(dev); 187 282 unsigned long flags; 188 283 189 - spin_lock_irqsave(&pdata->lock, flags); 190 - rtc_write(pdata->alrm_mday < 0 || (pdata->irqen & RTC_UF) ? 191 - 0x80 : bin2bcd(pdata->alrm_mday) & 0x3f, 192 - RTC_ALARM_DATE); 193 - rtc_write(pdata->alrm_hour < 0 || (pdata->irqen & RTC_UF) ? 194 - 0x80 : bin2bcd(pdata->alrm_hour) & 0x3f, 195 - RTC_ALARM_HOUR); 196 - rtc_write(pdata->alrm_min < 0 || (pdata->irqen & RTC_UF) ? 197 - 0x80 : bin2bcd(pdata->alrm_min) & 0x7f, 198 - RTC_ALARM_MIN); 199 - rtc_write(pdata->alrm_sec < 0 || (pdata->irqen & RTC_UF) ? 200 - 0x80 : bin2bcd(pdata->alrm_sec) & 0x7f, 201 - RTC_ALARM_SEC); 202 - rtc_write(rtc_read(RTC_CMD) | (pdata->irqen ? RTC_TIE : 0), RTC_CMD); 203 - rtc_read(RTC_CMD1); /* clear interrupts */ 204 - spin_unlock_irqrestore(&pdata->lock, flags); 205 - } 284 + spin_lock_irqsave(&ds1511->lock, flags); 285 + rtc_write(bin2bcd(alrm->time.tm_mday) & 0x3f, DS1511_AM4_DATE); 286 + rtc_write(bin2bcd(alrm->time.tm_hour) & 0x3f, DS1511_AM3_HOUR); 287 + rtc_write(bin2bcd(alrm->time.tm_min) & 0x7f, DS1511_AM2_MIN); 288 + rtc_write(bin2bcd(alrm->time.tm_sec) & 0x7f, DS1511_AM1_SEC); 289 + ds1511_rtc_alarm_enable(alrm->enabled); 206 290 207 - static int 208 - ds1511_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) 209 - { 210 - struct rtc_plat_data *pdata = dev_get_drvdata(dev); 291 + rtc_read(DS1511_CONTROL_A); /* clear interrupts */ 292 + spin_unlock_irqrestore(&ds1511->lock, flags); 211 293 212 - if (pdata->irq <= 0) 213 - return -EINVAL; 214 - 215 - pdata->alrm_mday = alrm->time.tm_mday; 216 - pdata->alrm_hour = alrm->time.tm_hour; 217 - pdata->alrm_min = alrm->time.tm_min; 218 - pdata->alrm_sec = alrm->time.tm_sec; 219 - if (alrm->enabled) 220 - pdata->irqen |= RTC_AF; 221 - 222 - ds1511_rtc_update_alarm(pdata); 223 294 return 0; 224 295 } 225 296 226 - static int 227 - ds1511_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) 297 + static int ds1511_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) 228 298 { 229 - struct rtc_plat_data *pdata = dev_get_drvdata(dev); 299 + alrm->time.tm_mday = bcd2bin(rtc_read(DS1511_AM4_DATE) & 0x3f); 300 + alrm->time.tm_hour = bcd2bin(rtc_read(DS1511_AM3_HOUR) & 0x3f); 301 + alrm->time.tm_min = bcd2bin(rtc_read(DS1511_AM2_MIN) & 0x7f); 302 + alrm->time.tm_sec = bcd2bin(rtc_read(DS1511_AM1_SEC) & 0x7f); 303 + alrm->enabled = !!(rtc_read(DS1511_CONTROL_B) & DS1511_TIE); 230 304 231 - if (pdata->irq <= 0) 232 - return -EINVAL; 233 - 234 - alrm->time.tm_mday = pdata->alrm_mday < 0 ? 0 : pdata->alrm_mday; 235 - alrm->time.tm_hour = pdata->alrm_hour < 0 ? 0 : pdata->alrm_hour; 236 - alrm->time.tm_min = pdata->alrm_min < 0 ? 0 : pdata->alrm_min; 237 - alrm->time.tm_sec = pdata->alrm_sec < 0 ? 0 : pdata->alrm_sec; 238 - alrm->enabled = (pdata->irqen & RTC_AF) ? 1 : 0; 239 305 return 0; 240 306 } 241 307 242 - static irqreturn_t 243 - ds1511_interrupt(int irq, void *dev_id) 308 + static irqreturn_t ds1511_interrupt(int irq, void *dev_id) 244 309 { 245 310 struct platform_device *pdev = dev_id; 246 - struct rtc_plat_data *pdata = platform_get_drvdata(pdev); 311 + struct ds1511_data *ds1511 = platform_get_drvdata(pdev); 247 312 unsigned long events = 0; 248 313 249 - spin_lock(&pdata->lock); 314 + spin_lock(&ds1511->lock); 250 315 /* 251 316 * read and clear interrupt 252 317 */ 253 - if (rtc_read(RTC_CMD1) & DS1511_IRQF) { 254 - events = RTC_IRQF; 255 - if (rtc_read(RTC_ALARM_SEC) & 0x80) 256 - events |= RTC_UF; 257 - else 258 - events |= RTC_AF; 259 - rtc_update_irq(pdata->rtc, 1, events); 318 + if (rtc_read(DS1511_CONTROL_A) & DS1511_IRQF) { 319 + events = RTC_IRQF | RTC_AF; 320 + rtc_update_irq(ds1511->rtc, 1, events); 260 321 } 261 - spin_unlock(&pdata->lock); 322 + spin_unlock(&ds1511->lock); 262 323 return events ? IRQ_HANDLED : IRQ_NONE; 263 324 } 264 325 265 326 static int ds1511_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) 266 327 { 267 - struct rtc_plat_data *pdata = dev_get_drvdata(dev); 328 + struct ds1511_data *ds1511 = dev_get_drvdata(dev); 329 + unsigned long flags; 268 330 269 - if (pdata->irq <= 0) 270 - return -EINVAL; 271 - if (enabled) 272 - pdata->irqen |= RTC_AF; 273 - else 274 - pdata->irqen &= ~RTC_AF; 275 - ds1511_rtc_update_alarm(pdata); 331 + spin_lock_irqsave(&ds1511->lock, flags); 332 + ds1511_rtc_alarm_enable(enabled); 333 + spin_unlock_irqrestore(&ds1511->lock, flags); 334 + 276 335 return 0; 277 336 } 278 337 ··· 271 408 272 409 static int ds1511_rtc_probe(struct platform_device *pdev) 273 410 { 274 - struct rtc_plat_data *pdata; 411 + struct ds1511_data *ds1511; 275 412 int ret = 0; 276 413 struct nvmem_config ds1511_nvmem_cfg = { 277 414 .name = "ds1511_nvram", ··· 283 420 .priv = &pdev->dev, 284 421 }; 285 422 286 - pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL); 287 - if (!pdata) 423 + ds1511 = devm_kzalloc(&pdev->dev, sizeof(*ds1511), GFP_KERNEL); 424 + if (!ds1511) 288 425 return -ENOMEM; 289 426 290 427 ds1511_base = devm_platform_ioremap_resource(pdev, 0); 291 428 if (IS_ERR(ds1511_base)) 292 429 return PTR_ERR(ds1511_base); 293 - pdata->ioaddr = ds1511_base; 294 - pdata->irq = platform_get_irq(pdev, 0); 430 + ds1511->ioaddr = ds1511_base; 431 + ds1511->irq = platform_get_irq(pdev, 0); 295 432 296 433 /* 297 434 * turn on the clock and the crystal, etc. 298 435 */ 299 - rtc_write(DS1511_BME, RTC_CMD); 300 - rtc_write(0, RTC_CMD1); 436 + rtc_write(DS1511_BME, DS1511_CONTROL_B); 437 + rtc_write(0, DS1511_CONTROL_A); 301 438 /* 302 439 * clear the wdog counter 303 440 */ ··· 311 448 /* 312 449 * check for a dying bat-tree 313 450 */ 314 - if (rtc_read(RTC_CMD1) & DS1511_BLF1) 451 + if (rtc_read(DS1511_CONTROL_A) & DS1511_BLF1) 315 452 dev_warn(&pdev->dev, "voltage-low detected.\n"); 316 453 317 - spin_lock_init(&pdata->lock); 318 - platform_set_drvdata(pdev, pdata); 454 + spin_lock_init(&ds1511->lock); 455 + platform_set_drvdata(pdev, ds1511); 319 456 320 - pdata->rtc = devm_rtc_allocate_device(&pdev->dev); 321 - if (IS_ERR(pdata->rtc)) 322 - return PTR_ERR(pdata->rtc); 457 + ds1511->rtc = devm_rtc_allocate_device(&pdev->dev); 458 + if (IS_ERR(ds1511->rtc)) 459 + return PTR_ERR(ds1511->rtc); 323 460 324 - pdata->rtc->ops = &ds1511_rtc_ops; 325 - 326 - ret = devm_rtc_register_device(pdata->rtc); 327 - if (ret) 328 - return ret; 329 - 330 - devm_rtc_nvmem_register(pdata->rtc, &ds1511_nvmem_cfg); 461 + ds1511->rtc->ops = &ds1511_rtc_ops; 462 + ds1511->rtc->range_max = RTC_TIMESTAMP_END_2099; 463 + ds1511->rtc->alarm_offset_max = 28 * 24 * 60 * 60 - 1; 331 464 332 465 /* 333 466 * if the platform has an interrupt in mind for this device, 334 467 * then by all means, set it 335 468 */ 336 - if (pdata->irq > 0) { 337 - rtc_read(RTC_CMD1); 338 - if (devm_request_irq(&pdev->dev, pdata->irq, ds1511_interrupt, 469 + if (ds1511->irq > 0) { 470 + rtc_read(DS1511_CONTROL_A); 471 + if (devm_request_irq(&pdev->dev, ds1511->irq, ds1511_interrupt, 339 472 IRQF_SHARED, pdev->name, pdev) < 0) { 340 473 341 474 dev_warn(&pdev->dev, "interrupt not available.\n"); 342 - pdata->irq = 0; 475 + ds1511->irq = 0; 343 476 } 344 477 } 478 + 479 + if (ds1511->irq == 0) 480 + clear_bit(RTC_FEATURE_ALARM, ds1511->rtc->features); 481 + 482 + ret = devm_rtc_register_device(ds1511->rtc); 483 + if (ret) 484 + return ret; 485 + 486 + devm_rtc_nvmem_register(ds1511->rtc, &ds1511_nvmem_cfg); 345 487 346 488 return 0; 347 489 }
+1 -4
drivers/rtc/rtc-m41t80.c
··· 909 909 if (IS_ERR(m41t80_data->rtc)) 910 910 return PTR_ERR(m41t80_data->rtc); 911 911 912 - #ifdef CONFIG_OF 913 - wakeup_source = of_property_read_bool(client->dev.of_node, 914 - "wakeup-source"); 915 - #endif 912 + wakeup_source = device_property_read_bool(&client->dev, "wakeup-source"); 916 913 if (client->irq > 0) { 917 914 unsigned long irqflags = IRQF_TRIGGER_LOW; 918 915
+1 -1
drivers/rtc/rtc-max31335.c
··· 204 204 return true; 205 205 206 206 /* interrupt status register */ 207 - if (reg == MAX31335_INT_EN1_A1IE) 207 + if (reg == MAX31335_STATUS1) 208 208 return true; 209 209 210 210 /* temperature registers */
+3 -3
drivers/rtc/rtc-nct3018y.c
··· 102 102 if (flags < 0) 103 103 return flags; 104 104 *alarm_enable = flags & NCT3018Y_BIT_AIE; 105 + dev_dbg(&client->dev, "%s:alarm_enable:%x\n", __func__, *alarm_enable); 106 + 105 107 } 106 108 107 109 if (alarm_flag) { ··· 112 110 if (flags < 0) 113 111 return flags; 114 112 *alarm_flag = flags & NCT3018Y_BIT_AF; 113 + dev_dbg(&client->dev, "%s:alarm_flag:%x\n", __func__, *alarm_flag); 115 114 } 116 - 117 - dev_dbg(&client->dev, "%s:alarm_enable:%x alarm_flag:%x\n", 118 - __func__, *alarm_enable, *alarm_flag); 119 115 120 116 return 0; 121 117 }
+25
drivers/rtc/rtc-pcf8523.c
··· 370 370 return regmap_write(pcf8523->regmap, PCF8523_REG_OFFSET, value); 371 371 } 372 372 373 + #ifdef CONFIG_PM_SLEEP 374 + static int pcf8523_suspend(struct device *dev) 375 + { 376 + struct i2c_client *client = to_i2c_client(dev); 377 + 378 + if (client->irq > 0 && device_may_wakeup(dev)) 379 + enable_irq_wake(client->irq); 380 + 381 + return 0; 382 + } 383 + 384 + static int pcf8523_resume(struct device *dev) 385 + { 386 + struct i2c_client *client = to_i2c_client(dev); 387 + 388 + if (client->irq > 0 && device_may_wakeup(dev)) 389 + disable_irq_wake(client->irq); 390 + 391 + return 0; 392 + } 393 + #endif 394 + 395 + static SIMPLE_DEV_PM_OPS(pcf8523_pm, pcf8523_suspend, pcf8523_resume); 396 + 373 397 static const struct rtc_class_ops pcf8523_rtc_ops = { 374 398 .read_time = pcf8523_rtc_read_time, 375 399 .set_time = pcf8523_rtc_set_time, ··· 511 487 .driver = { 512 488 .name = "rtc-pcf8523", 513 489 .of_match_table = pcf8523_of_match, 490 + .pm = &pcf8523_pm, 514 491 }, 515 492 .probe = pcf8523_probe, 516 493 .id_table = pcf8523_id,
+1 -1
include/linux/rtc.h
··· 42 42 #include <linux/timerqueue.h> 43 43 #include <linux/workqueue.h> 44 44 45 - extern struct class *rtc_class; 45 + extern const struct class rtc_class; 46 46 47 47 /* 48 48 * For these RTC methods the device parameter is the physical device
+1 -1
kernel/power/suspend_test.c
··· 201 201 } 202 202 203 203 /* RTCs have initialized by now too ... can we use one? */ 204 - dev = class_find_device(rtc_class, NULL, NULL, has_wakealarm); 204 + dev = class_find_device(&rtc_class, NULL, NULL, has_wakealarm); 205 205 if (dev) { 206 206 rtc = rtc_class_open(dev_name(dev)); 207 207 put_device(dev);
+1 -1
kernel/time/alarmtimer.c
··· 134 134 135 135 static int alarmtimer_rtc_interface_setup(void) 136 136 { 137 - alarmtimer_rtc_interface.class = rtc_class; 137 + alarmtimer_rtc_interface.class = &rtc_class; 138 138 return class_interface_register(&alarmtimer_rtc_interface); 139 139 } 140 140 static void alarmtimer_rtc_interface_remove(void)