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

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

Pull RTC updates from Alexandre Belloni:
"New drivers:
- Amlogic A4 and A5 RTC
- Marvell 88PM886 PMIC RTC
- Renesas RTCA-3 for Renesas RZ/G3S

Driver updates:
- ab-eoz9: fix temperature and alarm support
- cmos: improve locking behaviour
- isl12022: add alarm support
- m48t59: improve epoch handling
- mt6359: add range
- rzn1: fix BCD conversions and simplify driver"

* tag 'rtc-6.13' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (38 commits)
rtc: ab-eoz9: don't fail temperature reads on undervoltage notification
rtc: rzn1: reduce register access
rtc: rzn1: drop superfluous wday calculation
m68k: mvme147, mvme16x: Adopt rtc-m48t59 platform driver
rtc: brcmstb-waketimer: don't include 'pm_wakeup.h' directly
rtc: m48t59: Use platform_data struct for year offset value
rtc: ab-eoz9: fix abeoz9_rtc_read_alarm
rtc: rv3028: fix RV3028_TS_COUNT type
rtc: rzn1: update Michel's email
rtc: rzn1: fix BCD to rtc_time conversion errors
rtc: amlogic-a4: fix compile error
rtc: amlogic-a4: drop error messages
MAINTAINERS: Add an entry for Amlogic RTC driver
rtc: support for the Amlogic on-chip RTC
dt-bindings: rtc: Add Amlogic A4 and A5 RTC
rtc: add driver for Marvell 88PM886 PMIC RTC
rtc: check if __rtc_read_time was successful in rtc_timer_do_work()
rtc: pcf8563: Switch to regmap
rtc: pcf8563: Sort headers alphabetically
rtc: abx80x: Fix WDT bit position of the status register
...

