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

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

Pull RTC updates from Alexandre Belloni:
"Subsystem:
- stop setting max_user_freq from the individual drivers as this has
not been hardware related for a while

New drivers:
- Andes ATCRTC100
- Apple SMC
- Nvidia VRS

Drivers:
- renesas-rtca3: add RZ/V2H support
- tegra: add ACPI support"

* tag 'rtc-6.19' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (34 commits)
rtc: spacemit: MFD_SPACEMIT_P1 as dependencies
rtc: atcrtc100: Fix signedness bug in probe()
rtc: max31335: Fix ignored return value in set_alarm
rtc: gamecube: Check the return value of ioremap()
Documentation: ABI: testing: Fix "upto" typo in rtc-cdev
rtc: Add new rtc-macsmc driver for Apple Silicon Macs
dt-bindings: rtc: Add Apple SMC RTC
MAINTAINERS: drop unneeded file entry in NVIDIA VRS RTC DRIVER
rtc: isl12026: Add id_table
rtc: renesas-rtca3: Add support for multiple reset lines
dt-bindings: rtc: renesas,rz-rtca3: Add RZ/V2H support
rtc: tegra: Replace deprecated SIMPLE_DEV_PM_OPS
rtc: tegra: Add ACPI support
rtc: tegra: Use devm_clk_get_enabled() in probe
rtc: Kconfig: add MC34708 to mc13xxx help text
rtc: s35390a: use u8 instead of char for register buffer
rtc: nvvrs: add NVIDIA VRS RTC device driver
dt-bindings: rtc: Document NVIDIA VRS RTC
rtc: atcrtc100: Add ATCRTC100 RTC driver
MAINTAINERS: Add entry for ATCRTC100 RTC driver
...

