diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-10-27 12:24:24 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-10-27 12:24:24 -0400 |
commit | c7b7eefa57ae3c8802fdec7d07ac4df6c49d1e7a (patch) | |
tree | 7aac7dee4d94113648b210fe9dc4ba181dfc1ccf | |
parent | e5585453498907080c456ec5b51131867ed6d095 (diff) | |
parent | 3822d1bb0df18aa28930f19bc46e0704aea1be0f (diff) |
Merge tag 'rtc-4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux
Pull RTC updates from Alexandre Belloni:
"This cycle, there were mostly non urgent fixes in drivers. I also
finally unexported the non managed registration.
Subsystem:
- non devm managed registration is now removed from the driver API
- all the unnecessary rtc_valid_tm() calls have been removed
Drivers:
- abx80X: watchdog support
- cmos: fix non ACPI support
- sc27xx: fix alarm support
- Remove a possible sysfs race condition for ab8500, ds1307, ds1685,
isl1208
- Fix a possible race condition where an irq handler may be called
before the rtc_device struct is allocated for mt6397, pl030,
menelaus, armada38x"
* tag 'rtc-4.20' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (54 commits)
rtc: sc27xx: Always read normal alarm when registering RTC device
rtc: sc27xx: Add check to see if need to enable the alarm interrupt
rtc: sc27xx: Remove interrupts disable and clear in probe()
rtc: sc27xx: Clear SPG value update interrupt status
rtc: sc27xx: Set wakeup capability before registering rtc device
rtc: s35390a: Change buf's type to u8 in s35390a_init
rtc: ds1307: fix ds1339 wakealarm support
rtc: ds1685: simplify getting .driver_data
rtc: m41t80: mark expected switch fall-through
rtc: tegra: Propagate errors from platform_get_irq()
rtc: cmos: Remove the `use_acpi_alarm' module parameter for !ACPI
rtc: cmos: Fix non-ACPI undefined reference to `hpet_rtc_interrupt'
rtc: mv: let the core handle invalid alarms
rtc: vr41xx: switch to rtc_time64_to_tm/rtc_tm_to_time64
rtc: ab8500: remove useless check
rtc: ab8500: let the core handle range
rtc: ab8500: use rtc_add_group
rtc: rs5c348: report error when time is invalid
rtc: rs5c348: remove forward declaration
rtc: rs5c348: remove useless label
...
33 files changed, 547 insertions, 482 deletions
diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig index 53e75ddbba1c..80778b40f8fa 100644 --- a/arch/mips/Kconfig +++ b/arch/mips/Kconfig | |||
@@ -75,7 +75,7 @@ config MIPS | |||
75 | select MODULES_USE_ELF_RELA if MODULES && 64BIT | 75 | select MODULES_USE_ELF_RELA if MODULES && 64BIT |
76 | select MODULES_USE_ELF_REL if MODULES | 76 | select MODULES_USE_ELF_REL if MODULES |
77 | select PERF_USE_VMALLOC | 77 | select PERF_USE_VMALLOC |
78 | select RTC_LIB if !MACH_LOONGSON64 | 78 | select RTC_LIB |
79 | select SYSCTL_EXCEPTION_TRACE | 79 | select SYSCTL_EXCEPTION_TRACE |
80 | select VIRT_TO_BUS | 80 | select VIRT_TO_BUS |
81 | select NO_BOOTMEM | 81 | select NO_BOOTMEM |
diff --git a/drivers/char/Kconfig b/drivers/char/Kconfig index 40728491f37b..9d03b2ff5df6 100644 --- a/drivers/char/Kconfig +++ b/drivers/char/Kconfig | |||
@@ -268,7 +268,7 @@ if RTC_LIB=n | |||
268 | 268 | ||
269 | config RTC | 269 | config RTC |
270 | tristate "Enhanced Real Time Clock Support (legacy PC RTC driver)" | 270 | tristate "Enhanced Real Time Clock Support (legacy PC RTC driver)" |
271 | depends on ALPHA || (MIPS && MACH_LOONGSON64) | 271 | depends on ALPHA |
272 | ---help--- | 272 | ---help--- |
273 | If you say Y here and create a character special file /dev/rtc with | 273 | If you say Y here and create a character special file /dev/rtc with |
274 | major number 10 and minor number 135 using mknod ("man mknod"), you | 274 | major number 10 and minor number 135 using mknod ("man mknod"), you |
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 7d7be60a2413..a819ef07b7ec 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
@@ -187,6 +187,7 @@ config RTC_DRV_ABB5ZES3 | |||
187 | 187 | ||
188 | config RTC_DRV_ABX80X | 188 | config RTC_DRV_ABX80X |
189 | tristate "Abracon ABx80x" | 189 | tristate "Abracon ABx80x" |
190 | select WATCHDOG_CORE if WATCHDOG | ||
190 | help | 191 | help |
191 | If you say yes here you get support for Abracon AB080X and AB180X | 192 | If you say yes here you get support for Abracon AB080X and AB180X |
192 | families of ultra-low-power battery- and capacitor-backed real-time | 193 | families of ultra-low-power battery- and capacitor-backed real-time |
@@ -1007,17 +1008,6 @@ config RTC_DRV_DS17885 | |||
1007 | 1008 | ||
1008 | endchoice | 1009 | endchoice |
1009 | 1010 | ||
1010 | config RTC_DS1685_PROC_REGS | ||
1011 | bool "Display register values in /proc" | ||
1012 | depends on RTC_DRV_DS1685_FAMILY && PROC_FS | ||
1013 | help | ||
1014 | Enable this to display a readout of all of the RTC registers in | ||
1015 | /proc/drivers/rtc. Keep in mind that this can potentially lead | ||
1016 | to lost interrupts, as reading Control Register C will clear | ||
1017 | all pending IRQ flags. | ||
1018 | |||
1019 | Unless you are debugging this driver, choose N. | ||
1020 | |||
1021 | config RTC_DRV_DS1742 | 1011 | config RTC_DRV_DS1742 |
1022 | tristate "Maxim/Dallas DS1742/1743" | 1012 | tristate "Maxim/Dallas DS1742/1743" |
1023 | depends on HAS_IOMEM | 1013 | depends on HAS_IOMEM |
@@ -1587,7 +1577,7 @@ config RTC_DRV_MPC5121 | |||
1587 | 1577 | ||
1588 | config RTC_DRV_JZ4740 | 1578 | config RTC_DRV_JZ4740 |
1589 | tristate "Ingenic JZ4740 SoC" | 1579 | tristate "Ingenic JZ4740 SoC" |
1590 | depends on MACH_INGENIC || COMPILE_TEST | 1580 | depends on MIPS || COMPILE_TEST |
1591 | help | 1581 | help |
1592 | If you say yes here you get support for the Ingenic JZ47xx SoCs RTC | 1582 | If you say yes here you get support for the Ingenic JZ47xx SoCs RTC |
1593 | controllers. | 1583 | controllers. |
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index 5ff2fc0c361a..290c1730fb0a 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile | |||
@@ -36,9 +36,9 @@ obj-$(CONFIG_RTC_DRV_ASM9260) += rtc-asm9260.o | |||
36 | obj-$(CONFIG_RTC_DRV_AT91RM9200)+= rtc-at91rm9200.o | 36 | obj-$(CONFIG_RTC_DRV_AT91RM9200)+= rtc-at91rm9200.o |
37 | obj-$(CONFIG_RTC_DRV_AT91SAM9) += rtc-at91sam9.o | 37 | obj-$(CONFIG_RTC_DRV_AT91SAM9) += rtc-at91sam9.o |
38 | obj-$(CONFIG_RTC_DRV_AU1XXX) += rtc-au1xxx.o | 38 | obj-$(CONFIG_RTC_DRV_AU1XXX) += rtc-au1xxx.o |
39 | obj-$(CONFIG_RTC_DRV_BRCMSTB) += rtc-brcmstb-waketimer.o | ||
40 | obj-$(CONFIG_RTC_DRV_BQ32K) += rtc-bq32k.o | 39 | obj-$(CONFIG_RTC_DRV_BQ32K) += rtc-bq32k.o |
41 | obj-$(CONFIG_RTC_DRV_BQ4802) += rtc-bq4802.o | 40 | obj-$(CONFIG_RTC_DRV_BQ4802) += rtc-bq4802.o |
41 | obj-$(CONFIG_RTC_DRV_BRCMSTB) += rtc-brcmstb-waketimer.o | ||
42 | obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o | 42 | obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o |
43 | obj-$(CONFIG_RTC_DRV_COH901331) += rtc-coh901331.o | 43 | obj-$(CONFIG_RTC_DRV_COH901331) += rtc-coh901331.o |
44 | obj-$(CONFIG_RTC_DRV_CPCAP) += rtc-cpcap.o | 44 | obj-$(CONFIG_RTC_DRV_CPCAP) += rtc-cpcap.o |
@@ -71,6 +71,7 @@ obj-$(CONFIG_RTC_DRV_EP93XX) += rtc-ep93xx.o | |||
71 | obj-$(CONFIG_RTC_DRV_FM3130) += rtc-fm3130.o | 71 | obj-$(CONFIG_RTC_DRV_FM3130) += rtc-fm3130.o |
72 | obj-$(CONFIG_RTC_DRV_FTRTC010) += rtc-ftrtc010.o | 72 | obj-$(CONFIG_RTC_DRV_FTRTC010) += rtc-ftrtc010.o |
73 | obj-$(CONFIG_RTC_DRV_GENERIC) += rtc-generic.o | 73 | obj-$(CONFIG_RTC_DRV_GENERIC) += rtc-generic.o |
74 | obj-$(CONFIG_RTC_DRV_GOLDFISH) += rtc-goldfish.o | ||
74 | obj-$(CONFIG_RTC_DRV_HID_SENSOR_TIME) += rtc-hid-sensor-time.o | 75 | obj-$(CONFIG_RTC_DRV_HID_SENSOR_TIME) += rtc-hid-sensor-time.o |
75 | obj-$(CONFIG_RTC_DRV_HYM8563) += rtc-hym8563.o | 76 | obj-$(CONFIG_RTC_DRV_HYM8563) += rtc-hym8563.o |
76 | obj-$(CONFIG_RTC_DRV_IMXDI) += rtc-imxdi.o | 77 | obj-$(CONFIG_RTC_DRV_IMXDI) += rtc-imxdi.o |
@@ -78,10 +79,10 @@ obj-$(CONFIG_RTC_DRV_ISL12022) += rtc-isl12022.o | |||
78 | obj-$(CONFIG_RTC_DRV_ISL12026) += rtc-isl12026.o | 79 | obj-$(CONFIG_RTC_DRV_ISL12026) += rtc-isl12026.o |
79 | obj-$(CONFIG_RTC_DRV_ISL1208) += rtc-isl1208.o | 80 | obj-$(CONFIG_RTC_DRV_ISL1208) += rtc-isl1208.o |
80 | obj-$(CONFIG_RTC_DRV_JZ4740) += rtc-jz4740.o | 81 | obj-$(CONFIG_RTC_DRV_JZ4740) += rtc-jz4740.o |
82 | obj-$(CONFIG_RTC_DRV_LOONGSON1) += rtc-ls1x.o | ||
81 | obj-$(CONFIG_RTC_DRV_LP8788) += rtc-lp8788.o | 83 | obj-$(CONFIG_RTC_DRV_LP8788) += rtc-lp8788.o |
82 | obj-$(CONFIG_RTC_DRV_LPC24XX) += rtc-lpc24xx.o | 84 | obj-$(CONFIG_RTC_DRV_LPC24XX) += rtc-lpc24xx.o |
83 | obj-$(CONFIG_RTC_DRV_LPC32XX) += rtc-lpc32xx.o | 85 | obj-$(CONFIG_RTC_DRV_LPC32XX) += rtc-lpc32xx.o |
84 | obj-$(CONFIG_RTC_DRV_LOONGSON1) += rtc-ls1x.o | ||
85 | obj-$(CONFIG_RTC_DRV_M41T80) += rtc-m41t80.o | 86 | obj-$(CONFIG_RTC_DRV_M41T80) += rtc-m41t80.o |
86 | obj-$(CONFIG_RTC_DRV_M41T93) += rtc-m41t93.o | 87 | obj-$(CONFIG_RTC_DRV_M41T93) += rtc-m41t93.o |
87 | obj-$(CONFIG_RTC_DRV_M41T94) += rtc-m41t94.o | 88 | obj-$(CONFIG_RTC_DRV_M41T94) += rtc-m41t94.o |
@@ -100,7 +101,6 @@ obj-$(CONFIG_RTC_DRV_MC13XXX) += rtc-mc13xxx.o | |||
100 | obj-$(CONFIG_RTC_DRV_MCP795) += rtc-mcp795.o | 101 | obj-$(CONFIG_RTC_DRV_MCP795) += rtc-mcp795.o |
101 | obj-$(CONFIG_RTC_DRV_MOXART) += rtc-moxart.o | 102 | obj-$(CONFIG_RTC_DRV_MOXART) += rtc-moxart.o |
102 | obj-$(CONFIG_RTC_DRV_MPC5121) += rtc-mpc5121.o | 103 | obj-$(CONFIG_RTC_DRV_MPC5121) += rtc-mpc5121.o |
103 | obj-$(CONFIG_RTC_DRV_VRTC) += rtc-mrst.o | ||
104 | obj-$(CONFIG_RTC_DRV_MSM6242) += rtc-msm6242.o | 104 | obj-$(CONFIG_RTC_DRV_MSM6242) += rtc-msm6242.o |
105 | obj-$(CONFIG_RTC_DRV_MT6397) += rtc-mt6397.o | 105 | obj-$(CONFIG_RTC_DRV_MT6397) += rtc-mt6397.o |
106 | obj-$(CONFIG_RTC_DRV_MT7622) += rtc-mt7622.o | 106 | obj-$(CONFIG_RTC_DRV_MT7622) += rtc-mt7622.o |
@@ -116,8 +116,8 @@ obj-$(CONFIG_RTC_DRV_PCF2123) += rtc-pcf2123.o | |||
116 | obj-$(CONFIG_RTC_DRV_PCF2127) += rtc-pcf2127.o | 116 | obj-$(CONFIG_RTC_DRV_PCF2127) += rtc-pcf2127.o |
117 | obj-$(CONFIG_RTC_DRV_PCF50633) += rtc-pcf50633.o | 117 | obj-$(CONFIG_RTC_DRV_PCF50633) += rtc-pcf50633.o |
118 | obj-$(CONFIG_RTC_DRV_PCF85063) += rtc-pcf85063.o | 118 | obj-$(CONFIG_RTC_DRV_PCF85063) += rtc-pcf85063.o |
119 | obj-$(CONFIG_RTC_DRV_PCF85363) += rtc-pcf85363.o | ||
120 | obj-$(CONFIG_RTC_DRV_PCF8523) += rtc-pcf8523.o | 119 | obj-$(CONFIG_RTC_DRV_PCF8523) += rtc-pcf8523.o |
120 | obj-$(CONFIG_RTC_DRV_PCF85363) += rtc-pcf85363.o | ||
121 | obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o | 121 | obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o |
122 | obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o | 122 | obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o |
123 | obj-$(CONFIG_RTC_DRV_PIC32) += rtc-pic32.o | 123 | obj-$(CONFIG_RTC_DRV_PIC32) += rtc-pic32.o |
@@ -154,9 +154,9 @@ obj-$(CONFIG_RTC_DRV_SNVS) += rtc-snvs.o | |||
154 | obj-$(CONFIG_RTC_DRV_SPEAR) += rtc-spear.o | 154 | obj-$(CONFIG_RTC_DRV_SPEAR) += rtc-spear.o |
155 | obj-$(CONFIG_RTC_DRV_STARFIRE) += rtc-starfire.o | 155 | obj-$(CONFIG_RTC_DRV_STARFIRE) += rtc-starfire.o |
156 | obj-$(CONFIG_RTC_DRV_STK17TA8) += rtc-stk17ta8.o | 156 | obj-$(CONFIG_RTC_DRV_STK17TA8) += rtc-stk17ta8.o |
157 | obj-$(CONFIG_RTC_DRV_ST_LPC) += rtc-st-lpc.o | ||
157 | obj-$(CONFIG_RTC_DRV_STM32) += rtc-stm32.o | 158 | obj-$(CONFIG_RTC_DRV_STM32) += rtc-stm32.o |
158 | obj-$(CONFIG_RTC_DRV_STMP) += rtc-stmp3xxx.o | 159 | obj-$(CONFIG_RTC_DRV_STMP) += rtc-stmp3xxx.o |
159 | obj-$(CONFIG_RTC_DRV_ST_LPC) += rtc-st-lpc.o | ||
160 | obj-$(CONFIG_RTC_DRV_SUN4V) += rtc-sun4v.o | 160 | obj-$(CONFIG_RTC_DRV_SUN4V) += rtc-sun4v.o |
161 | obj-$(CONFIG_RTC_DRV_SUN6I) += rtc-sun6i.o | 161 | obj-$(CONFIG_RTC_DRV_SUN6I) += rtc-sun6i.o |
162 | obj-$(CONFIG_RTC_DRV_SUNXI) += rtc-sunxi.o | 162 | obj-$(CONFIG_RTC_DRV_SUNXI) += rtc-sunxi.o |
@@ -169,10 +169,10 @@ obj-$(CONFIG_RTC_DRV_TWL4030) += rtc-twl.o | |||
169 | obj-$(CONFIG_RTC_DRV_TX4939) += rtc-tx4939.o | 169 | obj-$(CONFIG_RTC_DRV_TX4939) += rtc-tx4939.o |
170 | obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o | 170 | obj-$(CONFIG_RTC_DRV_V3020) += rtc-v3020.o |
171 | obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o | 171 | obj-$(CONFIG_RTC_DRV_VR41XX) += rtc-vr41xx.o |
172 | obj-$(CONFIG_RTC_DRV_VRTC) += rtc-mrst.o | ||
172 | obj-$(CONFIG_RTC_DRV_VT8500) += rtc-vt8500.o | 173 | obj-$(CONFIG_RTC_DRV_VT8500) += rtc-vt8500.o |
173 | obj-$(CONFIG_RTC_DRV_WM831X) += rtc-wm831x.o | 174 | obj-$(CONFIG_RTC_DRV_WM831X) += rtc-wm831x.o |
174 | obj-$(CONFIG_RTC_DRV_WM8350) += rtc-wm8350.o | 175 | obj-$(CONFIG_RTC_DRV_WM8350) += rtc-wm8350.o |
175 | obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o | 176 | obj-$(CONFIG_RTC_DRV_X1205) += rtc-x1205.o |
176 | obj-$(CONFIG_RTC_DRV_XGENE) += rtc-xgene.o | 177 | obj-$(CONFIG_RTC_DRV_XGENE) += rtc-xgene.o |
177 | obj-$(CONFIG_RTC_DRV_ZYNQMP) += rtc-zynqmp.o | 178 | obj-$(CONFIG_RTC_DRV_ZYNQMP) += rtc-zynqmp.o |
178 | obj-$(CONFIG_RTC_DRV_GOLDFISH) += rtc-goldfish.o | ||
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index 0fca4d74c76b..3b43787f154b 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c | |||
@@ -286,9 +286,10 @@ static void rtc_device_get_offset(struct rtc_device *rtc) | |||
286 | * | 286 | * |
287 | * Returns the pointer to the new struct class device. | 287 | * Returns the pointer to the new struct class device. |
288 | */ | 288 | */ |
289 | struct rtc_device *rtc_device_register(const char *name, struct device *dev, | 289 | static struct rtc_device *rtc_device_register(const char *name, |
290 | const struct rtc_class_ops *ops, | 290 | struct device *dev, |
291 | struct module *owner) | 291 | const struct rtc_class_ops *ops, |
292 | struct module *owner) | ||
292 | { | 293 | { |
293 | struct rtc_device *rtc; | 294 | struct rtc_device *rtc; |
294 | struct rtc_wkalrm alrm; | 295 | struct rtc_wkalrm alrm; |
@@ -351,15 +352,13 @@ exit: | |||
351 | name, err); | 352 | name, err); |
352 | return ERR_PTR(err); | 353 | return ERR_PTR(err); |
353 | } | 354 | } |
354 | EXPORT_SYMBOL_GPL(rtc_device_register); | ||
355 | |||
356 | 355 | ||
357 | /** | 356 | /** |
358 | * rtc_device_unregister - removes the previously registered RTC class device | 357 | * rtc_device_unregister - removes the previously registered RTC class device |
359 | * | 358 | * |
360 | * @rtc: the RTC class device to destroy | 359 | * @rtc: the RTC class device to destroy |
361 | */ | 360 | */ |
362 | void rtc_device_unregister(struct rtc_device *rtc) | 361 | static void rtc_device_unregister(struct rtc_device *rtc) |
363 | { | 362 | { |
364 | mutex_lock(&rtc->ops_lock); | 363 | mutex_lock(&rtc->ops_lock); |
365 | /* | 364 | /* |
@@ -372,7 +371,6 @@ void rtc_device_unregister(struct rtc_device *rtc) | |||
372 | mutex_unlock(&rtc->ops_lock); | 371 | mutex_unlock(&rtc->ops_lock); |
373 | put_device(&rtc->dev); | 372 | put_device(&rtc->dev); |
374 | } | 373 | } |
375 | EXPORT_SYMBOL_GPL(rtc_device_unregister); | ||
376 | 374 | ||
377 | static void devm_rtc_device_release(struct device *dev, void *res) | 375 | static void devm_rtc_device_release(struct device *dev, void *res) |
378 | { | 376 | { |
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index 3d577e259e91..612a83d3ddcc 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c | |||
@@ -596,7 +596,6 @@ EXPORT_SYMBOL_GPL(rtc_update_irq_enable); | |||
596 | * This function is called when an AIE, UIE or PIE mode interrupt | 596 | * This function is called when an AIE, UIE or PIE mode interrupt |
597 | * has occurred (or been emulated). | 597 | * has occurred (or been emulated). |
598 | * | 598 | * |
599 | * Triggers the registered irq_task function callback. | ||
600 | */ | 599 | */ |
601 | void rtc_handle_legacy_irq(struct rtc_device *rtc, int num, int mode) | 600 | void rtc_handle_legacy_irq(struct rtc_device *rtc, int num, int mode) |
602 | { | 601 | { |
@@ -741,7 +740,6 @@ static int rtc_update_hrtimer(struct rtc_device *rtc, int enabled) | |||
741 | /** | 740 | /** |
742 | * rtc_irq_set_state - enable/disable 2^N Hz periodic IRQs | 741 | * rtc_irq_set_state - enable/disable 2^N Hz periodic IRQs |
743 | * @rtc: the rtc device | 742 | * @rtc: the rtc device |
744 | * @task: currently registered with rtc_irq_register() | ||
745 | * @enabled: true to enable periodic IRQs | 743 | * @enabled: true to enable periodic IRQs |
746 | * Context: any | 744 | * Context: any |
747 | * | 745 | * |
@@ -764,7 +762,6 @@ int rtc_irq_set_state(struct rtc_device *rtc, int enabled) | |||
764 | /** | 762 | /** |
765 | * rtc_irq_set_freq - set 2^N Hz periodic IRQ frequency for IRQ | 763 | * rtc_irq_set_freq - set 2^N Hz periodic IRQ frequency for IRQ |
766 | * @rtc: the rtc device | 764 | * @rtc: the rtc device |
767 | * @task: currently registered with rtc_irq_register() | ||
768 | * @freq: positive frequency | 765 | * @freq: positive frequency |
769 | * Context: any | 766 | * Context: any |
770 | * | 767 | * |
diff --git a/drivers/rtc/rtc-ab8500.c b/drivers/rtc/rtc-ab8500.c index e28f4401fd35..1f0cbd51ba06 100644 --- a/drivers/rtc/rtc-ab8500.c +++ b/drivers/rtc/rtc-ab8500.c | |||
@@ -46,7 +46,6 @@ | |||
46 | #define RTC_STATUS_DATA 0x01 | 46 | #define RTC_STATUS_DATA 0x01 |
47 | 47 | ||
48 | #define COUNTS_PER_SEC (0xF000 / 60) | 48 | #define COUNTS_PER_SEC (0xF000 / 60) |
49 | #define AB8500_RTC_EPOCH 2000 | ||
50 | 49 | ||
51 | static const u8 ab8500_rtc_time_regs[] = { | 50 | static const u8 ab8500_rtc_time_regs[] = { |
52 | AB8500_RTC_WATCH_TMIN_HI_REG, AB8500_RTC_WATCH_TMIN_MID_REG, | 51 | AB8500_RTC_WATCH_TMIN_HI_REG, AB8500_RTC_WATCH_TMIN_MID_REG, |
@@ -59,23 +58,6 @@ static const u8 ab8500_rtc_alarm_regs[] = { | |||
59 | AB8500_RTC_ALRM_MIN_LOW_REG | 58 | AB8500_RTC_ALRM_MIN_LOW_REG |
60 | }; | 59 | }; |
61 | 60 | ||
62 | /* Calculate the seconds from 1970 to 01-01-2000 00:00:00 */ | ||
63 | static unsigned long get_elapsed_seconds(int year) | ||
64 | { | ||
65 | unsigned long secs; | ||
66 | struct rtc_time tm = { | ||
67 | .tm_year = year - 1900, | ||
68 | .tm_mday = 1, | ||
69 | }; | ||
70 | |||
71 | /* | ||
72 | * This function calculates secs from 1970 and not from | ||
73 | * 1900, even if we supply the offset from year 1900. | ||
74 | */ | ||
75 | rtc_tm_to_time(&tm, &secs); | ||
76 | return secs; | ||
77 | } | ||
78 | |||
79 | static int ab8500_rtc_read_time(struct device *dev, struct rtc_time *tm) | 61 | static int ab8500_rtc_read_time(struct device *dev, struct rtc_time *tm) |
80 | { | 62 | { |
81 | unsigned long timeout = jiffies + HZ; | 63 | unsigned long timeout = jiffies + HZ; |
@@ -118,9 +100,6 @@ static int ab8500_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
118 | secs = secs / COUNTS_PER_SEC; | 100 | secs = secs / COUNTS_PER_SEC; |
119 | secs = secs + (mins * 60); | 101 | secs = secs + (mins * 60); |
120 | 102 | ||
121 | /* Add back the initially subtracted number of seconds */ | ||
122 | secs += get_elapsed_seconds(AB8500_RTC_EPOCH); | ||
123 | |||
124 | rtc_time_to_tm(secs, tm); | 103 | rtc_time_to_tm(secs, tm); |
125 | return 0; | 104 | return 0; |
126 | } | 105 | } |
@@ -131,21 +110,8 @@ static int ab8500_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
131 | unsigned char buf[ARRAY_SIZE(ab8500_rtc_time_regs)]; | 110 | unsigned char buf[ARRAY_SIZE(ab8500_rtc_time_regs)]; |
132 | unsigned long no_secs, no_mins, secs = 0; | 111 | unsigned long no_secs, no_mins, secs = 0; |
133 | 112 | ||
134 | if (tm->tm_year < (AB8500_RTC_EPOCH - 1900)) { | ||
135 | dev_dbg(dev, "year should be equal to or greater than %d\n", | ||
136 | AB8500_RTC_EPOCH); | ||
137 | return -EINVAL; | ||
138 | } | ||
139 | |||
140 | /* Get the number of seconds since 1970 */ | ||
141 | rtc_tm_to_time(tm, &secs); | 113 | rtc_tm_to_time(tm, &secs); |
142 | 114 | ||
143 | /* | ||
144 | * Convert it to the number of seconds since 01-01-2000 00:00:00, since | ||
145 | * we only have a small counter in the RTC. | ||
146 | */ | ||
147 | secs -= get_elapsed_seconds(AB8500_RTC_EPOCH); | ||
148 | |||
149 | no_mins = secs / 60; | 115 | no_mins = secs / 60; |
150 | 116 | ||
151 | no_secs = secs % 60; | 117 | no_secs = secs % 60; |
@@ -202,12 +168,9 @@ static int ab8500_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) | |||
202 | mins = (buf[0] << 16) | (buf[1] << 8) | (buf[2]); | 168 | mins = (buf[0] << 16) | (buf[1] << 8) | (buf[2]); |
203 | secs = mins * 60; | 169 | secs = mins * 60; |
204 | 170 | ||
205 | /* Add back the initially subtracted number of seconds */ | ||
206 | secs += get_elapsed_seconds(AB8500_RTC_EPOCH); | ||
207 | |||
208 | rtc_time_to_tm(secs, &alarm->time); | 171 | rtc_time_to_tm(secs, &alarm->time); |
209 | 172 | ||
210 | return rtc_valid_tm(&alarm->time); | 173 | return 0; |
211 | } | 174 | } |
212 | 175 | ||
213 | static int ab8500_rtc_irq_enable(struct device *dev, unsigned int enabled) | 176 | static int ab8500_rtc_irq_enable(struct device *dev, unsigned int enabled) |
@@ -224,12 +187,6 @@ static int ab8500_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) | |||
224 | unsigned long mins, secs = 0, cursec = 0; | 187 | unsigned long mins, secs = 0, cursec = 0; |
225 | struct rtc_time curtm; | 188 | struct rtc_time curtm; |
226 | 189 | ||
227 | if (alarm->time.tm_year < (AB8500_RTC_EPOCH - 1900)) { | ||
228 | dev_dbg(dev, "year should be equal to or greater than %d\n", | ||
229 | AB8500_RTC_EPOCH); | ||
230 | return -EINVAL; | ||
231 | } | ||
232 | |||
233 | /* Get the number of seconds since 1970 */ | 190 | /* Get the number of seconds since 1970 */ |
234 | rtc_tm_to_time(&alarm->time, &secs); | 191 | rtc_tm_to_time(&alarm->time, &secs); |
235 | 192 | ||
@@ -245,12 +202,6 @@ static int ab8500_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) | |||
245 | return -EINVAL; | 202 | return -EINVAL; |
246 | } | 203 | } |
247 | 204 | ||
248 | /* | ||
249 | * Convert it to the number of seconds since 01-01-2000 00:00:00, since | ||
250 | * we only have a small counter in the RTC. | ||
251 | */ | ||
252 | secs -= get_elapsed_seconds(AB8500_RTC_EPOCH); | ||
253 | |||
254 | mins = secs / 60; | 205 | mins = secs / 60; |
255 | 206 | ||
256 | buf[2] = mins & 0xFF; | 207 | buf[2] = mins & 0xFF; |
@@ -360,15 +311,14 @@ static DEVICE_ATTR(rtc_calibration, S_IRUGO | S_IWUSR, | |||
360 | ab8500_sysfs_show_rtc_calibration, | 311 | ab8500_sysfs_show_rtc_calibration, |
361 | ab8500_sysfs_store_rtc_calibration); | 312 | ab8500_sysfs_store_rtc_calibration); |
362 | 313 | ||
363 | static int ab8500_sysfs_rtc_register(struct device *dev) | 314 | static struct attribute *ab8500_rtc_attrs[] = { |
364 | { | 315 | &dev_attr_rtc_calibration.attr, |
365 | return device_create_file(dev, &dev_attr_rtc_calibration); | 316 | NULL |
366 | } | 317 | }; |
367 | 318 | ||
368 | static void ab8500_sysfs_rtc_unregister(struct device *dev) | 319 | static const struct attribute_group ab8500_rtc_sysfs_files = { |
369 | { | 320 | .attrs = ab8500_rtc_attrs, |
370 | device_remove_file(dev, &dev_attr_rtc_calibration); | 321 | }; |
371 | } | ||
372 | 322 | ||
373 | static irqreturn_t rtc_alarm_handler(int irq, void *data) | 323 | static irqreturn_t rtc_alarm_handler(int irq, void *data) |
374 | { | 324 | { |
@@ -429,14 +379,11 @@ static int ab8500_rtc_probe(struct platform_device *pdev) | |||
429 | 379 | ||
430 | device_init_wakeup(&pdev->dev, true); | 380 | device_init_wakeup(&pdev->dev, true); |
431 | 381 | ||
432 | rtc = devm_rtc_device_register(&pdev->dev, "ab8500-rtc", | 382 | rtc = devm_rtc_allocate_device(&pdev->dev); |
433 | (struct rtc_class_ops *)platid->driver_data, | 383 | if (IS_ERR(rtc)) |
434 | THIS_MODULE); | 384 | return PTR_ERR(rtc); |
435 | if (IS_ERR(rtc)) { | 385 | |
436 | dev_err(&pdev->dev, "Registration failed\n"); | 386 | rtc->ops = (struct rtc_class_ops *)platid->driver_data; |
437 | err = PTR_ERR(rtc); | ||
438 | return err; | ||
439 | } | ||
440 | 387 | ||
441 | err = devm_request_threaded_irq(&pdev->dev, irq, NULL, | 388 | err = devm_request_threaded_irq(&pdev->dev, irq, NULL, |
442 | rtc_alarm_handler, IRQF_ONESHOT, | 389 | rtc_alarm_handler, IRQF_ONESHOT, |
@@ -447,22 +394,23 @@ static int ab8500_rtc_probe(struct platform_device *pdev) | |||
447 | dev_pm_set_wake_irq(&pdev->dev, irq); | 394 | dev_pm_set_wake_irq(&pdev->dev, irq); |
448 | platform_set_drvdata(pdev, rtc); | 395 | platform_set_drvdata(pdev, rtc); |
449 | 396 | ||
450 | err = ab8500_sysfs_rtc_register(&pdev->dev); | ||
451 | if (err) { | ||
452 | dev_err(&pdev->dev, "sysfs RTC failed to register\n"); | ||
453 | return err; | ||
454 | } | ||
455 | |||
456 | rtc->uie_unsupported = 1; | 397 | rtc->uie_unsupported = 1; |
457 | 398 | ||
458 | return 0; | 399 | rtc->range_max = (1ULL << 24) * 60 - 1; // 24-bit minutes + 59 secs |
400 | rtc->start_secs = RTC_TIMESTAMP_BEGIN_2000; | ||
401 | rtc->set_start_time = true; | ||
402 | |||
403 | err = rtc_add_group(rtc, &ab8500_rtc_sysfs_files); | ||
404 | if (err) | ||
405 | return err; | ||
406 | |||
407 | return rtc_register_device(rtc); | ||
459 | } | 408 | } |
460 | 409 | ||
461 | static int ab8500_rtc_remove(struct platform_device *pdev) | 410 | static int ab8500_rtc_remove(struct platform_device *pdev) |
462 | { | 411 | { |
463 | dev_pm_clear_wake_irq(&pdev->dev); | 412 | dev_pm_clear_wake_irq(&pdev->dev); |
464 | device_init_wakeup(&pdev->dev, false); | 413 | device_init_wakeup(&pdev->dev, false); |
465 | ab8500_sysfs_rtc_unregister(&pdev->dev); | ||
466 | 414 | ||
467 | return 0; | 415 | return 0; |
468 | } | 416 | } |
diff --git a/drivers/rtc/rtc-abx80x.c b/drivers/rtc/rtc-abx80x.c index 2cefa67a1132..d8e94edcb0ba 100644 --- a/drivers/rtc/rtc-abx80x.c +++ b/drivers/rtc/rtc-abx80x.c | |||
@@ -17,6 +17,7 @@ | |||
17 | #include <linux/i2c.h> | 17 | #include <linux/i2c.h> |
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/rtc.h> | 19 | #include <linux/rtc.h> |
20 | #include <linux/watchdog.h> | ||
20 | 21 | ||
21 | #define ABX8XX_REG_HTH 0x00 | 22 | #define ABX8XX_REG_HTH 0x00 |
22 | #define ABX8XX_REG_SC 0x01 | 23 | #define ABX8XX_REG_SC 0x01 |
@@ -37,6 +38,7 @@ | |||
37 | 38 | ||
38 | #define ABX8XX_REG_STATUS 0x0f | 39 | #define ABX8XX_REG_STATUS 0x0f |
39 | #define ABX8XX_STATUS_AF BIT(2) | 40 | #define ABX8XX_STATUS_AF BIT(2) |
41 | #define ABX8XX_STATUS_WDT BIT(6) | ||
40 | 42 | ||
41 | #define ABX8XX_REG_CTRL1 0x10 | 43 | #define ABX8XX_REG_CTRL1 0x10 |
42 | #define ABX8XX_CTRL_WRITE BIT(0) | 44 | #define ABX8XX_CTRL_WRITE BIT(0) |
@@ -61,6 +63,14 @@ | |||
61 | #define ABX8XX_OSS_OF BIT(1) | 63 | #define ABX8XX_OSS_OF BIT(1) |
62 | #define ABX8XX_OSS_OMODE BIT(4) | 64 | #define ABX8XX_OSS_OMODE BIT(4) |
63 | 65 | ||
66 | #define ABX8XX_REG_WDT 0x1b | ||
67 | #define ABX8XX_WDT_WDS BIT(7) | ||
68 | #define ABX8XX_WDT_BMB_MASK 0x7c | ||
69 | #define ABX8XX_WDT_BMB_SHIFT 2 | ||
70 | #define ABX8XX_WDT_MAX_TIME (ABX8XX_WDT_BMB_MASK >> ABX8XX_WDT_BMB_SHIFT) | ||
71 | #define ABX8XX_WDT_WRB_MASK 0x03 | ||
72 | #define ABX8XX_WDT_WRB_1HZ 0x02 | ||
73 | |||
64 | #define ABX8XX_REG_CFG_KEY 0x1f | 74 | #define ABX8XX_REG_CFG_KEY 0x1f |
65 | #define ABX8XX_CFG_KEY_OSC 0xa1 | 75 | #define ABX8XX_CFG_KEY_OSC 0xa1 |
66 | #define ABX8XX_CFG_KEY_MISC 0x9d | 76 | #define ABX8XX_CFG_KEY_MISC 0x9d |
@@ -80,20 +90,27 @@ enum abx80x_chip {AB0801, AB0803, AB0804, AB0805, | |||
80 | struct abx80x_cap { | 90 | struct abx80x_cap { |
81 | u16 pn; | 91 | u16 pn; |
82 | bool has_tc; | 92 | bool has_tc; |
93 | bool has_wdog; | ||
83 | }; | 94 | }; |
84 | 95 | ||
85 | static struct abx80x_cap abx80x_caps[] = { | 96 | static struct abx80x_cap abx80x_caps[] = { |
86 | [AB0801] = {.pn = 0x0801}, | 97 | [AB0801] = {.pn = 0x0801}, |
87 | [AB0803] = {.pn = 0x0803}, | 98 | [AB0803] = {.pn = 0x0803}, |
88 | [AB0804] = {.pn = 0x0804, .has_tc = true}, | 99 | [AB0804] = {.pn = 0x0804, .has_tc = true, .has_wdog = true}, |
89 | [AB0805] = {.pn = 0x0805, .has_tc = true}, | 100 | [AB0805] = {.pn = 0x0805, .has_tc = true, .has_wdog = true}, |
90 | [AB1801] = {.pn = 0x1801}, | 101 | [AB1801] = {.pn = 0x1801}, |
91 | [AB1803] = {.pn = 0x1803}, | 102 | [AB1803] = {.pn = 0x1803}, |
92 | [AB1804] = {.pn = 0x1804, .has_tc = true}, | 103 | [AB1804] = {.pn = 0x1804, .has_tc = true, .has_wdog = true}, |
93 | [AB1805] = {.pn = 0x1805, .has_tc = true}, | 104 | [AB1805] = {.pn = 0x1805, .has_tc = true, .has_wdog = true}, |
94 | [ABX80X] = {.pn = 0} | 105 | [ABX80X] = {.pn = 0} |
95 | }; | 106 | }; |
96 | 107 | ||
108 | struct abx80x_priv { | ||
109 | struct rtc_device *rtc; | ||
110 | struct i2c_client *client; | ||
111 | struct watchdog_device wdog; | ||
112 | }; | ||
113 | |||
97 | static int abx80x_is_rc_mode(struct i2c_client *client) | 114 | static int abx80x_is_rc_mode(struct i2c_client *client) |
98 | { | 115 | { |
99 | int flags = 0; | 116 | int flags = 0; |
@@ -218,7 +235,8 @@ static int abx80x_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
218 | static irqreturn_t abx80x_handle_irq(int irq, void *dev_id) | 235 | static irqreturn_t abx80x_handle_irq(int irq, void *dev_id) |
219 | { | 236 | { |
220 | struct i2c_client *client = dev_id; | 237 | struct i2c_client *client = dev_id; |
221 | struct rtc_device *rtc = i2c_get_clientdata(client); | 238 | struct abx80x_priv *priv = i2c_get_clientdata(client); |
239 | struct rtc_device *rtc = priv->rtc; | ||
222 | int status; | 240 | int status; |
223 | 241 | ||
224 | status = i2c_smbus_read_byte_data(client, ABX8XX_REG_STATUS); | 242 | status = i2c_smbus_read_byte_data(client, ABX8XX_REG_STATUS); |
@@ -228,6 +246,13 @@ static irqreturn_t abx80x_handle_irq(int irq, void *dev_id) | |||
228 | if (status & ABX8XX_STATUS_AF) | 246 | if (status & ABX8XX_STATUS_AF) |
229 | rtc_update_irq(rtc, 1, RTC_AF | RTC_IRQF); | 247 | rtc_update_irq(rtc, 1, RTC_AF | RTC_IRQF); |
230 | 248 | ||
249 | /* | ||
250 | * It is unclear if we'll get an interrupt before the external | ||
251 | * reset kicks in. | ||
252 | */ | ||
253 | if (status & ABX8XX_STATUS_WDT) | ||
254 | dev_alert(&client->dev, "watchdog timeout interrupt.\n"); | ||
255 | |||
231 | i2c_smbus_write_byte_data(client, ABX8XX_REG_STATUS, 0); | 256 | i2c_smbus_write_byte_data(client, ABX8XX_REG_STATUS, 0); |
232 | 257 | ||
233 | return IRQ_HANDLED; | 258 | return IRQ_HANDLED; |
@@ -529,11 +554,94 @@ static void rtc_calib_remove_sysfs_group(void *_dev) | |||
529 | sysfs_remove_group(&dev->kobj, &rtc_calib_attr_group); | 554 | sysfs_remove_group(&dev->kobj, &rtc_calib_attr_group); |
530 | } | 555 | } |
531 | 556 | ||
557 | #ifdef CONFIG_WATCHDOG | ||
558 | |||
559 | static inline u8 timeout_bits(unsigned int timeout) | ||
560 | { | ||
561 | return ((timeout << ABX8XX_WDT_BMB_SHIFT) & ABX8XX_WDT_BMB_MASK) | | ||
562 | ABX8XX_WDT_WRB_1HZ; | ||
563 | } | ||
564 | |||
565 | static int __abx80x_wdog_set_timeout(struct watchdog_device *wdog, | ||
566 | unsigned int timeout) | ||
567 | { | ||
568 | struct abx80x_priv *priv = watchdog_get_drvdata(wdog); | ||
569 | u8 val = ABX8XX_WDT_WDS | timeout_bits(timeout); | ||
570 | |||
571 | /* | ||
572 | * Writing any timeout to the WDT register resets the watchdog timer. | ||
573 | * Writing 0 disables it. | ||
574 | */ | ||
575 | return i2c_smbus_write_byte_data(priv->client, ABX8XX_REG_WDT, val); | ||
576 | } | ||
577 | |||
578 | static int abx80x_wdog_set_timeout(struct watchdog_device *wdog, | ||
579 | unsigned int new_timeout) | ||
580 | { | ||
581 | int err = 0; | ||
582 | |||
583 | if (watchdog_hw_running(wdog)) | ||
584 | err = __abx80x_wdog_set_timeout(wdog, new_timeout); | ||
585 | |||
586 | if (err == 0) | ||
587 | wdog->timeout = new_timeout; | ||
588 | |||
589 | return err; | ||
590 | } | ||
591 | |||
592 | static int abx80x_wdog_ping(struct watchdog_device *wdog) | ||
593 | { | ||
594 | return __abx80x_wdog_set_timeout(wdog, wdog->timeout); | ||
595 | } | ||
596 | |||
597 | static int abx80x_wdog_start(struct watchdog_device *wdog) | ||
598 | { | ||
599 | return __abx80x_wdog_set_timeout(wdog, wdog->timeout); | ||
600 | } | ||
601 | |||
602 | static int abx80x_wdog_stop(struct watchdog_device *wdog) | ||
603 | { | ||
604 | return __abx80x_wdog_set_timeout(wdog, 0); | ||
605 | } | ||
606 | |||
607 | static const struct watchdog_info abx80x_wdog_info = { | ||
608 | .identity = "abx80x watchdog", | ||
609 | .options = WDIOF_KEEPALIVEPING | WDIOF_SETTIMEOUT | WDIOF_MAGICCLOSE, | ||
610 | }; | ||
611 | |||
612 | static const struct watchdog_ops abx80x_wdog_ops = { | ||
613 | .owner = THIS_MODULE, | ||
614 | .start = abx80x_wdog_start, | ||
615 | .stop = abx80x_wdog_stop, | ||
616 | .ping = abx80x_wdog_ping, | ||
617 | .set_timeout = abx80x_wdog_set_timeout, | ||
618 | }; | ||
619 | |||
620 | static int abx80x_setup_watchdog(struct abx80x_priv *priv) | ||
621 | { | ||
622 | priv->wdog.parent = &priv->client->dev; | ||
623 | priv->wdog.ops = &abx80x_wdog_ops; | ||
624 | priv->wdog.info = &abx80x_wdog_info; | ||
625 | priv->wdog.min_timeout = 1; | ||
626 | priv->wdog.max_timeout = ABX8XX_WDT_MAX_TIME; | ||
627 | priv->wdog.timeout = ABX8XX_WDT_MAX_TIME; | ||
628 | |||
629 | watchdog_set_drvdata(&priv->wdog, priv); | ||
630 | |||
631 | return devm_watchdog_register_device(&priv->client->dev, &priv->wdog); | ||
632 | } | ||
633 | #else | ||
634 | static int abx80x_setup_watchdog(struct abx80x_priv *priv) | ||
635 | { | ||
636 | return 0; | ||
637 | } | ||
638 | #endif | ||
639 | |||
532 | static int abx80x_probe(struct i2c_client *client, | 640 | static int abx80x_probe(struct i2c_client *client, |
533 | const struct i2c_device_id *id) | 641 | const struct i2c_device_id *id) |
534 | { | 642 | { |
535 | struct device_node *np = client->dev.of_node; | 643 | struct device_node *np = client->dev.of_node; |
536 | struct rtc_device *rtc; | 644 | struct abx80x_priv *priv; |
537 | int i, data, err, trickle_cfg = -EINVAL; | 645 | int i, data, err, trickle_cfg = -EINVAL; |
538 | char buf[7]; | 646 | char buf[7]; |
539 | unsigned int part = id->driver_data; | 647 | unsigned int part = id->driver_data; |
@@ -610,13 +718,24 @@ static int abx80x_probe(struct i2c_client *client, | |||
610 | if (err) | 718 | if (err) |
611 | return err; | 719 | return err; |
612 | 720 | ||
613 | rtc = devm_rtc_allocate_device(&client->dev); | 721 | priv = devm_kzalloc(&client->dev, sizeof(*priv), GFP_KERNEL); |
614 | if (IS_ERR(rtc)) | 722 | if (priv == NULL) |
615 | return PTR_ERR(rtc); | 723 | return -ENOMEM; |
724 | |||
725 | priv->rtc = devm_rtc_allocate_device(&client->dev); | ||
726 | if (IS_ERR(priv->rtc)) | ||
727 | return PTR_ERR(priv->rtc); | ||
728 | |||
729 | priv->rtc->ops = &abx80x_rtc_ops; | ||
730 | priv->client = client; | ||
616 | 731 | ||
617 | rtc->ops = &abx80x_rtc_ops; | 732 | i2c_set_clientdata(client, priv); |
618 | 733 | ||
619 | i2c_set_clientdata(client, rtc); | 734 | if (abx80x_caps[part].has_wdog) { |
735 | err = abx80x_setup_watchdog(priv); | ||
736 | if (err) | ||
737 | return err; | ||
738 | } | ||
620 | 739 | ||
621 | if (client->irq > 0) { | 740 | if (client->irq > 0) { |
622 | dev_info(&client->dev, "IRQ %d supplied\n", client->irq); | 741 | dev_info(&client->dev, "IRQ %d supplied\n", client->irq); |
@@ -649,7 +768,7 @@ static int abx80x_probe(struct i2c_client *client, | |||
649 | return err; | 768 | return err; |
650 | } | 769 | } |
651 | 770 | ||
652 | err = rtc_register_device(rtc); | 771 | err = rtc_register_device(priv->rtc); |
653 | 772 | ||
654 | return err; | 773 | return err; |
655 | } | 774 | } |
diff --git a/drivers/rtc/rtc-armada38x.c b/drivers/rtc/rtc-armada38x.c index bde53c8ccee2..9e78f004670b 100644 --- a/drivers/rtc/rtc-armada38x.c +++ b/drivers/rtc/rtc-armada38x.c | |||
@@ -224,7 +224,7 @@ static int armada38x_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
224 | time = rtc->data->read_rtc_reg(rtc, RTC_TIME); | 224 | time = rtc->data->read_rtc_reg(rtc, RTC_TIME); |
225 | spin_unlock_irqrestore(&rtc->lock, flags); | 225 | spin_unlock_irqrestore(&rtc->lock, flags); |
226 | 226 | ||
227 | rtc_time_to_tm(time, tm); | 227 | rtc_time64_to_tm(time, tm); |
228 | 228 | ||
229 | return 0; | 229 | return 0; |
230 | } | 230 | } |
@@ -249,13 +249,9 @@ static void armada38x_rtc_reset(struct armada38x_rtc *rtc) | |||
249 | static int armada38x_rtc_set_time(struct device *dev, struct rtc_time *tm) | 249 | static int armada38x_rtc_set_time(struct device *dev, struct rtc_time *tm) |
250 | { | 250 | { |
251 | struct armada38x_rtc *rtc = dev_get_drvdata(dev); | 251 | struct armada38x_rtc *rtc = dev_get_drvdata(dev); |
252 | int ret = 0; | ||
253 | unsigned long time, flags; | 252 | unsigned long time, flags; |
254 | 253 | ||
255 | ret = rtc_tm_to_time(tm, &time); | 254 | time = rtc_tm_to_time64(tm); |
256 | |||
257 | if (ret) | ||
258 | goto out; | ||
259 | 255 | ||
260 | if (!rtc->initialized) | 256 | if (!rtc->initialized) |
261 | armada38x_rtc_reset(rtc); | 257 | armada38x_rtc_reset(rtc); |
@@ -264,8 +260,7 @@ static int armada38x_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
264 | rtc_delayed_write(time, rtc, RTC_TIME); | 260 | rtc_delayed_write(time, rtc, RTC_TIME); |
265 | spin_unlock_irqrestore(&rtc->lock, flags); | 261 | spin_unlock_irqrestore(&rtc->lock, flags); |
266 | 262 | ||
267 | out: | 263 | return 0; |
268 | return ret; | ||
269 | } | 264 | } |
270 | 265 | ||
271 | static int armada38x_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | 266 | static int armada38x_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) |
@@ -284,7 +279,7 @@ static int armada38x_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
284 | spin_unlock_irqrestore(&rtc->lock, flags); | 279 | spin_unlock_irqrestore(&rtc->lock, flags); |
285 | 280 | ||
286 | alrm->enabled = val ? 1 : 0; | 281 | alrm->enabled = val ? 1 : 0; |
287 | rtc_time_to_tm(time, &alrm->time); | 282 | rtc_time64_to_tm(time, &alrm->time); |
288 | 283 | ||
289 | return 0; | 284 | return 0; |
290 | } | 285 | } |
@@ -295,12 +290,8 @@ static int armada38x_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
295 | u32 reg = ALARM_REG(RTC_ALARM1, rtc->data->alarm); | 290 | u32 reg = ALARM_REG(RTC_ALARM1, rtc->data->alarm); |
296 | u32 reg_irq = ALARM_REG(RTC_IRQ1_CONF, rtc->data->alarm); | 291 | u32 reg_irq = ALARM_REG(RTC_IRQ1_CONF, rtc->data->alarm); |
297 | unsigned long time, flags; | 292 | unsigned long time, flags; |
298 | int ret = 0; | ||
299 | 293 | ||
300 | ret = rtc_tm_to_time(&alrm->time, &time); | 294 | time = rtc_tm_to_time64(&alrm->time); |
301 | |||
302 | if (ret) | ||
303 | goto out; | ||
304 | 295 | ||
305 | spin_lock_irqsave(&rtc->lock, flags); | 296 | spin_lock_irqsave(&rtc->lock, flags); |
306 | 297 | ||
@@ -313,8 +304,7 @@ static int armada38x_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
313 | 304 | ||
314 | spin_unlock_irqrestore(&rtc->lock, flags); | 305 | spin_unlock_irqrestore(&rtc->lock, flags); |
315 | 306 | ||
316 | out: | 307 | return 0; |
317 | return ret; | ||
318 | } | 308 | } |
319 | 309 | ||
320 | static int armada38x_rtc_alarm_irq_enable(struct device *dev, | 310 | static int armada38x_rtc_alarm_irq_enable(struct device *dev, |
@@ -514,7 +504,6 @@ MODULE_DEVICE_TABLE(of, armada38x_rtc_of_match_table); | |||
514 | 504 | ||
515 | static __init int armada38x_rtc_probe(struct platform_device *pdev) | 505 | static __init int armada38x_rtc_probe(struct platform_device *pdev) |
516 | { | 506 | { |
517 | const struct rtc_class_ops *ops; | ||
518 | struct resource *res; | 507 | struct resource *res; |
519 | struct armada38x_rtc *rtc; | 508 | struct armada38x_rtc *rtc; |
520 | const struct of_device_id *match; | 509 | const struct of_device_id *match; |
@@ -551,6 +540,11 @@ static __init int armada38x_rtc_probe(struct platform_device *pdev) | |||
551 | dev_err(&pdev->dev, "no irq\n"); | 540 | dev_err(&pdev->dev, "no irq\n"); |
552 | return rtc->irq; | 541 | return rtc->irq; |
553 | } | 542 | } |
543 | |||
544 | rtc->rtc_dev = devm_rtc_allocate_device(&pdev->dev); | ||
545 | if (IS_ERR(rtc->rtc_dev)) | ||
546 | return PTR_ERR(rtc->rtc_dev); | ||
547 | |||
554 | if (devm_request_irq(&pdev->dev, rtc->irq, armada38x_rtc_alarm_irq, | 548 | if (devm_request_irq(&pdev->dev, rtc->irq, armada38x_rtc_alarm_irq, |
555 | 0, pdev->name, rtc) < 0) { | 549 | 0, pdev->name, rtc) < 0) { |
556 | dev_warn(&pdev->dev, "Interrupt not available.\n"); | 550 | dev_warn(&pdev->dev, "Interrupt not available.\n"); |
@@ -560,28 +554,26 @@ static __init int armada38x_rtc_probe(struct platform_device *pdev) | |||
560 | 554 | ||
561 | if (rtc->irq != -1) { | 555 | if (rtc->irq != -1) { |
562 | device_init_wakeup(&pdev->dev, 1); | 556 | device_init_wakeup(&pdev->dev, 1); |
563 | ops = &armada38x_rtc_ops; | 557 | rtc->rtc_dev->ops = &armada38x_rtc_ops; |
564 | } else { | 558 | } else { |
565 | /* | 559 | /* |
566 | * If there is no interrupt available then we can't | 560 | * If there is no interrupt available then we can't |
567 | * use the alarm | 561 | * use the alarm |
568 | */ | 562 | */ |
569 | ops = &armada38x_rtc_ops_noirq; | 563 | rtc->rtc_dev->ops = &armada38x_rtc_ops_noirq; |
570 | } | 564 | } |
571 | rtc->data = (struct armada38x_rtc_data *)match->data; | 565 | rtc->data = (struct armada38x_rtc_data *)match->data; |
572 | 566 | ||
573 | |||
574 | /* Update RTC-MBUS bridge timing parameters */ | 567 | /* Update RTC-MBUS bridge timing parameters */ |
575 | rtc->data->update_mbus_timing(rtc); | 568 | rtc->data->update_mbus_timing(rtc); |
576 | 569 | ||
577 | rtc->rtc_dev = devm_rtc_device_register(&pdev->dev, pdev->name, | 570 | rtc->rtc_dev->range_max = U32_MAX; |
578 | ops, THIS_MODULE); | 571 | |
579 | if (IS_ERR(rtc->rtc_dev)) { | 572 | ret = rtc_register_device(rtc->rtc_dev); |
580 | ret = PTR_ERR(rtc->rtc_dev); | 573 | if (ret) |
581 | dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret); | 574 | dev_err(&pdev->dev, "Failed to register RTC device: %d\n", ret); |
582 | return ret; | 575 | |
583 | } | 576 | return ret; |
584 | return 0; | ||
585 | } | 577 | } |
586 | 578 | ||
587 | #ifdef CONFIG_PM_SLEEP | 579 | #ifdef CONFIG_PM_SLEEP |
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index cd3a2411bc2f..df0c5776d49b 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c | |||
@@ -50,6 +50,7 @@ | |||
50 | /* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */ | 50 | /* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */ |
51 | #include <linux/mc146818rtc.h> | 51 | #include <linux/mc146818rtc.h> |
52 | 52 | ||
53 | #ifdef CONFIG_ACPI | ||
53 | /* | 54 | /* |
54 | * Use ACPI SCI to replace HPET interrupt for RTC Alarm event | 55 | * Use ACPI SCI to replace HPET interrupt for RTC Alarm event |
55 | * | 56 | * |
@@ -61,6 +62,18 @@ | |||
61 | static bool use_acpi_alarm; | 62 | static bool use_acpi_alarm; |
62 | module_param(use_acpi_alarm, bool, 0444); | 63 | module_param(use_acpi_alarm, bool, 0444); |
63 | 64 | ||
65 | static inline int cmos_use_acpi_alarm(void) | ||
66 | { | ||
67 | return use_acpi_alarm; | ||
68 | } | ||
69 | #else /* !CONFIG_ACPI */ | ||
70 | |||
71 | static inline int cmos_use_acpi_alarm(void) | ||
72 | { | ||
73 | return 0; | ||
74 | } | ||
75 | #endif | ||
76 | |||
64 | struct cmos_rtc { | 77 | struct cmos_rtc { |
65 | struct rtc_device *rtc; | 78 | struct rtc_device *rtc; |
66 | struct device *dev; | 79 | struct device *dev; |
@@ -167,9 +180,9 @@ static inline int hpet_unregister_irq_handler(irq_handler_t handler) | |||
167 | #endif | 180 | #endif |
168 | 181 | ||
169 | /* Don't use HPET for RTC Alarm event if ACPI Fixed event is used */ | 182 | /* Don't use HPET for RTC Alarm event if ACPI Fixed event is used */ |
170 | static int use_hpet_alarm(void) | 183 | static inline int use_hpet_alarm(void) |
171 | { | 184 | { |
172 | return is_hpet_enabled() && !use_acpi_alarm; | 185 | return is_hpet_enabled() && !cmos_use_acpi_alarm(); |
173 | } | 186 | } |
174 | 187 | ||
175 | /*----------------------------------------------------------------*/ | 188 | /*----------------------------------------------------------------*/ |
@@ -340,7 +353,7 @@ static void cmos_irq_enable(struct cmos_rtc *cmos, unsigned char mask) | |||
340 | if (use_hpet_alarm()) | 353 | if (use_hpet_alarm()) |
341 | hpet_set_rtc_irq_bit(mask); | 354 | hpet_set_rtc_irq_bit(mask); |
342 | 355 | ||
343 | if ((mask & RTC_AIE) && use_acpi_alarm) { | 356 | if ((mask & RTC_AIE) && cmos_use_acpi_alarm()) { |
344 | if (cmos->wake_on) | 357 | if (cmos->wake_on) |
345 | cmos->wake_on(cmos->dev); | 358 | cmos->wake_on(cmos->dev); |
346 | } | 359 | } |
@@ -358,7 +371,7 @@ static void cmos_irq_disable(struct cmos_rtc *cmos, unsigned char mask) | |||
358 | if (use_hpet_alarm()) | 371 | if (use_hpet_alarm()) |
359 | hpet_mask_rtc_irq_bit(mask); | 372 | hpet_mask_rtc_irq_bit(mask); |
360 | 373 | ||
361 | if ((mask & RTC_AIE) && use_acpi_alarm) { | 374 | if ((mask & RTC_AIE) && cmos_use_acpi_alarm()) { |
362 | if (cmos->wake_off) | 375 | if (cmos->wake_off) |
363 | cmos->wake_off(cmos->dev); | 376 | cmos->wake_off(cmos->dev); |
364 | } | 377 | } |
@@ -980,7 +993,7 @@ static int cmos_suspend(struct device *dev) | |||
980 | } | 993 | } |
981 | spin_unlock_irq(&rtc_lock); | 994 | spin_unlock_irq(&rtc_lock); |
982 | 995 | ||
983 | if ((tmp & RTC_AIE) && !use_acpi_alarm) { | 996 | if ((tmp & RTC_AIE) && !cmos_use_acpi_alarm()) { |
984 | cmos->enabled_wake = 1; | 997 | cmos->enabled_wake = 1; |
985 | if (cmos->wake_on) | 998 | if (cmos->wake_on) |
986 | cmos->wake_on(dev); | 999 | cmos->wake_on(dev); |
@@ -1031,7 +1044,7 @@ static void cmos_check_wkalrm(struct device *dev) | |||
1031 | * ACPI RTC wake event is cleared after resume from STR, | 1044 | * ACPI RTC wake event is cleared after resume from STR, |
1032 | * ACK the rtc irq here | 1045 | * ACK the rtc irq here |
1033 | */ | 1046 | */ |
1034 | if (t_now >= cmos->alarm_expires && use_acpi_alarm) { | 1047 | if (t_now >= cmos->alarm_expires && cmos_use_acpi_alarm()) { |
1035 | cmos_interrupt(0, (void *)cmos->rtc); | 1048 | cmos_interrupt(0, (void *)cmos->rtc); |
1036 | return; | 1049 | return; |
1037 | } | 1050 | } |
@@ -1053,7 +1066,7 @@ static int __maybe_unused cmos_resume(struct device *dev) | |||
1053 | struct cmos_rtc *cmos = dev_get_drvdata(dev); | 1066 | struct cmos_rtc *cmos = dev_get_drvdata(dev); |
1054 | unsigned char tmp; | 1067 | unsigned char tmp; |
1055 | 1068 | ||
1056 | if (cmos->enabled_wake && !use_acpi_alarm) { | 1069 | if (cmos->enabled_wake && !cmos_use_acpi_alarm()) { |
1057 | if (cmos->wake_off) | 1070 | if (cmos->wake_off) |
1058 | cmos->wake_off(dev); | 1071 | cmos->wake_off(dev); |
1059 | else | 1072 | else |
@@ -1132,7 +1145,7 @@ static u32 rtc_handler(void *context) | |||
1132 | * Or else, ACPI SCI is enabled during suspend/resume only, | 1145 | * Or else, ACPI SCI is enabled during suspend/resume only, |
1133 | * update rtc irq in that case. | 1146 | * update rtc irq in that case. |
1134 | */ | 1147 | */ |
1135 | if (use_acpi_alarm) | 1148 | if (cmos_use_acpi_alarm()) |
1136 | cmos_interrupt(0, (void *)cmos->rtc); | 1149 | cmos_interrupt(0, (void *)cmos->rtc); |
1137 | else { | 1150 | else { |
1138 | /* Fix me: can we use cmos_interrupt() here as well? */ | 1151 | /* Fix me: can we use cmos_interrupt() here as well? */ |
diff --git a/drivers/rtc/rtc-core.h b/drivers/rtc/rtc-core.h index ccc17a2e293d..0abf98983e13 100644 --- a/drivers/rtc/rtc-core.h +++ b/drivers/rtc/rtc-core.h | |||
@@ -40,23 +40,9 @@ static inline void rtc_proc_del_device(struct rtc_device *rtc) | |||
40 | 40 | ||
41 | #ifdef CONFIG_RTC_INTF_SYSFS | 41 | #ifdef CONFIG_RTC_INTF_SYSFS |
42 | const struct attribute_group **rtc_get_dev_attribute_groups(void); | 42 | const struct attribute_group **rtc_get_dev_attribute_groups(void); |
43 | int rtc_add_group(struct rtc_device *rtc, const struct attribute_group *grp); | ||
44 | int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group **grps); | ||
45 | #else | 43 | #else |
46 | static inline const struct attribute_group **rtc_get_dev_attribute_groups(void) | 44 | static inline const struct attribute_group **rtc_get_dev_attribute_groups(void) |
47 | { | 45 | { |
48 | return NULL; | 46 | return NULL; |
49 | } | 47 | } |
50 | |||
51 | static inline | ||
52 | int rtc_add_group(struct rtc_device *rtc, const struct attribute_group *grp) | ||
53 | { | ||
54 | return 0; | ||
55 | } | ||
56 | |||
57 | static inline | ||
58 | int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group **grps) | ||
59 | { | ||
60 | return 0; | ||
61 | } | ||
62 | #endif | 48 | #endif |
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index 4b2b4627daeb..74b31dce484f 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c | |||
@@ -114,6 +114,20 @@ enum ds_type { | |||
114 | # define RX8025_BIT_VDET 0x40 | 114 | # define RX8025_BIT_VDET 0x40 |
115 | # define RX8025_BIT_XST 0x20 | 115 | # define RX8025_BIT_XST 0x20 |
116 | 116 | ||
117 | #define M41TXX_REG_CONTROL 0x07 | ||
118 | # define M41TXX_BIT_OUT BIT(7) | ||
119 | # define M41TXX_BIT_FT BIT(6) | ||
120 | # define M41TXX_BIT_CALIB_SIGN BIT(5) | ||
121 | # define M41TXX_M_CALIBRATION GENMASK(4, 0) | ||
122 | |||
123 | /* negative offset step is -2.034ppm */ | ||
124 | #define M41TXX_NEG_OFFSET_STEP_PPB 2034 | ||
125 | /* positive offset step is +4.068ppm */ | ||
126 | #define M41TXX_POS_OFFSET_STEP_PPB 4068 | ||
127 | /* Min and max values supported with 'offset' interface by M41TXX */ | ||
128 | #define M41TXX_MIN_OFFSET ((-31) * M41TXX_NEG_OFFSET_STEP_PPB) | ||
129 | #define M41TXX_MAX_OFFSET ((31) * M41TXX_POS_OFFSET_STEP_PPB) | ||
130 | |||
117 | struct ds1307 { | 131 | struct ds1307 { |
118 | enum ds_type type; | 132 | enum ds_type type; |
119 | unsigned long flags; | 133 | unsigned long flags; |
@@ -146,6 +160,9 @@ struct chip_desc { | |||
146 | 160 | ||
147 | static int ds1307_get_time(struct device *dev, struct rtc_time *t); | 161 | static int ds1307_get_time(struct device *dev, struct rtc_time *t); |
148 | static int ds1307_set_time(struct device *dev, struct rtc_time *t); | 162 | static int ds1307_set_time(struct device *dev, struct rtc_time *t); |
163 | static int ds1337_read_alarm(struct device *dev, struct rtc_wkalrm *t); | ||
164 | static int ds1337_set_alarm(struct device *dev, struct rtc_wkalrm *t); | ||
165 | static int ds1307_alarm_irq_enable(struct device *dev, unsigned int enabled); | ||
149 | static u8 do_trickle_setup_ds1339(struct ds1307 *, u32 ohms, bool diode); | 166 | static u8 do_trickle_setup_ds1339(struct ds1307 *, u32 ohms, bool diode); |
150 | static irqreturn_t rx8130_irq(int irq, void *dev_id); | 167 | static irqreturn_t rx8130_irq(int irq, void *dev_id); |
151 | static int rx8130_read_alarm(struct device *dev, struct rtc_wkalrm *t); | 168 | static int rx8130_read_alarm(struct device *dev, struct rtc_wkalrm *t); |
@@ -155,6 +172,8 @@ static irqreturn_t mcp794xx_irq(int irq, void *dev_id); | |||
155 | static int mcp794xx_read_alarm(struct device *dev, struct rtc_wkalrm *t); | 172 | static int mcp794xx_read_alarm(struct device *dev, struct rtc_wkalrm *t); |
156 | static int mcp794xx_set_alarm(struct device *dev, struct rtc_wkalrm *t); | 173 | static int mcp794xx_set_alarm(struct device *dev, struct rtc_wkalrm *t); |
157 | static int mcp794xx_alarm_irq_enable(struct device *dev, unsigned int enabled); | 174 | static int mcp794xx_alarm_irq_enable(struct device *dev, unsigned int enabled); |
175 | static int m41txx_rtc_read_offset(struct device *dev, long *offset); | ||
176 | static int m41txx_rtc_set_offset(struct device *dev, long offset); | ||
158 | 177 | ||
159 | static const struct rtc_class_ops rx8130_rtc_ops = { | 178 | static const struct rtc_class_ops rx8130_rtc_ops = { |
160 | .read_time = ds1307_get_time, | 179 | .read_time = ds1307_get_time, |
@@ -172,6 +191,16 @@ static const struct rtc_class_ops mcp794xx_rtc_ops = { | |||
172 | .alarm_irq_enable = mcp794xx_alarm_irq_enable, | 191 | .alarm_irq_enable = mcp794xx_alarm_irq_enable, |
173 | }; | 192 | }; |
174 | 193 | ||
194 | static const struct rtc_class_ops m41txx_rtc_ops = { | ||
195 | .read_time = ds1307_get_time, | ||
196 | .set_time = ds1307_set_time, | ||
197 | .read_alarm = ds1337_read_alarm, | ||
198 | .set_alarm = ds1337_set_alarm, | ||
199 | .alarm_irq_enable = ds1307_alarm_irq_enable, | ||
200 | .read_offset = m41txx_rtc_read_offset, | ||
201 | .set_offset = m41txx_rtc_set_offset, | ||
202 | }; | ||
203 | |||
175 | static const struct chip_desc chips[last_ds_type] = { | 204 | static const struct chip_desc chips[last_ds_type] = { |
176 | [ds_1307] = { | 205 | [ds_1307] = { |
177 | .nvram_offset = 8, | 206 | .nvram_offset = 8, |
@@ -228,10 +257,17 @@ static const struct chip_desc chips[last_ds_type] = { | |||
228 | .irq_handler = rx8130_irq, | 257 | .irq_handler = rx8130_irq, |
229 | .rtc_ops = &rx8130_rtc_ops, | 258 | .rtc_ops = &rx8130_rtc_ops, |
230 | }, | 259 | }, |
260 | [m41t0] = { | ||
261 | .rtc_ops = &m41txx_rtc_ops, | ||
262 | }, | ||
263 | [m41t00] = { | ||
264 | .rtc_ops = &m41txx_rtc_ops, | ||
265 | }, | ||
231 | [m41t11] = { | 266 | [m41t11] = { |
232 | /* this is battery backed SRAM */ | 267 | /* this is battery backed SRAM */ |
233 | .nvram_offset = 8, | 268 | .nvram_offset = 8, |
234 | .nvram_size = 56, | 269 | .nvram_size = 56, |
270 | .rtc_ops = &m41txx_rtc_ops, | ||
235 | }, | 271 | }, |
236 | [mcp794xx] = { | 272 | [mcp794xx] = { |
237 | .alarm = 1, | 273 | .alarm = 1, |
@@ -973,6 +1009,110 @@ static int mcp794xx_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
973 | enabled ? MCP794XX_BIT_ALM0_EN : 0); | 1009 | enabled ? MCP794XX_BIT_ALM0_EN : 0); |
974 | } | 1010 | } |
975 | 1011 | ||
1012 | static int m41txx_rtc_read_offset(struct device *dev, long *offset) | ||
1013 | { | ||
1014 | struct ds1307 *ds1307 = dev_get_drvdata(dev); | ||
1015 | unsigned int ctrl_reg; | ||
1016 | u8 val; | ||
1017 | |||
1018 | regmap_read(ds1307->regmap, M41TXX_REG_CONTROL, &ctrl_reg); | ||
1019 | |||
1020 | val = ctrl_reg & M41TXX_M_CALIBRATION; | ||
1021 | |||
1022 | /* check if positive */ | ||
1023 | if (ctrl_reg & M41TXX_BIT_CALIB_SIGN) | ||
1024 | *offset = (val * M41TXX_POS_OFFSET_STEP_PPB); | ||
1025 | else | ||
1026 | *offset = -(val * M41TXX_NEG_OFFSET_STEP_PPB); | ||
1027 | |||
1028 | return 0; | ||
1029 | } | ||
1030 | |||
1031 | static int m41txx_rtc_set_offset(struct device *dev, long offset) | ||
1032 | { | ||
1033 | struct ds1307 *ds1307 = dev_get_drvdata(dev); | ||
1034 | unsigned int ctrl_reg; | ||
1035 | |||
1036 | if ((offset < M41TXX_MIN_OFFSET) || (offset > M41TXX_MAX_OFFSET)) | ||
1037 | return -ERANGE; | ||
1038 | |||
1039 | if (offset >= 0) { | ||
1040 | ctrl_reg = DIV_ROUND_CLOSEST(offset, | ||
1041 | M41TXX_POS_OFFSET_STEP_PPB); | ||
1042 | ctrl_reg |= M41TXX_BIT_CALIB_SIGN; | ||
1043 | } else { | ||
1044 | ctrl_reg = DIV_ROUND_CLOSEST(abs(offset), | ||
1045 | M41TXX_NEG_OFFSET_STEP_PPB); | ||
1046 | } | ||
1047 | |||
1048 | return regmap_update_bits(ds1307->regmap, M41TXX_REG_CONTROL, | ||
1049 | M41TXX_M_CALIBRATION | M41TXX_BIT_CALIB_SIGN, | ||
1050 | ctrl_reg); | ||
1051 | } | ||
1052 | |||
1053 | static ssize_t frequency_test_store(struct device *dev, | ||
1054 | struct device_attribute *attr, | ||
1055 | const char *buf, size_t count) | ||
1056 | { | ||
1057 | struct ds1307 *ds1307 = dev_get_drvdata(dev->parent); | ||
1058 | bool freq_test_en; | ||
1059 | int ret; | ||
1060 | |||
1061 | ret = kstrtobool(buf, &freq_test_en); | ||
1062 | if (ret) { | ||
1063 | dev_err(dev, "Failed to store RTC Frequency Test attribute\n"); | ||
1064 | return ret; | ||
1065 | } | ||
1066 | |||
1067 | regmap_update_bits(ds1307->regmap, M41TXX_REG_CONTROL, M41TXX_BIT_FT, | ||
1068 | freq_test_en ? M41TXX_BIT_FT : 0); | ||
1069 | |||
1070 | return count; | ||
1071 | } | ||
1072 | |||
1073 | static ssize_t frequency_test_show(struct device *dev, | ||
1074 | struct device_attribute *attr, | ||
1075 | char *buf) | ||
1076 | { | ||
1077 | struct ds1307 *ds1307 = dev_get_drvdata(dev->parent); | ||
1078 | unsigned int ctrl_reg; | ||
1079 | |||
1080 | regmap_read(ds1307->regmap, M41TXX_REG_CONTROL, &ctrl_reg); | ||
1081 | |||
1082 | return scnprintf(buf, PAGE_SIZE, (ctrl_reg & M41TXX_BIT_FT) ? "on\n" : | ||
1083 | "off\n"); | ||
1084 | } | ||
1085 | |||
1086 | static DEVICE_ATTR_RW(frequency_test); | ||
1087 | |||
1088 | static struct attribute *rtc_freq_test_attrs[] = { | ||
1089 | &dev_attr_frequency_test.attr, | ||
1090 | NULL, | ||
1091 | }; | ||
1092 | |||
1093 | static const struct attribute_group rtc_freq_test_attr_group = { | ||
1094 | .attrs = rtc_freq_test_attrs, | ||
1095 | }; | ||
1096 | |||
1097 | static int ds1307_add_frequency_test(struct ds1307 *ds1307) | ||
1098 | { | ||
1099 | int err; | ||
1100 | |||
1101 | switch (ds1307->type) { | ||
1102 | case m41t0: | ||
1103 | case m41t00: | ||
1104 | case m41t11: | ||
1105 | err = rtc_add_group(ds1307->rtc, &rtc_freq_test_attr_group); | ||
1106 | if (err) | ||
1107 | return err; | ||
1108 | break; | ||
1109 | default: | ||
1110 | break; | ||
1111 | } | ||
1112 | |||
1113 | return 0; | ||
1114 | } | ||
1115 | |||
976 | /*----------------------------------------------------------------------*/ | 1116 | /*----------------------------------------------------------------------*/ |
977 | 1117 | ||
978 | static int ds1307_nvram_read(void *priv, unsigned int offset, void *val, | 1118 | static int ds1307_nvram_read(void *priv, unsigned int offset, void *val, |
@@ -1384,7 +1524,6 @@ static void ds1307_clks_register(struct ds1307 *ds1307) | |||
1384 | static const struct regmap_config regmap_config = { | 1524 | static const struct regmap_config regmap_config = { |
1385 | .reg_bits = 8, | 1525 | .reg_bits = 8, |
1386 | .val_bits = 8, | 1526 | .val_bits = 8, |
1387 | .max_register = 0x9, | ||
1388 | }; | 1527 | }; |
1389 | 1528 | ||
1390 | static int ds1307_probe(struct i2c_client *client, | 1529 | static int ds1307_probe(struct i2c_client *client, |
@@ -1711,6 +1850,10 @@ read_rtc: | |||
1711 | } | 1850 | } |
1712 | 1851 | ||
1713 | ds1307->rtc->ops = chip->rtc_ops ?: &ds13xx_rtc_ops; | 1852 | ds1307->rtc->ops = chip->rtc_ops ?: &ds13xx_rtc_ops; |
1853 | err = ds1307_add_frequency_test(ds1307); | ||
1854 | if (err) | ||
1855 | return err; | ||
1856 | |||
1714 | err = rtc_register_device(ds1307->rtc); | 1857 | err = rtc_register_device(ds1307->rtc); |
1715 | if (err) | 1858 | if (err) |
1716 | return err; | 1859 | return err; |
diff --git a/drivers/rtc/rtc-ds1685.c b/drivers/rtc/rtc-ds1685.c index 6f39f683a98c..2710f2594c42 100644 --- a/drivers/rtc/rtc-ds1685.c +++ b/drivers/rtc/rtc-ds1685.c | |||
@@ -770,33 +770,6 @@ static const char *ds1685_rtc_sqw_freq[16] = { | |||
770 | "512Hz", "256Hz", "128Hz", "64Hz", "32Hz", "16Hz", "8Hz", "4Hz", "2Hz" | 770 | "512Hz", "256Hz", "128Hz", "64Hz", "32Hz", "16Hz", "8Hz", "4Hz", "2Hz" |
771 | }; | 771 | }; |
772 | 772 | ||
773 | #ifdef CONFIG_RTC_DS1685_PROC_REGS | ||
774 | /** | ||
775 | * ds1685_rtc_print_regs - helper function to print register values. | ||
776 | * @hex: hex byte to convert into binary bits. | ||
777 | * @dest: destination char array. | ||
778 | * | ||
779 | * This is basically a hex->binary function, just with extra spacing between | ||
780 | * the digits. It only works on 1-byte values (8 bits). | ||
781 | */ | ||
782 | static char* | ||
783 | ds1685_rtc_print_regs(u8 hex, char *dest) | ||
784 | { | ||
785 | u32 i, j; | ||
786 | char *tmp = dest; | ||
787 | |||
788 | for (i = 0; i < NUM_BITS; i++) { | ||
789 | *tmp++ = ((hex & 0x80) != 0 ? '1' : '0'); | ||
790 | for (j = 0; j < NUM_SPACES; j++) | ||
791 | *tmp++ = ' '; | ||
792 | hex <<= 1; | ||
793 | } | ||
794 | *tmp++ = '\0'; | ||
795 | |||
796 | return dest; | ||
797 | } | ||
798 | #endif | ||
799 | |||
800 | /** | 773 | /** |
801 | * ds1685_rtc_proc - procfs access function. | 774 | * ds1685_rtc_proc - procfs access function. |
802 | * @dev: pointer to device structure. | 775 | * @dev: pointer to device structure. |
@@ -805,13 +778,9 @@ ds1685_rtc_print_regs(u8 hex, char *dest) | |||
805 | static int | 778 | static int |
806 | ds1685_rtc_proc(struct device *dev, struct seq_file *seq) | 779 | ds1685_rtc_proc(struct device *dev, struct seq_file *seq) |
807 | { | 780 | { |
808 | struct platform_device *pdev = to_platform_device(dev); | 781 | struct ds1685_priv *rtc = dev_get_drvdata(dev); |
809 | struct ds1685_priv *rtc = platform_get_drvdata(pdev); | ||
810 | u8 ctrla, ctrlb, ctrlc, ctrld, ctrl4a, ctrl4b, ssn[8]; | 782 | u8 ctrla, ctrlb, ctrlc, ctrld, ctrl4a, ctrl4b, ssn[8]; |
811 | char *model; | 783 | char *model; |
812 | #ifdef CONFIG_RTC_DS1685_PROC_REGS | ||
813 | char bits[NUM_REGS][(NUM_BITS * NUM_SPACES) + NUM_BITS + 1]; | ||
814 | #endif | ||
815 | 784 | ||
816 | /* Read all the relevant data from the control registers. */ | 785 | /* Read all the relevant data from the control registers. */ |
817 | ds1685_rtc_switch_to_bank1(rtc); | 786 | ds1685_rtc_switch_to_bank1(rtc); |
@@ -859,28 +828,7 @@ ds1685_rtc_proc(struct device *dev, struct seq_file *seq) | |||
859 | "Periodic IRQ\t: %s\n" | 828 | "Periodic IRQ\t: %s\n" |
860 | "Periodic Rate\t: %s\n" | 829 | "Periodic Rate\t: %s\n" |
861 | "SQW Freq\t: %s\n" | 830 | "SQW Freq\t: %s\n" |
862 | #ifdef CONFIG_RTC_DS1685_PROC_REGS | ||
863 | "Serial #\t: %8phC\n" | ||
864 | "Register Status\t:\n" | ||
865 | " Ctrl A\t: UIP DV2 DV1 DV0 RS3 RS2 RS1 RS0\n" | ||
866 | "\t\t: %s\n" | ||
867 | " Ctrl B\t: SET PIE AIE UIE SQWE DM 2412 DSE\n" | ||
868 | "\t\t: %s\n" | ||
869 | " Ctrl C\t: IRQF PF AF UF --- --- --- ---\n" | ||
870 | "\t\t: %s\n" | ||
871 | " Ctrl D\t: VRT --- --- --- --- --- --- ---\n" | ||
872 | "\t\t: %s\n" | ||
873 | #if !defined(CONFIG_RTC_DRV_DS1685) && !defined(CONFIG_RTC_DRV_DS1689) | ||
874 | " Ctrl 4A\t: VRT2 INCR BME --- PAB RF WF KF\n" | ||
875 | #else | ||
876 | " Ctrl 4A\t: VRT2 INCR --- --- PAB RF WF KF\n" | ||
877 | #endif | ||
878 | "\t\t: %s\n" | ||
879 | " Ctrl 4B\t: ABE E32k CS RCE PRS RIE WIE KSE\n" | ||
880 | "\t\t: %s\n", | ||
881 | #else | ||
882 | "Serial #\t: %8phC\n", | 831 | "Serial #\t: %8phC\n", |
883 | #endif | ||
884 | model, | 832 | model, |
885 | ((ctrla & RTC_CTRL_A_DV1) ? "enabled" : "disabled"), | 833 | ((ctrla & RTC_CTRL_A_DV1) ? "enabled" : "disabled"), |
886 | ((ctrlb & RTC_CTRL_B_2412) ? "24-hour" : "12-hour"), | 834 | ((ctrlb & RTC_CTRL_B_2412) ? "24-hour" : "12-hour"), |
@@ -894,17 +842,7 @@ ds1685_rtc_proc(struct device *dev, struct seq_file *seq) | |||
894 | ds1685_rtc_pirq_rate[(ctrla & RTC_CTRL_A_RS_MASK)] : "none"), | 842 | ds1685_rtc_pirq_rate[(ctrla & RTC_CTRL_A_RS_MASK)] : "none"), |
895 | (!((ctrl4b & RTC_CTRL_4B_E32K)) ? | 843 | (!((ctrl4b & RTC_CTRL_4B_E32K)) ? |
896 | ds1685_rtc_sqw_freq[(ctrla & RTC_CTRL_A_RS_MASK)] : "32768Hz"), | 844 | ds1685_rtc_sqw_freq[(ctrla & RTC_CTRL_A_RS_MASK)] : "32768Hz"), |
897 | #ifdef CONFIG_RTC_DS1685_PROC_REGS | ||
898 | ssn, | ||
899 | ds1685_rtc_print_regs(ctrla, bits[0]), | ||
900 | ds1685_rtc_print_regs(ctrlb, bits[1]), | ||
901 | ds1685_rtc_print_regs(ctrlc, bits[2]), | ||
902 | ds1685_rtc_print_regs(ctrld, bits[3]), | ||
903 | ds1685_rtc_print_regs(ctrl4a, bits[4]), | ||
904 | ds1685_rtc_print_regs(ctrl4b, bits[5])); | ||
905 | #else | ||
906 | ssn); | 845 | ssn); |
907 | #endif | ||
908 | return 0; | 846 | return 0; |
909 | } | 847 | } |
910 | #else | 848 | #else |
@@ -927,30 +865,13 @@ ds1685_rtc_ops = { | |||
927 | }; | 865 | }; |
928 | /* ----------------------------------------------------------------------- */ | 866 | /* ----------------------------------------------------------------------- */ |
929 | 867 | ||
930 | 868 | static int ds1685_nvram_read(void *priv, unsigned int pos, void *val, | |
931 | /* ----------------------------------------------------------------------- */ | 869 | size_t size) |
932 | /* SysFS interface */ | ||
933 | |||
934 | #ifdef CONFIG_SYSFS | ||
935 | /** | ||
936 | * ds1685_rtc_sysfs_nvram_read - reads rtc nvram via sysfs. | ||
937 | * @file: pointer to file structure. | ||
938 | * @kobj: pointer to kobject structure. | ||
939 | * @bin_attr: pointer to bin_attribute structure. | ||
940 | * @buf: pointer to char array to hold the output. | ||
941 | * @pos: current file position pointer. | ||
942 | * @size: size of the data to read. | ||
943 | */ | ||
944 | static ssize_t | ||
945 | ds1685_rtc_sysfs_nvram_read(struct file *filp, struct kobject *kobj, | ||
946 | struct bin_attribute *bin_attr, char *buf, | ||
947 | loff_t pos, size_t size) | ||
948 | { | 870 | { |
949 | struct platform_device *pdev = | 871 | struct ds1685_priv *rtc = priv; |
950 | to_platform_device(container_of(kobj, struct device, kobj)); | ||
951 | struct ds1685_priv *rtc = platform_get_drvdata(pdev); | ||
952 | ssize_t count; | 872 | ssize_t count; |
953 | unsigned long flags = 0; | 873 | unsigned long flags = 0; |
874 | u8 *buf = val; | ||
954 | 875 | ||
955 | spin_lock_irqsave(&rtc->lock, flags); | 876 | spin_lock_irqsave(&rtc->lock, flags); |
956 | ds1685_rtc_switch_to_bank0(rtc); | 877 | ds1685_rtc_switch_to_bank0(rtc); |
@@ -1004,33 +925,16 @@ ds1685_rtc_sysfs_nvram_read(struct file *filp, struct kobject *kobj, | |||
1004 | #endif /* !CONFIG_RTC_DRV_DS1689 */ | 925 | #endif /* !CONFIG_RTC_DRV_DS1689 */ |
1005 | spin_unlock_irqrestore(&rtc->lock, flags); | 926 | spin_unlock_irqrestore(&rtc->lock, flags); |
1006 | 927 | ||
1007 | /* | 928 | return 0; |
1008 | * XXX: Bug? this appears to cause the function to get executed | ||
1009 | * several times in succession. But it's the only way to actually get | ||
1010 | * data written out to a file. | ||
1011 | */ | ||
1012 | return count; | ||
1013 | } | 929 | } |
1014 | 930 | ||
1015 | /** | 931 | static int ds1685_nvram_write(void *priv, unsigned int pos, void *val, |
1016 | * ds1685_rtc_sysfs_nvram_write - writes rtc nvram via sysfs. | 932 | size_t size) |
1017 | * @file: pointer to file structure. | ||
1018 | * @kobj: pointer to kobject structure. | ||
1019 | * @bin_attr: pointer to bin_attribute structure. | ||
1020 | * @buf: pointer to char array to hold the input. | ||
1021 | * @pos: current file position pointer. | ||
1022 | * @size: size of the data to write. | ||
1023 | */ | ||
1024 | static ssize_t | ||
1025 | ds1685_rtc_sysfs_nvram_write(struct file *filp, struct kobject *kobj, | ||
1026 | struct bin_attribute *bin_attr, char *buf, | ||
1027 | loff_t pos, size_t size) | ||
1028 | { | 933 | { |
1029 | struct platform_device *pdev = | 934 | struct ds1685_priv *rtc = priv; |
1030 | to_platform_device(container_of(kobj, struct device, kobj)); | ||
1031 | struct ds1685_priv *rtc = platform_get_drvdata(pdev); | ||
1032 | ssize_t count; | 935 | ssize_t count; |
1033 | unsigned long flags = 0; | 936 | unsigned long flags = 0; |
937 | u8 *buf = val; | ||
1034 | 938 | ||
1035 | spin_lock_irqsave(&rtc->lock, flags); | 939 | spin_lock_irqsave(&rtc->lock, flags); |
1036 | ds1685_rtc_switch_to_bank0(rtc); | 940 | ds1685_rtc_switch_to_bank0(rtc); |
@@ -1084,26 +988,11 @@ ds1685_rtc_sysfs_nvram_write(struct file *filp, struct kobject *kobj, | |||
1084 | #endif /* !CONFIG_RTC_DRV_DS1689 */ | 988 | #endif /* !CONFIG_RTC_DRV_DS1689 */ |
1085 | spin_unlock_irqrestore(&rtc->lock, flags); | 989 | spin_unlock_irqrestore(&rtc->lock, flags); |
1086 | 990 | ||
1087 | return count; | 991 | return 0; |
1088 | } | 992 | } |
1089 | 993 | ||
1090 | /** | 994 | /* ----------------------------------------------------------------------- */ |
1091 | * struct ds1685_rtc_sysfs_nvram_attr - sysfs attributes for rtc nvram. | 995 | /* SysFS interface */ |
1092 | * @attr: nvram attributes. | ||
1093 | * @read: nvram read function. | ||
1094 | * @write: nvram write function. | ||
1095 | * @size: nvram total size (bank0 + extended). | ||
1096 | */ | ||
1097 | static struct bin_attribute | ||
1098 | ds1685_rtc_sysfs_nvram_attr = { | ||
1099 | .attr = { | ||
1100 | .name = "nvram", | ||
1101 | .mode = S_IRUGO | S_IWUSR, | ||
1102 | }, | ||
1103 | .read = ds1685_rtc_sysfs_nvram_read, | ||
1104 | .write = ds1685_rtc_sysfs_nvram_write, | ||
1105 | .size = NVRAM_TOTAL_SZ | ||
1106 | }; | ||
1107 | 996 | ||
1108 | /** | 997 | /** |
1109 | * ds1685_rtc_sysfs_battery_show - sysfs file for main battery status. | 998 | * ds1685_rtc_sysfs_battery_show - sysfs file for main battery status. |
@@ -1188,43 +1077,6 @@ ds1685_rtc_sysfs_misc_grp = { | |||
1188 | .attrs = ds1685_rtc_sysfs_misc_attrs, | 1077 | .attrs = ds1685_rtc_sysfs_misc_attrs, |
1189 | }; | 1078 | }; |
1190 | 1079 | ||
1191 | /** | ||
1192 | * ds1685_rtc_sysfs_register - register sysfs files. | ||
1193 | * @dev: pointer to device structure. | ||
1194 | */ | ||
1195 | static int | ||
1196 | ds1685_rtc_sysfs_register(struct device *dev) | ||
1197 | { | ||
1198 | int ret = 0; | ||
1199 | |||
1200 | sysfs_bin_attr_init(&ds1685_rtc_sysfs_nvram_attr); | ||
1201 | ret = sysfs_create_bin_file(&dev->kobj, &ds1685_rtc_sysfs_nvram_attr); | ||
1202 | if (ret) | ||
1203 | return ret; | ||
1204 | |||
1205 | ret = sysfs_create_group(&dev->kobj, &ds1685_rtc_sysfs_misc_grp); | ||
1206 | if (ret) | ||
1207 | return ret; | ||
1208 | |||
1209 | return 0; | ||
1210 | } | ||
1211 | |||
1212 | /** | ||
1213 | * ds1685_rtc_sysfs_unregister - unregister sysfs files. | ||
1214 | * @dev: pointer to device structure. | ||
1215 | */ | ||
1216 | static int | ||
1217 | ds1685_rtc_sysfs_unregister(struct device *dev) | ||
1218 | { | ||
1219 | sysfs_remove_bin_file(&dev->kobj, &ds1685_rtc_sysfs_nvram_attr); | ||
1220 | sysfs_remove_group(&dev->kobj, &ds1685_rtc_sysfs_misc_grp); | ||
1221 | |||
1222 | return 0; | ||
1223 | } | ||
1224 | #endif /* CONFIG_SYSFS */ | ||
1225 | |||
1226 | |||
1227 | |||
1228 | /* ----------------------------------------------------------------------- */ | 1080 | /* ----------------------------------------------------------------------- */ |
1229 | /* Driver Probe/Removal */ | 1081 | /* Driver Probe/Removal */ |
1230 | 1082 | ||
@@ -1242,6 +1094,12 @@ ds1685_rtc_probe(struct platform_device *pdev) | |||
1242 | u8 ctrla, ctrlb, hours; | 1094 | u8 ctrla, ctrlb, hours; |
1243 | unsigned char am_pm; | 1095 | unsigned char am_pm; |
1244 | int ret = 0; | 1096 | int ret = 0; |
1097 | struct nvmem_config nvmem_cfg = { | ||
1098 | .name = "ds1685_nvram", | ||
1099 | .size = NVRAM_TOTAL_SZ, | ||
1100 | .reg_read = ds1685_nvram_read, | ||
1101 | .reg_write = ds1685_nvram_write, | ||
1102 | }; | ||
1245 | 1103 | ||
1246 | /* Get the platform data. */ | 1104 | /* Get the platform data. */ |
1247 | pdata = (struct ds1685_rtc_platform_data *) pdev->dev.platform_data; | 1105 | pdata = (struct ds1685_rtc_platform_data *) pdev->dev.platform_data; |
@@ -1499,11 +1357,15 @@ ds1685_rtc_probe(struct platform_device *pdev) | |||
1499 | /* Setup complete. */ | 1357 | /* Setup complete. */ |
1500 | ds1685_rtc_switch_to_bank0(rtc); | 1358 | ds1685_rtc_switch_to_bank0(rtc); |
1501 | 1359 | ||
1502 | #ifdef CONFIG_SYSFS | 1360 | ret = rtc_add_group(rtc_dev, &ds1685_rtc_sysfs_misc_grp); |
1503 | ret = ds1685_rtc_sysfs_register(&pdev->dev); | 1361 | if (ret) |
1362 | return ret; | ||
1363 | |||
1364 | rtc_dev->nvram_old_abi = true; | ||
1365 | nvmem_cfg.priv = rtc; | ||
1366 | ret = rtc_nvmem_register(rtc_dev, &nvmem_cfg); | ||
1504 | if (ret) | 1367 | if (ret) |
1505 | return ret; | 1368 | return ret; |
1506 | #endif | ||
1507 | 1369 | ||
1508 | return rtc_register_device(rtc_dev); | 1370 | return rtc_register_device(rtc_dev); |
1509 | } | 1371 | } |
@@ -1517,10 +1379,6 @@ ds1685_rtc_remove(struct platform_device *pdev) | |||
1517 | { | 1379 | { |
1518 | struct ds1685_priv *rtc = platform_get_drvdata(pdev); | 1380 | struct ds1685_priv *rtc = platform_get_drvdata(pdev); |
1519 | 1381 | ||
1520 | #ifdef CONFIG_SYSFS | ||
1521 | ds1685_rtc_sysfs_unregister(&pdev->dev); | ||
1522 | #endif | ||
1523 | |||
1524 | /* Read Ctrl B and clear PIE/AIE/UIE. */ | 1382 | /* Read Ctrl B and clear PIE/AIE/UIE. */ |
1525 | rtc->write(rtc, RTC_CTRL_B, | 1383 | rtc->write(rtc, RTC_CTRL_B, |
1526 | (rtc->read(rtc, RTC_CTRL_B) & | 1384 | (rtc->read(rtc, RTC_CTRL_B) & |
diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c index ea18a8f4bce0..ec5ef518a09b 100644 --- a/drivers/rtc/rtc-isl1208.c +++ b/drivers/rtc/rtc-isl1208.c | |||
@@ -10,12 +10,11 @@ | |||
10 | * | 10 | * |
11 | */ | 11 | */ |
12 | 12 | ||
13 | #include <linux/module.h> | ||
14 | #include <linux/i2c.h> | ||
15 | #include <linux/bcd.h> | 13 | #include <linux/bcd.h> |
16 | #include <linux/rtc.h> | 14 | #include <linux/i2c.h> |
17 | #include "rtc-core.h" | 15 | #include <linux/module.h> |
18 | #include <linux/of_irq.h> | 16 | #include <linux/of_irq.h> |
17 | #include <linux/rtc.h> | ||
19 | 18 | ||
20 | /* Register map */ | 19 | /* Register map */ |
21 | /* rtc section */ | 20 | /* rtc section */ |
@@ -518,7 +517,7 @@ static ssize_t timestamp0_store(struct device *dev, | |||
518 | struct device_attribute *attr, | 517 | struct device_attribute *attr, |
519 | const char *buf, size_t count) | 518 | const char *buf, size_t count) |
520 | { | 519 | { |
521 | struct i2c_client *client = dev_get_drvdata(dev); | 520 | struct i2c_client *client = to_i2c_client(dev->parent); |
522 | int sr; | 521 | int sr; |
523 | 522 | ||
524 | sr = isl1208_i2c_get_sr(client); | 523 | sr = isl1208_i2c_get_sr(client); |
@@ -540,7 +539,7 @@ static ssize_t timestamp0_store(struct device *dev, | |||
540 | static ssize_t timestamp0_show(struct device *dev, | 539 | static ssize_t timestamp0_show(struct device *dev, |
541 | struct device_attribute *attr, char *buf) | 540 | struct device_attribute *attr, char *buf) |
542 | { | 541 | { |
543 | struct i2c_client *client = dev_get_drvdata(dev); | 542 | struct i2c_client *client = to_i2c_client(dev->parent); |
544 | u8 regs[ISL1219_EVT_SECTION_LEN] = { 0, }; | 543 | u8 regs[ISL1219_EVT_SECTION_LEN] = { 0, }; |
545 | struct rtc_time tm; | 544 | struct rtc_time tm; |
546 | int sr; | 545 | int sr; |
@@ -650,7 +649,7 @@ static ssize_t | |||
650 | isl1208_sysfs_show_atrim(struct device *dev, | 649 | isl1208_sysfs_show_atrim(struct device *dev, |
651 | struct device_attribute *attr, char *buf) | 650 | struct device_attribute *attr, char *buf) |
652 | { | 651 | { |
653 | int atr = isl1208_i2c_get_atr(to_i2c_client(dev)); | 652 | int atr = isl1208_i2c_get_atr(to_i2c_client(dev->parent)); |
654 | if (atr < 0) | 653 | if (atr < 0) |
655 | return atr; | 654 | return atr; |
656 | 655 | ||
@@ -663,7 +662,7 @@ static ssize_t | |||
663 | isl1208_sysfs_show_dtrim(struct device *dev, | 662 | isl1208_sysfs_show_dtrim(struct device *dev, |
664 | struct device_attribute *attr, char *buf) | 663 | struct device_attribute *attr, char *buf) |
665 | { | 664 | { |
666 | int dtr = isl1208_i2c_get_dtr(to_i2c_client(dev)); | 665 | int dtr = isl1208_i2c_get_dtr(to_i2c_client(dev->parent)); |
667 | if (dtr < 0) | 666 | if (dtr < 0) |
668 | return dtr; | 667 | return dtr; |
669 | 668 | ||
@@ -676,7 +675,7 @@ static ssize_t | |||
676 | isl1208_sysfs_show_usr(struct device *dev, | 675 | isl1208_sysfs_show_usr(struct device *dev, |
677 | struct device_attribute *attr, char *buf) | 676 | struct device_attribute *attr, char *buf) |
678 | { | 677 | { |
679 | int usr = isl1208_i2c_get_usr(to_i2c_client(dev)); | 678 | int usr = isl1208_i2c_get_usr(to_i2c_client(dev->parent)); |
680 | if (usr < 0) | 679 | if (usr < 0) |
681 | return usr; | 680 | return usr; |
682 | 681 | ||
@@ -701,7 +700,10 @@ isl1208_sysfs_store_usr(struct device *dev, | |||
701 | if (usr < 0 || usr > 0xffff) | 700 | if (usr < 0 || usr > 0xffff) |
702 | return -EINVAL; | 701 | return -EINVAL; |
703 | 702 | ||
704 | return isl1208_i2c_set_usr(to_i2c_client(dev), usr) ? -EIO : count; | 703 | if (isl1208_i2c_set_usr(to_i2c_client(dev->parent), usr)) |
704 | return -EIO; | ||
705 | |||
706 | return count; | ||
705 | } | 707 | } |
706 | 708 | ||
707 | static DEVICE_ATTR(usr, S_IRUGO | S_IWUSR, isl1208_sysfs_show_usr, | 709 | static DEVICE_ATTR(usr, S_IRUGO | S_IWUSR, isl1208_sysfs_show_usr, |
@@ -765,7 +767,6 @@ isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
765 | rtc->ops = &isl1208_rtc_ops; | 767 | rtc->ops = &isl1208_rtc_ops; |
766 | 768 | ||
767 | i2c_set_clientdata(client, rtc); | 769 | i2c_set_clientdata(client, rtc); |
768 | dev_set_drvdata(&rtc->dev, client); | ||
769 | 770 | ||
770 | rc = isl1208_i2c_get_sr(client); | 771 | rc = isl1208_i2c_get_sr(client); |
771 | if (rc < 0) { | 772 | if (rc < 0) { |
@@ -804,7 +805,7 @@ isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
804 | evdet_irq = of_irq_get_byname(np, "evdet"); | 805 | evdet_irq = of_irq_get_byname(np, "evdet"); |
805 | } | 806 | } |
806 | 807 | ||
807 | rc = sysfs_create_group(&client->dev.kobj, &isl1208_rtc_sysfs_files); | 808 | rc = rtc_add_group(rtc, &isl1208_rtc_sysfs_files); |
808 | if (rc) | 809 | if (rc) |
809 | return rc; | 810 | return rc; |
810 | 811 | ||
@@ -821,14 +822,6 @@ isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
821 | return rtc_register_device(rtc); | 822 | return rtc_register_device(rtc); |
822 | } | 823 | } |
823 | 824 | ||
824 | static int | ||
825 | isl1208_remove(struct i2c_client *client) | ||
826 | { | ||
827 | sysfs_remove_group(&client->dev.kobj, &isl1208_rtc_sysfs_files); | ||
828 | |||
829 | return 0; | ||
830 | } | ||
831 | |||
832 | static const struct i2c_device_id isl1208_id[] = { | 825 | static const struct i2c_device_id isl1208_id[] = { |
833 | { "isl1208", TYPE_ISL1208 }, | 826 | { "isl1208", TYPE_ISL1208 }, |
834 | { "isl1218", TYPE_ISL1218 }, | 827 | { "isl1218", TYPE_ISL1218 }, |
@@ -851,7 +844,6 @@ static struct i2c_driver isl1208_driver = { | |||
851 | .of_match_table = of_match_ptr(isl1208_of_match), | 844 | .of_match_table = of_match_ptr(isl1208_of_match), |
852 | }, | 845 | }, |
853 | .probe = isl1208_probe, | 846 | .probe = isl1208_probe, |
854 | .remove = isl1208_remove, | ||
855 | .id_table = isl1208_id, | 847 | .id_table = isl1208_id, |
856 | }; | 848 | }; |
857 | 849 | ||
diff --git a/drivers/rtc/rtc-lib.c b/drivers/rtc/rtc-lib.c index 4a3c0f3aab14..ef160da84220 100644 --- a/drivers/rtc/rtc-lib.c +++ b/drivers/rtc/rtc-lib.c | |||
@@ -47,7 +47,7 @@ EXPORT_SYMBOL(rtc_year_days); | |||
47 | 47 | ||
48 | 48 | ||
49 | /* | 49 | /* |
50 | * rtc_time_to_tm64 - Converts time64_t to rtc_time. | 50 | * rtc_time64_to_tm - Converts time64_t to rtc_time. |
51 | * Convert seconds since 01-01-1970 00:00:00 to Gregorian date. | 51 | * Convert seconds since 01-01-1970 00:00:00 to Gregorian date. |
52 | */ | 52 | */ |
53 | void rtc_time64_to_tm(time64_t time, struct rtc_time *tm) | 53 | void rtc_time64_to_tm(time64_t time, struct rtc_time *tm) |
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c index ad03e2f12f5d..a3fb235fea0d 100644 --- a/drivers/rtc/rtc-m41t80.c +++ b/drivers/rtc/rtc-m41t80.c | |||
@@ -745,7 +745,7 @@ static int wdt_ioctl(struct file *file, unsigned int cmd, | |||
745 | return -EINVAL; | 745 | return -EINVAL; |
746 | wdt_margin = new_margin; | 746 | wdt_margin = new_margin; |
747 | wdt_ping(); | 747 | wdt_ping(); |
748 | /* Fall */ | 748 | /* Fall through */ |
749 | case WDIOC_GETTIMEOUT: | 749 | case WDIOC_GETTIMEOUT: |
750 | return put_user(wdt_margin, (int __user *)arg); | 750 | return put_user(wdt_margin, (int __user *)arg); |
751 | 751 | ||
diff --git a/drivers/rtc/rtc-mrst.c b/drivers/rtc/rtc-mrst.c index 1925aaf09093..daf354a6a853 100644 --- a/drivers/rtc/rtc-mrst.c +++ b/drivers/rtc/rtc-mrst.c | |||
@@ -90,7 +90,7 @@ static int mrst_read_time(struct device *dev, struct rtc_time *time) | |||
90 | unsigned long flags; | 90 | unsigned long flags; |
91 | 91 | ||
92 | if (vrtc_is_updating()) | 92 | if (vrtc_is_updating()) |
93 | mdelay(20); | 93 | msleep(20); |
94 | 94 | ||
95 | spin_lock_irqsave(&rtc_lock, flags); | 95 | spin_lock_irqsave(&rtc_lock, flags); |
96 | time->tm_sec = vrtc_cmos_read(RTC_SECONDS); | 96 | time->tm_sec = vrtc_cmos_read(RTC_SECONDS); |
@@ -261,11 +261,10 @@ static int mrst_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
261 | 261 | ||
262 | static int mrst_procfs(struct device *dev, struct seq_file *seq) | 262 | static int mrst_procfs(struct device *dev, struct seq_file *seq) |
263 | { | 263 | { |
264 | unsigned char rtc_control, valid; | 264 | unsigned char rtc_control; |
265 | 265 | ||
266 | spin_lock_irq(&rtc_lock); | 266 | spin_lock_irq(&rtc_lock); |
267 | rtc_control = vrtc_cmos_read(RTC_CONTROL); | 267 | rtc_control = vrtc_cmos_read(RTC_CONTROL); |
268 | valid = vrtc_cmos_read(RTC_VALID); | ||
269 | spin_unlock_irq(&rtc_lock); | 268 | spin_unlock_irq(&rtc_lock); |
270 | 269 | ||
271 | seq_printf(seq, | 270 | seq_printf(seq, |
diff --git a/drivers/rtc/rtc-mt6397.c b/drivers/rtc/rtc-mt6397.c index 385f8303bb41..e9a25ec4d434 100644 --- a/drivers/rtc/rtc-mt6397.c +++ b/drivers/rtc/rtc-mt6397.c | |||
@@ -332,6 +332,10 @@ static int mtk_rtc_probe(struct platform_device *pdev) | |||
332 | 332 | ||
333 | platform_set_drvdata(pdev, rtc); | 333 | platform_set_drvdata(pdev, rtc); |
334 | 334 | ||
335 | rtc->rtc_dev = devm_rtc_allocate_device(rtc->dev); | ||
336 | if (IS_ERR(rtc->rtc_dev)) | ||
337 | return PTR_ERR(rtc->rtc_dev); | ||
338 | |||
335 | ret = request_threaded_irq(rtc->irq, NULL, | 339 | ret = request_threaded_irq(rtc->irq, NULL, |
336 | mtk_rtc_irq_handler_thread, | 340 | mtk_rtc_irq_handler_thread, |
337 | IRQF_ONESHOT | IRQF_TRIGGER_HIGH, | 341 | IRQF_ONESHOT | IRQF_TRIGGER_HIGH, |
@@ -344,11 +348,11 @@ static int mtk_rtc_probe(struct platform_device *pdev) | |||
344 | 348 | ||
345 | device_init_wakeup(&pdev->dev, 1); | 349 | device_init_wakeup(&pdev->dev, 1); |
346 | 350 | ||
347 | rtc->rtc_dev = rtc_device_register("mt6397-rtc", &pdev->dev, | 351 | rtc->rtc_dev->ops = &mtk_rtc_ops; |
348 | &mtk_rtc_ops, THIS_MODULE); | 352 | |
349 | if (IS_ERR(rtc->rtc_dev)) { | 353 | ret = rtc_register_device(rtc->rtc_dev); |
354 | if (ret) { | ||
350 | dev_err(&pdev->dev, "register rtc device failed\n"); | 355 | dev_err(&pdev->dev, "register rtc device failed\n"); |
351 | ret = PTR_ERR(rtc->rtc_dev); | ||
352 | goto out_free_irq; | 356 | goto out_free_irq; |
353 | } | 357 | } |
354 | 358 | ||
@@ -365,7 +369,6 @@ static int mtk_rtc_remove(struct platform_device *pdev) | |||
365 | { | 369 | { |
366 | struct mt6397_rtc *rtc = platform_get_drvdata(pdev); | 370 | struct mt6397_rtc *rtc = platform_get_drvdata(pdev); |
367 | 371 | ||
368 | rtc_device_unregister(rtc->rtc_dev); | ||
369 | free_irq(rtc->irq, rtc->rtc_dev); | 372 | free_irq(rtc->irq, rtc->rtc_dev); |
370 | irq_dispose_mapping(rtc->irq); | 373 | irq_dispose_mapping(rtc->irq); |
371 | 374 | ||
diff --git a/drivers/rtc/rtc-mv.c b/drivers/rtc/rtc-mv.c index 4b198b3778d3..e7f14bd12fe3 100644 --- a/drivers/rtc/rtc-mv.c +++ b/drivers/rtc/rtc-mv.c | |||
@@ -125,13 +125,9 @@ static int mv_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm) | |||
125 | /* hw counts from year 2000, but tm_year is relative to 1900 */ | 125 | /* hw counts from year 2000, but tm_year is relative to 1900 */ |
126 | alm->time.tm_year = bcd2bin(year) + 100; | 126 | alm->time.tm_year = bcd2bin(year) + 100; |
127 | 127 | ||
128 | if (rtc_valid_tm(&alm->time) < 0) { | ||
129 | dev_err(dev, "retrieved alarm date/time is not valid.\n"); | ||
130 | rtc_time_to_tm(0, &alm->time); | ||
131 | } | ||
132 | |||
133 | alm->enabled = !!readl(ioaddr + RTC_ALARM_INTERRUPT_MASK_REG_OFFS); | 128 | alm->enabled = !!readl(ioaddr + RTC_ALARM_INTERRUPT_MASK_REG_OFFS); |
134 | return 0; | 129 | |
130 | return rtc_valid_tm(&alm->time); | ||
135 | } | 131 | } |
136 | 132 | ||
137 | static int mv_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) | 133 | static int mv_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) |
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index 323ff55cc165..320b4a520eb3 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c | |||
@@ -421,12 +421,6 @@ static struct omap_rtc *omap_rtc_power_off_rtc; | |||
421 | * The RTC can be used to control an external PMIC via the pmic_power_en pin, | 421 | * The RTC can be used to control an external PMIC via the pmic_power_en pin, |
422 | * which can be configured to transition to OFF on ALARM2 events. | 422 | * which can be configured to transition to OFF on ALARM2 events. |
423 | * | 423 | * |
424 | * Notes: | ||
425 | * The two-second alarm offset is the shortest offset possible as the alarm | ||
426 | * registers must be set before the next timer update and the offset | ||
427 | * calculation is too heavy for everything to be done within a single access | ||
428 | * period (~15 us). | ||
429 | * | ||
430 | * Called with local interrupts disabled. | 424 | * Called with local interrupts disabled. |
431 | */ | 425 | */ |
432 | static void omap_rtc_power_off(void) | 426 | static void omap_rtc_power_off(void) |
@@ -434,6 +428,7 @@ static void omap_rtc_power_off(void) | |||
434 | struct omap_rtc *rtc = omap_rtc_power_off_rtc; | 428 | struct omap_rtc *rtc = omap_rtc_power_off_rtc; |
435 | struct rtc_time tm; | 429 | struct rtc_time tm; |
436 | unsigned long now; | 430 | unsigned long now; |
431 | int seconds; | ||
437 | u32 val; | 432 | u32 val; |
438 | 433 | ||
439 | rtc->type->unlock(rtc); | 434 | rtc->type->unlock(rtc); |
@@ -441,11 +436,13 @@ static void omap_rtc_power_off(void) | |||
441 | val = rtc_readl(rtc, OMAP_RTC_PMIC_REG); | 436 | val = rtc_readl(rtc, OMAP_RTC_PMIC_REG); |
442 | rtc_writel(rtc, OMAP_RTC_PMIC_REG, val | OMAP_RTC_PMIC_POWER_EN_EN); | 437 | rtc_writel(rtc, OMAP_RTC_PMIC_REG, val | OMAP_RTC_PMIC_POWER_EN_EN); |
443 | 438 | ||
444 | /* set alarm two seconds from now */ | 439 | again: |
440 | /* set alarm one second from now */ | ||
445 | omap_rtc_read_time_raw(rtc, &tm); | 441 | omap_rtc_read_time_raw(rtc, &tm); |
442 | seconds = tm.tm_sec; | ||
446 | bcd2tm(&tm); | 443 | bcd2tm(&tm); |
447 | rtc_tm_to_time(&tm, &now); | 444 | rtc_tm_to_time(&tm, &now); |
448 | rtc_time_to_tm(now + 2, &tm); | 445 | rtc_time_to_tm(now + 1, &tm); |
449 | 446 | ||
450 | if (tm2bcd(&tm) < 0) { | 447 | if (tm2bcd(&tm) < 0) { |
451 | dev_err(&rtc->rtc->dev, "power off failed\n"); | 448 | dev_err(&rtc->rtc->dev, "power off failed\n"); |
@@ -470,14 +467,22 @@ static void omap_rtc_power_off(void) | |||
470 | val = rtc_read(rtc, OMAP_RTC_INTERRUPTS_REG); | 467 | val = rtc_read(rtc, OMAP_RTC_INTERRUPTS_REG); |
471 | rtc_writel(rtc, OMAP_RTC_INTERRUPTS_REG, | 468 | rtc_writel(rtc, OMAP_RTC_INTERRUPTS_REG, |
472 | val | OMAP_RTC_INTERRUPTS_IT_ALARM2); | 469 | val | OMAP_RTC_INTERRUPTS_IT_ALARM2); |
470 | |||
471 | /* Retry in case roll over happened before alarm was armed. */ | ||
472 | if (rtc_read(rtc, OMAP_RTC_SECONDS_REG) != seconds) { | ||
473 | val = rtc_read(rtc, OMAP_RTC_STATUS_REG); | ||
474 | if (!(val & OMAP_RTC_STATUS_ALARM2)) | ||
475 | goto again; | ||
476 | } | ||
477 | |||
473 | rtc->type->lock(rtc); | 478 | rtc->type->lock(rtc); |
474 | 479 | ||
475 | /* | 480 | /* |
476 | * Wait for alarm to trigger (within two seconds) and external PMIC to | 481 | * Wait for alarm to trigger (within one second) and external PMIC to |
477 | * power off the system. Add a 500 ms margin for external latencies | 482 | * power off the system. Add a 500 ms margin for external latencies |
478 | * (e.g. debounce circuits). | 483 | * (e.g. debounce circuits). |
479 | */ | 484 | */ |
480 | mdelay(2500); | 485 | mdelay(1500); |
481 | } | 486 | } |
482 | 487 | ||
483 | static const struct rtc_class_ops omap_rtc_ops = { | 488 | static const struct rtc_class_ops omap_rtc_ops = { |
@@ -721,8 +726,7 @@ static int omap_rtc_probe(struct platform_device *pdev) | |||
721 | if (of_id) { | 726 | if (of_id) { |
722 | rtc->type = of_id->data; | 727 | rtc->type = of_id->data; |
723 | rtc->is_pmic_controller = rtc->type->has_pmic_mode && | 728 | rtc->is_pmic_controller = rtc->type->has_pmic_mode && |
724 | of_property_read_bool(pdev->dev.of_node, | 729 | of_device_is_system_power_controller(pdev->dev.of_node); |
725 | "system-power-controller"); | ||
726 | } else { | 730 | } else { |
727 | id_entry = platform_get_device_id(pdev); | 731 | id_entry = platform_get_device_id(pdev); |
728 | rtc->type = (void *)id_entry->driver_data; | 732 | rtc->type = (void *)id_entry->driver_data; |
diff --git a/drivers/rtc/rtc-pl030.c b/drivers/rtc/rtc-pl030.c index f85a1a93e669..343bb6ed1783 100644 --- a/drivers/rtc/rtc-pl030.c +++ b/drivers/rtc/rtc-pl030.c | |||
@@ -112,6 +112,13 @@ static int pl030_probe(struct amba_device *dev, const struct amba_id *id) | |||
112 | goto err_rtc; | 112 | goto err_rtc; |
113 | } | 113 | } |
114 | 114 | ||
115 | rtc->rtc = devm_rtc_allocate_device(&dev->dev); | ||
116 | if (IS_ERR(rtc->rtc)) { | ||
117 | ret = PTR_ERR(rtc->rtc); | ||
118 | goto err_rtc; | ||
119 | } | ||
120 | |||
121 | rtc->rtc->ops = &pl030_ops; | ||
115 | rtc->base = ioremap(dev->res.start, resource_size(&dev->res)); | 122 | rtc->base = ioremap(dev->res.start, resource_size(&dev->res)); |
116 | if (!rtc->base) { | 123 | if (!rtc->base) { |
117 | ret = -ENOMEM; | 124 | ret = -ENOMEM; |
@@ -128,12 +135,9 @@ static int pl030_probe(struct amba_device *dev, const struct amba_id *id) | |||
128 | if (ret) | 135 | if (ret) |
129 | goto err_irq; | 136 | goto err_irq; |
130 | 137 | ||
131 | rtc->rtc = rtc_device_register("pl030", &dev->dev, &pl030_ops, | 138 | ret = rtc_register_device(rtc->rtc); |
132 | THIS_MODULE); | 139 | if (ret) |
133 | if (IS_ERR(rtc->rtc)) { | ||
134 | ret = PTR_ERR(rtc->rtc); | ||
135 | goto err_reg; | 140 | goto err_reg; |
136 | } | ||
137 | 141 | ||
138 | return 0; | 142 | return 0; |
139 | 143 | ||
@@ -154,7 +158,6 @@ static int pl030_remove(struct amba_device *dev) | |||
154 | writel(0, rtc->base + RTC_CR); | 158 | writel(0, rtc->base + RTC_CR); |
155 | 159 | ||
156 | free_irq(dev->irq[0], rtc); | 160 | free_irq(dev->irq[0], rtc); |
157 | rtc_device_unregister(rtc->rtc); | ||
158 | iounmap(rtc->base); | 161 | iounmap(rtc->base); |
159 | amba_release_regions(dev); | 162 | amba_release_regions(dev); |
160 | 163 | ||
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c index 82eb7da2c478..30943d200c5e 100644 --- a/drivers/rtc/rtc-pl031.c +++ b/drivers/rtc/rtc-pl031.c | |||
@@ -310,7 +310,6 @@ static int pl031_remove(struct amba_device *adev) | |||
310 | device_init_wakeup(&adev->dev, false); | 310 | device_init_wakeup(&adev->dev, false); |
311 | if (adev->irq[0]) | 311 | if (adev->irq[0]) |
312 | free_irq(adev->irq[0], ldata); | 312 | free_irq(adev->irq[0], ldata); |
313 | rtc_device_unregister(ldata->rtc); | ||
314 | amba_release_regions(adev); | 313 | amba_release_regions(adev); |
315 | 314 | ||
316 | return 0; | 315 | return 0; |
@@ -383,24 +382,25 @@ static int pl031_probe(struct amba_device *adev, const struct amba_id *id) | |||
383 | } | 382 | } |
384 | 383 | ||
385 | device_init_wakeup(&adev->dev, true); | 384 | device_init_wakeup(&adev->dev, true); |
386 | ldata->rtc = rtc_device_register("pl031", &adev->dev, ops, | 385 | ldata->rtc = devm_rtc_allocate_device(&adev->dev); |
387 | THIS_MODULE); | 386 | if (IS_ERR(ldata->rtc)) |
388 | if (IS_ERR(ldata->rtc)) { | 387 | return PTR_ERR(ldata->rtc); |
389 | ret = PTR_ERR(ldata->rtc); | 388 | |
389 | ldata->rtc->ops = ops; | ||
390 | |||
391 | ret = rtc_register_device(ldata->rtc); | ||
392 | if (ret) | ||
390 | goto out; | 393 | goto out; |
391 | } | ||
392 | 394 | ||
393 | if (adev->irq[0]) { | 395 | if (adev->irq[0]) { |
394 | ret = request_irq(adev->irq[0], pl031_interrupt, | 396 | ret = request_irq(adev->irq[0], pl031_interrupt, |
395 | vendor->irqflags, "rtc-pl031", ldata); | 397 | vendor->irqflags, "rtc-pl031", ldata); |
396 | if (ret) | 398 | if (ret) |
397 | goto out_no_irq; | 399 | goto out; |
398 | dev_pm_set_wake_irq(&adev->dev, adev->irq[0]); | 400 | dev_pm_set_wake_irq(&adev->dev, adev->irq[0]); |
399 | } | 401 | } |
400 | return 0; | 402 | return 0; |
401 | 403 | ||
402 | out_no_irq: | ||
403 | rtc_device_unregister(ldata->rtc); | ||
404 | out: | 404 | out: |
405 | amba_release_regions(adev); | 405 | amba_release_regions(adev); |
406 | err_req: | 406 | err_req: |
diff --git a/drivers/rtc/rtc-rs5c348.c b/drivers/rtc/rtc-rs5c348.c index f2de8b17e7e3..6582be707bd0 100644 --- a/drivers/rtc/rtc-rs5c348.c +++ b/drivers/rtc/rtc-rs5c348.c | |||
@@ -66,6 +66,17 @@ rs5c348_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
66 | u8 txbuf[5+7], *txp; | 66 | u8 txbuf[5+7], *txp; |
67 | int ret; | 67 | int ret; |
68 | 68 | ||
69 | ret = spi_w8r8(spi, RS5C348_CMD_R(RS5C348_REG_CTL2)); | ||
70 | if (ret < 0) | ||
71 | return ret; | ||
72 | if (ret & RS5C348_BIT_XSTP) { | ||
73 | txbuf[0] = RS5C348_CMD_W(RS5C348_REG_CTL2); | ||
74 | txbuf[1] = 0; | ||
75 | ret = spi_write_then_read(spi, txbuf, 2, NULL, 0); | ||
76 | if (ret < 0) | ||
77 | return ret; | ||
78 | } | ||
79 | |||
69 | /* Transfer 5 bytes before writing SEC. This gives 31us for carry. */ | 80 | /* Transfer 5 bytes before writing SEC. This gives 31us for carry. */ |
70 | txp = txbuf; | 81 | txp = txbuf; |
71 | txbuf[0] = RS5C348_CMD_R(RS5C348_REG_CTL2); /* cmd, ctl2 */ | 82 | txbuf[0] = RS5C348_CMD_R(RS5C348_REG_CTL2); /* cmd, ctl2 */ |
@@ -102,6 +113,16 @@ rs5c348_rtc_read_time(struct device *dev, struct rtc_time *tm) | |||
102 | u8 txbuf[5], rxbuf[7]; | 113 | u8 txbuf[5], rxbuf[7]; |
103 | int ret; | 114 | int ret; |
104 | 115 | ||
116 | ret = spi_w8r8(spi, RS5C348_CMD_R(RS5C348_REG_CTL2)); | ||
117 | if (ret < 0) | ||
118 | return ret; | ||
119 | if (ret & RS5C348_BIT_VDET) | ||
120 | dev_warn(&spi->dev, "voltage-low detected.\n"); | ||
121 | if (ret & RS5C348_BIT_XSTP) { | ||
122 | dev_warn(&spi->dev, "oscillator-stop detected.\n"); | ||
123 | return -EINVAL; | ||
124 | } | ||
125 | |||
105 | /* Transfer 5 byte befores reading SEC. This gives 31us for carry. */ | 126 | /* Transfer 5 byte befores reading SEC. This gives 31us for carry. */ |
106 | txbuf[0] = RS5C348_CMD_R(RS5C348_REG_CTL2); /* cmd, ctl2 */ | 127 | txbuf[0] = RS5C348_CMD_R(RS5C348_REG_CTL2); /* cmd, ctl2 */ |
107 | txbuf[1] = 0; /* dummy */ | 128 | txbuf[1] = 0; /* dummy */ |
@@ -143,8 +164,6 @@ static const struct rtc_class_ops rs5c348_rtc_ops = { | |||
143 | .set_time = rs5c348_rtc_set_time, | 164 | .set_time = rs5c348_rtc_set_time, |
144 | }; | 165 | }; |
145 | 166 | ||
146 | static struct spi_driver rs5c348_driver; | ||
147 | |||
148 | static int rs5c348_probe(struct spi_device *spi) | 167 | static int rs5c348_probe(struct spi_device *spi) |
149 | { | 168 | { |
150 | int ret; | 169 | int ret; |
@@ -161,53 +180,27 @@ static int rs5c348_probe(struct spi_device *spi) | |||
161 | ret = spi_w8r8(spi, RS5C348_CMD_R(RS5C348_REG_SECS)); | 180 | ret = spi_w8r8(spi, RS5C348_CMD_R(RS5C348_REG_SECS)); |
162 | if (ret < 0 || (ret & 0x80)) { | 181 | if (ret < 0 || (ret & 0x80)) { |
163 | dev_err(&spi->dev, "not found.\n"); | 182 | dev_err(&spi->dev, "not found.\n"); |
164 | goto kfree_exit; | 183 | return ret; |
165 | } | 184 | } |
166 | 185 | ||
167 | dev_info(&spi->dev, "spiclk %u KHz.\n", | 186 | dev_info(&spi->dev, "spiclk %u KHz.\n", |
168 | (spi->max_speed_hz + 500) / 1000); | 187 | (spi->max_speed_hz + 500) / 1000); |
169 | 188 | ||
170 | /* turn RTC on if it was not on */ | ||
171 | ret = spi_w8r8(spi, RS5C348_CMD_R(RS5C348_REG_CTL2)); | ||
172 | if (ret < 0) | ||
173 | goto kfree_exit; | ||
174 | if (ret & (RS5C348_BIT_XSTP | RS5C348_BIT_VDET)) { | ||
175 | u8 buf[2]; | ||
176 | struct rtc_time tm; | ||
177 | if (ret & RS5C348_BIT_VDET) | ||
178 | dev_warn(&spi->dev, "voltage-low detected.\n"); | ||
179 | if (ret & RS5C348_BIT_XSTP) | ||
180 | dev_warn(&spi->dev, "oscillator-stop detected.\n"); | ||
181 | rtc_time_to_tm(0, &tm); /* 1970/1/1 */ | ||
182 | ret = rs5c348_rtc_set_time(&spi->dev, &tm); | ||
183 | if (ret < 0) | ||
184 | goto kfree_exit; | ||
185 | buf[0] = RS5C348_CMD_W(RS5C348_REG_CTL2); | ||
186 | buf[1] = 0; | ||
187 | ret = spi_write_then_read(spi, buf, sizeof(buf), NULL, 0); | ||
188 | if (ret < 0) | ||
189 | goto kfree_exit; | ||
190 | } | ||
191 | |||
192 | ret = spi_w8r8(spi, RS5C348_CMD_R(RS5C348_REG_CTL1)); | 189 | ret = spi_w8r8(spi, RS5C348_CMD_R(RS5C348_REG_CTL1)); |
193 | if (ret < 0) | 190 | if (ret < 0) |
194 | goto kfree_exit; | 191 | return ret; |
195 | if (ret & RS5C348_BIT_24H) | 192 | if (ret & RS5C348_BIT_24H) |
196 | pdata->rtc_24h = 1; | 193 | pdata->rtc_24h = 1; |
197 | 194 | ||
198 | rtc = devm_rtc_device_register(&spi->dev, rs5c348_driver.driver.name, | 195 | rtc = devm_rtc_allocate_device(&spi->dev); |
199 | &rs5c348_rtc_ops, THIS_MODULE); | 196 | if (IS_ERR(rtc)) |
200 | 197 | return PTR_ERR(rtc); | |
201 | if (IS_ERR(rtc)) { | ||
202 | ret = PTR_ERR(rtc); | ||
203 | goto kfree_exit; | ||
204 | } | ||
205 | 198 | ||
206 | pdata->rtc = rtc; | 199 | pdata->rtc = rtc; |
207 | 200 | ||
208 | return 0; | 201 | rtc->ops = &rs5c348_rtc_ops; |
209 | kfree_exit: | 202 | |
210 | return ret; | 203 | return rtc_register_device(rtc); |
211 | } | 204 | } |
212 | 205 | ||
213 | static struct spi_driver rs5c348_driver = { | 206 | static struct spi_driver rs5c348_driver = { |
diff --git a/drivers/rtc/rtc-rv8803.c b/drivers/rtc/rtc-rv8803.c index 29fc3d210392..450a0b831a2d 100644 --- a/drivers/rtc/rtc-rv8803.c +++ b/drivers/rtc/rtc-rv8803.c | |||
@@ -615,6 +615,7 @@ static int rv8803_probe(struct i2c_client *client, | |||
615 | 615 | ||
616 | static const struct i2c_device_id rv8803_id[] = { | 616 | static const struct i2c_device_id rv8803_id[] = { |
617 | { "rv8803", rv_8803 }, | 617 | { "rv8803", rv_8803 }, |
618 | { "rx8803", rv_8803 }, | ||
618 | { "rx8900", rx_8900 }, | 619 | { "rx8900", rx_8900 }, |
619 | { } | 620 | { } |
620 | }; | 621 | }; |
@@ -623,7 +624,11 @@ MODULE_DEVICE_TABLE(i2c, rv8803_id); | |||
623 | static const struct of_device_id rv8803_of_match[] = { | 624 | static const struct of_device_id rv8803_of_match[] = { |
624 | { | 625 | { |
625 | .compatible = "microcrystal,rv8803", | 626 | .compatible = "microcrystal,rv8803", |
626 | .data = (void *)rx_8900 | 627 | .data = (void *)rv_8803 |
628 | }, | ||
629 | { | ||
630 | .compatible = "epson,rx8803", | ||
631 | .data = (void *)rv_8803 | ||
627 | }, | 632 | }, |
628 | { | 633 | { |
629 | .compatible = "epson,rx8900", | 634 | .compatible = "epson,rx8900", |
diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c index 77feb603cd4c..3c64dbb08109 100644 --- a/drivers/rtc/rtc-s35390a.c +++ b/drivers/rtc/rtc-s35390a.c | |||
@@ -108,7 +108,7 @@ static int s35390a_get_reg(struct s35390a *s35390a, int reg, char *buf, int len) | |||
108 | 108 | ||
109 | static int s35390a_init(struct s35390a *s35390a) | 109 | static int s35390a_init(struct s35390a *s35390a) |
110 | { | 110 | { |
111 | char buf; | 111 | u8 buf; |
112 | int ret; | 112 | int ret; |
113 | unsigned initcount = 0; | 113 | unsigned initcount = 0; |
114 | 114 | ||
diff --git a/drivers/rtc/rtc-sc27xx.c b/drivers/rtc/rtc-sc27xx.c index deea5c3726ad..b4eb3b3c6c2c 100644 --- a/drivers/rtc/rtc-sc27xx.c +++ b/drivers/rtc/rtc-sc27xx.c | |||
@@ -129,19 +129,6 @@ static int sprd_rtc_clear_alarm_ints(struct sprd_rtc *rtc) | |||
129 | SPRD_RTC_ALM_INT_MASK); | 129 | SPRD_RTC_ALM_INT_MASK); |
130 | } | 130 | } |
131 | 131 | ||
132 | static int sprd_rtc_disable_ints(struct sprd_rtc *rtc) | ||
133 | { | ||
134 | int ret; | ||
135 | |||
136 | ret = regmap_update_bits(rtc->regmap, rtc->base + SPRD_RTC_INT_EN, | ||
137 | SPRD_RTC_INT_MASK, 0); | ||
138 | if (ret) | ||
139 | return ret; | ||
140 | |||
141 | return regmap_write(rtc->regmap, rtc->base + SPRD_RTC_INT_CLR, | ||
142 | SPRD_RTC_INT_MASK); | ||
143 | } | ||
144 | |||
145 | static int sprd_rtc_lock_alarm(struct sprd_rtc *rtc, bool lock) | 132 | static int sprd_rtc_lock_alarm(struct sprd_rtc *rtc, bool lock) |
146 | { | 133 | { |
147 | int ret; | 134 | int ret; |
@@ -172,7 +159,8 @@ static int sprd_rtc_lock_alarm(struct sprd_rtc *rtc, bool lock) | |||
172 | return ret; | 159 | return ret; |
173 | } | 160 | } |
174 | 161 | ||
175 | return 0; | 162 | return regmap_write(rtc->regmap, rtc->base + SPRD_RTC_INT_CLR, |
163 | SPRD_RTC_SPG_UPD_EN); | ||
176 | } | 164 | } |
177 | 165 | ||
178 | static int sprd_rtc_get_secs(struct sprd_rtc *rtc, enum sprd_rtc_reg_types type, | 166 | static int sprd_rtc_get_secs(struct sprd_rtc *rtc, enum sprd_rtc_reg_types type, |
@@ -427,10 +415,14 @@ static int sprd_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
427 | u32 val; | 415 | u32 val; |
428 | 416 | ||
429 | /* | 417 | /* |
430 | * If aie_timer is enabled, we should get the normal alarm time. | 418 | * Before RTC device is registered, it will check to see if there is an |
419 | * alarm already set in RTC hardware, and we always read the normal | ||
420 | * alarm at this time. | ||
421 | * | ||
422 | * Or if aie_timer is enabled, we should get the normal alarm time. | ||
431 | * Otherwise we should get auxiliary alarm time. | 423 | * Otherwise we should get auxiliary alarm time. |
432 | */ | 424 | */ |
433 | if (rtc->rtc && rtc->rtc->aie_timer.enabled == 0) | 425 | if (rtc->rtc && rtc->rtc->registered && rtc->rtc->aie_timer.enabled == 0) |
434 | return sprd_rtc_read_aux_alarm(dev, alrm); | 426 | return sprd_rtc_read_aux_alarm(dev, alrm); |
435 | 427 | ||
436 | ret = sprd_rtc_get_secs(rtc, SPRD_RTC_ALARM, &secs); | 428 | ret = sprd_rtc_get_secs(rtc, SPRD_RTC_ALARM, &secs); |
@@ -575,6 +567,32 @@ static int sprd_rtc_check_power_down(struct sprd_rtc *rtc) | |||
575 | return 0; | 567 | return 0; |
576 | } | 568 | } |
577 | 569 | ||
570 | static int sprd_rtc_check_alarm_int(struct sprd_rtc *rtc) | ||
571 | { | ||
572 | u32 val; | ||
573 | int ret; | ||
574 | |||
575 | ret = regmap_read(rtc->regmap, rtc->base + SPRD_RTC_SPG_VALUE, &val); | ||
576 | if (ret) | ||
577 | return ret; | ||
578 | |||
579 | /* | ||
580 | * The SPRD_RTC_INT_EN register is not put in always-power-on region | ||
581 | * supplied by VDDRTC, so we should check if we need enable the alarm | ||
582 | * interrupt when system booting. | ||
583 | * | ||
584 | * If we have set SPRD_RTC_POWEROFF_ALM_FLAG which is saved in | ||
585 | * always-power-on region, that means we have set one alarm last time, | ||
586 | * so we should enable the alarm interrupt to help RTC core to see if | ||
587 | * there is an alarm already set in RTC hardware. | ||
588 | */ | ||
589 | if (!(val & SPRD_RTC_POWEROFF_ALM_FLAG)) | ||
590 | return 0; | ||
591 | |||
592 | return regmap_update_bits(rtc->regmap, rtc->base + SPRD_RTC_INT_EN, | ||
593 | SPRD_RTC_ALARM_EN, SPRD_RTC_ALARM_EN); | ||
594 | } | ||
595 | |||
578 | static int sprd_rtc_probe(struct platform_device *pdev) | 596 | static int sprd_rtc_probe(struct platform_device *pdev) |
579 | { | 597 | { |
580 | struct device_node *node = pdev->dev.of_node; | 598 | struct device_node *node = pdev->dev.of_node; |
@@ -608,10 +626,10 @@ static int sprd_rtc_probe(struct platform_device *pdev) | |||
608 | rtc->dev = &pdev->dev; | 626 | rtc->dev = &pdev->dev; |
609 | platform_set_drvdata(pdev, rtc); | 627 | platform_set_drvdata(pdev, rtc); |
610 | 628 | ||
611 | /* clear all RTC interrupts and disable all RTC interrupts */ | 629 | /* check if we need set the alarm interrupt */ |
612 | ret = sprd_rtc_disable_ints(rtc); | 630 | ret = sprd_rtc_check_alarm_int(rtc); |
613 | if (ret) { | 631 | if (ret) { |
614 | dev_err(&pdev->dev, "failed to disable RTC interrupts\n"); | 632 | dev_err(&pdev->dev, "failed to check RTC alarm interrupt\n"); |
615 | return ret; | 633 | return ret; |
616 | } | 634 | } |
617 | 635 | ||
@@ -631,16 +649,18 @@ static int sprd_rtc_probe(struct platform_device *pdev) | |||
631 | return ret; | 649 | return ret; |
632 | } | 650 | } |
633 | 651 | ||
652 | device_init_wakeup(&pdev->dev, 1); | ||
653 | |||
634 | rtc->rtc->ops = &sprd_rtc_ops; | 654 | rtc->rtc->ops = &sprd_rtc_ops; |
635 | rtc->rtc->range_min = 0; | 655 | rtc->rtc->range_min = 0; |
636 | rtc->rtc->range_max = 5662310399LL; | 656 | rtc->rtc->range_max = 5662310399LL; |
637 | ret = rtc_register_device(rtc->rtc); | 657 | ret = rtc_register_device(rtc->rtc); |
638 | if (ret) { | 658 | if (ret) { |
639 | dev_err(&pdev->dev, "failed to register rtc device\n"); | 659 | dev_err(&pdev->dev, "failed to register rtc device\n"); |
660 | device_init_wakeup(&pdev->dev, 0); | ||
640 | return ret; | 661 | return ret; |
641 | } | 662 | } |
642 | 663 | ||
643 | device_init_wakeup(&pdev->dev, 1); | ||
644 | return 0; | 664 | return 0; |
645 | } | 665 | } |
646 | 666 | ||
diff --git a/drivers/rtc/rtc-sun6i.c b/drivers/rtc/rtc-sun6i.c index 2cd5a7b1a2e3..fe07310952df 100644 --- a/drivers/rtc/rtc-sun6i.c +++ b/drivers/rtc/rtc-sun6i.c | |||
@@ -199,8 +199,7 @@ static void __init sun6i_rtc_clk_init(struct device_node *node) | |||
199 | if (!rtc) | 199 | if (!rtc) |
200 | return; | 200 | return; |
201 | 201 | ||
202 | clk_data = kzalloc(sizeof(*clk_data) + (sizeof(*clk_data->hws) * 2), | 202 | clk_data = kzalloc(struct_size(clk_data, hws, 2), GFP_KERNEL); |
203 | GFP_KERNEL); | ||
204 | if (!clk_data) { | 203 | if (!clk_data) { |
205 | kfree(rtc); | 204 | kfree(rtc); |
206 | return; | 205 | return; |
diff --git a/drivers/rtc/rtc-sysfs.c b/drivers/rtc/rtc-sysfs.c index f1ff30ade534..9746c32eee2e 100644 --- a/drivers/rtc/rtc-sysfs.c +++ b/drivers/rtc/rtc-sysfs.c | |||
@@ -338,8 +338,8 @@ int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group **grps) | |||
338 | 338 | ||
339 | new_cnt = old_cnt + add_cnt + 1; | 339 | new_cnt = old_cnt + add_cnt + 1; |
340 | groups = devm_kcalloc(&rtc->dev, new_cnt, sizeof(*groups), GFP_KERNEL); | 340 | groups = devm_kcalloc(&rtc->dev, new_cnt, sizeof(*groups), GFP_KERNEL); |
341 | if (IS_ERR_OR_NULL(groups)) | 341 | if (!groups) |
342 | return PTR_ERR(groups); | 342 | return -ENOMEM; |
343 | memcpy(groups, rtc->dev.groups, old_cnt * sizeof(*groups)); | 343 | memcpy(groups, rtc->dev.groups, old_cnt * sizeof(*groups)); |
344 | memcpy(groups + old_cnt, grps, add_cnt * sizeof(*groups)); | 344 | memcpy(groups + old_cnt, grps, add_cnt * sizeof(*groups)); |
345 | groups[old_cnt + add_cnt] = NULL; | 345 | groups[old_cnt + add_cnt] = NULL; |
diff --git a/drivers/rtc/rtc-tegra.c b/drivers/rtc/rtc-tegra.c index 8dc48fe7fc35..c9e77a83cd1b 100644 --- a/drivers/rtc/rtc-tegra.c +++ b/drivers/rtc/rtc-tegra.c | |||
@@ -322,9 +322,13 @@ static int __init tegra_rtc_probe(struct platform_device *pdev) | |||
322 | if (IS_ERR(info->rtc_base)) | 322 | if (IS_ERR(info->rtc_base)) |
323 | return PTR_ERR(info->rtc_base); | 323 | return PTR_ERR(info->rtc_base); |
324 | 324 | ||
325 | info->tegra_rtc_irq = platform_get_irq(pdev, 0); | 325 | ret = platform_get_irq(pdev, 0); |
326 | if (info->tegra_rtc_irq <= 0) | 326 | if (ret <= 0) { |
327 | return -EBUSY; | 327 | dev_err(&pdev->dev, "failed to get platform IRQ: %d\n", ret); |
328 | return ret; | ||
329 | } | ||
330 | |||
331 | info->tegra_rtc_irq = ret; | ||
328 | 332 | ||
329 | info->clk = devm_clk_get(&pdev->dev, NULL); | 333 | info->clk = devm_clk_get(&pdev->dev, NULL); |
330 | if (IS_ERR(info->clk)) | 334 | if (IS_ERR(info->clk)) |
diff --git a/drivers/rtc/rtc-test.c b/drivers/rtc/rtc-test.c index ade6a82709be..6c5f09c815e8 100644 --- a/drivers/rtc/rtc-test.c +++ b/drivers/rtc/rtc-test.c | |||
@@ -1,11 +1,8 @@ | |||
1 | // SPDX-License-Identifier: GPL-2.0 | ||
1 | /* | 2 | /* |
2 | * An RTC test device/driver | 3 | * An RTC test device/driver |
3 | * Copyright (C) 2005 Tower Technologies | 4 | * Copyright (C) 2005 Tower Technologies |
4 | * Author: Alessandro Zummo <a.zummo@towertech.it> | 5 | * Author: Alessandro Zummo <a.zummo@towertech.it> |
5 | * | ||
6 | * This program is free software; you can redistribute it and/or modify | ||
7 | * it under the terms of the GNU General Public License version 2 as | ||
8 | * published by the Free Software Foundation. | ||
9 | */ | 6 | */ |
10 | 7 | ||
11 | #include <linux/module.h> | 8 | #include <linux/module.h> |
@@ -197,7 +194,7 @@ static void __exit test_exit(void) | |||
197 | 194 | ||
198 | MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>"); | 195 | MODULE_AUTHOR("Alessandro Zummo <a.zummo@towertech.it>"); |
199 | MODULE_DESCRIPTION("RTC test driver/device"); | 196 | MODULE_DESCRIPTION("RTC test driver/device"); |
200 | MODULE_LICENSE("GPL"); | 197 | MODULE_LICENSE("GPL v2"); |
201 | 198 | ||
202 | module_init(test_init); | 199 | module_init(test_init); |
203 | module_exit(test_exit); | 200 | module_exit(test_exit); |
diff --git a/drivers/rtc/rtc-tx4939.c b/drivers/rtc/rtc-tx4939.c index 08dbefc79520..61c110b2045f 100644 --- a/drivers/rtc/rtc-tx4939.c +++ b/drivers/rtc/rtc-tx4939.c | |||
@@ -253,9 +253,7 @@ static int __init tx4939_rtc_probe(struct platform_device *pdev) | |||
253 | struct resource *res; | 253 | struct resource *res; |
254 | int irq, ret; | 254 | int irq, ret; |
255 | struct nvmem_config nvmem_cfg = { | 255 | struct nvmem_config nvmem_cfg = { |
256 | .name = "rv8803_nvram", | 256 | .name = "tx4939_nvram", |
257 | .word_size = 4, | ||
258 | .stride = 4, | ||
259 | .size = TX4939_RTC_REG_RAMSIZE, | 257 | .size = TX4939_RTC_REG_RAMSIZE, |
260 | .reg_read = tx4939_nvram_read, | 258 | .reg_read = tx4939_nvram_read, |
261 | .reg_write = tx4939_nvram_write, | 259 | .reg_write = tx4939_nvram_write, |
diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c index 70f013e692b0..e66d0f63cee2 100644 --- a/drivers/rtc/rtc-vr41xx.c +++ b/drivers/rtc/rtc-vr41xx.c | |||
@@ -136,8 +136,7 @@ static int vr41xx_rtc_set_time(struct device *dev, struct rtc_time *time) | |||
136 | time64_t epoch_sec, current_sec; | 136 | time64_t epoch_sec, current_sec; |
137 | 137 | ||
138 | epoch_sec = mktime64(epoch, 1, 1, 0, 0, 0); | 138 | epoch_sec = mktime64(epoch, 1, 1, 0, 0, 0); |
139 | current_sec = mktime64(time->tm_year + 1900, time->tm_mon + 1, time->tm_mday, | 139 | current_sec = rtc_tm_to_time64(time); |
140 | time->tm_hour, time->tm_min, time->tm_sec); | ||
141 | 140 | ||
142 | write_elapsed_second(current_sec - epoch_sec); | 141 | write_elapsed_second(current_sec - epoch_sec); |
143 | 142 | ||
@@ -158,7 +157,7 @@ static int vr41xx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) | |||
158 | 157 | ||
159 | spin_unlock_irq(&rtc_lock); | 158 | spin_unlock_irq(&rtc_lock); |
160 | 159 | ||
161 | rtc_time_to_tm((high << 17) | (mid << 1) | (low >> 15), time); | 160 | rtc_time64_to_tm((high << 17) | (mid << 1) | (low >> 15), time); |
162 | 161 | ||
163 | return 0; | 162 | return 0; |
164 | } | 163 | } |
@@ -166,10 +165,8 @@ static int vr41xx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) | |||
166 | static int vr41xx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) | 165 | static int vr41xx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) |
167 | { | 166 | { |
168 | time64_t alarm_sec; | 167 | time64_t alarm_sec; |
169 | struct rtc_time *time = &wkalrm->time; | ||
170 | 168 | ||
171 | alarm_sec = mktime64(time->tm_year + 1900, time->tm_mon + 1, time->tm_mday, | 169 | alarm_sec = rtc_tm_to_time64(&wkalrm->time); |
172 | time->tm_hour, time->tm_min, time->tm_sec); | ||
173 | 170 | ||
174 | spin_lock_irq(&rtc_lock); | 171 | spin_lock_irq(&rtc_lock); |
175 | 172 | ||
diff --git a/include/linux/rtc.h b/include/linux/rtc.h index 6aedc30003e7..c8bb4a2b48c3 100644 --- a/include/linux/rtc.h +++ b/include/linux/rtc.h | |||
@@ -167,17 +167,12 @@ struct rtc_device { | |||
167 | #define RTC_TIMESTAMP_BEGIN_2000 946684800LL /* 2000-01-01 00:00:00 */ | 167 | #define RTC_TIMESTAMP_BEGIN_2000 946684800LL /* 2000-01-01 00:00:00 */ |
168 | #define RTC_TIMESTAMP_END_2099 4102444799LL /* 2099-12-31 23:59:59 */ | 168 | #define RTC_TIMESTAMP_END_2099 4102444799LL /* 2099-12-31 23:59:59 */ |
169 | 169 | ||
170 | extern struct rtc_device *rtc_device_register(const char *name, | ||
171 | struct device *dev, | ||
172 | const struct rtc_class_ops *ops, | ||
173 | struct module *owner); | ||
174 | extern struct rtc_device *devm_rtc_device_register(struct device *dev, | 170 | extern struct rtc_device *devm_rtc_device_register(struct device *dev, |
175 | const char *name, | 171 | const char *name, |
176 | const struct rtc_class_ops *ops, | 172 | const struct rtc_class_ops *ops, |
177 | struct module *owner); | 173 | struct module *owner); |
178 | struct rtc_device *devm_rtc_allocate_device(struct device *dev); | 174 | struct rtc_device *devm_rtc_allocate_device(struct device *dev); |
179 | int __rtc_register_device(struct module *owner, struct rtc_device *rtc); | 175 | int __rtc_register_device(struct module *owner, struct rtc_device *rtc); |
180 | extern void rtc_device_unregister(struct rtc_device *rtc); | ||
181 | extern void devm_rtc_device_unregister(struct device *dev, | 176 | extern void devm_rtc_device_unregister(struct device *dev, |
182 | struct rtc_device *rtc); | 177 | struct rtc_device *rtc); |
183 | 178 | ||
@@ -277,4 +272,20 @@ static inline int rtc_nvmem_register(struct rtc_device *rtc, | |||
277 | static inline void rtc_nvmem_unregister(struct rtc_device *rtc) {} | 272 | static inline void rtc_nvmem_unregister(struct rtc_device *rtc) {} |
278 | #endif | 273 | #endif |
279 | 274 | ||
275 | #ifdef CONFIG_RTC_INTF_SYSFS | ||
276 | int rtc_add_group(struct rtc_device *rtc, const struct attribute_group *grp); | ||
277 | int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group **grps); | ||
278 | #else | ||
279 | static inline | ||
280 | int rtc_add_group(struct rtc_device *rtc, const struct attribute_group *grp) | ||
281 | { | ||
282 | return 0; | ||
283 | } | ||
284 | |||
285 | static inline | ||
286 | int rtc_add_groups(struct rtc_device *rtc, const struct attribute_group **grps) | ||
287 | { | ||
288 | return 0; | ||
289 | } | ||
290 | #endif | ||
280 | #endif /* _LINUX_RTC_H_ */ | 291 | #endif /* _LINUX_RTC_H_ */ |