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

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

Pull RTC updates from Alexandre Belloni:
"The isl1208 dirver was reworked tobe able to work as part of an MFD.

All the Loongson chips are now supported through a new driver, the old
one is removed.

Summary:

Subsystem:
- Switch i2c drivers back to use .probe()
- Constify pointers to hwmon_channel_info

New driver:
- Loongson on chip RTC, replacing the Loongson 1 only driver

Drivers:
- isl1208: cleanup and support for RAA215300
- st-lpc: cleanups
- stm32: fix wakeup"

* tag 'rtc-6.5' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (21 commits)
rtc: Add rtc driver for the Loongson family chips
rtc: Remove the Loongson-1 RTC driver
dt-bindings: rtc: Split loongson,ls2x-rtc into SoC-based compatibles
rtc: rv3028: make rv3028 probeable from userspace
rtc: isl1208: Add support for the built-in RTC on the PMIC RAA215300
rtc: isl1208: Add isl1208_set_xtoscb()
rtc: isl1208: Drop enum isl1208_id and split isl1208_configs[]
rtc: isl1208: Make similar I2C and DT-based matching table
rtc: isl1208: Drop name variable
dt-bindings: rtc: isil,isl1208: Document clock and clock-names properties
dt-bindings: rtc: isl1208: Convert to json-schema
rtc: st-lpc: Simplify clk handling in st_rtc_probe()
rtc: st-lpc: Release some resources in st_rtc_probe() in case of error
rtc: stm32: remove dedicated wakeup management
dt-bindings: rtc: restrict node name suffixes
rtc: add HAS_IOPORT dependencies
rtc: Switch i2c drivers back to use .probe()
rtc: rv3032: constify pointers to hwmon_channel_info
rtc: isl12022: constify pointers to hwmon_channel_info
rtc: ds3232: constify pointers to hwmon_channel_info
...