+1352 -100
+1 -1
Documentation/ABI/testing/rtc-cdev
··· 14 14 for RTCs that support alarms 15 15 16 16 * RTC_ALM_READ, RTC_ALM_SET: Read or set the alarm time for 17 - RTCs that support alarms. Can be set upto 24 hours in the 17 + RTCs that support alarms. Can be set up to 24 hours in the 18 18 future. Requires a separate RTC_AIE_ON call to enable the 19 19 alarm interrupt. (Prefer to use RTC_WKALM_*) 20 20
+9
Documentation/devicetree/bindings/mfd/apple,smc.yaml
··· 46 46 reboot: 47 47 $ref: /schemas/power/reset/apple,smc-reboot.yaml 48 48 49 + rtc: 50 + $ref: /schemas/rtc/apple,smc-rtc.yaml 51 + 49 52 additionalProperties: false 50 53 51 54 required: ··· 83 80 nvmem-cell-names = "shutdown_flag", "boot_stage", 84 81 "boot_error_count", "panic_count"; 85 82 }; 83 + 84 + rtc { 85 + compatible = "apple,smc-rtc"; 86 + nvmem-cells = <&rtc_offset>; 87 + nvmem-cell-names = "rtc_offset"; 88 + }; 86 89 }; 87 90 };
+43
Documentation/devicetree/bindings/rtc/andestech,atcrtc100.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/andestech,atcrtc100.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Andes ATCRTC100 Real-Time Clock 8 + 9 + maintainers: 10 + - CL Wang <cl634@andestech.com> 11 + 12 + allOf: 13 + - $ref: rtc.yaml# 14 + 15 + properties: 16 + compatible: 17 + enum: 18 + - andestech,atcrtc100 19 + 20 + reg: 21 + maxItems: 1 22 + 23 + interrupts: 24 + items: 25 + - description: Periodic timekeeping interrupt 26 + - description: RTC alarm interrupt 27 + 28 + required: 29 + - compatible 30 + - reg 31 + - interrupts 32 + 33 + unevaluatedProperties: false 34 + 35 + examples: 36 + - | 37 + #include <dt-bindings/interrupt-controller/irq.h> 38 + 39 + rtc@f0300000 { 40 + compatible = "andestech,atcrtc100"; 41 + reg = <0xf0300000 0x100>; 42 + interrupts = <1 IRQ_TYPE_LEVEL_HIGH>, <2 IRQ_TYPE_LEVEL_HIGH>; 43 + };
+35
Documentation/devicetree/bindings/rtc/apple,smc-rtc.yaml
··· 1 + # SPDX-License-Identifier: (GPL-2.0-only OR BSD-2-Clause) 2 + %YAML 1.2 3 + --- 4 + $id: http://devicetree.org/schemas/rtc/apple,smc-rtc.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Apple SMC RTC 8 + 9 + description: 10 + Apple Silicon Macs (M1, etc.) have an RTC that is part of the PMU IC, 11 + but most of the PMU functionality is abstracted out by the SMC. 12 + An additional RTC offset stored inside NVMEM is required to compute 13 + the current date/time. 14 + 15 + maintainers: 16 + - Sven Peter <sven@kernel.org> 17 + 18 + properties: 19 + compatible: 20 + const: apple,smc-rtc 21 + 22 + nvmem-cells: 23 + items: 24 + - description: 48bit RTC offset, specified in 32768 (2^15) Hz clock ticks 25 + 26 + nvmem-cell-names: 27 + items: 28 + - const: rtc_offset 29 + 30 + required: 31 + - compatible 32 + - nvmem-cells 33 + - nvmem-cell-names 34 + 35 + additionalProperties: false
+59
Documentation/devicetree/bindings/rtc/nvidia,vrs-10.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/nvidia,vrs-10.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: NVIDIA Voltage Regulator Specification Real Time Clock 8 + 9 + maintainers: 10 + - Shubhi Garg <shgarg@nvidia.com> 11 + 12 + description: 13 + NVIDIA VRS-10 (Voltage Regulator Specification) is a Power Management IC 14 + (PMIC) that implements a power sequencing solution with I2C interface. 15 + The device includes a real-time clock (RTC) with 32kHz clock output and 16 + backup battery support, alarm functionality for system wake-up from 17 + suspend and shutdown states, OTP memory for power sequencing configuration, 18 + and an interrupt controller for managing VRS events. 19 + 20 + properties: 21 + compatible: 22 + const: nvidia,vrs-10 23 + 24 + reg: 25 + maxItems: 1 26 + 27 + interrupts: 28 + maxItems: 1 29 + 30 + interrupt-controller: true 31 + 32 + '#interrupt-cells': 33 + const: 2 34 + 35 + required: 36 + - compatible 37 + - reg 38 + - interrupts 39 + - interrupt-controller 40 + - '#interrupt-cells' 41 + 42 + additionalProperties: false 43 + 44 + examples: 45 + - | 46 + #include <dt-bindings/interrupt-controller/irq.h> 47 + i2c { 48 + #address-cells = <1>; 49 + #size-cells = <0>; 50 + 51 + pmic@3c { 52 + compatible = "nvidia,vrs-10"; 53 + reg = <0x3c>; 54 + interrupt-parent = <&pmc>; 55 + interrupts = <24 IRQ_TYPE_LEVEL_LOW>; 56 + interrupt-controller; 57 + #interrupt-cells = <2>; 58 + }; 59 + };
+41 -5
Documentation/devicetree/bindings/rtc/renesas,rz-rtca3.yaml
··· 9 9 maintainers: 10 10 - Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com> 11 11 12 - allOf: 13 - - $ref: rtc.yaml# 14 - 15 12 properties: 16 13 compatible: 17 14 items: 18 15 - enum: 19 16 - renesas,r9a08g045-rtca3 # RZ/G3S 17 + - renesas,r9a09g057-rtca3 # RZ/V2H 20 18 - const: renesas,rz-rtca3 21 19 22 20 reg: ··· 46 48 maxItems: 1 47 49 48 50 resets: 49 - items: 50 - - description: VBATTB module reset 51 + minItems: 1 52 + maxItems: 2 53 + 54 + reset-names: 55 + minItems: 1 56 + maxItems: 2 51 57 52 58 required: 53 59 - compatible ··· 62 60 - clock-names 63 61 - power-domains 64 62 - resets 63 + 64 + allOf: 65 + - $ref: rtc.yaml# 66 + 67 + - if: 68 + properties: 69 + compatible: 70 + contains: 71 + const: renesas,r9a08g045-rtca3 72 + then: 73 + properties: 74 + resets: 75 + items: 76 + - description: VBATTB module reset 77 + reset-names: 78 + const: vbattb 79 + - if: 80 + properties: 81 + compatible: 82 + contains: 83 + const: renesas,r9a09g057-rtca3 84 + then: 85 + properties: 86 + resets: 87 + items: 88 + - description: RTC reset 89 + - description: Reset for the RTEST registers 90 + reset-names: 91 + items: 92 + - const: rtc 93 + - const: rtest 94 + required: 95 + - reset-names 65 96 66 97 additionalProperties: false 67 98 ··· 116 81 clock-names = "bus", "counter"; 117 82 power-domains = <&cpg>; 118 83 resets = <&cpg R9A08G045_VBAT_BRESETN>; 84 + reset-names = "vbattb"; 119 85 };
+15
MAINTAINERS
··· 2475 2475 F: Documentation/devicetree/bindings/power/apple* 2476 2476 F: Documentation/devicetree/bindings/power/reset/apple,smc-reboot.yaml 2477 2477 F: Documentation/devicetree/bindings/pwm/apple,s5l-fpwm.yaml 2478 + F: Documentation/devicetree/bindings/rtc/apple,smc-rtc.yaml 2478 2479 F: Documentation/devicetree/bindings/spi/apple,spi.yaml 2479 2480 F: Documentation/devicetree/bindings/spmi/apple,spmi.yaml 2480 2481 F: Documentation/devicetree/bindings/usb/apple,dwc3.yaml ··· 2502 2501 F: drivers/pinctrl/pinctrl-apple-gpio.c 2503 2502 F: drivers/power/reset/macsmc-reboot.c 2504 2503 F: drivers/pwm/pwm-apple.c 2504 + F: drivers/rtc/rtc-macsmc.c 2505 2505 F: drivers/soc/apple/* 2506 2506 F: drivers/spi/spi-apple.c 2507 2507 F: drivers/spmi/spmi-apple-controller.c ··· 4016 4014 F: drivers/power/reset/atc260x-poweroff.c 4017 4015 F: drivers/regulator/atc260x-regulator.c 4018 4016 F: include/linux/mfd/atc260x/* 4017 + 4018 + ATCRTC100 RTC DRIVER 4019 + M: CL Wang <cl634@andestech.com> 4020 + S: Supported 4021 + F: Documentation/devicetree/bindings/rtc/andestech,atcrtc100.yaml 4022 + F: drivers/rtc/rtc-atcrtc100.c 4019 4023 4020 4024 ATHEROS 71XX/9XXX GPIO DRIVER 4021 4025 M: Alban Bedel <albeu@free.fr> ··· 18699 18691 S: Maintained 18700 18692 F: drivers/video/fbdev/nvidia/ 18701 18693 F: drivers/video/fbdev/riva/ 18694 + 18695 + NVIDIA VRS RTC DRIVER 18696 + M: Shubhi Garg <shgarg@nvidia.com> 18697 + L: linux-tegra@vger.kernel.org 18698 + S: Maintained 18699 + F: Documentation/devicetree/bindings/rtc/nvidia,vrs-10.yaml 18700 + F: drivers/rtc/rtc-nvidia-vrs10.c 18702 18701 18703 18702 NVIDIA WMI EC BACKLIGHT DRIVER 18704 18703 M: Daniel Dadap <ddadap@nvidia.com>
+38 -3
drivers/rtc/Kconfig
··· 409 409 config RTC_DRV_SPACEMIT_P1 410 410 tristate "SpacemiT P1 RTC" 411 411 depends on ARCH_SPACEMIT || COMPILE_TEST 412 - select MFD_SPACEMIT_P1 413 - default ARCH_SPACEMIT 412 + depends on MFD_SPACEMIT_P1 413 + default MFD_SPACEMIT_P1 414 414 help 415 415 Enable support for the RTC function in the SpacemiT P1 PMIC. 416 416 This driver can also be built as a module, which will be called 417 417 "spacemit-p1-rtc". 418 + 419 + config RTC_DRV_NVIDIA_VRS10 420 + tristate "NVIDIA VRS10 RTC device" 421 + help 422 + If you say yes here you will get support for the battery backed RTC device 423 + of NVIDIA VRS (Voltage Regulator Specification). The RTC is connected via 424 + I2C interface and supports alarm functionality. 425 + This driver can also be built as a module. If so, the module will be called 426 + rtc-nvidia-vrs10. 418 427 419 428 config RTC_DRV_NCT3018Y 420 429 tristate "Nuvoton NCT3018Y" ··· 1071 1062 help 1072 1063 Direct support for the real-time clock found on every Alpha 1073 1064 system, specifically MC146818 compatibles. If in doubt, say Y. 1065 + 1066 + config RTC_DRV_ATCRTC100 1067 + tristate "Andes ATCRTC100" 1068 + depends on ARCH_ANDES || COMPILE_TEST 1069 + select REGMAP_MMIO 1070 + help 1071 + If you say yes here you will get support for the Andes ATCRTC100 1072 + RTC driver. 1073 + 1074 + This driver provides support for the Andes ATCRTC100 real-time clock 1075 + device. It allows setting and retrieving the time and date, as well 1076 + as setting alarms. 1077 + 1078 + To compile this driver as a module, choose M here: the module will 1079 + be called rtc-atcrtc100. 1074 1080 1075 1081 config RTC_DRV_DS1216 1076 1082 tristate "Dallas DS1216" ··· 1773 1749 tristate "Freescale MC13xxx RTC" 1774 1750 help 1775 1751 This enables support for the RTCs found on Freescale's PMICs 1776 - MC13783 and MC13892. 1752 + MC13783, MC13892 and MC34708. 1777 1753 1778 1754 config RTC_DRV_MPC5121 1779 1755 tristate "Freescale MPC5121 built-in RTC" ··· 2097 2073 2098 2074 This can also be built as a module. If so, the module will 2099 2075 be named "rtc_wilco_ec". 2076 + 2077 + config RTC_DRV_MACSMC 2078 + tristate "Apple Mac System Management Controller RTC" 2079 + depends on MFD_MACSMC 2080 + help 2081 + If you say yes here you get support for RTC functions 2082 + inside Apple SPMI PMUs accessed through the SoC's 2083 + System Management Controller 2084 + 2085 + To compile this driver as a module, choose M here: the 2086 + module will be called rtc-macsmc. 2100 2087 2101 2088 config RTC_DRV_MSC313 2102 2089 tristate "MStar MSC313 RTC"
+3
drivers/rtc/Makefile
··· 34 34 obj-$(CONFIG_RTC_DRV_ASPEED) += rtc-aspeed.o 35 35 obj-$(CONFIG_RTC_DRV_AT91RM9200)+= rtc-at91rm9200.o 36 36 obj-$(CONFIG_RTC_DRV_AT91SAM9) += rtc-at91sam9.o 37 + obj-$(CONFIG_RTC_DRV_ATCRTC100) += rtc-atcrtc100.o 37 38 obj-$(CONFIG_RTC_DRV_AU1XXX) += rtc-au1xxx.o 38 39 obj-$(CONFIG_RTC_DRV_BBNSM) += rtc-nxp-bbnsm.o 39 40 obj-$(CONFIG_RTC_DRV_BD70528) += rtc-bd70528.o ··· 94 93 obj-$(CONFIG_RTC_DRV_M48T59) += rtc-m48t59.o 95 94 obj-$(CONFIG_RTC_DRV_M48T86) += rtc-m48t86.o 96 95 obj-$(CONFIG_RTC_DRV_MA35D1) += rtc-ma35d1.o 96 + obj-$(CONFIG_RTC_DRV_MACSMC) += rtc-macsmc.o 97 97 obj-$(CONFIG_RTC_DRV_MAX31335) += rtc-max31335.o 98 98 obj-$(CONFIG_RTC_DRV_MAX6900) += rtc-max6900.o 99 99 obj-$(CONFIG_RTC_DRV_MAX6902) += rtc-max6902.o ··· 123 121 obj-$(CONFIG_RTC_DRV_NCT3018Y) += rtc-nct3018y.o 124 122 obj-$(CONFIG_RTC_DRV_NCT6694) += rtc-nct6694.o 125 123 obj-$(CONFIG_RTC_DRV_NTXEC) += rtc-ntxec.o 124 + obj-$(CONFIG_RTC_DRV_NVIDIA_VRS10)+= rtc-nvidia-vrs10.o 126 125 obj-$(CONFIG_RTC_DRV_OMAP) += rtc-omap.o 127 126 obj-$(CONFIG_RTC_DRV_OPAL) += rtc-opal.o 128 127 obj-$(CONFIG_RTC_DRV_OPTEE) += rtc-optee.o
+5 -27
drivers/rtc/rtc-amlogic-a4.c
··· 361 361 "failed to get_enable rtc sys clk\n"); 362 362 aml_rtc_init(rtc); 363 363 364 - device_init_wakeup(dev, true); 364 + devm_device_init_wakeup(dev); 365 365 platform_set_drvdata(pdev, rtc); 366 366 367 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 - } 368 + if (IS_ERR(rtc->rtc_dev)) 369 + return PTR_ERR(rtc->rtc_dev); 372 370 373 371 ret = devm_request_irq(dev, rtc->irq, aml_rtc_handler, 374 372 IRQF_ONESHOT, "aml-rtc alarm", rtc); 375 373 if (ret) { 376 374 dev_err_probe(dev, ret, "IRQ%d request failed, ret = %d\n", 377 375 rtc->irq, ret); 378 - goto err_clk; 376 + return ret; 379 377 } 380 378 381 379 rtc->rtc_dev->ops = &aml_rtc_ops; 382 380 rtc->rtc_dev->range_min = 0; 383 381 rtc->rtc_dev->range_max = U32_MAX; 384 382 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, false); 395 - 396 - return ret; 383 + return devm_rtc_register_device(rtc->rtc_dev); 397 384 } 398 385 399 386 #ifdef CONFIG_PM_SLEEP ··· 408 421 static SIMPLE_DEV_PM_OPS(aml_rtc_pm_ops, 409 422 aml_rtc_suspend, aml_rtc_resume); 410 423 411 - static void aml_rtc_remove(struct platform_device *pdev) 412 - { 413 - struct aml_rtc_data *rtc = dev_get_drvdata(&pdev->dev); 414 - 415 - clk_disable_unprepare(rtc->sys_clk); 416 - device_init_wakeup(&pdev->dev, false); 417 - } 418 - 419 424 static const struct aml_rtc_config a5_rtc_config = { 420 425 }; 421 426 ··· 430 451 431 452 static struct platform_driver aml_rtc_driver = { 432 453 .probe = aml_rtc_probe, 433 - .remove = aml_rtc_remove, 434 454 .driver = { 435 455 .name = "aml-rtc", 436 456 .pm = &aml_rtc_pm_ops,
+381
drivers/rtc/rtc-atcrtc100.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 + /* 3 + * Driver for Andes ATCRTC100 real time clock. 4 + * 5 + * Copyright (C) 2025 Andes Technology Corporation 6 + */ 7 + 8 + #include <linux/bitfield.h> 9 + #include <linux/delay.h> 10 + #include <linux/interrupt.h> 11 + #include <linux/math64.h> 12 + #include <linux/module.h> 13 + #include <linux/of.h> 14 + #include <linux/platform_device.h> 15 + #include <linux/pm_wakeirq.h> 16 + #include <linux/regmap.h> 17 + #include <linux/rtc.h> 18 + #include <linux/workqueue.h> 19 + 20 + /* Register Offsets */ 21 + #define RTC_ID 0x00 /* ID and Revision Register */ 22 + #define RTC_RSV 0x04 /* Reserved Register */ 23 + #define RTC_CNT 0x10 /* Counter Register */ 24 + #define RTC_ALM 0x14 /* Alarm Register */ 25 + #define RTC_CR 0x18 /* Control Register */ 26 + #define RTC_STA 0x1C /* Status Register */ 27 + #define RTC_TRIM 0x20 /* Digital Trimming Register */ 28 + 29 + /* RTC_ID Register */ 30 + #define ID_MSK GENMASK(31, 8) 31 + #define ID_ATCRTC100 0x030110 32 + 33 + /* RTC_CNT and RTC_ALM Register Fields */ 34 + #define SEC_MSK GENMASK(5, 0) 35 + #define MIN_MSK GENMASK(11, 6) 36 + #define HOUR_MSK GENMASK(16, 12) 37 + #define DAY_MSK GENMASK(31, 17) 38 + #define RTC_SEC_GET(x) FIELD_GET(SEC_MSK, x) 39 + #define RTC_MIN_GET(x) FIELD_GET(MIN_MSK, x) 40 + #define RTC_HOUR_GET(x) FIELD_GET(HOUR_MSK, x) 41 + #define RTC_DAY_GET(x) FIELD_GET(DAY_MSK, x) 42 + #define RTC_SEC_SET(x) FIELD_PREP(SEC_MSK, x) 43 + #define RTC_MIN_SET(x) FIELD_PREP(MIN_MSK, x) 44 + #define RTC_HOUR_SET(x) FIELD_PREP(HOUR_MSK, x) 45 + #define RTC_DAY_SET(x) FIELD_PREP(DAY_MSK, x) 46 + 47 + /* RTC_CR Register Bits */ 48 + #define RTC_EN BIT(0) /* RTC Enable */ 49 + #define ALARM_WAKEUP BIT(1) /* Alarm Wakeup Enable */ 50 + #define ALARM_INT BIT(2) /* Alarm Interrupt Enable */ 51 + #define DAY_INT BIT(3) /* Day Interrupt Enable */ 52 + #define HOUR_INT BIT(4) /* Hour Interrupt Enable */ 53 + #define MIN_INT BIT(5) /* Minute Interrupt Enable */ 54 + #define SEC_INT BIT(6) /* Second Periodic Interrupt Enable */ 55 + #define HSEC_INT BIT(7) /* Half-Second Periodic Interrupt Enable */ 56 + 57 + /* RTC_STA Register Bits */ 58 + #define WRITE_DONE BIT(16) /* Register write completion status */ 59 + 60 + /* Time conversion macro */ 61 + #define ATCRTC_TIME_TO_SEC(D, H, M, S) \ 62 + ((time64_t)(D) * 86400 + (H) * 3600 + (M) * 60 + (S)) 63 + 64 + /* Timeout for waiting for the write_done bit */ 65 + #define ATCRTC_TIMEOUT_US 1000000 66 + #define ATCRTC_TIMEOUT_USLEEP_MIN 20 67 + #define ATCRTC_TIMEOUT_USLEEP_MAX 30 68 + 69 + struct atcrtc_dev { 70 + struct rtc_device *rtc_dev; 71 + struct regmap *regmap; 72 + struct work_struct rtc_work; 73 + unsigned int alarm_irq; 74 + bool alarm_en; 75 + }; 76 + 77 + static const struct regmap_config atcrtc_regmap_config = { 78 + .reg_bits = 32, 79 + .reg_stride = 4, 80 + .val_bits = 32, 81 + .max_register = RTC_TRIM, 82 + .cache_type = REGCACHE_NONE, 83 + }; 84 + 85 + /** 86 + * atcrtc_check_write_done - Wait for RTC registers to be synchronized. 87 + * @rtc: Pointer to the atcrtc_dev structure. 88 + * 89 + * The WriteDone bit in the status register indicates the synchronization 90 + * progress of RTC register updates. This bit is cleared to zero whenever 91 + * any RTC control register (Counter, Alarm, Control, etc.) is written. 92 + * It returns to one only after all previous updates have been fully 93 + * synchronized to the RTC clock domain. This function polls the WriteDone 94 + * bit with a timeout to ensure the device is ready for the next operation. 95 + * 96 + * Return: 0 on success, or -EBUSY on timeout. 97 + */ 98 + static int atcrtc_check_write_done(struct atcrtc_dev *rtc) 99 + { 100 + unsigned int val; 101 + 102 + /* 103 + * Using read_poll_timeout is more efficient than a manual loop 104 + * with usleep_range. 105 + */ 106 + return regmap_read_poll_timeout(rtc->regmap, RTC_STA, val, 107 + val & WRITE_DONE, 108 + ATCRTC_TIMEOUT_USLEEP_MIN, 109 + ATCRTC_TIMEOUT_US); 110 + } 111 + 112 + static irqreturn_t atcrtc_alarm_isr(int irq, void *dev) 113 + { 114 + struct atcrtc_dev *rtc = dev; 115 + unsigned int status; 116 + 117 + regmap_read(rtc->regmap, RTC_STA, &status); 118 + if (status & ALARM_INT) { 119 + regmap_write(rtc->regmap, RTC_STA, ALARM_INT); 120 + rtc->alarm_en = false; 121 + schedule_work(&rtc->rtc_work); 122 + rtc_update_irq(rtc->rtc_dev, 1, RTC_AF | RTC_IRQF); 123 + return IRQ_HANDLED; 124 + } 125 + return IRQ_NONE; 126 + } 127 + 128 + static int atcrtc_alarm_irq_enable(struct device *dev, unsigned int enable) 129 + { 130 + struct atcrtc_dev *rtc = dev_get_drvdata(dev); 131 + unsigned int mask; 132 + int ret; 133 + 134 + ret = atcrtc_check_write_done(rtc); 135 + if (ret) 136 + return ret; 137 + 138 + mask = ALARM_WAKEUP | ALARM_INT; 139 + regmap_update_bits(rtc->regmap, RTC_CR, mask, enable ? mask : 0); 140 + 141 + return 0; 142 + } 143 + 144 + static void atcrtc_alarm_clear(struct work_struct *work) 145 + { 146 + struct atcrtc_dev *rtc = 147 + container_of(work, struct atcrtc_dev, rtc_work); 148 + int ret; 149 + 150 + rtc_lock(rtc->rtc_dev); 151 + 152 + if (!rtc->alarm_en) { 153 + ret = atcrtc_check_write_done(rtc); 154 + if (ret) 155 + dev_info(&rtc->rtc_dev->dev, 156 + "failed to sync before clearing alarm: %d\n", 157 + ret); 158 + else 159 + regmap_update_bits(rtc->regmap, RTC_CR, 160 + ALARM_WAKEUP | ALARM_INT, 0); 161 + } 162 + rtc_unlock(rtc->rtc_dev); 163 + } 164 + 165 + static int atcrtc_read_time(struct device *dev, struct rtc_time *tm) 166 + { 167 + struct atcrtc_dev *rtc = dev_get_drvdata(dev); 168 + time64_t time; 169 + unsigned int rtc_cnt; 170 + 171 + if (!regmap_test_bits(rtc->regmap, RTC_CR, RTC_EN)) 172 + return -EIO; 173 + 174 + regmap_read(rtc->regmap, RTC_CNT, &rtc_cnt); 175 + time = ATCRTC_TIME_TO_SEC(RTC_DAY_GET(rtc_cnt), 176 + RTC_HOUR_GET(rtc_cnt), 177 + RTC_MIN_GET(rtc_cnt), 178 + RTC_SEC_GET(rtc_cnt)); 179 + rtc_time64_to_tm(time, tm); 180 + 181 + return 0; 182 + } 183 + 184 + static int atcrtc_set_time(struct device *dev, struct rtc_time *tm) 185 + { 186 + struct atcrtc_dev *rtc = dev_get_drvdata(dev); 187 + time64_t time; 188 + unsigned int counter; 189 + unsigned int day; 190 + int ret; 191 + 192 + time = rtc_tm_to_time64(tm); 193 + day = div_s64(time, 86400); 194 + counter = RTC_DAY_SET(day) | 195 + RTC_HOUR_SET(tm->tm_hour) | 196 + RTC_MIN_SET(tm->tm_min) | 197 + RTC_SEC_SET(tm->tm_sec); 198 + ret = atcrtc_check_write_done(rtc); 199 + if (ret) 200 + return ret; 201 + regmap_write(rtc->regmap, RTC_CNT, counter); 202 + 203 + ret = atcrtc_check_write_done(rtc); 204 + if (ret) 205 + return ret; 206 + regmap_update_bits(rtc->regmap, RTC_CR, RTC_EN, RTC_EN); 207 + 208 + return 0; 209 + } 210 + 211 + static int atcrtc_read_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) 212 + { 213 + struct atcrtc_dev *rtc = dev_get_drvdata(dev); 214 + struct rtc_time *tm = &wkalrm->time; 215 + unsigned int rtc_alarm; 216 + 217 + wkalrm->enabled = regmap_test_bits(rtc->regmap, RTC_CR, ALARM_INT); 218 + regmap_read(rtc->regmap, RTC_ALM, &rtc_alarm); 219 + tm->tm_hour = RTC_HOUR_GET(rtc_alarm); 220 + tm->tm_min = RTC_MIN_GET(rtc_alarm); 221 + tm->tm_sec = RTC_SEC_GET(rtc_alarm); 222 + 223 + /* The RTC alarm does not support day/month/year fields */ 224 + tm->tm_mday = -1; 225 + tm->tm_mon = -1; 226 + tm->tm_year = -1; 227 + 228 + return 0; 229 + } 230 + 231 + static int atcrtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) 232 + { 233 + struct atcrtc_dev *rtc = dev_get_drvdata(dev); 234 + struct rtc_time *tm = &wkalrm->time; 235 + unsigned int rtc_alarm; 236 + int ret; 237 + 238 + /* Disable alarm first before setting a new one */ 239 + ret = atcrtc_alarm_irq_enable(dev, 0); 240 + if (ret) 241 + return ret; 242 + 243 + rtc->alarm_en = false; 244 + 245 + rtc_alarm = RTC_SEC_SET(tm->tm_sec) | 246 + RTC_MIN_SET(tm->tm_min) | 247 + RTC_HOUR_SET(tm->tm_hour); 248 + 249 + ret = atcrtc_check_write_done(rtc); 250 + if (ret) 251 + return ret; 252 + 253 + regmap_write(rtc->regmap, RTC_ALM, rtc_alarm); 254 + 255 + rtc->alarm_en = wkalrm->enabled; 256 + ret = atcrtc_alarm_irq_enable(dev, wkalrm->enabled); 257 + 258 + return ret; 259 + } 260 + 261 + static const struct rtc_class_ops rtc_ops = { 262 + .read_time = atcrtc_read_time, 263 + .set_time = atcrtc_set_time, 264 + .read_alarm = atcrtc_read_alarm, 265 + .set_alarm = atcrtc_set_alarm, 266 + .alarm_irq_enable = atcrtc_alarm_irq_enable, 267 + }; 268 + 269 + static int atcrtc_probe(struct platform_device *pdev) 270 + { 271 + struct atcrtc_dev *atcrtc_dev; 272 + void __iomem *reg_base; 273 + unsigned int rtc_id; 274 + int ret; 275 + 276 + atcrtc_dev = devm_kzalloc(&pdev->dev, sizeof(*atcrtc_dev), GFP_KERNEL); 277 + if (!atcrtc_dev) 278 + return -ENOMEM; 279 + platform_set_drvdata(pdev, atcrtc_dev); 280 + 281 + reg_base = devm_platform_ioremap_resource(pdev, 0); 282 + if (IS_ERR(reg_base)) 283 + return dev_err_probe(&pdev->dev, PTR_ERR(reg_base), 284 + "Failed to map I/O space\n"); 285 + 286 + atcrtc_dev->regmap = devm_regmap_init_mmio(&pdev->dev, 287 + reg_base, 288 + &atcrtc_regmap_config); 289 + if (IS_ERR(atcrtc_dev->regmap)) 290 + return dev_err_probe(&pdev->dev, PTR_ERR(atcrtc_dev->regmap), 291 + "Failed to initialize regmap\n"); 292 + 293 + regmap_read(atcrtc_dev->regmap, RTC_ID, &rtc_id); 294 + if (FIELD_GET(ID_MSK, rtc_id) != ID_ATCRTC100) 295 + return dev_err_probe(&pdev->dev, -ENODEV, 296 + "Failed to initialize RTC: unsupported hardware ID 0x%x\n", 297 + rtc_id); 298 + 299 + ret = platform_get_irq(pdev, 1); 300 + if (ret < 0) 301 + return dev_err_probe(&pdev->dev, ret, 302 + "Failed to get IRQ for alarm\n"); 303 + atcrtc_dev->alarm_irq = ret; 304 + 305 + ret = devm_request_irq(&pdev->dev, 306 + atcrtc_dev->alarm_irq, 307 + atcrtc_alarm_isr, 308 + 0, 309 + "atcrtc_alarm", 310 + atcrtc_dev); 311 + if (ret) 312 + return dev_err_probe(&pdev->dev, ret, 313 + "Failed to request IRQ %d for alarm\n", 314 + atcrtc_dev->alarm_irq); 315 + 316 + atcrtc_dev->rtc_dev = devm_rtc_allocate_device(&pdev->dev); 317 + if (IS_ERR(atcrtc_dev->rtc_dev)) 318 + return dev_err_probe(&pdev->dev, PTR_ERR(atcrtc_dev->rtc_dev), 319 + "Failed to allocate RTC device\n"); 320 + 321 + set_bit(RTC_FEATURE_ALARM, atcrtc_dev->rtc_dev->features); 322 + ret = device_init_wakeup(&pdev->dev, true); 323 + if (ret) 324 + return dev_err_probe(&pdev->dev, ret, 325 + "Failed to initialize wake capability\n"); 326 + 327 + ret = dev_pm_set_wake_irq(&pdev->dev, atcrtc_dev->alarm_irq); 328 + if (ret) { 329 + device_init_wakeup(&pdev->dev, false); 330 + return dev_err_probe(&pdev->dev, ret, 331 + "Failed to set wake IRQ\n"); 332 + } 333 + 334 + atcrtc_dev->rtc_dev->ops = &rtc_ops; 335 + 336 + INIT_WORK(&atcrtc_dev->rtc_work, atcrtc_alarm_clear); 337 + return devm_rtc_register_device(atcrtc_dev->rtc_dev); 338 + } 339 + 340 + static int atcrtc_resume(struct device *dev) 341 + { 342 + struct atcrtc_dev *rtc = dev_get_drvdata(dev); 343 + 344 + if (device_may_wakeup(dev)) 345 + disable_irq_wake(rtc->alarm_irq); 346 + 347 + return 0; 348 + } 349 + 350 + static int atcrtc_suspend(struct device *dev) 351 + { 352 + struct atcrtc_dev *rtc = dev_get_drvdata(dev); 353 + 354 + if (device_may_wakeup(dev)) 355 + enable_irq_wake(rtc->alarm_irq); 356 + 357 + return 0; 358 + } 359 + 360 + static DEFINE_SIMPLE_DEV_PM_OPS(atcrtc_pm_ops, atcrtc_suspend, atcrtc_resume); 361 + 362 + static const struct of_device_id atcrtc_dt_match[] = { 363 + { .compatible = "andestech,atcrtc100" }, 364 + { }, 365 + }; 366 + MODULE_DEVICE_TABLE(of, atcrtc_dt_match); 367 + 368 + static struct platform_driver atcrtc_platform_driver = { 369 + .driver = { 370 + .name = "atcrtc100", 371 + .of_match_table = atcrtc_dt_match, 372 + .pm = pm_sleep_ptr(&atcrtc_pm_ops), 373 + }, 374 + .probe = atcrtc_probe, 375 + }; 376 + 377 + module_platform_driver(atcrtc_platform_driver); 378 + 379 + MODULE_AUTHOR("CL Wang <cl634@andestech.com>"); 380 + MODULE_DESCRIPTION("Andes ATCRTC100 driver"); 381 + MODULE_LICENSE("GPL");
-3
drivers/rtc/rtc-ds1685.c
··· 1268 1268 rtc_dev->range_min = RTC_TIMESTAMP_BEGIN_2000; 1269 1269 rtc_dev->range_max = RTC_TIMESTAMP_END_2099; 1270 1270 1271 - /* Maximum periodic rate is 8192Hz (0.122070ms). */ 1272 - rtc_dev->max_user_freq = RTC_MAX_USER_FREQ; 1273 - 1274 1271 /* See if the platform doesn't support UIE. */ 1275 1272 if (pdata->uie_unsupported) 1276 1273 clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, rtc_dev->features);
+4
drivers/rtc/rtc-gamecube.c
··· 242 242 } 243 243 244 244 hw_srnprot = ioremap(res.start, resource_size(&res)); 245 + if (!hw_srnprot) { 246 + pr_err("failed to ioremap hw_srnprot\n"); 247 + return -ENOMEM; 248 + } 245 249 old = ioread32be(hw_srnprot); 246 250 247 251 /* TODO: figure out why we use this magic constant. I obtained it by
+7
drivers/rtc/rtc-isl12026.c
··· 484 484 }; 485 485 MODULE_DEVICE_TABLE(of, isl12026_dt_match); 486 486 487 + static const struct i2c_device_id isl12026_id[] = { 488 + { "isl12026" }, 489 + { }, 490 + }; 491 + MODULE_DEVICE_TABLE(i2c, isl12026_id); 492 + 487 493 static struct i2c_driver isl12026_driver = { 488 494 .driver = { 489 495 .name = "rtc-isl12026", ··· 497 491 }, 498 492 .probe = isl12026_probe, 499 493 .remove = isl12026_remove, 494 + .id_table = isl12026_id, 500 495 }; 501 496 502 497 module_i2c_driver(isl12026_driver);
+140
drivers/rtc/rtc-macsmc.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only OR MIT 2 + /* 3 + * Apple SMC RTC driver 4 + * Copyright The Asahi Linux Contributors 5 + */ 6 + 7 + #include <linux/bitops.h> 8 + #include <linux/mfd/macsmc.h> 9 + #include <linux/module.h> 10 + #include <linux/nvmem-consumer.h> 11 + #include <linux/of.h> 12 + #include <linux/platform_device.h> 13 + #include <linux/rtc.h> 14 + #include <linux/slab.h> 15 + 16 + /* 48-bit RTC */ 17 + #define RTC_BYTES 6 18 + #define RTC_BITS (8 * RTC_BYTES) 19 + 20 + /* 32768 Hz clock */ 21 + #define RTC_SEC_SHIFT 15 22 + 23 + struct macsmc_rtc { 24 + struct device *dev; 25 + struct apple_smc *smc; 26 + struct rtc_device *rtc_dev; 27 + struct nvmem_cell *rtc_offset; 28 + }; 29 + 30 + static int macsmc_rtc_get_time(struct device *dev, struct rtc_time *tm) 31 + { 32 + struct macsmc_rtc *rtc = dev_get_drvdata(dev); 33 + u64 ctr = 0, off = 0; 34 + time64_t now; 35 + void *p_off; 36 + size_t len; 37 + int ret; 38 + 39 + ret = apple_smc_read(rtc->smc, SMC_KEY(CLKM), &ctr, RTC_BYTES); 40 + if (ret < 0) 41 + return ret; 42 + if (ret != RTC_BYTES) 43 + return -EIO; 44 + 45 + p_off = nvmem_cell_read(rtc->rtc_offset, &len); 46 + if (IS_ERR(p_off)) 47 + return PTR_ERR(p_off); 48 + if (len < RTC_BYTES) { 49 + kfree(p_off); 50 + return -EIO; 51 + } 52 + 53 + memcpy(&off, p_off, RTC_BYTES); 54 + kfree(p_off); 55 + 56 + /* Sign extend from 48 to 64 bits, then arithmetic shift right 15 bits to get seconds */ 57 + now = sign_extend64(ctr + off, RTC_BITS - 1) >> RTC_SEC_SHIFT; 58 + rtc_time64_to_tm(now, tm); 59 + 60 + return ret; 61 + } 62 + 63 + static int macsmc_rtc_set_time(struct device *dev, struct rtc_time *tm) 64 + { 65 + struct macsmc_rtc *rtc = dev_get_drvdata(dev); 66 + u64 ctr = 0, off = 0; 67 + int ret; 68 + 69 + ret = apple_smc_read(rtc->smc, SMC_KEY(CLKM), &ctr, RTC_BYTES); 70 + if (ret < 0) 71 + return ret; 72 + if (ret != RTC_BYTES) 73 + return -EIO; 74 + 75 + /* This sets the offset such that the set second begins now */ 76 + off = (rtc_tm_to_time64(tm) << RTC_SEC_SHIFT) - ctr; 77 + return nvmem_cell_write(rtc->rtc_offset, &off, RTC_BYTES); 78 + } 79 + 80 + static const struct rtc_class_ops macsmc_rtc_ops = { 81 + .read_time = macsmc_rtc_get_time, 82 + .set_time = macsmc_rtc_set_time, 83 + }; 84 + 85 + static int macsmc_rtc_probe(struct platform_device *pdev) 86 + { 87 + struct apple_smc *smc = dev_get_drvdata(pdev->dev.parent); 88 + struct macsmc_rtc *rtc; 89 + 90 + /* 91 + * MFD will probe this device even without a node in the device tree, 92 + * thus bail out early if the SMC on the current machines does not 93 + * support RTC and has no node in the device tree. 94 + */ 95 + if (!pdev->dev.of_node) 96 + return -ENODEV; 97 + 98 + rtc = devm_kzalloc(&pdev->dev, sizeof(*rtc), GFP_KERNEL); 99 + if (!rtc) 100 + return -ENOMEM; 101 + 102 + rtc->dev = &pdev->dev; 103 + rtc->smc = smc; 104 + 105 + rtc->rtc_offset = devm_nvmem_cell_get(&pdev->dev, "rtc_offset"); 106 + if (IS_ERR(rtc->rtc_offset)) 107 + return dev_err_probe(&pdev->dev, PTR_ERR(rtc->rtc_offset), 108 + "Failed to get rtc_offset NVMEM cell\n"); 109 + 110 + rtc->rtc_dev = devm_rtc_allocate_device(&pdev->dev); 111 + if (IS_ERR(rtc->rtc_dev)) 112 + return PTR_ERR(rtc->rtc_dev); 113 + 114 + rtc->rtc_dev->ops = &macsmc_rtc_ops; 115 + rtc->rtc_dev->range_min = S64_MIN >> (RTC_SEC_SHIFT + (64 - RTC_BITS)); 116 + rtc->rtc_dev->range_max = S64_MAX >> (RTC_SEC_SHIFT + (64 - RTC_BITS)); 117 + 118 + platform_set_drvdata(pdev, rtc); 119 + 120 + return devm_rtc_register_device(rtc->rtc_dev); 121 + } 122 + 123 + static const struct of_device_id macsmc_rtc_of_table[] = { 124 + { .compatible = "apple,smc-rtc", }, 125 + {} 126 + }; 127 + MODULE_DEVICE_TABLE(of, macsmc_rtc_of_table); 128 + 129 + static struct platform_driver macsmc_rtc_driver = { 130 + .driver = { 131 + .name = "macsmc-rtc", 132 + .of_match_table = macsmc_rtc_of_table, 133 + }, 134 + .probe = macsmc_rtc_probe, 135 + }; 136 + module_platform_driver(macsmc_rtc_driver); 137 + 138 + MODULE_LICENSE("Dual MIT/GPL"); 139 + MODULE_DESCRIPTION("Apple SMC RTC driver"); 140 + MODULE_AUTHOR("Hector Martin <marcan@marcan.st>");
+2 -4
drivers/rtc/rtc-max31335.c
··· 391 391 if (ret) 392 392 return ret; 393 393 394 - ret = regmap_update_bits(max31335->regmap, max31335->chip->int_status_reg, 395 - MAX31335_STATUS1_A1F, 0); 396 - 397 - return 0; 394 + return regmap_update_bits(max31335->regmap, max31335->chip->int_status_reg, 395 + MAX31335_STATUS1_A1F, 0); 398 396 } 399 397 400 398 static int max31335_alarm_irq_enable(struct device *dev, unsigned int enabled)
+542
drivers/rtc/rtc-nvidia-vrs10.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * NVIDIA Voltage Regulator Specification RTC 4 + * 5 + * SPDX-FileCopyrightText: Copyright (c) 2025 NVIDIA CORPORATION & AFFILIATES. 6 + * All rights reserved. 7 + */ 8 + 9 + #include <linux/bits.h> 10 + #include <linux/err.h> 11 + #include <linux/i2c.h> 12 + #include <linux/interrupt.h> 13 + #include <linux/module.h> 14 + #include <linux/rtc.h> 15 + 16 + #define NVVRS_REG_VENDOR_ID 0x00 17 + #define NVVRS_REG_MODEL_REV 0x01 18 + 19 + /* Interrupts registers */ 20 + #define NVVRS_REG_INT_SRC1 0x10 21 + #define NVVRS_REG_INT_SRC2 0x11 22 + #define NVVRS_REG_INT_VENDOR 0x12 23 + 24 + /* Control Registers */ 25 + #define NVVRS_REG_CTL_1 0x28 26 + #define NVVRS_REG_CTL_2 0x29 27 + 28 + /* RTC Registers */ 29 + #define NVVRS_REG_RTC_T3 0x70 30 + #define NVVRS_REG_RTC_T2 0x71 31 + #define NVVRS_REG_RTC_T1 0x72 32 + #define NVVRS_REG_RTC_T0 0x73 33 + #define NVVRS_REG_RTC_A3 0x74 34 + #define NVVRS_REG_RTC_A2 0x75 35 + #define NVVRS_REG_RTC_A1 0x76 36 + #define NVVRS_REG_RTC_A0 0x77 37 + 38 + /* Interrupt Mask */ 39 + #define NVVRS_INT_SRC1_RSTIRQ_MASK BIT(0) 40 + #define NVVRS_INT_SRC1_OSC_MASK BIT(1) 41 + #define NVVRS_INT_SRC1_EN_MASK BIT(2) 42 + #define NVVRS_INT_SRC1_RTC_MASK BIT(3) 43 + #define NVVRS_INT_SRC1_PEC_MASK BIT(4) 44 + #define NVVRS_INT_SRC1_WDT_MASK BIT(5) 45 + #define NVVRS_INT_SRC1_EM_PD_MASK BIT(6) 46 + #define NVVRS_INT_SRC1_INTERNAL_MASK BIT(7) 47 + #define NVVRS_INT_SRC2_PBSP_MASK BIT(0) 48 + #define NVVRS_INT_SRC2_ECC_DED_MASK BIT(1) 49 + #define NVVRS_INT_SRC2_TSD_MASK BIT(2) 50 + #define NVVRS_INT_SRC2_LDO_MASK BIT(3) 51 + #define NVVRS_INT_SRC2_BIST_MASK BIT(4) 52 + #define NVVRS_INT_SRC2_RT_CRC_MASK BIT(5) 53 + #define NVVRS_INT_SRC2_VENDOR_MASK BIT(7) 54 + #define NVVRS_INT_VENDOR0_MASK BIT(0) 55 + #define NVVRS_INT_VENDOR1_MASK BIT(1) 56 + #define NVVRS_INT_VENDOR2_MASK BIT(2) 57 + #define NVVRS_INT_VENDOR3_MASK BIT(3) 58 + #define NVVRS_INT_VENDOR4_MASK BIT(4) 59 + #define NVVRS_INT_VENDOR5_MASK BIT(5) 60 + #define NVVRS_INT_VENDOR6_MASK BIT(6) 61 + #define NVVRS_INT_VENDOR7_MASK BIT(7) 62 + 63 + /* Controller Register Mask */ 64 + #define NVVRS_REG_CTL_1_FORCE_SHDN (BIT(0) | BIT(1)) 65 + #define NVVRS_REG_CTL_1_FORCE_ACT BIT(2) 66 + #define NVVRS_REG_CTL_1_FORCE_INT BIT(3) 67 + #define NVVRS_REG_CTL_2_EN_PEC BIT(0) 68 + #define NVVRS_REG_CTL_2_REQ_PEC BIT(1) 69 + #define NVVRS_REG_CTL_2_RTC_PU BIT(2) 70 + #define NVVRS_REG_CTL_2_RTC_WAKE BIT(3) 71 + #define NVVRS_REG_CTL_2_RST_DLY 0xF0 72 + 73 + #define ALARM_RESET_VAL 0xffffffff 74 + #define NVVRS_MIN_MODEL_REV 0x40 75 + 76 + enum nvvrs_irq_regs { 77 + NVVRS_IRQ_REG_INT_SRC1 = 0, 78 + NVVRS_IRQ_REG_INT_SRC2 = 1, 79 + NVVRS_IRQ_REG_INT_VENDOR = 2, 80 + NVVRS_IRQ_REG_COUNT = 3, 81 + }; 82 + 83 + struct nvvrs_rtc_info { 84 + struct device *dev; 85 + struct i2c_client *client; 86 + struct rtc_device *rtc; 87 + unsigned int irq; 88 + }; 89 + 90 + static int nvvrs_update_bits(struct nvvrs_rtc_info *info, u8 reg, 91 + u8 mask, u8 value) 92 + { 93 + int ret; 94 + u8 val; 95 + 96 + ret = i2c_smbus_read_byte_data(info->client, reg); 97 + if (ret < 0) 98 + return ret; 99 + 100 + val = (u8)ret; 101 + val &= ~mask; 102 + val |= (value & mask); 103 + 104 + return i2c_smbus_write_byte_data(info->client, reg, val); 105 + } 106 + 107 + static int nvvrs_rtc_write_alarm(struct i2c_client *client, u8 *time) 108 + { 109 + int ret; 110 + 111 + ret = i2c_smbus_write_byte_data(client, NVVRS_REG_RTC_A3, time[3]); 112 + if (ret < 0) 113 + return ret; 114 + 115 + ret = i2c_smbus_write_byte_data(client, NVVRS_REG_RTC_A2, time[2]); 116 + if (ret < 0) 117 + return ret; 118 + 119 + ret = i2c_smbus_write_byte_data(client, NVVRS_REG_RTC_A1, time[1]); 120 + if (ret < 0) 121 + return ret; 122 + 123 + return i2c_smbus_write_byte_data(client, NVVRS_REG_RTC_A0, time[0]); 124 + } 125 + 126 + static int nvvrs_rtc_enable_alarm(struct nvvrs_rtc_info *info) 127 + { 128 + int ret; 129 + 130 + /* Set RTC_WAKE bit for autonomous wake from sleep */ 131 + ret = nvvrs_update_bits(info, NVVRS_REG_CTL_2, NVVRS_REG_CTL_2_RTC_WAKE, 132 + NVVRS_REG_CTL_2_RTC_WAKE); 133 + if (ret < 0) 134 + return ret; 135 + 136 + /* Set RTC_PU bit for autonomous wake from shutdown */ 137 + ret = nvvrs_update_bits(info, NVVRS_REG_CTL_2, NVVRS_REG_CTL_2_RTC_PU, 138 + NVVRS_REG_CTL_2_RTC_PU); 139 + if (ret < 0) 140 + return ret; 141 + 142 + return 0; 143 + } 144 + 145 + static int nvvrs_rtc_disable_alarm(struct nvvrs_rtc_info *info) 146 + { 147 + struct i2c_client *client = info->client; 148 + u8 val[4]; 149 + int ret; 150 + 151 + /* Clear RTC_WAKE bit */ 152 + ret = nvvrs_update_bits(info, NVVRS_REG_CTL_2, NVVRS_REG_CTL_2_RTC_WAKE, 153 + 0); 154 + if (ret < 0) 155 + return ret; 156 + 157 + /* Clear RTC_PU bit */ 158 + ret = nvvrs_update_bits(info, NVVRS_REG_CTL_2, NVVRS_REG_CTL_2_RTC_PU, 159 + 0); 160 + if (ret < 0) 161 + return ret; 162 + 163 + /* Write ALARM_RESET_VAL in RTC Alarm register to disable alarm */ 164 + val[0] = 0xff; 165 + val[1] = 0xff; 166 + val[2] = 0xff; 167 + val[3] = 0xff; 168 + 169 + ret = nvvrs_rtc_write_alarm(client, val); 170 + if (ret < 0) 171 + return ret; 172 + 173 + return 0; 174 + } 175 + 176 + static int nvvrs_rtc_read_time(struct device *dev, struct rtc_time *tm) 177 + { 178 + struct nvvrs_rtc_info *info = dev_get_drvdata(dev); 179 + time64_t secs = 0; 180 + int ret; 181 + u8 val; 182 + 183 + /* 184 + * Multi-byte transfers are not supported with PEC enabled 185 + * Read MSB first to avoid coherency issues 186 + */ 187 + ret = i2c_smbus_read_byte_data(info->client, NVVRS_REG_RTC_T3); 188 + if (ret < 0) 189 + return ret; 190 + 191 + val = (u8)ret; 192 + secs |= (time64_t)val << 24; 193 + 194 + ret = i2c_smbus_read_byte_data(info->client, NVVRS_REG_RTC_T2); 195 + if (ret < 0) 196 + return ret; 197 + 198 + val = (u8)ret; 199 + secs |= (time64_t)val << 16; 200 + 201 + ret = i2c_smbus_read_byte_data(info->client, NVVRS_REG_RTC_T1); 202 + if (ret < 0) 203 + return ret; 204 + 205 + val = (u8)ret; 206 + secs |= (time64_t)val << 8; 207 + 208 + ret = i2c_smbus_read_byte_data(info->client, NVVRS_REG_RTC_T0); 209 + if (ret < 0) 210 + return ret; 211 + 212 + val = (u8)ret; 213 + secs |= val; 214 + 215 + rtc_time64_to_tm(secs, tm); 216 + 217 + return 0; 218 + } 219 + 220 + static int nvvrs_rtc_set_time(struct device *dev, struct rtc_time *tm) 221 + { 222 + struct nvvrs_rtc_info *info = dev_get_drvdata(dev); 223 + time64_t secs; 224 + u8 time[4]; 225 + int ret; 226 + 227 + secs = rtc_tm_to_time64(tm); 228 + time[0] = secs & 0xff; 229 + time[1] = (secs >> 8) & 0xff; 230 + time[2] = (secs >> 16) & 0xff; 231 + time[3] = (secs >> 24) & 0xff; 232 + 233 + ret = i2c_smbus_write_byte_data(info->client, NVVRS_REG_RTC_T3, time[3]); 234 + if (ret < 0) 235 + return ret; 236 + 237 + ret = i2c_smbus_write_byte_data(info->client, NVVRS_REG_RTC_T2, time[2]); 238 + if (ret < 0) 239 + return ret; 240 + 241 + ret = i2c_smbus_write_byte_data(info->client, NVVRS_REG_RTC_T1, time[1]); 242 + if (ret < 0) 243 + return ret; 244 + 245 + ret = i2c_smbus_write_byte_data(info->client, NVVRS_REG_RTC_T0, time[0]); 246 + 247 + return ret; 248 + } 249 + 250 + static int nvvrs_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) 251 + { 252 + struct nvvrs_rtc_info *info = dev_get_drvdata(dev); 253 + time64_t alarm_val = 0; 254 + int ret; 255 + u8 val; 256 + 257 + /* Multi-byte transfers are not supported with PEC enabled */ 258 + ret = i2c_smbus_read_byte_data(info->client, NVVRS_REG_RTC_A3); 259 + if (ret < 0) 260 + return ret; 261 + 262 + val = (u8)ret; 263 + alarm_val |= (time64_t)val << 24; 264 + 265 + ret = i2c_smbus_read_byte_data(info->client, NVVRS_REG_RTC_A2); 266 + if (ret < 0) 267 + return ret; 268 + 269 + val = (u8)ret; 270 + alarm_val |= (time64_t)val << 16; 271 + 272 + ret = i2c_smbus_read_byte_data(info->client, NVVRS_REG_RTC_A1); 273 + if (ret < 0) 274 + return ret; 275 + 276 + val = (u8)ret; 277 + alarm_val |= (time64_t)val << 8; 278 + 279 + ret = i2c_smbus_read_byte_data(info->client, NVVRS_REG_RTC_A0); 280 + if (ret < 0) 281 + return ret; 282 + 283 + val = (u8)ret; 284 + alarm_val |= val; 285 + 286 + if (alarm_val == ALARM_RESET_VAL) 287 + alrm->enabled = 0; 288 + else 289 + alrm->enabled = 1; 290 + 291 + rtc_time64_to_tm(alarm_val, &alrm->time); 292 + 293 + return 0; 294 + } 295 + 296 + static int nvvrs_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) 297 + { 298 + struct nvvrs_rtc_info *info = dev_get_drvdata(dev); 299 + time64_t secs; 300 + u8 time[4]; 301 + int ret; 302 + 303 + if (!alrm->enabled) { 304 + ret = nvvrs_rtc_disable_alarm(info); 305 + if (ret < 0) 306 + return ret; 307 + } 308 + 309 + ret = nvvrs_rtc_enable_alarm(info); 310 + if (ret < 0) 311 + return ret; 312 + 313 + secs = rtc_tm_to_time64(&alrm->time); 314 + time[0] = secs & 0xff; 315 + time[1] = (secs >> 8) & 0xff; 316 + time[2] = (secs >> 16) & 0xff; 317 + time[3] = (secs >> 24) & 0xff; 318 + 319 + ret = nvvrs_rtc_write_alarm(info->client, time); 320 + 321 + return ret; 322 + } 323 + 324 + static int nvvrs_pseq_irq_clear(struct nvvrs_rtc_info *info) 325 + { 326 + unsigned int i; 327 + int ret; 328 + 329 + for (i = 0; i < NVVRS_IRQ_REG_COUNT; i++) { 330 + ret = i2c_smbus_read_byte_data(info->client, 331 + NVVRS_REG_INT_SRC1 + i); 332 + if (ret < 0) { 333 + dev_err(info->dev, "Failed to read INT_SRC%d : %d\n", 334 + i + 1, ret); 335 + return ret; 336 + } 337 + 338 + ret = i2c_smbus_write_byte_data(info->client, 339 + NVVRS_REG_INT_SRC1 + i, 340 + (u8)ret); 341 + if (ret < 0) { 342 + dev_err(info->dev, "Failed to clear INT_SRC%d : %d\n", 343 + i + 1, ret); 344 + return ret; 345 + } 346 + } 347 + 348 + return 0; 349 + } 350 + 351 + static irqreturn_t nvvrs_rtc_irq_handler(int irq, void *data) 352 + { 353 + struct nvvrs_rtc_info *info = data; 354 + int ret; 355 + 356 + /* Check for RTC alarm interrupt */ 357 + ret = i2c_smbus_read_byte_data(info->client, NVVRS_REG_INT_SRC1); 358 + if (ret < 0) 359 + return IRQ_NONE; 360 + 361 + if (ret & NVVRS_INT_SRC1_RTC_MASK) { 362 + rtc_lock(info->rtc); 363 + rtc_update_irq(info->rtc, 1, RTC_IRQF | RTC_AF); 364 + rtc_unlock(info->rtc); 365 + } 366 + 367 + /* Clear all interrupts */ 368 + if (nvvrs_pseq_irq_clear(info) < 0) 369 + return IRQ_NONE; 370 + 371 + return IRQ_HANDLED; 372 + } 373 + 374 + static int nvvrs_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) 375 + { 376 + /* 377 + * This hardware does not support enabling/disabling the alarm IRQ 378 + * independently. The alarm is disabled by clearing the alarm time 379 + * via set_alarm(). 380 + */ 381 + return 0; 382 + } 383 + 384 + static const struct rtc_class_ops nvvrs_rtc_ops = { 385 + .read_time = nvvrs_rtc_read_time, 386 + .set_time = nvvrs_rtc_set_time, 387 + .read_alarm = nvvrs_rtc_read_alarm, 388 + .set_alarm = nvvrs_rtc_set_alarm, 389 + .alarm_irq_enable = nvvrs_rtc_alarm_irq_enable, 390 + }; 391 + 392 + static int nvvrs_pseq_vendor_info(struct nvvrs_rtc_info *info) 393 + { 394 + struct i2c_client *client = info->client; 395 + u8 vendor_id, model_rev; 396 + int ret; 397 + 398 + ret = i2c_smbus_read_byte_data(client, NVVRS_REG_VENDOR_ID); 399 + if (ret < 0) 400 + return dev_err_probe(&client->dev, ret, 401 + "Failed to read Vendor ID\n"); 402 + 403 + vendor_id = (u8)ret; 404 + 405 + ret = i2c_smbus_read_byte_data(client, NVVRS_REG_MODEL_REV); 406 + if (ret < 0) 407 + return dev_err_probe(&client->dev, ret, 408 + "Failed to read Model Revision\n"); 409 + 410 + model_rev = (u8)ret; 411 + 412 + if (model_rev < NVVRS_MIN_MODEL_REV) { 413 + return dev_err_probe(&client->dev, -ENODEV, 414 + "Chip revision 0x%02x is not supported!\n", 415 + model_rev); 416 + } 417 + 418 + dev_dbg(&client->dev, "NVVRS Vendor ID: 0x%02x, Model Rev: 0x%02x\n", 419 + vendor_id, model_rev); 420 + 421 + return 0; 422 + } 423 + 424 + static int nvvrs_rtc_probe(struct i2c_client *client) 425 + { 426 + struct nvvrs_rtc_info *info; 427 + int ret; 428 + 429 + info = devm_kzalloc(&client->dev, sizeof(*info), GFP_KERNEL); 430 + if (!info) 431 + return -ENOMEM; 432 + 433 + if (client->irq <= 0) 434 + return dev_err_probe(&client->dev, -EINVAL, "No IRQ specified\n"); 435 + 436 + info->irq = client->irq; 437 + info->dev = &client->dev; 438 + client->flags |= I2C_CLIENT_PEC; 439 + i2c_set_clientdata(client, info); 440 + info->client = client; 441 + 442 + /* Check vendor info */ 443 + if (nvvrs_pseq_vendor_info(info) < 0) 444 + return dev_err_probe(&client->dev, -EINVAL, 445 + "Failed to get vendor info\n"); 446 + 447 + /* Clear any pending IRQs before requesting IRQ handler */ 448 + if (nvvrs_pseq_irq_clear(info) < 0) 449 + return dev_err_probe(&client->dev, -EINVAL, 450 + "Failed to clear interrupts\n"); 451 + 452 + /* Allocate RTC device */ 453 + info->rtc = devm_rtc_allocate_device(info->dev); 454 + if (IS_ERR(info->rtc)) 455 + return PTR_ERR(info->rtc); 456 + 457 + info->rtc->ops = &nvvrs_rtc_ops; 458 + info->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000; 459 + info->rtc->range_max = RTC_TIMESTAMP_END_2099; 460 + 461 + /* Request RTC IRQ */ 462 + ret = devm_request_threaded_irq(info->dev, info->irq, NULL, 463 + nvvrs_rtc_irq_handler, IRQF_ONESHOT, 464 + "nvvrs-rtc", info); 465 + if (ret < 0) { 466 + dev_err_probe(info->dev, ret, "Failed to request RTC IRQ\n"); 467 + return ret; 468 + } 469 + 470 + /* RTC as a wakeup source */ 471 + devm_device_init_wakeup(info->dev); 472 + 473 + return devm_rtc_register_device(info->rtc); 474 + } 475 + 476 + #ifdef CONFIG_PM_SLEEP 477 + static int nvvrs_rtc_suspend(struct device *dev) 478 + { 479 + struct nvvrs_rtc_info *info = dev_get_drvdata(dev); 480 + int ret; 481 + 482 + if (device_may_wakeup(dev)) { 483 + /* Set RTC_WAKE bit for auto wake system from suspend state */ 484 + ret = nvvrs_update_bits(info, NVVRS_REG_CTL_2, 485 + NVVRS_REG_CTL_2_RTC_WAKE, 486 + NVVRS_REG_CTL_2_RTC_WAKE); 487 + if (ret < 0) { 488 + dev_err(info->dev, "Failed to set RTC_WAKE bit (%d)\n", 489 + ret); 490 + return ret; 491 + } 492 + 493 + return enable_irq_wake(info->irq); 494 + } 495 + 496 + return 0; 497 + } 498 + 499 + static int nvvrs_rtc_resume(struct device *dev) 500 + { 501 + struct nvvrs_rtc_info *info = dev_get_drvdata(dev); 502 + int ret; 503 + 504 + if (device_may_wakeup(dev)) { 505 + /* Clear FORCE_ACT bit */ 506 + ret = nvvrs_update_bits(info, NVVRS_REG_CTL_1, 507 + NVVRS_REG_CTL_1_FORCE_ACT, 0); 508 + if (ret < 0) { 509 + dev_err(info->dev, "Failed to clear FORCE_ACT bit (%d)\n", 510 + ret); 511 + return ret; 512 + } 513 + 514 + return disable_irq_wake(info->irq); 515 + } 516 + 517 + return 0; 518 + } 519 + 520 + #endif 521 + static SIMPLE_DEV_PM_OPS(nvvrs_rtc_pm_ops, nvvrs_rtc_suspend, nvvrs_rtc_resume); 522 + 523 + static const struct of_device_id nvvrs_rtc_of_match[] = { 524 + { .compatible = "nvidia,vrs-10" }, 525 + { }, 526 + }; 527 + MODULE_DEVICE_TABLE(of, nvvrs_rtc_of_match); 528 + 529 + static struct i2c_driver nvvrs_rtc_driver = { 530 + .driver = { 531 + .name = "rtc-nvidia-vrs10", 532 + .pm = &nvvrs_rtc_pm_ops, 533 + .of_match_table = nvvrs_rtc_of_match, 534 + }, 535 + .probe = nvvrs_rtc_probe, 536 + }; 537 + 538 + module_i2c_driver(nvvrs_rtc_driver); 539 + 540 + MODULE_AUTHOR("Shubhi Garg <shgarg@nvidia.com>"); 541 + MODULE_DESCRIPTION("NVIDIA Voltage Regulator Specification RTC driver"); 542 + MODULE_LICENSE("GPL");
-2
drivers/rtc/rtc-pic32.c
··· 340 340 if (ret) 341 341 goto err_nortc; 342 342 343 - pdata->rtc->max_user_freq = 128; 344 - 345 343 pic32_rtc_setfreq(&pdev->dev, 1); 346 344 ret = devm_request_irq(&pdev->dev, pdata->alarm_irq, 347 345 pic32_rtc_alarmirq, 0,
+1 -2
drivers/rtc/rtc-renesas-rtca3.c
··· 726 726 if (ret) 727 727 return ret; 728 728 729 - priv->rstc = devm_reset_control_get_shared(dev, NULL); 729 + priv->rstc = devm_reset_control_array_get_shared(dev); 730 730 if (IS_ERR(priv->rstc)) 731 731 return PTR_ERR(priv->rstc); 732 732 ··· 772 772 return PTR_ERR(priv->rtc_dev); 773 773 774 774 priv->rtc_dev->ops = &rtca3_ops; 775 - priv->rtc_dev->max_user_freq = 256; 776 775 priv->rtc_dev->range_min = RTC_TIMESTAMP_BEGIN_2000; 777 776 priv->rtc_dev->range_max = RTC_TIMESTAMP_END_2099; 778 777
-2
drivers/rtc/rtc-rv3028.c
··· 1023 1023 eeprom_cfg.priv = rv3028; 1024 1024 devm_rtc_nvmem_register(rv3028->rtc, &eeprom_cfg); 1025 1025 1026 - rv3028->rtc->max_user_freq = 1; 1027 - 1028 1026 #ifdef CONFIG_COMMON_CLK 1029 1027 rv3028_clkout_register_clk(rv3028, client); 1030 1028 #endif
-2
drivers/rtc/rtc-rv3032.c
··· 968 968 eeprom_cfg.priv = rv3032; 969 969 devm_rtc_nvmem_register(rv3032->rtc, &eeprom_cfg); 970 970 971 - rv3032->rtc->max_user_freq = 1; 972 - 973 971 #ifdef CONFIG_COMMON_CLK 974 972 rv3032_clkout_register_clk(rv3032, client); 975 973 #endif
-2
drivers/rtc/rtc-rv8803.c
··· 738 738 739 739 devm_rtc_nvmem_register(rv8803->rtc, &nvmem_cfg); 740 740 741 - rv8803->rtc->max_user_freq = 1; 742 - 743 741 return 0; 744 742 } 745 743
-2
drivers/rtc/rtc-rx6110.c
··· 324 324 if (err) 325 325 return err; 326 326 327 - rx6110->rtc->max_user_freq = 1; 328 - 329 327 return 0; 330 328 } 331 329
-1
drivers/rtc/rtc-rx8010.c
··· 412 412 } 413 413 414 414 rx8010->rtc->ops = &rx8010_rtc_ops; 415 - rx8010->rtc->max_user_freq = 1; 416 415 rx8010->rtc->range_min = RTC_TIMESTAMP_BEGIN_2000; 417 416 rx8010->rtc->range_max = RTC_TIMESTAMP_END_2099; 418 417
-2
drivers/rtc/rtc-rx8025.c
··· 565 565 clear_bit(RTC_FEATURE_ALARM, rx8025->rtc->features); 566 566 } 567 567 568 - rx8025->rtc->max_user_freq = 1; 569 - 570 568 set_bit(RTC_FEATURE_ALARM_RES_MINUTE, rx8025->rtc->features); 571 569 clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, rx8025->rtc->features); 572 570
+9 -9
drivers/rtc/rtc-s35390a.c
··· 66 66 int twentyfourhour; 67 67 }; 68 68 69 - static int s35390a_set_reg(struct s35390a *s35390a, int reg, char *buf, int len) 69 + static int s35390a_set_reg(struct s35390a *s35390a, int reg, u8 *buf, int len) 70 70 { 71 71 struct i2c_client *client = s35390a->client[reg]; 72 72 struct i2c_msg msg[] = { ··· 83 83 return 0; 84 84 } 85 85 86 - static int s35390a_get_reg(struct s35390a *s35390a, int reg, char *buf, int len) 86 + static int s35390a_get_reg(struct s35390a *s35390a, int reg, u8 *buf, int len) 87 87 { 88 88 struct i2c_client *client = s35390a->client[reg]; 89 89 struct i2c_msg msg[] = { ··· 168 168 169 169 static int s35390a_disable_test_mode(struct s35390a *s35390a) 170 170 { 171 - char buf[1]; 171 + u8 buf[1]; 172 172 173 173 if (s35390a_get_reg(s35390a, S35390A_CMD_STATUS2, buf, sizeof(buf)) < 0) 174 174 return -EIO; ··· 210 210 struct i2c_client *client = to_i2c_client(dev); 211 211 struct s35390a *s35390a = i2c_get_clientdata(client); 212 212 int i; 213 - char buf[7], status; 213 + u8 buf[7], status; 214 214 215 215 dev_dbg(&client->dev, "%s: tm is secs=%d, mins=%d, hours=%d mday=%d, " 216 216 "mon=%d, year=%d, wday=%d\n", __func__, tm->tm_sec, ··· 239 239 { 240 240 struct i2c_client *client = to_i2c_client(dev); 241 241 struct s35390a *s35390a = i2c_get_clientdata(client); 242 - char buf[7], status; 242 + u8 buf[7], status; 243 243 int i, err; 244 244 245 245 if (s35390a_read_status(s35390a, &status) == 1) ··· 273 273 { 274 274 struct i2c_client *client = to_i2c_client(dev); 275 275 struct s35390a *s35390a = i2c_get_clientdata(client); 276 - char buf[3], sts = 0; 276 + u8 buf[3], sts = 0; 277 277 int err, i; 278 278 279 279 dev_dbg(&client->dev, "%s: alm is secs=%d, mins=%d, hours=%d mday=%d, "\ ··· 326 326 { 327 327 struct i2c_client *client = to_i2c_client(dev); 328 328 struct s35390a *s35390a = i2c_get_clientdata(client); 329 - char buf[3], sts; 329 + u8 buf[3], sts; 330 330 int i, err; 331 331 332 332 err = s35390a_get_reg(s35390a, S35390A_CMD_STATUS2, &sts, sizeof(sts)); ··· 383 383 { 384 384 struct i2c_client *client = to_i2c_client(dev); 385 385 struct s35390a *s35390a = i2c_get_clientdata(client); 386 - char sts; 386 + u8 sts; 387 387 int err; 388 388 389 389 switch (cmd) { ··· 422 422 unsigned int i; 423 423 struct s35390a *s35390a; 424 424 struct rtc_device *rtc; 425 - char buf, status1; 425 + u8 buf, status1; 426 426 struct device *dev = &client->dev; 427 427 428 428 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C))
-3
drivers/rtc/rtc-sa1100.c
··· 40 40 41 41 #define RTC_DEF_DIVIDER (32768 - 1) 42 42 #define RTC_DEF_TRIM 0 43 - #define RTC_FREQ 1024 44 - 45 43 46 44 static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) 47 45 { ··· 200 202 } 201 203 202 204 info->rtc->ops = &sa1100_rtc_ops; 203 - info->rtc->max_user_freq = RTC_FREQ; 204 205 info->rtc->range_max = U32_MAX; 205 206 206 207 ret = devm_rtc_register_device(info->rtc);
-1
drivers/rtc/rtc-sh.c
··· 423 423 writeb(tmp, rtc->regbase + RCR1); 424 424 425 425 rtc->rtc_dev->ops = &sh_rtc_ops; 426 - rtc->rtc_dev->max_user_freq = 256; 427 426 428 427 if (rtc->capabilities & RTC_CAP_4_DIGIT_YEAR) { 429 428 rtc->rtc_dev->range_min = RTC_TIMESTAMP_BEGIN_1900;
+17 -28
drivers/rtc/rtc-tegra.c
··· 274 274 }; 275 275 MODULE_DEVICE_TABLE(of, tegra_rtc_dt_match); 276 276 277 + static const struct acpi_device_id tegra_rtc_acpi_match[] = { 278 + { "NVDA0280" }, 279 + { } 280 + }; 281 + MODULE_DEVICE_TABLE(acpi, tegra_rtc_acpi_match); 282 + 277 283 static int tegra_rtc_probe(struct platform_device *pdev) 278 284 { 279 285 struct tegra_rtc_info *info; ··· 306 300 info->rtc->ops = &tegra_rtc_ops; 307 301 info->rtc->range_max = U32_MAX; 308 302 309 - info->clk = devm_clk_get(&pdev->dev, NULL); 310 - if (IS_ERR(info->clk)) 311 - return PTR_ERR(info->clk); 312 - 313 - ret = clk_prepare_enable(info->clk); 314 - if (ret < 0) 315 - return ret; 303 + if (dev_of_node(&pdev->dev)) { 304 + info->clk = devm_clk_get_enabled(&pdev->dev, NULL); 305 + if (IS_ERR(info->clk)) 306 + return PTR_ERR(info->clk); 307 + } 316 308 317 309 /* set context info */ 318 310 info->pdev = pdev; ··· 328 324 ret = devm_request_irq(&pdev->dev, info->irq, tegra_rtc_irq_handler, 329 325 IRQF_TRIGGER_HIGH, dev_name(&pdev->dev), 330 326 &pdev->dev); 331 - if (ret) { 332 - dev_err(&pdev->dev, "failed to request interrupt: %d\n", ret); 333 - goto disable_clk; 334 - } 327 + if (ret) 328 + return dev_err_probe(&pdev->dev, ret, "failed to request interrupt\n"); 335 329 336 330 ret = devm_rtc_register_device(info->rtc); 337 331 if (ret) 338 - goto disable_clk; 332 + return ret; 339 333 340 334 dev_notice(&pdev->dev, "Tegra internal Real Time Clock\n"); 341 335 342 336 return 0; 343 - 344 - disable_clk: 345 - clk_disable_unprepare(info->clk); 346 - return ret; 347 337 } 348 338 349 - static void tegra_rtc_remove(struct platform_device *pdev) 350 - { 351 - struct tegra_rtc_info *info = platform_get_drvdata(pdev); 352 - 353 - clk_disable_unprepare(info->clk); 354 - } 355 - 356 - #ifdef CONFIG_PM_SLEEP 357 339 static int tegra_rtc_suspend(struct device *dev) 358 340 { 359 341 struct tegra_rtc_info *info = dev_get_drvdata(dev); ··· 377 387 378 388 return 0; 379 389 } 380 - #endif 381 390 382 - static SIMPLE_DEV_PM_OPS(tegra_rtc_pm_ops, tegra_rtc_suspend, tegra_rtc_resume); 391 + static DEFINE_SIMPLE_DEV_PM_OPS(tegra_rtc_pm_ops, tegra_rtc_suspend, tegra_rtc_resume); 383 392 384 393 static void tegra_rtc_shutdown(struct platform_device *pdev) 385 394 { ··· 388 399 389 400 static struct platform_driver tegra_rtc_driver = { 390 401 .probe = tegra_rtc_probe, 391 - .remove = tegra_rtc_remove, 392 402 .shutdown = tegra_rtc_shutdown, 393 403 .driver = { 394 404 .name = "tegra_rtc", 395 405 .of_match_table = tegra_rtc_dt_match, 396 - .pm = &tegra_rtc_pm_ops, 406 + .acpi_match_table = tegra_rtc_acpi_match, 407 + .pm = pm_sleep_ptr(&tegra_rtc_pm_ops), 397 408 }, 398 409 }; 399 410 module_platform_driver(tegra_rtc_driver);
-1
include/linux/rtc/ds1685.h
··· 324 324 #define RTC_SQW_2HZ 0x0f /* 0 1 1 1 1 */ 325 325 #define RTC_SQW_0HZ 0x00 /* 0 0 0 0 0 */ 326 326 #define RTC_SQW_32768HZ 32768 /* 1 - - - - */ 327 - #define RTC_MAX_USER_FREQ 8192 328 327 329 328 330 329 /*