diff options
author | Thomas Gleixner <tglx@linutronix.de> | 2011-05-14 06:06:36 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2011-05-14 06:06:36 -0400 |
commit | a18f22a968de17b29f2310cdb7ba69163e65ec15 (patch) | |
tree | a7d56d88fad5e444d7661484109758a2f436129e /drivers/rtc | |
parent | a1c57e0fec53defe745e64417eacdbd3618c3e66 (diff) | |
parent | 798778b8653f64b7b2162ac70eca10367cff6ce8 (diff) |
Merge branch 'consolidate-clksrc-i8253' of master.kernel.org:~rmk/linux-2.6-arm into timers/clocksource
Conflicts:
arch/ia64/kernel/cyclone.c
arch/mips/kernel/i8253.c
arch/x86/kernel/i8253.c
Reason: Resolve conflicts so further cleanups do not conflict further
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'drivers/rtc')
46 files changed, 1028 insertions, 951 deletions
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 4941cade319f..e1878877399c 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
@@ -985,4 +985,14 @@ config RTC_DRV_LPC32XX | |||
985 | This driver can also be buillt as a module. If so, the module | 985 | This driver can also be buillt as a module. If so, the module |
986 | will be called rtc-lpc32xx. | 986 | will be called rtc-lpc32xx. |
987 | 987 | ||
988 | config RTC_DRV_TEGRA | ||
989 | tristate "NVIDIA Tegra Internal RTC driver" | ||
990 | depends on RTC_CLASS && ARCH_TEGRA | ||
991 | help | ||
992 | If you say yes here you get support for the | ||
993 | Tegra 200 series internal RTC module. | ||
994 | |||
995 | This drive can also be built as a module. If so, the module | ||
996 | will be called rtc-tegra. | ||
997 | |||
988 | endif # RTC_CLASS | 998 | endif # RTC_CLASS |
diff --git a/drivers/rtc/Makefile b/drivers/rtc/Makefile index 2afdaf3ff986..ca91c3c42e98 100644 --- a/drivers/rtc/Makefile +++ b/drivers/rtc/Makefile | |||
@@ -2,9 +2,7 @@ | |||
2 | # Makefile for RTC class/drivers. | 2 | # Makefile for RTC class/drivers. |
3 | # | 3 | # |
4 | 4 | ||
5 | ifeq ($(CONFIG_RTC_DEBUG),y) | 5 | ccflags-$(CONFIG_RTC_DEBUG) := -DDEBUG |
6 | EXTRA_CFLAGS += -DDEBUG | ||
7 | endif | ||
8 | 6 | ||
9 | obj-$(CONFIG_RTC_LIB) += rtc-lib.o | 7 | obj-$(CONFIG_RTC_LIB) += rtc-lib.o |
10 | obj-$(CONFIG_RTC_HCTOSYS) += hctosys.o | 8 | obj-$(CONFIG_RTC_HCTOSYS) += hctosys.o |
@@ -93,6 +91,7 @@ obj-$(CONFIG_RTC_DRV_STARFIRE) += rtc-starfire.o | |||
93 | obj-$(CONFIG_RTC_DRV_STK17TA8) += rtc-stk17ta8.o | 91 | obj-$(CONFIG_RTC_DRV_STK17TA8) += rtc-stk17ta8.o |
94 | obj-$(CONFIG_RTC_DRV_STMP) += rtc-stmp3xxx.o | 92 | obj-$(CONFIG_RTC_DRV_STMP) += rtc-stmp3xxx.o |
95 | obj-$(CONFIG_RTC_DRV_SUN4V) += rtc-sun4v.o | 93 | obj-$(CONFIG_RTC_DRV_SUN4V) += rtc-sun4v.o |
94 | obj-$(CONFIG_RTC_DRV_TEGRA) += rtc-tegra.o | ||
96 | obj-$(CONFIG_RTC_DRV_TEST) += rtc-test.o | 95 | obj-$(CONFIG_RTC_DRV_TEST) += rtc-test.o |
97 | obj-$(CONFIG_RTC_DRV_TWL4030) += rtc-twl.o | 96 | obj-$(CONFIG_RTC_DRV_TWL4030) += rtc-twl.o |
98 | obj-$(CONFIG_RTC_DRV_TX4939) += rtc-tx4939.o | 97 | obj-$(CONFIG_RTC_DRV_TX4939) += rtc-tx4939.o |
diff --git a/drivers/rtc/class.c b/drivers/rtc/class.c index c404b61386bf..39013867cbd6 100644 --- a/drivers/rtc/class.c +++ b/drivers/rtc/class.c | |||
@@ -117,6 +117,7 @@ struct rtc_device *rtc_device_register(const char *name, struct device *dev, | |||
117 | struct module *owner) | 117 | struct module *owner) |
118 | { | 118 | { |
119 | struct rtc_device *rtc; | 119 | struct rtc_device *rtc; |
120 | struct rtc_wkalrm alrm; | ||
120 | int id, err; | 121 | int id, err; |
121 | 122 | ||
122 | if (idr_pre_get(&rtc_idr, GFP_KERNEL) == 0) { | 123 | if (idr_pre_get(&rtc_idr, GFP_KERNEL) == 0) { |
@@ -166,6 +167,12 @@ struct rtc_device *rtc_device_register(const char *name, struct device *dev, | |||
166 | rtc->pie_timer.function = rtc_pie_update_irq; | 167 | rtc->pie_timer.function = rtc_pie_update_irq; |
167 | rtc->pie_enabled = 0; | 168 | rtc->pie_enabled = 0; |
168 | 169 | ||
170 | /* Check to see if there is an ALARM already set in hw */ | ||
171 | err = __rtc_read_alarm(rtc, &alrm); | ||
172 | |||
173 | if (!err && !rtc_valid_tm(&alrm.time)) | ||
174 | rtc_initialize_alarm(rtc, &alrm); | ||
175 | |||
169 | strlcpy(rtc->name, name, RTC_DEVICE_NAME_SIZE); | 176 | strlcpy(rtc->name, name, RTC_DEVICE_NAME_SIZE); |
170 | dev_set_name(&rtc->dev, "rtc%d", id); | 177 | dev_set_name(&rtc->dev, "rtc%d", id); |
171 | 178 | ||
diff --git a/drivers/rtc/interface.c b/drivers/rtc/interface.c index cb2f0728fd70..ef6316acec43 100644 --- a/drivers/rtc/interface.c +++ b/drivers/rtc/interface.c | |||
@@ -116,6 +116,186 @@ int rtc_set_mmss(struct rtc_device *rtc, unsigned long secs) | |||
116 | } | 116 | } |
117 | EXPORT_SYMBOL_GPL(rtc_set_mmss); | 117 | EXPORT_SYMBOL_GPL(rtc_set_mmss); |
118 | 118 | ||
119 | static int rtc_read_alarm_internal(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | ||
120 | { | ||
121 | int err; | ||
122 | |||
123 | err = mutex_lock_interruptible(&rtc->ops_lock); | ||
124 | if (err) | ||
125 | return err; | ||
126 | |||
127 | if (rtc->ops == NULL) | ||
128 | err = -ENODEV; | ||
129 | else if (!rtc->ops->read_alarm) | ||
130 | err = -EINVAL; | ||
131 | else { | ||
132 | memset(alarm, 0, sizeof(struct rtc_wkalrm)); | ||
133 | err = rtc->ops->read_alarm(rtc->dev.parent, alarm); | ||
134 | } | ||
135 | |||
136 | mutex_unlock(&rtc->ops_lock); | ||
137 | return err; | ||
138 | } | ||
139 | |||
140 | int __rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | ||
141 | { | ||
142 | int err; | ||
143 | struct rtc_time before, now; | ||
144 | int first_time = 1; | ||
145 | unsigned long t_now, t_alm; | ||
146 | enum { none, day, month, year } missing = none; | ||
147 | unsigned days; | ||
148 | |||
149 | /* The lower level RTC driver may return -1 in some fields, | ||
150 | * creating invalid alarm->time values, for reasons like: | ||
151 | * | ||
152 | * - The hardware may not be capable of filling them in; | ||
153 | * many alarms match only on time-of-day fields, not | ||
154 | * day/month/year calendar data. | ||
155 | * | ||
156 | * - Some hardware uses illegal values as "wildcard" match | ||
157 | * values, which non-Linux firmware (like a BIOS) may try | ||
158 | * to set up as e.g. "alarm 15 minutes after each hour". | ||
159 | * Linux uses only oneshot alarms. | ||
160 | * | ||
161 | * When we see that here, we deal with it by using values from | ||
162 | * a current RTC timestamp for any missing (-1) values. The | ||
163 | * RTC driver prevents "periodic alarm" modes. | ||
164 | * | ||
165 | * But this can be racey, because some fields of the RTC timestamp | ||
166 | * may have wrapped in the interval since we read the RTC alarm, | ||
167 | * which would lead to us inserting inconsistent values in place | ||
168 | * of the -1 fields. | ||
169 | * | ||
170 | * Reading the alarm and timestamp in the reverse sequence | ||
171 | * would have the same race condition, and not solve the issue. | ||
172 | * | ||
173 | * So, we must first read the RTC timestamp, | ||
174 | * then read the RTC alarm value, | ||
175 | * and then read a second RTC timestamp. | ||
176 | * | ||
177 | * If any fields of the second timestamp have changed | ||
178 | * when compared with the first timestamp, then we know | ||
179 | * our timestamp may be inconsistent with that used by | ||
180 | * the low-level rtc_read_alarm_internal() function. | ||
181 | * | ||
182 | * So, when the two timestamps disagree, we just loop and do | ||
183 | * the process again to get a fully consistent set of values. | ||
184 | * | ||
185 | * This could all instead be done in the lower level driver, | ||
186 | * but since more than one lower level RTC implementation needs it, | ||
187 | * then it's probably best best to do it here instead of there.. | ||
188 | */ | ||
189 | |||
190 | /* Get the "before" timestamp */ | ||
191 | err = rtc_read_time(rtc, &before); | ||
192 | if (err < 0) | ||
193 | return err; | ||
194 | do { | ||
195 | if (!first_time) | ||
196 | memcpy(&before, &now, sizeof(struct rtc_time)); | ||
197 | first_time = 0; | ||
198 | |||
199 | /* get the RTC alarm values, which may be incomplete */ | ||
200 | err = rtc_read_alarm_internal(rtc, alarm); | ||
201 | if (err) | ||
202 | return err; | ||
203 | |||
204 | /* full-function RTCs won't have such missing fields */ | ||
205 | if (rtc_valid_tm(&alarm->time) == 0) | ||
206 | return 0; | ||
207 | |||
208 | /* get the "after" timestamp, to detect wrapped fields */ | ||
209 | err = rtc_read_time(rtc, &now); | ||
210 | if (err < 0) | ||
211 | return err; | ||
212 | |||
213 | /* note that tm_sec is a "don't care" value here: */ | ||
214 | } while ( before.tm_min != now.tm_min | ||
215 | || before.tm_hour != now.tm_hour | ||
216 | || before.tm_mon != now.tm_mon | ||
217 | || before.tm_year != now.tm_year); | ||
218 | |||
219 | /* Fill in the missing alarm fields using the timestamp; we | ||
220 | * know there's at least one since alarm->time is invalid. | ||
221 | */ | ||
222 | if (alarm->time.tm_sec == -1) | ||
223 | alarm->time.tm_sec = now.tm_sec; | ||
224 | if (alarm->time.tm_min == -1) | ||
225 | alarm->time.tm_min = now.tm_min; | ||
226 | if (alarm->time.tm_hour == -1) | ||
227 | alarm->time.tm_hour = now.tm_hour; | ||
228 | |||
229 | /* For simplicity, only support date rollover for now */ | ||
230 | if (alarm->time.tm_mday == -1) { | ||
231 | alarm->time.tm_mday = now.tm_mday; | ||
232 | missing = day; | ||
233 | } | ||
234 | if (alarm->time.tm_mon == -1) { | ||
235 | alarm->time.tm_mon = now.tm_mon; | ||
236 | if (missing == none) | ||
237 | missing = month; | ||
238 | } | ||
239 | if (alarm->time.tm_year == -1) { | ||
240 | alarm->time.tm_year = now.tm_year; | ||
241 | if (missing == none) | ||
242 | missing = year; | ||
243 | } | ||
244 | |||
245 | /* with luck, no rollover is needed */ | ||
246 | rtc_tm_to_time(&now, &t_now); | ||
247 | rtc_tm_to_time(&alarm->time, &t_alm); | ||
248 | if (t_now < t_alm) | ||
249 | goto done; | ||
250 | |||
251 | switch (missing) { | ||
252 | |||
253 | /* 24 hour rollover ... if it's now 10am Monday, an alarm that | ||
254 | * that will trigger at 5am will do so at 5am Tuesday, which | ||
255 | * could also be in the next month or year. This is a common | ||
256 | * case, especially for PCs. | ||
257 | */ | ||
258 | case day: | ||
259 | dev_dbg(&rtc->dev, "alarm rollover: %s\n", "day"); | ||
260 | t_alm += 24 * 60 * 60; | ||
261 | rtc_time_to_tm(t_alm, &alarm->time); | ||
262 | break; | ||
263 | |||
264 | /* Month rollover ... if it's the 31th, an alarm on the 3rd will | ||
265 | * be next month. An alarm matching on the 30th, 29th, or 28th | ||
266 | * may end up in the month after that! Many newer PCs support | ||
267 | * this type of alarm. | ||
268 | */ | ||
269 | case month: | ||
270 | dev_dbg(&rtc->dev, "alarm rollover: %s\n", "month"); | ||
271 | do { | ||
272 | if (alarm->time.tm_mon < 11) | ||
273 | alarm->time.tm_mon++; | ||
274 | else { | ||
275 | alarm->time.tm_mon = 0; | ||
276 | alarm->time.tm_year++; | ||
277 | } | ||
278 | days = rtc_month_days(alarm->time.tm_mon, | ||
279 | alarm->time.tm_year); | ||
280 | } while (days < alarm->time.tm_mday); | ||
281 | break; | ||
282 | |||
283 | /* Year rollover ... easy except for leap years! */ | ||
284 | case year: | ||
285 | dev_dbg(&rtc->dev, "alarm rollover: %s\n", "year"); | ||
286 | do { | ||
287 | alarm->time.tm_year++; | ||
288 | } while (rtc_valid_tm(&alarm->time) != 0); | ||
289 | break; | ||
290 | |||
291 | default: | ||
292 | dev_warn(&rtc->dev, "alarm rollover not handled\n"); | ||
293 | } | ||
294 | |||
295 | done: | ||
296 | return 0; | ||
297 | } | ||
298 | |||
119 | int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | 299 | int rtc_read_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) |
120 | { | 300 | { |
121 | int err; | 301 | int err; |
@@ -195,6 +375,32 @@ int rtc_set_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | |||
195 | } | 375 | } |
196 | EXPORT_SYMBOL_GPL(rtc_set_alarm); | 376 | EXPORT_SYMBOL_GPL(rtc_set_alarm); |
197 | 377 | ||
378 | /* Called once per device from rtc_device_register */ | ||
379 | int rtc_initialize_alarm(struct rtc_device *rtc, struct rtc_wkalrm *alarm) | ||
380 | { | ||
381 | int err; | ||
382 | |||
383 | err = rtc_valid_tm(&alarm->time); | ||
384 | if (err != 0) | ||
385 | return err; | ||
386 | |||
387 | err = mutex_lock_interruptible(&rtc->ops_lock); | ||
388 | if (err) | ||
389 | return err; | ||
390 | |||
391 | rtc->aie_timer.node.expires = rtc_tm_to_ktime(alarm->time); | ||
392 | rtc->aie_timer.period = ktime_set(0, 0); | ||
393 | if (alarm->enabled) { | ||
394 | rtc->aie_timer.enabled = 1; | ||
395 | timerqueue_add(&rtc->timerqueue, &rtc->aie_timer.node); | ||
396 | } | ||
397 | mutex_unlock(&rtc->ops_lock); | ||
398 | return err; | ||
399 | } | ||
400 | EXPORT_SYMBOL_GPL(rtc_initialize_alarm); | ||
401 | |||
402 | |||
403 | |||
198 | int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled) | 404 | int rtc_alarm_irq_enable(struct rtc_device *rtc, unsigned int enabled) |
199 | { | 405 | { |
200 | int err = mutex_lock_interruptible(&rtc->ops_lock); | 406 | int err = mutex_lock_interruptible(&rtc->ops_lock); |
@@ -274,7 +480,7 @@ EXPORT_SYMBOL_GPL(rtc_update_irq_enable); | |||
274 | * @rtc: pointer to the rtc device | 480 | * @rtc: pointer to the rtc device |
275 | * | 481 | * |
276 | * This function is called when an AIE, UIE or PIE mode interrupt | 482 | * This function is called when an AIE, UIE or PIE mode interrupt |
277 | * has occured (or been emulated). | 483 | * has occurred (or been emulated). |
278 | * | 484 | * |
279 | * Triggers the registered irq_task function callback. | 485 | * Triggers the registered irq_task function callback. |
280 | */ | 486 | */ |
diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c index 26d1cf5d19ae..e39b77a4609a 100644 --- a/drivers/rtc/rtc-at91rm9200.c +++ b/drivers/rtc/rtc-at91rm9200.c | |||
@@ -60,7 +60,7 @@ static void at91_rtc_decodetime(unsigned int timereg, unsigned int calreg, | |||
60 | /* | 60 | /* |
61 | * The Calendar Alarm register does not have a field for | 61 | * The Calendar Alarm register does not have a field for |
62 | * the year - so these will return an invalid value. When an | 62 | * the year - so these will return an invalid value. When an |
63 | * alarm is set, at91_alarm_year wille store the current year. | 63 | * alarm is set, at91_alarm_year will store the current year. |
64 | */ | 64 | */ |
65 | tm->tm_year = bcd2bin(date & AT91_RTC_CENT) * 100; /* century */ | 65 | tm->tm_year = bcd2bin(date & AT91_RTC_CENT) * 100; /* century */ |
66 | tm->tm_year += bcd2bin((date & AT91_RTC_YEAR) >> 8); /* year */ | 66 | tm->tm_year += bcd2bin((date & AT91_RTC_YEAR) >> 8); /* year */ |
@@ -183,33 +183,6 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
183 | return 0; | 183 | return 0; |
184 | } | 184 | } |
185 | 185 | ||
186 | /* | ||
187 | * Handle commands from user-space | ||
188 | */ | ||
189 | static int at91_rtc_ioctl(struct device *dev, unsigned int cmd, | ||
190 | unsigned long arg) | ||
191 | { | ||
192 | int ret = 0; | ||
193 | |||
194 | pr_debug("%s(): cmd=%08x, arg=%08lx.\n", __func__, cmd, arg); | ||
195 | |||
196 | /* important: scrub old status before enabling IRQs */ | ||
197 | switch (cmd) { | ||
198 | case RTC_UIE_OFF: /* update off */ | ||
199 | at91_sys_write(AT91_RTC_IDR, AT91_RTC_SECEV); | ||
200 | break; | ||
201 | case RTC_UIE_ON: /* update on */ | ||
202 | at91_sys_write(AT91_RTC_SCCR, AT91_RTC_SECEV); | ||
203 | at91_sys_write(AT91_RTC_IER, AT91_RTC_SECEV); | ||
204 | break; | ||
205 | default: | ||
206 | ret = -ENOIOCTLCMD; | ||
207 | break; | ||
208 | } | ||
209 | |||
210 | return ret; | ||
211 | } | ||
212 | |||
213 | static int at91_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | 186 | static int at91_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) |
214 | { | 187 | { |
215 | pr_debug("%s(): cmd=%08x\n", __func__, enabled); | 188 | pr_debug("%s(): cmd=%08x\n", __func__, enabled); |
@@ -269,7 +242,6 @@ static irqreturn_t at91_rtc_interrupt(int irq, void *dev_id) | |||
269 | } | 242 | } |
270 | 243 | ||
271 | static const struct rtc_class_ops at91_rtc_ops = { | 244 | static const struct rtc_class_ops at91_rtc_ops = { |
272 | .ioctl = at91_rtc_ioctl, | ||
273 | .read_time = at91_rtc_readtime, | 245 | .read_time = at91_rtc_readtime, |
274 | .set_time = at91_rtc_settime, | 246 | .set_time = at91_rtc_settime, |
275 | .read_alarm = at91_rtc_readalarm, | 247 | .read_alarm = at91_rtc_readalarm, |
diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c index c36749e4c926..a3ad957507dc 100644 --- a/drivers/rtc/rtc-at91sam9.c +++ b/drivers/rtc/rtc-at91sam9.c | |||
@@ -216,33 +216,6 @@ static int at91_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
216 | return 0; | 216 | return 0; |
217 | } | 217 | } |
218 | 218 | ||
219 | /* | ||
220 | * Handle commands from user-space | ||
221 | */ | ||
222 | static int at91_rtc_ioctl(struct device *dev, unsigned int cmd, | ||
223 | unsigned long arg) | ||
224 | { | ||
225 | struct sam9_rtc *rtc = dev_get_drvdata(dev); | ||
226 | int ret = 0; | ||
227 | u32 mr = rtt_readl(rtc, MR); | ||
228 | |||
229 | dev_dbg(dev, "ioctl: cmd=%08x, arg=%08lx, mr %08x\n", cmd, arg, mr); | ||
230 | |||
231 | switch (cmd) { | ||
232 | case RTC_UIE_OFF: /* update off */ | ||
233 | rtt_writel(rtc, MR, mr & ~AT91_RTT_RTTINCIEN); | ||
234 | break; | ||
235 | case RTC_UIE_ON: /* update on */ | ||
236 | rtt_writel(rtc, MR, mr | AT91_RTT_RTTINCIEN); | ||
237 | break; | ||
238 | default: | ||
239 | ret = -ENOIOCTLCMD; | ||
240 | break; | ||
241 | } | ||
242 | |||
243 | return ret; | ||
244 | } | ||
245 | |||
246 | static int at91_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | 219 | static int at91_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) |
247 | { | 220 | { |
248 | struct sam9_rtc *rtc = dev_get_drvdata(dev); | 221 | struct sam9_rtc *rtc = dev_get_drvdata(dev); |
@@ -303,13 +276,12 @@ static irqreturn_t at91_rtc_interrupt(int irq, void *_rtc) | |||
303 | } | 276 | } |
304 | 277 | ||
305 | static const struct rtc_class_ops at91_rtc_ops = { | 278 | static const struct rtc_class_ops at91_rtc_ops = { |
306 | .ioctl = at91_rtc_ioctl, | ||
307 | .read_time = at91_rtc_readtime, | 279 | .read_time = at91_rtc_readtime, |
308 | .set_time = at91_rtc_settime, | 280 | .set_time = at91_rtc_settime, |
309 | .read_alarm = at91_rtc_readalarm, | 281 | .read_alarm = at91_rtc_readalarm, |
310 | .set_alarm = at91_rtc_setalarm, | 282 | .set_alarm = at91_rtc_setalarm, |
311 | .proc = at91_rtc_proc, | 283 | .proc = at91_rtc_proc, |
312 | .alarm_irq_enabled = at91_rtc_alarm_irq_enable, | 284 | .alarm_irq_enable = at91_rtc_alarm_irq_enable, |
313 | }; | 285 | }; |
314 | 286 | ||
315 | /* | 287 | /* |
diff --git a/drivers/rtc/rtc-bfin.c b/drivers/rtc/rtc-bfin.c index 17971d93354d..90d866272c8e 100644 --- a/drivers/rtc/rtc-bfin.c +++ b/drivers/rtc/rtc-bfin.c | |||
@@ -20,9 +20,9 @@ | |||
20 | * write would be discarded and things quickly fall apart. | 20 | * write would be discarded and things quickly fall apart. |
21 | * | 21 | * |
22 | * To keep this delay from significantly degrading performance (we, in theory, | 22 | * To keep this delay from significantly degrading performance (we, in theory, |
23 | * would have to sleep for up to 1 second everytime we wanted to write a | 23 | * would have to sleep for up to 1 second every time we wanted to write a |
24 | * register), we only check the write pending status before we start to issue | 24 | * register), we only check the write pending status before we start to issue |
25 | * a new write. We bank on the idea that it doesnt matter when the sync | 25 | * a new write. We bank on the idea that it doesn't matter when the sync |
26 | * happens so long as we don't attempt another write before it does. The only | 26 | * happens so long as we don't attempt another write before it does. The only |
27 | * time userspace would take this penalty is when they try and do multiple | 27 | * time userspace would take this penalty is when they try and do multiple |
28 | * operations right after another ... but in this case, they need to take the | 28 | * operations right after another ... but in this case, they need to take the |
@@ -240,32 +240,6 @@ static void bfin_rtc_int_set_alarm(struct bfin_rtc *rtc) | |||
240 | */ | 240 | */ |
241 | bfin_rtc_int_set(rtc->rtc_alarm.tm_yday == -1 ? RTC_ISTAT_ALARM : RTC_ISTAT_ALARM_DAY); | 241 | bfin_rtc_int_set(rtc->rtc_alarm.tm_yday == -1 ? RTC_ISTAT_ALARM : RTC_ISTAT_ALARM_DAY); |
242 | } | 242 | } |
243 | static int bfin_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | ||
244 | { | ||
245 | struct bfin_rtc *rtc = dev_get_drvdata(dev); | ||
246 | int ret = 0; | ||
247 | |||
248 | dev_dbg_stamp(dev); | ||
249 | |||
250 | bfin_rtc_sync_pending(dev); | ||
251 | |||
252 | switch (cmd) { | ||
253 | case RTC_UIE_ON: | ||
254 | dev_dbg_stamp(dev); | ||
255 | bfin_rtc_int_set(RTC_ISTAT_SEC); | ||
256 | break; | ||
257 | case RTC_UIE_OFF: | ||
258 | dev_dbg_stamp(dev); | ||
259 | bfin_rtc_int_clear(~RTC_ISTAT_SEC); | ||
260 | break; | ||
261 | |||
262 | default: | ||
263 | dev_dbg_stamp(dev); | ||
264 | ret = -ENOIOCTLCMD; | ||
265 | } | ||
266 | |||
267 | return ret; | ||
268 | } | ||
269 | 243 | ||
270 | static int bfin_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | 244 | static int bfin_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) |
271 | { | 245 | { |
@@ -276,6 +250,8 @@ static int bfin_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
276 | bfin_rtc_int_set_alarm(rtc); | 250 | bfin_rtc_int_set_alarm(rtc); |
277 | else | 251 | else |
278 | bfin_rtc_int_clear(~(RTC_ISTAT_ALARM | RTC_ISTAT_ALARM_DAY)); | 252 | bfin_rtc_int_clear(~(RTC_ISTAT_ALARM | RTC_ISTAT_ALARM_DAY)); |
253 | |||
254 | return 0; | ||
279 | } | 255 | } |
280 | 256 | ||
281 | static int bfin_rtc_read_time(struct device *dev, struct rtc_time *tm) | 257 | static int bfin_rtc_read_time(struct device *dev, struct rtc_time *tm) |
@@ -358,7 +334,6 @@ static int bfin_rtc_proc(struct device *dev, struct seq_file *seq) | |||
358 | } | 334 | } |
359 | 335 | ||
360 | static struct rtc_class_ops bfin_rtc_ops = { | 336 | static struct rtc_class_ops bfin_rtc_ops = { |
361 | .ioctl = bfin_rtc_ioctl, | ||
362 | .read_time = bfin_rtc_read_time, | 337 | .read_time = bfin_rtc_read_time, |
363 | .set_time = bfin_rtc_set_time, | 338 | .set_time = bfin_rtc_set_time, |
364 | .read_alarm = bfin_rtc_read_alarm, | 339 | .read_alarm = bfin_rtc_read_alarm, |
diff --git a/drivers/rtc/rtc-cmos.c b/drivers/rtc/rtc-cmos.c index c7ff8df347e7..911e75cdc125 100644 --- a/drivers/rtc/rtc-cmos.c +++ b/drivers/rtc/rtc-cmos.c | |||
@@ -37,6 +37,8 @@ | |||
37 | #include <linux/mod_devicetable.h> | 37 | #include <linux/mod_devicetable.h> |
38 | #include <linux/log2.h> | 38 | #include <linux/log2.h> |
39 | #include <linux/pm.h> | 39 | #include <linux/pm.h> |
40 | #include <linux/of.h> | ||
41 | #include <linux/of_platform.h> | ||
40 | 42 | ||
41 | /* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */ | 43 | /* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */ |
42 | #include <asm-generic/rtc.h> | 44 | #include <asm-generic/rtc.h> |
@@ -375,50 +377,6 @@ static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t) | |||
375 | return 0; | 377 | return 0; |
376 | } | 378 | } |
377 | 379 | ||
378 | static int cmos_irq_set_freq(struct device *dev, int freq) | ||
379 | { | ||
380 | struct cmos_rtc *cmos = dev_get_drvdata(dev); | ||
381 | int f; | ||
382 | unsigned long flags; | ||
383 | |||
384 | if (!is_valid_irq(cmos->irq)) | ||
385 | return -ENXIO; | ||
386 | |||
387 | if (!is_power_of_2(freq)) | ||
388 | return -EINVAL; | ||
389 | /* 0 = no irqs; 1 = 2^15 Hz ... 15 = 2^0 Hz */ | ||
390 | f = ffs(freq); | ||
391 | if (f-- > 16) | ||
392 | return -EINVAL; | ||
393 | f = 16 - f; | ||
394 | |||
395 | spin_lock_irqsave(&rtc_lock, flags); | ||
396 | hpet_set_periodic_freq(freq); | ||
397 | CMOS_WRITE(RTC_REF_CLCK_32KHZ | f, RTC_FREQ_SELECT); | ||
398 | spin_unlock_irqrestore(&rtc_lock, flags); | ||
399 | |||
400 | return 0; | ||
401 | } | ||
402 | |||
403 | static int cmos_irq_set_state(struct device *dev, int enabled) | ||
404 | { | ||
405 | struct cmos_rtc *cmos = dev_get_drvdata(dev); | ||
406 | unsigned long flags; | ||
407 | |||
408 | if (!is_valid_irq(cmos->irq)) | ||
409 | return -ENXIO; | ||
410 | |||
411 | spin_lock_irqsave(&rtc_lock, flags); | ||
412 | |||
413 | if (enabled) | ||
414 | cmos_irq_enable(cmos, RTC_PIE); | ||
415 | else | ||
416 | cmos_irq_disable(cmos, RTC_PIE); | ||
417 | |||
418 | spin_unlock_irqrestore(&rtc_lock, flags); | ||
419 | return 0; | ||
420 | } | ||
421 | |||
422 | static int cmos_alarm_irq_enable(struct device *dev, unsigned int enabled) | 380 | static int cmos_alarm_irq_enable(struct device *dev, unsigned int enabled) |
423 | { | 381 | { |
424 | struct cmos_rtc *cmos = dev_get_drvdata(dev); | 382 | struct cmos_rtc *cmos = dev_get_drvdata(dev); |
@@ -438,25 +396,6 @@ static int cmos_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
438 | return 0; | 396 | return 0; |
439 | } | 397 | } |
440 | 398 | ||
441 | static int cmos_update_irq_enable(struct device *dev, unsigned int enabled) | ||
442 | { | ||
443 | struct cmos_rtc *cmos = dev_get_drvdata(dev); | ||
444 | unsigned long flags; | ||
445 | |||
446 | if (!is_valid_irq(cmos->irq)) | ||
447 | return -EINVAL; | ||
448 | |||
449 | spin_lock_irqsave(&rtc_lock, flags); | ||
450 | |||
451 | if (enabled) | ||
452 | cmos_irq_enable(cmos, RTC_UIE); | ||
453 | else | ||
454 | cmos_irq_disable(cmos, RTC_UIE); | ||
455 | |||
456 | spin_unlock_irqrestore(&rtc_lock, flags); | ||
457 | return 0; | ||
458 | } | ||
459 | |||
460 | #if defined(CONFIG_RTC_INTF_PROC) || defined(CONFIG_RTC_INTF_PROC_MODULE) | 399 | #if defined(CONFIG_RTC_INTF_PROC) || defined(CONFIG_RTC_INTF_PROC_MODULE) |
461 | 400 | ||
462 | static int cmos_procfs(struct device *dev, struct seq_file *seq) | 401 | static int cmos_procfs(struct device *dev, struct seq_file *seq) |
@@ -501,10 +440,7 @@ static const struct rtc_class_ops cmos_rtc_ops = { | |||
501 | .read_alarm = cmos_read_alarm, | 440 | .read_alarm = cmos_read_alarm, |
502 | .set_alarm = cmos_set_alarm, | 441 | .set_alarm = cmos_set_alarm, |
503 | .proc = cmos_procfs, | 442 | .proc = cmos_procfs, |
504 | .irq_set_freq = cmos_irq_set_freq, | ||
505 | .irq_set_state = cmos_irq_set_state, | ||
506 | .alarm_irq_enable = cmos_alarm_irq_enable, | 443 | .alarm_irq_enable = cmos_alarm_irq_enable, |
507 | .update_irq_enable = cmos_update_irq_enable, | ||
508 | }; | 444 | }; |
509 | 445 | ||
510 | /*----------------------------------------------------------------*/ | 446 | /*----------------------------------------------------------------*/ |
@@ -1123,6 +1059,47 @@ static struct pnp_driver cmos_pnp_driver = { | |||
1123 | 1059 | ||
1124 | #endif /* CONFIG_PNP */ | 1060 | #endif /* CONFIG_PNP */ |
1125 | 1061 | ||
1062 | #ifdef CONFIG_OF | ||
1063 | static const struct of_device_id of_cmos_match[] = { | ||
1064 | { | ||
1065 | .compatible = "motorola,mc146818", | ||
1066 | }, | ||
1067 | { }, | ||
1068 | }; | ||
1069 | MODULE_DEVICE_TABLE(of, of_cmos_match); | ||
1070 | |||
1071 | static __init void cmos_of_init(struct platform_device *pdev) | ||
1072 | { | ||
1073 | struct device_node *node = pdev->dev.of_node; | ||
1074 | struct rtc_time time; | ||
1075 | int ret; | ||
1076 | const __be32 *val; | ||
1077 | |||
1078 | if (!node) | ||
1079 | return; | ||
1080 | |||
1081 | val = of_get_property(node, "ctrl-reg", NULL); | ||
1082 | if (val) | ||
1083 | CMOS_WRITE(be32_to_cpup(val), RTC_CONTROL); | ||
1084 | |||
1085 | val = of_get_property(node, "freq-reg", NULL); | ||
1086 | if (val) | ||
1087 | CMOS_WRITE(be32_to_cpup(val), RTC_FREQ_SELECT); | ||
1088 | |||
1089 | get_rtc_time(&time); | ||
1090 | ret = rtc_valid_tm(&time); | ||
1091 | if (ret) { | ||
1092 | struct rtc_time def_time = { | ||
1093 | .tm_year = 1, | ||
1094 | .tm_mday = 1, | ||
1095 | }; | ||
1096 | set_rtc_time(&def_time); | ||
1097 | } | ||
1098 | } | ||
1099 | #else | ||
1100 | static inline void cmos_of_init(struct platform_device *pdev) {} | ||
1101 | #define of_cmos_match NULL | ||
1102 | #endif | ||
1126 | /*----------------------------------------------------------------*/ | 1103 | /*----------------------------------------------------------------*/ |
1127 | 1104 | ||
1128 | /* Platform setup should have set up an RTC device, when PNP is | 1105 | /* Platform setup should have set up an RTC device, when PNP is |
@@ -1131,6 +1108,7 @@ static struct pnp_driver cmos_pnp_driver = { | |||
1131 | 1108 | ||
1132 | static int __init cmos_platform_probe(struct platform_device *pdev) | 1109 | static int __init cmos_platform_probe(struct platform_device *pdev) |
1133 | { | 1110 | { |
1111 | cmos_of_init(pdev); | ||
1134 | cmos_wake_setup(&pdev->dev); | 1112 | cmos_wake_setup(&pdev->dev); |
1135 | return cmos_do_probe(&pdev->dev, | 1113 | return cmos_do_probe(&pdev->dev, |
1136 | platform_get_resource(pdev, IORESOURCE_IO, 0), | 1114 | platform_get_resource(pdev, IORESOURCE_IO, 0), |
@@ -1162,6 +1140,7 @@ static struct platform_driver cmos_platform_driver = { | |||
1162 | #ifdef CONFIG_PM | 1140 | #ifdef CONFIG_PM |
1163 | .pm = &cmos_pm_ops, | 1141 | .pm = &cmos_pm_ops, |
1164 | #endif | 1142 | #endif |
1143 | .of_match_table = of_cmos_match, | ||
1165 | } | 1144 | } |
1166 | }; | 1145 | }; |
1167 | 1146 | ||
diff --git a/drivers/rtc/rtc-coh901331.c b/drivers/rtc/rtc-coh901331.c index 316f484999b5..80f9c88214c5 100644 --- a/drivers/rtc/rtc-coh901331.c +++ b/drivers/rtc/rtc-coh901331.c | |||
@@ -220,6 +220,7 @@ static int __init coh901331_probe(struct platform_device *pdev) | |||
220 | } | 220 | } |
221 | clk_disable(rtap->clk); | 221 | clk_disable(rtap->clk); |
222 | 222 | ||
223 | platform_set_drvdata(pdev, rtap); | ||
223 | rtap->rtc = rtc_device_register("coh901331", &pdev->dev, &coh901331_ops, | 224 | rtap->rtc = rtc_device_register("coh901331", &pdev->dev, &coh901331_ops, |
224 | THIS_MODULE); | 225 | THIS_MODULE); |
225 | if (IS_ERR(rtap->rtc)) { | 226 | if (IS_ERR(rtap->rtc)) { |
@@ -227,11 +228,10 @@ static int __init coh901331_probe(struct platform_device *pdev) | |||
227 | goto out_no_rtc; | 228 | goto out_no_rtc; |
228 | } | 229 | } |
229 | 230 | ||
230 | platform_set_drvdata(pdev, rtap); | ||
231 | |||
232 | return 0; | 231 | return 0; |
233 | 232 | ||
234 | out_no_rtc: | 233 | out_no_rtc: |
234 | platform_set_drvdata(pdev, NULL); | ||
235 | out_no_clk_enable: | 235 | out_no_clk_enable: |
236 | clk_put(rtap->clk); | 236 | clk_put(rtap->clk); |
237 | out_no_clk: | 237 | out_no_clk: |
diff --git a/drivers/rtc/rtc-davinci.c b/drivers/rtc/rtc-davinci.c index 34647fc1ee98..8d46838dff8a 100644 --- a/drivers/rtc/rtc-davinci.c +++ b/drivers/rtc/rtc-davinci.c | |||
@@ -231,10 +231,6 @@ davinci_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | |||
231 | case RTC_WIE_OFF: | 231 | case RTC_WIE_OFF: |
232 | rtc_ctrl &= ~PRTCSS_RTC_CTRL_WEN; | 232 | rtc_ctrl &= ~PRTCSS_RTC_CTRL_WEN; |
233 | break; | 233 | break; |
234 | case RTC_UIE_OFF: | ||
235 | case RTC_UIE_ON: | ||
236 | ret = -ENOTTY; | ||
237 | break; | ||
238 | default: | 234 | default: |
239 | ret = -ENOIOCTLCMD; | 235 | ret = -ENOIOCTLCMD; |
240 | } | 236 | } |
@@ -473,55 +469,6 @@ static int davinci_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) | |||
473 | return 0; | 469 | return 0; |
474 | } | 470 | } |
475 | 471 | ||
476 | static int davinci_rtc_irq_set_state(struct device *dev, int enabled) | ||
477 | { | ||
478 | struct davinci_rtc *davinci_rtc = dev_get_drvdata(dev); | ||
479 | unsigned long flags; | ||
480 | u8 rtc_ctrl; | ||
481 | |||
482 | spin_lock_irqsave(&davinci_rtc_lock, flags); | ||
483 | |||
484 | rtc_ctrl = rtcss_read(davinci_rtc, PRTCSS_RTC_CTRL); | ||
485 | |||
486 | if (enabled) { | ||
487 | while (rtcss_read(davinci_rtc, PRTCSS_RTC_CTRL) | ||
488 | & PRTCSS_RTC_CTRL_WDTBUS) | ||
489 | cpu_relax(); | ||
490 | |||
491 | rtc_ctrl |= PRTCSS_RTC_CTRL_TE; | ||
492 | rtcss_write(davinci_rtc, rtc_ctrl, PRTCSS_RTC_CTRL); | ||
493 | |||
494 | rtcss_write(davinci_rtc, 0x0, PRTCSS_RTC_CLKC_CNT); | ||
495 | |||
496 | rtc_ctrl |= PRTCSS_RTC_CTRL_TIEN | | ||
497 | PRTCSS_RTC_CTRL_TMMD | | ||
498 | PRTCSS_RTC_CTRL_TMRFLG; | ||
499 | } else | ||
500 | rtc_ctrl &= ~PRTCSS_RTC_CTRL_TIEN; | ||
501 | |||
502 | rtcss_write(davinci_rtc, rtc_ctrl, PRTCSS_RTC_CTRL); | ||
503 | |||
504 | spin_unlock_irqrestore(&davinci_rtc_lock, flags); | ||
505 | |||
506 | return 0; | ||
507 | } | ||
508 | |||
509 | static int davinci_rtc_irq_set_freq(struct device *dev, int freq) | ||
510 | { | ||
511 | struct davinci_rtc *davinci_rtc = dev_get_drvdata(dev); | ||
512 | unsigned long flags; | ||
513 | u16 tmr_counter = (0x8000 >> (ffs(freq) - 1)); | ||
514 | |||
515 | spin_lock_irqsave(&davinci_rtc_lock, flags); | ||
516 | |||
517 | rtcss_write(davinci_rtc, tmr_counter & 0xFF, PRTCSS_RTC_TMR0); | ||
518 | rtcss_write(davinci_rtc, (tmr_counter & 0xFF00) >> 8, PRTCSS_RTC_TMR1); | ||
519 | |||
520 | spin_unlock_irqrestore(&davinci_rtc_lock, flags); | ||
521 | |||
522 | return 0; | ||
523 | } | ||
524 | |||
525 | static struct rtc_class_ops davinci_rtc_ops = { | 472 | static struct rtc_class_ops davinci_rtc_ops = { |
526 | .ioctl = davinci_rtc_ioctl, | 473 | .ioctl = davinci_rtc_ioctl, |
527 | .read_time = davinci_rtc_read_time, | 474 | .read_time = davinci_rtc_read_time, |
@@ -529,8 +476,6 @@ static struct rtc_class_ops davinci_rtc_ops = { | |||
529 | .alarm_irq_enable = davinci_rtc_alarm_irq_enable, | 476 | .alarm_irq_enable = davinci_rtc_alarm_irq_enable, |
530 | .read_alarm = davinci_rtc_read_alarm, | 477 | .read_alarm = davinci_rtc_read_alarm, |
531 | .set_alarm = davinci_rtc_set_alarm, | 478 | .set_alarm = davinci_rtc_set_alarm, |
532 | .irq_set_state = davinci_rtc_irq_set_state, | ||
533 | .irq_set_freq = davinci_rtc_irq_set_freq, | ||
534 | }; | 479 | }; |
535 | 480 | ||
536 | static int __init davinci_rtc_probe(struct platform_device *pdev) | 481 | static int __init davinci_rtc_probe(struct platform_device *pdev) |
diff --git a/drivers/rtc/rtc-ds1374.c b/drivers/rtc/rtc-ds1374.c index d834a63ec4b0..e6e71deb188f 100644 --- a/drivers/rtc/rtc-ds1374.c +++ b/drivers/rtc/rtc-ds1374.c | |||
@@ -25,6 +25,7 @@ | |||
25 | #include <linux/bcd.h> | 25 | #include <linux/bcd.h> |
26 | #include <linux/workqueue.h> | 26 | #include <linux/workqueue.h> |
27 | #include <linux/slab.h> | 27 | #include <linux/slab.h> |
28 | #include <linux/pm.h> | ||
28 | 29 | ||
29 | #define DS1374_REG_TOD0 0x00 /* Time of Day */ | 30 | #define DS1374_REG_TOD0 0x00 /* Time of Day */ |
30 | #define DS1374_REG_TOD1 0x01 | 31 | #define DS1374_REG_TOD1 0x01 |
@@ -409,32 +410,38 @@ static int __devexit ds1374_remove(struct i2c_client *client) | |||
409 | } | 410 | } |
410 | 411 | ||
411 | #ifdef CONFIG_PM | 412 | #ifdef CONFIG_PM |
412 | static int ds1374_suspend(struct i2c_client *client, pm_message_t state) | 413 | static int ds1374_suspend(struct device *dev) |
413 | { | 414 | { |
415 | struct i2c_client *client = to_i2c_client(dev); | ||
416 | |||
414 | if (client->irq >= 0 && device_may_wakeup(&client->dev)) | 417 | if (client->irq >= 0 && device_may_wakeup(&client->dev)) |
415 | enable_irq_wake(client->irq); | 418 | enable_irq_wake(client->irq); |
416 | return 0; | 419 | return 0; |
417 | } | 420 | } |
418 | 421 | ||
419 | static int ds1374_resume(struct i2c_client *client) | 422 | static int ds1374_resume(struct device *dev) |
420 | { | 423 | { |
424 | struct i2c_client *client = to_i2c_client(dev); | ||
425 | |||
421 | if (client->irq >= 0 && device_may_wakeup(&client->dev)) | 426 | if (client->irq >= 0 && device_may_wakeup(&client->dev)) |
422 | disable_irq_wake(client->irq); | 427 | disable_irq_wake(client->irq); |
423 | return 0; | 428 | return 0; |
424 | } | 429 | } |
430 | |||
431 | static SIMPLE_DEV_PM_OPS(ds1374_pm, ds1374_suspend, ds1374_resume); | ||
432 | |||
433 | #define DS1374_PM (&ds1374_pm) | ||
425 | #else | 434 | #else |
426 | #define ds1374_suspend NULL | 435 | #define DS1374_PM NULL |
427 | #define ds1374_resume NULL | ||
428 | #endif | 436 | #endif |
429 | 437 | ||
430 | static struct i2c_driver ds1374_driver = { | 438 | static struct i2c_driver ds1374_driver = { |
431 | .driver = { | 439 | .driver = { |
432 | .name = "rtc-ds1374", | 440 | .name = "rtc-ds1374", |
433 | .owner = THIS_MODULE, | 441 | .owner = THIS_MODULE, |
442 | .pm = DS1374_PM, | ||
434 | }, | 443 | }, |
435 | .probe = ds1374_probe, | 444 | .probe = ds1374_probe, |
436 | .suspend = ds1374_suspend, | ||
437 | .resume = ds1374_resume, | ||
438 | .remove = __devexit_p(ds1374_remove), | 445 | .remove = __devexit_p(ds1374_remove), |
439 | .id_table = ds1374_id, | 446 | .id_table = ds1374_id, |
440 | }; | 447 | }; |
diff --git a/drivers/rtc/rtc-ds1390.c b/drivers/rtc/rtc-ds1390.c index 26a86d235051..b038d2cfef26 100644 --- a/drivers/rtc/rtc-ds1390.c +++ b/drivers/rtc/rtc-ds1390.c | |||
@@ -158,7 +158,7 @@ static int __devinit ds1390_probe(struct spi_device *spi) | |||
158 | 158 | ||
159 | static int __devexit ds1390_remove(struct spi_device *spi) | 159 | static int __devexit ds1390_remove(struct spi_device *spi) |
160 | { | 160 | { |
161 | struct ds1390 *chip = platform_get_drvdata(spi); | 161 | struct ds1390 *chip = spi_get_drvdata(spi); |
162 | 162 | ||
163 | rtc_device_unregister(chip->rtc); | 163 | rtc_device_unregister(chip->rtc); |
164 | kfree(chip); | 164 | kfree(chip); |
diff --git a/drivers/rtc/rtc-ds1511.c b/drivers/rtc/rtc-ds1511.c index 37268e97de49..fbabc773dded 100644 --- a/drivers/rtc/rtc-ds1511.c +++ b/drivers/rtc/rtc-ds1511.c | |||
@@ -397,29 +397,12 @@ static int ds1511_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
397 | return 0; | 397 | return 0; |
398 | } | 398 | } |
399 | 399 | ||
400 | static int ds1511_rtc_update_irq_enable(struct device *dev, | ||
401 | unsigned int enabled) | ||
402 | { | ||
403 | struct platform_device *pdev = to_platform_device(dev); | ||
404 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); | ||
405 | |||
406 | if (pdata->irq <= 0) | ||
407 | return -EINVAL; | ||
408 | if (enabled) | ||
409 | pdata->irqen |= RTC_UF; | ||
410 | else | ||
411 | pdata->irqen &= ~RTC_UF; | ||
412 | ds1511_rtc_update_alarm(pdata); | ||
413 | return 0; | ||
414 | } | ||
415 | |||
416 | static const struct rtc_class_ops ds1511_rtc_ops = { | 400 | static const struct rtc_class_ops ds1511_rtc_ops = { |
417 | .read_time = ds1511_rtc_read_time, | 401 | .read_time = ds1511_rtc_read_time, |
418 | .set_time = ds1511_rtc_set_time, | 402 | .set_time = ds1511_rtc_set_time, |
419 | .read_alarm = ds1511_rtc_read_alarm, | 403 | .read_alarm = ds1511_rtc_read_alarm, |
420 | .set_alarm = ds1511_rtc_set_alarm, | 404 | .set_alarm = ds1511_rtc_set_alarm, |
421 | .alarm_irq_enable = ds1511_rtc_alarm_irq_enable, | 405 | .alarm_irq_enable = ds1511_rtc_alarm_irq_enable, |
422 | .update_irq_enable = ds1511_rtc_update_irq_enable, | ||
423 | }; | 406 | }; |
424 | 407 | ||
425 | static ssize_t | 408 | static ssize_t |
@@ -485,7 +468,7 @@ ds1511_nvram_write(struct file *filp, struct kobject *kobj, | |||
485 | static struct bin_attribute ds1511_nvram_attr = { | 468 | static struct bin_attribute ds1511_nvram_attr = { |
486 | .attr = { | 469 | .attr = { |
487 | .name = "nvram", | 470 | .name = "nvram", |
488 | .mode = S_IRUGO | S_IWUGO, | 471 | .mode = S_IRUGO | S_IWUSR, |
489 | }, | 472 | }, |
490 | .size = DS1511_RAM_MAX, | 473 | .size = DS1511_RAM_MAX, |
491 | .read = ds1511_nvram_read, | 474 | .read = ds1511_nvram_read, |
diff --git a/drivers/rtc/rtc-ds1553.c b/drivers/rtc/rtc-ds1553.c index ff432e2ca275..fee41b97c9e8 100644 --- a/drivers/rtc/rtc-ds1553.c +++ b/drivers/rtc/rtc-ds1553.c | |||
@@ -227,29 +227,12 @@ static int ds1553_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
227 | return 0; | 227 | return 0; |
228 | } | 228 | } |
229 | 229 | ||
230 | static int ds1553_rtc_update_irq_enable(struct device *dev, | ||
231 | unsigned int enabled) | ||
232 | { | ||
233 | struct platform_device *pdev = to_platform_device(dev); | ||
234 | struct rtc_plat_data *pdata = platform_get_drvdata(pdev); | ||
235 | |||
236 | if (pdata->irq <= 0) | ||
237 | return -EINVAL; | ||
238 | if (enabled) | ||
239 | pdata->irqen |= RTC_UF; | ||
240 | else | ||
241 | pdata->irqen &= ~RTC_UF; | ||
242 | ds1553_rtc_update_alarm(pdata); | ||
243 | return 0; | ||
244 | } | ||
245 | |||
246 | static const struct rtc_class_ops ds1553_rtc_ops = { | 230 | static const struct rtc_class_ops ds1553_rtc_ops = { |
247 | .read_time = ds1553_rtc_read_time, | 231 | .read_time = ds1553_rtc_read_time, |
248 | .set_time = ds1553_rtc_set_time, | 232 | .set_time = ds1553_rtc_set_time, |
249 | .read_alarm = ds1553_rtc_read_alarm, | 233 | .read_alarm = ds1553_rtc_read_alarm, |
250 | .set_alarm = ds1553_rtc_set_alarm, | 234 | .set_alarm = ds1553_rtc_set_alarm, |
251 | .alarm_irq_enable = ds1553_rtc_alarm_irq_enable, | 235 | .alarm_irq_enable = ds1553_rtc_alarm_irq_enable, |
252 | .update_irq_enable = ds1553_rtc_update_irq_enable, | ||
253 | }; | 236 | }; |
254 | 237 | ||
255 | static ssize_t ds1553_nvram_read(struct file *filp, struct kobject *kobj, | 238 | static ssize_t ds1553_nvram_read(struct file *filp, struct kobject *kobj, |
diff --git a/drivers/rtc/rtc-ds3232.c b/drivers/rtc/rtc-ds3232.c index 23a9ee19764c..27b7bf672ac6 100644 --- a/drivers/rtc/rtc-ds3232.c +++ b/drivers/rtc/rtc-ds3232.c | |||
@@ -1,7 +1,7 @@ | |||
1 | /* | 1 | /* |
2 | * RTC client/driver for the Maxim/Dallas DS3232 Real-Time Clock over I2C | 2 | * RTC client/driver for the Maxim/Dallas DS3232 Real-Time Clock over I2C |
3 | * | 3 | * |
4 | * Copyright (C) 2009-2010 Freescale Semiconductor. | 4 | * Copyright (C) 2009-2011 Freescale Semiconductor. |
5 | * Author: Jack Lan <jack.lan@freescale.com> | 5 | * Author: Jack Lan <jack.lan@freescale.com> |
6 | * | 6 | * |
7 | * This program is free software; you can redistribute it and/or modify it | 7 | * This program is free software; you can redistribute it and/or modify it |
@@ -141,9 +141,11 @@ static int ds3232_read_time(struct device *dev, struct rtc_time *time) | |||
141 | time->tm_hour = bcd2bin(hour); | 141 | time->tm_hour = bcd2bin(hour); |
142 | } | 142 | } |
143 | 143 | ||
144 | time->tm_wday = bcd2bin(week); | 144 | /* Day of the week in linux range is 0~6 while 1~7 in RTC chip */ |
145 | time->tm_wday = bcd2bin(week) - 1; | ||
145 | time->tm_mday = bcd2bin(day); | 146 | time->tm_mday = bcd2bin(day); |
146 | time->tm_mon = bcd2bin(month & 0x7F); | 147 | /* linux tm_mon range:0~11, while month range is 1~12 in RTC chip */ |
148 | time->tm_mon = bcd2bin(month & 0x7F) - 1; | ||
147 | if (century) | 149 | if (century) |
148 | add_century = 100; | 150 | add_century = 100; |
149 | 151 | ||
@@ -162,9 +164,11 @@ static int ds3232_set_time(struct device *dev, struct rtc_time *time) | |||
162 | buf[0] = bin2bcd(time->tm_sec); | 164 | buf[0] = bin2bcd(time->tm_sec); |
163 | buf[1] = bin2bcd(time->tm_min); | 165 | buf[1] = bin2bcd(time->tm_min); |
164 | buf[2] = bin2bcd(time->tm_hour); | 166 | buf[2] = bin2bcd(time->tm_hour); |
165 | buf[3] = bin2bcd(time->tm_wday); /* Day of the week */ | 167 | /* Day of the week in linux range is 0~6 while 1~7 in RTC chip */ |
168 | buf[3] = bin2bcd(time->tm_wday + 1); | ||
166 | buf[4] = bin2bcd(time->tm_mday); /* Date */ | 169 | buf[4] = bin2bcd(time->tm_mday); /* Date */ |
167 | buf[5] = bin2bcd(time->tm_mon); | 170 | /* linux tm_mon range:0~11, while month range is 1~12 in RTC chip */ |
171 | buf[5] = bin2bcd(time->tm_mon + 1); | ||
168 | if (time->tm_year >= 100) { | 172 | if (time->tm_year >= 100) { |
169 | buf[5] |= 0x80; | 173 | buf[5] |= 0x80; |
170 | buf[6] = bin2bcd(time->tm_year - 100); | 174 | buf[6] = bin2bcd(time->tm_year - 100); |
@@ -335,23 +339,6 @@ static int ds3232_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
335 | return 0; | 339 | return 0; |
336 | } | 340 | } |
337 | 341 | ||
338 | static int ds3232_update_irq_enable(struct device *dev, unsigned int enabled) | ||
339 | { | ||
340 | struct i2c_client *client = to_i2c_client(dev); | ||
341 | struct ds3232 *ds3232 = i2c_get_clientdata(client); | ||
342 | |||
343 | if (client->irq <= 0) | ||
344 | return -EINVAL; | ||
345 | |||
346 | if (enabled) | ||
347 | ds3232->rtc->irq_data |= RTC_UF; | ||
348 | else | ||
349 | ds3232->rtc->irq_data &= ~RTC_UF; | ||
350 | |||
351 | ds3232_update_alarm(client); | ||
352 | return 0; | ||
353 | } | ||
354 | |||
355 | static irqreturn_t ds3232_irq(int irq, void *dev_id) | 342 | static irqreturn_t ds3232_irq(int irq, void *dev_id) |
356 | { | 343 | { |
357 | struct i2c_client *client = dev_id; | 344 | struct i2c_client *client = dev_id; |
@@ -402,7 +389,6 @@ static const struct rtc_class_ops ds3232_rtc_ops = { | |||
402 | .read_alarm = ds3232_read_alarm, | 389 | .read_alarm = ds3232_read_alarm, |
403 | .set_alarm = ds3232_set_alarm, | 390 | .set_alarm = ds3232_set_alarm, |
404 | .alarm_irq_enable = ds3232_alarm_irq_enable, | 391 | .alarm_irq_enable = ds3232_alarm_irq_enable, |
405 | .update_irq_enable = ds3232_update_irq_enable, | ||
406 | }; | 392 | }; |
407 | 393 | ||
408 | static int __devinit ds3232_probe(struct i2c_client *client, | 394 | static int __devinit ds3232_probe(struct i2c_client *client, |
diff --git a/drivers/rtc/rtc-ds3234.c b/drivers/rtc/rtc-ds3234.c index a774ca35b5f7..bbd26228f532 100644 --- a/drivers/rtc/rtc-ds3234.c +++ b/drivers/rtc/rtc-ds3234.c | |||
@@ -158,7 +158,7 @@ static int __devinit ds3234_probe(struct spi_device *spi) | |||
158 | 158 | ||
159 | static int __devexit ds3234_remove(struct spi_device *spi) | 159 | static int __devexit ds3234_remove(struct spi_device *spi) |
160 | { | 160 | { |
161 | struct rtc_device *rtc = platform_get_drvdata(spi); | 161 | struct rtc_device *rtc = spi_get_drvdata(spi); |
162 | 162 | ||
163 | rtc_device_unregister(rtc); | 163 | rtc_device_unregister(rtc); |
164 | return 0; | 164 | return 0; |
diff --git a/drivers/rtc/rtc-isl1208.c b/drivers/rtc/rtc-isl1208.c index 468200c38ecb..da8beb8cae51 100644 --- a/drivers/rtc/rtc-isl1208.c +++ b/drivers/rtc/rtc-isl1208.c | |||
@@ -39,6 +39,8 @@ | |||
39 | #define ISL1208_REG_SR_BAT (1<<1) /* battery */ | 39 | #define ISL1208_REG_SR_BAT (1<<1) /* battery */ |
40 | #define ISL1208_REG_SR_RTCF (1<<0) /* rtc fail */ | 40 | #define ISL1208_REG_SR_RTCF (1<<0) /* rtc fail */ |
41 | #define ISL1208_REG_INT 0x08 | 41 | #define ISL1208_REG_INT 0x08 |
42 | #define ISL1208_REG_INT_ALME (1<<6) /* alarm enable */ | ||
43 | #define ISL1208_REG_INT_IM (1<<7) /* interrupt/alarm mode */ | ||
42 | #define ISL1208_REG_09 0x09 /* reserved */ | 44 | #define ISL1208_REG_09 0x09 /* reserved */ |
43 | #define ISL1208_REG_ATR 0x0a | 45 | #define ISL1208_REG_ATR 0x0a |
44 | #define ISL1208_REG_DTR 0x0b | 46 | #define ISL1208_REG_DTR 0x0b |
@@ -202,6 +204,30 @@ isl1208_i2c_set_usr(struct i2c_client *client, u16 usr) | |||
202 | } | 204 | } |
203 | 205 | ||
204 | static int | 206 | static int |
207 | isl1208_rtc_toggle_alarm(struct i2c_client *client, int enable) | ||
208 | { | ||
209 | int icr = i2c_smbus_read_byte_data(client, ISL1208_REG_INT); | ||
210 | |||
211 | if (icr < 0) { | ||
212 | dev_err(&client->dev, "%s: reading INT failed\n", __func__); | ||
213 | return icr; | ||
214 | } | ||
215 | |||
216 | if (enable) | ||
217 | icr |= ISL1208_REG_INT_ALME | ISL1208_REG_INT_IM; | ||
218 | else | ||
219 | icr &= ~(ISL1208_REG_INT_ALME | ISL1208_REG_INT_IM); | ||
220 | |||
221 | icr = i2c_smbus_write_byte_data(client, ISL1208_REG_INT, icr); | ||
222 | if (icr < 0) { | ||
223 | dev_err(&client->dev, "%s: writing INT failed\n", __func__); | ||
224 | return icr; | ||
225 | } | ||
226 | |||
227 | return 0; | ||
228 | } | ||
229 | |||
230 | static int | ||
205 | isl1208_rtc_proc(struct device *dev, struct seq_file *seq) | 231 | isl1208_rtc_proc(struct device *dev, struct seq_file *seq) |
206 | { | 232 | { |
207 | struct i2c_client *const client = to_i2c_client(dev); | 233 | struct i2c_client *const client = to_i2c_client(dev); |
@@ -288,9 +314,8 @@ isl1208_i2c_read_alarm(struct i2c_client *client, struct rtc_wkalrm *alarm) | |||
288 | { | 314 | { |
289 | struct rtc_time *const tm = &alarm->time; | 315 | struct rtc_time *const tm = &alarm->time; |
290 | u8 regs[ISL1208_ALARM_SECTION_LEN] = { 0, }; | 316 | u8 regs[ISL1208_ALARM_SECTION_LEN] = { 0, }; |
291 | int sr; | 317 | int icr, yr, sr = isl1208_i2c_get_sr(client); |
292 | 318 | ||
293 | sr = isl1208_i2c_get_sr(client); | ||
294 | if (sr < 0) { | 319 | if (sr < 0) { |
295 | dev_err(&client->dev, "%s: reading SR failed\n", __func__); | 320 | dev_err(&client->dev, "%s: reading SR failed\n", __func__); |
296 | return sr; | 321 | return sr; |
@@ -313,6 +338,73 @@ isl1208_i2c_read_alarm(struct i2c_client *client, struct rtc_wkalrm *alarm) | |||
313 | bcd2bin(regs[ISL1208_REG_MOA - ISL1208_REG_SCA] & 0x1f) - 1; | 338 | bcd2bin(regs[ISL1208_REG_MOA - ISL1208_REG_SCA] & 0x1f) - 1; |
314 | tm->tm_wday = bcd2bin(regs[ISL1208_REG_DWA - ISL1208_REG_SCA] & 0x03); | 339 | tm->tm_wday = bcd2bin(regs[ISL1208_REG_DWA - ISL1208_REG_SCA] & 0x03); |
315 | 340 | ||
341 | /* The alarm doesn't store the year so get it from the rtc section */ | ||
342 | yr = i2c_smbus_read_byte_data(client, ISL1208_REG_YR); | ||
343 | if (yr < 0) { | ||
344 | dev_err(&client->dev, "%s: reading RTC YR failed\n", __func__); | ||
345 | return yr; | ||
346 | } | ||
347 | tm->tm_year = bcd2bin(yr) + 100; | ||
348 | |||
349 | icr = i2c_smbus_read_byte_data(client, ISL1208_REG_INT); | ||
350 | if (icr < 0) { | ||
351 | dev_err(&client->dev, "%s: reading INT failed\n", __func__); | ||
352 | return icr; | ||
353 | } | ||
354 | alarm->enabled = !!(icr & ISL1208_REG_INT_ALME); | ||
355 | |||
356 | return 0; | ||
357 | } | ||
358 | |||
359 | static int | ||
360 | isl1208_i2c_set_alarm(struct i2c_client *client, struct rtc_wkalrm *alarm) | ||
361 | { | ||
362 | struct rtc_time *alarm_tm = &alarm->time; | ||
363 | u8 regs[ISL1208_ALARM_SECTION_LEN] = { 0, }; | ||
364 | const int offs = ISL1208_REG_SCA; | ||
365 | unsigned long rtc_secs, alarm_secs; | ||
366 | struct rtc_time rtc_tm; | ||
367 | int err, enable; | ||
368 | |||
369 | err = isl1208_i2c_read_time(client, &rtc_tm); | ||
370 | if (err) | ||
371 | return err; | ||
372 | err = rtc_tm_to_time(&rtc_tm, &rtc_secs); | ||
373 | if (err) | ||
374 | return err; | ||
375 | err = rtc_tm_to_time(alarm_tm, &alarm_secs); | ||
376 | if (err) | ||
377 | return err; | ||
378 | |||
379 | /* If the alarm time is before the current time disable the alarm */ | ||
380 | if (!alarm->enabled || alarm_secs <= rtc_secs) | ||
381 | enable = 0x00; | ||
382 | else | ||
383 | enable = 0x80; | ||
384 | |||
385 | /* Program the alarm and enable it for each setting */ | ||
386 | regs[ISL1208_REG_SCA - offs] = bin2bcd(alarm_tm->tm_sec) | enable; | ||
387 | regs[ISL1208_REG_MNA - offs] = bin2bcd(alarm_tm->tm_min) | enable; | ||
388 | regs[ISL1208_REG_HRA - offs] = bin2bcd(alarm_tm->tm_hour) | | ||
389 | ISL1208_REG_HR_MIL | enable; | ||
390 | |||
391 | regs[ISL1208_REG_DTA - offs] = bin2bcd(alarm_tm->tm_mday) | enable; | ||
392 | regs[ISL1208_REG_MOA - offs] = bin2bcd(alarm_tm->tm_mon + 1) | enable; | ||
393 | regs[ISL1208_REG_DWA - offs] = bin2bcd(alarm_tm->tm_wday & 7) | enable; | ||
394 | |||
395 | /* write ALARM registers */ | ||
396 | err = isl1208_i2c_set_regs(client, offs, regs, | ||
397 | ISL1208_ALARM_SECTION_LEN); | ||
398 | if (err < 0) { | ||
399 | dev_err(&client->dev, "%s: writing ALARM section failed\n", | ||
400 | __func__); | ||
401 | return err; | ||
402 | } | ||
403 | |||
404 | err = isl1208_rtc_toggle_alarm(client, enable); | ||
405 | if (err) | ||
406 | return err; | ||
407 | |||
316 | return 0; | 408 | return 0; |
317 | } | 409 | } |
318 | 410 | ||
@@ -391,12 +483,63 @@ isl1208_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) | |||
391 | return isl1208_i2c_read_alarm(to_i2c_client(dev), alarm); | 483 | return isl1208_i2c_read_alarm(to_i2c_client(dev), alarm); |
392 | } | 484 | } |
393 | 485 | ||
486 | static int | ||
487 | isl1208_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) | ||
488 | { | ||
489 | return isl1208_i2c_set_alarm(to_i2c_client(dev), alarm); | ||
490 | } | ||
491 | |||
492 | static irqreturn_t | ||
493 | isl1208_rtc_interrupt(int irq, void *data) | ||
494 | { | ||
495 | unsigned long timeout = jiffies + msecs_to_jiffies(1000); | ||
496 | struct i2c_client *client = data; | ||
497 | int handled = 0, sr, err; | ||
498 | |||
499 | /* | ||
500 | * I2C reads get NAK'ed if we read straight away after an interrupt? | ||
501 | * Using a mdelay/msleep didn't seem to help either, so we work around | ||
502 | * this by continually trying to read the register for a short time. | ||
503 | */ | ||
504 | while (1) { | ||
505 | sr = isl1208_i2c_get_sr(client); | ||
506 | if (sr >= 0) | ||
507 | break; | ||
508 | |||
509 | if (time_after(jiffies, timeout)) { | ||
510 | dev_err(&client->dev, "%s: reading SR failed\n", | ||
511 | __func__); | ||
512 | return sr; | ||
513 | } | ||
514 | } | ||
515 | |||
516 | if (sr & ISL1208_REG_SR_ALM) { | ||
517 | dev_dbg(&client->dev, "alarm!\n"); | ||
518 | |||
519 | /* Clear the alarm */ | ||
520 | sr &= ~ISL1208_REG_SR_ALM; | ||
521 | sr = i2c_smbus_write_byte_data(client, ISL1208_REG_SR, sr); | ||
522 | if (sr < 0) | ||
523 | dev_err(&client->dev, "%s: writing SR failed\n", | ||
524 | __func__); | ||
525 | else | ||
526 | handled = 1; | ||
527 | |||
528 | /* Disable the alarm */ | ||
529 | err = isl1208_rtc_toggle_alarm(client, 0); | ||
530 | if (err) | ||
531 | return err; | ||
532 | } | ||
533 | |||
534 | return handled ? IRQ_HANDLED : IRQ_NONE; | ||
535 | } | ||
536 | |||
394 | static const struct rtc_class_ops isl1208_rtc_ops = { | 537 | static const struct rtc_class_ops isl1208_rtc_ops = { |
395 | .proc = isl1208_rtc_proc, | 538 | .proc = isl1208_rtc_proc, |
396 | .read_time = isl1208_rtc_read_time, | 539 | .read_time = isl1208_rtc_read_time, |
397 | .set_time = isl1208_rtc_set_time, | 540 | .set_time = isl1208_rtc_set_time, |
398 | .read_alarm = isl1208_rtc_read_alarm, | 541 | .read_alarm = isl1208_rtc_read_alarm, |
399 | /*.set_alarm = isl1208_rtc_set_alarm, */ | 542 | .set_alarm = isl1208_rtc_set_alarm, |
400 | }; | 543 | }; |
401 | 544 | ||
402 | /* sysfs interface */ | 545 | /* sysfs interface */ |
@@ -488,11 +631,29 @@ isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
488 | dev_info(&client->dev, | 631 | dev_info(&client->dev, |
489 | "chip found, driver version " DRV_VERSION "\n"); | 632 | "chip found, driver version " DRV_VERSION "\n"); |
490 | 633 | ||
634 | if (client->irq > 0) { | ||
635 | rc = request_threaded_irq(client->irq, NULL, | ||
636 | isl1208_rtc_interrupt, | ||
637 | IRQF_SHARED, | ||
638 | isl1208_driver.driver.name, client); | ||
639 | if (!rc) { | ||
640 | device_init_wakeup(&client->dev, 1); | ||
641 | enable_irq_wake(client->irq); | ||
642 | } else { | ||
643 | dev_err(&client->dev, | ||
644 | "Unable to request irq %d, no alarm support\n", | ||
645 | client->irq); | ||
646 | client->irq = 0; | ||
647 | } | ||
648 | } | ||
649 | |||
491 | rtc = rtc_device_register(isl1208_driver.driver.name, | 650 | rtc = rtc_device_register(isl1208_driver.driver.name, |
492 | &client->dev, &isl1208_rtc_ops, | 651 | &client->dev, &isl1208_rtc_ops, |
493 | THIS_MODULE); | 652 | THIS_MODULE); |
494 | if (IS_ERR(rtc)) | 653 | if (IS_ERR(rtc)) { |
495 | return PTR_ERR(rtc); | 654 | rc = PTR_ERR(rtc); |
655 | goto exit_free_irq; | ||
656 | } | ||
496 | 657 | ||
497 | i2c_set_clientdata(client, rtc); | 658 | i2c_set_clientdata(client, rtc); |
498 | 659 | ||
@@ -514,6 +675,9 @@ isl1208_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
514 | 675 | ||
515 | exit_unregister: | 676 | exit_unregister: |
516 | rtc_device_unregister(rtc); | 677 | rtc_device_unregister(rtc); |
678 | exit_free_irq: | ||
679 | if (client->irq) | ||
680 | free_irq(client->irq, client); | ||
517 | 681 | ||
518 | return rc; | 682 | return rc; |
519 | } | 683 | } |
@@ -525,6 +689,8 @@ isl1208_remove(struct i2c_client *client) | |||
525 | 689 | ||
526 | sysfs_remove_group(&client->dev.kobj, &isl1208_rtc_sysfs_files); | 690 | sysfs_remove_group(&client->dev.kobj, &isl1208_rtc_sysfs_files); |
527 | rtc_device_unregister(rtc); | 691 | rtc_device_unregister(rtc); |
692 | if (client->irq) | ||
693 | free_irq(client->irq, client); | ||
528 | 694 | ||
529 | return 0; | 695 | return 0; |
530 | } | 696 | } |
diff --git a/drivers/rtc/rtc-jz4740.c b/drivers/rtc/rtc-jz4740.c index 2e16f72c9056..b6473631d182 100644 --- a/drivers/rtc/rtc-jz4740.c +++ b/drivers/rtc/rtc-jz4740.c | |||
@@ -168,12 +168,6 @@ static int jz4740_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
168 | return ret; | 168 | return ret; |
169 | } | 169 | } |
170 | 170 | ||
171 | static int jz4740_rtc_update_irq_enable(struct device *dev, unsigned int enable) | ||
172 | { | ||
173 | struct jz4740_rtc *rtc = dev_get_drvdata(dev); | ||
174 | return jz4740_rtc_ctrl_set_bits(rtc, JZ_RTC_CTRL_1HZ_IRQ, enable); | ||
175 | } | ||
176 | |||
177 | static int jz4740_rtc_alarm_irq_enable(struct device *dev, unsigned int enable) | 171 | static int jz4740_rtc_alarm_irq_enable(struct device *dev, unsigned int enable) |
178 | { | 172 | { |
179 | struct jz4740_rtc *rtc = dev_get_drvdata(dev); | 173 | struct jz4740_rtc *rtc = dev_get_drvdata(dev); |
@@ -185,7 +179,6 @@ static struct rtc_class_ops jz4740_rtc_ops = { | |||
185 | .set_mmss = jz4740_rtc_set_mmss, | 179 | .set_mmss = jz4740_rtc_set_mmss, |
186 | .read_alarm = jz4740_rtc_read_alarm, | 180 | .read_alarm = jz4740_rtc_read_alarm, |
187 | .set_alarm = jz4740_rtc_set_alarm, | 181 | .set_alarm = jz4740_rtc_set_alarm, |
188 | .update_irq_enable = jz4740_rtc_update_irq_enable, | ||
189 | .alarm_irq_enable = jz4740_rtc_alarm_irq_enable, | 182 | .alarm_irq_enable = jz4740_rtc_alarm_irq_enable, |
190 | }; | 183 | }; |
191 | 184 | ||
diff --git a/drivers/rtc/rtc-lpc32xx.c b/drivers/rtc/rtc-lpc32xx.c index ec8701ce99f9..ae16250c762f 100644 --- a/drivers/rtc/rtc-lpc32xx.c +++ b/drivers/rtc/rtc-lpc32xx.c | |||
@@ -240,7 +240,7 @@ static int __devinit lpc32xx_rtc_probe(struct platform_device *pdev) | |||
240 | spin_lock_init(&rtc->lock); | 240 | spin_lock_init(&rtc->lock); |
241 | 241 | ||
242 | /* | 242 | /* |
243 | * The RTC is on a seperate power domain and can keep it's state | 243 | * The RTC is on a separate power domain and can keep it's state |
244 | * across a chip power cycle. If the RTC has never been previously | 244 | * across a chip power cycle. If the RTC has never been previously |
245 | * setup, then set it up now for the first time. | 245 | * setup, then set it up now for the first time. |
246 | */ | 246 | */ |
diff --git a/drivers/rtc/rtc-m41t94.c b/drivers/rtc/rtc-m41t94.c index c8c97a4169d4..e259ed76ae85 100644 --- a/drivers/rtc/rtc-m41t94.c +++ b/drivers/rtc/rtc-m41t94.c | |||
@@ -136,7 +136,7 @@ static int __devinit m41t94_probe(struct spi_device *spi) | |||
136 | 136 | ||
137 | static int __devexit m41t94_remove(struct spi_device *spi) | 137 | static int __devexit m41t94_remove(struct spi_device *spi) |
138 | { | 138 | { |
139 | struct rtc_device *rtc = platform_get_drvdata(spi); | 139 | struct rtc_device *rtc = spi_get_drvdata(spi); |
140 | 140 | ||
141 | if (rtc) | 141 | if (rtc) |
142 | rtc_device_unregister(rtc); | 142 | rtc_device_unregister(rtc); |
diff --git a/drivers/rtc/rtc-max8925.c b/drivers/rtc/rtc-max8925.c index 174036dda786..20494b5edc3c 100644 --- a/drivers/rtc/rtc-max8925.c +++ b/drivers/rtc/rtc-max8925.c | |||
@@ -257,6 +257,8 @@ static int __devinit max8925_rtc_probe(struct platform_device *pdev) | |||
257 | goto out_irq; | 257 | goto out_irq; |
258 | } | 258 | } |
259 | 259 | ||
260 | dev_set_drvdata(&pdev->dev, info); | ||
261 | |||
260 | info->rtc_dev = rtc_device_register("max8925-rtc", &pdev->dev, | 262 | info->rtc_dev = rtc_device_register("max8925-rtc", &pdev->dev, |
261 | &max8925_rtc_ops, THIS_MODULE); | 263 | &max8925_rtc_ops, THIS_MODULE); |
262 | ret = PTR_ERR(info->rtc_dev); | 264 | ret = PTR_ERR(info->rtc_dev); |
@@ -265,7 +267,6 @@ static int __devinit max8925_rtc_probe(struct platform_device *pdev) | |||
265 | goto out_rtc; | 267 | goto out_rtc; |
266 | } | 268 | } |
267 | 269 | ||
268 | dev_set_drvdata(&pdev->dev, info); | ||
269 | platform_set_drvdata(pdev, info); | 270 | platform_set_drvdata(pdev, info); |
270 | 271 | ||
271 | return 0; | 272 | return 0; |
diff --git a/drivers/rtc/rtc-mc13xxx.c b/drivers/rtc/rtc-mc13xxx.c index 5314b153bfba..c5ac03793e79 100644 --- a/drivers/rtc/rtc-mc13xxx.c +++ b/drivers/rtc/rtc-mc13xxx.c | |||
@@ -282,12 +282,6 @@ static irqreturn_t mc13xxx_rtc_update_handler(int irq, void *dev) | |||
282 | return IRQ_HANDLED; | 282 | return IRQ_HANDLED; |
283 | } | 283 | } |
284 | 284 | ||
285 | static int mc13xxx_rtc_update_irq_enable(struct device *dev, | ||
286 | unsigned int enabled) | ||
287 | { | ||
288 | return mc13xxx_rtc_irq_enable(dev, enabled, MC13XXX_IRQ_1HZ); | ||
289 | } | ||
290 | |||
291 | static int mc13xxx_rtc_alarm_irq_enable(struct device *dev, | 285 | static int mc13xxx_rtc_alarm_irq_enable(struct device *dev, |
292 | unsigned int enabled) | 286 | unsigned int enabled) |
293 | { | 287 | { |
@@ -300,7 +294,6 @@ static const struct rtc_class_ops mc13xxx_rtc_ops = { | |||
300 | .read_alarm = mc13xxx_rtc_read_alarm, | 294 | .read_alarm = mc13xxx_rtc_read_alarm, |
301 | .set_alarm = mc13xxx_rtc_set_alarm, | 295 | .set_alarm = mc13xxx_rtc_set_alarm, |
302 | .alarm_irq_enable = mc13xxx_rtc_alarm_irq_enable, | 296 | .alarm_irq_enable = mc13xxx_rtc_alarm_irq_enable, |
303 | .update_irq_enable = mc13xxx_rtc_update_irq_enable, | ||
304 | }; | 297 | }; |
305 | 298 | ||
306 | static irqreturn_t mc13xxx_rtc_reset_handler(int irq, void *dev) | 299 | static irqreturn_t mc13xxx_rtc_reset_handler(int irq, void *dev) |
@@ -408,6 +401,7 @@ const struct platform_device_id mc13xxx_rtc_idtable[] = { | |||
408 | }, { | 401 | }, { |
409 | .name = "mc13892-rtc", | 402 | .name = "mc13892-rtc", |
410 | }, | 403 | }, |
404 | { } | ||
411 | }; | 405 | }; |
412 | 406 | ||
413 | static struct platform_driver mc13xxx_rtc_driver = { | 407 | static struct platform_driver mc13xxx_rtc_driver = { |
diff --git a/drivers/rtc/rtc-mpc5121.c b/drivers/rtc/rtc-mpc5121.c index dfcdf0901d21..09ccd8d3ba2a 100644 --- a/drivers/rtc/rtc-mpc5121.c +++ b/drivers/rtc/rtc-mpc5121.c | |||
@@ -240,36 +240,15 @@ static int mpc5121_rtc_alarm_irq_enable(struct device *dev, | |||
240 | return 0; | 240 | return 0; |
241 | } | 241 | } |
242 | 242 | ||
243 | static int mpc5121_rtc_update_irq_enable(struct device *dev, | ||
244 | unsigned int enabled) | ||
245 | { | ||
246 | struct mpc5121_rtc_data *rtc = dev_get_drvdata(dev); | ||
247 | struct mpc5121_rtc_regs __iomem *regs = rtc->regs; | ||
248 | int val; | ||
249 | |||
250 | val = in_8(®s->int_enable); | ||
251 | |||
252 | if (enabled) | ||
253 | val = (val & ~0x8) | 0x1; | ||
254 | else | ||
255 | val &= ~0x1; | ||
256 | |||
257 | out_8(®s->int_enable, val); | ||
258 | |||
259 | return 0; | ||
260 | } | ||
261 | |||
262 | static const struct rtc_class_ops mpc5121_rtc_ops = { | 243 | static const struct rtc_class_ops mpc5121_rtc_ops = { |
263 | .read_time = mpc5121_rtc_read_time, | 244 | .read_time = mpc5121_rtc_read_time, |
264 | .set_time = mpc5121_rtc_set_time, | 245 | .set_time = mpc5121_rtc_set_time, |
265 | .read_alarm = mpc5121_rtc_read_alarm, | 246 | .read_alarm = mpc5121_rtc_read_alarm, |
266 | .set_alarm = mpc5121_rtc_set_alarm, | 247 | .set_alarm = mpc5121_rtc_set_alarm, |
267 | .alarm_irq_enable = mpc5121_rtc_alarm_irq_enable, | 248 | .alarm_irq_enable = mpc5121_rtc_alarm_irq_enable, |
268 | .update_irq_enable = mpc5121_rtc_update_irq_enable, | ||
269 | }; | 249 | }; |
270 | 250 | ||
271 | static int __devinit mpc5121_rtc_probe(struct platform_device *op, | 251 | static int __devinit mpc5121_rtc_probe(struct platform_device *op) |
272 | const struct of_device_id *match) | ||
273 | { | 252 | { |
274 | struct mpc5121_rtc_data *rtc; | 253 | struct mpc5121_rtc_data *rtc; |
275 | int err = 0; | 254 | int err = 0; |
@@ -364,7 +343,7 @@ static struct of_device_id mpc5121_rtc_match[] __devinitdata = { | |||
364 | {}, | 343 | {}, |
365 | }; | 344 | }; |
366 | 345 | ||
367 | static struct of_platform_driver mpc5121_rtc_driver = { | 346 | static struct platform_driver mpc5121_rtc_driver = { |
368 | .driver = { | 347 | .driver = { |
369 | .name = "mpc5121-rtc", | 348 | .name = "mpc5121-rtc", |
370 | .owner = THIS_MODULE, | 349 | .owner = THIS_MODULE, |
@@ -376,13 +355,13 @@ static struct of_platform_driver mpc5121_rtc_driver = { | |||
376 | 355 | ||
377 | static int __init mpc5121_rtc_init(void) | 356 | static int __init mpc5121_rtc_init(void) |
378 | { | 357 | { |
379 | return of_register_platform_driver(&mpc5121_rtc_driver); | 358 | return platform_driver_register(&mpc5121_rtc_driver); |
380 | } | 359 | } |
381 | module_init(mpc5121_rtc_init); | 360 | module_init(mpc5121_rtc_init); |
382 | 361 | ||
383 | static void __exit mpc5121_rtc_exit(void) | 362 | static void __exit mpc5121_rtc_exit(void) |
384 | { | 363 | { |
385 | of_unregister_platform_driver(&mpc5121_rtc_driver); | 364 | platform_driver_unregister(&mpc5121_rtc_driver); |
386 | } | 365 | } |
387 | module_exit(mpc5121_rtc_exit); | 366 | module_exit(mpc5121_rtc_exit); |
388 | 367 | ||
diff --git a/drivers/rtc/rtc-mrst.c b/drivers/rtc/rtc-mrst.c index 1db62db8469d..b2f096871a97 100644 --- a/drivers/rtc/rtc-mrst.c +++ b/drivers/rtc/rtc-mrst.c | |||
@@ -62,6 +62,17 @@ static inline int is_intr(u8 rtc_intr) | |||
62 | return rtc_intr & RTC_IRQMASK; | 62 | return rtc_intr & RTC_IRQMASK; |
63 | } | 63 | } |
64 | 64 | ||
65 | static inline unsigned char vrtc_is_updating(void) | ||
66 | { | ||
67 | unsigned char uip; | ||
68 | unsigned long flags; | ||
69 | |||
70 | spin_lock_irqsave(&rtc_lock, flags); | ||
71 | uip = (vrtc_cmos_read(RTC_FREQ_SELECT) & RTC_UIP); | ||
72 | spin_unlock_irqrestore(&rtc_lock, flags); | ||
73 | return uip; | ||
74 | } | ||
75 | |||
65 | /* | 76 | /* |
66 | * rtc_time's year contains the increment over 1900, but vRTC's YEAR | 77 | * rtc_time's year contains the increment over 1900, but vRTC's YEAR |
67 | * register can't be programmed to value larger than 0x64, so vRTC | 78 | * register can't be programmed to value larger than 0x64, so vRTC |
@@ -76,7 +87,7 @@ static int mrst_read_time(struct device *dev, struct rtc_time *time) | |||
76 | { | 87 | { |
77 | unsigned long flags; | 88 | unsigned long flags; |
78 | 89 | ||
79 | if (rtc_is_updating()) | 90 | if (vrtc_is_updating()) |
80 | mdelay(20); | 91 | mdelay(20); |
81 | 92 | ||
82 | spin_lock_irqsave(&rtc_lock, flags); | 93 | spin_lock_irqsave(&rtc_lock, flags); |
@@ -236,25 +247,6 @@ static int mrst_set_alarm(struct device *dev, struct rtc_wkalrm *t) | |||
236 | return 0; | 247 | return 0; |
237 | } | 248 | } |
238 | 249 | ||
239 | static int mrst_irq_set_state(struct device *dev, int enabled) | ||
240 | { | ||
241 | struct mrst_rtc *mrst = dev_get_drvdata(dev); | ||
242 | unsigned long flags; | ||
243 | |||
244 | if (!mrst->irq) | ||
245 | return -ENXIO; | ||
246 | |||
247 | spin_lock_irqsave(&rtc_lock, flags); | ||
248 | |||
249 | if (enabled) | ||
250 | mrst_irq_enable(mrst, RTC_PIE); | ||
251 | else | ||
252 | mrst_irq_disable(mrst, RTC_PIE); | ||
253 | |||
254 | spin_unlock_irqrestore(&rtc_lock, flags); | ||
255 | return 0; | ||
256 | } | ||
257 | |||
258 | /* Currently, the vRTC doesn't support UIE ON/OFF */ | 250 | /* Currently, the vRTC doesn't support UIE ON/OFF */ |
259 | static int mrst_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | 251 | static int mrst_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) |
260 | { | 252 | { |
@@ -301,7 +293,6 @@ static const struct rtc_class_ops mrst_rtc_ops = { | |||
301 | .read_alarm = mrst_read_alarm, | 293 | .read_alarm = mrst_read_alarm, |
302 | .set_alarm = mrst_set_alarm, | 294 | .set_alarm = mrst_set_alarm, |
303 | .proc = mrst_procfs, | 295 | .proc = mrst_procfs, |
304 | .irq_set_state = mrst_irq_set_state, | ||
305 | .alarm_irq_enable = mrst_rtc_alarm_irq_enable, | 296 | .alarm_irq_enable = mrst_rtc_alarm_irq_enable, |
306 | }; | 297 | }; |
307 | 298 | ||
@@ -328,7 +319,7 @@ static irqreturn_t mrst_rtc_irq(int irq, void *p) | |||
328 | return IRQ_NONE; | 319 | return IRQ_NONE; |
329 | } | 320 | } |
330 | 321 | ||
331 | static int __init | 322 | static int __devinit |
332 | vrtc_mrst_do_probe(struct device *dev, struct resource *iomem, int rtc_irq) | 323 | vrtc_mrst_do_probe(struct device *dev, struct resource *iomem, int rtc_irq) |
333 | { | 324 | { |
334 | int retval = 0; | 325 | int retval = 0; |
@@ -351,6 +342,8 @@ vrtc_mrst_do_probe(struct device *dev, struct resource *iomem, int rtc_irq) | |||
351 | 342 | ||
352 | mrst_rtc.irq = rtc_irq; | 343 | mrst_rtc.irq = rtc_irq; |
353 | mrst_rtc.iomem = iomem; | 344 | mrst_rtc.iomem = iomem; |
345 | mrst_rtc.dev = dev; | ||
346 | dev_set_drvdata(dev, &mrst_rtc); | ||
354 | 347 | ||
355 | mrst_rtc.rtc = rtc_device_register(driver_name, dev, | 348 | mrst_rtc.rtc = rtc_device_register(driver_name, dev, |
356 | &mrst_rtc_ops, THIS_MODULE); | 349 | &mrst_rtc_ops, THIS_MODULE); |
@@ -359,8 +352,6 @@ vrtc_mrst_do_probe(struct device *dev, struct resource *iomem, int rtc_irq) | |||
359 | goto cleanup0; | 352 | goto cleanup0; |
360 | } | 353 | } |
361 | 354 | ||
362 | mrst_rtc.dev = dev; | ||
363 | dev_set_drvdata(dev, &mrst_rtc); | ||
364 | rename_region(iomem, dev_name(&mrst_rtc.rtc->dev)); | 355 | rename_region(iomem, dev_name(&mrst_rtc.rtc->dev)); |
365 | 356 | ||
366 | spin_lock_irq(&rtc_lock); | 357 | spin_lock_irq(&rtc_lock); |
@@ -385,9 +376,10 @@ vrtc_mrst_do_probe(struct device *dev, struct resource *iomem, int rtc_irq) | |||
385 | return 0; | 376 | return 0; |
386 | 377 | ||
387 | cleanup1: | 378 | cleanup1: |
388 | mrst_rtc.dev = NULL; | ||
389 | rtc_device_unregister(mrst_rtc.rtc); | 379 | rtc_device_unregister(mrst_rtc.rtc); |
390 | cleanup0: | 380 | cleanup0: |
381 | dev_set_drvdata(dev, NULL); | ||
382 | mrst_rtc.dev = NULL; | ||
391 | release_region(iomem->start, iomem->end + 1 - iomem->start); | 383 | release_region(iomem->start, iomem->end + 1 - iomem->start); |
392 | dev_err(dev, "rtc-mrst: unable to initialise\n"); | 384 | dev_err(dev, "rtc-mrst: unable to initialise\n"); |
393 | return retval; | 385 | return retval; |
@@ -400,7 +392,7 @@ static void rtc_mrst_do_shutdown(void) | |||
400 | spin_unlock_irq(&rtc_lock); | 392 | spin_unlock_irq(&rtc_lock); |
401 | } | 393 | } |
402 | 394 | ||
403 | static void __exit rtc_mrst_do_remove(struct device *dev) | 395 | static void __devexit rtc_mrst_do_remove(struct device *dev) |
404 | { | 396 | { |
405 | struct mrst_rtc *mrst = dev_get_drvdata(dev); | 397 | struct mrst_rtc *mrst = dev_get_drvdata(dev); |
406 | struct resource *iomem; | 398 | struct resource *iomem; |
@@ -509,14 +501,14 @@ static inline int mrst_poweroff(struct device *dev) | |||
509 | 501 | ||
510 | #endif | 502 | #endif |
511 | 503 | ||
512 | static int __init vrtc_mrst_platform_probe(struct platform_device *pdev) | 504 | static int __devinit vrtc_mrst_platform_probe(struct platform_device *pdev) |
513 | { | 505 | { |
514 | return vrtc_mrst_do_probe(&pdev->dev, | 506 | return vrtc_mrst_do_probe(&pdev->dev, |
515 | platform_get_resource(pdev, IORESOURCE_MEM, 0), | 507 | platform_get_resource(pdev, IORESOURCE_MEM, 0), |
516 | platform_get_irq(pdev, 0)); | 508 | platform_get_irq(pdev, 0)); |
517 | } | 509 | } |
518 | 510 | ||
519 | static int __exit vrtc_mrst_platform_remove(struct platform_device *pdev) | 511 | static int __devexit vrtc_mrst_platform_remove(struct platform_device *pdev) |
520 | { | 512 | { |
521 | rtc_mrst_do_remove(&pdev->dev); | 513 | rtc_mrst_do_remove(&pdev->dev); |
522 | return 0; | 514 | return 0; |
@@ -534,7 +526,7 @@ MODULE_ALIAS("platform:vrtc_mrst"); | |||
534 | 526 | ||
535 | static struct platform_driver vrtc_mrst_platform_driver = { | 527 | static struct platform_driver vrtc_mrst_platform_driver = { |
536 | .probe = vrtc_mrst_platform_probe, | 528 | .probe = vrtc_mrst_platform_probe, |
537 | .remove = __exit_p(vrtc_mrst_platform_remove), | 529 | .remove = __devexit_p(vrtc_mrst_platform_remove), |
538 | .shutdown = vrtc_mrst_platform_shutdown, | 530 | .shutdown = vrtc_mrst_platform_shutdown, |
539 | .driver = { | 531 | .driver = { |
540 | .name = (char *) driver_name, | 532 | .name = (char *) driver_name, |
diff --git a/drivers/rtc/rtc-mxc.c b/drivers/rtc/rtc-mxc.c index 0b06c1e03fd5..826ab64a8fa9 100644 --- a/drivers/rtc/rtc-mxc.c +++ b/drivers/rtc/rtc-mxc.c | |||
@@ -274,12 +274,6 @@ static int mxc_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
274 | return 0; | 274 | return 0; |
275 | } | 275 | } |
276 | 276 | ||
277 | static int mxc_rtc_update_irq_enable(struct device *dev, unsigned int enabled) | ||
278 | { | ||
279 | mxc_rtc_irq_enable(dev, RTC_1HZ_BIT, enabled); | ||
280 | return 0; | ||
281 | } | ||
282 | |||
283 | /* | 277 | /* |
284 | * This function reads the current RTC time into tm in Gregorian date. | 278 | * This function reads the current RTC time into tm in Gregorian date. |
285 | */ | 279 | */ |
@@ -368,7 +362,6 @@ static struct rtc_class_ops mxc_rtc_ops = { | |||
368 | .read_alarm = mxc_rtc_read_alarm, | 362 | .read_alarm = mxc_rtc_read_alarm, |
369 | .set_alarm = mxc_rtc_set_alarm, | 363 | .set_alarm = mxc_rtc_set_alarm, |
370 | .alarm_irq_enable = mxc_rtc_alarm_irq_enable, | 364 | .alarm_irq_enable = mxc_rtc_alarm_irq_enable, |
371 | .update_irq_enable = mxc_rtc_update_irq_enable, | ||
372 | }; | 365 | }; |
373 | 366 | ||
374 | static int __init mxc_rtc_probe(struct platform_device *pdev) | 367 | static int __init mxc_rtc_probe(struct platform_device *pdev) |
diff --git a/drivers/rtc/rtc-nuc900.c b/drivers/rtc/rtc-nuc900.c index ddb0857e15a4..781068d62f23 100644 --- a/drivers/rtc/rtc-nuc900.c +++ b/drivers/rtc/rtc-nuc900.c | |||
@@ -134,20 +134,6 @@ static void nuc900_rtc_bin2bcd(struct device *dev, struct rtc_time *settm, | |||
134 | gettm->bcd_hour = bin2bcd(settm->tm_hour) << 16; | 134 | gettm->bcd_hour = bin2bcd(settm->tm_hour) << 16; |
135 | } | 135 | } |
136 | 136 | ||
137 | static int nuc900_update_irq_enable(struct device *dev, unsigned int enabled) | ||
138 | { | ||
139 | struct nuc900_rtc *rtc = dev_get_drvdata(dev); | ||
140 | |||
141 | if (enabled) | ||
142 | __raw_writel(__raw_readl(rtc->rtc_reg + REG_RTC_RIER)| | ||
143 | (TICKINTENB), rtc->rtc_reg + REG_RTC_RIER); | ||
144 | else | ||
145 | __raw_writel(__raw_readl(rtc->rtc_reg + REG_RTC_RIER)& | ||
146 | (~TICKINTENB), rtc->rtc_reg + REG_RTC_RIER); | ||
147 | |||
148 | return 0; | ||
149 | } | ||
150 | |||
151 | static int nuc900_alarm_irq_enable(struct device *dev, unsigned int enabled) | 137 | static int nuc900_alarm_irq_enable(struct device *dev, unsigned int enabled) |
152 | { | 138 | { |
153 | struct nuc900_rtc *rtc = dev_get_drvdata(dev); | 139 | struct nuc900_rtc *rtc = dev_get_drvdata(dev); |
@@ -234,7 +220,6 @@ static struct rtc_class_ops nuc900_rtc_ops = { | |||
234 | .read_alarm = nuc900_rtc_read_alarm, | 220 | .read_alarm = nuc900_rtc_read_alarm, |
235 | .set_alarm = nuc900_rtc_set_alarm, | 221 | .set_alarm = nuc900_rtc_set_alarm, |
236 | .alarm_irq_enable = nuc900_alarm_irq_enable, | 222 | .alarm_irq_enable = nuc900_alarm_irq_enable, |
237 | .update_irq_enable = nuc900_update_irq_enable, | ||
238 | }; | 223 | }; |
239 | 224 | ||
240 | static int __devinit nuc900_rtc_probe(struct platform_device *pdev) | 225 | static int __devinit nuc900_rtc_probe(struct platform_device *pdev) |
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index b4dbf3a319b3..bcae8dd41496 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c | |||
@@ -135,44 +135,6 @@ static irqreturn_t rtc_irq(int irq, void *rtc) | |||
135 | return IRQ_HANDLED; | 135 | return IRQ_HANDLED; |
136 | } | 136 | } |
137 | 137 | ||
138 | #ifdef CONFIG_RTC_INTF_DEV | ||
139 | |||
140 | static int | ||
141 | omap_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | ||
142 | { | ||
143 | u8 reg; | ||
144 | |||
145 | switch (cmd) { | ||
146 | case RTC_UIE_OFF: | ||
147 | case RTC_UIE_ON: | ||
148 | break; | ||
149 | default: | ||
150 | return -ENOIOCTLCMD; | ||
151 | } | ||
152 | |||
153 | local_irq_disable(); | ||
154 | rtc_wait_not_busy(); | ||
155 | reg = rtc_read(OMAP_RTC_INTERRUPTS_REG); | ||
156 | switch (cmd) { | ||
157 | /* UIE = Update Interrupt Enable (1/second) */ | ||
158 | case RTC_UIE_OFF: | ||
159 | reg &= ~OMAP_RTC_INTERRUPTS_IT_TIMER; | ||
160 | break; | ||
161 | case RTC_UIE_ON: | ||
162 | reg |= OMAP_RTC_INTERRUPTS_IT_TIMER; | ||
163 | break; | ||
164 | } | ||
165 | rtc_wait_not_busy(); | ||
166 | rtc_write(reg, OMAP_RTC_INTERRUPTS_REG); | ||
167 | local_irq_enable(); | ||
168 | |||
169 | return 0; | ||
170 | } | ||
171 | |||
172 | #else | ||
173 | #define omap_rtc_ioctl NULL | ||
174 | #endif | ||
175 | |||
176 | static int omap_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | 138 | static int omap_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) |
177 | { | 139 | { |
178 | u8 reg; | 140 | u8 reg; |
@@ -313,7 +275,6 @@ static int omap_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) | |||
313 | } | 275 | } |
314 | 276 | ||
315 | static struct rtc_class_ops omap_rtc_ops = { | 277 | static struct rtc_class_ops omap_rtc_ops = { |
316 | .ioctl = omap_rtc_ioctl, | ||
317 | .read_time = omap_rtc_read_time, | 278 | .read_time = omap_rtc_read_time, |
318 | .set_time = omap_rtc_set_time, | 279 | .set_time = omap_rtc_set_time, |
319 | .read_alarm = omap_rtc_read_alarm, | 280 | .read_alarm = omap_rtc_read_alarm, |
@@ -433,7 +394,7 @@ static int __init omap_rtc_probe(struct platform_device *pdev) | |||
433 | return 0; | 394 | return 0; |
434 | 395 | ||
435 | fail2: | 396 | fail2: |
436 | free_irq(omap_rtc_timer, NULL); | 397 | free_irq(omap_rtc_timer, rtc); |
437 | fail1: | 398 | fail1: |
438 | rtc_device_unregister(rtc); | 399 | rtc_device_unregister(rtc); |
439 | fail0: | 400 | fail0: |
diff --git a/drivers/rtc/rtc-pcap.c b/drivers/rtc/rtc-pcap.c index 25c0b3fd44f1..a633abc42896 100644 --- a/drivers/rtc/rtc-pcap.c +++ b/drivers/rtc/rtc-pcap.c | |||
@@ -131,18 +131,12 @@ static int pcap_rtc_alarm_irq_enable(struct device *dev, unsigned int en) | |||
131 | return pcap_rtc_irq_enable(dev, PCAP_IRQ_TODA, en); | 131 | return pcap_rtc_irq_enable(dev, PCAP_IRQ_TODA, en); |
132 | } | 132 | } |
133 | 133 | ||
134 | static int pcap_rtc_update_irq_enable(struct device *dev, unsigned int en) | ||
135 | { | ||
136 | return pcap_rtc_irq_enable(dev, PCAP_IRQ_1HZ, en); | ||
137 | } | ||
138 | |||
139 | static const struct rtc_class_ops pcap_rtc_ops = { | 134 | static const struct rtc_class_ops pcap_rtc_ops = { |
140 | .read_time = pcap_rtc_read_time, | 135 | .read_time = pcap_rtc_read_time, |
141 | .read_alarm = pcap_rtc_read_alarm, | 136 | .read_alarm = pcap_rtc_read_alarm, |
142 | .set_alarm = pcap_rtc_set_alarm, | 137 | .set_alarm = pcap_rtc_set_alarm, |
143 | .set_mmss = pcap_rtc_set_mmss, | 138 | .set_mmss = pcap_rtc_set_mmss, |
144 | .alarm_irq_enable = pcap_rtc_alarm_irq_enable, | 139 | .alarm_irq_enable = pcap_rtc_alarm_irq_enable, |
145 | .update_irq_enable = pcap_rtc_update_irq_enable, | ||
146 | }; | 140 | }; |
147 | 141 | ||
148 | static int __devinit pcap_rtc_probe(struct platform_device *pdev) | 142 | static int __devinit pcap_rtc_probe(struct platform_device *pdev) |
diff --git a/drivers/rtc/rtc-pcf50633.c b/drivers/rtc/rtc-pcf50633.c index 16edf94ab42f..f90c574f9d05 100644 --- a/drivers/rtc/rtc-pcf50633.c +++ b/drivers/rtc/rtc-pcf50633.c | |||
@@ -106,25 +106,6 @@ pcf50633_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
106 | return 0; | 106 | return 0; |
107 | } | 107 | } |
108 | 108 | ||
109 | static int | ||
110 | pcf50633_rtc_update_irq_enable(struct device *dev, unsigned int enabled) | ||
111 | { | ||
112 | struct pcf50633_rtc *rtc = dev_get_drvdata(dev); | ||
113 | int err; | ||
114 | |||
115 | if (enabled) | ||
116 | err = pcf50633_irq_unmask(rtc->pcf, PCF50633_IRQ_SECOND); | ||
117 | else | ||
118 | err = pcf50633_irq_mask(rtc->pcf, PCF50633_IRQ_SECOND); | ||
119 | |||
120 | if (err < 0) | ||
121 | return err; | ||
122 | |||
123 | rtc->second_enabled = enabled; | ||
124 | |||
125 | return 0; | ||
126 | } | ||
127 | |||
128 | static int pcf50633_rtc_read_time(struct device *dev, struct rtc_time *tm) | 109 | static int pcf50633_rtc_read_time(struct device *dev, struct rtc_time *tm) |
129 | { | 110 | { |
130 | struct pcf50633_rtc *rtc; | 111 | struct pcf50633_rtc *rtc; |
@@ -262,8 +243,7 @@ static struct rtc_class_ops pcf50633_rtc_ops = { | |||
262 | .set_time = pcf50633_rtc_set_time, | 243 | .set_time = pcf50633_rtc_set_time, |
263 | .read_alarm = pcf50633_rtc_read_alarm, | 244 | .read_alarm = pcf50633_rtc_read_alarm, |
264 | .set_alarm = pcf50633_rtc_set_alarm, | 245 | .set_alarm = pcf50633_rtc_set_alarm, |
265 | .alarm_irq_enable = pcf50633_rtc_alarm_irq_enable, | 246 | .alarm_irq_enable = pcf50633_rtc_alarm_irq_enable, |
266 | .update_irq_enable = pcf50633_rtc_update_irq_enable, | ||
267 | }; | 247 | }; |
268 | 248 | ||
269 | static void pcf50633_rtc_irq(int irq, void *data) | 249 | static void pcf50633_rtc_irq(int irq, void *data) |
diff --git a/drivers/rtc/rtc-pl030.c b/drivers/rtc/rtc-pl030.c index bbdb2f02798a..1d28d4451dae 100644 --- a/drivers/rtc/rtc-pl030.c +++ b/drivers/rtc/rtc-pl030.c | |||
@@ -35,11 +35,6 @@ static irqreturn_t pl030_interrupt(int irq, void *dev_id) | |||
35 | return IRQ_HANDLED; | 35 | return IRQ_HANDLED; |
36 | } | 36 | } |
37 | 37 | ||
38 | static int pl030_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | ||
39 | { | ||
40 | return -ENOIOCTLCMD; | ||
41 | } | ||
42 | |||
43 | static int pl030_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) | 38 | static int pl030_read_alarm(struct device *dev, struct rtc_wkalrm *alrm) |
44 | { | 39 | { |
45 | struct pl030_rtc *rtc = dev_get_drvdata(dev); | 40 | struct pl030_rtc *rtc = dev_get_drvdata(dev); |
@@ -96,14 +91,13 @@ static int pl030_set_time(struct device *dev, struct rtc_time *tm) | |||
96 | } | 91 | } |
97 | 92 | ||
98 | static const struct rtc_class_ops pl030_ops = { | 93 | static const struct rtc_class_ops pl030_ops = { |
99 | .ioctl = pl030_ioctl, | ||
100 | .read_time = pl030_read_time, | 94 | .read_time = pl030_read_time, |
101 | .set_time = pl030_set_time, | 95 | .set_time = pl030_set_time, |
102 | .read_alarm = pl030_read_alarm, | 96 | .read_alarm = pl030_read_alarm, |
103 | .set_alarm = pl030_set_alarm, | 97 | .set_alarm = pl030_set_alarm, |
104 | }; | 98 | }; |
105 | 99 | ||
106 | static int pl030_probe(struct amba_device *dev, struct amba_id *id) | 100 | static int pl030_probe(struct amba_device *dev, const struct amba_id *id) |
107 | { | 101 | { |
108 | struct pl030_rtc *rtc; | 102 | struct pl030_rtc *rtc; |
109 | int ret; | 103 | int ret; |
diff --git a/drivers/rtc/rtc-pl031.c b/drivers/rtc/rtc-pl031.c index b7a6690e5b35..ff1b84bd9bb5 100644 --- a/drivers/rtc/rtc-pl031.c +++ b/drivers/rtc/rtc-pl031.c | |||
@@ -293,57 +293,6 @@ static int pl031_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) | |||
293 | return ret; | 293 | return ret; |
294 | } | 294 | } |
295 | 295 | ||
296 | /* Periodic interrupt is only available in ST variants. */ | ||
297 | static int pl031_irq_set_state(struct device *dev, int enabled) | ||
298 | { | ||
299 | struct pl031_local *ldata = dev_get_drvdata(dev); | ||
300 | |||
301 | if (enabled == 1) { | ||
302 | /* Clear any pending timer interrupt. */ | ||
303 | writel(RTC_BIT_PI, ldata->base + RTC_ICR); | ||
304 | |||
305 | writel(readl(ldata->base + RTC_IMSC) | RTC_BIT_PI, | ||
306 | ldata->base + RTC_IMSC); | ||
307 | |||
308 | /* Now start the timer */ | ||
309 | writel(readl(ldata->base + RTC_TCR) | RTC_TCR_EN, | ||
310 | ldata->base + RTC_TCR); | ||
311 | |||
312 | } else { | ||
313 | writel(readl(ldata->base + RTC_IMSC) & (~RTC_BIT_PI), | ||
314 | ldata->base + RTC_IMSC); | ||
315 | |||
316 | /* Also stop the timer */ | ||
317 | writel(readl(ldata->base + RTC_TCR) & (~RTC_TCR_EN), | ||
318 | ldata->base + RTC_TCR); | ||
319 | } | ||
320 | /* Wait at least 1 RTC32 clock cycle to ensure next access | ||
321 | * to RTC_TCR will succeed. | ||
322 | */ | ||
323 | udelay(40); | ||
324 | |||
325 | return 0; | ||
326 | } | ||
327 | |||
328 | static int pl031_irq_set_freq(struct device *dev, int freq) | ||
329 | { | ||
330 | struct pl031_local *ldata = dev_get_drvdata(dev); | ||
331 | |||
332 | /* Cant set timer if it is already enabled */ | ||
333 | if (readl(ldata->base + RTC_TCR) & RTC_TCR_EN) { | ||
334 | dev_err(dev, "can't change frequency while timer enabled\n"); | ||
335 | return -EINVAL; | ||
336 | } | ||
337 | |||
338 | /* If self start bit in RTC_TCR is set timer will start here, | ||
339 | * but we never set that bit. Instead we start the timer when | ||
340 | * set_state is called with enabled == 1. | ||
341 | */ | ||
342 | writel(RTC_TIMER_FREQ / freq, ldata->base + RTC_TLR); | ||
343 | |||
344 | return 0; | ||
345 | } | ||
346 | |||
347 | static int pl031_remove(struct amba_device *adev) | 296 | static int pl031_remove(struct amba_device *adev) |
348 | { | 297 | { |
349 | struct pl031_local *ldata = dev_get_drvdata(&adev->dev); | 298 | struct pl031_local *ldata = dev_get_drvdata(&adev->dev); |
@@ -358,7 +307,7 @@ static int pl031_remove(struct amba_device *adev) | |||
358 | return 0; | 307 | return 0; |
359 | } | 308 | } |
360 | 309 | ||
361 | static int pl031_probe(struct amba_device *adev, struct amba_id *id) | 310 | static int pl031_probe(struct amba_device *adev, const struct amba_id *id) |
362 | { | 311 | { |
363 | int ret; | 312 | int ret; |
364 | struct pl031_local *ldata; | 313 | struct pl031_local *ldata; |
@@ -440,8 +389,6 @@ static struct rtc_class_ops stv1_pl031_ops = { | |||
440 | .read_alarm = pl031_read_alarm, | 389 | .read_alarm = pl031_read_alarm, |
441 | .set_alarm = pl031_set_alarm, | 390 | .set_alarm = pl031_set_alarm, |
442 | .alarm_irq_enable = pl031_alarm_irq_enable, | 391 | .alarm_irq_enable = pl031_alarm_irq_enable, |
443 | .irq_set_state = pl031_irq_set_state, | ||
444 | .irq_set_freq = pl031_irq_set_freq, | ||
445 | }; | 392 | }; |
446 | 393 | ||
447 | /* And the second ST derivative */ | 394 | /* And the second ST derivative */ |
@@ -451,8 +398,6 @@ static struct rtc_class_ops stv2_pl031_ops = { | |||
451 | .read_alarm = pl031_stv2_read_alarm, | 398 | .read_alarm = pl031_stv2_read_alarm, |
452 | .set_alarm = pl031_stv2_set_alarm, | 399 | .set_alarm = pl031_stv2_set_alarm, |
453 | .alarm_irq_enable = pl031_alarm_irq_enable, | 400 | .alarm_irq_enable = pl031_alarm_irq_enable, |
454 | .irq_set_state = pl031_irq_set_state, | ||
455 | .irq_set_freq = pl031_irq_set_freq, | ||
456 | }; | 401 | }; |
457 | 402 | ||
458 | static struct amba_id pl031_ids[] = { | 403 | static struct amba_id pl031_ids[] = { |
diff --git a/drivers/rtc/rtc-proc.c b/drivers/rtc/rtc-proc.c index 242bbf86c74a..0a59fda5c09d 100644 --- a/drivers/rtc/rtc-proc.c +++ b/drivers/rtc/rtc-proc.c | |||
@@ -69,6 +69,14 @@ static int rtc_proc_show(struct seq_file *seq, void *offset) | |||
69 | alrm.enabled ? "yes" : "no"); | 69 | alrm.enabled ? "yes" : "no"); |
70 | seq_printf(seq, "alrm_pending\t: %s\n", | 70 | seq_printf(seq, "alrm_pending\t: %s\n", |
71 | alrm.pending ? "yes" : "no"); | 71 | alrm.pending ? "yes" : "no"); |
72 | seq_printf(seq, "update IRQ enabled\t: %s\n", | ||
73 | (rtc->uie_rtctimer.enabled) ? "yes" : "no"); | ||
74 | seq_printf(seq, "periodic IRQ enabled\t: %s\n", | ||
75 | (rtc->pie_enabled) ? "yes" : "no"); | ||
76 | seq_printf(seq, "periodic IRQ frequency\t: %d\n", | ||
77 | rtc->irq_freq); | ||
78 | seq_printf(seq, "max user IRQ frequency\t: %d\n", | ||
79 | rtc->max_user_freq); | ||
72 | } | 80 | } |
73 | 81 | ||
74 | seq_printf(seq, "24hr\t\t: yes\n"); | 82 | seq_printf(seq, "24hr\t\t: yes\n"); |
diff --git a/drivers/rtc/rtc-pxa.c b/drivers/rtc/rtc-pxa.c index 29e867a1aaa8..fc9f4991574b 100644 --- a/drivers/rtc/rtc-pxa.c +++ b/drivers/rtc/rtc-pxa.c | |||
@@ -209,32 +209,6 @@ static void pxa_rtc_release(struct device *dev) | |||
209 | free_irq(pxa_rtc->irq_1Hz, dev); | 209 | free_irq(pxa_rtc->irq_1Hz, dev); |
210 | } | 210 | } |
211 | 211 | ||
212 | static int pxa_periodic_irq_set_freq(struct device *dev, int freq) | ||
213 | { | ||
214 | struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); | ||
215 | int period_ms; | ||
216 | |||
217 | if (freq < 1 || freq > MAXFREQ_PERIODIC) | ||
218 | return -EINVAL; | ||
219 | |||
220 | period_ms = 1000 / freq; | ||
221 | rtc_writel(pxa_rtc, PIAR, period_ms); | ||
222 | |||
223 | return 0; | ||
224 | } | ||
225 | |||
226 | static int pxa_periodic_irq_set_state(struct device *dev, int enabled) | ||
227 | { | ||
228 | struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); | ||
229 | |||
230 | if (enabled) | ||
231 | rtsr_set_bits(pxa_rtc, RTSR_PIALE | RTSR_PICE); | ||
232 | else | ||
233 | rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_PICE); | ||
234 | |||
235 | return 0; | ||
236 | } | ||
237 | |||
238 | static int pxa_alarm_irq_enable(struct device *dev, unsigned int enabled) | 212 | static int pxa_alarm_irq_enable(struct device *dev, unsigned int enabled) |
239 | { | 213 | { |
240 | struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); | 214 | struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); |
@@ -250,21 +224,6 @@ static int pxa_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
250 | return 0; | 224 | return 0; |
251 | } | 225 | } |
252 | 226 | ||
253 | static int pxa_update_irq_enable(struct device *dev, unsigned int enabled) | ||
254 | { | ||
255 | struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); | ||
256 | |||
257 | spin_lock_irq(&pxa_rtc->lock); | ||
258 | |||
259 | if (enabled) | ||
260 | rtsr_set_bits(pxa_rtc, RTSR_HZE); | ||
261 | else | ||
262 | rtsr_clear_bits(pxa_rtc, RTSR_HZE); | ||
263 | |||
264 | spin_unlock_irq(&pxa_rtc->lock); | ||
265 | return 0; | ||
266 | } | ||
267 | |||
268 | static int pxa_rtc_read_time(struct device *dev, struct rtc_time *tm) | 227 | static int pxa_rtc_read_time(struct device *dev, struct rtc_time *tm) |
269 | { | 228 | { |
270 | struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); | 229 | struct pxa_rtc *pxa_rtc = dev_get_drvdata(dev); |
@@ -346,10 +305,7 @@ static const struct rtc_class_ops pxa_rtc_ops = { | |||
346 | .read_alarm = pxa_rtc_read_alarm, | 305 | .read_alarm = pxa_rtc_read_alarm, |
347 | .set_alarm = pxa_rtc_set_alarm, | 306 | .set_alarm = pxa_rtc_set_alarm, |
348 | .alarm_irq_enable = pxa_alarm_irq_enable, | 307 | .alarm_irq_enable = pxa_alarm_irq_enable, |
349 | .update_irq_enable = pxa_update_irq_enable, | ||
350 | .proc = pxa_rtc_proc, | 308 | .proc = pxa_rtc_proc, |
351 | .irq_set_state = pxa_periodic_irq_set_state, | ||
352 | .irq_set_freq = pxa_periodic_irq_set_freq, | ||
353 | }; | 309 | }; |
354 | 310 | ||
355 | static int __init pxa_rtc_probe(struct platform_device *pdev) | 311 | static int __init pxa_rtc_probe(struct platform_device *pdev) |
diff --git a/drivers/rtc/rtc-rs5c372.c b/drivers/rtc/rtc-rs5c372.c index 6aaa1550e3b1..85c1b848dd72 100644 --- a/drivers/rtc/rtc-rs5c372.c +++ b/drivers/rtc/rtc-rs5c372.c | |||
@@ -281,57 +281,6 @@ static int rs5c372_rtc_set_time(struct device *dev, struct rtc_time *tm) | |||
281 | return rs5c372_set_datetime(to_i2c_client(dev), tm); | 281 | return rs5c372_set_datetime(to_i2c_client(dev), tm); |
282 | } | 282 | } |
283 | 283 | ||
284 | #if defined(CONFIG_RTC_INTF_DEV) || defined(CONFIG_RTC_INTF_DEV_MODULE) | ||
285 | |||
286 | static int | ||
287 | rs5c_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | ||
288 | { | ||
289 | struct i2c_client *client = to_i2c_client(dev); | ||
290 | struct rs5c372 *rs5c = i2c_get_clientdata(client); | ||
291 | unsigned char buf; | ||
292 | int status, addr; | ||
293 | |||
294 | buf = rs5c->regs[RS5C_REG_CTRL1]; | ||
295 | switch (cmd) { | ||
296 | case RTC_UIE_OFF: | ||
297 | case RTC_UIE_ON: | ||
298 | /* some 327a modes use a different IRQ pin for 1Hz irqs */ | ||
299 | if (rs5c->type == rtc_rs5c372a | ||
300 | && (buf & RS5C372A_CTRL1_SL1)) | ||
301 | return -ENOIOCTLCMD; | ||
302 | default: | ||
303 | return -ENOIOCTLCMD; | ||
304 | } | ||
305 | |||
306 | status = rs5c_get_regs(rs5c); | ||
307 | if (status < 0) | ||
308 | return status; | ||
309 | |||
310 | addr = RS5C_ADDR(RS5C_REG_CTRL1); | ||
311 | switch (cmd) { | ||
312 | case RTC_UIE_OFF: /* update off */ | ||
313 | buf &= ~RS5C_CTRL1_CT_MASK; | ||
314 | break; | ||
315 | case RTC_UIE_ON: /* update on */ | ||
316 | buf &= ~RS5C_CTRL1_CT_MASK; | ||
317 | buf |= RS5C_CTRL1_CT4; | ||
318 | break; | ||
319 | } | ||
320 | |||
321 | if (i2c_smbus_write_byte_data(client, addr, buf) < 0) { | ||
322 | printk(KERN_WARNING "%s: can't update alarm\n", | ||
323 | rs5c->rtc->name); | ||
324 | status = -EIO; | ||
325 | } else | ||
326 | rs5c->regs[RS5C_REG_CTRL1] = buf; | ||
327 | |||
328 | return status; | ||
329 | } | ||
330 | |||
331 | #else | ||
332 | #define rs5c_rtc_ioctl NULL | ||
333 | #endif | ||
334 | |||
335 | 284 | ||
336 | static int rs5c_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | 285 | static int rs5c_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) |
337 | { | 286 | { |
@@ -480,7 +429,6 @@ static int rs5c372_rtc_proc(struct device *dev, struct seq_file *seq) | |||
480 | 429 | ||
481 | static const struct rtc_class_ops rs5c372_rtc_ops = { | 430 | static const struct rtc_class_ops rs5c372_rtc_ops = { |
482 | .proc = rs5c372_rtc_proc, | 431 | .proc = rs5c372_rtc_proc, |
483 | .ioctl = rs5c_rtc_ioctl, | ||
484 | .read_time = rs5c372_rtc_read_time, | 432 | .read_time = rs5c372_rtc_read_time, |
485 | .set_time = rs5c372_rtc_set_time, | 433 | .set_time = rs5c372_rtc_set_time, |
486 | .read_alarm = rs5c_read_alarm, | 434 | .read_alarm = rs5c_read_alarm, |
diff --git a/drivers/rtc/rtc-rx8025.c b/drivers/rtc/rtc-rx8025.c index af32a62e12a8..fde172fb2abe 100644 --- a/drivers/rtc/rtc-rx8025.c +++ b/drivers/rtc/rtc-rx8025.c | |||
@@ -424,37 +424,12 @@ static int rx8025_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
424 | return 0; | 424 | return 0; |
425 | } | 425 | } |
426 | 426 | ||
427 | static int rx8025_irq_set_state(struct device *dev, int enabled) | ||
428 | { | ||
429 | struct i2c_client *client = to_i2c_client(dev); | ||
430 | struct rx8025_data *rx8025 = i2c_get_clientdata(client); | ||
431 | int ctrl1; | ||
432 | int err; | ||
433 | |||
434 | if (client->irq <= 0) | ||
435 | return -ENXIO; | ||
436 | |||
437 | ctrl1 = rx8025->ctrl1 & ~RX8025_BIT_CTRL1_CT; | ||
438 | if (enabled) | ||
439 | ctrl1 |= RX8025_BIT_CTRL1_CT_1HZ; | ||
440 | if (ctrl1 != rx8025->ctrl1) { | ||
441 | rx8025->ctrl1 = ctrl1; | ||
442 | err = rx8025_write_reg(rx8025->client, RX8025_REG_CTRL1, | ||
443 | rx8025->ctrl1); | ||
444 | if (err) | ||
445 | return err; | ||
446 | } | ||
447 | |||
448 | return 0; | ||
449 | } | ||
450 | |||
451 | static struct rtc_class_ops rx8025_rtc_ops = { | 427 | static struct rtc_class_ops rx8025_rtc_ops = { |
452 | .read_time = rx8025_get_time, | 428 | .read_time = rx8025_get_time, |
453 | .set_time = rx8025_set_time, | 429 | .set_time = rx8025_set_time, |
454 | .read_alarm = rx8025_read_alarm, | 430 | .read_alarm = rx8025_read_alarm, |
455 | .set_alarm = rx8025_set_alarm, | 431 | .set_alarm = rx8025_set_alarm, |
456 | .alarm_irq_enable = rx8025_alarm_irq_enable, | 432 | .alarm_irq_enable = rx8025_alarm_irq_enable, |
457 | .irq_set_state = rx8025_irq_set_state, | ||
458 | }; | 433 | }; |
459 | 434 | ||
460 | /* | 435 | /* |
diff --git a/drivers/rtc/rtc-s3c.c b/drivers/rtc/rtc-s3c.c index cf953ecbfca9..b3466c491cd3 100644 --- a/drivers/rtc/rtc-s3c.c +++ b/drivers/rtc/rtc-s3c.c | |||
@@ -77,47 +77,18 @@ static irqreturn_t s3c_rtc_tickirq(int irq, void *id) | |||
77 | } | 77 | } |
78 | 78 | ||
79 | /* Update control registers */ | 79 | /* Update control registers */ |
80 | static void s3c_rtc_setaie(int to) | 80 | static int s3c_rtc_setaie(struct device *dev, unsigned int enabled) |
81 | { | 81 | { |
82 | unsigned int tmp; | 82 | unsigned int tmp; |
83 | 83 | ||
84 | pr_debug("%s: aie=%d\n", __func__, to); | 84 | pr_debug("%s: aie=%d\n", __func__, enabled); |
85 | 85 | ||
86 | tmp = readb(s3c_rtc_base + S3C2410_RTCALM) & ~S3C2410_RTCALM_ALMEN; | 86 | tmp = readb(s3c_rtc_base + S3C2410_RTCALM) & ~S3C2410_RTCALM_ALMEN; |
87 | 87 | ||
88 | if (to) | 88 | if (enabled) |
89 | tmp |= S3C2410_RTCALM_ALMEN; | 89 | tmp |= S3C2410_RTCALM_ALMEN; |
90 | 90 | ||
91 | writeb(tmp, s3c_rtc_base + S3C2410_RTCALM); | 91 | writeb(tmp, s3c_rtc_base + S3C2410_RTCALM); |
92 | } | ||
93 | |||
94 | static int s3c_rtc_setpie(struct device *dev, int enabled) | ||
95 | { | ||
96 | unsigned int tmp; | ||
97 | |||
98 | pr_debug("%s: pie=%d\n", __func__, enabled); | ||
99 | |||
100 | spin_lock_irq(&s3c_rtc_pie_lock); | ||
101 | |||
102 | if (s3c_rtc_cpu_type == TYPE_S3C64XX) { | ||
103 | tmp = readw(s3c_rtc_base + S3C2410_RTCCON); | ||
104 | tmp &= ~S3C64XX_RTCCON_TICEN; | ||
105 | |||
106 | if (enabled) | ||
107 | tmp |= S3C64XX_RTCCON_TICEN; | ||
108 | |||
109 | writew(tmp, s3c_rtc_base + S3C2410_RTCCON); | ||
110 | } else { | ||
111 | tmp = readb(s3c_rtc_base + S3C2410_TICNT); | ||
112 | tmp &= ~S3C2410_TICNT_ENABLE; | ||
113 | |||
114 | if (enabled) | ||
115 | tmp |= S3C2410_TICNT_ENABLE; | ||
116 | |||
117 | writeb(tmp, s3c_rtc_base + S3C2410_TICNT); | ||
118 | } | ||
119 | |||
120 | spin_unlock_irq(&s3c_rtc_pie_lock); | ||
121 | 92 | ||
122 | return 0; | 93 | return 0; |
123 | } | 94 | } |
@@ -308,7 +279,7 @@ static int s3c_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
308 | 279 | ||
309 | writeb(alrm_en, base + S3C2410_RTCALM); | 280 | writeb(alrm_en, base + S3C2410_RTCALM); |
310 | 281 | ||
311 | s3c_rtc_setaie(alrm->enabled); | 282 | s3c_rtc_setaie(dev, alrm->enabled); |
312 | 283 | ||
313 | return 0; | 284 | return 0; |
314 | } | 285 | } |
@@ -365,7 +336,6 @@ static void s3c_rtc_release(struct device *dev) | |||
365 | 336 | ||
366 | /* do not clear AIE here, it may be needed for wake */ | 337 | /* do not clear AIE here, it may be needed for wake */ |
367 | 338 | ||
368 | s3c_rtc_setpie(dev, 0); | ||
369 | free_irq(s3c_rtc_alarmno, rtc_dev); | 339 | free_irq(s3c_rtc_alarmno, rtc_dev); |
370 | free_irq(s3c_rtc_tickno, rtc_dev); | 340 | free_irq(s3c_rtc_tickno, rtc_dev); |
371 | } | 341 | } |
@@ -377,8 +347,6 @@ static const struct rtc_class_ops s3c_rtcops = { | |||
377 | .set_time = s3c_rtc_settime, | 347 | .set_time = s3c_rtc_settime, |
378 | .read_alarm = s3c_rtc_getalarm, | 348 | .read_alarm = s3c_rtc_getalarm, |
379 | .set_alarm = s3c_rtc_setalarm, | 349 | .set_alarm = s3c_rtc_setalarm, |
380 | .irq_set_freq = s3c_rtc_setfreq, | ||
381 | .irq_set_state = s3c_rtc_setpie, | ||
382 | .proc = s3c_rtc_proc, | 350 | .proc = s3c_rtc_proc, |
383 | .alarm_irq_enable = s3c_rtc_setaie, | 351 | .alarm_irq_enable = s3c_rtc_setaie, |
384 | }; | 352 | }; |
@@ -439,8 +407,7 @@ static int __devexit s3c_rtc_remove(struct platform_device *dev) | |||
439 | platform_set_drvdata(dev, NULL); | 407 | platform_set_drvdata(dev, NULL); |
440 | rtc_device_unregister(rtc); | 408 | rtc_device_unregister(rtc); |
441 | 409 | ||
442 | s3c_rtc_setpie(&dev->dev, 0); | 410 | s3c_rtc_setaie(&dev->dev, 0); |
443 | s3c_rtc_setaie(0); | ||
444 | 411 | ||
445 | clk_disable(rtc_clk); | 412 | clk_disable(rtc_clk); |
446 | clk_put(rtc_clk); | 413 | clk_put(rtc_clk); |
diff --git a/drivers/rtc/rtc-sa1100.c b/drivers/rtc/rtc-sa1100.c index 5dfe5ffcb0d3..0b40bb88a884 100644 --- a/drivers/rtc/rtc-sa1100.c +++ b/drivers/rtc/rtc-sa1100.c | |||
@@ -43,7 +43,6 @@ | |||
43 | #define RTC_DEF_TRIM 0 | 43 | #define RTC_DEF_TRIM 0 |
44 | 44 | ||
45 | static const unsigned long RTC_FREQ = 1024; | 45 | static const unsigned long RTC_FREQ = 1024; |
46 | static unsigned long timer_freq; | ||
47 | static struct rtc_time rtc_alarm; | 46 | static struct rtc_time rtc_alarm; |
48 | static DEFINE_SPINLOCK(sa1100_rtc_lock); | 47 | static DEFINE_SPINLOCK(sa1100_rtc_lock); |
49 | 48 | ||
@@ -156,114 +155,11 @@ static irqreturn_t sa1100_rtc_interrupt(int irq, void *dev_id) | |||
156 | return IRQ_HANDLED; | 155 | return IRQ_HANDLED; |
157 | } | 156 | } |
158 | 157 | ||
159 | static int sa1100_irq_set_freq(struct device *dev, int freq) | ||
160 | { | ||
161 | if (freq < 1 || freq > timer_freq) { | ||
162 | return -EINVAL; | ||
163 | } else { | ||
164 | struct rtc_device *rtc = (struct rtc_device *)dev; | ||
165 | |||
166 | rtc->irq_freq = freq; | ||
167 | |||
168 | return 0; | ||
169 | } | ||
170 | } | ||
171 | |||
172 | static int rtc_timer1_count; | ||
173 | |||
174 | static int sa1100_irq_set_state(struct device *dev, int enabled) | ||
175 | { | ||
176 | spin_lock_irq(&sa1100_rtc_lock); | ||
177 | if (enabled) { | ||
178 | struct rtc_device *rtc = (struct rtc_device *)dev; | ||
179 | |||
180 | OSMR1 = timer_freq / rtc->irq_freq + OSCR; | ||
181 | OIER |= OIER_E1; | ||
182 | rtc_timer1_count = 1; | ||
183 | } else { | ||
184 | OIER &= ~OIER_E1; | ||
185 | } | ||
186 | spin_unlock_irq(&sa1100_rtc_lock); | ||
187 | |||
188 | return 0; | ||
189 | } | ||
190 | |||
191 | static inline int sa1100_timer1_retrigger(struct rtc_device *rtc) | ||
192 | { | ||
193 | unsigned long diff; | ||
194 | unsigned long period = timer_freq / rtc->irq_freq; | ||
195 | |||
196 | spin_lock_irq(&sa1100_rtc_lock); | ||
197 | |||
198 | do { | ||
199 | OSMR1 += period; | ||
200 | diff = OSMR1 - OSCR; | ||
201 | /* If OSCR > OSMR1, diff is a very large number (unsigned | ||
202 | * math). This means we have a lost interrupt. */ | ||
203 | } while (diff > period); | ||
204 | OIER |= OIER_E1; | ||
205 | |||
206 | spin_unlock_irq(&sa1100_rtc_lock); | ||
207 | |||
208 | return 0; | ||
209 | } | ||
210 | |||
211 | static irqreturn_t timer1_interrupt(int irq, void *dev_id) | ||
212 | { | ||
213 | struct platform_device *pdev = to_platform_device(dev_id); | ||
214 | struct rtc_device *rtc = platform_get_drvdata(pdev); | ||
215 | |||
216 | /* | ||
217 | * If we match for the first time, rtc_timer1_count will be 1. | ||
218 | * Otherwise, we wrapped around (very unlikely but | ||
219 | * still possible) so compute the amount of missed periods. | ||
220 | * The match reg is updated only when the data is actually retrieved | ||
221 | * to avoid unnecessary interrupts. | ||
222 | */ | ||
223 | OSSR = OSSR_M1; /* clear match on timer1 */ | ||
224 | |||
225 | rtc_update_irq(rtc, rtc_timer1_count, RTC_PF | RTC_IRQF); | ||
226 | |||
227 | if (rtc_timer1_count == 1) | ||
228 | rtc_timer1_count = | ||
229 | (rtc->irq_freq * ((1 << 30) / (timer_freq >> 2))); | ||
230 | |||
231 | /* retrigger. */ | ||
232 | sa1100_timer1_retrigger(rtc); | ||
233 | |||
234 | return IRQ_HANDLED; | ||
235 | } | ||
236 | |||
237 | static int sa1100_rtc_read_callback(struct device *dev, int data) | ||
238 | { | ||
239 | if (data & RTC_PF) { | ||
240 | struct rtc_device *rtc = (struct rtc_device *)dev; | ||
241 | |||
242 | /* interpolate missed periods and set match for the next */ | ||
243 | unsigned long period = timer_freq / rtc->irq_freq; | ||
244 | unsigned long oscr = OSCR; | ||
245 | unsigned long osmr1 = OSMR1; | ||
246 | unsigned long missed = (oscr - osmr1)/period; | ||
247 | data += missed << 8; | ||
248 | OSSR = OSSR_M1; /* clear match on timer 1 */ | ||
249 | OSMR1 = osmr1 + (missed + 1)*period; | ||
250 | /* Ensure we didn't miss another match in the mean time. | ||
251 | * Here we compare (match - OSCR) 8 instead of 0 -- | ||
252 | * see comment in pxa_timer_interrupt() for explanation. | ||
253 | */ | ||
254 | while ((signed long)((osmr1 = OSMR1) - OSCR) <= 8) { | ||
255 | data += 0x100; | ||
256 | OSSR = OSSR_M1; /* clear match on timer 1 */ | ||
257 | OSMR1 = osmr1 + period; | ||
258 | } | ||
259 | } | ||
260 | return data; | ||
261 | } | ||
262 | |||
263 | static int sa1100_rtc_open(struct device *dev) | 158 | static int sa1100_rtc_open(struct device *dev) |
264 | { | 159 | { |
265 | int ret; | 160 | int ret; |
266 | struct rtc_device *rtc = (struct rtc_device *)dev; | 161 | struct platform_device *plat_dev = to_platform_device(dev); |
162 | struct rtc_device *rtc = platform_get_drvdata(plat_dev); | ||
267 | 163 | ||
268 | ret = request_irq(IRQ_RTC1Hz, sa1100_rtc_interrupt, IRQF_DISABLED, | 164 | ret = request_irq(IRQ_RTC1Hz, sa1100_rtc_interrupt, IRQF_DISABLED, |
269 | "rtc 1Hz", dev); | 165 | "rtc 1Hz", dev); |
@@ -277,19 +173,11 @@ static int sa1100_rtc_open(struct device *dev) | |||
277 | dev_err(dev, "IRQ %d already in use.\n", IRQ_RTCAlrm); | 173 | dev_err(dev, "IRQ %d already in use.\n", IRQ_RTCAlrm); |
278 | goto fail_ai; | 174 | goto fail_ai; |
279 | } | 175 | } |
280 | ret = request_irq(IRQ_OST1, timer1_interrupt, IRQF_DISABLED, | ||
281 | "rtc timer", dev); | ||
282 | if (ret) { | ||
283 | dev_err(dev, "IRQ %d already in use.\n", IRQ_OST1); | ||
284 | goto fail_pi; | ||
285 | } | ||
286 | rtc->max_user_freq = RTC_FREQ; | 176 | rtc->max_user_freq = RTC_FREQ; |
287 | sa1100_irq_set_freq(dev, RTC_FREQ); | 177 | rtc_irq_set_freq(rtc, NULL, RTC_FREQ); |
288 | 178 | ||
289 | return 0; | 179 | return 0; |
290 | 180 | ||
291 | fail_pi: | ||
292 | free_irq(IRQ_RTCAlrm, dev); | ||
293 | fail_ai: | 181 | fail_ai: |
294 | free_irq(IRQ_RTC1Hz, dev); | 182 | free_irq(IRQ_RTC1Hz, dev); |
295 | fail_ui: | 183 | fail_ui: |
@@ -304,30 +192,10 @@ static void sa1100_rtc_release(struct device *dev) | |||
304 | OSSR = OSSR_M1; | 192 | OSSR = OSSR_M1; |
305 | spin_unlock_irq(&sa1100_rtc_lock); | 193 | spin_unlock_irq(&sa1100_rtc_lock); |
306 | 194 | ||
307 | free_irq(IRQ_OST1, dev); | ||
308 | free_irq(IRQ_RTCAlrm, dev); | 195 | free_irq(IRQ_RTCAlrm, dev); |
309 | free_irq(IRQ_RTC1Hz, dev); | 196 | free_irq(IRQ_RTC1Hz, dev); |
310 | } | 197 | } |
311 | 198 | ||
312 | |||
313 | static int sa1100_rtc_ioctl(struct device *dev, unsigned int cmd, | ||
314 | unsigned long arg) | ||
315 | { | ||
316 | switch (cmd) { | ||
317 | case RTC_UIE_OFF: | ||
318 | spin_lock_irq(&sa1100_rtc_lock); | ||
319 | RTSR &= ~RTSR_HZE; | ||
320 | spin_unlock_irq(&sa1100_rtc_lock); | ||
321 | return 0; | ||
322 | case RTC_UIE_ON: | ||
323 | spin_lock_irq(&sa1100_rtc_lock); | ||
324 | RTSR |= RTSR_HZE; | ||
325 | spin_unlock_irq(&sa1100_rtc_lock); | ||
326 | return 0; | ||
327 | } | ||
328 | return -ENOIOCTLCMD; | ||
329 | } | ||
330 | |||
331 | static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | 199 | static int sa1100_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) |
332 | { | 200 | { |
333 | spin_lock_irq(&sa1100_rtc_lock); | 201 | spin_lock_irq(&sa1100_rtc_lock); |
@@ -386,31 +254,20 @@ static int sa1100_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
386 | 254 | ||
387 | static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq) | 255 | static int sa1100_rtc_proc(struct device *dev, struct seq_file *seq) |
388 | { | 256 | { |
389 | struct rtc_device *rtc = (struct rtc_device *)dev; | 257 | seq_printf(seq, "trim/divider\t\t: 0x%08x\n", (u32) RTTR); |
390 | 258 | seq_printf(seq, "RTSR\t\t\t: 0x%08x\n", (u32)RTSR); | |
391 | seq_printf(seq, "trim/divider\t: 0x%08x\n", (u32) RTTR); | ||
392 | seq_printf(seq, "update_IRQ\t: %s\n", | ||
393 | (RTSR & RTSR_HZE) ? "yes" : "no"); | ||
394 | seq_printf(seq, "periodic_IRQ\t: %s\n", | ||
395 | (OIER & OIER_E1) ? "yes" : "no"); | ||
396 | seq_printf(seq, "periodic_freq\t: %d\n", rtc->irq_freq); | ||
397 | seq_printf(seq, "RTSR\t\t: 0x%08x\n", (u32)RTSR); | ||
398 | 259 | ||
399 | return 0; | 260 | return 0; |
400 | } | 261 | } |
401 | 262 | ||
402 | static const struct rtc_class_ops sa1100_rtc_ops = { | 263 | static const struct rtc_class_ops sa1100_rtc_ops = { |
403 | .open = sa1100_rtc_open, | 264 | .open = sa1100_rtc_open, |
404 | .read_callback = sa1100_rtc_read_callback, | ||
405 | .release = sa1100_rtc_release, | 265 | .release = sa1100_rtc_release, |
406 | .ioctl = sa1100_rtc_ioctl, | ||
407 | .read_time = sa1100_rtc_read_time, | 266 | .read_time = sa1100_rtc_read_time, |
408 | .set_time = sa1100_rtc_set_time, | 267 | .set_time = sa1100_rtc_set_time, |
409 | .read_alarm = sa1100_rtc_read_alarm, | 268 | .read_alarm = sa1100_rtc_read_alarm, |
410 | .set_alarm = sa1100_rtc_set_alarm, | 269 | .set_alarm = sa1100_rtc_set_alarm, |
411 | .proc = sa1100_rtc_proc, | 270 | .proc = sa1100_rtc_proc, |
412 | .irq_set_freq = sa1100_irq_set_freq, | ||
413 | .irq_set_state = sa1100_irq_set_state, | ||
414 | .alarm_irq_enable = sa1100_rtc_alarm_irq_enable, | 271 | .alarm_irq_enable = sa1100_rtc_alarm_irq_enable, |
415 | }; | 272 | }; |
416 | 273 | ||
@@ -418,8 +275,6 @@ static int sa1100_rtc_probe(struct platform_device *pdev) | |||
418 | { | 275 | { |
419 | struct rtc_device *rtc; | 276 | struct rtc_device *rtc; |
420 | 277 | ||
421 | timer_freq = get_clock_tick_rate(); | ||
422 | |||
423 | /* | 278 | /* |
424 | * According to the manual we should be able to let RTTR be zero | 279 | * According to the manual we should be able to let RTTR be zero |
425 | * and then a default diviser for a 32.768KHz clock is used. | 280 | * and then a default diviser for a 32.768KHz clock is used. |
@@ -445,11 +300,6 @@ static int sa1100_rtc_probe(struct platform_device *pdev) | |||
445 | 300 | ||
446 | platform_set_drvdata(pdev, rtc); | 301 | platform_set_drvdata(pdev, rtc); |
447 | 302 | ||
448 | /* Set the irq_freq */ | ||
449 | /*TODO: Find out who is messing with this value after we initialize | ||
450 | * it here.*/ | ||
451 | rtc->irq_freq = RTC_FREQ; | ||
452 | |||
453 | /* Fix for a nasty initialization problem the in SA11xx RTSR register. | 303 | /* Fix for a nasty initialization problem the in SA11xx RTSR register. |
454 | * See also the comments in sa1100_rtc_interrupt(). | 304 | * See also the comments in sa1100_rtc_interrupt(). |
455 | * | 305 | * |
diff --git a/drivers/rtc/rtc-sh.c b/drivers/rtc/rtc-sh.c index 93314a9e7fa9..6ac55fd48413 100644 --- a/drivers/rtc/rtc-sh.c +++ b/drivers/rtc/rtc-sh.c | |||
@@ -344,27 +344,6 @@ static inline void sh_rtc_setcie(struct device *dev, unsigned int enable) | |||
344 | spin_unlock_irq(&rtc->lock); | 344 | spin_unlock_irq(&rtc->lock); |
345 | } | 345 | } |
346 | 346 | ||
347 | static int sh_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | ||
348 | { | ||
349 | struct sh_rtc *rtc = dev_get_drvdata(dev); | ||
350 | unsigned int ret = 0; | ||
351 | |||
352 | switch (cmd) { | ||
353 | case RTC_UIE_OFF: | ||
354 | rtc->periodic_freq &= ~PF_OXS; | ||
355 | sh_rtc_setcie(dev, 0); | ||
356 | break; | ||
357 | case RTC_UIE_ON: | ||
358 | rtc->periodic_freq |= PF_OXS; | ||
359 | sh_rtc_setcie(dev, 1); | ||
360 | break; | ||
361 | default: | ||
362 | ret = -ENOIOCTLCMD; | ||
363 | } | ||
364 | |||
365 | return ret; | ||
366 | } | ||
367 | |||
368 | static int sh_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | 347 | static int sh_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) |
369 | { | 348 | { |
370 | sh_rtc_setaie(dev, enabled); | 349 | sh_rtc_setaie(dev, enabled); |
@@ -598,13 +577,10 @@ static int sh_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) | |||
598 | } | 577 | } |
599 | 578 | ||
600 | static struct rtc_class_ops sh_rtc_ops = { | 579 | static struct rtc_class_ops sh_rtc_ops = { |
601 | .ioctl = sh_rtc_ioctl, | ||
602 | .read_time = sh_rtc_read_time, | 580 | .read_time = sh_rtc_read_time, |
603 | .set_time = sh_rtc_set_time, | 581 | .set_time = sh_rtc_set_time, |
604 | .read_alarm = sh_rtc_read_alarm, | 582 | .read_alarm = sh_rtc_read_alarm, |
605 | .set_alarm = sh_rtc_set_alarm, | 583 | .set_alarm = sh_rtc_set_alarm, |
606 | .irq_set_state = sh_rtc_irq_set_state, | ||
607 | .irq_set_freq = sh_rtc_irq_set_freq, | ||
608 | .proc = sh_rtc_proc, | 584 | .proc = sh_rtc_proc, |
609 | .alarm_irq_enable = sh_rtc_alarm_irq_enable, | 585 | .alarm_irq_enable = sh_rtc_alarm_irq_enable, |
610 | }; | 586 | }; |
@@ -806,11 +782,11 @@ static void sh_rtc_set_irq_wake(struct device *dev, int enabled) | |||
806 | struct platform_device *pdev = to_platform_device(dev); | 782 | struct platform_device *pdev = to_platform_device(dev); |
807 | struct sh_rtc *rtc = platform_get_drvdata(pdev); | 783 | struct sh_rtc *rtc = platform_get_drvdata(pdev); |
808 | 784 | ||
809 | set_irq_wake(rtc->periodic_irq, enabled); | 785 | irq_set_irq_wake(rtc->periodic_irq, enabled); |
810 | 786 | ||
811 | if (rtc->carry_irq > 0) { | 787 | if (rtc->carry_irq > 0) { |
812 | set_irq_wake(rtc->carry_irq, enabled); | 788 | irq_set_irq_wake(rtc->carry_irq, enabled); |
813 | set_irq_wake(rtc->alarm_irq, enabled); | 789 | irq_set_irq_wake(rtc->alarm_irq, enabled); |
814 | } | 790 | } |
815 | } | 791 | } |
816 | 792 | ||
diff --git a/drivers/rtc/rtc-stmp3xxx.c b/drivers/rtc/rtc-stmp3xxx.c index 7e7d0c806f2d..572e9534b591 100644 --- a/drivers/rtc/rtc-stmp3xxx.c +++ b/drivers/rtc/rtc-stmp3xxx.c | |||
@@ -115,19 +115,6 @@ static int stmp3xxx_alarm_irq_enable(struct device *dev, unsigned int enabled) | |||
115 | return 0; | 115 | return 0; |
116 | } | 116 | } |
117 | 117 | ||
118 | static int stmp3xxx_update_irq_enable(struct device *dev, unsigned int enabled) | ||
119 | { | ||
120 | struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev); | ||
121 | |||
122 | if (enabled) | ||
123 | stmp3xxx_setl(BM_RTC_CTRL_ONEMSEC_IRQ_EN, | ||
124 | rtc_data->io + HW_RTC_CTRL); | ||
125 | else | ||
126 | stmp3xxx_clearl(BM_RTC_CTRL_ONEMSEC_IRQ_EN, | ||
127 | rtc_data->io + HW_RTC_CTRL); | ||
128 | return 0; | ||
129 | } | ||
130 | |||
131 | static int stmp3xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm) | 118 | static int stmp3xxx_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alm) |
132 | { | 119 | { |
133 | struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev); | 120 | struct stmp3xxx_rtc_data *rtc_data = dev_get_drvdata(dev); |
@@ -149,8 +136,6 @@ static int stmp3xxx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alm) | |||
149 | static struct rtc_class_ops stmp3xxx_rtc_ops = { | 136 | static struct rtc_class_ops stmp3xxx_rtc_ops = { |
150 | .alarm_irq_enable = | 137 | .alarm_irq_enable = |
151 | stmp3xxx_alarm_irq_enable, | 138 | stmp3xxx_alarm_irq_enable, |
152 | .update_irq_enable = | ||
153 | stmp3xxx_update_irq_enable, | ||
154 | .read_time = stmp3xxx_rtc_gettime, | 139 | .read_time = stmp3xxx_rtc_gettime, |
155 | .set_mmss = stmp3xxx_rtc_set_mmss, | 140 | .set_mmss = stmp3xxx_rtc_set_mmss, |
156 | .read_alarm = stmp3xxx_rtc_read_alarm, | 141 | .read_alarm = stmp3xxx_rtc_read_alarm, |
diff --git a/drivers/rtc/rtc-tegra.c b/drivers/rtc/rtc-tegra.c new file mode 100644 index 000000000000..2fc31aac3f4e --- /dev/null +++ b/drivers/rtc/rtc-tegra.c | |||
@@ -0,0 +1,488 @@ | |||
1 | /* | ||
2 | * An RTC driver for the NVIDIA Tegra 200 series internal RTC. | ||
3 | * | ||
4 | * Copyright (c) 2010, NVIDIA Corporation. | ||
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 as published by | ||
8 | * the Free Software Foundation; either version 2 of the License, or | ||
9 | * (at your option) any later version. | ||
10 | * | ||
11 | * This program is distributed in the hope that it will be useful, but WITHOUT | ||
12 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
13 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for | ||
14 | * more details. | ||
15 | * | ||
16 | * You should have received a copy of the GNU General Public License along | ||
17 | * with this program; if not, write to the Free Software Foundation, Inc., | ||
18 | * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | ||
19 | */ | ||
20 | #include <linux/kernel.h> | ||
21 | #include <linux/init.h> | ||
22 | #include <linux/module.h> | ||
23 | #include <linux/slab.h> | ||
24 | #include <linux/irq.h> | ||
25 | #include <linux/io.h> | ||
26 | #include <linux/delay.h> | ||
27 | #include <linux/rtc.h> | ||
28 | #include <linux/platform_device.h> | ||
29 | |||
30 | /* set to 1 = busy every eight 32kHz clocks during copy of sec+msec to AHB */ | ||
31 | #define TEGRA_RTC_REG_BUSY 0x004 | ||
32 | #define TEGRA_RTC_REG_SECONDS 0x008 | ||
33 | /* when msec is read, the seconds are buffered into shadow seconds. */ | ||
34 | #define TEGRA_RTC_REG_SHADOW_SECONDS 0x00c | ||
35 | #define TEGRA_RTC_REG_MILLI_SECONDS 0x010 | ||
36 | #define TEGRA_RTC_REG_SECONDS_ALARM0 0x014 | ||
37 | #define TEGRA_RTC_REG_SECONDS_ALARM1 0x018 | ||
38 | #define TEGRA_RTC_REG_MILLI_SECONDS_ALARM0 0x01c | ||
39 | #define TEGRA_RTC_REG_INTR_MASK 0x028 | ||
40 | /* write 1 bits to clear status bits */ | ||
41 | #define TEGRA_RTC_REG_INTR_STATUS 0x02c | ||
42 | |||
43 | /* bits in INTR_MASK */ | ||
44 | #define TEGRA_RTC_INTR_MASK_MSEC_CDN_ALARM (1<<4) | ||
45 | #define TEGRA_RTC_INTR_MASK_SEC_CDN_ALARM (1<<3) | ||
46 | #define TEGRA_RTC_INTR_MASK_MSEC_ALARM (1<<2) | ||
47 | #define TEGRA_RTC_INTR_MASK_SEC_ALARM1 (1<<1) | ||
48 | #define TEGRA_RTC_INTR_MASK_SEC_ALARM0 (1<<0) | ||
49 | |||
50 | /* bits in INTR_STATUS */ | ||
51 | #define TEGRA_RTC_INTR_STATUS_MSEC_CDN_ALARM (1<<4) | ||
52 | #define TEGRA_RTC_INTR_STATUS_SEC_CDN_ALARM (1<<3) | ||
53 | #define TEGRA_RTC_INTR_STATUS_MSEC_ALARM (1<<2) | ||
54 | #define TEGRA_RTC_INTR_STATUS_SEC_ALARM1 (1<<1) | ||
55 | #define TEGRA_RTC_INTR_STATUS_SEC_ALARM0 (1<<0) | ||
56 | |||
57 | struct tegra_rtc_info { | ||
58 | struct platform_device *pdev; | ||
59 | struct rtc_device *rtc_dev; | ||
60 | void __iomem *rtc_base; /* NULL if not initialized. */ | ||
61 | int tegra_rtc_irq; /* alarm and periodic irq */ | ||
62 | spinlock_t tegra_rtc_lock; | ||
63 | }; | ||
64 | |||
65 | /* RTC hardware is busy when it is updating its values over AHB once | ||
66 | * every eight 32kHz clocks (~250uS). | ||
67 | * outside of these updates the CPU is free to write. | ||
68 | * CPU is always free to read. | ||
69 | */ | ||
70 | static inline u32 tegra_rtc_check_busy(struct tegra_rtc_info *info) | ||
71 | { | ||
72 | return readl(info->rtc_base + TEGRA_RTC_REG_BUSY) & 1; | ||
73 | } | ||
74 | |||
75 | /* Wait for hardware to be ready for writing. | ||
76 | * This function tries to maximize the amount of time before the next update. | ||
77 | * It does this by waiting for the RTC to become busy with its periodic update, | ||
78 | * then returning once the RTC first becomes not busy. | ||
79 | * This periodic update (where the seconds and milliseconds are copied to the | ||
80 | * AHB side) occurs every eight 32kHz clocks (~250uS). | ||
81 | * The behavior of this function allows us to make some assumptions without | ||
82 | * introducing a race, because 250uS is plenty of time to read/write a value. | ||
83 | */ | ||
84 | static int tegra_rtc_wait_while_busy(struct device *dev) | ||
85 | { | ||
86 | struct tegra_rtc_info *info = dev_get_drvdata(dev); | ||
87 | |||
88 | int retries = 500; /* ~490 us is the worst case, ~250 us is best. */ | ||
89 | |||
90 | /* first wait for the RTC to become busy. this is when it | ||
91 | * posts its updated seconds+msec registers to AHB side. */ | ||
92 | while (tegra_rtc_check_busy(info)) { | ||
93 | if (!retries--) | ||
94 | goto retry_failed; | ||
95 | udelay(1); | ||
96 | } | ||
97 | |||
98 | /* now we have about 250 us to manipulate registers */ | ||
99 | return 0; | ||
100 | |||
101 | retry_failed: | ||
102 | dev_err(dev, "write failed:retry count exceeded.\n"); | ||
103 | return -ETIMEDOUT; | ||
104 | } | ||
105 | |||
106 | static int tegra_rtc_read_time(struct device *dev, struct rtc_time *tm) | ||
107 | { | ||
108 | struct tegra_rtc_info *info = dev_get_drvdata(dev); | ||
109 | unsigned long sec, msec; | ||
110 | unsigned long sl_irq_flags; | ||
111 | |||
112 | /* RTC hardware copies seconds to shadow seconds when a read | ||
113 | * of milliseconds occurs. use a lock to keep other threads out. */ | ||
114 | spin_lock_irqsave(&info->tegra_rtc_lock, sl_irq_flags); | ||
115 | |||
116 | msec = readl(info->rtc_base + TEGRA_RTC_REG_MILLI_SECONDS); | ||
117 | sec = readl(info->rtc_base + TEGRA_RTC_REG_SHADOW_SECONDS); | ||
118 | |||
119 | spin_unlock_irqrestore(&info->tegra_rtc_lock, sl_irq_flags); | ||
120 | |||
121 | rtc_time_to_tm(sec, tm); | ||
122 | |||
123 | dev_vdbg(dev, "time read as %lu. %d/%d/%d %d:%02u:%02u\n", | ||
124 | sec, | ||
125 | tm->tm_mon + 1, | ||
126 | tm->tm_mday, | ||
127 | tm->tm_year + 1900, | ||
128 | tm->tm_hour, | ||
129 | tm->tm_min, | ||
130 | tm->tm_sec | ||
131 | ); | ||
132 | |||
133 | return 0; | ||
134 | } | ||
135 | |||
136 | static int tegra_rtc_set_time(struct device *dev, struct rtc_time *tm) | ||
137 | { | ||
138 | struct tegra_rtc_info *info = dev_get_drvdata(dev); | ||
139 | unsigned long sec; | ||
140 | int ret; | ||
141 | |||
142 | /* convert tm to seconds. */ | ||
143 | ret = rtc_valid_tm(tm); | ||
144 | if (ret) | ||
145 | return ret; | ||
146 | |||
147 | rtc_tm_to_time(tm, &sec); | ||
148 | |||
149 | dev_vdbg(dev, "time set to %lu. %d/%d/%d %d:%02u:%02u\n", | ||
150 | sec, | ||
151 | tm->tm_mon+1, | ||
152 | tm->tm_mday, | ||
153 | tm->tm_year+1900, | ||
154 | tm->tm_hour, | ||
155 | tm->tm_min, | ||
156 | tm->tm_sec | ||
157 | ); | ||
158 | |||
159 | /* seconds only written if wait succeeded. */ | ||
160 | ret = tegra_rtc_wait_while_busy(dev); | ||
161 | if (!ret) | ||
162 | writel(sec, info->rtc_base + TEGRA_RTC_REG_SECONDS); | ||
163 | |||
164 | dev_vdbg(dev, "time read back as %d\n", | ||
165 | readl(info->rtc_base + TEGRA_RTC_REG_SECONDS)); | ||
166 | |||
167 | return ret; | ||
168 | } | ||
169 | |||
170 | static int tegra_rtc_read_alarm(struct device *dev, struct rtc_wkalrm *alarm) | ||
171 | { | ||
172 | struct tegra_rtc_info *info = dev_get_drvdata(dev); | ||
173 | unsigned long sec; | ||
174 | unsigned tmp; | ||
175 | |||
176 | sec = readl(info->rtc_base + TEGRA_RTC_REG_SECONDS_ALARM0); | ||
177 | |||
178 | if (sec == 0) { | ||
179 | /* alarm is disabled. */ | ||
180 | alarm->enabled = 0; | ||
181 | alarm->time.tm_mon = -1; | ||
182 | alarm->time.tm_mday = -1; | ||
183 | alarm->time.tm_year = -1; | ||
184 | alarm->time.tm_hour = -1; | ||
185 | alarm->time.tm_min = -1; | ||
186 | alarm->time.tm_sec = -1; | ||
187 | } else { | ||
188 | /* alarm is enabled. */ | ||
189 | alarm->enabled = 1; | ||
190 | rtc_time_to_tm(sec, &alarm->time); | ||
191 | } | ||
192 | |||
193 | tmp = readl(info->rtc_base + TEGRA_RTC_REG_INTR_STATUS); | ||
194 | alarm->pending = (tmp & TEGRA_RTC_INTR_STATUS_SEC_ALARM0) != 0; | ||
195 | |||
196 | return 0; | ||
197 | } | ||
198 | |||
199 | static int tegra_rtc_alarm_irq_enable(struct device *dev, unsigned int enabled) | ||
200 | { | ||
201 | struct tegra_rtc_info *info = dev_get_drvdata(dev); | ||
202 | unsigned status; | ||
203 | unsigned long sl_irq_flags; | ||
204 | |||
205 | tegra_rtc_wait_while_busy(dev); | ||
206 | spin_lock_irqsave(&info->tegra_rtc_lock, sl_irq_flags); | ||
207 | |||
208 | /* read the original value, and OR in the flag. */ | ||
209 | status = readl(info->rtc_base + TEGRA_RTC_REG_INTR_MASK); | ||
210 | if (enabled) | ||
211 | status |= TEGRA_RTC_INTR_MASK_SEC_ALARM0; /* set it */ | ||
212 | else | ||
213 | status &= ~TEGRA_RTC_INTR_MASK_SEC_ALARM0; /* clear it */ | ||
214 | |||
215 | writel(status, info->rtc_base + TEGRA_RTC_REG_INTR_MASK); | ||
216 | |||
217 | spin_unlock_irqrestore(&info->tegra_rtc_lock, sl_irq_flags); | ||
218 | |||
219 | return 0; | ||
220 | } | ||
221 | |||
222 | static int tegra_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *alarm) | ||
223 | { | ||
224 | struct tegra_rtc_info *info = dev_get_drvdata(dev); | ||
225 | unsigned long sec; | ||
226 | |||
227 | if (alarm->enabled) | ||
228 | rtc_tm_to_time(&alarm->time, &sec); | ||
229 | else | ||
230 | sec = 0; | ||
231 | |||
232 | tegra_rtc_wait_while_busy(dev); | ||
233 | writel(sec, info->rtc_base + TEGRA_RTC_REG_SECONDS_ALARM0); | ||
234 | dev_vdbg(dev, "alarm read back as %d\n", | ||
235 | readl(info->rtc_base + TEGRA_RTC_REG_SECONDS_ALARM0)); | ||
236 | |||
237 | /* if successfully written and alarm is enabled ... */ | ||
238 | if (sec) { | ||
239 | tegra_rtc_alarm_irq_enable(dev, 1); | ||
240 | |||
241 | dev_vdbg(dev, "alarm set as %lu. %d/%d/%d %d:%02u:%02u\n", | ||
242 | sec, | ||
243 | alarm->time.tm_mon+1, | ||
244 | alarm->time.tm_mday, | ||
245 | alarm->time.tm_year+1900, | ||
246 | alarm->time.tm_hour, | ||
247 | alarm->time.tm_min, | ||
248 | alarm->time.tm_sec); | ||
249 | } else { | ||
250 | /* disable alarm if 0 or write error. */ | ||
251 | dev_vdbg(dev, "alarm disabled\n"); | ||
252 | tegra_rtc_alarm_irq_enable(dev, 0); | ||
253 | } | ||
254 | |||
255 | return 0; | ||
256 | } | ||
257 | |||
258 | static int tegra_rtc_proc(struct device *dev, struct seq_file *seq) | ||
259 | { | ||
260 | if (!dev || !dev->driver) | ||
261 | return 0; | ||
262 | |||
263 | return seq_printf(seq, "name\t\t: %s\n", dev_name(dev)); | ||
264 | } | ||
265 | |||
266 | static irqreturn_t tegra_rtc_irq_handler(int irq, void *data) | ||
267 | { | ||
268 | struct device *dev = data; | ||
269 | struct tegra_rtc_info *info = dev_get_drvdata(dev); | ||
270 | unsigned long events = 0; | ||
271 | unsigned status; | ||
272 | unsigned long sl_irq_flags; | ||
273 | |||
274 | status = readl(info->rtc_base + TEGRA_RTC_REG_INTR_STATUS); | ||
275 | if (status) { | ||
276 | /* clear the interrupt masks and status on any irq. */ | ||
277 | tegra_rtc_wait_while_busy(dev); | ||
278 | spin_lock_irqsave(&info->tegra_rtc_lock, sl_irq_flags); | ||
279 | writel(0, info->rtc_base + TEGRA_RTC_REG_INTR_MASK); | ||
280 | writel(status, info->rtc_base + TEGRA_RTC_REG_INTR_STATUS); | ||
281 | spin_unlock_irqrestore(&info->tegra_rtc_lock, sl_irq_flags); | ||
282 | } | ||
283 | |||
284 | /* check if Alarm */ | ||
285 | if ((status & TEGRA_RTC_INTR_STATUS_SEC_ALARM0)) | ||
286 | events |= RTC_IRQF | RTC_AF; | ||
287 | |||
288 | /* check if Periodic */ | ||
289 | if ((status & TEGRA_RTC_INTR_STATUS_SEC_CDN_ALARM)) | ||
290 | events |= RTC_IRQF | RTC_PF; | ||
291 | |||
292 | rtc_update_irq(info->rtc_dev, 1, events); | ||
293 | |||
294 | return IRQ_HANDLED; | ||
295 | } | ||
296 | |||
297 | static struct rtc_class_ops tegra_rtc_ops = { | ||
298 | .read_time = tegra_rtc_read_time, | ||
299 | .set_time = tegra_rtc_set_time, | ||
300 | .read_alarm = tegra_rtc_read_alarm, | ||
301 | .set_alarm = tegra_rtc_set_alarm, | ||
302 | .proc = tegra_rtc_proc, | ||
303 | .alarm_irq_enable = tegra_rtc_alarm_irq_enable, | ||
304 | }; | ||
305 | |||
306 | static int __devinit tegra_rtc_probe(struct platform_device *pdev) | ||
307 | { | ||
308 | struct tegra_rtc_info *info; | ||
309 | struct resource *res; | ||
310 | int ret; | ||
311 | |||
312 | info = kzalloc(sizeof(struct tegra_rtc_info), GFP_KERNEL); | ||
313 | if (!info) | ||
314 | return -ENOMEM; | ||
315 | |||
316 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
317 | if (!res) { | ||
318 | dev_err(&pdev->dev, | ||
319 | "Unable to allocate resources for device.\n"); | ||
320 | ret = -EBUSY; | ||
321 | goto err_free_info; | ||
322 | } | ||
323 | |||
324 | if (!request_mem_region(res->start, resource_size(res), pdev->name)) { | ||
325 | dev_err(&pdev->dev, | ||
326 | "Unable to request mem region for device.\n"); | ||
327 | ret = -EBUSY; | ||
328 | goto err_free_info; | ||
329 | } | ||
330 | |||
331 | info->tegra_rtc_irq = platform_get_irq(pdev, 0); | ||
332 | if (info->tegra_rtc_irq <= 0) { | ||
333 | ret = -EBUSY; | ||
334 | goto err_release_mem_region; | ||
335 | } | ||
336 | |||
337 | info->rtc_base = ioremap_nocache(res->start, resource_size(res)); | ||
338 | if (!info->rtc_base) { | ||
339 | dev_err(&pdev->dev, "Unable to grab IOs for device.\n"); | ||
340 | ret = -EBUSY; | ||
341 | goto err_release_mem_region; | ||
342 | } | ||
343 | |||
344 | /* set context info. */ | ||
345 | info->pdev = pdev; | ||
346 | info->tegra_rtc_lock = __SPIN_LOCK_UNLOCKED(info->tegra_rtc_lock); | ||
347 | |||
348 | platform_set_drvdata(pdev, info); | ||
349 | |||
350 | /* clear out the hardware. */ | ||
351 | writel(0, info->rtc_base + TEGRA_RTC_REG_SECONDS_ALARM0); | ||
352 | writel(0xffffffff, info->rtc_base + TEGRA_RTC_REG_INTR_STATUS); | ||
353 | writel(0, info->rtc_base + TEGRA_RTC_REG_INTR_MASK); | ||
354 | |||
355 | device_init_wakeup(&pdev->dev, 1); | ||
356 | |||
357 | info->rtc_dev = rtc_device_register( | ||
358 | pdev->name, &pdev->dev, &tegra_rtc_ops, THIS_MODULE); | ||
359 | if (IS_ERR(info->rtc_dev)) { | ||
360 | ret = PTR_ERR(info->rtc_dev); | ||
361 | info->rtc_dev = NULL; | ||
362 | dev_err(&pdev->dev, | ||
363 | "Unable to register device (err=%d).\n", | ||
364 | ret); | ||
365 | goto err_iounmap; | ||
366 | } | ||
367 | |||
368 | ret = request_irq(info->tegra_rtc_irq, tegra_rtc_irq_handler, | ||
369 | IRQF_TRIGGER_HIGH, "rtc alarm", &pdev->dev); | ||
370 | if (ret) { | ||
371 | dev_err(&pdev->dev, | ||
372 | "Unable to request interrupt for device (err=%d).\n", | ||
373 | ret); | ||
374 | goto err_dev_unreg; | ||
375 | } | ||
376 | |||
377 | dev_notice(&pdev->dev, "Tegra internal Real Time Clock\n"); | ||
378 | |||
379 | return 0; | ||
380 | |||
381 | err_dev_unreg: | ||
382 | rtc_device_unregister(info->rtc_dev); | ||
383 | err_iounmap: | ||
384 | iounmap(info->rtc_base); | ||
385 | err_release_mem_region: | ||
386 | release_mem_region(res->start, resource_size(res)); | ||
387 | err_free_info: | ||
388 | kfree(info); | ||
389 | |||
390 | return ret; | ||
391 | } | ||
392 | |||
393 | static int __devexit tegra_rtc_remove(struct platform_device *pdev) | ||
394 | { | ||
395 | struct tegra_rtc_info *info = platform_get_drvdata(pdev); | ||
396 | struct resource *res; | ||
397 | |||
398 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | ||
399 | if (!res) | ||
400 | return -EBUSY; | ||
401 | |||
402 | free_irq(info->tegra_rtc_irq, &pdev->dev); | ||
403 | rtc_device_unregister(info->rtc_dev); | ||
404 | iounmap(info->rtc_base); | ||
405 | release_mem_region(res->start, resource_size(res)); | ||
406 | kfree(info); | ||
407 | |||
408 | platform_set_drvdata(pdev, NULL); | ||
409 | |||
410 | return 0; | ||
411 | } | ||
412 | |||
413 | #ifdef CONFIG_PM | ||
414 | static int tegra_rtc_suspend(struct platform_device *pdev, pm_message_t state) | ||
415 | { | ||
416 | struct device *dev = &pdev->dev; | ||
417 | struct tegra_rtc_info *info = platform_get_drvdata(pdev); | ||
418 | |||
419 | tegra_rtc_wait_while_busy(dev); | ||
420 | |||
421 | /* only use ALARM0 as a wake source. */ | ||
422 | writel(0xffffffff, info->rtc_base + TEGRA_RTC_REG_INTR_STATUS); | ||
423 | writel(TEGRA_RTC_INTR_STATUS_SEC_ALARM0, | ||
424 | info->rtc_base + TEGRA_RTC_REG_INTR_MASK); | ||
425 | |||
426 | dev_vdbg(dev, "alarm sec = %d\n", | ||
427 | readl(info->rtc_base + TEGRA_RTC_REG_SECONDS_ALARM0)); | ||
428 | |||
429 | dev_vdbg(dev, "Suspend (device_may_wakeup=%d) irq:%d\n", | ||
430 | device_may_wakeup(dev), info->tegra_rtc_irq); | ||
431 | |||
432 | /* leave the alarms on as a wake source. */ | ||
433 | if (device_may_wakeup(dev)) | ||
434 | enable_irq_wake(info->tegra_rtc_irq); | ||
435 | |||
436 | return 0; | ||
437 | } | ||
438 | |||
439 | static int tegra_rtc_resume(struct platform_device *pdev) | ||
440 | { | ||
441 | struct device *dev = &pdev->dev; | ||
442 | struct tegra_rtc_info *info = platform_get_drvdata(pdev); | ||
443 | |||
444 | dev_vdbg(dev, "Resume (device_may_wakeup=%d)\n", | ||
445 | device_may_wakeup(dev)); | ||
446 | /* alarms were left on as a wake source, turn them off. */ | ||
447 | if (device_may_wakeup(dev)) | ||
448 | disable_irq_wake(info->tegra_rtc_irq); | ||
449 | |||
450 | return 0; | ||
451 | } | ||
452 | #endif | ||
453 | |||
454 | static void tegra_rtc_shutdown(struct platform_device *pdev) | ||
455 | { | ||
456 | dev_vdbg(&pdev->dev, "disabling interrupts.\n"); | ||
457 | tegra_rtc_alarm_irq_enable(&pdev->dev, 0); | ||
458 | } | ||
459 | |||
460 | MODULE_ALIAS("platform:tegra_rtc"); | ||
461 | static struct platform_driver tegra_rtc_driver = { | ||
462 | .remove = __devexit_p(tegra_rtc_remove), | ||
463 | .shutdown = tegra_rtc_shutdown, | ||
464 | .driver = { | ||
465 | .name = "tegra_rtc", | ||
466 | .owner = THIS_MODULE, | ||
467 | }, | ||
468 | #ifdef CONFIG_PM | ||
469 | .suspend = tegra_rtc_suspend, | ||
470 | .resume = tegra_rtc_resume, | ||
471 | #endif | ||
472 | }; | ||
473 | |||
474 | static int __init tegra_rtc_init(void) | ||
475 | { | ||
476 | return platform_driver_probe(&tegra_rtc_driver, tegra_rtc_probe); | ||
477 | } | ||
478 | module_init(tegra_rtc_init); | ||
479 | |||
480 | static void __exit tegra_rtc_exit(void) | ||
481 | { | ||
482 | platform_driver_unregister(&tegra_rtc_driver); | ||
483 | } | ||
484 | module_exit(tegra_rtc_exit); | ||
485 | |||
486 | MODULE_AUTHOR("Jon Mayo <jmayo@nvidia.com>"); | ||
487 | MODULE_DESCRIPTION("driver for Tegra internal RTC"); | ||
488 | MODULE_LICENSE("GPL"); | ||
diff --git a/drivers/rtc/rtc-test.c b/drivers/rtc/rtc-test.c index a82d6fe97076..7e96254bd365 100644 --- a/drivers/rtc/rtc-test.c +++ b/drivers/rtc/rtc-test.c | |||
@@ -78,11 +78,16 @@ static ssize_t test_irq_store(struct device *dev, | |||
78 | struct rtc_device *rtc = platform_get_drvdata(plat_dev); | 78 | struct rtc_device *rtc = platform_get_drvdata(plat_dev); |
79 | 79 | ||
80 | retval = count; | 80 | retval = count; |
81 | if (strncmp(buf, "tick", 4) == 0) | 81 | if (strncmp(buf, "tick", 4) == 0 && rtc->pie_enabled) |
82 | rtc_update_irq(rtc, 1, RTC_PF | RTC_IRQF); | 82 | rtc_update_irq(rtc, 1, RTC_PF | RTC_IRQF); |
83 | else if (strncmp(buf, "alarm", 5) == 0) | 83 | else if (strncmp(buf, "alarm", 5) == 0) { |
84 | rtc_update_irq(rtc, 1, RTC_AF | RTC_IRQF); | 84 | struct rtc_wkalrm alrm; |
85 | else if (strncmp(buf, "update", 6) == 0) | 85 | int err = rtc_read_alarm(rtc, &alrm); |
86 | |||
87 | if (!err && alrm.enabled) | ||
88 | rtc_update_irq(rtc, 1, RTC_AF | RTC_IRQF); | ||
89 | |||
90 | } else if (strncmp(buf, "update", 6) == 0 && rtc->uie_rtctimer.enabled) | ||
86 | rtc_update_irq(rtc, 1, RTC_UF | RTC_IRQF); | 91 | rtc_update_irq(rtc, 1, RTC_UF | RTC_IRQF); |
87 | else | 92 | else |
88 | retval = -EINVAL; | 93 | retval = -EINVAL; |
diff --git a/drivers/rtc/rtc-twl.c b/drivers/rtc/rtc-twl.c index ed1b86828124..f9a2799c44d6 100644 --- a/drivers/rtc/rtc-twl.c +++ b/drivers/rtc/rtc-twl.c | |||
@@ -213,18 +213,6 @@ static int twl_rtc_alarm_irq_enable(struct device *dev, unsigned enabled) | |||
213 | return ret; | 213 | return ret; |
214 | } | 214 | } |
215 | 215 | ||
216 | static int twl_rtc_update_irq_enable(struct device *dev, unsigned enabled) | ||
217 | { | ||
218 | int ret; | ||
219 | |||
220 | if (enabled) | ||
221 | ret = set_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_TIMER_M); | ||
222 | else | ||
223 | ret = mask_rtc_irq_bit(BIT_RTC_INTERRUPTS_REG_IT_TIMER_M); | ||
224 | |||
225 | return ret; | ||
226 | } | ||
227 | |||
228 | /* | 216 | /* |
229 | * Gets current TWL RTC time and date parameters. | 217 | * Gets current TWL RTC time and date parameters. |
230 | * | 218 | * |
@@ -433,7 +421,6 @@ static struct rtc_class_ops twl_rtc_ops = { | |||
433 | .read_alarm = twl_rtc_read_alarm, | 421 | .read_alarm = twl_rtc_read_alarm, |
434 | .set_alarm = twl_rtc_set_alarm, | 422 | .set_alarm = twl_rtc_set_alarm, |
435 | .alarm_irq_enable = twl_rtc_alarm_irq_enable, | 423 | .alarm_irq_enable = twl_rtc_alarm_irq_enable, |
436 | .update_irq_enable = twl_rtc_update_irq_enable, | ||
437 | }; | 424 | }; |
438 | 425 | ||
439 | /*----------------------------------------------------------------------*/ | 426 | /*----------------------------------------------------------------------*/ |
diff --git a/drivers/rtc/rtc-vr41xx.c b/drivers/rtc/rtc-vr41xx.c index 769190ac6d11..c5698cda366a 100644 --- a/drivers/rtc/rtc-vr41xx.c +++ b/drivers/rtc/rtc-vr41xx.c | |||
@@ -207,36 +207,6 @@ static int vr41xx_rtc_set_alarm(struct device *dev, struct rtc_wkalrm *wkalrm) | |||
207 | return 0; | 207 | return 0; |
208 | } | 208 | } |
209 | 209 | ||
210 | static int vr41xx_rtc_irq_set_freq(struct device *dev, int freq) | ||
211 | { | ||
212 | u64 count; | ||
213 | |||
214 | if (!is_power_of_2(freq)) | ||
215 | return -EINVAL; | ||
216 | count = RTC_FREQUENCY; | ||
217 | do_div(count, freq); | ||
218 | |||
219 | spin_lock_irq(&rtc_lock); | ||
220 | |||
221 | periodic_count = count; | ||
222 | rtc1_write(RTCL1LREG, periodic_count); | ||
223 | rtc1_write(RTCL1HREG, periodic_count >> 16); | ||
224 | |||
225 | spin_unlock_irq(&rtc_lock); | ||
226 | |||
227 | return 0; | ||
228 | } | ||
229 | |||
230 | static int vr41xx_rtc_irq_set_state(struct device *dev, int enabled) | ||
231 | { | ||
232 | if (enabled) | ||
233 | enable_irq(pie_irq); | ||
234 | else | ||
235 | disable_irq(pie_irq); | ||
236 | |||
237 | return 0; | ||
238 | } | ||
239 | |||
240 | static int vr41xx_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) | 210 | static int vr41xx_rtc_ioctl(struct device *dev, unsigned int cmd, unsigned long arg) |
241 | { | 211 | { |
242 | switch (cmd) { | 212 | switch (cmd) { |
@@ -308,8 +278,6 @@ static const struct rtc_class_ops vr41xx_rtc_ops = { | |||
308 | .set_time = vr41xx_rtc_set_time, | 278 | .set_time = vr41xx_rtc_set_time, |
309 | .read_alarm = vr41xx_rtc_read_alarm, | 279 | .read_alarm = vr41xx_rtc_read_alarm, |
310 | .set_alarm = vr41xx_rtc_set_alarm, | 280 | .set_alarm = vr41xx_rtc_set_alarm, |
311 | .irq_set_freq = vr41xx_rtc_irq_set_freq, | ||
312 | .irq_set_state = vr41xx_rtc_irq_set_state, | ||
313 | }; | 281 | }; |
314 | 282 | ||
315 | static int __devinit rtc_probe(struct platform_device *pdev) | 283 | static int __devinit rtc_probe(struct platform_device *pdev) |
diff --git a/drivers/rtc/rtc-wm831x.c b/drivers/rtc/rtc-wm831x.c index 82931dc65c0b..bdc909bd56da 100644 --- a/drivers/rtc/rtc-wm831x.c +++ b/drivers/rtc/rtc-wm831x.c | |||
@@ -315,21 +315,6 @@ static int wm831x_rtc_alarm_irq_enable(struct device *dev, | |||
315 | return wm831x_rtc_stop_alarm(wm831x_rtc); | 315 | return wm831x_rtc_stop_alarm(wm831x_rtc); |
316 | } | 316 | } |
317 | 317 | ||
318 | static int wm831x_rtc_update_irq_enable(struct device *dev, | ||
319 | unsigned int enabled) | ||
320 | { | ||
321 | struct wm831x_rtc *wm831x_rtc = dev_get_drvdata(dev); | ||
322 | int val; | ||
323 | |||
324 | if (enabled) | ||
325 | val = 1 << WM831X_RTC_PINT_FREQ_SHIFT; | ||
326 | else | ||
327 | val = 0; | ||
328 | |||
329 | return wm831x_set_bits(wm831x_rtc->wm831x, WM831X_RTC_CONTROL, | ||
330 | WM831X_RTC_PINT_FREQ_MASK, val); | ||
331 | } | ||
332 | |||
333 | static irqreturn_t wm831x_alm_irq(int irq, void *data) | 318 | static irqreturn_t wm831x_alm_irq(int irq, void *data) |
334 | { | 319 | { |
335 | struct wm831x_rtc *wm831x_rtc = data; | 320 | struct wm831x_rtc *wm831x_rtc = data; |
@@ -354,7 +339,6 @@ static const struct rtc_class_ops wm831x_rtc_ops = { | |||
354 | .read_alarm = wm831x_rtc_readalarm, | 339 | .read_alarm = wm831x_rtc_readalarm, |
355 | .set_alarm = wm831x_rtc_setalarm, | 340 | .set_alarm = wm831x_rtc_setalarm, |
356 | .alarm_irq_enable = wm831x_rtc_alarm_irq_enable, | 341 | .alarm_irq_enable = wm831x_rtc_alarm_irq_enable, |
357 | .update_irq_enable = wm831x_rtc_update_irq_enable, | ||
358 | }; | 342 | }; |
359 | 343 | ||
360 | #ifdef CONFIG_PM | 344 | #ifdef CONFIG_PM |
diff --git a/drivers/rtc/rtc-wm8350.c b/drivers/rtc/rtc-wm8350.c index 3d0dc76b38af..66421426e404 100644 --- a/drivers/rtc/rtc-wm8350.c +++ b/drivers/rtc/rtc-wm8350.c | |||
@@ -302,26 +302,6 @@ static int wm8350_rtc_setalarm(struct device *dev, struct rtc_wkalrm *alrm) | |||
302 | return ret; | 302 | return ret; |
303 | } | 303 | } |
304 | 304 | ||
305 | static int wm8350_rtc_update_irq_enable(struct device *dev, | ||
306 | unsigned int enabled) | ||
307 | { | ||
308 | struct wm8350 *wm8350 = dev_get_drvdata(dev); | ||
309 | |||
310 | /* Suppress duplicate changes since genirq nests enable and | ||
311 | * disable calls. */ | ||
312 | if (enabled == wm8350->rtc.update_enabled) | ||
313 | return 0; | ||
314 | |||
315 | if (enabled) | ||
316 | wm8350_unmask_irq(wm8350, WM8350_IRQ_RTC_SEC); | ||
317 | else | ||
318 | wm8350_mask_irq(wm8350, WM8350_IRQ_RTC_SEC); | ||
319 | |||
320 | wm8350->rtc.update_enabled = enabled; | ||
321 | |||
322 | return 0; | ||
323 | } | ||
324 | |||
325 | static irqreturn_t wm8350_rtc_alarm_handler(int irq, void *data) | 305 | static irqreturn_t wm8350_rtc_alarm_handler(int irq, void *data) |
326 | { | 306 | { |
327 | struct wm8350 *wm8350 = data; | 307 | struct wm8350 *wm8350 = data; |
@@ -357,7 +337,6 @@ static const struct rtc_class_ops wm8350_rtc_ops = { | |||
357 | .read_alarm = wm8350_rtc_readalarm, | 337 | .read_alarm = wm8350_rtc_readalarm, |
358 | .set_alarm = wm8350_rtc_setalarm, | 338 | .set_alarm = wm8350_rtc_setalarm, |
359 | .alarm_irq_enable = wm8350_rtc_alarm_irq_enable, | 339 | .alarm_irq_enable = wm8350_rtc_alarm_irq_enable, |
360 | .update_irq_enable = wm8350_rtc_update_irq_enable, | ||
361 | }; | 340 | }; |
362 | 341 | ||
363 | #ifdef CONFIG_PM | 342 | #ifdef CONFIG_PM |
diff --git a/drivers/rtc/rtc-x1205.c b/drivers/rtc/rtc-x1205.c index 9aae49139a0a..b00aad2620d4 100644 --- a/drivers/rtc/rtc-x1205.c +++ b/drivers/rtc/rtc-x1205.c | |||
@@ -573,7 +573,7 @@ static int x1205_probe(struct i2c_client *client, | |||
573 | 573 | ||
574 | i2c_set_clientdata(client, rtc); | 574 | i2c_set_clientdata(client, rtc); |
575 | 575 | ||
576 | /* Check for power failures and eventualy enable the osc */ | 576 | /* Check for power failures and eventually enable the osc */ |
577 | if ((err = x1205_get_status(client, &sr)) == 0) { | 577 | if ((err = x1205_get_status(client, &sr)) == 0) { |
578 | if (sr & X1205_SR_RTCF) { | 578 | if (sr & X1205_SR_RTCF) { |
579 | dev_err(&client->dev, | 579 | dev_err(&client->dev, |