diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2017-05-10 22:37:14 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2017-05-10 22:37:14 -0400 |
commit | 556d994a75790dce8a9c6b35b94cff1d526b2e32 (patch) | |
tree | 8158b1c21a195ea21bfd7ec32a1eb29374d90f49 /drivers/rtc | |
parent | 291b38a7565b41676cafd1b4052315a94d9c8977 (diff) | |
parent | 332e0d13d3c7d1e4394a513585a3d3b15a0030b8 (diff) |
Merge tag 'rtc-4.12' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux
Pull RTC updates from Alexandre Belloni:
"RTC subsystem update:
- Add OF device ID table for i2c drivers
New RTC driver:
- Motorola CPCAP PMIC RTC
RTC driver updates:
- cmos: fix IRQ selection
- ds1307: Add ST m41t0 support
- ds1374: fix watchdog configuration
- sh: Add rza series support"
* tag 'rtc-4.12' of git://git.kernel.org/pub/scm/linux/kernel/git/abelloni/linux: (33 commits)
rtc: gemini: add return value validation
rtc: snvs: fix an incorrect check of return value
rtc: ds1374: wdt: Fix stop/start ioctl always returning -EINVAL
rtc: ds1374: wdt: Fix issue with timeout scaling from secs to wdt ticks
rtc: sh: mark PM functions as unused
rtc: hid-sensor-time: remove some dead code
rtc: m41t80: Add proper compatible for rv4162
rtc: ds1307: Add m41t0 to OF device ID table
rtc: ds1307: support m41t0 variant
rtc: cpcap: fix improper use of IRQ_NONE for request_threaded_irq
rtc: cmos: Do not assume irq 8 for rtc when there are no legacy irqs
x86: i8259: export legacy_pic symbol
dt-bindings: rtc: document the rtc-sh bindings
rtc: sh: add support for rza series
rtc: cpcap: kfreeing devm allocated memory
rtc: wm8350: Remove unused to_wm8350_from_rtc_dev
rtc: cpcap: new rtc driver
dt-bindings: Add vendor prefix for Motorola
rtc: omap: mark PM methods as __maybe_unused
rtc: omap: remove incorrect __exit markups
...
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/Kconfig | 11 | ||||
-rw-r--r-- | drivers/rtc/Makefile | 1 | ||||
-rw-r--r-- | drivers/rtc/rtc-bq32k.c | 7 | ||||
-rw-r--r-- | drivers/rtc/rtc-cmos.c | 17 | ||||
-rw-r--r-- | drivers/rtc/rtc-cpcap.c | 330 | ||||
-rw-r--r-- | drivers/rtc/rtc-ds1307.c | 85 | ||||
-rw-r--r-- | drivers/rtc/rtc-ds1374.c | 11 | ||||
-rw-r--r-- | drivers/rtc/rtc-ds1672.c | 9 | ||||
-rw-r--r-- | drivers/rtc/rtc-ds3232.c | 7 | ||||
-rw-r--r-- | drivers/rtc/rtc-gemini.c | 2 | ||||
-rw-r--r-- | drivers/rtc/rtc-hid-sensor-time.c | 4 | ||||
-rw-r--r-- | drivers/rtc/rtc-isl1208.c | 12 | ||||
-rw-r--r-- | drivers/rtc/rtc-m41t80.c | 68 | ||||
-rw-r--r-- | drivers/rtc/rtc-omap.c | 22 | ||||
-rw-r--r-- | drivers/rtc/rtc-rs5c372.c | 37 | ||||
-rw-r--r-- | drivers/rtc/rtc-rv3029c2.c | 9 | ||||
-rw-r--r-- | drivers/rtc/rtc-rv8803.c | 21 | ||||
-rw-r--r-- | drivers/rtc/rtc-rx8010.c | 7 | ||||
-rw-r--r-- | drivers/rtc/rtc-rx8581.c | 7 | ||||
-rw-r--r-- | drivers/rtc/rtc-s35390a.c | 8 | ||||
-rw-r--r-- | drivers/rtc/rtc-sh.c | 39 | ||||
-rw-r--r-- | drivers/rtc/rtc-snvs.c | 2 | ||||
-rw-r--r-- | drivers/rtc/rtc-wm8350.c | 2 |
23 files changed, 672 insertions, 46 deletions
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index ee1b0e9dde79..8d3b95728326 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
@@ -1303,10 +1303,10 @@ config RTC_DRV_SA1100 | |||
1303 | 1303 | ||
1304 | config RTC_DRV_SH | 1304 | config RTC_DRV_SH |
1305 | tristate "SuperH On-Chip RTC" | 1305 | tristate "SuperH On-Chip RTC" |
1306 | depends on SUPERH && HAVE_CLK | 1306 | depends on SUPERH || ARCH_RENESAS |
1307 | help | 1307 | help |
1308 | Say Y here to enable support for the on-chip RTC found in | 1308 | Say Y here to enable support for the on-chip RTC found in |
1309 | most SuperH processors. | 1309 | most SuperH processors. This RTC is also found in RZ/A SoCs. |
1310 | 1310 | ||
1311 | To compile this driver as a module, choose M here: the | 1311 | To compile this driver as a module, choose M here: the |
1312 | module will be called rtc-sh. | 1312 | module will be called rtc-sh. |
@@ -1731,6 +1731,13 @@ config RTC_DRV_STM32 | |||
1731 | This driver can also be built as a module, if so, the module | 1731 | This driver can also be built as a module, if so, the module |
1732 | will be called "rtc-stm32". | 1732 | will be called "rtc-stm32". |
1733 | 1733 | ||
1734 | config RTC_DRV_CPCAP | ||
1735 | depends on MFD_CPCAP | ||
1736 | tristate "Motorola CPCAP RTC" | ||
1737 | help | ||
1738 | Say y here for CPCAP rtc found on some Motorola phones | ||
1739 | and tablets such as Droid 4. | ||
1740 | |||
1734 | comment "HID Sensor RTC drivers" | 1741 | comment "HID Sensor RTC drivers" |
1735 | 1742 | ||
1736 | config RTC_DRV_HID_SENSOR_TIME | 1743 | config RTC_DRV_HID_SENSOR_TIME |
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index f07297b1460a..13857d2fce09 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile | |||
@@ -40,6 +40,7 @@ obj-$(CONFIG_RTC_DRV_BQ32K) += rtc-bq32k.o | |||
40 | obj-$(CONFIG_RTC_DRV_BQ4802) += rtc-bq4802.o | 40 | obj-$(CONFIG_RTC_DRV_BQ4802) += rtc-bq4802.o |
41 | obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o | 41 | obj-$(CONFIG_RTC_DRV_CMOS) += rtc-cmos.o |
42 | obj-$(CONFIG_RTC_DRV_COH901331) += rtc-coh901331.o | 42 | obj-$(CONFIG_RTC_DRV_COH901331) += rtc-coh901331.o |
43 | obj-$(CONFIG_RTC_DRV_CPCAP) += rtc-cpcap.o | ||
43 | obj-$(CONFIG_RTC_DRV_DA9052) += rtc-da9052.o | 44 | obj-$(CONFIG_RTC_DRV_DA9052) += rtc-da9052.o |
44 | obj-$(CONFIG_RTC_DRV_DA9055) += rtc-da9055.o | 45 | obj-$(CONFIG_RTC_DRV_DA9055) += rtc-da9055.o |
45 | obj-$(CONFIG_RTC_DRV_DA9063) += rtc-da9063.o | 46 | obj-$(CONFIG_RTC_DRV_DA9063) += rtc-da9063.o |
diff --git a/drivers/rtc/rtc-bq32k.c b/drivers/rtc/rtc-bq32k.c index 2b223935001f..98ac8d5c7901 100644 --- a/drivers/rtc/rtc-bq32k.c +++ b/drivers/rtc/rtc-bq32k.c | |||
@@ -310,9 +310,16 @@ static const struct i2c_device_id bq32k_id[] = { | |||
310 | }; | 310 | }; |
311 | MODULE_DEVICE_TABLE(i2c, bq32k_id); | 311 | MODULE_DEVICE_TABLE(i2c, bq32k_id); |
312 | 312 | ||
313 | static const struct of_device_id bq32k_of_match[] = { | ||
314 | { .compatible = "ti,bq32000" }, | ||
315 | { } | ||
316 | }; | ||
317 | MODULE_DEVICE_TABLE(of, bq32k_of_match); | ||
318 | |||
313 | static struct i2c_driver bq32k_driver = { | 319 | static struct i2c_driver bq32k_driver = { |
314 | .driver = { | 320 | .driver = { |
315 | .name = "bq32k", | 321 | .name = "bq32k", |
322 | .of_match_table = of_match_ptr(bq32k_of_match), | ||
316 | }, | 323 | }, |
317 | .probe = bq32k_probe, | 324 | .probe = bq32k_probe, |
318 | .remove = bq32k_remove, | 325 | .remove = bq32k_remove, |
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index f4a96dbdabf2..b3de973a6260 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c | |||
@@ -41,6 +41,9 @@ | |||
41 | #include <linux/pm.h> | 41 | #include <linux/pm.h> |
42 | #include <linux/of.h> | 42 | #include <linux/of.h> |
43 | #include <linux/of_platform.h> | 43 | #include <linux/of_platform.h> |
44 | #ifdef CONFIG_X86 | ||
45 | #include <asm/i8259.h> | ||
46 | #endif | ||
44 | 47 | ||
45 | /* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */ | 48 | /* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */ |
46 | #include <linux/mc146818rtc.h> | 49 | #include <linux/mc146818rtc.h> |
@@ -1193,17 +1196,23 @@ static int cmos_pnp_probe(struct pnp_dev *pnp, const struct pnp_device_id *id) | |||
1193 | { | 1196 | { |
1194 | cmos_wake_setup(&pnp->dev); | 1197 | cmos_wake_setup(&pnp->dev); |
1195 | 1198 | ||
1196 | if (pnp_port_start(pnp, 0) == 0x70 && !pnp_irq_valid(pnp, 0)) | 1199 | if (pnp_port_start(pnp, 0) == 0x70 && !pnp_irq_valid(pnp, 0)) { |
1200 | unsigned int irq = 0; | ||
1201 | #ifdef CONFIG_X86 | ||
1197 | /* Some machines contain a PNP entry for the RTC, but | 1202 | /* Some machines contain a PNP entry for the RTC, but |
1198 | * don't define the IRQ. It should always be safe to | 1203 | * don't define the IRQ. It should always be safe to |
1199 | * hardcode it in these cases | 1204 | * hardcode it on systems with a legacy PIC. |
1200 | */ | 1205 | */ |
1206 | if (nr_legacy_irqs()) | ||
1207 | irq = 8; | ||
1208 | #endif | ||
1201 | return cmos_do_probe(&pnp->dev, | 1209 | return cmos_do_probe(&pnp->dev, |
1202 | pnp_get_resource(pnp, IORESOURCE_IO, 0), 8); | 1210 | pnp_get_resource(pnp, IORESOURCE_IO, 0), irq); |
1203 | else | 1211 | } else { |
1204 | return cmos_do_probe(&pnp->dev, | 1212 | return cmos_do_probe(&pnp->dev, |
1205 | pnp_get_resource(pnp, IORESOURCE_IO, 0), | 1213 | pnp_get_resource(pnp, IORESOURCE_IO, 0), |
1206 | pnp_irq(pnp, 0)); | 1214 | pnp_irq(pnp, 0)); |
1215 | } | ||
1207 | } | 1216 | } |
1208 | 1217 | ||
1209 | static void cmos_pnp_remove(struct pnp_dev *pnp) | 1218 | static void cmos_pnp_remove(struct pnp_dev *pnp) |
diff --git a/drivers/rtc/rtc-cpcap.c b/drivers/rtc/rtc-cpcap.c new file mode 100644 index 000000000000..3a0333e1f21a --- /dev/null +++ b/drivers/rtc/rtc-cpcap.c | |||
@@ -0,0 +1,330 @@ | |||
1 | /* | ||
2 | * Motorola CPCAP PMIC RTC driver | ||
3 | * | ||
4 | * Based on cpcap-regulator.c from Motorola Linux kernel tree | ||
5 | * Copyright (C) 2009 Motorola, Inc. | ||
6 | * | ||
7 | * Rewritten for mainline kernel | ||
8 | * - use DT | ||
9 | * - use regmap | ||
10 | * - use standard interrupt framework | ||
11 | * - use managed device resources | ||
12 | * - remove custom "secure clock daemon" helpers | ||
13 | * | ||
14 | * Copyright (C) 2017 Sebastian Reichel <sre@kernel.org> | ||
15 | * | ||
16 | * This program is free software; you can redistribute it and/or modify | ||
17 | * it under the terms of the GNU General Public License version 2 as | ||
18 | * published by the Free Software Foundation. | ||
19 | * | ||
20 | * This program is distributed in the hope that it will be useful, | ||
21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
23 | * GNU General Public License for more details. | ||
24 | */ | ||
25 | #include <linux/kernel.h> | ||
26 | #include <linux/module.h> | ||
27 | #include <linux/init.h> | ||
28 | #include <linux/device.h> | ||
29 | #include <linux/platform_device.h> | ||
30 | #include <linux/rtc.h> | ||
31 | #include <linux/err.h> | ||
32 | #include <linux/regmap.h> | ||
33 | #include <linux/mfd/motorola-cpcap.h> | ||
34 | #include <linux/slab.h> | ||
35 | #include <linux/sched.h> | ||
36 | |||
37 | #define SECS_PER_DAY 86400 | ||
38 | #define DAY_MASK 0x7FFF | ||
39 | #define TOD1_MASK 0x00FF | ||
40 | #define TOD2_MASK 0x01FF | ||
41 | |||
42 | struct cpcap_time { | ||
43 | int day; | ||
44 | int tod1; | ||
45 | int tod2; | ||
46 | }; | ||
47 | |||
48 | struct cpcap_rtc { | ||
49 | struct regmap *regmap; | ||
50 | struct rtc_device *rtc_dev; | ||
51 | u16 vendor; | ||
52 | int alarm_irq; | ||
53 | bool alarm_enabled; | ||
54 | int update_irq; | ||
55 | bool update_enabled; | ||
56 | }; | ||
57 | |||
58 | static void cpcap2rtc_time(struct rtc_time *rtc, struct cpcap_time *cpcap) | ||
59 | { | ||
60 | unsigned long int tod; | ||
61 | unsigned long int time; | ||
62 | |||
63 | tod = (cpcap->tod1 & TOD1_MASK) | ((cpcap->tod2 & TOD2_MASK) << 8); | ||
64 | time = tod + ((cpcap->day & DAY_MASK) * SECS_PER_DAY); | ||
65 | |||
66 | rtc_time_to_tm(time, rtc); | ||
67 | } | ||
68 | |||
69 | static void rtc2cpcap_time(struct cpcap_time *cpcap, struct rtc_time *rtc) | ||
70 | { | ||
71 | unsigned long time; | ||
72 | |||
73 | rtc_tm_to_time(rtc, &time); | ||
74 | |||
75 | cpcap->day = time / SECS_PER_DAY; | ||
76 | time %= SECS_PER_DAY; | ||
77 | cpcap->tod2 = (time >> 8) & TOD2_MASK; | ||
78 | cpcap->tod1 = time & TOD1_MASK; | ||
79 | } | ||
80 | |||
81 | static int cpcap_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | ||
82 | { | ||
83 | struct cpcap_rtc *rtc = dev_get_drvdata(dev); | ||
84 | |||
85 | if (rtc->alarm_enabled == enabled) | ||
86 | return 0; | ||
87 | |||
88 | if (enabled) | ||
89 | enable_irq(rtc->alarm_irq); | ||
90 | else | ||
91 | disable_irq(rtc->alarm_irq); | ||
92 | |||
93 | rtc->alarm_enabled = !!enabled; | ||
94 | |||
95 | return 0; | ||
96 | } | ||
97 | |||
98 | static int cpcap_rtc_read_time(struct device *dev, struct rtc_time *tm) | ||
99 | { | ||
100 | struct cpcap_rtc *rtc; | ||
101 | struct cpcap_time cpcap_tm; | ||
102 | int temp_tod2; | ||
103 | int ret; | ||
104 | |||
105 | rtc = dev_get_drvdata(dev); | ||
106 | |||
107 | ret = regmap_read(rtc->regmap, CPCAP_REG_TOD2, &temp_tod2); | ||
108 | ret |= regmap_read(rtc->regmap, CPCAP_REG_DAY, &cpcap_tm.day); | ||
109 | ret |= regmap_read(rtc->regmap, CPCAP_REG_TOD1, &cpcap_tm.tod1); | ||
110 | ret |= regmap_read(rtc->regmap, CPCAP_REG_TOD2, &cpcap_tm.tod2); | ||
111 | |||
112 | if (temp_tod2 > cpcap_tm.tod2) | ||
113 | ret |= regmap_read(rtc->regmap, CPCAP_REG_DAY, &cpcap_tm.day); | ||
114 | |||
115 | if (ret) { | ||
116 | dev_err(dev, "Failed to read time\n"); | ||
117 | return -EIO; | ||
118 | } | ||
119 | |||
120 | cpcap2rtc_time(tm, &cpcap_tm); | ||
121 | |||
122 | return rtc_valid_tm(tm); | ||
123 | } | ||
124 | |||
125 | static int cpcap_rtc_set_time(struct device *dev, struct rtc_time *tm) | ||
126 | { | ||
127 | struct cpcap_rtc *rtc; | ||
128 | struct cpcap_time cpcap_tm; | ||
129 | int ret = 0; | ||
130 | |||
131 | rtc = dev_get_drvdata(dev); | ||
132 | |||
133 | rtc2cpcap_time(&cpcap_tm, tm); | ||
134 | |||
135 | if (rtc->alarm_enabled) | ||
136 | disable_irq(rtc->alarm_irq); | ||
137 | if (rtc->update_enabled) | ||
138 | disable_irq(rtc->update_irq); | ||
139 | |||
140 | if (rtc->vendor == CPCAP_VENDOR_ST) { | ||
141 | /* The TOD1 and TOD2 registers MUST be written in this order | ||
142 | * for the change to properly set. | ||
143 | */ | ||
144 | ret |= regmap_update_bits(rtc->regmap, CPCAP_REG_TOD1, | ||
145 | TOD1_MASK, cpcap_tm.tod1); | ||
146 | ret |= regmap_update_bits(rtc->regmap, CPCAP_REG_TOD2, | ||
147 | TOD2_MASK, cpcap_tm.tod2); | ||
148 | ret |= regmap_update_bits(rtc->regmap, CPCAP_REG_DAY, | ||
149 | DAY_MASK, cpcap_tm.day); | ||
150 | } else { | ||
151 | /* Clearing the upper lower 8 bits of the TOD guarantees that | ||
152 | * the upper half of TOD (TOD2) will not increment for 0xFF RTC | ||
153 | * ticks (255 seconds). During this time we can safely write | ||
154 | * to DAY, TOD2, then TOD1 (in that order) and expect RTC to be | ||
155 | * synchronized to the exact time requested upon the final write | ||
156 | * to TOD1. | ||
157 | */ | ||
158 | ret |= regmap_update_bits(rtc->regmap, CPCAP_REG_TOD1, | ||
159 | TOD1_MASK, 0); | ||
160 | ret |= regmap_update_bits(rtc->regmap, CPCAP_REG_DAY, | ||
161 | DAY_MASK, cpcap_tm.day); | ||
162 | ret |= regmap_update_bits(rtc->regmap, CPCAP_REG_TOD2, | ||
163 | TOD2_MASK, cpcap_tm.tod2); | ||
164 | ret |= regmap_update_bits(rtc->regmap, CPCAP_REG_TOD1, | ||
165 | TOD1_MASK, cpcap_tm.tod1); | ||
166 | } | ||
167 | |||
168 | if (rtc->update_enabled) | ||
169 | enable_irq(rtc->update_irq); | ||
170 | if (rtc->alarm_enabled) | ||
171 | enable_irq(rtc->alarm_irq); | ||
172 | |||
173 | return ret; | ||
174 | } | ||
175 | |||
176 | static int cpcap_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | ||
177 | { | ||
178 | struct cpcap_rtc *rtc; | ||
179 | struct cpcap_time cpcap_tm; | ||
180 | int ret; | ||
181 | |||
182 | rtc = dev_get_drvdata(dev); | ||
183 | |||
184 | alrm->enabled = rtc->alarm_enabled; | ||
185 | |||
186 | ret = regmap_read(rtc->regmap, CPCAP_REG_DAYA, &cpcap_tm.day); | ||
187 | ret |= regmap_read(rtc->regmap, CPCAP_REG_TODA2, &cpcap_tm.tod2); | ||
188 | ret |= regmap_read(rtc->regmap, CPCAP_REG_TODA1, &cpcap_tm.tod1); | ||
189 | |||
190 | if (ret) { | ||
191 | dev_err(dev, "Failed to read time\n"); | ||
192 | return -EIO; | ||
193 | } | ||
194 | |||
195 | cpcap2rtc_time(&alrm->time, &cpcap_tm); | ||
196 | return rtc_valid_tm(&alrm->time); | ||
197 | } | ||
198 | |||
199 | static int cpcap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | ||
200 | { | ||
201 | struct cpcap_rtc *rtc; | ||
202 | struct cpcap_time cpcap_tm; | ||
203 | int ret; | ||
204 | |||
205 | rtc = dev_get_drvdata(dev); | ||
206 | |||
207 | rtc2cpcap_time(&cpcap_tm, &alrm->time); | ||
208 | |||
209 | if (rtc->alarm_enabled) | ||
210 | disable_irq(rtc->alarm_irq); | ||
211 | |||
212 | ret = regmap_update_bits(rtc->regmap, CPCAP_REG_DAYA, DAY_MASK, | ||
213 | cpcap_tm.day); | ||
214 | ret |= regmap_update_bits(rtc->regmap, CPCAP_REG_TODA2, TOD2_MASK, | ||
215 | cpcap_tm.tod2); | ||
216 | ret |= regmap_update_bits(rtc->regmap, CPCAP_REG_TODA1, TOD1_MASK, | ||
217 | cpcap_tm.tod1); | ||
218 | |||
219 | if (!ret) { | ||
220 | enable_irq(rtc->alarm_irq); | ||
221 | rtc->alarm_enabled = true; | ||
222 | } | ||
223 | |||
224 | return ret; | ||
225 | } | ||
226 | |||
227 | static const struct rtc_class_ops cpcap_rtc_ops = { | ||
228 | .read_time = cpcap_rtc_read_time, | ||
229 | .set_time = cpcap_rtc_set_time, | ||
230 | .read_alarm = cpcap_rtc_read_alarm, | ||
231 | .set_alarm = cpcap_rtc_set_alarm, | ||
232 | .alarm_irq_enable = cpcap_rtc_alarm_irq_enable, | ||
233 | }; | ||
234 | |||
235 | static irqreturn_t cpcap_rtc_alarm_irq(int irq, void *data) | ||
236 | { | ||
237 | struct cpcap_rtc *rtc = data; | ||
238 | |||
239 | rtc_update_irq(rtc->rtc_dev, 1, RTC_AF | RTC_IRQF); | ||
240 | return IRQ_HANDLED; | ||
241 | } | ||
242 | |||
243 | static irqreturn_t cpcap_rtc_update_irq(int irq, void *data) | ||
244 | { | ||
245 | struct cpcap_rtc *rtc = data; | ||
246 | |||
247 | rtc_update_irq(rtc->rtc_dev, 1, RTC_UF | RTC_IRQF); | ||
248 | return IRQ_HANDLED; | ||
249 | } | ||
250 | |||
251 | static int cpcap_rtc_probe(struct platform_device *pdev) | ||
252 | { | ||
253 | struct device *dev = &pdev->dev; | ||
254 | struct cpcap_rtc *rtc; | ||
255 | int err; | ||
256 | |||
257 | rtc = devm_kzalloc(dev, sizeof(*rtc), GFP_KERNEL); | ||
258 | if (!rtc) | ||
259 | return -ENOMEM; | ||
260 | |||
261 | rtc->regmap = dev_get_regmap(dev->parent, NULL); | ||
262 | if (!rtc->regmap) | ||
263 | return -ENODEV; | ||
264 | |||
265 | platform_set_drvdata(pdev, rtc); | ||
266 | rtc->rtc_dev = devm_rtc_device_register(dev, "cpcap_rtc", | ||
267 | &cpcap_rtc_ops, THIS_MODULE); | ||
268 | |||
269 | if (IS_ERR(rtc->rtc_dev)) | ||
270 | return PTR_ERR(rtc->rtc_dev); | ||
271 | |||
272 | err = cpcap_get_vendor(dev, rtc->regmap, &rtc->vendor); | ||
273 | if (err) | ||
274 | return err; | ||
275 | |||
276 | rtc->alarm_irq = platform_get_irq(pdev, 0); | ||
277 | err = devm_request_threaded_irq(dev, rtc->alarm_irq, NULL, | ||
278 | cpcap_rtc_alarm_irq, IRQF_TRIGGER_NONE, | ||
279 | "rtc_alarm", rtc); | ||
280 | if (err) { | ||
281 | dev_err(dev, "Could not request alarm irq: %d\n", err); | ||
282 | return err; | ||
283 | } | ||
284 | disable_irq(rtc->alarm_irq); | ||
285 | |||
286 | /* Stock Android uses the 1 Hz interrupt for "secure clock daemon", | ||
287 | * which is not supported by the mainline kernel. The mainline kernel | ||
288 | * does not use the irq at the moment, but we explicitly request and | ||
289 | * disable it, so that its masked and does not wake up the processor | ||
290 | * every second. | ||
291 | */ | ||
292 | rtc->update_irq = platform_get_irq(pdev, 1); | ||
293 | err = devm_request_threaded_irq(dev, rtc->update_irq, NULL, | ||
294 | cpcap_rtc_update_irq, IRQF_TRIGGER_NONE, | ||
295 | "rtc_1hz", rtc); | ||
296 | if (err) { | ||
297 | dev_err(dev, "Could not request update irq: %d\n", err); | ||
298 | return err; | ||
299 | } | ||
300 | disable_irq(rtc->update_irq); | ||
301 | |||
302 | err = device_init_wakeup(dev, 1); | ||
303 | if (err) { | ||
304 | dev_err(dev, "wakeup initialization failed (%d)\n", err); | ||
305 | /* ignore error and continue without wakeup support */ | ||
306 | } | ||
307 | |||
308 | return 0; | ||
309 | } | ||
310 | |||
311 | static const struct of_device_id cpcap_rtc_of_match[] = { | ||
312 | { .compatible = "motorola,cpcap-rtc", }, | ||
313 | {}, | ||
314 | }; | ||
315 | MODULE_DEVICE_TABLE(of, cpcap_rtc_of_match); | ||
316 | |||
317 | static struct platform_driver cpcap_rtc_driver = { | ||
318 | .probe = cpcap_rtc_probe, | ||
319 | .driver = { | ||
320 | .name = "cpcap-rtc", | ||
321 | .of_match_table = cpcap_rtc_of_match, | ||
322 | }, | ||
323 | }; | ||
324 | |||
325 | module_platform_driver(cpcap_rtc_driver); | ||
326 | |||
327 | MODULE_ALIAS("platform:cpcap-rtc"); | ||
328 | MODULE_DESCRIPTION("CPCAP RTC driver"); | ||
329 | MODULE_AUTHOR("Sebastian Reichel <sre@kernel.org>"); | ||
330 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/rtc/rtc-ds1307.c b/drivers/rtc/rtc-ds1307.c index 4ad97be48043..77339b3d50a1 100644 --- a/drivers/rtc/rtc-ds1307.c +++ b/drivers/rtc/rtc-ds1307.c | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/i2c.h> | 16 | #include <linux/i2c.h> |
17 | #include <linux/init.h> | 17 | #include <linux/init.h> |
18 | #include <linux/module.h> | 18 | #include <linux/module.h> |
19 | #include <linux/of_device.h> | ||
19 | #include <linux/rtc/ds1307.h> | 20 | #include <linux/rtc/ds1307.h> |
20 | #include <linux/rtc.h> | 21 | #include <linux/rtc.h> |
21 | #include <linux/slab.h> | 22 | #include <linux/slab.h> |
@@ -38,6 +39,7 @@ enum ds_type { | |||
38 | ds_1340, | 39 | ds_1340, |
39 | ds_1388, | 40 | ds_1388, |
40 | ds_3231, | 41 | ds_3231, |
42 | m41t0, | ||
41 | m41t00, | 43 | m41t00, |
42 | mcp794xx, | 44 | mcp794xx, |
43 | rx_8025, | 45 | rx_8025, |
@@ -52,6 +54,7 @@ enum ds_type { | |||
52 | # define DS1340_BIT_nEOSC 0x80 | 54 | # define DS1340_BIT_nEOSC 0x80 |
53 | # define MCP794XX_BIT_ST 0x80 | 55 | # define MCP794XX_BIT_ST 0x80 |
54 | #define DS1307_REG_MIN 0x01 /* 00-59 */ | 56 | #define DS1307_REG_MIN 0x01 /* 00-59 */ |
57 | # define M41T0_BIT_OF 0x80 | ||
55 | #define DS1307_REG_HOUR 0x02 /* 00-23, or 1-12{am,pm} */ | 58 | #define DS1307_REG_HOUR 0x02 /* 00-23, or 1-12{am,pm} */ |
56 | # define DS1307_BIT_12HR 0x40 /* in REG_HOUR */ | 59 | # define DS1307_BIT_12HR 0x40 /* in REG_HOUR */ |
57 | # define DS1307_BIT_PM 0x20 /* in REG_HOUR */ | 60 | # define DS1307_BIT_PM 0x20 /* in REG_HOUR */ |
@@ -182,6 +185,7 @@ static const struct i2c_device_id ds1307_id[] = { | |||
182 | { "ds1388", ds_1388 }, | 185 | { "ds1388", ds_1388 }, |
183 | { "ds1340", ds_1340 }, | 186 | { "ds1340", ds_1340 }, |
184 | { "ds3231", ds_3231 }, | 187 | { "ds3231", ds_3231 }, |
188 | { "m41t0", m41t0 }, | ||
185 | { "m41t00", m41t00 }, | 189 | { "m41t00", m41t00 }, |
186 | { "mcp7940x", mcp794xx }, | 190 | { "mcp7940x", mcp794xx }, |
187 | { "mcp7941x", mcp794xx }, | 191 | { "mcp7941x", mcp794xx }, |
@@ -192,6 +196,69 @@ static const struct i2c_device_id ds1307_id[] = { | |||
192 | }; | 196 | }; |
193 | MODULE_DEVICE_TABLE(i2c, ds1307_id); | 197 | MODULE_DEVICE_TABLE(i2c, ds1307_id); |
194 | 198 | ||
199 | #ifdef CONFIG_OF | ||
200 | static const struct of_device_id ds1307_of_match[] = { | ||
201 | { | ||
202 | .compatible = "dallas,ds1307", | ||
203 | .data = (void *)ds_1307 | ||
204 | }, | ||
205 | { | ||
206 | .compatible = "dallas,ds1337", | ||
207 | .data = (void *)ds_1337 | ||
208 | }, | ||
209 | { | ||
210 | .compatible = "dallas,ds1338", | ||
211 | .data = (void *)ds_1338 | ||
212 | }, | ||
213 | { | ||
214 | .compatible = "dallas,ds1339", | ||
215 | .data = (void *)ds_1339 | ||
216 | }, | ||
217 | { | ||
218 | .compatible = "dallas,ds1388", | ||
219 | .data = (void *)ds_1388 | ||
220 | }, | ||
221 | { | ||
222 | .compatible = "dallas,ds1340", | ||
223 | .data = (void *)ds_1340 | ||
224 | }, | ||
225 | { | ||
226 | .compatible = "maxim,ds3231", | ||
227 | .data = (void *)ds_3231 | ||
228 | }, | ||
229 | { | ||
230 | .compatible = "st,m41t0", | ||
231 | .data = (void *)m41t00 | ||
232 | }, | ||
233 | { | ||
234 | .compatible = "st,m41t00", | ||
235 | .data = (void *)m41t00 | ||
236 | }, | ||
237 | { | ||
238 | .compatible = "microchip,mcp7940x", | ||
239 | .data = (void *)mcp794xx | ||
240 | }, | ||
241 | { | ||
242 | .compatible = "microchip,mcp7941x", | ||
243 | .data = (void *)mcp794xx | ||
244 | }, | ||
245 | { | ||
246 | .compatible = "pericom,pt7c4338", | ||
247 | .data = (void *)ds_1307 | ||
248 | }, | ||
249 | { | ||
250 | .compatible = "epson,rx8025", | ||
251 | .data = (void *)rx_8025 | ||
252 | }, | ||
253 | { | ||
254 | .compatible = "isil,isl12057", | ||
255 | .data = (void *)ds_1337 | ||
256 | }, | ||
257 | { } | ||
258 | }; | ||
259 | MODULE_DEVICE_TABLE(of, ds1307_of_match); | ||
260 | #endif | ||
261 | |||
195 | #ifdef CONFIG_ACPI | 262 | #ifdef CONFIG_ACPI |
196 | static const struct acpi_device_id ds1307_acpi_ids[] = { | 263 | static const struct acpi_device_id ds1307_acpi_ids[] = { |
197 | { .id = "DS1307", .driver_data = ds_1307 }, | 264 | { .id = "DS1307", .driver_data = ds_1307 }, |
@@ -201,6 +268,7 @@ static const struct acpi_device_id ds1307_acpi_ids[] = { | |||
201 | { .id = "DS1388", .driver_data = ds_1388 }, | 268 | { .id = "DS1388", .driver_data = ds_1388 }, |
202 | { .id = "DS1340", .driver_data = ds_1340 }, | 269 | { .id = "DS1340", .driver_data = ds_1340 }, |
203 | { .id = "DS3231", .driver_data = ds_3231 }, | 270 | { .id = "DS3231", .driver_data = ds_3231 }, |
271 | { .id = "M41T0", .driver_data = m41t0 }, | ||
204 | { .id = "M41T00", .driver_data = m41t00 }, | 272 | { .id = "M41T00", .driver_data = m41t00 }, |
205 | { .id = "MCP7940X", .driver_data = mcp794xx }, | 273 | { .id = "MCP7940X", .driver_data = mcp794xx }, |
206 | { .id = "MCP7941X", .driver_data = mcp794xx }, | 274 | { .id = "MCP7941X", .driver_data = mcp794xx }, |
@@ -396,6 +464,13 @@ static int ds1307_get_time(struct device *dev, struct rtc_time *t) | |||
396 | 464 | ||
397 | dev_dbg(dev, "%s: %7ph\n", "read", ds1307->regs); | 465 | dev_dbg(dev, "%s: %7ph\n", "read", ds1307->regs); |
398 | 466 | ||
467 | /* if oscillator fail bit is set, no data can be trusted */ | ||
468 | if (ds1307->type == m41t0 && | ||
469 | ds1307->regs[DS1307_REG_MIN] & M41T0_BIT_OF) { | ||
470 | dev_warn_once(dev, "oscillator failed, set time!\n"); | ||
471 | return -EINVAL; | ||
472 | } | ||
473 | |||
399 | t->tm_sec = bcd2bin(ds1307->regs[DS1307_REG_SECS] & 0x7f); | 474 | t->tm_sec = bcd2bin(ds1307->regs[DS1307_REG_SECS] & 0x7f); |
400 | t->tm_min = bcd2bin(ds1307->regs[DS1307_REG_MIN] & 0x7f); | 475 | t->tm_min = bcd2bin(ds1307->regs[DS1307_REG_MIN] & 0x7f); |
401 | tmp = ds1307->regs[DS1307_REG_HOUR] & 0x3f; | 476 | tmp = ds1307->regs[DS1307_REG_HOUR] & 0x3f; |
@@ -1318,7 +1393,12 @@ static int ds1307_probe(struct i2c_client *client, | |||
1318 | i2c_set_clientdata(client, ds1307); | 1393 | i2c_set_clientdata(client, ds1307); |
1319 | 1394 | ||
1320 | ds1307->client = client; | 1395 | ds1307->client = client; |
1321 | if (id) { | 1396 | |
1397 | if (client->dev.of_node) { | ||
1398 | ds1307->type = (enum ds_type) | ||
1399 | of_device_get_match_data(&client->dev); | ||
1400 | chip = &chips[ds1307->type]; | ||
1401 | } else if (id) { | ||
1322 | chip = &chips[id->driver_data]; | 1402 | chip = &chips[id->driver_data]; |
1323 | ds1307->type = id->driver_data; | 1403 | ds1307->type = id->driver_data; |
1324 | } else { | 1404 | } else { |
@@ -1513,6 +1593,7 @@ read_rtc: | |||
1513 | tmp = ds1307->regs[DS1307_REG_SECS]; | 1593 | tmp = ds1307->regs[DS1307_REG_SECS]; |
1514 | switch (ds1307->type) { | 1594 | switch (ds1307->type) { |
1515 | case ds_1307: | 1595 | case ds_1307: |
1596 | case m41t0: | ||
1516 | case m41t00: | 1597 | case m41t00: |
1517 | /* clock halted? turn it on, so clock can tick. */ | 1598 | /* clock halted? turn it on, so clock can tick. */ |
1518 | if (tmp & DS1307_BIT_CH) { | 1599 | if (tmp & DS1307_BIT_CH) { |
@@ -1577,6 +1658,7 @@ read_rtc: | |||
1577 | tmp = ds1307->regs[DS1307_REG_HOUR]; | 1658 | tmp = ds1307->regs[DS1307_REG_HOUR]; |
1578 | switch (ds1307->type) { | 1659 | switch (ds1307->type) { |
1579 | case ds_1340: | 1660 | case ds_1340: |
1661 | case m41t0: | ||
1580 | case m41t00: | 1662 | case m41t00: |
1581 | /* | 1663 | /* |
1582 | * NOTE: ignores century bits; fix before deploying | 1664 | * NOTE: ignores century bits; fix before deploying |
@@ -1711,6 +1793,7 @@ static int ds1307_remove(struct i2c_client *client) | |||
1711 | static struct i2c_driver ds1307_driver = { | 1793 | static struct i2c_driver ds1307_driver = { |
1712 | .driver = { | 1794 | .driver = { |
1713 | .name = "rtc-ds1307", | 1795 | .name = "rtc-ds1307", |
1796 | .of_match_table = of_match_ptr(ds1307_of_match), | ||
1714 | .acpi_match_table = ACPI_PTR(ds1307_acpi_ids), | 1797 | .acpi_match_table = ACPI_PTR(ds1307_acpi_ids), |
1715 | }, | 1798 | }, |
1716 | .probe = ds1307_probe, | 1799 | .probe = ds1307_probe, |
diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c index 52429f0a57cc..38a2e9e684df 100644 --- a/drivers/rtc/rtc-ds1374.c +++ b/drivers/rtc/rtc-ds1374.c | |||
@@ -525,6 +525,10 @@ static long ds1374_wdt_ioctl(struct file *file, unsigned int cmd, | |||
525 | if (get_user(new_margin, (int __user *)arg)) | 525 | if (get_user(new_margin, (int __user *)arg)) |
526 | return -EFAULT; | 526 | return -EFAULT; |
527 | 527 | ||
528 | /* the hardware's tick rate is 4096 Hz, so | ||
529 | * the counter value needs to be scaled accordingly | ||
530 | */ | ||
531 | new_margin <<= 12; | ||
528 | if (new_margin < 1 || new_margin > 16777216) | 532 | if (new_margin < 1 || new_margin > 16777216) |
529 | return -EINVAL; | 533 | return -EINVAL; |
530 | 534 | ||
@@ -533,7 +537,8 @@ static long ds1374_wdt_ioctl(struct file *file, unsigned int cmd, | |||
533 | ds1374_wdt_ping(); | 537 | ds1374_wdt_ping(); |
534 | /* fallthrough */ | 538 | /* fallthrough */ |
535 | case WDIOC_GETTIMEOUT: | 539 | case WDIOC_GETTIMEOUT: |
536 | return put_user(wdt_margin, (int __user *)arg); | 540 | /* when returning ... inverse is true */ |
541 | return put_user((wdt_margin >> 12), (int __user *)arg); | ||
537 | case WDIOC_SETOPTIONS: | 542 | case WDIOC_SETOPTIONS: |
538 | if (copy_from_user(&options, (int __user *)arg, sizeof(int))) | 543 | if (copy_from_user(&options, (int __user *)arg, sizeof(int))) |
539 | return -EFAULT; | 544 | return -EFAULT; |
@@ -541,14 +546,15 @@ static long ds1374_wdt_ioctl(struct file *file, unsigned int cmd, | |||
541 | if (options & WDIOS_DISABLECARD) { | 546 | if (options & WDIOS_DISABLECARD) { |
542 | pr_info("disable watchdog\n"); | 547 | pr_info("disable watchdog\n"); |
543 | ds1374_wdt_disable(); | 548 | ds1374_wdt_disable(); |
549 | return 0; | ||
544 | } | 550 | } |
545 | 551 | ||
546 | if (options & WDIOS_ENABLECARD) { | 552 | if (options & WDIOS_ENABLECARD) { |
547 | pr_info("enable watchdog\n"); | 553 | pr_info("enable watchdog\n"); |
548 | ds1374_wdt_settimeout(wdt_margin); | 554 | ds1374_wdt_settimeout(wdt_margin); |
549 | ds1374_wdt_ping(); | 555 | ds1374_wdt_ping(); |
556 | return 0; | ||
550 | } | 557 | } |
551 | |||
552 | return -EINVAL; | 558 | return -EINVAL; |
553 | } | 559 | } |
554 | return -ENOTTY; | 560 | return -ENOTTY; |
@@ -704,6 +710,7 @@ static SIMPLE_DEV_PM_OPS(ds1374_pm, ds1374_suspend, ds1374_resume); | |||
704 | static struct i2c_driver ds1374_driver = { | 710 | static struct i2c_driver ds1374_driver = { |
705 | .driver = { | 711 | .driver = { |
706 | .name = "rtc-ds1374", | 712 | .name = "rtc-ds1374", |
713 | .of_match_table = of_match_ptr(ds1374_of_match), | ||
707 | .pm = &ds1374_pm, | 714 | .pm = &ds1374_pm, |
708 | }, | 715 | }, |
709 | .probe = ds1374_probe, | 716 | .probe = ds1374_probe, |
diff --git a/drivers/rtc/rtc-ds1672.c b/drivers/rtc/rtc-ds1672.c index 5c18ac7394c4..7bf46bfe11a4 100644 --- a/drivers/rtc/rtc-ds1672.c +++ b/drivers/rtc/rtc-ds1672.c | |||
@@ -196,10 +196,17 @@ static struct i2c_device_id ds1672_id[] = { | |||
196 | }; | 196 | }; |
197 | MODULE_DEVICE_TABLE(i2c, ds1672_id); | 197 | MODULE_DEVICE_TABLE(i2c, ds1672_id); |
198 | 198 | ||
199 | static const struct of_device_id ds1672_of_match[] = { | ||
200 | { .compatible = "dallas,ds1672" }, | ||
201 | { } | ||
202 | }; | ||
203 | MODULE_DEVICE_TABLE(of, ds1672_of_match); | ||
204 | |||
199 | static struct i2c_driver ds1672_driver = { | 205 | static struct i2c_driver ds1672_driver = { |
200 | .driver = { | 206 | .driver = { |
201 | .name = "rtc-ds1672", | 207 | .name = "rtc-ds1672", |
202 | }, | 208 | .of_match_table = of_match_ptr(ds1672_of_match), |
209 | }, | ||
203 | .probe = &ds1672_probe, | 210 | .probe = &ds1672_probe, |
204 | .id_table = ds1672_id, | 211 | .id_table = ds1672_id, |
205 | }; | 212 | }; |
diff --git a/drivers/rtc/rtc-ds3232.c b/drivers/rtc/rtc-ds3232.c index 9bb39a06b994..deff431a37c4 100644 --- a/drivers/rtc/rtc-ds3232.c +++ b/drivers/rtc/rtc-ds3232.c | |||
@@ -442,9 +442,16 @@ static const struct i2c_device_id ds3232_id[] = { | |||
442 | }; | 442 | }; |
443 | MODULE_DEVICE_TABLE(i2c, ds3232_id); | 443 | MODULE_DEVICE_TABLE(i2c, ds3232_id); |
444 | 444 | ||
445 | static const struct of_device_id ds3232_of_match[] = { | ||
446 | { .compatible = "dallas,ds3232" }, | ||
447 | { } | ||
448 | }; | ||
449 | MODULE_DEVICE_TABLE(of, ds3232_of_match); | ||
450 | |||
445 | static struct i2c_driver ds3232_driver = { | 451 | static struct i2c_driver ds3232_driver = { |
446 | .driver = { | 452 | .driver = { |
447 | .name = "rtc-ds3232", | 453 | .name = "rtc-ds3232", |
454 | .of_match_table = of_match_ptr(ds3232_of_match), | ||
448 | .pm = &ds3232_pm_ops, | 455 | .pm = &ds3232_pm_ops, |
449 | }, | 456 | }, |
450 | .probe = ds3232_i2c_probe, | 457 | .probe = ds3232_i2c_probe, |
diff --git a/drivers/rtc/rtc-gemini.c b/drivers/rtc/rtc-gemini.c index ccf0dbadb62d..5279390bb42d 100644 --- a/drivers/rtc/rtc-gemini.c +++ b/drivers/rtc/rtc-gemini.c | |||
@@ -139,6 +139,8 @@ static int gemini_rtc_probe(struct platform_device *pdev) | |||
139 | 139 | ||
140 | rtc->rtc_base = devm_ioremap(dev, res->start, | 140 | rtc->rtc_base = devm_ioremap(dev, res->start, |
141 | resource_size(res)); | 141 | resource_size(res)); |
142 | if (!rtc->rtc_base) | ||
143 | return -ENOMEM; | ||
142 | 144 | ||
143 | ret = devm_request_irq(dev, rtc->rtc_irq, gemini_rtc_interrupt, | 145 | ret = devm_request_irq(dev, rtc->rtc_irq, gemini_rtc_interrupt, |
144 | IRQF_SHARED, pdev->name, dev); | 146 | IRQF_SHARED, pdev->name, dev); |
diff --git a/drivers/rtc/rtc-hid-sensor-time.c b/drivers/rtc/rtc-hid-sensor-time.c index c398f74234c6..2751dba850c6 100644 --- a/drivers/rtc/rtc-hid-sensor-time.c +++ b/drivers/rtc/rtc-hid-sensor-time.c | |||
@@ -291,9 +291,9 @@ static int hid_time_probe(struct platform_device *pdev) | |||
291 | "hid-sensor-time", &hid_time_rtc_ops, | 291 | "hid-sensor-time", &hid_time_rtc_ops, |
292 | THIS_MODULE); | 292 | THIS_MODULE); |
293 | 293 | ||
294 | if (IS_ERR_OR_NULL(time_state->rtc)) { | 294 | if (IS_ERR(time_state->rtc)) { |
295 | hid_device_io_stop(hsdev->hdev); | 295 | hid_device_io_stop(hsdev->hdev); |
296 | ret = time_state->rtc ? PTR_ERR(time_state->rtc) : -ENODEV; | 296 | ret = PTR_ERR(time_state->rtc); |
297 | time_state->rtc = NULL; | 297 | time_state->rtc = NULL; |
298 | dev_err(&pdev->dev, "rtc device register failed!\n"); | 298 | dev_err(&pdev->dev, "rtc device register failed!\n"); |
299 | goto err_rtc; | 299 | goto err_rtc; |
diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c index 2893785f0eba..8dd299c6a1f3 100644 --- a/drivers/rtc/rtc-isl1208.c +++ b/drivers/rtc/rtc-isl1208.c | |||
@@ -687,10 +687,18 @@ static const struct i2c_device_id isl1208_id[] = { | |||
687 | }; | 687 | }; |
688 | MODULE_DEVICE_TABLE(i2c, isl1208_id); | 688 | MODULE_DEVICE_TABLE(i2c, isl1208_id); |
689 | 689 | ||
690 | static const struct of_device_id isl1208_of_match[] = { | ||
691 | { .compatible = "isil,isl1208" }, | ||
692 | { .compatible = "isil,isl1218" }, | ||
693 | { } | ||
694 | }; | ||
695 | MODULE_DEVICE_TABLE(of, isl1208_of_match); | ||
696 | |||
690 | static struct i2c_driver isl1208_driver = { | 697 | static struct i2c_driver isl1208_driver = { |
691 | .driver = { | 698 | .driver = { |
692 | .name = "rtc-isl1208", | 699 | .name = "rtc-isl1208", |
693 | }, | 700 | .of_match_table = of_match_ptr(isl1208_of_match), |
701 | }, | ||
694 | .probe = isl1208_probe, | 702 | .probe = isl1208_probe, |
695 | .remove = isl1208_remove, | 703 | .remove = isl1208_remove, |
696 | .id_table = isl1208_id, | 704 | .id_table = isl1208_id, |
diff --git a/drivers/rtc/rtc-m41t80.c b/drivers/rtc/rtc-m41t80.c index 58698d21c2c3..5ec4653022ff 100644 --- a/drivers/rtc/rtc-m41t80.c +++ b/drivers/rtc/rtc-m41t80.c | |||
@@ -20,6 +20,7 @@ | |||
20 | #include <linux/init.h> | 20 | #include <linux/init.h> |
21 | #include <linux/kernel.h> | 21 | #include <linux/kernel.h> |
22 | #include <linux/module.h> | 22 | #include <linux/module.h> |
23 | #include <linux/of_device.h> | ||
23 | #include <linux/rtc.h> | 24 | #include <linux/rtc.h> |
24 | #include <linux/slab.h> | 25 | #include <linux/slab.h> |
25 | #include <linux/mutex.h> | 26 | #include <linux/mutex.h> |
@@ -86,8 +87,66 @@ static const struct i2c_device_id m41t80_id[] = { | |||
86 | }; | 87 | }; |
87 | MODULE_DEVICE_TABLE(i2c, m41t80_id); | 88 | MODULE_DEVICE_TABLE(i2c, m41t80_id); |
88 | 89 | ||
90 | static const struct of_device_id m41t80_of_match[] = { | ||
91 | { | ||
92 | .compatible = "st,m41t62", | ||
93 | .data = (void *)(M41T80_FEATURE_SQ | M41T80_FEATURE_SQ_ALT) | ||
94 | }, | ||
95 | { | ||
96 | .compatible = "st,m41t65", | ||
97 | .data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_WD) | ||
98 | }, | ||
99 | { | ||
100 | .compatible = "st,m41t80", | ||
101 | .data = (void *)(M41T80_FEATURE_SQ) | ||
102 | }, | ||
103 | { | ||
104 | .compatible = "st,m41t81", | ||
105 | .data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_SQ) | ||
106 | }, | ||
107 | { | ||
108 | .compatible = "st,m41t81s", | ||
109 | .data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ) | ||
110 | }, | ||
111 | { | ||
112 | .compatible = "st,m41t82", | ||
113 | .data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ) | ||
114 | }, | ||
115 | { | ||
116 | .compatible = "st,m41t83", | ||
117 | .data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ) | ||
118 | }, | ||
119 | { | ||
120 | .compatible = "st,m41t84", | ||
121 | .data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ) | ||
122 | }, | ||
123 | { | ||
124 | .compatible = "st,m41t85", | ||
125 | .data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ) | ||
126 | }, | ||
127 | { | ||
128 | .compatible = "st,m41t87", | ||
129 | .data = (void *)(M41T80_FEATURE_HT | M41T80_FEATURE_BL | M41T80_FEATURE_SQ) | ||
130 | }, | ||
131 | { | ||
132 | .compatible = "microcrystal,rv4162", | ||
133 | .data = (void *)(M41T80_FEATURE_SQ | M41T80_FEATURE_WD | M41T80_FEATURE_SQ_ALT) | ||
134 | }, | ||
135 | /* DT compatibility only, do not use compatibles below: */ | ||
136 | { | ||
137 | .compatible = "st,rv4162", | ||
138 | .data = (void *)(M41T80_FEATURE_SQ | M41T80_FEATURE_WD | M41T80_FEATURE_SQ_ALT) | ||
139 | }, | ||
140 | { | ||
141 | .compatible = "rv4162", | ||
142 | .data = (void *)(M41T80_FEATURE_SQ | M41T80_FEATURE_WD | M41T80_FEATURE_SQ_ALT) | ||
143 | }, | ||
144 | { } | ||
145 | }; | ||
146 | MODULE_DEVICE_TABLE(of, m41t80_of_match); | ||
147 | |||
89 | struct m41t80_data { | 148 | struct m41t80_data { |
90 | u8 features; | 149 | unsigned long features; |
91 | struct rtc_device *rtc; | 150 | struct rtc_device *rtc; |
92 | }; | 151 | }; |
93 | 152 | ||
@@ -786,7 +845,11 @@ static int m41t80_probe(struct i2c_client *client, | |||
786 | if (!m41t80_data) | 845 | if (!m41t80_data) |
787 | return -ENOMEM; | 846 | return -ENOMEM; |
788 | 847 | ||
789 | m41t80_data->features = id->driver_data; | 848 | if (client->dev.of_node) |
849 | m41t80_data->features = (unsigned long) | ||
850 | of_device_get_match_data(&client->dev); | ||
851 | else | ||
852 | m41t80_data->features = id->driver_data; | ||
790 | i2c_set_clientdata(client, m41t80_data); | 853 | i2c_set_clientdata(client, m41t80_data); |
791 | 854 | ||
792 | if (client->irq > 0) { | 855 | if (client->irq > 0) { |
@@ -894,6 +957,7 @@ static int m41t80_remove(struct i2c_client *client) | |||
894 | static struct i2c_driver m41t80_driver = { | 957 | static struct i2c_driver m41t80_driver = { |
895 | .driver = { | 958 | .driver = { |
896 | .name = "rtc-m41t80", | 959 | .name = "rtc-m41t80", |
960 | .of_match_table = of_match_ptr(m41t80_of_match), | ||
897 | .pm = &m41t80_pm, | 961 | .pm = &m41t80_pm, |
898 | }, | 962 | }, |
899 | .probe = m41t80_probe, | 963 | .probe = m41t80_probe, |
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index 73594f38c453..13f7cd11c07e 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c | |||
@@ -844,7 +844,7 @@ err: | |||
844 | return ret; | 844 | return ret; |
845 | } | 845 | } |
846 | 846 | ||
847 | static int __exit omap_rtc_remove(struct platform_device *pdev) | 847 | static int omap_rtc_remove(struct platform_device *pdev) |
848 | { | 848 | { |
849 | struct omap_rtc *rtc = platform_get_drvdata(pdev); | 849 | struct omap_rtc *rtc = platform_get_drvdata(pdev); |
850 | u8 reg; | 850 | u8 reg; |
@@ -882,8 +882,7 @@ static int __exit omap_rtc_remove(struct platform_device *pdev) | |||
882 | return 0; | 882 | return 0; |
883 | } | 883 | } |
884 | 884 | ||
885 | #ifdef CONFIG_PM_SLEEP | 885 | static int __maybe_unused omap_rtc_suspend(struct device *dev) |
886 | static int omap_rtc_suspend(struct device *dev) | ||
887 | { | 886 | { |
888 | struct omap_rtc *rtc = dev_get_drvdata(dev); | 887 | struct omap_rtc *rtc = dev_get_drvdata(dev); |
889 | 888 | ||
@@ -906,7 +905,7 @@ static int omap_rtc_suspend(struct device *dev) | |||
906 | return 0; | 905 | return 0; |
907 | } | 906 | } |
908 | 907 | ||
909 | static int omap_rtc_resume(struct device *dev) | 908 | static int __maybe_unused omap_rtc_resume(struct device *dev) |
910 | { | 909 | { |
911 | struct omap_rtc *rtc = dev_get_drvdata(dev); | 910 | struct omap_rtc *rtc = dev_get_drvdata(dev); |
912 | 911 | ||
@@ -921,10 +920,8 @@ static int omap_rtc_resume(struct device *dev) | |||
921 | 920 | ||
922 | return 0; | 921 | return 0; |
923 | } | 922 | } |
924 | #endif | ||
925 | 923 | ||
926 | #ifdef CONFIG_PM | 924 | static int __maybe_unused omap_rtc_runtime_suspend(struct device *dev) |
927 | static int omap_rtc_runtime_suspend(struct device *dev) | ||
928 | { | 925 | { |
929 | struct omap_rtc *rtc = dev_get_drvdata(dev); | 926 | struct omap_rtc *rtc = dev_get_drvdata(dev); |
930 | 927 | ||
@@ -934,16 +931,9 @@ static int omap_rtc_runtime_suspend(struct device *dev) | |||
934 | return 0; | 931 | return 0; |
935 | } | 932 | } |
936 | 933 | ||
937 | static int omap_rtc_runtime_resume(struct device *dev) | ||
938 | { | ||
939 | return 0; | ||
940 | } | ||
941 | #endif | ||
942 | |||
943 | static const struct dev_pm_ops omap_rtc_pm_ops = { | 934 | static const struct dev_pm_ops omap_rtc_pm_ops = { |
944 | SET_SYSTEM_SLEEP_PM_OPS(omap_rtc_suspend, omap_rtc_resume) | 935 | SET_SYSTEM_SLEEP_PM_OPS(omap_rtc_suspend, omap_rtc_resume) |
945 | SET_RUNTIME_PM_OPS(omap_rtc_runtime_suspend, | 936 | SET_RUNTIME_PM_OPS(omap_rtc_runtime_suspend, NULL, NULL) |
946 | omap_rtc_runtime_resume, NULL) | ||
947 | }; | 937 | }; |
948 | 938 | ||
949 | static void omap_rtc_shutdown(struct platform_device *pdev) | 939 | static void omap_rtc_shutdown(struct platform_device *pdev) |
@@ -964,7 +954,7 @@ static void omap_rtc_shutdown(struct platform_device *pdev) | |||
964 | 954 | ||
965 | static struct platform_driver omap_rtc_driver = { | 955 | static struct platform_driver omap_rtc_driver = { |
966 | .probe = omap_rtc_probe, | 956 | .probe = omap_rtc_probe, |
967 | .remove = __exit_p(omap_rtc_remove), | 957 | .remove = omap_rtc_remove, |
968 | .shutdown = omap_rtc_shutdown, | 958 | .shutdown = omap_rtc_shutdown, |
969 | .driver = { | 959 | .driver = { |
970 | .name = "omap_rtc", | 960 | .name = "omap_rtc", |
diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c index c8c757466783..d4eff8d7131f 100644 --- a/drivers/rtc/rtc-rs5c372.c +++ b/drivers/rtc/rtc-rs5c372.c | |||
@@ -15,6 +15,7 @@ | |||
15 | #include <linux/bcd.h> | 15 | #include <linux/bcd.h> |
16 | #include <linux/slab.h> | 16 | #include <linux/slab.h> |
17 | #include <linux/module.h> | 17 | #include <linux/module.h> |
18 | #include <linux/of_device.h> | ||
18 | 19 | ||
19 | /* | 20 | /* |
20 | * Ricoh has a family of I2C based RTCs, which differ only slightly from | 21 | * Ricoh has a family of I2C based RTCs, which differ only slightly from |
@@ -83,6 +84,35 @@ static const struct i2c_device_id rs5c372_id[] = { | |||
83 | }; | 84 | }; |
84 | MODULE_DEVICE_TABLE(i2c, rs5c372_id); | 85 | MODULE_DEVICE_TABLE(i2c, rs5c372_id); |
85 | 86 | ||
87 | static const struct of_device_id rs5c372_of_match[] = { | ||
88 | { | ||
89 | .compatible = "ricoh,r2025sd", | ||
90 | .data = (void *)rtc_r2025sd | ||
91 | }, | ||
92 | { | ||
93 | .compatible = "ricoh,r2221tl", | ||
94 | .data = (void *)rtc_r2221tl | ||
95 | }, | ||
96 | { | ||
97 | .compatible = "ricoh,rs5c372a", | ||
98 | .data = (void *)rtc_rs5c372a | ||
99 | }, | ||
100 | { | ||
101 | .compatible = "ricoh,rs5c372b", | ||
102 | .data = (void *)rtc_rs5c372b | ||
103 | }, | ||
104 | { | ||
105 | .compatible = "ricoh,rv5c386", | ||
106 | .data = (void *)rtc_rv5c386 | ||
107 | }, | ||
108 | { | ||
109 | .compatible = "ricoh,rv5c387a", | ||
110 | .data = (void *)rtc_rv5c387a | ||
111 | }, | ||
112 | { } | ||
113 | }; | ||
114 | MODULE_DEVICE_TABLE(of, rs5c372_of_match); | ||
115 | |||
86 | /* REVISIT: this assumes that: | 116 | /* REVISIT: this assumes that: |
87 | * - we're in the 21st century, so it's safe to ignore the century | 117 | * - we're in the 21st century, so it's safe to ignore the century |
88 | * bit for rv5c38[67] (REG_MONTH bit 7); | 118 | * bit for rv5c38[67] (REG_MONTH bit 7); |
@@ -581,7 +611,11 @@ static int rs5c372_probe(struct i2c_client *client, | |||
581 | 611 | ||
582 | rs5c372->client = client; | 612 | rs5c372->client = client; |
583 | i2c_set_clientdata(client, rs5c372); | 613 | i2c_set_clientdata(client, rs5c372); |
584 | rs5c372->type = id->driver_data; | 614 | if (client->dev.of_node) |
615 | rs5c372->type = (enum rtc_type) | ||
616 | of_device_get_match_data(&client->dev); | ||
617 | else | ||
618 | rs5c372->type = id->driver_data; | ||
585 | 619 | ||
586 | /* we read registers 0x0f then 0x00-0x0f; skip the first one */ | 620 | /* we read registers 0x0f then 0x00-0x0f; skip the first one */ |
587 | rs5c372->regs = &rs5c372->buf[1]; | 621 | rs5c372->regs = &rs5c372->buf[1]; |
@@ -673,6 +707,7 @@ static int rs5c372_remove(struct i2c_client *client) | |||
673 | static struct i2c_driver rs5c372_driver = { | 707 | static struct i2c_driver rs5c372_driver = { |
674 | .driver = { | 708 | .driver = { |
675 | .name = "rtc-rs5c372", | 709 | .name = "rtc-rs5c372", |
710 | .of_match_table = of_match_ptr(rs5c372_of_match), | ||
676 | }, | 711 | }, |
677 | .probe = rs5c372_probe, | 712 | .probe = rs5c372_probe, |
678 | .remove = rs5c372_remove, | 713 | .remove = rs5c372_remove, |
diff --git a/drivers/rtc/rtc-rv3029c2.c b/drivers/rtc/rtc-rv3029c2.c index 1f9f7b4bf3fb..85fa1da03762 100644 --- a/drivers/rtc/rtc-rv3029c2.c +++ b/drivers/rtc/rtc-rv3029c2.c | |||
@@ -875,9 +875,18 @@ static struct i2c_device_id rv3029_id[] = { | |||
875 | }; | 875 | }; |
876 | MODULE_DEVICE_TABLE(i2c, rv3029_id); | 876 | MODULE_DEVICE_TABLE(i2c, rv3029_id); |
877 | 877 | ||
878 | static const struct of_device_id rv3029_of_match[] = { | ||
879 | { .compatible = "rv3029" }, | ||
880 | { .compatible = "rv3029c2" }, | ||
881 | { .compatible = "mc,rv3029c2" }, | ||
882 | { } | ||
883 | }; | ||
884 | MODULE_DEVICE_TABLE(of, rv3029_of_match); | ||
885 | |||
878 | static struct i2c_driver rv3029_driver = { | 886 | static struct i2c_driver rv3029_driver = { |
879 | .driver = { | 887 | .driver = { |
880 | .name = "rtc-rv3029c2", | 888 | .name = "rtc-rv3029c2", |
889 | .of_match_table = of_match_ptr(rv3029_of_match), | ||
881 | }, | 890 | }, |
882 | .probe = rv3029_i2c_probe, | 891 | .probe = rv3029_i2c_probe, |
883 | .id_table = rv3029_id, | 892 | .id_table = rv3029_id, |
diff --git a/drivers/rtc/rtc-rv8803.c b/drivers/rtc/rtc-rv8803.c index f9277e536f7e..9ad97ab29866 100644 --- a/drivers/rtc/rtc-rv8803.c +++ b/drivers/rtc/rtc-rv8803.c | |||
@@ -18,6 +18,7 @@ | |||
18 | #include <linux/interrupt.h> | 18 | #include <linux/interrupt.h> |
19 | #include <linux/kernel.h> | 19 | #include <linux/kernel.h> |
20 | #include <linux/module.h> | 20 | #include <linux/module.h> |
21 | #include <linux/of_device.h> | ||
21 | #include <linux/rtc.h> | 22 | #include <linux/rtc.h> |
22 | 23 | ||
23 | #define RV8803_I2C_TRY_COUNT 4 | 24 | #define RV8803_I2C_TRY_COUNT 4 |
@@ -556,7 +557,11 @@ static int rv8803_probe(struct i2c_client *client, | |||
556 | 557 | ||
557 | mutex_init(&rv8803->flags_lock); | 558 | mutex_init(&rv8803->flags_lock); |
558 | rv8803->client = client; | 559 | rv8803->client = client; |
559 | rv8803->type = id->driver_data; | 560 | if (client->dev.of_node) |
561 | rv8803->type = (enum rv8803_type) | ||
562 | of_device_get_match_data(&client->dev); | ||
563 | else | ||
564 | rv8803->type = id->driver_data; | ||
560 | i2c_set_clientdata(client, rv8803); | 565 | i2c_set_clientdata(client, rv8803); |
561 | 566 | ||
562 | flags = rv8803_read_reg(client, RV8803_FLAG); | 567 | flags = rv8803_read_reg(client, RV8803_FLAG); |
@@ -627,9 +632,23 @@ static const struct i2c_device_id rv8803_id[] = { | |||
627 | }; | 632 | }; |
628 | MODULE_DEVICE_TABLE(i2c, rv8803_id); | 633 | MODULE_DEVICE_TABLE(i2c, rv8803_id); |
629 | 634 | ||
635 | static const struct of_device_id rv8803_of_match[] = { | ||
636 | { | ||
637 | .compatible = "microcrystal,rv8803", | ||
638 | .data = (void *)rx_8900 | ||
639 | }, | ||
640 | { | ||
641 | .compatible = "epson,rx8900", | ||
642 | .data = (void *)rx_8900 | ||
643 | }, | ||
644 | { } | ||
645 | }; | ||
646 | MODULE_DEVICE_TABLE(of, rv8803_of_match); | ||
647 | |||
630 | static struct i2c_driver rv8803_driver = { | 648 | static struct i2c_driver rv8803_driver = { |
631 | .driver = { | 649 | .driver = { |
632 | .name = "rtc-rv8803", | 650 | .name = "rtc-rv8803", |
651 | .of_match_table = of_match_ptr(rv8803_of_match), | ||
633 | }, | 652 | }, |
634 | .probe = rv8803_probe, | 653 | .probe = rv8803_probe, |
635 | .remove = rv8803_remove, | 654 | .remove = rv8803_remove, |
diff --git a/drivers/rtc/rtc-rx8010.c b/drivers/rtc/rtc-rx8010.c index d08da371912c..1ed3403ff8ac 100644 --- a/drivers/rtc/rtc-rx8010.c +++ b/drivers/rtc/rtc-rx8010.c | |||
@@ -59,6 +59,12 @@ static const struct i2c_device_id rx8010_id[] = { | |||
59 | }; | 59 | }; |
60 | MODULE_DEVICE_TABLE(i2c, rx8010_id); | 60 | MODULE_DEVICE_TABLE(i2c, rx8010_id); |
61 | 61 | ||
62 | static const struct of_device_id rx8010_of_match[] = { | ||
63 | { .compatible = "epson,rx8010" }, | ||
64 | { } | ||
65 | }; | ||
66 | MODULE_DEVICE_TABLE(of, rx8010_of_match); | ||
67 | |||
62 | struct rx8010_data { | 68 | struct rx8010_data { |
63 | struct i2c_client *client; | 69 | struct i2c_client *client; |
64 | struct rtc_device *rtc; | 70 | struct rtc_device *rtc; |
@@ -487,6 +493,7 @@ static int rx8010_probe(struct i2c_client *client, | |||
487 | static struct i2c_driver rx8010_driver = { | 493 | static struct i2c_driver rx8010_driver = { |
488 | .driver = { | 494 | .driver = { |
489 | .name = "rtc-rx8010", | 495 | .name = "rtc-rx8010", |
496 | .of_match_table = of_match_ptr(rx8010_of_match), | ||
490 | }, | 497 | }, |
491 | .probe = rx8010_probe, | 498 | .probe = rx8010_probe, |
492 | .id_table = rx8010_id, | 499 | .id_table = rx8010_id, |
diff --git a/drivers/rtc/rtc-rx8581.c b/drivers/rtc/rtc-rx8581.c index 0c362a3d1f17..9998d7937688 100644 --- a/drivers/rtc/rtc-rx8581.c +++ b/drivers/rtc/rtc-rx8581.c | |||
@@ -308,9 +308,16 @@ static const struct i2c_device_id rx8581_id[] = { | |||
308 | }; | 308 | }; |
309 | MODULE_DEVICE_TABLE(i2c, rx8581_id); | 309 | MODULE_DEVICE_TABLE(i2c, rx8581_id); |
310 | 310 | ||
311 | static const struct of_device_id rx8581_of_match[] = { | ||
312 | { .compatible = "epson,rx8581" }, | ||
313 | { } | ||
314 | }; | ||
315 | MODULE_DEVICE_TABLE(of, rx8581_of_match); | ||
316 | |||
311 | static struct i2c_driver rx8581_driver = { | 317 | static struct i2c_driver rx8581_driver = { |
312 | .driver = { | 318 | .driver = { |
313 | .name = "rtc-rx8581", | 319 | .name = "rtc-rx8581", |
320 | .of_match_table = of_match_ptr(rx8581_of_match), | ||
314 | }, | 321 | }, |
315 | .probe = rx8581_probe, | 322 | .probe = rx8581_probe, |
316 | .id_table = rx8581_id, | 323 | .id_table = rx8581_id, |
diff --git a/drivers/rtc/rtc-s35390a.c b/drivers/rtc/rtc-s35390a.c index 5dab4665ca3b..449820eeefe8 100644 --- a/drivers/rtc/rtc-s35390a.c +++ b/drivers/rtc/rtc-s35390a.c | |||
@@ -58,6 +58,13 @@ static const struct i2c_device_id s35390a_id[] = { | |||
58 | }; | 58 | }; |
59 | MODULE_DEVICE_TABLE(i2c, s35390a_id); | 59 | MODULE_DEVICE_TABLE(i2c, s35390a_id); |
60 | 60 | ||
61 | static const struct of_device_id s35390a_of_match[] = { | ||
62 | { .compatible = "s35390a" }, | ||
63 | { .compatible = "sii,s35390a" }, | ||
64 | { } | ||
65 | }; | ||
66 | MODULE_DEVICE_TABLE(of, s35390a_of_match); | ||
67 | |||
61 | struct s35390a { | 68 | struct s35390a { |
62 | struct i2c_client *client[8]; | 69 | struct i2c_client *client[8]; |
63 | struct rtc_device *rtc; | 70 | struct rtc_device *rtc; |
@@ -502,6 +509,7 @@ static int s35390a_remove(struct i2c_client *client) | |||
502 | static struct i2c_driver s35390a_driver = { | 509 | static struct i2c_driver s35390a_driver = { |
503 | .driver = { | 510 | .driver = { |
504 | .name = "rtc-s35390a", | 511 | .name = "rtc-s35390a", |
512 | .of_match_table = of_match_ptr(s35390a_of_match), | ||
505 | }, | 513 | }, |
506 | .probe = s35390a_probe, | 514 | .probe = s35390a_probe, |
507 | .remove = s35390a_remove, | 515 | .remove = s35390a_remove, |
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c index c626e43a9cbb..6c2d3989f967 100644 --- a/drivers/rtc/rtc-sh.c +++ b/drivers/rtc/rtc-sh.c | |||
@@ -27,7 +27,15 @@ | |||
27 | #include <linux/log2.h> | 27 | #include <linux/log2.h> |
28 | #include <linux/clk.h> | 28 | #include <linux/clk.h> |
29 | #include <linux/slab.h> | 29 | #include <linux/slab.h> |
30 | #ifdef CONFIG_SUPERH | ||
30 | #include <asm/rtc.h> | 31 | #include <asm/rtc.h> |
32 | #else | ||
33 | /* Default values for RZ/A RTC */ | ||
34 | #define rtc_reg_size sizeof(u16) | ||
35 | #define RTC_BIT_INVERTED 0 /* no chip bugs */ | ||
36 | #define RTC_CAP_4_DIGIT_YEAR (1 << 0) | ||
37 | #define RTC_DEF_CAPABILITIES RTC_CAP_4_DIGIT_YEAR | ||
38 | #endif | ||
31 | 39 | ||
32 | #define DRV_NAME "sh-rtc" | 40 | #define DRV_NAME "sh-rtc" |
33 | 41 | ||
@@ -570,6 +578,8 @@ static int __init sh_rtc_probe(struct platform_device *pdev) | |||
570 | rtc->alarm_irq = platform_get_irq(pdev, 2); | 578 | rtc->alarm_irq = platform_get_irq(pdev, 2); |
571 | 579 | ||
572 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); | 580 | res = platform_get_resource(pdev, IORESOURCE_IO, 0); |
581 | if (!res) | ||
582 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
573 | if (unlikely(res == NULL)) { | 583 | if (unlikely(res == NULL)) { |
574 | dev_err(&pdev->dev, "No IO resource\n"); | 584 | dev_err(&pdev->dev, "No IO resource\n"); |
575 | return -ENOENT; | 585 | return -ENOENT; |
@@ -587,12 +597,15 @@ static int __init sh_rtc_probe(struct platform_device *pdev) | |||
587 | if (unlikely(!rtc->regbase)) | 597 | if (unlikely(!rtc->regbase)) |
588 | return -EINVAL; | 598 | return -EINVAL; |
589 | 599 | ||
590 | clk_id = pdev->id; | 600 | if (!pdev->dev.of_node) { |
591 | /* With a single device, the clock id is still "rtc0" */ | 601 | clk_id = pdev->id; |
592 | if (clk_id < 0) | 602 | /* With a single device, the clock id is still "rtc0" */ |
593 | clk_id = 0; | 603 | if (clk_id < 0) |
604 | clk_id = 0; | ||
594 | 605 | ||
595 | snprintf(clk_name, sizeof(clk_name), "rtc%d", clk_id); | 606 | snprintf(clk_name, sizeof(clk_name), "rtc%d", clk_id); |
607 | } else | ||
608 | snprintf(clk_name, sizeof(clk_name), "fck"); | ||
596 | 609 | ||
597 | rtc->clk = devm_clk_get(&pdev->dev, clk_name); | 610 | rtc->clk = devm_clk_get(&pdev->dev, clk_name); |
598 | if (IS_ERR(rtc->clk)) { | 611 | if (IS_ERR(rtc->clk)) { |
@@ -608,6 +621,8 @@ static int __init sh_rtc_probe(struct platform_device *pdev) | |||
608 | clk_enable(rtc->clk); | 621 | clk_enable(rtc->clk); |
609 | 622 | ||
610 | rtc->capabilities = RTC_DEF_CAPABILITIES; | 623 | rtc->capabilities = RTC_DEF_CAPABILITIES; |
624 | |||
625 | #ifdef CONFIG_SUPERH | ||
611 | if (dev_get_platdata(&pdev->dev)) { | 626 | if (dev_get_platdata(&pdev->dev)) { |
612 | struct sh_rtc_platform_info *pinfo = | 627 | struct sh_rtc_platform_info *pinfo = |
613 | dev_get_platdata(&pdev->dev); | 628 | dev_get_platdata(&pdev->dev); |
@@ -618,6 +633,7 @@ static int __init sh_rtc_probe(struct platform_device *pdev) | |||
618 | */ | 633 | */ |
619 | rtc->capabilities |= pinfo->capabilities; | 634 | rtc->capabilities |= pinfo->capabilities; |
620 | } | 635 | } |
636 | #endif | ||
621 | 637 | ||
622 | if (rtc->carry_irq <= 0) { | 638 | if (rtc->carry_irq <= 0) { |
623 | /* register shared periodic/carry/alarm irq */ | 639 | /* register shared periodic/carry/alarm irq */ |
@@ -718,8 +734,7 @@ static void sh_rtc_set_irq_wake(struct device *dev, int enabled) | |||
718 | } | 734 | } |
719 | } | 735 | } |
720 | 736 | ||
721 | #ifdef CONFIG_PM_SLEEP | 737 | static int __maybe_unused sh_rtc_suspend(struct device *dev) |
722 | static int sh_rtc_suspend(struct device *dev) | ||
723 | { | 738 | { |
724 | if (device_may_wakeup(dev)) | 739 | if (device_may_wakeup(dev)) |
725 | sh_rtc_set_irq_wake(dev, 1); | 740 | sh_rtc_set_irq_wake(dev, 1); |
@@ -727,21 +742,27 @@ static int sh_rtc_suspend(struct device *dev) | |||
727 | return 0; | 742 | return 0; |
728 | } | 743 | } |
729 | 744 | ||
730 | static int sh_rtc_resume(struct device *dev) | 745 | static int __maybe_unused sh_rtc_resume(struct device *dev) |
731 | { | 746 | { |
732 | if (device_may_wakeup(dev)) | 747 | if (device_may_wakeup(dev)) |
733 | sh_rtc_set_irq_wake(dev, 0); | 748 | sh_rtc_set_irq_wake(dev, 0); |
734 | 749 | ||
735 | return 0; | 750 | return 0; |
736 | } | 751 | } |
737 | #endif | ||
738 | 752 | ||
739 | static SIMPLE_DEV_PM_OPS(sh_rtc_pm_ops, sh_rtc_suspend, sh_rtc_resume); | 753 | static SIMPLE_DEV_PM_OPS(sh_rtc_pm_ops, sh_rtc_suspend, sh_rtc_resume); |
740 | 754 | ||
755 | static const struct of_device_id sh_rtc_of_match[] = { | ||
756 | { .compatible = "renesas,sh-rtc", }, | ||
757 | { /* sentinel */ } | ||
758 | }; | ||
759 | MODULE_DEVICE_TABLE(of, sh_rtc_of_match); | ||
760 | |||
741 | static struct platform_driver sh_rtc_platform_driver = { | 761 | static struct platform_driver sh_rtc_platform_driver = { |
742 | .driver = { | 762 | .driver = { |
743 | .name = DRV_NAME, | 763 | .name = DRV_NAME, |
744 | .pm = &sh_rtc_pm_ops, | 764 | .pm = &sh_rtc_pm_ops, |
765 | .of_match_table = sh_rtc_of_match, | ||
745 | }, | 766 | }, |
746 | .remove = __exit_p(sh_rtc_remove), | 767 | .remove = __exit_p(sh_rtc_remove), |
747 | }; | 768 | }; |
diff --git a/drivers/rtc/rtc-snvs.c b/drivers/rtc/rtc-snvs.c index d51b07d620f7..d8ef9e052c4f 100644 --- a/drivers/rtc/rtc-snvs.c +++ b/drivers/rtc/rtc-snvs.c | |||
@@ -258,7 +258,7 @@ static int snvs_rtc_probe(struct platform_device *pdev) | |||
258 | of_property_read_u32(pdev->dev.of_node, "offset", &data->offset); | 258 | of_property_read_u32(pdev->dev.of_node, "offset", &data->offset); |
259 | } | 259 | } |
260 | 260 | ||
261 | if (!data->regmap) { | 261 | if (IS_ERR(data->regmap)) { |
262 | dev_err(&pdev->dev, "Can't find snvs syscon\n"); | 262 | dev_err(&pdev->dev, "Can't find snvs syscon\n"); |
263 | return -ENODEV; | 263 | return -ENODEV; |
264 | } | 264 | } |
diff --git a/drivers/rtc/rtc-wm8350.c b/drivers/rtc/rtc-wm8350.c index fa247deb9cf4..483c7993516b 100644 --- a/drivers/rtc/rtc-wm8350.c +++ b/drivers/rtc/rtc-wm8350.c | |||
@@ -30,8 +30,6 @@ | |||
30 | #define WM8350_SET_TIME_RETRIES 5 | 30 | #define WM8350_SET_TIME_RETRIES 5 |
31 | #define WM8350_GET_TIME_RETRIES 5 | 31 | #define WM8350_GET_TIME_RETRIES 5 |
32 | 32 | ||
33 | #define to_wm8350_from_rtc_dev(d) container_of(d, struct wm8350, rtc.pdev.dev) | ||
34 | |||
35 | /* | 33 | /* |
36 | * Read current time and date in RTC | 34 | * Read current time and date in RTC |
37 | */ | 35 | */ |