+2226 -604
+3 -1
Documentation/devicetree/bindings/rtc/allwinner,sun6i-a31-rtc.yaml
··· 30 30 - const: allwinner,sun50i-a64-rtc 31 31 - const: allwinner,sun8i-h3-rtc 32 32 - items: 33 - - const: allwinner,sun20i-d1-rtc 33 + - enum: 34 + - allwinner,sun20i-d1-rtc 35 + - allwinner,sun55i-a523-rtc 34 36 - const: allwinner,sun50i-r329-rtc 35 37 36 38 reg:
+63
Documentation/devicetree/bindings/rtc/amlogic,a4-rtc.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + # Copyright (C) 2024 Amlogic, Inc. All rights reserved 3 + %YAML 1.2 4 + --- 5 + $id: http://devicetree.org/schemas/rtc/amlogic,a4-rtc.yaml# 6 + $schema: http://devicetree.org/meta-schemas/core.yaml# 7 + 8 + title: Amlogic A4 and A5 RTC 9 + 10 + maintainers: 11 + - Yiting Deng <yiting.deng@amlogic.com> 12 + - Xianwei Zhao <xianwei.zhao@amlogic.com> 13 + 14 + allOf: 15 + - $ref: rtc.yaml# 16 + 17 + properties: 18 + compatible: 19 + enum: 20 + - amlogic,a4-rtc 21 + - amlogic,a5-rtc 22 + 23 + reg: 24 + maxItems: 1 25 + 26 + clocks: 27 + items: 28 + - description: RTC clock source, available 24M or 32K crystal 29 + oscillator source. when using 24M, need to divide 24M into 32K. 30 + - description: RTC module accesses the clock of the apb bus. 31 + 32 + clock-names: 33 + items: 34 + - const: osc 35 + - const: sys 36 + 37 + interrupts: 38 + maxItems: 1 39 + 40 + required: 41 + - compatible 42 + - reg 43 + - clocks 44 + - clock-names 45 + - interrupts 46 + 47 + additionalProperties: false 48 + 49 + examples: 50 + - | 51 + #include <dt-bindings/interrupt-controller/arm-gic.h> 52 + apb { 53 + #address-cells = <2>; 54 + #size-cells = <2>; 55 + 56 + rtc@8e600 { 57 + compatible = "amlogic,a4-rtc"; 58 + reg = <0x0 0x8e600 0x0 0x38>; 59 + clocks = <&xtal_32k>, <&clkc_periphs 1>; 60 + clock-names = "osc", "sys"; 61 + interrupts = <GIC_SPI 131 IRQ_TYPE_EDGE_RISING>; 62 + }; 63 + };
+6 -4
Documentation/devicetree/bindings/rtc/microchip,mfps-rtc.yaml Documentation/devicetree/bindings/rtc/microchip,mpfs-rtc.yaml
··· 1 1 # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 2 %YAML 1.2 3 3 --- 4 - $id: http://devicetree.org/schemas/rtc/microchip,mfps-rtc.yaml# 4 + $id: http://devicetree.org/schemas/rtc/microchip,mpfs-rtc.yaml# 5 5 6 6 $schema: http://devicetree.org/meta-schemas/core.yaml# 7 7 ··· 12 12 13 13 maintainers: 14 14 - Daire McNamara <daire.mcnamara@microchip.com> 15 - - Lewis Hanly <lewis.hanly@microchip.com> 16 15 17 16 properties: 18 17 compatible: 19 - enum: 20 - - microchip,mpfs-rtc 18 + oneOf: 19 + - items: 20 + - const: microchip,pic64gx-rtc 21 + - const: microchip,mpfs-rtc 22 + - const: microchip,mpfs-rtc 21 23 22 24 reg: 23 25 maxItems: 1
+84
Documentation/devicetree/bindings/rtc/renesas,rz-rtca3.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/renesas,rz-rtca3.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Renesas RTCA-3 Real Time Clock 8 + 9 + maintainers: 10 + - Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> 11 + 12 + allOf: 13 + - $ref: rtc.yaml# 14 + 15 + properties: 16 + compatible: 17 + items: 18 + - enum: 19 + - renesas,r9a08g045-rtca3 # RZ/G3S 20 + - const: renesas,rz-rtca3 21 + 22 + reg: 23 + maxItems: 1 24 + 25 + interrupts: 26 + items: 27 + - description: Alarm interrupt 28 + - description: Periodic interrupt 29 + - description: Carry interrupt 30 + 31 + interrupt-names: 32 + items: 33 + - const: alarm 34 + - const: period 35 + - const: carry 36 + 37 + clocks: 38 + items: 39 + - description: RTC bus clock 40 + - description: RTC counter clock 41 + 42 + clock-names: 43 + items: 44 + - const: bus 45 + - const: counter 46 + 47 + power-domains: 48 + maxItems: 1 49 + 50 + resets: 51 + items: 52 + - description: VBATTB module reset 53 + 54 + required: 55 + - compatible 56 + - reg 57 + - interrupts 58 + - interrupt-names 59 + - clocks 60 + - clock-names 61 + - power-domains 62 + - resets 63 + 64 + additionalProperties: false 65 + 66 + examples: 67 + - | 68 + #include <dt-bindings/clock/r9a08g045-cpg.h> 69 + #include <dt-bindings/clock/renesas,r9a08g045-vbattb.h> 70 + #include <dt-bindings/interrupt-controller/arm-gic.h> 71 + #include <dt-bindings/interrupt-controller/irq.h> 72 + 73 + rtc@1004ec00 { 74 + compatible = "renesas,r9a08g045-rtca3", "renesas,rz-rtca3"; 75 + reg = <0x1004ec00 0x400>; 76 + interrupts = <GIC_SPI 315 IRQ_TYPE_LEVEL_HIGH>, 77 + <GIC_SPI 316 IRQ_TYPE_LEVEL_HIGH>, 78 + <GIC_SPI 317 IRQ_TYPE_LEVEL_HIGH>; 79 + interrupt-names = "alarm", "period", "carry"; 80 + clocks = <&cpg CPG_MOD R9A08G045_VBAT_BCLK>, <&vbattclk VBATTB_VBATTCLK>; 81 + clock-names = "bus", "counter"; 82 + power-domains = <&cpg>; 83 + resets = <&cpg R9A08G045_VBAT_BRESETN>; 84 + };
+17
MAINTAINERS
··· 1218 1218 F: drivers/perf/amlogic/ 1219 1219 F: include/soc/amlogic/ 1220 1220 1221 + AMLOGIC RTC DRIVER 1222 + M: Yiting Deng <yiting.deng@amlogic.com> 1223 + M: Xianwei Zhao <xianwei.zhao@amlogic.com> 1224 + L: linux-amlogic@lists.infradead.org 1225 + S: Maintained 1226 + F: Documentation/devicetree/bindings/rtc/amlogic,a4-rtc.yaml 1227 + F: drivers/rtc/rtc-amlogic-a4.c 1228 + 1221 1229 AMPHENOL CHIPCAP 2 HUMIDITY-TEMPERATURE IIO DRIVER 1222 1230 M: Javier Carrasco <javier.carrasco.cruz@gmail.com> 1223 1231 L: linux-hwmon@vger.kernel.org ··· 13802 13794 F: drivers/input/misc/88pm886-onkey.c 13803 13795 F: drivers/mfd/88pm886.c 13804 13796 F: drivers/regulator/88pm886-regulator.c 13797 + F: drivers/rtc/rtc-88pm886.c 13805 13798 F: include/linux/mfd/88pm886.h 13806 13799 13807 13800 MARVELL ARMADA 3700 PHY DRIVERS ··· 19923 19914 S: Supported 19924 19915 F: Documentation/devicetree/bindings/timer/renesas,rz-mtu3.yaml 19925 19916 F: drivers/counter/rz-mtu3-cnt.c 19917 + 19918 + RENESAS RTCA-3 RTC DRIVER 19919 + M: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> 19920 + L: linux-rtc@vger.kernel.org 19921 + L: linux-renesas-soc@vger.kernel.org 19922 + S: Supported 19923 + F: Documentation/devicetree/bindings/rtc/renesas,rz-rtca3.yaml 19924 + F: drivers/rtc/rtc-renesas-rtca3.c 19926 19925 19927 19926 RENESAS RZ/N1 A5PSW SWITCH DRIVER 19928 19927 M: Clément Léger <clement.leger@bootlin.com>
+1
arch/m68k/configs/multi_defconfig
··· 503 503 # CONFIG_USB_SUPPORT is not set 504 504 CONFIG_RTC_CLASS=y 505 505 # CONFIG_RTC_NVMEM is not set 506 + CONFIG_RTC_DRV_M48T59=m 506 507 CONFIG_RTC_DRV_MSM6242=m 507 508 CONFIG_RTC_DRV_RP5C01=m 508 509 CONFIG_RTC_DRV_GENERIC=m
+1
arch/m68k/configs/mvme147_defconfig
··· 391 391 # CONFIG_USB_SUPPORT is not set 392 392 CONFIG_RTC_CLASS=y 393 393 # CONFIG_RTC_NVMEM is not set 394 + CONFIG_RTC_DRV_M48T59=y 394 395 CONFIG_RTC_DRV_GENERIC=m 395 396 # CONFIG_VIRTIO_MENU is not set 396 397 # CONFIG_VHOST_MENU is not set
+1
arch/m68k/configs/mvme16x_defconfig
··· 392 392 # CONFIG_USB_SUPPORT is not set 393 393 CONFIG_RTC_CLASS=y 394 394 # CONFIG_RTC_NVMEM is not set 395 + CONFIG_RTC_DRV_M48T59=y 395 396 CONFIG_RTC_DRV_GENERIC=m 396 397 # CONFIG_VIRTIO_MENU is not set 397 398 # CONFIG_VHOST_MENU is not set
+1 -18
arch/m68k/include/asm/mvme147hw.h
··· 4 4 5 5 #include <asm/irq.h> 6 6 7 - typedef struct { 8 - unsigned char 9 - ctrl, 10 - bcd_sec, 11 - bcd_min, 12 - bcd_hr, 13 - bcd_dow, 14 - bcd_dom, 15 - bcd_mth, 16 - bcd_year; 17 - } MK48T02; 18 - 19 - #define RTC_WRITE 0x80 20 - #define RTC_READ 0x40 21 - #define RTC_STOP 0x20 22 - 23 - #define m147_rtc ((MK48T02 * volatile)0xfffe07f8) 24 - 7 + #define MVME147_RTC_BASE 0xfffe0000 25 8 26 9 struct pcc_regs { 27 10 volatile u_long dma_tadr;
+1 -17
arch/m68k/include/asm/mvme16xhw.h
··· 24 24 25 25 #define mvmelp ((*(volatile MVMElpPtr)(MVME_LPR_BASE))) 26 26 27 - typedef struct { 28 - unsigned char 29 - ctrl, 30 - bcd_sec, 31 - bcd_min, 32 - bcd_hr, 33 - bcd_dow, 34 - bcd_dom, 35 - bcd_mth, 36 - bcd_year; 37 - } MK48T08_t, *MK48T08ptr_t; 38 - 39 - #define RTC_WRITE 0x80 40 - #define RTC_READ 0x40 41 - #define RTC_STOP 0x20 42 - 43 - #define MVME_RTC_BASE 0xfffc1ff8 27 + #define MVME_RTC_BASE 0xfffc0000 44 28 45 29 #define MVME_I596_BASE 0xfff46000 46 30
+24 -31
arch/m68k/mvme147/config.c
··· 19 19 #include <linux/linkage.h> 20 20 #include <linux/init.h> 21 21 #include <linux/major.h> 22 - #include <linux/rtc.h> 23 22 #include <linux/interrupt.h> 23 + #include <linux/platform_device.h> 24 + #include <linux/rtc/m48t59.h> 24 25 25 26 #include <asm/bootinfo.h> 26 27 #include <asm/bootinfo-vme.h> ··· 37 36 38 37 static void mvme147_get_model(char *model); 39 38 static void __init mvme147_sched_init(void); 40 - extern int mvme147_hwclk (int, struct rtc_time *); 41 39 extern void mvme147_reset (void); 42 - 43 - 44 - static int bcd2int (unsigned char b); 45 40 46 41 47 42 int __init mvme147_parse_bootinfo(const struct bi_record *bi) ··· 77 80 { 78 81 mach_sched_init = mvme147_sched_init; 79 82 mach_init_IRQ = mvme147_init_IRQ; 80 - mach_hwclk = mvme147_hwclk; 81 83 mach_reset = mvme147_reset; 82 84 mach_get_model = mvme147_get_model; 83 85 ··· 84 88 if (!vme_brdtype) 85 89 vme_brdtype = VME_TYPE_MVME147; 86 90 } 91 + 92 + static struct resource m48t59_rsrc[] = { 93 + DEFINE_RES_MEM(MVME147_RTC_BASE, 0x800), 94 + }; 95 + 96 + static struct m48t59_plat_data m48t59_data = { 97 + .type = M48T59RTC_TYPE_M48T02, 98 + .yy_offset = 70, 99 + }; 100 + 101 + static int __init mvme147_platform_init(void) 102 + { 103 + if (!MACH_IS_MVME147) 104 + return 0; 105 + 106 + platform_device_register_resndata(NULL, "rtc-m48t59", -1, 107 + m48t59_rsrc, ARRAY_SIZE(m48t59_rsrc), 108 + &m48t59_data, sizeof(m48t59_data)); 109 + return 0; 110 + } 111 + 112 + arch_initcall(mvme147_platform_init); 87 113 88 114 static u64 mvme147_read_clk(struct clocksource *cs); 89 115 ··· 178 160 local_irq_restore(flags); 179 161 180 162 return ticks; 181 - } 182 - 183 - static int bcd2int (unsigned char b) 184 - { 185 - return ((b>>4)*10 + (b&15)); 186 - } 187 - 188 - int mvme147_hwclk(int op, struct rtc_time *t) 189 - { 190 - if (!op) { 191 - m147_rtc->ctrl = RTC_READ; 192 - t->tm_year = bcd2int (m147_rtc->bcd_year); 193 - t->tm_mon = bcd2int(m147_rtc->bcd_mth) - 1; 194 - t->tm_mday = bcd2int (m147_rtc->bcd_dom); 195 - t->tm_hour = bcd2int (m147_rtc->bcd_hr); 196 - t->tm_min = bcd2int (m147_rtc->bcd_min); 197 - t->tm_sec = bcd2int (m147_rtc->bcd_sec); 198 - m147_rtc->ctrl = 0; 199 - if (t->tm_year < 70) 200 - t->tm_year += 100; 201 - } else { 202 - /* FIXME Setting the time is not yet supported */ 203 - return -EOPNOTSUPP; 204 - } 205 - return 0; 206 163 } 207 164 208 165 static void scc_delay(void)
+1 -1
arch/m68k/mvme16x/Makefile
··· 3 3 # Makefile for Linux arch/m68k/mvme16x source directory 4 4 # 5 5 6 - obj-y := config.o rtc.o 6 + obj-y := config.o
+24 -33
arch/m68k/mvme16x/config.c
··· 21 21 #include <linux/linkage.h> 22 22 #include <linux/init.h> 23 23 #include <linux/major.h> 24 - #include <linux/rtc.h> 25 24 #include <linux/interrupt.h> 26 25 #include <linux/module.h> 26 + #include <linux/platform_device.h> 27 + #include <linux/rtc/m48t59.h> 27 28 28 29 #include <asm/bootinfo.h> 29 30 #include <asm/bootinfo-vme.h> ··· 40 39 41 40 extern t_bdid mvme_bdid; 42 41 43 - static MK48T08ptr_t volatile rtc = (MK48T08ptr_t)MVME_RTC_BASE; 44 - 45 42 static void mvme16x_get_model(char *model); 46 43 extern void mvme16x_sched_init(void); 47 - extern int mvme16x_hwclk (int, struct rtc_time *); 48 44 extern void mvme16x_reset (void); 49 - 50 - int bcd2int (unsigned char b); 51 - 52 45 53 46 unsigned short mvme16x_config; 54 47 EXPORT_SYMBOL(mvme16x_config); ··· 263 268 264 269 mach_sched_init = mvme16x_sched_init; 265 270 mach_init_IRQ = mvme16x_init_IRQ; 266 - mach_hwclk = mvme16x_hwclk; 267 271 mach_reset = mvme16x_reset; 268 272 mach_get_model = mvme16x_get_model; 269 273 mach_get_hardware_list = mvme16x_get_hardware_list; ··· 305 311 mvme16x_config = MVME16x_CONFIG_GOT_LP | MVME16x_CONFIG_GOT_CD2401; 306 312 } 307 313 } 314 + 315 + static struct resource m48t59_rsrc[] = { 316 + DEFINE_RES_MEM(MVME_RTC_BASE, 0x2000), 317 + }; 318 + 319 + static struct m48t59_plat_data m48t59_data = { 320 + .type = M48T59RTC_TYPE_M48T08, 321 + .yy_offset = 70, 322 + }; 323 + 324 + static int __init mvme16x_platform_init(void) 325 + { 326 + if (!MACH_IS_MVME16x) 327 + return 0; 328 + 329 + platform_device_register_resndata(NULL, "rtc-m48t59", -1, 330 + m48t59_rsrc, ARRAY_SIZE(m48t59_rsrc), 331 + &m48t59_data, sizeof(m48t59_data)); 332 + return 0; 333 + } 334 + 335 + arch_initcall(mvme16x_platform_init); 308 336 309 337 static irqreturn_t mvme16x_abort_int (int irq, void *dev_id) 310 338 { ··· 441 425 local_irq_restore(flags); 442 426 443 427 return ticks; 444 - } 445 - 446 - int bcd2int (unsigned char b) 447 - { 448 - return ((b>>4)*10 + (b&15)); 449 - } 450 - 451 - int mvme16x_hwclk(int op, struct rtc_time *t) 452 - { 453 - if (!op) { 454 - rtc->ctrl = RTC_READ; 455 - t->tm_year = bcd2int (rtc->bcd_year); 456 - t->tm_mon = bcd2int(rtc->bcd_mth) - 1; 457 - t->tm_mday = bcd2int (rtc->bcd_dom); 458 - t->tm_hour = bcd2int (rtc->bcd_hr); 459 - t->tm_min = bcd2int (rtc->bcd_min); 460 - t->tm_sec = bcd2int (rtc->bcd_sec); 461 - rtc->ctrl = 0; 462 - if (t->tm_year < 70) 463 - t->tm_year += 100; 464 - } else { 465 - /* FIXME Setting the time is not yet supported */ 466 - return -EOPNOTSUPP; 467 - } 468 - return 0; 469 428 }
-165
arch/m68k/mvme16x/rtc.c
··· 1 - // SPDX-License-Identifier: GPL-2.0 2 - /* 3 - * Real Time Clock interface for Linux on the MVME16x 4 - * 5 - * Based on the PC driver by Paul Gortmaker. 6 - */ 7 - 8 - #define RTC_VERSION "1.00" 9 - 10 - #include <linux/types.h> 11 - #include <linux/errno.h> 12 - #include <linux/miscdevice.h> 13 - #include <linux/ioport.h> 14 - #include <linux/capability.h> 15 - #include <linux/fcntl.h> 16 - #include <linux/init.h> 17 - #include <linux/poll.h> 18 - #include <linux/rtc.h> /* For struct rtc_time and ioctls, etc */ 19 - #include <linux/bcd.h> 20 - #include <asm/mvme16xhw.h> 21 - 22 - #include <asm/io.h> 23 - #include <linux/uaccess.h> 24 - #include <asm/setup.h> 25 - 26 - /* 27 - * We sponge a minor off of the misc major. No need slurping 28 - * up another valuable major dev number for this. If you add 29 - * an ioctl, make sure you don't conflict with SPARC's RTC 30 - * ioctls. 31 - */ 32 - 33 - static const unsigned char days_in_mo[] = 34 - {0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; 35 - 36 - static atomic_t rtc_ready = ATOMIC_INIT(1); 37 - 38 - static long rtc_ioctl(struct file *file, unsigned int cmd, unsigned long arg) 39 - { 40 - volatile MK48T08ptr_t rtc = (MK48T08ptr_t)MVME_RTC_BASE; 41 - unsigned long flags; 42 - struct rtc_time wtime; 43 - void __user *argp = (void __user *)arg; 44 - 45 - switch (cmd) { 46 - case RTC_RD_TIME: /* Read the time/date from RTC */ 47 - { 48 - local_irq_save(flags); 49 - /* Ensure clock and real-time-mode-register are accessible */ 50 - rtc->ctrl = RTC_READ; 51 - memset(&wtime, 0, sizeof(struct rtc_time)); 52 - wtime.tm_sec = bcd2bin(rtc->bcd_sec); 53 - wtime.tm_min = bcd2bin(rtc->bcd_min); 54 - wtime.tm_hour = bcd2bin(rtc->bcd_hr); 55 - wtime.tm_mday = bcd2bin(rtc->bcd_dom); 56 - wtime.tm_mon = bcd2bin(rtc->bcd_mth)-1; 57 - wtime.tm_year = bcd2bin(rtc->bcd_year); 58 - if (wtime.tm_year < 70) 59 - wtime.tm_year += 100; 60 - wtime.tm_wday = bcd2bin(rtc->bcd_dow)-1; 61 - rtc->ctrl = 0; 62 - local_irq_restore(flags); 63 - return copy_to_user(argp, &wtime, sizeof wtime) ? 64 - -EFAULT : 0; 65 - } 66 - case RTC_SET_TIME: /* Set the RTC */ 67 - { 68 - struct rtc_time rtc_tm; 69 - unsigned char mon, day, hrs, min, sec, leap_yr; 70 - unsigned int yrs; 71 - 72 - if (!capable(CAP_SYS_ADMIN)) 73 - return -EACCES; 74 - 75 - if (copy_from_user(&rtc_tm, argp, sizeof(struct rtc_time))) 76 - return -EFAULT; 77 - 78 - yrs = rtc_tm.tm_year; 79 - if (yrs < 1900) 80 - yrs += 1900; 81 - mon = rtc_tm.tm_mon + 1; /* tm_mon starts at zero */ 82 - day = rtc_tm.tm_mday; 83 - hrs = rtc_tm.tm_hour; 84 - min = rtc_tm.tm_min; 85 - sec = rtc_tm.tm_sec; 86 - 87 - leap_yr = ((!(yrs % 4) && (yrs % 100)) || !(yrs % 400)); 88 - 89 - if ((mon > 12) || (day == 0)) 90 - return -EINVAL; 91 - 92 - if (day > (days_in_mo[mon] + ((mon == 2) && leap_yr))) 93 - return -EINVAL; 94 - 95 - if ((hrs >= 24) || (min >= 60) || (sec >= 60)) 96 - return -EINVAL; 97 - 98 - if (yrs >= 2070) 99 - return -EINVAL; 100 - 101 - local_irq_save(flags); 102 - rtc->ctrl = RTC_WRITE; 103 - 104 - rtc->bcd_sec = bin2bcd(sec); 105 - rtc->bcd_min = bin2bcd(min); 106 - rtc->bcd_hr = bin2bcd(hrs); 107 - rtc->bcd_dom = bin2bcd(day); 108 - rtc->bcd_mth = bin2bcd(mon); 109 - rtc->bcd_year = bin2bcd(yrs%100); 110 - 111 - rtc->ctrl = 0; 112 - local_irq_restore(flags); 113 - return 0; 114 - } 115 - default: 116 - return -EINVAL; 117 - } 118 - } 119 - 120 - /* 121 - * We enforce only one user at a time here with the open/close. 122 - */ 123 - static int rtc_open(struct inode *inode, struct file *file) 124 - { 125 - if( !atomic_dec_and_test(&rtc_ready) ) 126 - { 127 - atomic_inc( &rtc_ready ); 128 - return -EBUSY; 129 - } 130 - return 0; 131 - } 132 - 133 - static int rtc_release(struct inode *inode, struct file *file) 134 - { 135 - atomic_inc( &rtc_ready ); 136 - return 0; 137 - } 138 - 139 - /* 140 - * The various file operations we support. 141 - */ 142 - 143 - static const struct file_operations rtc_fops = { 144 - .unlocked_ioctl = rtc_ioctl, 145 - .open = rtc_open, 146 - .release = rtc_release, 147 - .llseek = noop_llseek, 148 - }; 149 - 150 - static struct miscdevice rtc_dev= 151 - { 152 - .minor = RTC_MINOR, 153 - .name = "rtc", 154 - .fops = &rtc_fops 155 - }; 156 - 157 - static int __init rtc_MK48T08_init(void) 158 - { 159 - if (!MACH_IS_MVME16x) 160 - return -ENODEV; 161 - 162 - pr_info("MK48T08 Real Time Clock Driver v%s\n", RTC_VERSION); 163 - return misc_register(&rtc_dev); 164 - } 165 - device_initcall(rtc_MK48T08_init);
+1
arch/sparc/kernel/time_32.c
··· 255 255 static struct m48t59_plat_data m48t59_data = { 256 256 .read_byte = mostek_read_byte, 257 257 .write_byte = mostek_write_byte, 258 + .yy_offset = 68, 258 259 }; 259 260 260 261 /* resource is set at runtime */
+1
arch/sparc/kernel/time_64.c
··· 544 544 static struct m48t59_plat_data m48t59_data = { 545 545 .read_byte = mostek_read_byte, 546 546 .write_byte = mostek_write_byte, 547 + .yy_offset = 68, 547 548 }; 548 549 549 550 static struct platform_device m48t59_rtc = {
+33
drivers/rtc/Kconfig
··· 182 182 This driver can also be built as a module. If so, the module 183 183 will be called rtc-88pm80x. 184 184 185 + config RTC_DRV_88PM886 186 + tristate "Marvell 88PM886 RTC driver" 187 + depends on MFD_88PM886_PMIC 188 + help 189 + If you say yes here you will get support for the RTC function in the 190 + Marvell 88PM886 chip. 191 + 192 + This driver can also be built as a module. If so, the module 193 + will be called rtc-88pm886. 194 + 185 195 config RTC_DRV_ABB5ZES3 186 196 select REGMAP_I2C 187 197 tristate "Abracon AB-RTCMC-32.768kHz-B5ZE-S3" ··· 506 496 507 497 config RTC_DRV_PCF8563 508 498 tristate "Philips PCF8563/Epson RTC8564" 499 + select REGMAP_I2C 509 500 help 510 501 If you say yes here you get support for the 511 502 Philips PCF8563 RTC chip. The Epson RTC8564 ··· 2016 2005 This driver can also be built as a module, if so, the module 2017 2006 will be called "rtc-ma35d1". 2018 2007 2008 + config RTC_DRV_RENESAS_RTCA3 2009 + tristate "Renesas RTCA-3 RTC" 2010 + depends on ARCH_RENESAS 2011 + help 2012 + If you say yes here you get support for the Renesas RTCA-3 RTC 2013 + available on the Renesas RZ/G3S SoC. 2014 + 2015 + This driver can also be built as a module, if so, the module 2016 + will be called "rtc-rtca3". 2017 + 2019 2018 comment "HID Sensor RTC drivers" 2020 2019 2021 2020 config RTC_DRV_HID_SENSOR_TIME ··· 2090 2069 2091 2070 This driver can also be built as a module, if so, the module 2092 2071 will be called "rtc-ssd20xd". 2072 + 2073 + config RTC_DRV_AMLOGIC_A4 2074 + tristate "Amlogic RTC" 2075 + depends on ARCH_MESON || COMPILE_TEST 2076 + select REGMAP_MMIO 2077 + default y 2078 + help 2079 + If you say yes here you get support for the RTC block on the 2080 + Amlogic A113L2(A4) and A113X2(A5) SoCs. 2081 + 2082 + This driver can also be built as a module. If so, the module 2083 + will be called "rtc-amlogic-a4". 2093 2084 2094 2085 endif # RTC_CLASS
+4 -1
drivers/rtc/Makefile
··· 21 21 22 22 obj-$(CONFIG_RTC_DRV_88PM80X) += rtc-88pm80x.o 23 23 obj-$(CONFIG_RTC_DRV_88PM860X) += rtc-88pm860x.o 24 + obj-$(CONFIG_RTC_DRV_88PM886) += rtc-88pm886.o 24 25 obj-$(CONFIG_RTC_DRV_AB8500) += rtc-ab8500.o 25 26 obj-$(CONFIG_RTC_DRV_ABB5ZES3) += rtc-ab-b5ze-s3.o 26 27 obj-$(CONFIG_RTC_DRV_ABEOZ9) += rtc-ab-eoz9.o 27 28 obj-$(CONFIG_RTC_DRV_ABX80X) += rtc-abx80x.o 28 29 obj-$(CONFIG_RTC_DRV_AC100) += rtc-ac100.o 30 + obj-$(CONFIG_RTC_DRV_AMLOGIC_A4) += rtc-amlogic-a4.o 29 31 obj-$(CONFIG_RTC_DRV_ARMADA38X) += rtc-armada38x.o 30 32 obj-$(CONFIG_RTC_DRV_AS3722) += rtc-as3722.o 31 33 obj-$(CONFIG_RTC_DRV_ASM9260) += rtc-asm9260.o ··· 160 158 obj-$(CONFIG_RTC_DRV_RX8111) += rtc-rx8111.o 161 159 obj-$(CONFIG_RTC_DRV_RX8581) += rtc-rx8581.o 162 160 obj-$(CONFIG_RTC_DRV_RZN1) += rtc-rzn1.o 161 + obj-$(CONFIG_RTC_DRV_RENESAS_RTCA3) += rtc-renesas-rtca3.o 163 162 obj-$(CONFIG_RTC_DRV_S35390A) += rtc-s35390a.o 164 163 obj-$(CONFIG_RTC_DRV_S3C) += rtc-s3c.o 165 164 obj-$(CONFIG_RTC_DRV_S5M) += rtc-s5m.o 166 165 obj-$(CONFIG_RTC_DRV_SA1100) += rtc-sa1100.o 167 166 obj-$(CONFIG_RTC_DRV_SC27XX) += rtc-sc27xx.o 168 167 obj-$(CONFIG_RTC_DRV_SD2405AL) += rtc-sd2405al.o 169 - obj-$(CONFIG_RTC_DRV_SD3078) += rtc-sd3078.o 168 + obj-$(CONFIG_RTC_DRV_SD3078) += rtc-sd3078.o 170 169 obj-$(CONFIG_RTC_DRV_SH) += rtc-sh.o 171 170 obj-$(CONFIG_RTC_DRV_SNVS) += rtc-snvs.o 172 171 obj-$(CONFIG_RTC_DRV_SPEAR) += rtc-spear.o
+6 -1
drivers/rtc/interface.c
··· 904 904 struct timerqueue_node *next; 905 905 ktime_t now; 906 906 struct rtc_time tm; 907 + int err; 907 908 908 909 struct rtc_device *rtc = 909 910 container_of(work, struct rtc_device, irqwork); 910 911 911 912 mutex_lock(&rtc->ops_lock); 912 913 again: 913 - __rtc_read_time(rtc, &tm); 914 + err = __rtc_read_time(rtc, &tm); 915 + if (err) { 916 + mutex_unlock(&rtc->ops_lock); 917 + return; 918 + } 914 919 now = rtc_tm_to_ktime(tm); 915 920 while ((next = timerqueue_getnext(&rtc->timerqueue))) { 916 921 if (next->expires > now)
+1 -1
drivers/rtc/rtc-88pm80x.c
··· 329 329 .pm = &pm80x_rtc_pm_ops, 330 330 }, 331 331 .probe = pm80x_rtc_probe, 332 - .remove_new = pm80x_rtc_remove, 332 + .remove = pm80x_rtc_remove, 333 333 }; 334 334 335 335 module_platform_driver(pm80x_rtc_driver);
+1 -1
drivers/rtc/rtc-88pm860x.c
··· 371 371 .pm = &pm860x_rtc_pm_ops, 372 372 }, 373 373 .probe = pm860x_rtc_probe, 374 - .remove_new = pm860x_rtc_remove, 374 + .remove = pm860x_rtc_remove, 375 375 }; 376 376 377 377 module_platform_driver(pm860x_rtc_driver);
+97
drivers/rtc/rtc-88pm886.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + #include <linux/limits.h> 3 + #include <linux/mod_devicetable.h> 4 + #include <linux/platform_device.h> 5 + #include <linux/rtc.h> 6 + 7 + #include <linux/mfd/88pm886.h> 8 + 9 + /* 10 + * Time is calculated as the sum of a 32-bit read-only advancing counter and a 11 + * writeable constant offset stored in the chip's spare registers. 12 + */ 13 + 14 + static int pm886_rtc_read_time(struct device *dev, struct rtc_time *tm) 15 + { 16 + struct regmap *regmap = dev_get_drvdata(dev); 17 + u32 time; 18 + u32 buf; 19 + int ret; 20 + 21 + ret = regmap_bulk_read(regmap, PM886_REG_RTC_SPARE1, &buf, 4); 22 + if (ret) 23 + return ret; 24 + time = buf; 25 + 26 + ret = regmap_bulk_read(regmap, PM886_REG_RTC_CNT1, &buf, 4); 27 + if (ret) 28 + return ret; 29 + time += buf; 30 + 31 + rtc_time64_to_tm(time, tm); 32 + 33 + return 0; 34 + } 35 + 36 + static int pm886_rtc_set_time(struct device *dev, struct rtc_time *tm) 37 + { 38 + struct regmap *regmap = dev_get_drvdata(dev); 39 + u32 buf; 40 + int ret; 41 + 42 + ret = regmap_bulk_read(regmap, PM886_REG_RTC_CNT1, &buf, 4); 43 + if (ret) 44 + return ret; 45 + 46 + buf = rtc_tm_to_time64(tm) - buf; 47 + 48 + return regmap_bulk_write(regmap, PM886_REG_RTC_SPARE1, &buf, 4); 49 + } 50 + 51 + static const struct rtc_class_ops pm886_rtc_ops = { 52 + .read_time = pm886_rtc_read_time, 53 + .set_time = pm886_rtc_set_time, 54 + }; 55 + 56 + static int pm886_rtc_probe(struct platform_device *pdev) 57 + { 58 + struct pm886_chip *chip = dev_get_drvdata(pdev->dev.parent); 59 + struct device *dev = &pdev->dev; 60 + struct rtc_device *rtc; 61 + int ret; 62 + 63 + platform_set_drvdata(pdev, chip->regmap); 64 + 65 + rtc = devm_rtc_allocate_device(dev); 66 + if (IS_ERR(rtc)) 67 + return dev_err_probe(dev, PTR_ERR(rtc), 68 + "Failed to allocate RTC device\n"); 69 + 70 + rtc->ops = &pm886_rtc_ops; 71 + rtc->range_max = U32_MAX; 72 + 73 + ret = devm_rtc_register_device(rtc); 74 + if (ret) 75 + return dev_err_probe(dev, ret, "Failed to register RTC device\n"); 76 + 77 + return 0; 78 + } 79 + 80 + static const struct platform_device_id pm886_rtc_id_table[] = { 81 + { "88pm886-rtc", }, 82 + { } 83 + }; 84 + MODULE_DEVICE_TABLE(platform, pm886_rtc_id_table); 85 + 86 + static struct platform_driver pm886_rtc_driver = { 87 + .driver = { 88 + .name = "88pm886-rtc", 89 + }, 90 + .probe = pm886_rtc_probe, 91 + .id_table = pm886_rtc_id_table, 92 + }; 93 + module_platform_driver(pm886_rtc_driver); 94 + 95 + MODULE_DESCRIPTION("Marvell 88PM886 RTC driver"); 96 + MODULE_AUTHOR("Karel Balej <balejk@matfyz.cz>"); 97 + MODULE_LICENSE("GPL");
+1 -10
drivers/rtc/rtc-ab-eoz9.c
··· 64 64 #define ABEOZ9_BIT_ALARM_MIN GENMASK(6, 0) 65 65 #define ABEOZ9_REG_ALARM_HOURS 0x12 66 66 #define ABEOZ9_BIT_ALARM_HOURS_PM BIT(5) 67 - #define ABEOZ9_BIT_ALARM_HOURS GENMASK(4, 0) 67 + #define ABEOZ9_BIT_ALARM_HOURS GENMASK(5, 0) 68 68 #define ABEOZ9_REG_ALARM_DAYS 0x13 69 69 #define ABEOZ9_BIT_ALARM_DAYS GENMASK(5, 0) 70 70 #define ABEOZ9_REG_ALARM_WEEKDAYS 0x14 ··· 231 231 alarm->time.tm_sec = bcd2bin(FIELD_GET(ABEOZ9_BIT_ALARM_SEC, regs[0])); 232 232 alarm->time.tm_min = bcd2bin(FIELD_GET(ABEOZ9_BIT_ALARM_MIN, regs[1])); 233 233 alarm->time.tm_hour = bcd2bin(FIELD_GET(ABEOZ9_BIT_ALARM_HOURS, regs[2])); 234 - if (FIELD_GET(ABEOZ9_BIT_ALARM_HOURS_PM, regs[2])) 235 - alarm->time.tm_hour += 12; 236 234 237 235 alarm->time.tm_mday = bcd2bin(FIELD_GET(ABEOZ9_BIT_ALARM_DAYS, regs[3])); 238 236 ··· 393 395 ret = regmap_read(regmap, ABEOZ9_REG_CTRL_STATUS, &val); 394 396 if (ret < 0) 395 397 return ret; 396 - 397 - if ((val & ABEOZ9_REG_CTRL_STATUS_V1F) || 398 - (val & ABEOZ9_REG_CTRL_STATUS_V2F)) { 399 - dev_err(dev, 400 - "thermometer might be disabled due to low voltage\n"); 401 - return -EINVAL; 402 - } 403 398 404 399 switch (attr) { 405 400 case hwmon_temp_input:
+1 -1
drivers/rtc/rtc-ab8500.c
··· 403 403 .name = "ab8500-rtc", 404 404 }, 405 405 .probe = ab8500_rtc_probe, 406 - .remove_new = ab8500_rtc_remove, 406 + .remove = ab8500_rtc_remove, 407 407 .id_table = ab85xx_rtc_ids, 408 408 }; 409 409
+1 -1
drivers/rtc/rtc-abx80x.c
··· 39 39 #define ABX8XX_REG_STATUS 0x0f 40 40 #define ABX8XX_STATUS_AF BIT(2) 41 41 #define ABX8XX_STATUS_BLF BIT(4) 42 - #define ABX8XX_STATUS_WDT BIT(6) 42 + #define ABX8XX_STATUS_WDT BIT(5) 43 43 44 44 #define ABX8XX_REG_CTRL1 0x10 45 45 #define ABX8XX_CTRL_WRITE BIT(0)
+1 -1
drivers/rtc/rtc-ac100.c
··· 628 628 629 629 static struct platform_driver ac100_rtc_driver = { 630 630 .probe = ac100_rtc_probe, 631 - .remove_new = ac100_rtc_remove, 631 + .remove = ac100_rtc_remove, 632 632 .driver = { 633 633 .name = "ac100-rtc", 634 634 .of_match_table = of_match_ptr(ac100_rtc_match),
+465
drivers/rtc/rtc-amlogic-a4.c
··· 1 + // SPDX-License-Identifier: (GPL-2.0-only OR MIT) 2 + /* 3 + * Copyright (C) 2024 Amlogic, Inc. All rights reserved 4 + * Author: Yiting Deng <yiting.deng@amlogic.com> 5 + */ 6 + 7 + #include <linux/bitfield.h> 8 + #include <linux/clk.h> 9 + #include <linux/clk-provider.h> 10 + #include <linux/delay.h> 11 + #include <linux/module.h> 12 + #include <linux/platform_device.h> 13 + #include <linux/regmap.h> 14 + #include <linux/rtc.h> 15 + #include <linux/time64.h> 16 + 17 + /* rtc oscillator rate */ 18 + #define OSC_32K 32768 19 + #define OSC_24M 24000000 20 + 21 + #define RTC_CTRL (0x0 << 2) /* Control RTC */ 22 + #define RTC_ALRM0_EN BIT(0) 23 + #define RTC_OSC_SEL BIT(8) 24 + #define RTC_ENABLE BIT(12) 25 + 26 + #define RTC_COUNTER_REG (0x1 << 2) /* Program RTC counter initial value */ 27 + 28 + #define RTC_ALARM0_REG (0x2 << 2) /* Program RTC alarm0 value */ 29 + 30 + #define RTC_SEC_ADJUST_REG (0x6 << 2) /* Control second-based timing adjustment */ 31 + #define RTC_MATCH_COUNTER GENMASK(18, 0) 32 + #define RTC_SEC_ADJUST_CTRL GENMASK(20, 19) 33 + #define RTC_ADJ_VALID BIT(23) 34 + 35 + #define RTC_INT_MASK (0x8 << 2) /* RTC interrupt mask */ 36 + #define RTC_ALRM0_IRQ_MSK BIT(0) 37 + 38 + #define RTC_INT_CLR (0x9 << 2) /* Clear RTC interrupt */ 39 + #define RTC_ALRM0_IRQ_CLR BIT(0) 40 + 41 + #define RTC_OSCIN_CTRL0 (0xa << 2) /* Control RTC clk from 24M */ 42 + #define RTC_OSCIN_CTRL1 (0xb << 2) /* Control RTC clk from 24M */ 43 + #define RTC_OSCIN_IN_EN BIT(31) 44 + #define RTC_OSCIN_OUT_CFG GENMASK(29, 28) 45 + #define RTC_OSCIN_OUT_N0M0 GENMASK(11, 0) 46 + #define RTC_OSCIN_OUT_N1M1 GENMASK(23, 12) 47 + 48 + #define RTC_INT_STATUS (0xc << 2) /* RTC interrupt status */ 49 + #define RTC_ALRM0_IRQ_STATUS BIT(0) 50 + 51 + #define RTC_REAL_TIME (0xd << 2) /* RTC time value */ 52 + 53 + #define RTC_OSCIN_OUT_32K_N0 0x2dc 54 + #define RTC_OSCIN_OUT_32K_N1 0x2db 55 + #define RTC_OSCIN_OUT_32K_M0 0x1 56 + #define RTC_OSCIN_OUT_32K_M1 0x2 57 + 58 + #define RTC_SWALLOW_SECOND 0x2 59 + #define RTC_INSERT_SECOND 0x3 60 + 61 + struct aml_rtc_config { 62 + bool gray_stored; 63 + }; 64 + 65 + struct aml_rtc_data { 66 + struct regmap *map; 67 + struct rtc_device *rtc_dev; 68 + int irq; 69 + struct clk *rtc_clk; 70 + struct clk *sys_clk; 71 + int rtc_enabled; 72 + const struct aml_rtc_config *config; 73 + }; 74 + 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 + 82 + static inline u32 gray_to_binary(u32 gray) 83 + { 84 + u32 bcd = gray; 85 + int size = sizeof(bcd) * 8; 86 + int i; 87 + 88 + for (i = 0; (1 << i) < size; i++) 89 + bcd ^= bcd >> (1 << i); 90 + 91 + return bcd; 92 + } 93 + 94 + static inline u32 binary_to_gray(u32 bcd) 95 + { 96 + return bcd ^ (bcd >> 1); 97 + } 98 + 99 + static int aml_rtc_read_time(struct device *dev, struct rtc_time *tm) 100 + { 101 + struct aml_rtc_data *rtc = dev_get_drvdata(dev); 102 + u32 time_sec; 103 + 104 + /* if RTC disabled, read time failed */ 105 + if (!rtc->rtc_enabled) 106 + return -EINVAL; 107 + 108 + regmap_read(rtc->map, RTC_REAL_TIME, &time_sec); 109 + if (rtc->config->gray_stored) 110 + time_sec = gray_to_binary(time_sec); 111 + rtc_time64_to_tm(time_sec, tm); 112 + dev_dbg(dev, "%s: read time = %us\n", __func__, time_sec); 113 + 114 + return 0; 115 + } 116 + 117 + static int aml_rtc_set_time(struct device *dev, struct rtc_time *tm) 118 + { 119 + struct aml_rtc_data *rtc = dev_get_drvdata(dev); 120 + u32 time_sec; 121 + 122 + /* if RTC disabled, first enable it */ 123 + if (!rtc->rtc_enabled) { 124 + regmap_write_bits(rtc->map, RTC_CTRL, RTC_ENABLE, RTC_ENABLE); 125 + usleep_range(100, 200); 126 + rtc->rtc_enabled = regmap_test_bits(rtc->map, RTC_CTRL, RTC_ENABLE); 127 + if (!rtc->rtc_enabled) 128 + return -EINVAL; 129 + } 130 + 131 + time_sec = rtc_tm_to_time64(tm); 132 + if (rtc->config->gray_stored) 133 + time_sec = binary_to_gray(time_sec); 134 + regmap_write(rtc->map, RTC_COUNTER_REG, time_sec); 135 + dev_dbg(dev, "%s: set time = %us\n", __func__, time_sec); 136 + 137 + return 0; 138 + } 139 + 140 + static int aml_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) 141 + { 142 + struct aml_rtc_data *rtc = dev_get_drvdata(dev); 143 + time64_t alarm_sec; 144 + 145 + /* if RTC disabled, set alarm failed */ 146 + if (!rtc->rtc_enabled) 147 + return -EINVAL; 148 + 149 + regmap_update_bits(rtc->map, RTC_CTRL, 150 + RTC_ALRM0_EN, RTC_ALRM0_EN); 151 + regmap_update_bits(rtc->map, RTC_INT_MASK, 152 + RTC_ALRM0_IRQ_MSK, 0); 153 + 154 + alarm_sec = rtc_tm_to_time64(&alarm->time); 155 + if (rtc->config->gray_stored) 156 + alarm_sec = binary_to_gray(alarm_sec); 157 + regmap_write(rtc->map, RTC_ALARM0_REG, alarm_sec); 158 + 159 + dev_dbg(dev, "%s: alarm->enabled=%d alarm_set=%llds\n", __func__, 160 + alarm->enabled, alarm_sec); 161 + 162 + return 0; 163 + } 164 + 165 + static int aml_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) 166 + { 167 + struct aml_rtc_data *rtc = dev_get_drvdata(dev); 168 + u32 alarm_sec; 169 + int alarm_enable; 170 + int alarm_mask; 171 + 172 + /* if RTC disabled, read alarm failed */ 173 + if (!rtc->rtc_enabled) 174 + return -EINVAL; 175 + 176 + regmap_read(rtc->map, RTC_ALARM0_REG, &alarm_sec); 177 + if (rtc->config->gray_stored) 178 + alarm_sec = gray_to_binary(alarm_sec); 179 + rtc_time64_to_tm(alarm_sec, &alarm->time); 180 + 181 + alarm_enable = regmap_test_bits(rtc->map, RTC_CTRL, RTC_ALRM0_EN); 182 + alarm_mask = regmap_test_bits(rtc->map, RTC_INT_MASK, RTC_ALRM0_IRQ_MSK); 183 + alarm->enabled = (alarm_enable && !alarm_mask) ? 1 : 0; 184 + dev_dbg(dev, "%s: alarm->enabled=%d alarm=%us\n", __func__, 185 + alarm->enabled, alarm_sec); 186 + 187 + return 0; 188 + } 189 + 190 + static int aml_rtc_read_offset(struct device *dev, long *offset) 191 + { 192 + struct aml_rtc_data *rtc = dev_get_drvdata(dev); 193 + u32 reg_val; 194 + long val; 195 + int sign, match_counter, enable; 196 + 197 + /* if RTC disabled, read offset failed */ 198 + if (!rtc->rtc_enabled) 199 + return -EINVAL; 200 + 201 + regmap_read(rtc->map, RTC_SEC_ADJUST_REG, &reg_val); 202 + enable = FIELD_GET(RTC_ADJ_VALID, reg_val); 203 + if (!enable) { 204 + val = 0; 205 + } else { 206 + sign = FIELD_GET(RTC_SEC_ADJUST_CTRL, reg_val); 207 + match_counter = FIELD_GET(RTC_MATCH_COUNTER, reg_val); 208 + val = 1000000000 / (match_counter + 1); 209 + if (sign == RTC_SWALLOW_SECOND) 210 + val = -val; 211 + } 212 + *offset = val; 213 + 214 + return 0; 215 + } 216 + 217 + static int aml_rtc_set_offset(struct device *dev, long offset) 218 + { 219 + struct aml_rtc_data *rtc = dev_get_drvdata(dev); 220 + int sign = 0; 221 + int match_counter = 0; 222 + int enable = 0; 223 + u32 reg_val; 224 + 225 + /* if RTC disabled, set offset failed */ 226 + if (!rtc->rtc_enabled) 227 + return -EINVAL; 228 + 229 + if (offset) { 230 + enable = 1; 231 + sign = offset < 0 ? RTC_SWALLOW_SECOND : RTC_INSERT_SECOND; 232 + match_counter = 1000000000 / abs(offset) - 1; 233 + if (match_counter < 0 || match_counter > RTC_MATCH_COUNTER) 234 + return -EINVAL; 235 + } 236 + 237 + reg_val = FIELD_PREP(RTC_ADJ_VALID, enable) | 238 + FIELD_PREP(RTC_SEC_ADJUST_CTRL, sign) | 239 + FIELD_PREP(RTC_MATCH_COUNTER, match_counter); 240 + regmap_write(rtc->map, RTC_SEC_ADJUST_REG, reg_val); 241 + 242 + return 0; 243 + } 244 + 245 + static int aml_rtc_alarm_enable(struct device *dev, unsigned int enabled) 246 + { 247 + struct aml_rtc_data *rtc = dev_get_drvdata(dev); 248 + 249 + if (enabled) { 250 + regmap_update_bits(rtc->map, RTC_CTRL, 251 + RTC_ALRM0_EN, RTC_ALRM0_EN); 252 + regmap_update_bits(rtc->map, RTC_INT_MASK, 253 + RTC_ALRM0_IRQ_MSK, 0); 254 + } else { 255 + regmap_update_bits(rtc->map, RTC_INT_MASK, 256 + RTC_ALRM0_IRQ_MSK, RTC_ALRM0_IRQ_MSK); 257 + regmap_update_bits(rtc->map, RTC_CTRL, 258 + RTC_ALRM0_EN, 0); 259 + } 260 + 261 + return 0; 262 + } 263 + 264 + static const struct rtc_class_ops aml_rtc_ops = { 265 + .read_time = aml_rtc_read_time, 266 + .set_time = aml_rtc_set_time, 267 + .read_alarm = aml_rtc_read_alarm, 268 + .set_alarm = aml_rtc_set_alarm, 269 + .alarm_irq_enable = aml_rtc_alarm_enable, 270 + .read_offset = aml_rtc_read_offset, 271 + .set_offset = aml_rtc_set_offset, 272 + }; 273 + 274 + static irqreturn_t aml_rtc_handler(int irq, void *data) 275 + { 276 + struct aml_rtc_data *rtc = (struct aml_rtc_data *)data; 277 + 278 + regmap_write(rtc->map, RTC_ALARM0_REG, 0); 279 + regmap_write(rtc->map, RTC_INT_CLR, RTC_ALRM0_IRQ_STATUS); 280 + 281 + rtc_update_irq(rtc->rtc_dev, 1, RTC_AF | RTC_IRQF); 282 + 283 + return IRQ_HANDLED; 284 + } 285 + 286 + static void aml_rtc_init(struct aml_rtc_data *rtc) 287 + { 288 + u32 reg_val = 0; 289 + 290 + rtc->rtc_enabled = regmap_test_bits(rtc->map, RTC_CTRL, RTC_ENABLE); 291 + if (!rtc->rtc_enabled) { 292 + if (clk_get_rate(rtc->rtc_clk) == OSC_24M) { 293 + /* select 24M oscillator */ 294 + regmap_write_bits(rtc->map, RTC_CTRL, RTC_OSC_SEL, RTC_OSC_SEL); 295 + 296 + /* 297 + * Set RTC oscillator to freq_out to freq_in/((N0*M0+N1*M1)/(M0+M1)) 298 + * Enable clock_in gate of oscillator 24MHz 299 + * Set N0 to 733, N1 to 732 300 + */ 301 + reg_val = FIELD_PREP(RTC_OSCIN_IN_EN, 1) 302 + | FIELD_PREP(RTC_OSCIN_OUT_CFG, 1) 303 + | FIELD_PREP(RTC_OSCIN_OUT_N0M0, RTC_OSCIN_OUT_32K_N0) 304 + | FIELD_PREP(RTC_OSCIN_OUT_N1M1, RTC_OSCIN_OUT_32K_N1); 305 + regmap_write_bits(rtc->map, RTC_OSCIN_CTRL0, RTC_OSCIN_IN_EN 306 + | RTC_OSCIN_OUT_CFG | RTC_OSCIN_OUT_N0M0 307 + | RTC_OSCIN_OUT_N1M1, reg_val); 308 + 309 + /* Set M0 to 2, M1 to 3, so freq_out = 32768 Hz*/ 310 + reg_val = FIELD_PREP(RTC_OSCIN_OUT_N0M0, RTC_OSCIN_OUT_32K_M0) 311 + | FIELD_PREP(RTC_OSCIN_OUT_N1M1, RTC_OSCIN_OUT_32K_M1); 312 + regmap_write_bits(rtc->map, RTC_OSCIN_CTRL1, RTC_OSCIN_OUT_N0M0 313 + | RTC_OSCIN_OUT_N1M1, reg_val); 314 + } else { 315 + /* select 32K oscillator */ 316 + regmap_write_bits(rtc->map, RTC_CTRL, RTC_OSC_SEL, 0); 317 + } 318 + } 319 + regmap_write_bits(rtc->map, RTC_INT_MASK, 320 + RTC_ALRM0_IRQ_MSK, RTC_ALRM0_IRQ_MSK); 321 + regmap_write_bits(rtc->map, RTC_CTRL, RTC_ALRM0_EN, 0); 322 + } 323 + 324 + static int aml_rtc_probe(struct platform_device *pdev) 325 + { 326 + struct device *dev = &pdev->dev; 327 + struct aml_rtc_data *rtc; 328 + void __iomem *base; 329 + int ret = 0; 330 + 331 + rtc = devm_kzalloc(dev, sizeof(*rtc), GFP_KERNEL); 332 + if (!rtc) 333 + return -ENOMEM; 334 + 335 + rtc->config = of_device_get_match_data(dev); 336 + if (!rtc->config) 337 + return -ENODEV; 338 + 339 + base = devm_platform_ioremap_resource(pdev, 0); 340 + if (IS_ERR(base)) 341 + return dev_err_probe(dev, PTR_ERR(base), "resource ioremap failed\n"); 342 + 343 + rtc->map = devm_regmap_init_mmio(dev, base, &aml_rtc_regmap_config); 344 + if (IS_ERR(rtc->map)) 345 + return dev_err_probe(dev, PTR_ERR(rtc->map), "regmap init failed\n"); 346 + 347 + rtc->irq = platform_get_irq(pdev, 0); 348 + if (rtc->irq < 0) 349 + return rtc->irq; 350 + 351 + rtc->rtc_clk = devm_clk_get(dev, "osc"); 352 + if (IS_ERR(rtc->rtc_clk)) 353 + return dev_err_probe(dev, PTR_ERR(rtc->rtc_clk), 354 + "failed to find rtc clock\n"); 355 + if (clk_get_rate(rtc->rtc_clk) != OSC_32K && clk_get_rate(rtc->rtc_clk) != OSC_24M) 356 + return dev_err_probe(dev, -EINVAL, "Invalid clock configuration\n"); 357 + 358 + rtc->sys_clk = devm_clk_get_enabled(dev, "sys"); 359 + if (IS_ERR(rtc->sys_clk)) 360 + return dev_err_probe(dev, PTR_ERR(rtc->sys_clk), 361 + "failed to get_enable rtc sys clk\n"); 362 + aml_rtc_init(rtc); 363 + 364 + device_init_wakeup(dev, 1); 365 + platform_set_drvdata(pdev, rtc); 366 + 367 + rtc->rtc_dev = devm_rtc_allocate_device(dev); 368 + if (IS_ERR(rtc->rtc_dev)) { 369 + ret = PTR_ERR(rtc->rtc_dev); 370 + goto err_clk; 371 + } 372 + 373 + ret = devm_request_irq(dev, rtc->irq, aml_rtc_handler, 374 + IRQF_ONESHOT, "aml-rtc alarm", rtc); 375 + if (ret) { 376 + dev_err_probe(dev, ret, "IRQ%d request failed, ret = %d\n", 377 + rtc->irq, ret); 378 + goto err_clk; 379 + } 380 + 381 + rtc->rtc_dev->ops = &aml_rtc_ops; 382 + rtc->rtc_dev->range_min = 0; 383 + rtc->rtc_dev->range_max = U32_MAX; 384 + 385 + ret = devm_rtc_register_device(rtc->rtc_dev); 386 + if (ret) { 387 + dev_err_probe(&pdev->dev, ret, "Failed to register RTC device: %d\n", ret); 388 + goto err_clk; 389 + } 390 + 391 + return 0; 392 + err_clk: 393 + clk_disable_unprepare(rtc->sys_clk); 394 + device_init_wakeup(dev, 0); 395 + 396 + return ret; 397 + } 398 + 399 + #ifdef CONFIG_PM_SLEEP 400 + static int aml_rtc_suspend(struct device *dev) 401 + { 402 + struct aml_rtc_data *rtc = dev_get_drvdata(dev); 403 + 404 + if (device_may_wakeup(dev)) 405 + enable_irq_wake(rtc->irq); 406 + 407 + return 0; 408 + } 409 + 410 + static int aml_rtc_resume(struct device *dev) 411 + { 412 + struct aml_rtc_data *rtc = dev_get_drvdata(dev); 413 + 414 + if (device_may_wakeup(dev)) 415 + disable_irq_wake(rtc->irq); 416 + 417 + return 0; 418 + } 419 + #endif 420 + 421 + static SIMPLE_DEV_PM_OPS(aml_rtc_pm_ops, 422 + aml_rtc_suspend, aml_rtc_resume); 423 + 424 + static void aml_rtc_remove(struct platform_device *pdev) 425 + { 426 + struct aml_rtc_data *rtc = dev_get_drvdata(&pdev->dev); 427 + 428 + clk_disable_unprepare(rtc->sys_clk); 429 + device_init_wakeup(&pdev->dev, 0); 430 + } 431 + 432 + static const struct aml_rtc_config a5_rtc_config = { 433 + }; 434 + 435 + static const struct aml_rtc_config a4_rtc_config = { 436 + .gray_stored = true, 437 + }; 438 + 439 + static const struct of_device_id aml_rtc_device_id[] = { 440 + { 441 + .compatible = "amlogic,a4-rtc", 442 + .data = &a4_rtc_config, 443 + }, 444 + { 445 + .compatible = "amlogic,a5-rtc", 446 + .data = &a5_rtc_config, 447 + }, 448 + { } 449 + }; 450 + MODULE_DEVICE_TABLE(of, aml_rtc_device_id); 451 + 452 + static struct platform_driver aml_rtc_driver = { 453 + .probe = aml_rtc_probe, 454 + .remove = aml_rtc_remove, 455 + .driver = { 456 + .name = "aml-rtc", 457 + .pm = &aml_rtc_pm_ops, 458 + .of_match_table = aml_rtc_device_id, 459 + }, 460 + }; 461 + 462 + module_platform_driver(aml_rtc_driver); 463 + MODULE_DESCRIPTION("Amlogic RTC driver"); 464 + MODULE_AUTHOR("Yiting Deng <yiting.deng@amlogic.com>"); 465 + MODULE_LICENSE("GPL");
+1 -1
drivers/rtc/rtc-asm9260.c
··· 325 325 326 326 static struct platform_driver asm9260_rtc_driver = { 327 327 .probe = asm9260_rtc_probe, 328 - .remove_new = asm9260_rtc_remove, 328 + .remove = asm9260_rtc_remove, 329 329 .driver = { 330 330 .name = "asm9260-rtc", 331 331 .of_match_table = asm9260_dt_ids,
+1 -1
drivers/rtc/rtc-at91rm9200.c
··· 640 640 * triggering a section mismatch warning. 641 641 */ 642 642 static struct platform_driver at91_rtc_driver __refdata = { 643 - .remove_new = __exit_p(at91_rtc_remove), 643 + .remove = __exit_p(at91_rtc_remove), 644 644 .shutdown = at91_rtc_shutdown, 645 645 .driver = { 646 646 .name = "at91_rtc",
+1 -1
drivers/rtc/rtc-at91sam9.c
··· 530 530 531 531 static struct platform_driver at91_rtc_driver = { 532 532 .probe = at91_rtc_probe, 533 - .remove_new = at91_rtc_remove, 533 + .remove = at91_rtc_remove, 534 534 .shutdown = at91_rtc_shutdown, 535 535 .driver = { 536 536 .name = "rtc-at91sam9",
+1 -2
drivers/rtc/rtc-brcmstb-waketimer.c
··· 17 17 #include <linux/of.h> 18 18 #include <linux/platform_device.h> 19 19 #include <linux/pm.h> 20 - #include <linux/pm_wakeup.h> 21 20 #include <linux/reboot.h> 22 21 #include <linux/rtc.h> 23 22 #include <linux/stat.h> ··· 416 417 417 418 static struct platform_driver brcmstb_waketmr_driver = { 418 419 .probe = brcmstb_waketmr_probe, 419 - .remove_new = brcmstb_waketmr_remove, 420 + .remove = brcmstb_waketmr_remove, 420 421 .driver = { 421 422 .name = "brcmstb-waketimer", 422 423 .pm = &brcmstb_waketmr_pm_ops,
+1 -1
drivers/rtc/rtc-cadence.c
··· 402 402 .pm = &cdns_rtc_pm_ops, 403 403 }, 404 404 .probe = cdns_rtc_probe, 405 - .remove_new = cdns_rtc_remove, 405 + .remove = cdns_rtc_remove, 406 406 }; 407 407 module_platform_driver(cdns_rtc_driver); 408 408
+19 -20
drivers/rtc/rtc-cmos.c
··· 645 645 unsigned char *buf = val; 646 646 647 647 off += NVRAM_OFFSET; 648 - spin_lock_irq(&rtc_lock); 649 - for (; count; count--, off++) { 648 + for (; count; count--, off++, buf++) { 649 + guard(spinlock_irq)(&rtc_lock); 650 650 if (off < 128) 651 - *buf++ = CMOS_READ(off); 651 + *buf = CMOS_READ(off); 652 652 else if (can_bank2) 653 - *buf++ = cmos_read_bank2(off); 653 + *buf = cmos_read_bank2(off); 654 654 else 655 - break; 655 + return -EIO; 656 656 } 657 - spin_unlock_irq(&rtc_lock); 658 657 659 - return count ? -EIO : 0; 658 + return 0; 660 659 } 661 660 662 661 static int cmos_nvram_write(void *priv, unsigned int off, void *val, ··· 670 671 * NVRAM to update, updating checksums is also part of its job. 671 672 */ 672 673 off += NVRAM_OFFSET; 673 - spin_lock_irq(&rtc_lock); 674 - for (; count; count--, off++) { 674 + for (; count; count--, off++, buf++) { 675 675 /* don't trash RTC registers */ 676 676 if (off == cmos->day_alrm 677 677 || off == cmos->mon_alrm 678 678 || off == cmos->century) 679 - buf++; 680 - else if (off < 128) 681 - CMOS_WRITE(*buf++, off); 682 - else if (can_bank2) 683 - cmos_write_bank2(*buf++, off); 684 - else 685 - break; 686 - } 687 - spin_unlock_irq(&rtc_lock); 679 + continue; 688 680 689 - return count ? -EIO : 0; 681 + guard(spinlock_irq)(&rtc_lock); 682 + if (off < 128) 683 + CMOS_WRITE(*buf, off); 684 + else if (can_bank2) 685 + cmos_write_bank2(*buf, off); 686 + else 687 + return -EIO; 688 + } 689 + 690 + return 0; 690 691 } 691 692 692 693 /*----------------------------------------------------------------*/ ··· 1527 1528 MODULE_ALIAS("platform:rtc_cmos"); 1528 1529 1529 1530 static struct platform_driver cmos_platform_driver = { 1530 - .remove_new = cmos_platform_remove, 1531 + .remove = cmos_platform_remove, 1531 1532 .shutdown = cmos_platform_shutdown, 1532 1533 .driver = { 1533 1534 .name = driver_name,
+1 -1
drivers/rtc/rtc-cros-ec.c
··· 401 401 402 402 static struct platform_driver cros_ec_rtc_driver = { 403 403 .probe = cros_ec_rtc_probe, 404 - .remove_new = cros_ec_rtc_remove, 404 + .remove = cros_ec_rtc_remove, 405 405 .driver = { 406 406 .name = DRV_NAME, 407 407 .pm = &cros_ec_rtc_pm_ops,
+1 -1
drivers/rtc/rtc-ds1685.c
··· 1354 1354 .name = "rtc-ds1685", 1355 1355 }, 1356 1356 .probe = ds1685_rtc_probe, 1357 - .remove_new = ds1685_rtc_remove, 1357 + .remove = ds1685_rtc_remove, 1358 1358 }; 1359 1359 module_platform_driver(ds1685_rtc_driver); 1360 1360 /* ----------------------------------------------------------------------- */
+1 -1
drivers/rtc/rtc-ftrtc010.c
··· 214 214 .of_match_table = ftrtc010_rtc_dt_match, 215 215 }, 216 216 .probe = ftrtc010_rtc_probe, 217 - .remove_new = ftrtc010_rtc_remove, 217 + .remove = ftrtc010_rtc_remove, 218 218 }; 219 219 220 220 module_platform_driver_probe(ftrtc010_rtc_driver, ftrtc010_rtc_probe);
+1 -1
drivers/rtc/rtc-hid-sensor-time.c
··· 319 319 .name = KBUILD_MODNAME, 320 320 }, 321 321 .probe = hid_time_probe, 322 - .remove_new = hid_time_remove, 322 + .remove = hid_time_remove, 323 323 }; 324 324 module_platform_driver(hid_time_platform_driver); 325 325
+1 -1
drivers/rtc/rtc-imxdi.c
··· 860 860 .name = "imxdi_rtc", 861 861 .of_match_table = dryice_dt_ids, 862 862 }, 863 - .remove_new = __exit_p(dryice_rtc_remove), 863 + .remove = __exit_p(dryice_rtc_remove), 864 864 }; 865 865 866 866 module_platform_driver_probe(dryice_rtc_driver, dryice_rtc_probe);
+254 -17
drivers/rtc/rtc-isl12022.c
··· 21 21 22 22 #include <asm/byteorder.h> 23 23 24 - /* ISL register offsets */ 24 + /* RTC - Real time clock registers */ 25 25 #define ISL12022_REG_SC 0x00 26 26 #define ISL12022_REG_MN 0x01 27 27 #define ISL12022_REG_HR 0x02 ··· 30 30 #define ISL12022_REG_YR 0x05 31 31 #define ISL12022_REG_DW 0x06 32 32 33 + /* CSR - Control and status registers */ 33 34 #define ISL12022_REG_SR 0x07 34 35 #define ISL12022_REG_INT 0x08 35 - 36 36 #define ISL12022_REG_PWR_VBAT 0x0a 37 - 38 37 #define ISL12022_REG_BETA 0x0d 38 + 39 + /* ALARM - Alarm registers */ 40 + #define ISL12022_REG_SCA0 0x10 41 + #define ISL12022_REG_MNA0 0x11 42 + #define ISL12022_REG_HRA0 0x12 43 + #define ISL12022_REG_DTA0 0x13 44 + #define ISL12022_REG_MOA0 0x14 45 + #define ISL12022_REG_DWA0 0x15 46 + #define ISL12022_ALARM ISL12022_REG_SCA0 47 + #define ISL12022_ALARM_LEN (ISL12022_REG_DWA0 - ISL12022_REG_SCA0 + 1) 48 + 49 + /* TEMP - Temperature sensor registers */ 39 50 #define ISL12022_REG_TEMP_L 0x28 40 51 41 52 /* ISL register bits */ 42 53 #define ISL12022_HR_MIL (1 << 7) /* military or 24 hour time */ 43 54 55 + #define ISL12022_SR_ALM (1 << 4) 44 56 #define ISL12022_SR_LBAT85 (1 << 2) 45 57 #define ISL12022_SR_LBAT75 (1 << 1) 46 58 59 + #define ISL12022_INT_ARST (1 << 7) 47 60 #define ISL12022_INT_WRTC (1 << 6) 61 + #define ISL12022_INT_IM (1 << 5) 62 + #define ISL12022_INT_FOBATB (1 << 4) 48 63 #define ISL12022_INT_FO_MASK GENMASK(3, 0) 49 64 #define ISL12022_INT_FO_OFF 0x0 50 65 #define ISL12022_INT_FO_32K 0x1 ··· 67 52 #define ISL12022_REG_VB85_MASK GENMASK(5, 3) 68 53 #define ISL12022_REG_VB75_MASK GENMASK(2, 0) 69 54 55 + #define ISL12022_ALARM_ENABLE (1 << 7) /* for all ALARM registers */ 56 + 70 57 #define ISL12022_BETA_TSE (1 << 7) 58 + 59 + static struct i2c_driver isl12022_driver; 60 + 61 + struct isl12022 { 62 + struct rtc_device *rtc; 63 + struct regmap *regmap; 64 + int irq; 65 + bool irq_enabled; 66 + }; 71 67 72 68 static umode_t isl12022_hwmon_is_visible(const void *data, 73 69 enum hwmon_sensor_types type, ··· 142 116 143 117 static void isl12022_hwmon_register(struct device *dev) 144 118 { 145 - struct regmap *regmap = dev_get_drvdata(dev); 119 + struct isl12022 *isl12022 = dev_get_drvdata(dev); 120 + struct regmap *regmap = isl12022->regmap; 146 121 struct device *hwmon; 147 122 int ret; 148 123 ··· 170 143 */ 171 144 static int isl12022_rtc_read_time(struct device *dev, struct rtc_time *tm) 172 145 { 173 - struct regmap *regmap = dev_get_drvdata(dev); 174 - uint8_t buf[ISL12022_REG_INT + 1]; 146 + struct isl12022 *isl12022 = dev_get_drvdata(dev); 147 + struct regmap *regmap = isl12022->regmap; 148 + u8 buf[ISL12022_REG_INT + 1]; 175 149 int ret; 176 150 177 151 ret = regmap_bulk_read(regmap, ISL12022_REG_SC, buf, sizeof(buf)); ··· 206 178 207 179 static int isl12022_rtc_set_time(struct device *dev, struct rtc_time *tm) 208 180 { 209 - struct regmap *regmap = dev_get_drvdata(dev); 181 + struct isl12022 *isl12022 = dev_get_drvdata(dev); 182 + struct regmap *regmap = isl12022->regmap; 210 183 int ret; 211 - uint8_t buf[ISL12022_REG_DW + 1]; 184 + u8 buf[ISL12022_REG_DW + 1]; 212 185 213 186 dev_dbg(dev, "%s: %ptR\n", __func__, tm); 214 187 ··· 237 208 return regmap_bulk_write(regmap, ISL12022_REG_SC, buf, sizeof(buf)); 238 209 } 239 210 211 + static int isl12022_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) 212 + { 213 + struct rtc_time *tm = &alarm->time; 214 + struct isl12022 *isl12022 = dev_get_drvdata(dev); 215 + struct regmap *regmap = isl12022->regmap; 216 + u8 buf[ISL12022_ALARM_LEN]; 217 + unsigned int i, yr; 218 + int ret; 219 + 220 + ret = regmap_bulk_read(regmap, ISL12022_ALARM, buf, sizeof(buf)); 221 + if (ret) { 222 + dev_dbg(dev, "%s: reading ALARM registers failed\n", 223 + __func__); 224 + return ret; 225 + } 226 + 227 + /* The alarm doesn't store the year so get it from the rtc section */ 228 + ret = regmap_read(regmap, ISL12022_REG_YR, &yr); 229 + if (ret) { 230 + dev_dbg(dev, "%s: reading YR register failed\n", __func__); 231 + return ret; 232 + } 233 + 234 + dev_dbg(dev, 235 + "%s: sc=%02x, mn=%02x, hr=%02x, dt=%02x, mo=%02x, dw=%02x yr=%u\n", 236 + __func__, buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], yr); 237 + 238 + tm->tm_sec = bcd2bin(buf[ISL12022_REG_SCA0 - ISL12022_ALARM] & 0x7F); 239 + tm->tm_min = bcd2bin(buf[ISL12022_REG_MNA0 - ISL12022_ALARM] & 0x7F); 240 + tm->tm_hour = bcd2bin(buf[ISL12022_REG_HRA0 - ISL12022_ALARM] & 0x3F); 241 + tm->tm_mday = bcd2bin(buf[ISL12022_REG_DTA0 - ISL12022_ALARM] & 0x3F); 242 + tm->tm_mon = bcd2bin(buf[ISL12022_REG_MOA0 - ISL12022_ALARM] & 0x1F) - 1; 243 + tm->tm_wday = buf[ISL12022_REG_DWA0 - ISL12022_ALARM] & 0x07; 244 + tm->tm_year = bcd2bin(yr) + 100; 245 + 246 + for (i = 0; i < ISL12022_ALARM_LEN; i++) { 247 + if (buf[i] & ISL12022_ALARM_ENABLE) { 248 + alarm->enabled = 1; 249 + break; 250 + } 251 + } 252 + 253 + dev_dbg(dev, "%s: %ptR\n", __func__, tm); 254 + 255 + return 0; 256 + } 257 + 258 + static int isl12022_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) 259 + { 260 + struct rtc_time *alarm_tm = &alarm->time; 261 + struct isl12022 *isl12022 = dev_get_drvdata(dev); 262 + struct regmap *regmap = isl12022->regmap; 263 + u8 regs[ISL12022_ALARM_LEN] = { 0, }; 264 + struct rtc_time rtc_tm; 265 + int ret, enable, dw; 266 + 267 + ret = isl12022_rtc_read_time(dev, &rtc_tm); 268 + if (ret) 269 + return ret; 270 + 271 + /* If the alarm time is before the current time disable the alarm */ 272 + if (!alarm->enabled || rtc_tm_sub(alarm_tm, &rtc_tm) <= 0) 273 + enable = 0; 274 + else 275 + enable = ISL12022_ALARM_ENABLE; 276 + 277 + /* 278 + * Set non-matching day of the week to safeguard against early false 279 + * matching while setting all the alarm registers (this rtc lacks a 280 + * general alarm/irq enable/disable bit). 281 + */ 282 + ret = regmap_read(regmap, ISL12022_REG_DW, &dw); 283 + if (ret) { 284 + dev_dbg(dev, "%s: reading DW failed\n", __func__); 285 + return ret; 286 + } 287 + /* ~4 days into the future should be enough to avoid match */ 288 + dw = ((dw + 4) % 7) | ISL12022_ALARM_ENABLE; 289 + ret = regmap_write(regmap, ISL12022_REG_DWA0, dw); 290 + if (ret) { 291 + dev_dbg(dev, "%s: writing DWA0 failed\n", __func__); 292 + return ret; 293 + } 294 + 295 + /* Program the alarm and enable it for each setting */ 296 + regs[ISL12022_REG_SCA0 - ISL12022_ALARM] = bin2bcd(alarm_tm->tm_sec) | enable; 297 + regs[ISL12022_REG_MNA0 - ISL12022_ALARM] = bin2bcd(alarm_tm->tm_min) | enable; 298 + regs[ISL12022_REG_HRA0 - ISL12022_ALARM] = bin2bcd(alarm_tm->tm_hour) | enable; 299 + regs[ISL12022_REG_DTA0 - ISL12022_ALARM] = bin2bcd(alarm_tm->tm_mday) | enable; 300 + regs[ISL12022_REG_MOA0 - ISL12022_ALARM] = bin2bcd(alarm_tm->tm_mon + 1) | enable; 301 + regs[ISL12022_REG_DWA0 - ISL12022_ALARM] = bin2bcd(alarm_tm->tm_wday & 7) | enable; 302 + 303 + /* write ALARM registers */ 304 + ret = regmap_bulk_write(regmap, ISL12022_ALARM, &regs, sizeof(regs)); 305 + if (ret) { 306 + dev_dbg(dev, "%s: writing ALARM registers failed\n", __func__); 307 + return ret; 308 + } 309 + 310 + return 0; 311 + } 312 + 313 + static irqreturn_t isl12022_rtc_interrupt(int irq, void *data) 314 + { 315 + struct isl12022 *isl12022 = data; 316 + struct rtc_device *rtc = isl12022->rtc; 317 + struct device *dev = &rtc->dev; 318 + struct regmap *regmap = isl12022->regmap; 319 + u32 val = 0; 320 + unsigned long events = 0; 321 + int ret; 322 + 323 + ret = regmap_read(regmap, ISL12022_REG_SR, &val); 324 + if (ret) { 325 + dev_dbg(dev, "%s: reading SR failed\n", __func__); 326 + return IRQ_HANDLED; 327 + } 328 + 329 + if (val & ISL12022_SR_ALM) 330 + events |= RTC_IRQF | RTC_AF; 331 + 332 + if (events & RTC_AF) 333 + dev_dbg(dev, "alarm!\n"); 334 + 335 + if (!events) 336 + return IRQ_NONE; 337 + 338 + rtc_update_irq(rtc, 1, events); 339 + return IRQ_HANDLED; 340 + } 341 + 342 + static int isl12022_rtc_alarm_irq_enable(struct device *dev, 343 + unsigned int enabled) 344 + { 345 + struct isl12022 *isl12022 = dev_get_drvdata(dev); 346 + 347 + /* Make sure enabled is 0 or 1 */ 348 + enabled = !!enabled; 349 + 350 + if (isl12022->irq_enabled == enabled) 351 + return 0; 352 + 353 + if (enabled) 354 + enable_irq(isl12022->irq); 355 + else 356 + disable_irq(isl12022->irq); 357 + 358 + isl12022->irq_enabled = enabled; 359 + 360 + return 0; 361 + } 362 + 363 + static int isl12022_setup_irq(struct device *dev, int irq) 364 + { 365 + struct isl12022 *isl12022 = dev_get_drvdata(dev); 366 + struct regmap *regmap = isl12022->regmap; 367 + unsigned int reg_mask, reg_val; 368 + u8 buf[ISL12022_ALARM_LEN] = { 0, }; 369 + int ret; 370 + 371 + /* Clear and disable all alarm registers */ 372 + ret = regmap_bulk_write(regmap, ISL12022_ALARM, buf, sizeof(buf)); 373 + if (ret) 374 + return ret; 375 + 376 + /* 377 + * Enable automatic reset of ALM bit and enable single event interrupt 378 + * mode. 379 + */ 380 + reg_mask = ISL12022_INT_ARST | ISL12022_INT_IM | ISL12022_INT_FO_MASK; 381 + reg_val = ISL12022_INT_ARST | ISL12022_INT_FO_OFF; 382 + ret = regmap_write_bits(regmap, ISL12022_REG_INT, 383 + reg_mask, reg_val); 384 + if (ret) 385 + return ret; 386 + 387 + ret = devm_request_threaded_irq(dev, irq, NULL, 388 + isl12022_rtc_interrupt, 389 + IRQF_SHARED | IRQF_ONESHOT, 390 + isl12022_driver.driver.name, 391 + isl12022); 392 + if (ret) 393 + return dev_err_probe(dev, ret, "Unable to request irq %d\n", irq); 394 + 395 + isl12022->irq = irq; 396 + return 0; 397 + } 398 + 240 399 static int isl12022_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) 241 400 { 242 - struct regmap *regmap = dev_get_drvdata(dev); 401 + struct isl12022 *isl12022 = dev_get_drvdata(dev); 402 + struct regmap *regmap = isl12022->regmap; 243 403 u32 user, val; 244 404 int ret; 245 405 ··· 456 238 .ioctl = isl12022_rtc_ioctl, 457 239 .read_time = isl12022_rtc_read_time, 458 240 .set_time = isl12022_rtc_set_time, 241 + .read_alarm = isl12022_rtc_read_alarm, 242 + .set_alarm = isl12022_rtc_set_alarm, 243 + .alarm_irq_enable = isl12022_rtc_alarm_irq_enable, 459 244 }; 460 245 461 246 static const struct regmap_config regmap_config = { ··· 469 248 470 249 static int isl12022_register_clock(struct device *dev) 471 250 { 472 - struct regmap *regmap = dev_get_drvdata(dev); 251 + struct isl12022 *isl12022 = dev_get_drvdata(dev); 252 + struct regmap *regmap = isl12022->regmap; 473 253 struct clk_hw *hw; 474 254 int ret; 475 255 ··· 510 288 511 289 static void isl12022_set_trip_levels(struct device *dev) 512 290 { 513 - struct regmap *regmap = dev_get_drvdata(dev); 291 + struct isl12022 *isl12022 = dev_get_drvdata(dev); 292 + struct regmap *regmap = isl12022->regmap; 514 293 u32 levels[2] = {0, 0}; 515 294 int ret, i, j, x[2]; 516 295 u8 val, mask; ··· 548 325 549 326 static int isl12022_probe(struct i2c_client *client) 550 327 { 328 + struct isl12022 *isl12022; 551 329 struct rtc_device *rtc; 552 330 struct regmap *regmap; 553 331 int ret; ··· 556 332 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) 557 333 return -ENODEV; 558 334 559 - regmap = devm_regmap_init_i2c(client, &regmap_config); 560 - if (IS_ERR(regmap)) { 561 - dev_err(&client->dev, "regmap allocation failed\n"); 562 - return PTR_ERR(regmap); 563 - } 335 + /* Allocate driver state */ 336 + isl12022 = devm_kzalloc(&client->dev, sizeof(*isl12022), GFP_KERNEL); 337 + if (!isl12022) 338 + return -ENOMEM; 564 339 565 - dev_set_drvdata(&client->dev, regmap); 340 + regmap = devm_regmap_init_i2c(client, &regmap_config); 341 + if (IS_ERR(regmap)) 342 + return dev_err_probe(&client->dev, PTR_ERR(regmap), "regmap allocation failed\n"); 343 + isl12022->regmap = regmap; 344 + 345 + dev_set_drvdata(&client->dev, isl12022); 566 346 567 347 ret = isl12022_register_clock(&client->dev); 568 348 if (ret) ··· 578 350 rtc = devm_rtc_allocate_device(&client->dev); 579 351 if (IS_ERR(rtc)) 580 352 return PTR_ERR(rtc); 353 + isl12022->rtc = rtc; 581 354 582 355 rtc->ops = &isl12022_rtc_ops; 583 356 rtc->range_min = RTC_TIMESTAMP_BEGIN_2000; 584 357 rtc->range_max = RTC_TIMESTAMP_END_2099; 358 + 359 + if (client->irq > 0) { 360 + ret = isl12022_setup_irq(&client->dev, client->irq); 361 + if (ret) 362 + return ret; 363 + } else { 364 + clear_bit(RTC_FEATURE_ALARM, rtc->features); 365 + } 585 366 586 367 return devm_rtc_register_device(rtc); 587 368 }
+1 -1
drivers/rtc/rtc-loongson.c
··· 381 381 382 382 static struct platform_driver loongson_rtc_driver = { 383 383 .probe = loongson_rtc_probe, 384 - .remove_new = loongson_rtc_remove, 384 + .remove = loongson_rtc_remove, 385 385 .driver = { 386 386 .name = "loongson-rtc", 387 387 .of_match_table = loongson_rtc_of_match,
+1 -1
drivers/rtc/rtc-lpc24xx.c
··· 285 285 286 286 static struct platform_driver lpc24xx_rtc_driver = { 287 287 .probe = lpc24xx_rtc_probe, 288 - .remove_new = lpc24xx_rtc_remove, 288 + .remove = lpc24xx_rtc_remove, 289 289 .driver = { 290 290 .name = "lpc24xx-rtc", 291 291 .of_match_table = lpc24xx_rtc_match,
+4 -22
drivers/rtc/rtc-m48t59.c
··· 71 71 /* Issue the READ command */ 72 72 M48T59_SET_BITS(M48T59_CNTL_READ, M48T59_CNTL); 73 73 74 - tm->tm_year = bcd2bin(M48T59_READ(M48T59_YEAR)); 74 + tm->tm_year = bcd2bin(M48T59_READ(M48T59_YEAR)) + pdata->yy_offset; 75 75 /* tm_mon is 0-11 */ 76 76 tm->tm_mon = bcd2bin(M48T59_READ(M48T59_MONTH)) - 1; 77 77 tm->tm_mday = bcd2bin(M48T59_READ(M48T59_MDAY)); ··· 82 82 dev_dbg(dev, "Century bit is enabled\n"); 83 83 tm->tm_year += 100; /* one century */ 84 84 } 85 - #ifdef CONFIG_SPARC 86 - /* Sun SPARC machines count years since 1968 */ 87 - tm->tm_year += 68; 88 - #endif 89 85 90 86 tm->tm_wday = bcd2bin(val & 0x07); 91 87 tm->tm_hour = bcd2bin(M48T59_READ(M48T59_HOUR) & 0x3F); ··· 102 106 struct m48t59_private *m48t59 = dev_get_drvdata(dev); 103 107 unsigned long flags; 104 108 u8 val = 0; 105 - int year = tm->tm_year; 106 - 107 - #ifdef CONFIG_SPARC 108 - /* Sun SPARC machines count years since 1968 */ 109 - year -= 68; 110 - #endif 109 + int year = tm->tm_year - pdata->yy_offset; 111 110 112 111 dev_dbg(dev, "RTC set time %04d-%02d-%02d %02d/%02d/%02d\n", 113 112 year + 1900, tm->tm_mon, tm->tm_mday, ··· 153 162 /* Issue the READ command */ 154 163 M48T59_SET_BITS(M48T59_CNTL_READ, M48T59_CNTL); 155 164 156 - tm->tm_year = bcd2bin(M48T59_READ(M48T59_YEAR)); 157 - #ifdef CONFIG_SPARC 158 - /* Sun SPARC machines count years since 1968 */ 159 - tm->tm_year += 68; 160 - #endif 165 + tm->tm_year = bcd2bin(M48T59_READ(M48T59_YEAR)) + pdata->yy_offset; 161 166 /* tm_mon is 0-11 */ 162 167 tm->tm_mon = bcd2bin(M48T59_READ(M48T59_MONTH)) - 1; 163 168 ··· 184 197 struct rtc_time *tm = &alrm->time; 185 198 u8 mday, hour, min, sec; 186 199 unsigned long flags; 187 - int year = tm->tm_year; 188 - 189 - #ifdef CONFIG_SPARC 190 - /* Sun SPARC machines count years since 1968 */ 191 - year -= 68; 192 - #endif 200 + int year = tm->tm_year - pdata->yy_offset; 193 201 194 202 /* If no irq, we don't support ALARM */ 195 203 if (m48t59->irq == NO_IRQ)
+1 -1
drivers/rtc/rtc-max77686.c
··· 875 875 .pm = &max77686_rtc_pm_ops, 876 876 }, 877 877 .probe = max77686_rtc_probe, 878 - .remove_new = max77686_rtc_remove, 878 + .remove = max77686_rtc_remove, 879 879 .id_table = rtc_id, 880 880 }; 881 881
+1 -1
drivers/rtc/rtc-mc13xxx.c
··· 350 350 351 351 static struct platform_driver mc13xxx_rtc_driver = { 352 352 .id_table = mc13xxx_rtc_idtable, 353 - .remove_new = mc13xxx_rtc_remove, 353 + .remove = mc13xxx_rtc_remove, 354 354 .driver = { 355 355 .name = DRIVER_NAME, 356 356 },
+2 -4
drivers/rtc/rtc-mc146818-lib.c
··· 216 216 unsigned char save_control, save_freq_select; 217 217 unsigned int yrs; 218 218 #ifdef CONFIG_MACH_DECSTATION 219 - unsigned int real_yrs, leap_yr; 219 + unsigned int real_yrs; 220 220 #endif 221 221 unsigned char century = 0; 222 222 ··· 232 232 233 233 #ifdef CONFIG_MACH_DECSTATION 234 234 real_yrs = yrs; 235 - leap_yr = ((!((yrs + 1900) % 4) && ((yrs + 1900) % 100)) || 236 - !((yrs + 1900) % 400)); 237 235 yrs = 72; 238 236 239 237 /* ··· 239 241 * for non-leap years, so that Feb, 29th is handled 240 242 * correctly. 241 243 */ 242 - if (!leap_yr && mon < 3) { 244 + if (!is_leap_year(real_yrs + 1900) && mon < 3) { 243 245 real_yrs--; 244 246 yrs = 73; 245 247 }
+1 -1
drivers/rtc/rtc-mpc5121.c
··· 398 398 .of_match_table = of_match_ptr(mpc5121_rtc_match), 399 399 }, 400 400 .probe = mpc5121_rtc_probe, 401 - .remove_new = mpc5121_rtc_remove, 401 + .remove = mpc5121_rtc_remove, 402 402 }; 403 403 404 404 module_platform_driver(mpc5121_rtc_driver);
+1 -1
drivers/rtc/rtc-mpfs.c
··· 288 288 289 289 static struct platform_driver mpfs_rtc_driver = { 290 290 .probe = mpfs_rtc_probe, 291 - .remove_new = mpfs_rtc_remove, 291 + .remove = mpfs_rtc_remove, 292 292 .driver = { 293 293 .name = "mpfs_rtc", 294 294 .of_match_table = mpfs_rtc_of_match,
+10 -19
drivers/rtc/rtc-mt6397.c
··· 75 75 tm->tm_min = data[RTC_OFFSET_MIN]; 76 76 tm->tm_hour = data[RTC_OFFSET_HOUR]; 77 77 tm->tm_mday = data[RTC_OFFSET_DOM]; 78 + tm->tm_wday = data[RTC_OFFSET_DOW]; 78 79 tm->tm_mon = data[RTC_OFFSET_MTH] & RTC_TC_MTH_MASK; 79 80 tm->tm_year = data[RTC_OFFSET_YEAR]; 80 81 ··· 87 86 88 87 static int mtk_rtc_read_time(struct device *dev, struct rtc_time *tm) 89 88 { 90 - time64_t time; 91 89 struct mt6397_rtc *rtc = dev_get_drvdata(dev); 92 - int days, sec, ret; 90 + int sec, ret; 93 91 94 92 do { 95 93 ret = __mtk_rtc_read_time(rtc, tm, &sec); ··· 96 96 goto exit; 97 97 } while (sec < tm->tm_sec); 98 98 99 - /* HW register use 7 bits to store year data, minus 100 - * RTC_MIN_YEAR_OFFSET before write year data to register, and plus 101 - * RTC_MIN_YEAR_OFFSET back after read year from register 102 - */ 103 - tm->tm_year += RTC_MIN_YEAR_OFFSET; 104 - 105 - /* HW register start mon from one, but tm_mon start from zero. */ 99 + /* HW register start mon/wday from one, but tm_mon/tm_wday start from zero. */ 106 100 tm->tm_mon--; 107 - time = rtc_tm_to_time64(tm); 108 - 109 - /* rtc_tm_to_time64 covert Gregorian date to seconds since 110 - * 01-01-1970 00:00:00, and this date is Thursday. 111 - */ 112 - days = div_s64(time, 86400); 113 - tm->tm_wday = (days + 4) % 7; 101 + tm->tm_wday--; 114 102 115 103 exit: 116 104 return ret; ··· 110 122 int ret; 111 123 u16 data[RTC_OFFSET_COUNT]; 112 124 113 - tm->tm_year -= RTC_MIN_YEAR_OFFSET; 114 125 tm->tm_mon++; 126 + tm->tm_wday++; 115 127 116 128 data[RTC_OFFSET_SEC] = tm->tm_sec; 117 129 data[RTC_OFFSET_MIN] = tm->tm_min; 118 130 data[RTC_OFFSET_HOUR] = tm->tm_hour; 119 131 data[RTC_OFFSET_DOM] = tm->tm_mday; 132 + data[RTC_OFFSET_DOW] = tm->tm_wday; 120 133 data[RTC_OFFSET_MTH] = tm->tm_mon; 121 134 data[RTC_OFFSET_YEAR] = tm->tm_year; 122 135 ··· 167 178 tm->tm_mon = data[RTC_OFFSET_MTH] & RTC_AL_MTH_MASK; 168 179 tm->tm_year = data[RTC_OFFSET_YEAR] & RTC_AL_YEA_MASK; 169 180 170 - tm->tm_year += RTC_MIN_YEAR_OFFSET; 171 181 tm->tm_mon--; 172 182 173 183 return 0; ··· 182 194 int ret; 183 195 u16 data[RTC_OFFSET_COUNT]; 184 196 185 - tm->tm_year -= RTC_MIN_YEAR_OFFSET; 186 197 tm->tm_mon++; 187 198 188 199 mutex_lock(&rtc->lock); ··· 289 302 device_init_wakeup(&pdev->dev, 1); 290 303 291 304 rtc->rtc_dev->ops = &mtk_rtc_ops; 305 + rtc->rtc_dev->range_min = RTC_TIMESTAMP_BEGIN_1900; 306 + rtc->rtc_dev->range_max = mktime64(2027, 12, 31, 23, 59, 59); 307 + rtc->rtc_dev->start_secs = mktime64(1968, 1, 2, 0, 0, 0); 308 + rtc->rtc_dev->set_start_time = true; 292 309 293 310 return devm_rtc_register_device(rtc->rtc_dev); 294 311 }
+1 -1
drivers/rtc/rtc-mt7622.c
··· 394 394 395 395 static struct platform_driver mtk_rtc_driver = { 396 396 .probe = mtk_rtc_probe, 397 - .remove_new = mtk_rtc_remove, 397 + .remove = mtk_rtc_remove, 398 398 .driver = { 399 399 .name = MTK_RTC_DEV, 400 400 .of_match_table = mtk_rtc_match,
+1 -1
drivers/rtc/rtc-mv.c
··· 308 308 * triggering a section mismatch warning. 309 309 */ 310 310 static struct platform_driver mv_rtc_driver __refdata = { 311 - .remove_new = __exit_p(mv_rtc_remove), 311 + .remove = __exit_p(mv_rtc_remove), 312 312 .driver = { 313 313 .name = "rtc-mv", 314 314 .of_match_table = of_match_ptr(rtc_mv_of_match_table),
+1 -1
drivers/rtc/rtc-mxc_v2.c
··· 381 381 .of_match_table = mxc_ids, 382 382 }, 383 383 .probe = mxc_rtc_probe, 384 - .remove_new = mxc_rtc_remove, 384 + .remove = mxc_rtc_remove, 385 385 }; 386 386 387 387 module_platform_driver(mxc_rtc_driver);
+18 -2
drivers/rtc/rtc-nxp-bbnsm.c
··· 197 197 if (ret) { 198 198 dev_err(&pdev->dev, "failed to request irq %d: %d\n", 199 199 bbnsm->irq, ret); 200 - return ret; 200 + goto err; 201 201 } 202 202 203 203 bbnsm->rtc->ops = &bbnsm_rtc_ops; 204 204 bbnsm->rtc->range_max = U32_MAX; 205 205 206 - return devm_rtc_register_device(bbnsm->rtc); 206 + ret = devm_rtc_register_device(bbnsm->rtc); 207 + if (ret) 208 + goto err; 209 + 210 + return 0; 211 + 212 + err: 213 + dev_pm_clear_wake_irq(&pdev->dev); 214 + device_init_wakeup(&pdev->dev, false); 215 + return ret; 216 + } 217 + 218 + static void bbnsm_rtc_remove(struct platform_device *pdev) 219 + { 220 + dev_pm_clear_wake_irq(&pdev->dev); 221 + device_init_wakeup(&pdev->dev, false); 207 222 } 208 223 209 224 static const struct of_device_id bbnsm_dt_ids[] = { ··· 233 218 .of_match_table = bbnsm_dt_ids, 234 219 }, 235 220 .probe = bbnsm_rtc_probe, 221 + .remove = bbnsm_rtc_remove, 236 222 }; 237 223 module_platform_driver(bbnsm_rtc_driver); 238 224
+1 -1
drivers/rtc/rtc-omap.c
··· 1014 1014 1015 1015 static struct platform_driver omap_rtc_driver = { 1016 1016 .probe = omap_rtc_probe, 1017 - .remove_new = omap_rtc_remove, 1017 + .remove = omap_rtc_remove, 1018 1018 .shutdown = omap_rtc_shutdown, 1019 1019 .driver = { 1020 1020 .name = "omap_rtc",
+1 -1
drivers/rtc/rtc-palmas.c
··· 346 346 347 347 static struct platform_driver palmas_rtc_driver = { 348 348 .probe = palmas_rtc_probe, 349 - .remove_new = palmas_rtc_remove, 349 + .remove = palmas_rtc_remove, 350 350 .driver = { 351 351 .name = "palmas-rtc", 352 352 .pm = &palmas_rtc_pm_ops,
+1 -1
drivers/rtc/rtc-pcf50633.c
··· 273 273 .name = "pcf50633-rtc", 274 274 }, 275 275 .probe = pcf50633_rtc_probe, 276 - .remove_new = pcf50633_rtc_remove, 276 + .remove = pcf50633_rtc_remove, 277 277 }; 278 278 279 279 module_platform_driver(pcf50633_rtc_driver);
+86 -128
drivers/rtc/rtc-pcf8563.c
··· 11 11 * https://www.nxp.com/docs/en/data-sheet/PCF8563.pdf 12 12 */ 13 13 14 - #include <linux/clk-provider.h> 15 - #include <linux/i2c.h> 16 14 #include <linux/bcd.h> 17 - #include <linux/rtc.h> 18 - #include <linux/slab.h> 15 + #include <linux/clk-provider.h> 16 + #include <linux/err.h> 17 + #include <linux/i2c.h> 19 18 #include <linux/module.h> 20 19 #include <linux/of.h> 21 - #include <linux/err.h> 20 + #include <linux/regmap.h> 21 + #include <linux/rtc.h> 22 + #include <linux/slab.h> 22 23 23 24 #define PCF8563_REG_ST1 0x00 /* status */ 24 25 #define PCF8563_REG_ST2 0x01 ··· 78 77 */ 79 78 int c_polarity; /* 0: MO_C=1 means 19xx, otherwise MO_C=1 means 20xx */ 80 79 81 - struct i2c_client *client; 80 + struct regmap *regmap; 82 81 #ifdef CONFIG_COMMON_CLK 83 82 struct clk_hw clkout_hw; 84 83 #endif 85 84 }; 86 85 87 - static int pcf8563_read_block_data(struct i2c_client *client, unsigned char reg, 88 - unsigned char length, unsigned char *buf) 86 + static int pcf8563_set_alarm_mode(struct pcf8563 *pcf8563, bool on) 89 87 { 90 - struct i2c_msg msgs[] = { 91 - {/* setup read ptr */ 92 - .addr = client->addr, 93 - .len = 1, 94 - .buf = &reg, 95 - }, 96 - { 97 - .addr = client->addr, 98 - .flags = I2C_M_RD, 99 - .len = length, 100 - .buf = buf 101 - }, 102 - }; 103 - 104 - if ((i2c_transfer(client->adapter, msgs, 2)) != 2) { 105 - dev_err(&client->dev, "%s: read error\n", __func__); 106 - return -EIO; 107 - } 108 - 109 - return 0; 110 - } 111 - 112 - static int pcf8563_write_block_data(struct i2c_client *client, 113 - unsigned char reg, unsigned char length, 114 - unsigned char *buf) 115 - { 116 - int i, err; 117 - 118 - for (i = 0; i < length; i++) { 119 - unsigned char data[2] = { reg + i, buf[i] }; 120 - 121 - err = i2c_master_send(client, data, sizeof(data)); 122 - if (err != sizeof(data)) { 123 - dev_err(&client->dev, 124 - "%s: err=%d addr=%02x, data=%02x\n", 125 - __func__, err, data[0], data[1]); 126 - return -EIO; 127 - } 128 - } 129 - 130 - return 0; 131 - } 132 - 133 - static int pcf8563_set_alarm_mode(struct i2c_client *client, bool on) 134 - { 135 - unsigned char buf; 88 + u32 buf; 136 89 int err; 137 90 138 - err = pcf8563_read_block_data(client, PCF8563_REG_ST2, 1, &buf); 91 + err = regmap_read(pcf8563->regmap, PCF8563_REG_ST2, &buf); 139 92 if (err < 0) 140 93 return err; 141 94 ··· 100 145 101 146 buf &= ~(PCF8563_BIT_AF | PCF8563_BITS_ST2_N); 102 147 103 - err = pcf8563_write_block_data(client, PCF8563_REG_ST2, 1, &buf); 104 - if (err < 0) { 105 - dev_err(&client->dev, "%s: write error\n", __func__); 106 - return -EIO; 107 - } 108 - 109 - return 0; 148 + return regmap_write(pcf8563->regmap, PCF8563_REG_ST2, buf); 110 149 } 111 150 112 - static int pcf8563_get_alarm_mode(struct i2c_client *client, unsigned char *en, 151 + static int pcf8563_get_alarm_mode(struct pcf8563 *pcf8563, unsigned char *en, 113 152 unsigned char *pen) 114 153 { 115 - unsigned char buf; 154 + u32 buf; 116 155 int err; 117 156 118 - err = pcf8563_read_block_data(client, PCF8563_REG_ST2, 1, &buf); 119 - if (err) 157 + err = regmap_read(pcf8563->regmap, PCF8563_REG_ST2, &buf); 158 + if (err < 0) 120 159 return err; 121 160 122 161 if (en) ··· 123 174 124 175 static irqreturn_t pcf8563_irq(int irq, void *dev_id) 125 176 { 126 - struct pcf8563 *pcf8563 = i2c_get_clientdata(dev_id); 127 - int err; 177 + struct pcf8563 *pcf8563 = dev_id; 128 178 char pending; 179 + int err; 129 180 130 - err = pcf8563_get_alarm_mode(pcf8563->client, NULL, &pending); 181 + err = pcf8563_get_alarm_mode(pcf8563, NULL, &pending); 131 182 if (err) 132 183 return IRQ_NONE; 133 184 134 185 if (pending) { 135 186 rtc_update_irq(pcf8563->rtc, 1, RTC_IRQF | RTC_AF); 136 - pcf8563_set_alarm_mode(pcf8563->client, 1); 187 + pcf8563_set_alarm_mode(pcf8563, 1); 137 188 return IRQ_HANDLED; 138 189 } 139 190 ··· 146 197 */ 147 198 static int pcf8563_rtc_read_time(struct device *dev, struct rtc_time *tm) 148 199 { 149 - struct i2c_client *client = to_i2c_client(dev); 150 - struct pcf8563 *pcf8563 = i2c_get_clientdata(client); 200 + struct pcf8563 *pcf8563 = dev_get_drvdata(dev); 151 201 unsigned char buf[9]; 152 202 int err; 153 203 154 - err = pcf8563_read_block_data(client, PCF8563_REG_ST1, 9, buf); 155 - if (err) 204 + err = regmap_bulk_read(pcf8563->regmap, PCF8563_REG_ST1, buf, 205 + sizeof(buf)); 206 + if (err < 0) 156 207 return err; 157 208 158 209 if (buf[PCF8563_REG_SC] & PCF8563_SC_LV) { 159 - dev_err(&client->dev, 210 + dev_err(dev, 160 211 "low voltage detected, date/time is not reliable.\n"); 161 212 return -EINVAL; 162 213 } 163 214 164 - dev_dbg(&client->dev, 215 + dev_dbg(dev, 165 216 "%s: raw data is st1=%02x, st2=%02x, sec=%02x, min=%02x, hr=%02x, " 166 217 "mday=%02x, wday=%02x, mon=%02x, year=%02x\n", 167 218 __func__, 168 219 buf[0], buf[1], buf[2], buf[3], 169 220 buf[4], buf[5], buf[6], buf[7], 170 221 buf[8]); 171 - 172 222 173 223 tm->tm_sec = bcd2bin(buf[PCF8563_REG_SC] & 0x7F); 174 224 tm->tm_min = bcd2bin(buf[PCF8563_REG_MN] & 0x7F); ··· 180 232 pcf8563->c_polarity = (buf[PCF8563_REG_MO] & PCF8563_MO_C) ? 181 233 (tm->tm_year >= 100) : (tm->tm_year < 100); 182 234 183 - dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d, " 235 + dev_dbg(dev, "%s: tm is secs=%d, mins=%d, hours=%d, " 184 236 "mday=%d, mon=%d, year=%d, wday=%d\n", 185 237 __func__, 186 238 tm->tm_sec, tm->tm_min, tm->tm_hour, ··· 191 243 192 244 static int pcf8563_rtc_set_time(struct device *dev, struct rtc_time *tm) 193 245 { 194 - struct i2c_client *client = to_i2c_client(dev); 195 - struct pcf8563 *pcf8563 = i2c_get_clientdata(client); 246 + struct pcf8563 *pcf8563 = dev_get_drvdata(dev); 196 247 unsigned char buf[9]; 197 248 198 - dev_dbg(&client->dev, "%s: secs=%d, mins=%d, hours=%d, " 249 + dev_dbg(dev, "%s: secs=%d, mins=%d, hours=%d, " 199 250 "mday=%d, mon=%d, year=%d, wday=%d\n", 200 251 __func__, 201 252 tm->tm_sec, tm->tm_min, tm->tm_hour, ··· 217 270 218 271 buf[PCF8563_REG_DW] = tm->tm_wday & 0x07; 219 272 220 - return pcf8563_write_block_data(client, PCF8563_REG_SC, 221 - 9 - PCF8563_REG_SC, buf + PCF8563_REG_SC); 273 + return regmap_bulk_write(pcf8563->regmap, PCF8563_REG_SC, 274 + buf + PCF8563_REG_SC, 275 + sizeof(buf) - PCF8563_REG_SC); 222 276 } 223 277 224 278 static int pcf8563_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) 225 279 { 226 - struct i2c_client *client = to_i2c_client(dev); 280 + struct pcf8563 *pcf8563 = dev_get_drvdata(dev); 227 281 int ret; 228 282 229 283 switch (cmd) { 230 284 case RTC_VL_READ: 231 - ret = i2c_smbus_read_byte_data(client, PCF8563_REG_SC); 285 + ret = regmap_test_bits(pcf8563->regmap, PCF8563_REG_SC, 286 + PCF8563_SC_LV); 232 287 if (ret < 0) 233 288 return ret; 234 289 235 - return put_user(ret & PCF8563_SC_LV ? RTC_VL_DATA_INVALID : 0, 290 + return put_user(ret ? RTC_VL_DATA_INVALID : 0, 236 291 (unsigned int __user *)arg); 237 292 default: 238 293 return -ENOIOCTLCMD; ··· 243 294 244 295 static int pcf8563_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *tm) 245 296 { 246 - struct i2c_client *client = to_i2c_client(dev); 297 + struct pcf8563 *pcf8563 = dev_get_drvdata(dev); 247 298 unsigned char buf[4]; 248 299 int err; 249 300 250 - err = pcf8563_read_block_data(client, PCF8563_REG_AMN, 4, buf); 251 - if (err) 301 + err = regmap_bulk_read(pcf8563->regmap, PCF8563_REG_AMN, buf, 302 + sizeof(buf)); 303 + if (err < 0) 252 304 return err; 253 305 254 - dev_dbg(&client->dev, 306 + dev_dbg(dev, 255 307 "%s: raw data is min=%02x, hr=%02x, mday=%02x, wday=%02x\n", 256 308 __func__, buf[0], buf[1], buf[2], buf[3]); 257 309 ··· 262 312 tm->time.tm_mday = bcd2bin(buf[2] & 0x3F); 263 313 tm->time.tm_wday = bcd2bin(buf[3] & 0x7); 264 314 265 - err = pcf8563_get_alarm_mode(client, &tm->enabled, &tm->pending); 315 + err = pcf8563_get_alarm_mode(pcf8563, &tm->enabled, &tm->pending); 266 316 if (err < 0) 267 317 return err; 268 318 269 - dev_dbg(&client->dev, "%s: tm is mins=%d, hours=%d, mday=%d, wday=%d," 319 + dev_dbg(dev, "%s: tm is mins=%d, hours=%d, mday=%d, wday=%d," 270 320 " enabled=%d, pending=%d\n", __func__, tm->time.tm_min, 271 321 tm->time.tm_hour, tm->time.tm_mday, tm->time.tm_wday, 272 322 tm->enabled, tm->pending); ··· 276 326 277 327 static int pcf8563_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *tm) 278 328 { 279 - struct i2c_client *client = to_i2c_client(dev); 329 + struct pcf8563 *pcf8563 = dev_get_drvdata(dev); 280 330 unsigned char buf[4]; 281 331 int err; 282 332 ··· 285 335 buf[2] = bin2bcd(tm->time.tm_mday); 286 336 buf[3] = tm->time.tm_wday & 0x07; 287 337 288 - err = pcf8563_write_block_data(client, PCF8563_REG_AMN, 4, buf); 338 + err = regmap_bulk_write(pcf8563->regmap, PCF8563_REG_SC, buf, 339 + sizeof(buf)); 289 340 if (err) 290 341 return err; 291 342 292 - return pcf8563_set_alarm_mode(client, !!tm->enabled); 343 + return pcf8563_set_alarm_mode(pcf8563, !!tm->enabled); 293 344 } 294 345 295 346 static int pcf8563_irq_enable(struct device *dev, unsigned int enabled) 296 347 { 348 + struct pcf8563 *pcf8563 = dev_get_drvdata(dev); 349 + 297 350 dev_dbg(dev, "%s: en=%d\n", __func__, enabled); 298 - return pcf8563_set_alarm_mode(to_i2c_client(dev), !!enabled); 351 + return pcf8563_set_alarm_mode(pcf8563, !!enabled); 299 352 } 300 353 301 354 #ifdef CONFIG_COMMON_CLK ··· 319 366 unsigned long parent_rate) 320 367 { 321 368 struct pcf8563 *pcf8563 = clkout_hw_to_pcf8563(hw); 322 - struct i2c_client *client = pcf8563->client; 323 - unsigned char buf; 324 - int ret = pcf8563_read_block_data(client, PCF8563_REG_CLKO, 1, &buf); 369 + u32 buf; 370 + int ret; 325 371 372 + ret = regmap_read(pcf8563->regmap, PCF8563_REG_CLKO, &buf); 326 373 if (ret < 0) 327 374 return 0; 328 375 ··· 346 393 unsigned long parent_rate) 347 394 { 348 395 struct pcf8563 *pcf8563 = clkout_hw_to_pcf8563(hw); 349 - struct i2c_client *client = pcf8563->client; 350 - unsigned char buf; 351 - int ret = pcf8563_read_block_data(client, PCF8563_REG_CLKO, 1, &buf); 352 - int i; 396 + int i, ret; 397 + u32 buf; 353 398 399 + ret = regmap_read(pcf8563->regmap, PCF8563_REG_CLKO, &buf); 354 400 if (ret < 0) 355 401 return ret; 356 402 ··· 357 405 if (clkout_rates[i] == rate) { 358 406 buf &= ~PCF8563_REG_CLKO_F_MASK; 359 407 buf |= i; 360 - ret = pcf8563_write_block_data(client, 361 - PCF8563_REG_CLKO, 1, 362 - &buf); 363 - return ret; 408 + return regmap_update_bits(pcf8563->regmap, 409 + PCF8563_REG_CLKO, 410 + PCF8563_REG_CLKO_F_MASK, 411 + buf); 364 412 } 365 413 366 414 return -EINVAL; ··· 369 417 static int pcf8563_clkout_control(struct clk_hw *hw, bool enable) 370 418 { 371 419 struct pcf8563 *pcf8563 = clkout_hw_to_pcf8563(hw); 372 - struct i2c_client *client = pcf8563->client; 373 - unsigned char buf; 374 - int ret = pcf8563_read_block_data(client, PCF8563_REG_CLKO, 1, &buf); 420 + u32 buf; 421 + int ret; 375 422 423 + ret = regmap_read(pcf8563->regmap, PCF8563_REG_CLKO, &buf); 376 424 if (ret < 0) 377 425 return ret; 378 426 ··· 381 429 else 382 430 buf &= ~PCF8563_REG_CLKO_FE; 383 431 384 - ret = pcf8563_write_block_data(client, PCF8563_REG_CLKO, 1, &buf); 385 - return ret; 432 + return regmap_update_bits(pcf8563->regmap, PCF8563_REG_CLKO, 433 + PCF8563_REG_CLKO_FE, buf); 386 434 } 387 435 388 436 static int pcf8563_clkout_prepare(struct clk_hw *hw) ··· 398 446 static int pcf8563_clkout_is_prepared(struct clk_hw *hw) 399 447 { 400 448 struct pcf8563 *pcf8563 = clkout_hw_to_pcf8563(hw); 401 - struct i2c_client *client = pcf8563->client; 402 - unsigned char buf; 403 - int ret = pcf8563_read_block_data(client, PCF8563_REG_CLKO, 1, &buf); 449 + u32 buf; 450 + int ret; 404 451 452 + ret = regmap_read(pcf8563->regmap, PCF8563_REG_CLKO, &buf); 405 453 if (ret < 0) 406 454 return ret; 407 455 ··· 419 467 420 468 static struct clk *pcf8563_clkout_register_clk(struct pcf8563 *pcf8563) 421 469 { 422 - struct i2c_client *client = pcf8563->client; 423 - struct device_node *node = client->dev.of_node; 424 - struct clk *clk; 470 + struct device_node *node = pcf8563->rtc->dev.of_node; 425 471 struct clk_init_data init; 472 + struct clk *clk; 426 473 int ret; 427 - unsigned char buf; 428 474 429 475 /* disable the clkout output */ 430 - buf = 0; 431 - ret = pcf8563_write_block_data(client, PCF8563_REG_CLKO, 1, &buf); 476 + ret = regmap_clear_bits(pcf8563->regmap, PCF8563_REG_CLKO, 477 + PCF8563_REG_CLKO_FE); 432 478 if (ret < 0) 433 479 return ERR_PTR(ret); 434 480 ··· 441 491 of_property_read_string(node, "clock-output-names", &init.name); 442 492 443 493 /* register the clock */ 444 - clk = devm_clk_register(&client->dev, &pcf8563->clkout_hw); 494 + clk = devm_clk_register(&pcf8563->rtc->dev, &pcf8563->clkout_hw); 445 495 446 496 if (!IS_ERR(clk)) 447 497 of_clk_add_provider(node, of_clk_src_simple_get, clk); ··· 459 509 .alarm_irq_enable = pcf8563_irq_enable, 460 510 }; 461 511 512 + static const struct regmap_config regmap_config = { 513 + .reg_bits = 8, 514 + .val_bits = 8, 515 + .max_register = 0xF, 516 + }; 517 + 462 518 static int pcf8563_probe(struct i2c_client *client) 463 519 { 464 520 struct pcf8563 *pcf8563; 465 521 int err; 466 - unsigned char buf; 467 522 468 523 dev_dbg(&client->dev, "%s\n", __func__); 469 524 ··· 480 525 if (!pcf8563) 481 526 return -ENOMEM; 482 527 528 + pcf8563->regmap = devm_regmap_init_i2c(client, &regmap_config); 529 + if (IS_ERR(pcf8563->regmap)) 530 + return PTR_ERR(pcf8563->regmap); 531 + 483 532 i2c_set_clientdata(client, pcf8563); 484 - pcf8563->client = client; 533 + device_set_wakeup_capable(&client->dev, 1); 485 534 486 535 /* Set timer to lowest frequency to save power (ref Haoyu datasheet) */ 487 - buf = PCF8563_TMRC_1_60; 488 - err = pcf8563_write_block_data(client, PCF8563_REG_TMRC, 1, &buf); 536 + err = regmap_set_bits(pcf8563->regmap, PCF8563_REG_TMRC, 537 + PCF8563_TMRC_1_60); 489 538 if (err < 0) { 490 539 dev_err(&client->dev, "%s: write error\n", __func__); 491 540 return err; 492 541 } 493 542 494 543 /* Clear flags and disable interrupts */ 495 - buf = 0; 496 - err = pcf8563_write_block_data(client, PCF8563_REG_ST2, 1, &buf); 544 + err = regmap_write(pcf8563->regmap, PCF8563_REG_ST2, 0); 497 545 if (err < 0) { 498 546 dev_err(&client->dev, "%s: write error\n", __func__); 499 547 return err;
+1 -1
drivers/rtc/rtc-pic32.c
··· 371 371 372 372 static struct platform_driver pic32_rtc_driver = { 373 373 .probe = pic32_rtc_probe, 374 - .remove_new = pic32_rtc_remove, 374 + .remove = pic32_rtc_remove, 375 375 .driver = { 376 376 .name = "pic32-rtc", 377 377 .of_match_table = of_match_ptr(pic32_rtc_dt_ids),
+1 -1
drivers/rtc/rtc-pm8xxx.c
··· 537 537 538 538 static struct platform_driver pm8xxx_rtc_driver = { 539 539 .probe = pm8xxx_rtc_probe, 540 - .remove_new = pm8xxx_remove, 540 + .remove = pm8xxx_remove, 541 541 .driver = { 542 542 .name = "rtc-pm8xxx", 543 543 .of_match_table = pm8xxx_id_table,
+1 -1
drivers/rtc/rtc-pxa.c
··· 409 409 * triggering a section mismatch warning. 410 410 */ 411 411 static struct platform_driver pxa_rtc_driver __refdata = { 412 - .remove_new = __exit_p(pxa_rtc_remove), 412 + .remove = __exit_p(pxa_rtc_remove), 413 413 .driver = { 414 414 .name = "pxa-rtc", 415 415 .of_match_table = of_match_ptr(pxa_rtc_dt_ids),
+1 -1
drivers/rtc/rtc-rc5t583.c
··· 298 298 299 299 static struct platform_driver rc5t583_rtc_driver = { 300 300 .probe = rc5t583_rtc_probe, 301 - .remove_new = rc5t583_rtc_remove, 301 + .remove = rc5t583_rtc_remove, 302 302 .driver = { 303 303 .name = "rtc-rc5t583", 304 304 .pm = &rc5t583_rtc_pm_ops,
+900
drivers/rtc/rtc-renesas-rtca3.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * On-Chip RTC Support available on RZ/G3S SoC 4 + * 5 + * Copyright (C) 2024 Renesas Electronics Corp. 6 + */ 7 + #include <linux/bcd.h> 8 + #include <linux/bitfield.h> 9 + #include <linux/cleanup.h> 10 + #include <linux/clk.h> 11 + #include <linux/completion.h> 12 + #include <linux/delay.h> 13 + #include <linux/iopoll.h> 14 + #include <linux/interrupt.h> 15 + #include <linux/jiffies.h> 16 + #include <linux/of.h> 17 + #include <linux/platform_device.h> 18 + #include <linux/pm_runtime.h> 19 + #include <linux/reset.h> 20 + #include <linux/rtc.h> 21 + 22 + /* Counter registers. */ 23 + #define RTCA3_RSECCNT 0x2 24 + #define RTCA3_RSECCNT_SEC GENMASK(6, 0) 25 + #define RTCA3_RMINCNT 0x4 26 + #define RTCA3_RMINCNT_MIN GENMASK(6, 0) 27 + #define RTCA3_RHRCNT 0x6 28 + #define RTCA3_RHRCNT_HR GENMASK(5, 0) 29 + #define RTCA3_RHRCNT_PM BIT(6) 30 + #define RTCA3_RWKCNT 0x8 31 + #define RTCA3_RWKCNT_WK GENMASK(2, 0) 32 + #define RTCA3_RDAYCNT 0xa 33 + #define RTCA3_RDAYCNT_DAY GENMASK(5, 0) 34 + #define RTCA3_RMONCNT 0xc 35 + #define RTCA3_RMONCNT_MONTH GENMASK(4, 0) 36 + #define RTCA3_RYRCNT 0xe 37 + #define RTCA3_RYRCNT_YEAR GENMASK(7, 0) 38 + 39 + /* Alarm registers. */ 40 + #define RTCA3_RSECAR 0x10 41 + #define RTCA3_RSECAR_SEC GENMASK(6, 0) 42 + #define RTCA3_RMINAR 0x12 43 + #define RTCA3_RMINAR_MIN GENMASK(6, 0) 44 + #define RTCA3_RHRAR 0x14 45 + #define RTCA3_RHRAR_HR GENMASK(5, 0) 46 + #define RTCA3_RHRAR_PM BIT(6) 47 + #define RTCA3_RWKAR 0x16 48 + #define RTCA3_RWKAR_DAYW GENMASK(2, 0) 49 + #define RTCA3_RDAYAR 0x18 50 + #define RTCA3_RDAYAR_DATE GENMASK(5, 0) 51 + #define RTCA3_RMONAR 0x1a 52 + #define RTCA3_RMONAR_MON GENMASK(4, 0) 53 + #define RTCA3_RYRAR 0x1c 54 + #define RTCA3_RYRAR_YR GENMASK(7, 0) 55 + #define RTCA3_RYRAREN 0x1e 56 + 57 + /* Alarm enable bit (for all alarm registers). */ 58 + #define RTCA3_AR_ENB BIT(7) 59 + 60 + /* Control registers. */ 61 + #define RTCA3_RCR1 0x22 62 + #define RTCA3_RCR1_AIE BIT(0) 63 + #define RTCA3_RCR1_CIE BIT(1) 64 + #define RTCA3_RCR1_PIE BIT(2) 65 + #define RTCA3_RCR1_PES GENMASK(7, 4) 66 + #define RTCA3_RCR1_PES_1_64_SEC 0x8 67 + #define RTCA3_RCR2 0x24 68 + #define RTCA3_RCR2_START BIT(0) 69 + #define RTCA3_RCR2_RESET BIT(1) 70 + #define RTCA3_RCR2_AADJE BIT(4) 71 + #define RTCA3_RCR2_ADJP BIT(5) 72 + #define RTCA3_RCR2_HR24 BIT(6) 73 + #define RTCA3_RCR2_CNTMD BIT(7) 74 + #define RTCA3_RSR 0x20 75 + #define RTCA3_RSR_AF BIT(0) 76 + #define RTCA3_RSR_CF BIT(1) 77 + #define RTCA3_RSR_PF BIT(2) 78 + #define RTCA3_RADJ 0x2e 79 + #define RTCA3_RADJ_ADJ GENMASK(5, 0) 80 + #define RTCA3_RADJ_ADJ_MAX 0x3f 81 + #define RTCA3_RADJ_PMADJ GENMASK(7, 6) 82 + #define RTCA3_RADJ_PMADJ_NONE 0 83 + #define RTCA3_RADJ_PMADJ_ADD 1 84 + #define RTCA3_RADJ_PMADJ_SUB 2 85 + 86 + /* Polling operation timeouts. */ 87 + #define RTCA3_DEFAULT_TIMEOUT_US 150 88 + #define RTCA3_IRQSET_TIMEOUT_US 5000 89 + #define RTCA3_START_TIMEOUT_US 150000 90 + #define RTCA3_RESET_TIMEOUT_US 200000 91 + 92 + /** 93 + * enum rtca3_alrm_set_step - RTCA3 alarm set steps 94 + * @RTCA3_ALRM_SSTEP_DONE: alarm setup done step 95 + * @RTCA3_ALRM_SSTEP_IRQ: two 1/64 periodic IRQs were generated step 96 + * @RTCA3_ALRM_SSTEP_INIT: alarm setup initialization step 97 + */ 98 + enum rtca3_alrm_set_step { 99 + RTCA3_ALRM_SSTEP_DONE = 0, 100 + RTCA3_ALRM_SSTEP_IRQ = 1, 101 + RTCA3_ALRM_SSTEP_INIT = 3, 102 + }; 103 + 104 + /** 105 + * struct rtca3_ppb_per_cycle - PPB per cycle 106 + * @ten_sec: PPB per cycle in 10 seconds adjutment mode 107 + * @sixty_sec: PPB per cycle in 60 seconds adjustment mode 108 + */ 109 + struct rtca3_ppb_per_cycle { 110 + int ten_sec; 111 + int sixty_sec; 112 + }; 113 + 114 + /** 115 + * struct rtca3_priv - RTCA3 private data structure 116 + * @base: base address 117 + * @rtc_dev: RTC device 118 + * @rstc: reset control 119 + * @set_alarm_completion: alarm setup completion 120 + * @alrm_sstep: alarm setup step (see enum rtca3_alrm_set_step) 121 + * @lock: device lock 122 + * @ppb: ppb per cycle for each the available adjustment modes 123 + * @wakeup_irq: wakeup IRQ 124 + */ 125 + struct rtca3_priv { 126 + void __iomem *base; 127 + struct rtc_device *rtc_dev; 128 + struct reset_control *rstc; 129 + struct completion set_alarm_completion; 130 + atomic_t alrm_sstep; 131 + spinlock_t lock; 132 + struct rtca3_ppb_per_cycle ppb; 133 + int wakeup_irq; 134 + }; 135 + 136 + static void rtca3_byte_update_bits(struct rtca3_priv *priv, u8 off, u8 mask, u8 val) 137 + { 138 + u8 tmp; 139 + 140 + tmp = readb(priv->base + off); 141 + tmp &= ~mask; 142 + tmp |= (val & mask); 143 + writeb(tmp, priv->base + off); 144 + } 145 + 146 + static u8 rtca3_alarm_handler_helper(struct rtca3_priv *priv) 147 + { 148 + u8 val, pending; 149 + 150 + val = readb(priv->base + RTCA3_RSR); 151 + pending = val & RTCA3_RSR_AF; 152 + writeb(val & ~pending, priv->base + RTCA3_RSR); 153 + 154 + if (pending) 155 + rtc_update_irq(priv->rtc_dev, 1, RTC_AF | RTC_IRQF); 156 + 157 + return pending; 158 + } 159 + 160 + static irqreturn_t rtca3_alarm_handler(int irq, void *dev_id) 161 + { 162 + struct rtca3_priv *priv = dev_id; 163 + u8 pending; 164 + 165 + guard(spinlock)(&priv->lock); 166 + 167 + pending = rtca3_alarm_handler_helper(priv); 168 + 169 + return IRQ_RETVAL(pending); 170 + } 171 + 172 + static irqreturn_t rtca3_periodic_handler(int irq, void *dev_id) 173 + { 174 + struct rtca3_priv *priv = dev_id; 175 + u8 val, pending; 176 + 177 + guard(spinlock)(&priv->lock); 178 + 179 + val = readb(priv->base + RTCA3_RSR); 180 + pending = val & RTCA3_RSR_PF; 181 + 182 + if (pending) { 183 + writeb(val & ~pending, priv->base + RTCA3_RSR); 184 + 185 + if (atomic_read(&priv->alrm_sstep) > RTCA3_ALRM_SSTEP_IRQ) { 186 + /* Alarm setup in progress. */ 187 + atomic_dec(&priv->alrm_sstep); 188 + 189 + if (atomic_read(&priv->alrm_sstep) == RTCA3_ALRM_SSTEP_IRQ) { 190 + /* 191 + * We got 2 * 1/64 periodic interrupts. Disable 192 + * interrupt and let alarm setup continue. 193 + */ 194 + rtca3_byte_update_bits(priv, RTCA3_RCR1, 195 + RTCA3_RCR1_PIE, 0); 196 + readb_poll_timeout_atomic(priv->base + RTCA3_RCR1, val, 197 + !(val & RTCA3_RCR1_PIE), 198 + 10, RTCA3_DEFAULT_TIMEOUT_US); 199 + complete(&priv->set_alarm_completion); 200 + } 201 + } 202 + } 203 + 204 + return IRQ_RETVAL(pending); 205 + } 206 + 207 + static void rtca3_prepare_cntalrm_regs_for_read(struct rtca3_priv *priv, bool cnt) 208 + { 209 + /* Offset b/w time and alarm registers. */ 210 + u8 offset = cnt ? 0 : 0xe; 211 + 212 + /* 213 + * According to HW manual (section 22.6.4. Notes on writing to and 214 + * reading from registers) after writing to count registers, alarm 215 + * registers, year alarm enable register, bits RCR2.AADJE, AADJP, 216 + * and HR24 register, we need to do 3 empty reads before being 217 + * able to fetch the registers content. 218 + */ 219 + for (u8 i = 0; i < 3; i++) { 220 + readb(priv->base + RTCA3_RSECCNT + offset); 221 + readb(priv->base + RTCA3_RMINCNT + offset); 222 + readb(priv->base + RTCA3_RHRCNT + offset); 223 + readb(priv->base + RTCA3_RWKCNT + offset); 224 + readb(priv->base + RTCA3_RDAYCNT + offset); 225 + readw(priv->base + RTCA3_RYRCNT + offset); 226 + if (!cnt) 227 + readb(priv->base + RTCA3_RYRAREN); 228 + } 229 + } 230 + 231 + static int rtca3_read_time(struct device *dev, struct rtc_time *tm) 232 + { 233 + struct rtca3_priv *priv = dev_get_drvdata(dev); 234 + u8 sec, min, hour, wday, mday, month, tmp; 235 + u8 trials = 0; 236 + u32 year100; 237 + u16 year; 238 + 239 + guard(spinlock_irqsave)(&priv->lock); 240 + 241 + tmp = readb(priv->base + RTCA3_RCR2); 242 + if (!(tmp & RTCA3_RCR2_START)) 243 + return -EINVAL; 244 + 245 + do { 246 + /* Clear carry interrupt. */ 247 + rtca3_byte_update_bits(priv, RTCA3_RSR, RTCA3_RSR_CF, 0); 248 + 249 + /* Read counters. */ 250 + sec = readb(priv->base + RTCA3_RSECCNT); 251 + min = readb(priv->base + RTCA3_RMINCNT); 252 + hour = readb(priv->base + RTCA3_RHRCNT); 253 + wday = readb(priv->base + RTCA3_RWKCNT); 254 + mday = readb(priv->base + RTCA3_RDAYCNT); 255 + month = readb(priv->base + RTCA3_RMONCNT); 256 + year = readw(priv->base + RTCA3_RYRCNT); 257 + 258 + tmp = readb(priv->base + RTCA3_RSR); 259 + 260 + /* 261 + * We cannot generate carries due to reading 64Hz counter as 262 + * the driver doesn't implement carry, thus, carries will be 263 + * generated once per seconds. Add a timeout of 5 trials here 264 + * to avoid infinite loop, if any. 265 + */ 266 + } while ((tmp & RTCA3_RSR_CF) && ++trials < 5); 267 + 268 + if (trials >= 5) 269 + return -ETIMEDOUT; 270 + 271 + tm->tm_sec = bcd2bin(FIELD_GET(RTCA3_RSECCNT_SEC, sec)); 272 + tm->tm_min = bcd2bin(FIELD_GET(RTCA3_RMINCNT_MIN, min)); 273 + tm->tm_hour = bcd2bin(FIELD_GET(RTCA3_RHRCNT_HR, hour)); 274 + tm->tm_wday = bcd2bin(FIELD_GET(RTCA3_RWKCNT_WK, wday)); 275 + tm->tm_mday = bcd2bin(FIELD_GET(RTCA3_RDAYCNT_DAY, mday)); 276 + tm->tm_mon = bcd2bin(FIELD_GET(RTCA3_RMONCNT_MONTH, month)) - 1; 277 + year = FIELD_GET(RTCA3_RYRCNT_YEAR, year); 278 + year100 = bcd2bin((year == 0x99) ? 0x19 : 0x20); 279 + tm->tm_year = (year100 * 100 + bcd2bin(year)) - 1900; 280 + 281 + return 0; 282 + } 283 + 284 + static int rtca3_set_time(struct device *dev, struct rtc_time *tm) 285 + { 286 + struct rtca3_priv *priv = dev_get_drvdata(dev); 287 + u8 rcr2, tmp; 288 + int ret; 289 + 290 + guard(spinlock_irqsave)(&priv->lock); 291 + 292 + /* Stop the RTC. */ 293 + rcr2 = readb(priv->base + RTCA3_RCR2); 294 + writeb(rcr2 & ~RTCA3_RCR2_START, priv->base + RTCA3_RCR2); 295 + ret = readb_poll_timeout_atomic(priv->base + RTCA3_RCR2, tmp, 296 + !(tmp & RTCA3_RCR2_START), 297 + 10, RTCA3_DEFAULT_TIMEOUT_US); 298 + if (ret) 299 + return ret; 300 + 301 + /* Update time. */ 302 + writeb(bin2bcd(tm->tm_sec), priv->base + RTCA3_RSECCNT); 303 + writeb(bin2bcd(tm->tm_min), priv->base + RTCA3_RMINCNT); 304 + writeb(bin2bcd(tm->tm_hour), priv->base + RTCA3_RHRCNT); 305 + writeb(bin2bcd(tm->tm_wday), priv->base + RTCA3_RWKCNT); 306 + writeb(bin2bcd(tm->tm_mday), priv->base + RTCA3_RDAYCNT); 307 + writeb(bin2bcd(tm->tm_mon + 1), priv->base + RTCA3_RMONCNT); 308 + writew(bin2bcd(tm->tm_year % 100), priv->base + RTCA3_RYRCNT); 309 + 310 + /* Make sure we can read back the counters. */ 311 + rtca3_prepare_cntalrm_regs_for_read(priv, true); 312 + 313 + /* Start RTC. */ 314 + writeb(rcr2 | RTCA3_RCR2_START, priv->base + RTCA3_RCR2); 315 + return readb_poll_timeout_atomic(priv->base + RTCA3_RCR2, tmp, 316 + (tmp & RTCA3_RCR2_START), 317 + 10, RTCA3_DEFAULT_TIMEOUT_US); 318 + } 319 + 320 + static int rtca3_alarm_irq_set_helper(struct rtca3_priv *priv, 321 + u8 interrupts, 322 + unsigned int enabled) 323 + { 324 + u8 tmp, val; 325 + 326 + if (enabled) { 327 + /* 328 + * AIE, CIE, PIE bit indexes in RSR corresponds with 329 + * those on RCR1. Same interrupts mask can be used. 330 + */ 331 + rtca3_byte_update_bits(priv, RTCA3_RSR, interrupts, 0); 332 + val = interrupts; 333 + } else { 334 + val = 0; 335 + } 336 + 337 + rtca3_byte_update_bits(priv, RTCA3_RCR1, interrupts, val); 338 + return readb_poll_timeout_atomic(priv->base + RTCA3_RCR1, tmp, 339 + ((tmp & interrupts) == val), 340 + 10, RTCA3_IRQSET_TIMEOUT_US); 341 + } 342 + 343 + static int rtca3_alarm_irq_enable(struct device *dev, unsigned int enabled) 344 + { 345 + struct rtca3_priv *priv = dev_get_drvdata(dev); 346 + 347 + guard(spinlock_irqsave)(&priv->lock); 348 + 349 + return rtca3_alarm_irq_set_helper(priv, RTCA3_RCR1_AIE, enabled); 350 + } 351 + 352 + static int rtca3_read_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) 353 + { 354 + struct rtca3_priv *priv = dev_get_drvdata(dev); 355 + u8 sec, min, hour, wday, mday, month; 356 + struct rtc_time *tm = &wkalrm->time; 357 + u32 year100; 358 + u16 year; 359 + 360 + guard(spinlock_irqsave)(&priv->lock); 361 + 362 + sec = readb(priv->base + RTCA3_RSECAR); 363 + min = readb(priv->base + RTCA3_RMINAR); 364 + hour = readb(priv->base + RTCA3_RHRAR); 365 + wday = readb(priv->base + RTCA3_RWKAR); 366 + mday = readb(priv->base + RTCA3_RDAYAR); 367 + month = readb(priv->base + RTCA3_RMONAR); 368 + year = readw(priv->base + RTCA3_RYRAR); 369 + 370 + tm->tm_sec = bcd2bin(FIELD_GET(RTCA3_RSECAR_SEC, sec)); 371 + tm->tm_min = bcd2bin(FIELD_GET(RTCA3_RMINAR_MIN, min)); 372 + tm->tm_hour = bcd2bin(FIELD_GET(RTCA3_RHRAR_HR, hour)); 373 + tm->tm_wday = bcd2bin(FIELD_GET(RTCA3_RWKAR_DAYW, wday)); 374 + tm->tm_mday = bcd2bin(FIELD_GET(RTCA3_RDAYAR_DATE, mday)); 375 + tm->tm_mon = bcd2bin(FIELD_GET(RTCA3_RMONAR_MON, month)) - 1; 376 + year = FIELD_GET(RTCA3_RYRAR_YR, year); 377 + year100 = bcd2bin((year == 0x99) ? 0x19 : 0x20); 378 + tm->tm_year = (year100 * 100 + bcd2bin(year)) - 1900; 379 + 380 + wkalrm->enabled = !!(readb(priv->base + RTCA3_RCR1) & RTCA3_RCR1_AIE); 381 + 382 + return 0; 383 + } 384 + 385 + static int rtca3_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) 386 + { 387 + struct rtca3_priv *priv = dev_get_drvdata(dev); 388 + struct rtc_time *tm = &wkalrm->time; 389 + u8 rcr1, tmp; 390 + int ret; 391 + 392 + scoped_guard(spinlock_irqsave, &priv->lock) { 393 + tmp = readb(priv->base + RTCA3_RCR2); 394 + if (!(tmp & RTCA3_RCR2_START)) 395 + return -EPERM; 396 + 397 + /* Disable AIE to prevent false interrupts. */ 398 + rcr1 = readb(priv->base + RTCA3_RCR1); 399 + rcr1 &= ~RTCA3_RCR1_AIE; 400 + writeb(rcr1, priv->base + RTCA3_RCR1); 401 + ret = readb_poll_timeout_atomic(priv->base + RTCA3_RCR1, tmp, 402 + !(tmp & RTCA3_RCR1_AIE), 403 + 10, RTCA3_DEFAULT_TIMEOUT_US); 404 + if (ret) 405 + return ret; 406 + 407 + /* Set the time and enable the alarm. */ 408 + writeb(RTCA3_AR_ENB | bin2bcd(tm->tm_sec), priv->base + RTCA3_RSECAR); 409 + writeb(RTCA3_AR_ENB | bin2bcd(tm->tm_min), priv->base + RTCA3_RMINAR); 410 + writeb(RTCA3_AR_ENB | bin2bcd(tm->tm_hour), priv->base + RTCA3_RHRAR); 411 + writeb(RTCA3_AR_ENB | bin2bcd(tm->tm_wday), priv->base + RTCA3_RWKAR); 412 + writeb(RTCA3_AR_ENB | bin2bcd(tm->tm_mday), priv->base + RTCA3_RDAYAR); 413 + writeb(RTCA3_AR_ENB | bin2bcd(tm->tm_mon + 1), priv->base + RTCA3_RMONAR); 414 + 415 + writew(bin2bcd(tm->tm_year % 100), priv->base + RTCA3_RYRAR); 416 + writeb(RTCA3_AR_ENB, priv->base + RTCA3_RYRAREN); 417 + 418 + /* Make sure we can read back the counters. */ 419 + rtca3_prepare_cntalrm_regs_for_read(priv, false); 420 + 421 + /* Need to wait for 2 * 1/64 periodic interrupts to be generated. */ 422 + atomic_set(&priv->alrm_sstep, RTCA3_ALRM_SSTEP_INIT); 423 + reinit_completion(&priv->set_alarm_completion); 424 + 425 + /* Enable periodic interrupt. */ 426 + rcr1 |= RTCA3_RCR1_PIE; 427 + writeb(rcr1, priv->base + RTCA3_RCR1); 428 + ret = readb_poll_timeout_atomic(priv->base + RTCA3_RCR1, tmp, 429 + (tmp & RTCA3_RCR1_PIE), 430 + 10, RTCA3_IRQSET_TIMEOUT_US); 431 + } 432 + 433 + if (ret) 434 + goto setup_failed; 435 + 436 + /* Wait for the 2 * 1/64 periodic interrupts. */ 437 + ret = wait_for_completion_interruptible_timeout(&priv->set_alarm_completion, 438 + msecs_to_jiffies(500)); 439 + if (ret <= 0) { 440 + ret = -ETIMEDOUT; 441 + goto setup_failed; 442 + } 443 + 444 + scoped_guard(spinlock_irqsave, &priv->lock) { 445 + ret = rtca3_alarm_irq_set_helper(priv, RTCA3_RCR1_AIE, wkalrm->enabled); 446 + atomic_set(&priv->alrm_sstep, RTCA3_ALRM_SSTEP_DONE); 447 + } 448 + 449 + return ret; 450 + 451 + setup_failed: 452 + scoped_guard(spinlock_irqsave, &priv->lock) { 453 + /* 454 + * Disable PIE to avoid interrupt storm in case HW needed more than 455 + * specified timeout for setup. 456 + */ 457 + writeb(rcr1 & ~RTCA3_RCR1_PIE, priv->base + RTCA3_RCR1); 458 + readb_poll_timeout_atomic(priv->base + RTCA3_RCR1, tmp, !(tmp & ~RTCA3_RCR1_PIE), 459 + 10, RTCA3_DEFAULT_TIMEOUT_US); 460 + atomic_set(&priv->alrm_sstep, RTCA3_ALRM_SSTEP_DONE); 461 + } 462 + 463 + return ret; 464 + } 465 + 466 + static int rtca3_read_offset(struct device *dev, long *offset) 467 + { 468 + struct rtca3_priv *priv = dev_get_drvdata(dev); 469 + u8 val, radj, cycles; 470 + u32 ppb_per_cycle; 471 + 472 + scoped_guard(spinlock_irqsave, &priv->lock) { 473 + radj = readb(priv->base + RTCA3_RADJ); 474 + val = readb(priv->base + RTCA3_RCR2); 475 + } 476 + 477 + cycles = FIELD_GET(RTCA3_RADJ_ADJ, radj); 478 + 479 + if (!cycles) { 480 + *offset = 0; 481 + return 0; 482 + } 483 + 484 + if (val & RTCA3_RCR2_ADJP) 485 + ppb_per_cycle = priv->ppb.ten_sec; 486 + else 487 + ppb_per_cycle = priv->ppb.sixty_sec; 488 + 489 + *offset = cycles * ppb_per_cycle; 490 + val = FIELD_GET(RTCA3_RADJ_PMADJ, radj); 491 + if (val == RTCA3_RADJ_PMADJ_SUB) 492 + *offset = -(*offset); 493 + 494 + return 0; 495 + } 496 + 497 + static int rtca3_set_offset(struct device *dev, long offset) 498 + { 499 + struct rtca3_priv *priv = dev_get_drvdata(dev); 500 + int cycles, cycles10, cycles60; 501 + u8 radj, adjp, tmp; 502 + int ret; 503 + 504 + /* 505 + * Automatic time error adjustment could be set at intervals of 10 506 + * or 60 seconds. 507 + */ 508 + cycles10 = DIV_ROUND_CLOSEST(offset, priv->ppb.ten_sec); 509 + cycles60 = DIV_ROUND_CLOSEST(offset, priv->ppb.sixty_sec); 510 + 511 + /* We can set b/w 1 and 63 clock cycles. */ 512 + if (cycles60 >= -RTCA3_RADJ_ADJ_MAX && 513 + cycles60 <= RTCA3_RADJ_ADJ_MAX) { 514 + cycles = cycles60; 515 + adjp = 0; 516 + } else if (cycles10 >= -RTCA3_RADJ_ADJ_MAX && 517 + cycles10 <= RTCA3_RADJ_ADJ_MAX) { 518 + cycles = cycles10; 519 + adjp = RTCA3_RCR2_ADJP; 520 + } else { 521 + return -ERANGE; 522 + } 523 + 524 + radj = FIELD_PREP(RTCA3_RADJ_ADJ, abs(cycles)); 525 + if (!cycles) 526 + radj |= FIELD_PREP(RTCA3_RADJ_PMADJ, RTCA3_RADJ_PMADJ_NONE); 527 + else if (cycles > 0) 528 + radj |= FIELD_PREP(RTCA3_RADJ_PMADJ, RTCA3_RADJ_PMADJ_ADD); 529 + else 530 + radj |= FIELD_PREP(RTCA3_RADJ_PMADJ, RTCA3_RADJ_PMADJ_SUB); 531 + 532 + guard(spinlock_irqsave)(&priv->lock); 533 + 534 + tmp = readb(priv->base + RTCA3_RCR2); 535 + 536 + if ((tmp & RTCA3_RCR2_ADJP) != adjp) { 537 + /* RADJ.PMADJ need to be set to zero before setting RCR2.ADJP. */ 538 + writeb(0, priv->base + RTCA3_RADJ); 539 + ret = readb_poll_timeout_atomic(priv->base + RTCA3_RADJ, tmp, !tmp, 540 + 10, RTCA3_DEFAULT_TIMEOUT_US); 541 + if (ret) 542 + return ret; 543 + 544 + rtca3_byte_update_bits(priv, RTCA3_RCR2, RTCA3_RCR2_ADJP, adjp); 545 + ret = readb_poll_timeout_atomic(priv->base + RTCA3_RCR2, tmp, 546 + ((tmp & RTCA3_RCR2_ADJP) == adjp), 547 + 10, RTCA3_DEFAULT_TIMEOUT_US); 548 + if (ret) 549 + return ret; 550 + } 551 + 552 + writeb(radj, priv->base + RTCA3_RADJ); 553 + return readb_poll_timeout_atomic(priv->base + RTCA3_RADJ, tmp, (tmp == radj), 554 + 10, RTCA3_DEFAULT_TIMEOUT_US); 555 + } 556 + 557 + static const struct rtc_class_ops rtca3_ops = { 558 + .read_time = rtca3_read_time, 559 + .set_time = rtca3_set_time, 560 + .read_alarm = rtca3_read_alarm, 561 + .set_alarm = rtca3_set_alarm, 562 + .alarm_irq_enable = rtca3_alarm_irq_enable, 563 + .set_offset = rtca3_set_offset, 564 + .read_offset = rtca3_read_offset, 565 + }; 566 + 567 + static int rtca3_initial_setup(struct clk *clk, struct rtca3_priv *priv) 568 + { 569 + unsigned long osc32k_rate; 570 + u8 val, tmp, mask; 571 + u32 sleep_us; 572 + int ret; 573 + 574 + osc32k_rate = clk_get_rate(clk); 575 + if (!osc32k_rate) 576 + return -EINVAL; 577 + 578 + sleep_us = DIV_ROUND_UP_ULL(1000000ULL, osc32k_rate) * 6; 579 + 580 + priv->ppb.ten_sec = DIV_ROUND_CLOSEST_ULL(1000000000ULL, (osc32k_rate * 10)); 581 + priv->ppb.sixty_sec = DIV_ROUND_CLOSEST_ULL(1000000000ULL, (osc32k_rate * 60)); 582 + 583 + /* 584 + * According to HW manual (section 22.4.2. Clock and count mode setting procedure) 585 + * we need to wait at least 6 cycles of the 32KHz clock after clock was enabled. 586 + */ 587 + usleep_range(sleep_us, sleep_us + 10); 588 + 589 + /* Disable all interrupts. */ 590 + mask = RTCA3_RCR1_AIE | RTCA3_RCR1_CIE | RTCA3_RCR1_PIE; 591 + ret = rtca3_alarm_irq_set_helper(priv, mask, 0); 592 + if (ret) 593 + return ret; 594 + 595 + mask = RTCA3_RCR2_START | RTCA3_RCR2_HR24; 596 + val = readb(priv->base + RTCA3_RCR2); 597 + /* Nothing to do if already started in 24 hours and calendar count mode. */ 598 + if ((val & mask) == mask) 599 + return 0; 600 + 601 + /* Reconfigure the RTC in 24 hours and calendar count mode. */ 602 + mask = RTCA3_RCR2_START | RTCA3_RCR2_CNTMD; 603 + writeb(0, priv->base + RTCA3_RCR2); 604 + ret = readb_poll_timeout(priv->base + RTCA3_RCR2, tmp, !(tmp & mask), 605 + 10, RTCA3_DEFAULT_TIMEOUT_US); 606 + if (ret) 607 + return ret; 608 + 609 + /* 610 + * Set 24 hours mode. According to HW manual (section 22.3.19. RTC Control 611 + * Register 2) this needs to be done separate from stop operation. 612 + */ 613 + mask = RTCA3_RCR2_HR24; 614 + val = RTCA3_RCR2_HR24; 615 + writeb(val, priv->base + RTCA3_RCR2); 616 + ret = readb_poll_timeout(priv->base + RTCA3_RCR2, tmp, (tmp & mask), 617 + 10, RTCA3_DEFAULT_TIMEOUT_US); 618 + if (ret) 619 + return ret; 620 + 621 + /* Execute reset. */ 622 + mask = RTCA3_RCR2_RESET; 623 + writeb(val | RTCA3_RCR2_RESET, priv->base + RTCA3_RCR2); 624 + ret = readb_poll_timeout(priv->base + RTCA3_RCR2, tmp, !(tmp & mask), 625 + 10, RTCA3_RESET_TIMEOUT_US); 626 + if (ret) 627 + return ret; 628 + 629 + /* 630 + * According to HW manual (section 22.6.3. Notes on writing to and reading 631 + * from registers) after reset we need to wait 6 clock cycles before 632 + * writing to RTC registers. 633 + */ 634 + usleep_range(sleep_us, sleep_us + 10); 635 + 636 + /* Set no adjustment. */ 637 + writeb(0, priv->base + RTCA3_RADJ); 638 + ret = readb_poll_timeout(priv->base + RTCA3_RADJ, tmp, !tmp, 10, 639 + RTCA3_DEFAULT_TIMEOUT_US); 640 + 641 + /* Start the RTC and enable automatic time error adjustment. */ 642 + mask = RTCA3_RCR2_START | RTCA3_RCR2_AADJE; 643 + val |= RTCA3_RCR2_START | RTCA3_RCR2_AADJE; 644 + writeb(val, priv->base + RTCA3_RCR2); 645 + ret = readb_poll_timeout(priv->base + RTCA3_RCR2, tmp, ((tmp & mask) == mask), 646 + 10, RTCA3_START_TIMEOUT_US); 647 + if (ret) 648 + return ret; 649 + 650 + /* 651 + * According to HW manual (section 22.6.4. Notes on writing to and reading 652 + * from registers) we need to wait 1/128 seconds while the clock is operating 653 + * (RCR2.START bit = 1) to be able to read the counters after a return from 654 + * reset. 655 + */ 656 + usleep_range(8000, 9000); 657 + 658 + /* Set period interrupt to 1/64 seconds. It is necessary for alarm setup. */ 659 + val = FIELD_PREP(RTCA3_RCR1_PES, RTCA3_RCR1_PES_1_64_SEC); 660 + rtca3_byte_update_bits(priv, RTCA3_RCR1, RTCA3_RCR1_PES, val); 661 + return readb_poll_timeout(priv->base + RTCA3_RCR1, tmp, ((tmp & RTCA3_RCR1_PES) == val), 662 + 10, RTCA3_DEFAULT_TIMEOUT_US); 663 + } 664 + 665 + static int rtca3_request_irqs(struct platform_device *pdev, struct rtca3_priv *priv) 666 + { 667 + struct device *dev = &pdev->dev; 668 + int ret, irq; 669 + 670 + irq = platform_get_irq_byname(pdev, "alarm"); 671 + if (irq < 0) 672 + return dev_err_probe(dev, irq, "Failed to get alarm IRQ!\n"); 673 + 674 + ret = devm_request_irq(dev, irq, rtca3_alarm_handler, 0, "rtca3-alarm", priv); 675 + if (ret) 676 + return dev_err_probe(dev, ret, "Failed to request alarm IRQ!\n"); 677 + priv->wakeup_irq = irq; 678 + 679 + irq = platform_get_irq_byname(pdev, "period"); 680 + if (irq < 0) 681 + return dev_err_probe(dev, irq, "Failed to get period IRQ!\n"); 682 + 683 + ret = devm_request_irq(dev, irq, rtca3_periodic_handler, 0, "rtca3-period", priv); 684 + if (ret) 685 + return dev_err_probe(dev, ret, "Failed to request period IRQ!\n"); 686 + 687 + /* 688 + * Driver doesn't implement carry handler. Just get the IRQ here 689 + * for backward compatibility, in case carry support will be added later. 690 + */ 691 + irq = platform_get_irq_byname(pdev, "carry"); 692 + if (irq < 0) 693 + return dev_err_probe(dev, irq, "Failed to get carry IRQ!\n"); 694 + 695 + return 0; 696 + } 697 + 698 + static void rtca3_action(void *data) 699 + { 700 + struct device *dev = data; 701 + struct rtca3_priv *priv = dev_get_drvdata(dev); 702 + int ret; 703 + 704 + ret = reset_control_assert(priv->rstc); 705 + if (ret) 706 + dev_err(dev, "Failed to de-assert reset!"); 707 + 708 + ret = pm_runtime_put_sync(dev); 709 + if (ret < 0) 710 + dev_err(dev, "Failed to runtime suspend!"); 711 + } 712 + 713 + static int rtca3_probe(struct platform_device *pdev) 714 + { 715 + struct device *dev = &pdev->dev; 716 + struct rtca3_priv *priv; 717 + struct clk *clk; 718 + int ret; 719 + 720 + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 721 + if (!priv) 722 + return -ENOMEM; 723 + 724 + priv->base = devm_platform_ioremap_resource(pdev, 0); 725 + if (IS_ERR(priv->base)) 726 + return PTR_ERR(priv->base); 727 + 728 + ret = devm_pm_runtime_enable(dev); 729 + if (ret) 730 + return ret; 731 + 732 + priv->rstc = devm_reset_control_get_shared(dev, NULL); 733 + if (IS_ERR(priv->rstc)) 734 + return PTR_ERR(priv->rstc); 735 + 736 + ret = pm_runtime_resume_and_get(dev); 737 + if (ret) 738 + return ret; 739 + 740 + ret = reset_control_deassert(priv->rstc); 741 + if (ret) { 742 + pm_runtime_put_sync(dev); 743 + return ret; 744 + } 745 + 746 + dev_set_drvdata(dev, priv); 747 + ret = devm_add_action_or_reset(dev, rtca3_action, dev); 748 + if (ret) 749 + return ret; 750 + 751 + /* 752 + * This must be an always-on clock to keep the RTC running even after 753 + * driver is unbinded. 754 + */ 755 + clk = devm_clk_get_enabled(dev, "counter"); 756 + if (IS_ERR(clk)) 757 + return PTR_ERR(clk); 758 + 759 + spin_lock_init(&priv->lock); 760 + atomic_set(&priv->alrm_sstep, RTCA3_ALRM_SSTEP_DONE); 761 + init_completion(&priv->set_alarm_completion); 762 + 763 + ret = rtca3_initial_setup(clk, priv); 764 + if (ret) 765 + return dev_err_probe(dev, ret, "Failed to setup the RTC!\n"); 766 + 767 + ret = rtca3_request_irqs(pdev, priv); 768 + if (ret) 769 + return ret; 770 + 771 + device_init_wakeup(&pdev->dev, 1); 772 + 773 + priv->rtc_dev = devm_rtc_allocate_device(&pdev->dev); 774 + if (IS_ERR(priv->rtc_dev)) 775 + return PTR_ERR(priv->rtc_dev); 776 + 777 + priv->rtc_dev->ops = &rtca3_ops; 778 + priv->rtc_dev->max_user_freq = 256; 779 + priv->rtc_dev->range_min = RTC_TIMESTAMP_BEGIN_2000; 780 + priv->rtc_dev->range_max = RTC_TIMESTAMP_END_2099; 781 + 782 + return devm_rtc_register_device(priv->rtc_dev); 783 + } 784 + 785 + static void rtca3_remove(struct platform_device *pdev) 786 + { 787 + struct rtca3_priv *priv = platform_get_drvdata(pdev); 788 + 789 + guard(spinlock_irqsave)(&priv->lock); 790 + 791 + /* 792 + * Disable alarm, periodic interrupts. The RTC device cannot 793 + * power up the system. 794 + */ 795 + rtca3_alarm_irq_set_helper(priv, RTCA3_RCR1_AIE | RTCA3_RCR1_PIE, 0); 796 + } 797 + 798 + static int rtca3_suspend(struct device *dev) 799 + { 800 + struct rtca3_priv *priv = dev_get_drvdata(dev); 801 + 802 + if (!device_may_wakeup(dev)) 803 + return 0; 804 + 805 + /* Alarm setup in progress. */ 806 + if (atomic_read(&priv->alrm_sstep) != RTCA3_ALRM_SSTEP_DONE) 807 + return -EBUSY; 808 + 809 + enable_irq_wake(priv->wakeup_irq); 810 + 811 + return 0; 812 + } 813 + 814 + static int rtca3_clean_alarm(struct rtca3_priv *priv) 815 + { 816 + struct rtc_device *rtc_dev = priv->rtc_dev; 817 + time64_t alarm_time, now; 818 + struct rtc_wkalrm alarm; 819 + struct rtc_time tm; 820 + u8 pending; 821 + int ret; 822 + 823 + ret = rtc_read_alarm(rtc_dev, &alarm); 824 + if (ret) 825 + return ret; 826 + 827 + if (!alarm.enabled) 828 + return 0; 829 + 830 + ret = rtc_read_time(rtc_dev, &tm); 831 + if (ret) 832 + return ret; 833 + 834 + alarm_time = rtc_tm_to_time64(&alarm.time); 835 + now = rtc_tm_to_time64(&tm); 836 + if (alarm_time >= now) 837 + return 0; 838 + 839 + /* 840 + * Heuristically, it has been determined that when returning from deep 841 + * sleep state the RTCA3_RSR.AF is zero even though the alarm expired. 842 + * Call again the rtc_update_irq() if alarm helper detects this. 843 + */ 844 + 845 + guard(spinlock_irqsave)(&priv->lock); 846 + 847 + pending = rtca3_alarm_handler_helper(priv); 848 + if (!pending) 849 + rtc_update_irq(priv->rtc_dev, 1, RTC_AF | RTC_IRQF); 850 + 851 + return 0; 852 + } 853 + 854 + static int rtca3_resume(struct device *dev) 855 + { 856 + struct rtca3_priv *priv = dev_get_drvdata(dev); 857 + 858 + if (!device_may_wakeup(dev)) 859 + return 0; 860 + 861 + disable_irq_wake(priv->wakeup_irq); 862 + 863 + /* 864 + * According to the HW manual (section 22.6.4 Notes on writing to 865 + * and reading from registers) we need to wait 1/128 seconds while 866 + * RCR2.START = 1 to be able to read the counters after a return from low 867 + * power consumption state. 868 + */ 869 + mdelay(8); 870 + 871 + /* 872 + * The alarm cannot wake the system from deep sleep states. In case 873 + * we return from deep sleep states and the alarm expired we need 874 + * to disable it to avoid failures when setting another alarm. 875 + */ 876 + return rtca3_clean_alarm(priv); 877 + } 878 + 879 + static DEFINE_SIMPLE_DEV_PM_OPS(rtca3_pm_ops, rtca3_suspend, rtca3_resume); 880 + 881 + static const struct of_device_id rtca3_of_match[] = { 882 + { .compatible = "renesas,rz-rtca3", }, 883 + { /* sentinel */ } 884 + }; 885 + MODULE_DEVICE_TABLE(of, rtca3_of_match); 886 + 887 + static struct platform_driver rtca3_platform_driver = { 888 + .driver = { 889 + .name = "rtc-rtca3", 890 + .pm = pm_ptr(&rtca3_pm_ops), 891 + .of_match_table = rtca3_of_match, 892 + }, 893 + .probe = rtca3_probe, 894 + .remove = rtca3_remove, 895 + }; 896 + module_platform_driver(rtca3_platform_driver); 897 + 898 + MODULE_DESCRIPTION("Renesas RTCA-3 RTC driver"); 899 + MODULE_AUTHOR("Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>"); 900 + MODULE_LICENSE("GPL");
+1 -1
drivers/rtc/rtc-rtd119x.c
··· 228 228 229 229 static struct platform_driver rtd119x_rtc_driver = { 230 230 .probe = rtd119x_rtc_probe, 231 - .remove_new = rtd119x_rtc_remove, 231 + .remove = rtd119x_rtc_remove, 232 232 .driver = { 233 233 .name = "rtd1295-rtc", 234 234 .of_match_table = rtd119x_rtc_dt_ids,
+4 -2
drivers/rtc/rtc-rv3028.c
··· 120 120 { 121 121 struct rv3028_data *rv3028 = dev_get_drvdata(dev->parent); 122 122 struct rtc_time tm; 123 - int ret, count; 123 + unsigned int count; 124 124 u8 date[6]; 125 + int ret; 125 126 126 127 ret = regmap_read(rv3028->regmap, RV3028_TS_COUNT, &count); 127 128 if (ret) ··· 157 156 struct device_attribute *attr, char *buf) 158 157 { 159 158 struct rv3028_data *rv3028 = dev_get_drvdata(dev->parent); 160 - int ret, count; 159 + unsigned int count; 160 + int ret; 161 161 162 162 ret = regmap_read(rv3028->regmap, RV3028_TS_COUNT, &count); 163 163 if (ret)
+34 -58
drivers/rtc/rtc-rzn1.c
··· 7 7 * - 2022 Schneider Electric 8 8 * 9 9 * Authors: 10 - * - Michel Pollet <michel.pollet@bp.renesas.com>, <buserror@gmail.com> 10 + * - Michel Pollet <buserror@gmail.com> 11 11 * - Miquel Raynal <miquel.raynal@bootlin.com> 12 12 */ 13 13 ··· 35 35 #define RZN1_RTC_CTL2_WUST BIT(5) 36 36 #define RZN1_RTC_CTL2_STOPPED (RZN1_RTC_CTL2_WAIT | RZN1_RTC_CTL2_WST) 37 37 38 - #define RZN1_RTC_SEC 0x14 39 - #define RZN1_RTC_MIN 0x18 40 - #define RZN1_RTC_HOUR 0x1c 41 - #define RZN1_RTC_WEEK 0x20 42 - #define RZN1_RTC_DAY 0x24 43 - #define RZN1_RTC_MONTH 0x28 44 - #define RZN1_RTC_YEAR 0x2c 38 + #define RZN1_RTC_TIME 0x30 39 + #define RZN1_RTC_TIME_MIN_SHIFT 8 40 + #define RZN1_RTC_TIME_HOUR_SHIFT 16 41 + #define RZN1_RTC_CAL 0x34 42 + #define RZN1_RTC_CAL_DAY_SHIFT 8 43 + #define RZN1_RTC_CAL_MON_SHIFT 16 44 + #define RZN1_RTC_CAL_YEAR_SHIFT 24 45 45 46 46 #define RZN1_RTC_SUBU 0x38 47 47 #define RZN1_RTC_SUBU_DEV BIT(7) ··· 52 52 #define RZN1_RTC_ALW 0x48 53 53 54 54 #define RZN1_RTC_SECC 0x4c 55 - #define RZN1_RTC_MINC 0x50 56 - #define RZN1_RTC_HOURC 0x54 57 - #define RZN1_RTC_WEEKC 0x58 58 - #define RZN1_RTC_DAYC 0x5c 59 - #define RZN1_RTC_MONTHC 0x60 60 - #define RZN1_RTC_YEARC 0x64 55 + #define RZN1_RTC_TIMEC 0x68 56 + #define RZN1_RTC_CALC 0x6c 61 57 62 58 struct rzn1_rtc { 63 59 struct rtc_device *rtcdev; ··· 62 66 63 67 static void rzn1_rtc_get_time_snapshot(struct rzn1_rtc *rtc, struct rtc_time *tm) 64 68 { 65 - tm->tm_sec = readl(rtc->base + RZN1_RTC_SECC); 66 - tm->tm_min = readl(rtc->base + RZN1_RTC_MINC); 67 - tm->tm_hour = readl(rtc->base + RZN1_RTC_HOURC); 68 - tm->tm_wday = readl(rtc->base + RZN1_RTC_WEEKC); 69 - tm->tm_mday = readl(rtc->base + RZN1_RTC_DAYC); 70 - tm->tm_mon = readl(rtc->base + RZN1_RTC_MONTHC); 71 - tm->tm_year = readl(rtc->base + RZN1_RTC_YEARC); 72 - } 69 + u32 val; 73 70 74 - static unsigned int rzn1_rtc_tm_to_wday(struct rtc_time *tm) 75 - { 76 - time64_t time; 77 - unsigned int days; 78 - u32 secs; 71 + val = readl(rtc->base + RZN1_RTC_TIMEC); 72 + tm->tm_sec = bcd2bin(val); 73 + tm->tm_min = bcd2bin(val >> RZN1_RTC_TIME_MIN_SHIFT); 74 + tm->tm_hour = bcd2bin(val >> RZN1_RTC_TIME_HOUR_SHIFT); 79 75 80 - time = rtc_tm_to_time64(tm); 81 - days = div_s64_rem(time, 86400, &secs); 82 - 83 - /* day of the week, 1970-01-01 was a Thursday */ 84 - return (days + 4) % 7; 76 + val = readl(rtc->base + RZN1_RTC_CALC); 77 + tm->tm_wday = val & 0x0f; 78 + tm->tm_mday = bcd2bin(val >> RZN1_RTC_CAL_DAY_SHIFT); 79 + tm->tm_mon = bcd2bin(val >> RZN1_RTC_CAL_MON_SHIFT) - 1; 80 + tm->tm_year = bcd2bin(val >> RZN1_RTC_CAL_YEAR_SHIFT) + 100; 85 81 } 86 82 87 83 static int rzn1_rtc_read_time(struct device *dev, struct rtc_time *tm) ··· 91 103 92 104 rzn1_rtc_get_time_snapshot(rtc, tm); 93 105 secs = readl(rtc->base + RZN1_RTC_SECC); 94 - if (tm->tm_sec != secs) 106 + if (tm->tm_sec != bcd2bin(secs)) 95 107 rzn1_rtc_get_time_snapshot(rtc, tm); 96 - 97 - tm->tm_sec = bcd2bin(tm->tm_sec); 98 - tm->tm_min = bcd2bin(tm->tm_min); 99 - tm->tm_hour = bcd2bin(tm->tm_hour); 100 - tm->tm_wday = bcd2bin(tm->tm_wday); 101 - tm->tm_mday = bcd2bin(tm->tm_mday); 102 - tm->tm_mon = bcd2bin(tm->tm_mon); 103 - tm->tm_year = bcd2bin(tm->tm_year); 104 108 105 109 return 0; 106 110 } ··· 102 122 struct rzn1_rtc *rtc = dev_get_drvdata(dev); 103 123 u32 val; 104 124 int ret; 105 - 106 - tm->tm_sec = bin2bcd(tm->tm_sec); 107 - tm->tm_min = bin2bcd(tm->tm_min); 108 - tm->tm_hour = bin2bcd(tm->tm_hour); 109 - tm->tm_wday = bin2bcd(rzn1_rtc_tm_to_wday(tm)); 110 - tm->tm_mday = bin2bcd(tm->tm_mday); 111 - tm->tm_mon = bin2bcd(tm->tm_mon); 112 - tm->tm_year = bin2bcd(tm->tm_year); 113 125 114 126 val = readl(rtc->base + RZN1_RTC_CTL2); 115 127 if (!(val & RZN1_RTC_CTL2_STOPPED)) { ··· 116 144 return ret; 117 145 } 118 146 119 - writel(tm->tm_sec, rtc->base + RZN1_RTC_SEC); 120 - writel(tm->tm_min, rtc->base + RZN1_RTC_MIN); 121 - writel(tm->tm_hour, rtc->base + RZN1_RTC_HOUR); 122 - writel(tm->tm_wday, rtc->base + RZN1_RTC_WEEK); 123 - writel(tm->tm_mday, rtc->base + RZN1_RTC_DAY); 124 - writel(tm->tm_mon, rtc->base + RZN1_RTC_MONTH); 125 - writel(tm->tm_year, rtc->base + RZN1_RTC_YEAR); 147 + val = bin2bcd(tm->tm_sec); 148 + val |= bin2bcd(tm->tm_min) << RZN1_RTC_TIME_MIN_SHIFT; 149 + val |= bin2bcd(tm->tm_hour) << RZN1_RTC_TIME_HOUR_SHIFT; 150 + writel(val, rtc->base + RZN1_RTC_TIME); 151 + 152 + val = tm->tm_wday; 153 + val |= bin2bcd(tm->tm_mday) << RZN1_RTC_CAL_DAY_SHIFT; 154 + val |= bin2bcd(tm->tm_mon + 1) << RZN1_RTC_CAL_MON_SHIFT; 155 + val |= bin2bcd(tm->tm_year - 100) << RZN1_RTC_CAL_YEAR_SHIFT; 156 + writel(val, rtc->base + RZN1_RTC_CAL); 157 + 126 158 writel(0, rtc->base + RZN1_RTC_CTL2); 127 159 128 160 return 0; ··· 381 405 382 406 static struct platform_driver rzn1_rtc_driver = { 383 407 .probe = rzn1_rtc_probe, 384 - .remove_new = rzn1_rtc_remove, 408 + .remove = rzn1_rtc_remove, 385 409 .driver = { 386 410 .name = "rzn1-rtc", 387 411 .of_match_table = rzn1_rtc_of_match, ··· 389 413 }; 390 414 module_platform_driver(rzn1_rtc_driver); 391 415 392 - MODULE_AUTHOR("Michel Pollet <Michel.Pollet@bp.renesas.com"); 416 + MODULE_AUTHOR("Michel Pollet <buserror@gmail.com>"); 393 417 MODULE_AUTHOR("Miquel Raynal <miquel.raynal@bootlin.com"); 394 418 MODULE_DESCRIPTION("RZ/N1 RTC driver"); 395 419 MODULE_LICENSE("GPL");
+1 -1
drivers/rtc/rtc-s3c.c
··· 597 597 598 598 static struct platform_driver s3c_rtc_driver = { 599 599 .probe = s3c_rtc_probe, 600 - .remove_new = s3c_rtc_remove, 600 + .remove = s3c_rtc_remove, 601 601 .driver = { 602 602 .name = "s3c-rtc", 603 603 .pm = &s3c_rtc_pm_ops,
+1 -1
drivers/rtc/rtc-sa1100.c
··· 341 341 342 342 static struct platform_driver sa1100_rtc_driver = { 343 343 .probe = sa1100_rtc_probe, 344 - .remove_new = sa1100_rtc_remove, 344 + .remove = sa1100_rtc_remove, 345 345 .driver = { 346 346 .name = "sa1100-rtc", 347 347 .pm = &sa1100_rtc_pm_ops,
+1 -1
drivers/rtc/rtc-sh.c
··· 678 678 .pm = &sh_rtc_pm_ops, 679 679 .of_match_table = sh_rtc_of_match, 680 680 }, 681 - .remove_new = __exit_p(sh_rtc_remove), 681 + .remove = __exit_p(sh_rtc_remove), 682 682 }; 683 683 684 684 module_platform_driver_probe(sh_rtc_platform_driver, sh_rtc_probe);
+1 -1
drivers/rtc/rtc-spear.c
··· 475 475 476 476 static struct platform_driver spear_rtc_driver = { 477 477 .probe = spear_rtc_probe, 478 - .remove_new = spear_rtc_remove, 478 + .remove = spear_rtc_remove, 479 479 .shutdown = spear_rtc_shutdown, 480 480 .driver = { 481 481 .name = "rtc-spear",
+2 -3
drivers/rtc/rtc-st-lpc.c
··· 218 218 return -EINVAL; 219 219 } 220 220 221 - ret = devm_request_irq(&pdev->dev, rtc->irq, st_rtc_handler, 0, 222 - pdev->name, rtc); 221 + ret = devm_request_irq(&pdev->dev, rtc->irq, st_rtc_handler, 222 + IRQF_NO_AUTOEN, pdev->name, rtc); 223 223 if (ret) { 224 224 dev_err(&pdev->dev, "Failed to request irq %i\n", rtc->irq); 225 225 return ret; 226 226 } 227 227 228 228 enable_irq_wake(rtc->irq); 229 - disable_irq(rtc->irq); 230 229 231 230 rtc->clk = devm_clk_get_enabled(&pdev->dev, NULL); 232 231 if (IS_ERR(rtc->clk))
+1 -1
drivers/rtc/rtc-stm32.c
··· 1287 1287 1288 1288 static struct platform_driver stm32_rtc_driver = { 1289 1289 .probe = stm32_rtc_probe, 1290 - .remove_new = stm32_rtc_remove, 1290 + .remove = stm32_rtc_remove, 1291 1291 .driver = { 1292 1292 .name = DRIVER_NAME, 1293 1293 .pm = &stm32_rtc_pm_ops,
+1 -1
drivers/rtc/rtc-stmp3xxx.c
··· 403 403 404 404 static struct platform_driver stmp3xxx_rtcdrv = { 405 405 .probe = stmp3xxx_rtc_probe, 406 - .remove_new = stmp3xxx_rtc_remove, 406 + .remove = stmp3xxx_rtc_remove, 407 407 .driver = { 408 408 .name = "stmp3xxx-rtc", 409 409 .pm = &stmp3xxx_rtc_pm_ops,
+1 -1
drivers/rtc/rtc-sunplus.c
··· 344 344 345 345 static struct platform_driver sp_rtc_driver = { 346 346 .probe = sp_rtc_probe, 347 - .remove_new = sp_rtc_remove, 347 + .remove = sp_rtc_remove, 348 348 .driver = { 349 349 .name = "sp7021-rtc", 350 350 .of_match_table = sp_rtc_of_match,
+1 -1
drivers/rtc/rtc-tegra.c
··· 399 399 400 400 static struct platform_driver tegra_rtc_driver = { 401 401 .probe = tegra_rtc_probe, 402 - .remove_new = tegra_rtc_remove, 402 + .remove = tegra_rtc_remove, 403 403 .shutdown = tegra_rtc_shutdown, 404 404 .driver = { 405 405 .name = "tegra_rtc",
+1 -1
drivers/rtc/rtc-tps6586x.c
··· 317 317 .pm = &tps6586x_pm_ops, 318 318 }, 319 319 .probe = tps6586x_rtc_probe, 320 - .remove_new = tps6586x_rtc_remove, 320 + .remove = tps6586x_rtc_remove, 321 321 }; 322 322 module_platform_driver(tps6586x_rtc_driver); 323 323
+1 -1
drivers/rtc/rtc-twl.c
··· 673 673 674 674 static struct platform_driver twl4030rtc_driver = { 675 675 .probe = twl_rtc_probe, 676 - .remove_new = twl_rtc_remove, 676 + .remove = twl_rtc_remove, 677 677 .shutdown = twl_rtc_shutdown, 678 678 .driver = { 679 679 .name = "twl_rtc",
+1 -1
drivers/rtc/rtc-vt8500.c
··· 251 251 252 252 static struct platform_driver vt8500_rtc_driver = { 253 253 .probe = vt8500_rtc_probe, 254 - .remove_new = vt8500_rtc_remove, 254 + .remove = vt8500_rtc_remove, 255 255 .driver = { 256 256 .name = "vt8500-rtc", 257 257 .of_match_table = wmt_dt_ids,
+1 -1
drivers/rtc/rtc-wm8350.c
··· 459 459 460 460 static struct platform_driver wm8350_rtc_driver = { 461 461 .probe = wm8350_rtc_probe, 462 - .remove_new = wm8350_rtc_remove, 462 + .remove = wm8350_rtc_remove, 463 463 .driver = { 464 464 .name = "wm8350-rtc", 465 465 .pm = &wm8350_rtc_pm_ops,
+1 -1
drivers/rtc/rtc-xgene.c
··· 263 263 264 264 static struct platform_driver xgene_rtc_driver = { 265 265 .probe = xgene_rtc_probe, 266 - .remove_new = xgene_rtc_remove, 266 + .remove = xgene_rtc_remove, 267 267 .driver = { 268 268 .name = "xgene-rtc", 269 269 .pm = &xgene_rtc_pm_ops,
+1 -1
drivers/rtc/rtc-zynqmp.c
··· 382 382 383 383 static struct platform_driver xlnx_rtc_driver = { 384 384 .probe = xlnx_rtc_probe, 385 - .remove_new = xlnx_rtc_remove, 385 + .remove = xlnx_rtc_remove, 386 386 .driver = { 387 387 .name = KBUILD_MODNAME, 388 388 .pm = &xlnx_rtc_pm_ops,
+9
include/linux/mfd/88pm886.h
··· 31 31 #define PM886_INT_WC BIT(1) 32 32 #define PM886_INT_MASK_MODE BIT(2) 33 33 34 + #define PM886_REG_RTC_CNT1 0xd1 35 + #define PM886_REG_RTC_CNT2 0xd2 36 + #define PM886_REG_RTC_CNT3 0xd3 37 + #define PM886_REG_RTC_CNT4 0xd4 38 + #define PM886_REG_RTC_SPARE1 0xea 39 + #define PM886_REG_RTC_SPARE2 0xeb 40 + #define PM886_REG_RTC_SPARE3 0xec 41 + #define PM886_REG_RTC_SPARE4 0xed 42 + #define PM886_REG_RTC_SPARE5 0xee 34 43 #define PM886_REG_RTC_SPARE6 0xef 35 44 36 45 #define PM886_REG_BUCK_EN 0x08
+3
include/linux/rtc/m48t59.h
··· 56 56 void __iomem *ioaddr; 57 57 /* offset to RTC registers, automatically set according to the type */ 58 58 unsigned int offset; 59 + 60 + /* YY digits (in RTC) are offset, i.e. year is 1900 + yy_offset + YY */ 61 + int yy_offset; 59 62 }; 60 63 61 64 #endif /* _LINUX_RTC_M48T59_H_ */