+726 -350
-38
Documentation/devicetree/bindings/rtc/isil,isl1208.txt
··· 1 - Intersil ISL1209/19 I2C RTC/Alarm chip with event in 2 - 3 - ISL12X9 have additional pins EVIN and #EVDET for tamper detection, while the 4 - ISL1208 and ISL1218 do not. They are all use the same driver with the bindings 5 - described here, with chip specific properties as noted. 6 - 7 - Required properties supported by the device: 8 - - "compatible": Should be one of the following: 9 - - "isil,isl1208" 10 - - "isil,isl1209" 11 - - "isil,isl1218" 12 - - "isil,isl1219" 13 - - "reg": I2C bus address of the device 14 - 15 - Optional properties: 16 - - "interrupt-names": list which may contains "irq" and "evdet" 17 - evdet applies to isl1209 and isl1219 only 18 - - "interrupts": list of interrupts for "irq" and "evdet" 19 - evdet applies to isl1209 and isl1219 only 20 - - "isil,ev-evienb": Enable or disable internal pull on EVIN pin 21 - Applies to isl1209 and isl1219 only 22 - Possible values are 0 and 1 23 - Value 0 enables internal pull-up on evin pin, 1 disables it. 24 - Default will leave the non-volatile configuration of the pullup 25 - as is. 26 - 27 - Example isl1219 node with #IRQ pin connected to SoC gpio1 pin12 and #EVDET pin 28 - connected to SoC gpio2 pin 24 and internal pull-up enabled in EVIN pin. 29 - 30 - isl1219: rtc@68 { 31 - compatible = "isil,isl1219"; 32 - reg = <0x68>; 33 - interrupt-names = "irq", "evdet"; 34 - interrupts-extended = <&gpio1 12 IRQ_TYPE_EDGE_FALLING>, 35 - <&gpio2 24 IRQ_TYPE_EDGE_FALLING>; 36 - isil,ev-evienb = <1>; 37 - }; 38 -
+100
Documentation/devicetree/bindings/rtc/isil,isl1208.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/isil,isl1208.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Intersil ISL1209/19 I2C RTC/Alarm chip with event in 8 + 9 + maintainers: 10 + - Biju Das <biju.das.jz@bp.renesas.com> 11 + - Trent Piepho <tpiepho@gmail.com> 12 + 13 + description: 14 + ISL12X9 have additional pins EVIN and EVDET for tamper detection, while the 15 + ISL1208 and ISL1218 do not. 16 + 17 + properties: 18 + compatible: 19 + enum: 20 + - isil,isl1208 21 + - isil,isl1209 22 + - isil,isl1218 23 + - isil,isl1219 24 + 25 + reg: 26 + maxItems: 1 27 + 28 + clocks: 29 + maxItems: 1 30 + 31 + clock-names: 32 + description: | 33 + Use xin, if connected to an external crystal. 34 + Use clkin, if connected to an external clock signal. 35 + enum: 36 + - xin 37 + - clkin 38 + 39 + interrupts: 40 + minItems: 1 41 + maxItems: 2 42 + 43 + interrupt-names: 44 + minItems: 1 45 + items: 46 + - const: irq 47 + - const: evdet 48 + 49 + isil,ev-evienb: 50 + $ref: /schemas/types.yaml#/definitions/uint32 51 + enum: [ 0, 1 ] 52 + description: | 53 + Enable or disable internal pull on EVIN pin 54 + Default will leave the non-volatile configuration of the pullup 55 + as is. 56 + <0> : Enables internal pull-up on evin pin 57 + <1> : Disables internal pull-up on evin pin 58 + 59 + required: 60 + - compatible 61 + - reg 62 + 63 + allOf: 64 + - $ref: rtc.yaml# 65 + - if: 66 + properties: 67 + compatible: 68 + contains: 69 + enum: 70 + - isil,isl1209 71 + - isil,isl1219 72 + then: 73 + properties: 74 + interrupts: 75 + maxItems: 2 76 + interrupt-names: 77 + items: 78 + - const: irq 79 + - const: evdet 80 + else: 81 + properties: 82 + interrupts: 83 + maxItems: 1 84 + interrupt-names: 85 + items: 86 + - const: irq 87 + 88 + unevaluatedProperties: false 89 + 90 + examples: 91 + - | 92 + i2c { 93 + #address-cells = <1>; 94 + #size-cells = <0>; 95 + 96 + rtc_twi: rtc@6f { 97 + compatible = "isil,isl1208"; 98 + reg = <0x6f>; 99 + }; 100 + };
+57
Documentation/devicetree/bindings/rtc/loongson,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/loongson,rtc.yaml# 5 + $schema: http://devicetree.org/meta-schemas/core.yaml# 6 + 7 + title: Loongson Real-Time Clock 8 + 9 + description: 10 + The Loongson family chips use an on-chip counter 0 (Time Of Year 11 + counter) as the RTC. 12 + 13 + maintainers: 14 + - Binbin Zhou <zhoubinbin@loongson.cn> 15 + 16 + allOf: 17 + - $ref: rtc.yaml# 18 + 19 + properties: 20 + compatible: 21 + oneOf: 22 + - enum: 23 + - loongson,ls1b-rtc 24 + - loongson,ls1c-rtc 25 + - loongson,ls7a-rtc 26 + - loongson,ls2k1000-rtc 27 + - items: 28 + - enum: 29 + - loongson,ls2k2000-rtc 30 + - loongson,ls2k0500-rtc 31 + - const: loongson,ls7a-rtc 32 + 33 + reg: 34 + maxItems: 1 35 + 36 + interrupts: 37 + maxItems: 1 38 + 39 + required: 40 + - compatible 41 + - reg 42 + 43 + unevaluatedProperties: false 44 + 45 + examples: 46 + - | 47 + #include <dt-bindings/interrupt-controller/irq.h> 48 + 49 + rtc@1fe27800 { 50 + compatible = "loongson,ls2k1000-rtc"; 51 + reg = <0x1fe27800 0x100>; 52 + 53 + interrupt-parent = <&liointc1>; 54 + interrupts = <8 IRQ_TYPE_LEVEL_HIGH>; 55 + }; 56 + 57 + ...
+1 -1
Documentation/devicetree/bindings/rtc/rtc.yaml
··· 15 15 16 16 properties: 17 17 $nodename: 18 - pattern: "^rtc(@.*|-[0-9a-f])*$" 18 + pattern: "^rtc(@.*|-([0-9]|[1-9][0-9]+))?$" 19 19 20 20 aux-voltage-chargeable: 21 21 $ref: /schemas/types.yaml#/definitions/uint32
-2
Documentation/devicetree/bindings/rtc/trivial-rtc.yaml
··· 47 47 - isil,isl1218 48 48 # Intersil ISL12022 Real-time Clock 49 49 - isil,isl12022 50 - # Loongson-2K Socs/LS7A bridge Real-time Clock 51 - - loongson,ls2x-rtc 52 50 # Real Time Clock Module with I2C-Bus 53 51 - microcrystal,rv3029 54 52 # Real Time Clock
+16 -11
drivers/rtc/Kconfig
··· 956 956 config RTC_DRV_CMOS 957 957 tristate "PC-style 'CMOS'" 958 958 depends on X86 || ARM || PPC || MIPS || SPARC64 959 + depends on HAS_IOPORT || MACH_DECSTATION 959 960 default y if X86 960 961 select RTC_MC146818_LIB 961 962 help ··· 977 976 config RTC_DRV_ALPHA 978 977 bool "Alpha PC-style CMOS" 979 978 depends on ALPHA 979 + depends on HAS_IOPORT 980 980 select RTC_MC146818_LIB 981 981 default y 982 982 help ··· 1195 1193 1196 1194 config RTC_DRV_BQ4802 1197 1195 tristate "TI BQ4802" 1198 - depends on HAS_IOMEM 1196 + depends on HAS_IOMEM && HAS_IOPORT 1199 1197 help 1200 1198 If you say Y here you will get support for the TI 1201 1199 BQ4802 RTC chip. ··· 1687 1685 This driver can also be built as a module. If so, the module 1688 1686 will be called rtc-jz4740. 1689 1687 1688 + config RTC_DRV_LOONGSON 1689 + tristate "Loongson On-chip RTC" 1690 + depends on MACH_LOONGSON32 || MACH_LOONGSON64 || COMPILE_TEST 1691 + select REGMAP_MMIO 1692 + help 1693 + This is a driver for the Loongson on-chip Counter0 (Time-Of-Year 1694 + counter) to be used as a RTC. 1695 + It can be found on Loongson-1 series cpu, Loongson-2K series cpu 1696 + and Loongson LS7A bridge chips. 1697 + 1698 + This driver can also be built as a module. If so, the module 1699 + will be called rtc-loongson. 1700 + 1690 1701 config RTC_DRV_LPC24XX 1691 1702 tristate "NXP RTC for LPC178x/18xx/408x/43xx" 1692 1703 depends on ARCH_LPC18XX || COMPILE_TEST ··· 1740 1725 1741 1726 This drive can also be built as a module. If so, the module 1742 1727 will be called rtc-tegra. 1743 - 1744 - config RTC_DRV_LOONGSON1 1745 - tristate "loongson1 RTC support" 1746 - depends on MACH_LOONGSON32 1747 - help 1748 - This is a driver for the loongson1 on-chip Counter0 (Time-Of-Year 1749 - counter) to be used as a RTC. 1750 - 1751 - This driver can also be built as a module. If so, the module 1752 - will be called rtc-ls1x. 1753 1728 1754 1729 config RTC_DRV_MXC 1755 1730 tristate "Freescale MXC Real Time Clock"
+1 -1
drivers/rtc/Makefile
··· 78 78 obj-$(CONFIG_RTC_DRV_ISL12026) += rtc-isl12026.o 79 79 obj-$(CONFIG_RTC_DRV_ISL1208) += rtc-isl1208.o 80 80 obj-$(CONFIG_RTC_DRV_JZ4740) += rtc-jz4740.o 81 - obj-$(CONFIG_RTC_DRV_LOONGSON1) += rtc-ls1x.o 81 + obj-$(CONFIG_RTC_DRV_LOONGSON) += rtc-loongson.o 82 82 obj-$(CONFIG_RTC_DRV_LP8788) += rtc-lp8788.o 83 83 obj-$(CONFIG_RTC_DRV_LPC24XX) += rtc-lpc24xx.o 84 84 obj-$(CONFIG_RTC_DRV_LPC32XX) += rtc-lpc32xx.o
+1 -1
drivers/rtc/rtc-ab-b5ze-s3.c
··· 944 944 .pm = &abb5zes3_rtc_pm_ops, 945 945 .of_match_table = of_match_ptr(abb5zes3_dt_match), 946 946 }, 947 - .probe_new = abb5zes3_probe, 947 + .probe = abb5zes3_probe, 948 948 .id_table = abb5zes3_id, 949 949 }; 950 950 module_i2c_driver(abb5zes3_driver);
+2 -2
drivers/rtc/rtc-ab-eoz9.c
··· 455 455 .config = abeoz9_temp_config, 456 456 }; 457 457 458 - static const struct hwmon_channel_info *abeoz9_info[] = { 458 + static const struct hwmon_channel_info * const abeoz9_info[] = { 459 459 &abeoz9_chip, 460 460 &abeoz9_temp, 461 461 NULL ··· 584 584 .name = "rtc-ab-eoz9", 585 585 .of_match_table = of_match_ptr(abeoz9_dt_match), 586 586 }, 587 - .probe_new = abeoz9_probe, 587 + .probe = abeoz9_probe, 588 588 .id_table = abeoz9_id, 589 589 }; 590 590
+1 -1
drivers/rtc/rtc-abx80x.c
··· 992 992 .name = "rtc-abx80x", 993 993 .of_match_table = of_match_ptr(abx80x_of_match), 994 994 }, 995 - .probe_new = abx80x_probe, 995 + .probe = abx80x_probe, 996 996 .id_table = abx80x_id, 997 997 }; 998 998
+1 -1
drivers/rtc/rtc-bq32k.c
··· 320 320 .name = "bq32k", 321 321 .of_match_table = of_match_ptr(bq32k_of_match), 322 322 }, 323 - .probe_new = bq32k_probe, 323 + .probe = bq32k_probe, 324 324 .remove = bq32k_remove, 325 325 .id_table = bq32k_id, 326 326 };
+1 -1
drivers/rtc/rtc-ds1307.c
··· 2011 2011 .name = "rtc-ds1307", 2012 2012 .of_match_table = ds1307_of_match, 2013 2013 }, 2014 - .probe_new = ds1307_probe, 2014 + .probe = ds1307_probe, 2015 2015 .id_table = ds1307_id, 2016 2016 }; 2017 2017
+1 -1
drivers/rtc/rtc-ds1374.c
··· 572 572 .of_match_table = of_match_ptr(ds1374_of_match), 573 573 .pm = &ds1374_pm, 574 574 }, 575 - .probe_new = ds1374_probe, 575 + .probe = ds1374_probe, 576 576 .remove = ds1374_remove, 577 577 .id_table = ds1374_id, 578 578 };
+1 -1
drivers/rtc/rtc-ds1672.c
··· 149 149 .name = "rtc-ds1672", 150 150 .of_match_table = of_match_ptr(ds1672_of_match), 151 151 }, 152 - .probe_new = ds1672_probe, 152 + .probe = ds1672_probe, 153 153 .id_table = ds1672_id, 154 154 }; 155 155
+2 -2
drivers/rtc/rtc-ds3232.c
··· 359 359 .config = ds3232_hwmon_temp_config, 360 360 }; 361 361 362 - static const struct hwmon_channel_info *ds3232_hwmon_info[] = { 362 + static const struct hwmon_channel_info * const ds3232_hwmon_info[] = { 363 363 &ds3232_hwmon_chip, 364 364 &ds3232_hwmon_temp, 365 365 NULL ··· 603 603 .of_match_table = of_match_ptr(ds3232_of_match), 604 604 .pm = &ds3232_pm_ops, 605 605 }, 606 - .probe_new = ds3232_i2c_probe, 606 + .probe = ds3232_i2c_probe, 607 607 .id_table = ds3232_id, 608 608 }; 609 609
+1 -1
drivers/rtc/rtc-em3027.c
··· 147 147 .name = "rtc-em3027", 148 148 .of_match_table = of_match_ptr(em3027_of_match), 149 149 }, 150 - .probe_new = em3027_probe, 150 + .probe = em3027_probe, 151 151 .id_table = em3027_id, 152 152 }; 153 153
+1 -1
drivers/rtc/rtc-fm3130.c
··· 517 517 .driver = { 518 518 .name = "rtc-fm3130", 519 519 }, 520 - .probe_new = fm3130_probe, 520 + .probe = fm3130_probe, 521 521 .id_table = fm3130_id, 522 522 }; 523 523
+1 -1
drivers/rtc/rtc-hym8563.c
··· 576 576 .pm = &hym8563_pm_ops, 577 577 .of_match_table = hym8563_dt_idtable, 578 578 }, 579 - .probe_new = hym8563_probe, 579 + .probe = hym8563_probe, 580 580 .id_table = hym8563_id, 581 581 }; 582 582
+2 -2
drivers/rtc/rtc-isl12022.c
··· 89 89 return -EOPNOTSUPP; 90 90 } 91 91 92 - static const struct hwmon_channel_info *isl12022_hwmon_info[] = { 92 + static const struct hwmon_channel_info * const isl12022_hwmon_info[] = { 93 93 HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT), 94 94 NULL 95 95 }; ··· 262 262 .name = "rtc-isl12022", 263 263 .of_match_table = isl12022_dt_match, 264 264 }, 265 - .probe_new = isl12022_probe, 265 + .probe = isl12022_probe, 266 266 .id_table = isl12022_id, 267 267 }; 268 268
+1 -1
drivers/rtc/rtc-isl12026.c
··· 490 490 .name = "rtc-isl12026", 491 491 .of_match_table = isl12026_dt_match, 492 492 }, 493 - .probe_new = isl12026_probe_new, 493 + .probe = isl12026_probe_new, 494 494 .remove = isl12026_remove, 495 495 }; 496 496
+99 -33
drivers/rtc/rtc-isl1208.c
··· 6 6 */ 7 7 8 8 #include <linux/bcd.h> 9 + #include <linux/clk.h> 9 10 #include <linux/i2c.h> 10 11 #include <linux/module.h> 11 12 #include <linux/of_device.h> ··· 69 68 70 69 static struct i2c_driver isl1208_driver; 71 70 72 - /* ISL1208 various variants */ 73 - enum isl1208_id { 74 - TYPE_ISL1208 = 0, 75 - TYPE_ISL1209, 76 - TYPE_ISL1218, 77 - TYPE_ISL1219, 78 - ISL_LAST_ID 79 - }; 80 - 81 71 /* Chip capabilities table */ 82 - static const struct isl1208_config { 83 - const char name[8]; 72 + struct isl1208_config { 84 73 unsigned int nvmem_length; 85 74 unsigned has_tamper:1; 86 75 unsigned has_timestamp:1; 87 - } isl1208_configs[] = { 88 - [TYPE_ISL1208] = { "isl1208", 2, false, false }, 89 - [TYPE_ISL1209] = { "isl1209", 2, true, false }, 90 - [TYPE_ISL1218] = { "isl1218", 8, false, false }, 91 - [TYPE_ISL1219] = { "isl1219", 2, true, true }, 76 + unsigned has_inverted_osc_bit:1; 77 + }; 78 + 79 + static const struct isl1208_config config_isl1208 = { 80 + .nvmem_length = 2, 81 + .has_tamper = false, 82 + .has_timestamp = false 83 + }; 84 + 85 + static const struct isl1208_config config_isl1209 = { 86 + .nvmem_length = 2, 87 + .has_tamper = true, 88 + .has_timestamp = false 89 + }; 90 + 91 + static const struct isl1208_config config_isl1218 = { 92 + .nvmem_length = 8, 93 + .has_tamper = false, 94 + .has_timestamp = false 95 + }; 96 + 97 + static const struct isl1208_config config_isl1219 = { 98 + .nvmem_length = 2, 99 + .has_tamper = true, 100 + .has_timestamp = true 101 + }; 102 + 103 + static const struct isl1208_config config_raa215300_a0 = { 104 + .nvmem_length = 2, 105 + .has_tamper = false, 106 + .has_timestamp = false, 107 + .has_inverted_osc_bit = true 92 108 }; 93 109 94 110 static const struct i2c_device_id isl1208_id[] = { 95 - { "isl1208", TYPE_ISL1208 }, 96 - { "isl1209", TYPE_ISL1209 }, 97 - { "isl1218", TYPE_ISL1218 }, 98 - { "isl1219", TYPE_ISL1219 }, 111 + { "isl1208", .driver_data = (kernel_ulong_t)&config_isl1208 }, 112 + { "isl1209", .driver_data = (kernel_ulong_t)&config_isl1209 }, 113 + { "isl1218", .driver_data = (kernel_ulong_t)&config_isl1218 }, 114 + { "isl1219", .driver_data = (kernel_ulong_t)&config_isl1219 }, 115 + { "raa215300_a0", .driver_data = (kernel_ulong_t)&config_raa215300_a0 }, 99 116 { } 100 117 }; 101 118 MODULE_DEVICE_TABLE(i2c, isl1208_id); 102 119 103 120 static const __maybe_unused struct of_device_id isl1208_of_match[] = { 104 - { .compatible = "isil,isl1208", .data = &isl1208_configs[TYPE_ISL1208] }, 105 - { .compatible = "isil,isl1209", .data = &isl1208_configs[TYPE_ISL1209] }, 106 - { .compatible = "isil,isl1218", .data = &isl1208_configs[TYPE_ISL1218] }, 107 - { .compatible = "isil,isl1219", .data = &isl1208_configs[TYPE_ISL1219] }, 121 + { .compatible = "isil,isl1208", .data = &config_isl1208 }, 122 + { .compatible = "isil,isl1209", .data = &config_isl1209 }, 123 + { .compatible = "isil,isl1218", .data = &config_isl1218 }, 124 + { .compatible = "isil,isl1219", .data = &config_isl1219 }, 108 125 { } 109 126 }; 110 127 MODULE_DEVICE_TABLE(of, isl1208_of_match); ··· 183 164 } 184 165 185 166 return 0; 167 + } 168 + 169 + static int isl1208_set_xtoscb(struct i2c_client *client, int sr, int xtosb_val) 170 + { 171 + /* Do nothing if bit is already set to desired value */ 172 + if ((sr & ISL1208_REG_SR_XTOSCB) == xtosb_val) 173 + return 0; 174 + 175 + if (xtosb_val) 176 + sr |= ISL1208_REG_SR_XTOSCB; 177 + else 178 + sr &= ~ISL1208_REG_SR_XTOSCB; 179 + 180 + return i2c_smbus_write_byte_data(client, ISL1208_REG_SR, sr); 186 181 } 187 182 188 183 static int ··· 535 502 return 0; 536 503 } 537 504 538 - 539 505 static int 540 506 isl1208_rtc_set_time(struct device *dev, struct rtc_time *tm) 541 507 { ··· 829 797 } 830 798 831 799 static int 800 + isl1208_clk_present(struct i2c_client *client, const char *name) 801 + { 802 + struct clk *clk; 803 + 804 + clk = devm_clk_get_optional(&client->dev, name); 805 + if (IS_ERR(clk)) 806 + return PTR_ERR(clk); 807 + 808 + return !!clk; 809 + } 810 + 811 + static int 832 812 isl1208_probe(struct i2c_client *client) 833 813 { 834 - int rc = 0; 835 814 struct isl1208_state *isl1208; 836 815 int evdet_irq = -1; 816 + int xtosb_val = 0; 817 + int rc = 0; 818 + int sr; 837 819 838 820 if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) 839 821 return -ENODEV; ··· 869 823 } else { 870 824 const struct i2c_device_id *id = i2c_match_id(isl1208_id, client); 871 825 872 - if (id->driver_data >= ISL_LAST_ID) 826 + if (!id) 873 827 return -ENODEV; 874 - isl1208->config = &isl1208_configs[id->driver_data]; 828 + isl1208->config = (struct isl1208_config *)id->driver_data; 829 + } 830 + 831 + rc = isl1208_clk_present(client, "xin"); 832 + if (rc < 0) 833 + return rc; 834 + 835 + if (!rc) { 836 + rc = isl1208_clk_present(client, "clkin"); 837 + if (rc < 0) 838 + return rc; 839 + 840 + if (rc) 841 + xtosb_val = 1; 875 842 } 876 843 877 844 isl1208->rtc = devm_rtc_allocate_device(&client->dev); ··· 898 839 isl1208->nvmem_config.size = isl1208->config->nvmem_length; 899 840 isl1208->nvmem_config.priv = isl1208; 900 841 901 - rc = isl1208_i2c_get_sr(client); 902 - if (rc < 0) { 842 + sr = isl1208_i2c_get_sr(client); 843 + if (sr < 0) { 903 844 dev_err(&client->dev, "reading status failed\n"); 904 - return rc; 845 + return sr; 905 846 } 906 847 907 - if (rc & ISL1208_REG_SR_RTCF) 848 + if (isl1208->config->has_inverted_osc_bit) 849 + xtosb_val = !xtosb_val; 850 + 851 + rc = isl1208_set_xtoscb(client, sr, xtosb_val); 852 + if (rc) 853 + return rc; 854 + 855 + if (sr & ISL1208_REG_SR_RTCF) 908 856 dev_warn(&client->dev, "rtc power failure detected, " 909 857 "please set clock.\n"); 910 858 ··· 974 908 .name = "rtc-isl1208", 975 909 .of_match_table = of_match_ptr(isl1208_of_match), 976 910 }, 977 - .probe_new = isl1208_probe, 911 + .probe = isl1208_probe, 978 912 .id_table = isl1208_id, 979 913 }; 980 914
+397
drivers/rtc/rtc-loongson.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-or-later 2 + /* 3 + * Loongson RTC driver 4 + * 5 + * Maintained out-of-tree by Huacai Chen <chenhuacai@kernel.org>. 6 + * Rewritten for mainline by WANG Xuerui <git@xen0n.name>. 7 + * Binbin Zhou <zhoubinbin@loongson.cn> 8 + */ 9 + 10 + #include <linux/bitfield.h> 11 + #include <linux/kernel.h> 12 + #include <linux/module.h> 13 + #include <linux/platform_device.h> 14 + #include <linux/regmap.h> 15 + #include <linux/rtc.h> 16 + #include <linux/acpi.h> 17 + 18 + /* Time Of Year(TOY) counters registers */ 19 + #define TOY_TRIM_REG 0x20 /* Must be initialized to 0 */ 20 + #define TOY_WRITE0_REG 0x24 /* TOY low 32-bits value (write-only) */ 21 + #define TOY_WRITE1_REG 0x28 /* TOY high 32-bits value (write-only) */ 22 + #define TOY_READ0_REG 0x2c /* TOY low 32-bits value (read-only) */ 23 + #define TOY_READ1_REG 0x30 /* TOY high 32-bits value (read-only) */ 24 + #define TOY_MATCH0_REG 0x34 /* TOY timing interrupt 0 */ 25 + #define TOY_MATCH1_REG 0x38 /* TOY timing interrupt 1 */ 26 + #define TOY_MATCH2_REG 0x3c /* TOY timing interrupt 2 */ 27 + 28 + /* RTC counters registers */ 29 + #define RTC_CTRL_REG 0x40 /* TOY and RTC control register */ 30 + #define RTC_TRIM_REG 0x60 /* Must be initialized to 0 */ 31 + #define RTC_WRITE0_REG 0x64 /* RTC counters value (write-only) */ 32 + #define RTC_READ0_REG 0x68 /* RTC counters value (read-only) */ 33 + #define RTC_MATCH0_REG 0x6c /* RTC timing interrupt 0 */ 34 + #define RTC_MATCH1_REG 0x70 /* RTC timing interrupt 1 */ 35 + #define RTC_MATCH2_REG 0x74 /* RTC timing interrupt 2 */ 36 + 37 + /* bitmask of TOY_WRITE0_REG */ 38 + #define TOY_MON GENMASK(31, 26) 39 + #define TOY_DAY GENMASK(25, 21) 40 + #define TOY_HOUR GENMASK(20, 16) 41 + #define TOY_MIN GENMASK(15, 10) 42 + #define TOY_SEC GENMASK(9, 4) 43 + #define TOY_MSEC GENMASK(3, 0) 44 + 45 + /* bitmask of TOY_MATCH0/1/2_REG */ 46 + #define TOY_MATCH_YEAR GENMASK(31, 26) 47 + #define TOY_MATCH_MON GENMASK(25, 22) 48 + #define TOY_MATCH_DAY GENMASK(21, 17) 49 + #define TOY_MATCH_HOUR GENMASK(16, 12) 50 + #define TOY_MATCH_MIN GENMASK(11, 6) 51 + #define TOY_MATCH_SEC GENMASK(5, 0) 52 + 53 + /* bitmask of RTC_CTRL_REG */ 54 + #define RTC_ENABLE BIT(13) /* 1: RTC counters enable */ 55 + #define TOY_ENABLE BIT(11) /* 1: TOY counters enable */ 56 + #define OSC_ENABLE BIT(8) /* 1: 32.768k crystal enable */ 57 + #define TOY_ENABLE_MASK (TOY_ENABLE | OSC_ENABLE) 58 + 59 + /* PM domain registers */ 60 + #define PM1_STS_REG 0x0c /* Power management 1 status register */ 61 + #define RTC_STS BIT(10) /* RTC status */ 62 + #define PM1_EN_REG 0x10 /* Power management 1 enable register */ 63 + #define RTC_EN BIT(10) /* RTC event enable */ 64 + 65 + /* 66 + * According to the LS1C manual, RTC_CTRL and alarm-related registers are not defined. 67 + * Accessing the relevant registers will cause the system to hang. 68 + */ 69 + #define LS1C_RTC_CTRL_WORKAROUND BIT(0) 70 + 71 + struct loongson_rtc_config { 72 + u32 pm_offset; /* Offset of PM domain, for RTC alarm wakeup */ 73 + u32 flags; /* Workaround bits */ 74 + }; 75 + 76 + struct loongson_rtc_priv { 77 + spinlock_t lock; /* protects PM registers access */ 78 + u32 fix_year; /* RTC alarm year compensation value */ 79 + struct rtc_device *rtcdev; 80 + struct regmap *regmap; 81 + void __iomem *pm_base; /* PM domain base, for RTC alarm wakeup */ 82 + const struct loongson_rtc_config *config; 83 + }; 84 + 85 + static const struct loongson_rtc_config ls1b_rtc_config = { 86 + .pm_offset = 0, 87 + .flags = 0, 88 + }; 89 + 90 + static const struct loongson_rtc_config ls1c_rtc_config = { 91 + .pm_offset = 0, 92 + .flags = LS1C_RTC_CTRL_WORKAROUND, 93 + }; 94 + 95 + static const struct loongson_rtc_config generic_rtc_config = { 96 + .pm_offset = 0x100, 97 + .flags = 0, 98 + }; 99 + 100 + static const struct loongson_rtc_config ls2k1000_rtc_config = { 101 + .pm_offset = 0x800, 102 + .flags = 0, 103 + }; 104 + 105 + static const struct regmap_config loongson_rtc_regmap_config = { 106 + .reg_bits = 32, 107 + .val_bits = 32, 108 + .reg_stride = 4, 109 + }; 110 + 111 + /* RTC alarm irq handler */ 112 + static irqreturn_t loongson_rtc_isr(int irq, void *id) 113 + { 114 + struct loongson_rtc_priv *priv = (struct loongson_rtc_priv *)id; 115 + 116 + rtc_update_irq(priv->rtcdev, 1, RTC_AF | RTC_IRQF); 117 + return IRQ_HANDLED; 118 + } 119 + 120 + /* For ACPI fixed event handler */ 121 + static u32 loongson_rtc_handler(void *id) 122 + { 123 + struct loongson_rtc_priv *priv = (struct loongson_rtc_priv *)id; 124 + 125 + spin_lock(&priv->lock); 126 + /* Disable RTC alarm wakeup and interrupt */ 127 + writel(readl(priv->pm_base + PM1_EN_REG) & ~RTC_EN, 128 + priv->pm_base + PM1_EN_REG); 129 + 130 + /* Clear RTC interrupt status */ 131 + writel(RTC_STS, priv->pm_base + PM1_STS_REG); 132 + spin_unlock(&priv->lock); 133 + 134 + /* 135 + * The TOY_MATCH0_REG should be cleared 0 here, 136 + * otherwise the interrupt cannot be cleared. 137 + */ 138 + return regmap_write(priv->regmap, TOY_MATCH0_REG, 0); 139 + } 140 + 141 + static int loongson_rtc_set_enabled(struct device *dev) 142 + { 143 + struct loongson_rtc_priv *priv = dev_get_drvdata(dev); 144 + 145 + if (priv->config->flags & LS1C_RTC_CTRL_WORKAROUND) 146 + return 0; 147 + 148 + /* Enable RTC TOY counters and crystal */ 149 + return regmap_update_bits(priv->regmap, RTC_CTRL_REG, TOY_ENABLE_MASK, 150 + TOY_ENABLE_MASK); 151 + } 152 + 153 + static bool loongson_rtc_get_enabled(struct device *dev) 154 + { 155 + int ret; 156 + u32 ctrl_data; 157 + struct loongson_rtc_priv *priv = dev_get_drvdata(dev); 158 + 159 + if (priv->config->flags & LS1C_RTC_CTRL_WORKAROUND) 160 + return true; 161 + 162 + ret = regmap_read(priv->regmap, RTC_CTRL_REG, &ctrl_data); 163 + if (ret < 0) 164 + return false; 165 + 166 + return ctrl_data & TOY_ENABLE_MASK; 167 + } 168 + 169 + static int loongson_rtc_read_time(struct device *dev, struct rtc_time *tm) 170 + { 171 + int ret; 172 + u32 rtc_data[2]; 173 + struct loongson_rtc_priv *priv = dev_get_drvdata(dev); 174 + 175 + if (!loongson_rtc_get_enabled(dev)) 176 + return -EINVAL; 177 + 178 + ret = regmap_bulk_read(priv->regmap, TOY_READ0_REG, rtc_data, 179 + ARRAY_SIZE(rtc_data)); 180 + if (ret < 0) 181 + return ret; 182 + 183 + tm->tm_sec = FIELD_GET(TOY_SEC, rtc_data[0]); 184 + tm->tm_min = FIELD_GET(TOY_MIN, rtc_data[0]); 185 + tm->tm_hour = FIELD_GET(TOY_HOUR, rtc_data[0]); 186 + tm->tm_mday = FIELD_GET(TOY_DAY, rtc_data[0]); 187 + tm->tm_mon = FIELD_GET(TOY_MON, rtc_data[0]) - 1; 188 + tm->tm_year = rtc_data[1]; 189 + 190 + /* Prepare for RTC alarm year compensation value. */ 191 + priv->fix_year = tm->tm_year / 64 * 64; 192 + return 0; 193 + } 194 + 195 + static int loongson_rtc_set_time(struct device *dev, struct rtc_time *tm) 196 + { 197 + int ret; 198 + u32 rtc_data[2]; 199 + struct loongson_rtc_priv *priv = dev_get_drvdata(dev); 200 + 201 + rtc_data[0] = FIELD_PREP(TOY_SEC, tm->tm_sec) 202 + | FIELD_PREP(TOY_MIN, tm->tm_min) 203 + | FIELD_PREP(TOY_HOUR, tm->tm_hour) 204 + | FIELD_PREP(TOY_DAY, tm->tm_mday) 205 + | FIELD_PREP(TOY_MON, tm->tm_mon + 1); 206 + rtc_data[1] = tm->tm_year; 207 + 208 + ret = regmap_bulk_write(priv->regmap, TOY_WRITE0_REG, rtc_data, 209 + ARRAY_SIZE(rtc_data)); 210 + if (ret < 0) 211 + return ret; 212 + 213 + return loongson_rtc_set_enabled(dev); 214 + } 215 + 216 + static int loongson_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) 217 + { 218 + int ret; 219 + u32 alarm_data; 220 + struct loongson_rtc_priv *priv = dev_get_drvdata(dev); 221 + 222 + ret = regmap_read(priv->regmap, TOY_MATCH0_REG, &alarm_data); 223 + if (ret < 0) 224 + return ret; 225 + 226 + alrm->time.tm_sec = FIELD_GET(TOY_MATCH_SEC, alarm_data); 227 + alrm->time.tm_min = FIELD_GET(TOY_MATCH_MIN, alarm_data); 228 + alrm->time.tm_hour = FIELD_GET(TOY_MATCH_HOUR, alarm_data); 229 + alrm->time.tm_mday = FIELD_GET(TOY_MATCH_DAY, alarm_data); 230 + alrm->time.tm_mon = FIELD_GET(TOY_MATCH_MON, alarm_data) - 1; 231 + /* 232 + * This is a hardware bug: the year field of SYS_TOYMATCH is only 6 bits, 233 + * making it impossible to save year values larger than 64. 234 + * 235 + * SYS_TOYMATCH is used to match the alarm time value and determine if 236 + * an alarm is triggered, so we must keep the lower 6 bits of the year 237 + * value constant during the value conversion. 238 + * 239 + * In summary, we need to manually add 64(or a multiple of 64) to the 240 + * year value to avoid the invalid alarm prompt at startup. 241 + */ 242 + alrm->time.tm_year = FIELD_GET(TOY_MATCH_YEAR, alarm_data) + priv->fix_year; 243 + 244 + alrm->enabled = !!(readl(priv->pm_base + PM1_EN_REG) & RTC_EN); 245 + return 0; 246 + } 247 + 248 + static int loongson_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) 249 + { 250 + u32 val; 251 + struct loongson_rtc_priv *priv = dev_get_drvdata(dev); 252 + 253 + spin_lock(&priv->lock); 254 + val = readl(priv->pm_base + PM1_EN_REG); 255 + /* Enable RTC alarm wakeup */ 256 + writel(enabled ? val | RTC_EN : val & ~RTC_EN, 257 + priv->pm_base + PM1_EN_REG); 258 + spin_unlock(&priv->lock); 259 + 260 + return 0; 261 + } 262 + 263 + static int loongson_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) 264 + { 265 + int ret; 266 + u32 alarm_data; 267 + struct loongson_rtc_priv *priv = dev_get_drvdata(dev); 268 + 269 + alarm_data = FIELD_PREP(TOY_MATCH_SEC, alrm->time.tm_sec) 270 + | FIELD_PREP(TOY_MATCH_MIN, alrm->time.tm_min) 271 + | FIELD_PREP(TOY_MATCH_HOUR, alrm->time.tm_hour) 272 + | FIELD_PREP(TOY_MATCH_DAY, alrm->time.tm_mday) 273 + | FIELD_PREP(TOY_MATCH_MON, alrm->time.tm_mon + 1) 274 + | FIELD_PREP(TOY_MATCH_YEAR, alrm->time.tm_year - priv->fix_year); 275 + 276 + ret = regmap_write(priv->regmap, TOY_MATCH0_REG, alarm_data); 277 + if (ret < 0) 278 + return ret; 279 + 280 + return loongson_rtc_alarm_irq_enable(dev, alrm->enabled); 281 + } 282 + 283 + static const struct rtc_class_ops loongson_rtc_ops = { 284 + .read_time = loongson_rtc_read_time, 285 + .set_time = loongson_rtc_set_time, 286 + .read_alarm = loongson_rtc_read_alarm, 287 + .set_alarm = loongson_rtc_set_alarm, 288 + .alarm_irq_enable = loongson_rtc_alarm_irq_enable, 289 + }; 290 + 291 + static int loongson_rtc_probe(struct platform_device *pdev) 292 + { 293 + int ret, alarm_irq; 294 + void __iomem *regs; 295 + struct loongson_rtc_priv *priv; 296 + struct device *dev = &pdev->dev; 297 + 298 + priv = devm_kzalloc(dev, sizeof(*priv), GFP_KERNEL); 299 + if (!priv) 300 + return -ENOMEM; 301 + 302 + regs = devm_platform_ioremap_resource(pdev, 0); 303 + if (IS_ERR(regs)) 304 + return dev_err_probe(dev, PTR_ERR(regs), 305 + "devm_platform_ioremap_resource failed\n"); 306 + 307 + priv->regmap = devm_regmap_init_mmio(dev, regs, 308 + &loongson_rtc_regmap_config); 309 + if (IS_ERR(priv->regmap)) 310 + return dev_err_probe(dev, PTR_ERR(priv->regmap), 311 + "devm_regmap_init_mmio failed\n"); 312 + 313 + priv->config = device_get_match_data(dev); 314 + spin_lock_init(&priv->lock); 315 + platform_set_drvdata(pdev, priv); 316 + 317 + priv->rtcdev = devm_rtc_allocate_device(dev); 318 + if (IS_ERR(priv->rtcdev)) 319 + return dev_err_probe(dev, PTR_ERR(priv->rtcdev), 320 + "devm_rtc_allocate_device failed\n"); 321 + 322 + /* Get RTC alarm irq */ 323 + alarm_irq = platform_get_irq(pdev, 0); 324 + if (alarm_irq > 0) { 325 + ret = devm_request_irq(dev, alarm_irq, loongson_rtc_isr, 326 + 0, "loongson-alarm", priv); 327 + if (ret < 0) 328 + return dev_err_probe(dev, ret, "Unable to request irq %d\n", 329 + alarm_irq); 330 + 331 + priv->pm_base = regs - priv->config->pm_offset; 332 + device_init_wakeup(dev, 1); 333 + 334 + if (has_acpi_companion(dev)) 335 + acpi_install_fixed_event_handler(ACPI_EVENT_RTC, 336 + loongson_rtc_handler, priv); 337 + } else { 338 + /* Loongson-1C RTC does not support alarm */ 339 + clear_bit(RTC_FEATURE_ALARM, priv->rtcdev->features); 340 + } 341 + 342 + /* Loongson RTC does not support UIE */ 343 + clear_bit(RTC_FEATURE_UPDATE_INTERRUPT, priv->rtcdev->features); 344 + priv->rtcdev->ops = &loongson_rtc_ops; 345 + priv->rtcdev->range_min = RTC_TIMESTAMP_BEGIN_2000; 346 + priv->rtcdev->range_max = RTC_TIMESTAMP_END_2099; 347 + 348 + return devm_rtc_register_device(priv->rtcdev); 349 + } 350 + 351 + static void loongson_rtc_remove(struct platform_device *pdev) 352 + { 353 + struct device *dev = &pdev->dev; 354 + struct loongson_rtc_priv *priv = dev_get_drvdata(dev); 355 + 356 + if (!test_bit(RTC_FEATURE_ALARM, priv->rtcdev->features)) 357 + return; 358 + 359 + if (has_acpi_companion(dev)) 360 + acpi_remove_fixed_event_handler(ACPI_EVENT_RTC, 361 + loongson_rtc_handler); 362 + 363 + device_init_wakeup(dev, 0); 364 + loongson_rtc_alarm_irq_enable(dev, 0); 365 + } 366 + 367 + static const struct of_device_id loongson_rtc_of_match[] = { 368 + { .compatible = "loongson,ls1b-rtc", .data = &ls1b_rtc_config }, 369 + { .compatible = "loongson,ls1c-rtc", .data = &ls1c_rtc_config }, 370 + { .compatible = "loongson,ls7a-rtc", .data = &generic_rtc_config }, 371 + { .compatible = "loongson,ls2k1000-rtc", .data = &ls2k1000_rtc_config }, 372 + { /* sentinel */ } 373 + }; 374 + MODULE_DEVICE_TABLE(of, loongson_rtc_of_match); 375 + 376 + static const struct acpi_device_id loongson_rtc_acpi_match[] = { 377 + { "LOON0001", .driver_data = (kernel_ulong_t)&generic_rtc_config }, 378 + { } 379 + }; 380 + MODULE_DEVICE_TABLE(acpi, loongson_rtc_acpi_match); 381 + 382 + static struct platform_driver loongson_rtc_driver = { 383 + .probe = loongson_rtc_probe, 384 + .remove_new = loongson_rtc_remove, 385 + .driver = { 386 + .name = "loongson-rtc", 387 + .of_match_table = loongson_rtc_of_match, 388 + .acpi_match_table = loongson_rtc_acpi_match, 389 + }, 390 + }; 391 + module_platform_driver(loongson_rtc_driver); 392 + 393 + MODULE_DESCRIPTION("Loongson RTC driver"); 394 + MODULE_AUTHOR("Binbin Zhou <zhoubinbin@loongson.cn>"); 395 + MODULE_AUTHOR("WANG Xuerui <git@xen0n.name>"); 396 + MODULE_AUTHOR("Huacai Chen <chenhuacai@kernel.org>"); 397 + MODULE_LICENSE("GPL");
-192
drivers/rtc/rtc-ls1x.c
··· 1 - // SPDX-License-Identifier: GPL-2.0-or-later 2 - /* 3 - * Copyright (c) 2011 Zhao Zhang <zhzhl555@gmail.com> 4 - * 5 - * Derived from driver/rtc/rtc-au1xxx.c 6 - */ 7 - 8 - #include <linux/module.h> 9 - #include <linux/kernel.h> 10 - #include <linux/rtc.h> 11 - #include <linux/init.h> 12 - #include <linux/platform_device.h> 13 - #include <linux/delay.h> 14 - #include <linux/types.h> 15 - #include <linux/io.h> 16 - #include <loongson1.h> 17 - 18 - #define LS1X_RTC_REG_OFFSET (LS1X_RTC_BASE + 0x20) 19 - #define LS1X_RTC_REGS(x) \ 20 - ((void __iomem *)KSEG1ADDR(LS1X_RTC_REG_OFFSET + (x))) 21 - 22 - /*RTC programmable counters 0 and 1*/ 23 - #define SYS_COUNTER_CNTRL (LS1X_RTC_REGS(0x20)) 24 - #define SYS_CNTRL_ERS (1 << 23) 25 - #define SYS_CNTRL_RTS (1 << 20) 26 - #define SYS_CNTRL_RM2 (1 << 19) 27 - #define SYS_CNTRL_RM1 (1 << 18) 28 - #define SYS_CNTRL_RM0 (1 << 17) 29 - #define SYS_CNTRL_RS (1 << 16) 30 - #define SYS_CNTRL_BP (1 << 14) 31 - #define SYS_CNTRL_REN (1 << 13) 32 - #define SYS_CNTRL_BRT (1 << 12) 33 - #define SYS_CNTRL_TEN (1 << 11) 34 - #define SYS_CNTRL_BTT (1 << 10) 35 - #define SYS_CNTRL_E0 (1 << 8) 36 - #define SYS_CNTRL_ETS (1 << 7) 37 - #define SYS_CNTRL_32S (1 << 5) 38 - #define SYS_CNTRL_TTS (1 << 4) 39 - #define SYS_CNTRL_TM2 (1 << 3) 40 - #define SYS_CNTRL_TM1 (1 << 2) 41 - #define SYS_CNTRL_TM0 (1 << 1) 42 - #define SYS_CNTRL_TS (1 << 0) 43 - 44 - /* Programmable Counter 0 Registers */ 45 - #define SYS_TOYTRIM (LS1X_RTC_REGS(0)) 46 - #define SYS_TOYWRITE0 (LS1X_RTC_REGS(4)) 47 - #define SYS_TOYWRITE1 (LS1X_RTC_REGS(8)) 48 - #define SYS_TOYREAD0 (LS1X_RTC_REGS(0xC)) 49 - #define SYS_TOYREAD1 (LS1X_RTC_REGS(0x10)) 50 - #define SYS_TOYMATCH0 (LS1X_RTC_REGS(0x14)) 51 - #define SYS_TOYMATCH1 (LS1X_RTC_REGS(0x18)) 52 - #define SYS_TOYMATCH2 (LS1X_RTC_REGS(0x1C)) 53 - 54 - /* Programmable Counter 1 Registers */ 55 - #define SYS_RTCTRIM (LS1X_RTC_REGS(0x40)) 56 - #define SYS_RTCWRITE0 (LS1X_RTC_REGS(0x44)) 57 - #define SYS_RTCREAD0 (LS1X_RTC_REGS(0x48)) 58 - #define SYS_RTCMATCH0 (LS1X_RTC_REGS(0x4C)) 59 - #define SYS_RTCMATCH1 (LS1X_RTC_REGS(0x50)) 60 - #define SYS_RTCMATCH2 (LS1X_RTC_REGS(0x54)) 61 - 62 - #define LS1X_SEC_OFFSET (4) 63 - #define LS1X_MIN_OFFSET (10) 64 - #define LS1X_HOUR_OFFSET (16) 65 - #define LS1X_DAY_OFFSET (21) 66 - #define LS1X_MONTH_OFFSET (26) 67 - 68 - 69 - #define LS1X_SEC_MASK (0x3f) 70 - #define LS1X_MIN_MASK (0x3f) 71 - #define LS1X_HOUR_MASK (0x1f) 72 - #define LS1X_DAY_MASK (0x1f) 73 - #define LS1X_MONTH_MASK (0x3f) 74 - #define LS1X_YEAR_MASK (0xffffffff) 75 - 76 - #define ls1x_get_sec(t) (((t) >> LS1X_SEC_OFFSET) & LS1X_SEC_MASK) 77 - #define ls1x_get_min(t) (((t) >> LS1X_MIN_OFFSET) & LS1X_MIN_MASK) 78 - #define ls1x_get_hour(t) (((t) >> LS1X_HOUR_OFFSET) & LS1X_HOUR_MASK) 79 - #define ls1x_get_day(t) (((t) >> LS1X_DAY_OFFSET) & LS1X_DAY_MASK) 80 - #define ls1x_get_month(t) (((t) >> LS1X_MONTH_OFFSET) & LS1X_MONTH_MASK) 81 - 82 - #define RTC_CNTR_OK (SYS_CNTRL_E0 | SYS_CNTRL_32S) 83 - 84 - static int ls1x_rtc_read_time(struct device *dev, struct rtc_time *rtm) 85 - { 86 - unsigned long v; 87 - time64_t t; 88 - 89 - v = readl(SYS_TOYREAD0); 90 - t = readl(SYS_TOYREAD1); 91 - 92 - memset(rtm, 0, sizeof(struct rtc_time)); 93 - t = mktime64((t & LS1X_YEAR_MASK), ls1x_get_month(v), 94 - ls1x_get_day(v), ls1x_get_hour(v), 95 - ls1x_get_min(v), ls1x_get_sec(v)); 96 - rtc_time64_to_tm(t, rtm); 97 - 98 - return 0; 99 - } 100 - 101 - static int ls1x_rtc_set_time(struct device *dev, struct rtc_time *rtm) 102 - { 103 - unsigned long v, t, c; 104 - int ret = -ETIMEDOUT; 105 - 106 - v = ((rtm->tm_mon + 1) << LS1X_MONTH_OFFSET) 107 - | (rtm->tm_mday << LS1X_DAY_OFFSET) 108 - | (rtm->tm_hour << LS1X_HOUR_OFFSET) 109 - | (rtm->tm_min << LS1X_MIN_OFFSET) 110 - | (rtm->tm_sec << LS1X_SEC_OFFSET); 111 - 112 - writel(v, SYS_TOYWRITE0); 113 - c = 0x10000; 114 - /* add timeout check counter, for more safe */ 115 - while ((readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_TS) && --c) 116 - usleep_range(1000, 3000); 117 - 118 - if (!c) { 119 - dev_err(dev, "set time timeout!\n"); 120 - goto err; 121 - } 122 - 123 - t = rtm->tm_year + 1900; 124 - writel(t, SYS_TOYWRITE1); 125 - c = 0x10000; 126 - while ((readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_TS) && --c) 127 - usleep_range(1000, 3000); 128 - 129 - if (!c) { 130 - dev_err(dev, "set time timeout!\n"); 131 - goto err; 132 - } 133 - return 0; 134 - err: 135 - return ret; 136 - } 137 - 138 - static const struct rtc_class_ops ls1x_rtc_ops = { 139 - .read_time = ls1x_rtc_read_time, 140 - .set_time = ls1x_rtc_set_time, 141 - }; 142 - 143 - static int ls1x_rtc_probe(struct platform_device *pdev) 144 - { 145 - struct rtc_device *rtcdev; 146 - unsigned long v; 147 - 148 - v = readl(SYS_COUNTER_CNTRL); 149 - if (!(v & RTC_CNTR_OK)) { 150 - dev_err(&pdev->dev, "rtc counters not working\n"); 151 - return -ENODEV; 152 - } 153 - 154 - /* set to 1 HZ if needed */ 155 - if (readl(SYS_TOYTRIM) != 32767) { 156 - v = 0x100000; 157 - while ((readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_TTS) && --v) 158 - usleep_range(1000, 3000); 159 - 160 - if (!v) { 161 - dev_err(&pdev->dev, "time out\n"); 162 - return -ETIMEDOUT; 163 - } 164 - writel(32767, SYS_TOYTRIM); 165 - } 166 - /* this loop coundn't be endless */ 167 - while (readl(SYS_COUNTER_CNTRL) & SYS_CNTRL_TTS) 168 - usleep_range(1000, 3000); 169 - 170 - rtcdev = devm_rtc_allocate_device(&pdev->dev); 171 - if (IS_ERR(rtcdev)) 172 - return PTR_ERR(rtcdev); 173 - 174 - platform_set_drvdata(pdev, rtcdev); 175 - rtcdev->ops = &ls1x_rtc_ops; 176 - rtcdev->range_min = RTC_TIMESTAMP_BEGIN_1900; 177 - rtcdev->range_max = RTC_TIMESTAMP_END_2099; 178 - 179 - return devm_rtc_register_device(rtcdev); 180 - } 181 - 182 - static struct platform_driver ls1x_rtc_driver = { 183 - .driver = { 184 - .name = "ls1x-rtc", 185 - }, 186 - .probe = ls1x_rtc_probe, 187 - }; 188 - 189 - module_platform_driver(ls1x_rtc_driver); 190 - 191 - MODULE_AUTHOR("zhao zhang <zhzhl555@gmail.com>"); 192 - MODULE_LICENSE("GPL");
+1 -1
drivers/rtc/rtc-m41t80.c
··· 1013 1013 .of_match_table = of_match_ptr(m41t80_of_match), 1014 1014 .pm = &m41t80_pm, 1015 1015 }, 1016 - .probe_new = m41t80_probe, 1016 + .probe = m41t80_probe, 1017 1017 .remove = m41t80_remove, 1018 1018 .id_table = m41t80_id, 1019 1019 };
+1 -1
drivers/rtc/rtc-max6900.c
··· 224 224 .driver = { 225 225 .name = "rtc-max6900", 226 226 }, 227 - .probe_new = max6900_probe, 227 + .probe = max6900_probe, 228 228 .id_table = max6900_id, 229 229 }; 230 230
+1 -1
drivers/rtc/rtc-nct3018y.c
··· 540 540 .name = "rtc-nct3018y", 541 541 .of_match_table = of_match_ptr(nct3018y_of_match), 542 542 }, 543 - .probe_new = nct3018y_probe, 543 + .probe = nct3018y_probe, 544 544 .id_table = nct3018y_id, 545 545 }; 546 546
+1 -1
drivers/rtc/rtc-pcf2127.c
··· 923 923 .name = "rtc-pcf2127-i2c", 924 924 .of_match_table = of_match_ptr(pcf2127_of_match), 925 925 }, 926 - .probe_new = pcf2127_i2c_probe, 926 + .probe = pcf2127_i2c_probe, 927 927 .id_table = pcf2127_i2c_id, 928 928 }; 929 929
+1 -1
drivers/rtc/rtc-pcf85063.c
··· 681 681 .name = "rtc-pcf85063", 682 682 .of_match_table = of_match_ptr(pcf85063_of_match), 683 683 }, 684 - .probe_new = pcf85063_probe, 684 + .probe = pcf85063_probe, 685 685 .id_table = pcf85063_ids, 686 686 }; 687 687
+1 -1
drivers/rtc/rtc-pcf8523.c
··· 488 488 .name = "rtc-pcf8523", 489 489 .of_match_table = pcf8523_of_match, 490 490 }, 491 - .probe_new = pcf8523_probe, 491 + .probe = pcf8523_probe, 492 492 .id_table = pcf8523_id, 493 493 }; 494 494 module_i2c_driver(pcf8523_driver);
+1 -1
drivers/rtc/rtc-pcf85363.c
··· 475 475 .name = "pcf85363", 476 476 .of_match_table = of_match_ptr(dev_ids), 477 477 }, 478 - .probe_new = pcf85363_probe, 478 + .probe = pcf85363_probe, 479 479 }; 480 480 481 481 module_i2c_driver(pcf85363_driver);
+1 -1
drivers/rtc/rtc-pcf8563.c
··· 612 612 .name = "rtc-pcf8563", 613 613 .of_match_table = of_match_ptr(pcf8563_of_match), 614 614 }, 615 - .probe_new = pcf8563_probe, 615 + .probe = pcf8563_probe, 616 616 .id_table = pcf8563_id, 617 617 }; 618 618
+1 -1
drivers/rtc/rtc-pcf8583.c
··· 306 306 .driver = { 307 307 .name = "pcf8583", 308 308 }, 309 - .probe_new = pcf8583_probe, 309 + .probe = pcf8583_probe, 310 310 .id_table = pcf8583_id, 311 311 }; 312 312
+1 -1
drivers/rtc/rtc-rs5c372.c
··· 921 921 .name = "rtc-rs5c372", 922 922 .of_match_table = of_match_ptr(rs5c372_of_match), 923 923 }, 924 - .probe_new = rs5c372_probe, 924 + .probe = rs5c372_probe, 925 925 .remove = rs5c372_remove, 926 926 .id_table = rs5c372_id, 927 927 };
+8 -1
drivers/rtc/rtc-rv3028.c
··· 994 994 }; 995 995 MODULE_DEVICE_TABLE(of, rv3028_of_match); 996 996 997 + static const struct i2c_device_id rv3028_id_table[] = { 998 + { .name = "rv3028", }, 999 + { } 1000 + }; 1001 + MODULE_DEVICE_TABLE(i2c, rv3028_id_table); 1002 + 997 1003 static struct i2c_driver rv3028_driver = { 998 1004 .driver = { 999 1005 .name = "rtc-rv3028", 1000 1006 .acpi_match_table = rv3028_i2c_acpi_match, 1001 1007 .of_match_table = of_match_ptr(rv3028_of_match), 1002 1008 }, 1003 - .probe_new = rv3028_probe, 1009 + .id_table = rv3028_id_table, 1010 + .probe = rv3028_probe, 1004 1011 }; 1005 1012 module_i2c_driver(rv3028_driver); 1006 1013
+1 -1
drivers/rtc/rtc-rv3029c2.c
··· 824 824 .name = "rv3029", 825 825 .of_match_table = of_match_ptr(rv3029_of_match), 826 826 }, 827 - .probe_new = rv3029_i2c_probe, 827 + .probe = rv3029_i2c_probe, 828 828 .id_table = rv3029_id, 829 829 }; 830 830
+2 -2
drivers/rtc/rtc-rv3032.c
··· 842 842 return err; 843 843 } 844 844 845 - static const struct hwmon_channel_info *rv3032_hwmon_info[] = { 845 + static const struct hwmon_channel_info * const rv3032_hwmon_info[] = { 846 846 HWMON_CHANNEL_INFO(chip, HWMON_C_REGISTER_TZ), 847 847 HWMON_CHANNEL_INFO(temp, HWMON_T_INPUT | HWMON_T_MAX | HWMON_T_MAX_HYST), 848 848 NULL ··· 998 998 .acpi_match_table = rv3032_i2c_acpi_match, 999 999 .of_match_table = of_match_ptr(rv3032_of_match), 1000 1000 }, 1001 - .probe_new = rv3032_probe, 1001 + .probe = rv3032_probe, 1002 1002 }; 1003 1003 module_i2c_driver(rv3032_driver); 1004 1004
+1 -1
drivers/rtc/rtc-rv8803.c
··· 739 739 .name = "rtc-rv8803", 740 740 .of_match_table = of_match_ptr(rv8803_of_match), 741 741 }, 742 - .probe_new = rv8803_probe, 742 + .probe = rv8803_probe, 743 743 .id_table = rv8803_id, 744 744 }; 745 745 module_i2c_driver(rv8803_driver);
+1 -1
drivers/rtc/rtc-rx6110.c
··· 462 462 .name = RX6110_DRIVER_NAME, 463 463 .acpi_match_table = rx6110_i2c_acpi_match, 464 464 }, 465 - .probe_new = rx6110_i2c_probe, 465 + .probe = rx6110_i2c_probe, 466 466 .id_table = rx6110_i2c_id, 467 467 }; 468 468
+1 -1
drivers/rtc/rtc-rx8010.c
··· 424 424 .name = "rtc-rx8010", 425 425 .of_match_table = of_match_ptr(rx8010_of_match), 426 426 }, 427 - .probe_new = rx8010_probe, 427 + .probe = rx8010_probe, 428 428 .id_table = rx8010_id, 429 429 }; 430 430
+1 -1
drivers/rtc/rtc-rx8025.c
··· 581 581 .driver = { 582 582 .name = "rtc-rx8025", 583 583 }, 584 - .probe_new = rx8025_probe, 584 + .probe = rx8025_probe, 585 585 .id_table = rx8025_id, 586 586 }; 587 587
+1 -1
drivers/rtc/rtc-rx8581.c
··· 325 325 .name = "rtc-rx8581", 326 326 .of_match_table = of_match_ptr(rx8581_of_match), 327 327 }, 328 - .probe_new = rx8581_probe, 328 + .probe = rx8581_probe, 329 329 .id_table = rx8581_id, 330 330 }; 331 331
+1 -1
drivers/rtc/rtc-s35390a.c
··· 499 499 .name = "rtc-s35390a", 500 500 .of_match_table = of_match_ptr(s35390a_of_match), 501 501 }, 502 - .probe_new = s35390a_probe, 502 + .probe = s35390a_probe, 503 503 .id_table = s35390a_id, 504 504 }; 505 505
+1 -1
drivers/rtc/rtc-sd3078.c
··· 217 217 .name = "sd3078", 218 218 .of_match_table = of_match_ptr(rtc_dt_match), 219 219 }, 220 - .probe_new = sd3078_probe, 220 + .probe = sd3078_probe, 221 221 .id_table = sd3078_id, 222 222 }; 223 223
+5 -11
drivers/rtc/rtc-st-lpc.c
··· 228 228 enable_irq_wake(rtc->irq); 229 229 disable_irq(rtc->irq); 230 230 231 - rtc->clk = clk_get(&pdev->dev, NULL); 232 - if (IS_ERR(rtc->clk)) { 233 - dev_err(&pdev->dev, "Unable to request clock\n"); 234 - return PTR_ERR(rtc->clk); 235 - } 236 - 237 - clk_prepare_enable(rtc->clk); 231 + rtc->clk = devm_clk_get_enabled(&pdev->dev, NULL); 232 + if (IS_ERR(rtc->clk)) 233 + return dev_err_probe(&pdev->dev, PTR_ERR(rtc->clk), 234 + "Unable to request clock\n"); 238 235 239 236 rtc->clkrate = clk_get_rate(rtc->clk); 240 237 if (!rtc->clkrate) { 241 - clk_disable_unprepare(rtc->clk); 242 238 dev_err(&pdev->dev, "Unable to fetch clock rate\n"); 243 239 return -EINVAL; 244 240 } ··· 248 252 do_div(rtc->rtc_dev->range_max, rtc->clkrate); 249 253 250 254 ret = devm_rtc_register_device(rtc->rtc_dev); 251 - if (ret) { 252 - clk_disable_unprepare(rtc->clk); 255 + if (ret) 253 256 return ret; 254 - } 255 257 256 258 return 0; 257 259 }
+5 -23
drivers/rtc/rtc-stm32.c
··· 114 114 void (*clear_events)(struct stm32_rtc *rtc, unsigned int flags); 115 115 bool has_pclk; 116 116 bool need_dbp; 117 - bool has_wakeirq; 118 117 }; 119 118 120 119 struct stm32_rtc { ··· 126 127 struct clk *rtc_ck; 127 128 const struct stm32_rtc_data *data; 128 129 int irq_alarm; 129 - int wakeirq_alarm; 130 130 }; 131 131 132 132 static void stm32_rtc_wpr_unlock(struct stm32_rtc *rtc) ··· 545 547 static const struct stm32_rtc_data stm32_rtc_data = { 546 548 .has_pclk = false, 547 549 .need_dbp = true, 548 - .has_wakeirq = false, 549 550 .regs = { 550 551 .tr = 0x00, 551 552 .dr = 0x04, ··· 566 569 static const struct stm32_rtc_data stm32h7_rtc_data = { 567 570 .has_pclk = true, 568 571 .need_dbp = true, 569 - .has_wakeirq = false, 570 572 .regs = { 571 573 .tr = 0x00, 572 574 .dr = 0x04, ··· 596 600 static const struct stm32_rtc_data stm32mp1_data = { 597 601 .has_pclk = true, 598 602 .need_dbp = false, 599 - .has_wakeirq = true, 600 603 .regs = { 601 604 .tr = 0x00, 602 605 .dr = 0x04, ··· 774 779 } 775 780 776 781 ret = device_init_wakeup(&pdev->dev, true); 777 - if (rtc->data->has_wakeirq) { 778 - rtc->wakeirq_alarm = platform_get_irq(pdev, 1); 779 - if (rtc->wakeirq_alarm > 0) { 780 - ret = dev_pm_set_dedicated_wake_irq(&pdev->dev, 781 - rtc->wakeirq_alarm); 782 - } else { 783 - ret = rtc->wakeirq_alarm; 784 - if (rtc->wakeirq_alarm == -EPROBE_DEFER) 785 - goto err; 786 - } 787 - } 788 782 if (ret) 789 - dev_warn(&pdev->dev, "alarm can't wake up the system: %d", ret); 783 + goto err; 784 + 785 + ret = dev_pm_set_wake_irq(&pdev->dev, rtc->irq_alarm); 786 + if (ret) 787 + goto err; 790 788 791 789 platform_set_drvdata(pdev, rtc); 792 790 ··· 867 879 if (rtc->data->has_pclk) 868 880 clk_disable_unprepare(rtc->pclk); 869 881 870 - if (device_may_wakeup(dev)) 871 - return enable_irq_wake(rtc->irq_alarm); 872 - 873 882 return 0; 874 883 } 875 884 ··· 887 902 clk_disable_unprepare(rtc->pclk); 888 903 return ret; 889 904 } 890 - 891 - if (device_may_wakeup(dev)) 892 - return disable_irq_wake(rtc->irq_alarm); 893 905 894 906 return ret; 895 907 }
+1 -1
drivers/rtc/rtc-x1205.c
··· 679 679 .name = "rtc-x1205", 680 680 .of_match_table = x1205_dt_ids, 681 681 }, 682 - .probe_new = x1205_probe, 682 + .probe = x1205_probe, 683 683 .remove = x1205_remove, 684 684 .id_table = x1205_id, 685 685 };