diff options
author | Johan Hovold <jhovold@gmail.com> | 2013-06-12 17:04:53 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2013-06-12 19:29:45 -0400 |
commit | de645475913f677eb024b3d2bd52e264e8106497 (patch) | |
tree | 616479fb03ec5c28a397192d039d18d97ab199a4 /drivers/rtc | |
parent | 558c61e5579a81551c0d6c2deaed1da3c7bf714a (diff) |
rtc-at91rm9200: add configuration support
Add configuration support which can be used to implement SoC-specific
workarounds for broken hardware.
Signed-off-by: Johan Hovold <jhovold@gmail.com>
Acked-by: Nicolas Ferre <nicolas.ferre@atmel.com>
Cc: Douglas Gilbert <dgilbert@interlog.com>
Cc: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>
Cc: Ludovic Desroches <ludovic.desroches@atmel.com>
Cc: Robert Nelson <Robert.Nelson@digikey.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'drivers/rtc')
-rw-r--r-- | drivers/rtc/rtc-at91rm9200.c | 46 |
1 files changed, 38 insertions, 8 deletions
diff --git a/drivers/rtc/rtc-at91rm9200.c b/drivers/rtc/rtc-at91rm9200.c index eeeb73f1fc3b..ab2024b159fa 100644 --- a/drivers/rtc/rtc-at91rm9200.c +++ b/drivers/rtc/rtc-at91rm9200.c | |||
@@ -42,6 +42,10 @@ | |||
42 | 42 | ||
43 | #define AT91_RTC_EPOCH 1900UL /* just like arch/arm/common/rtctime.c */ | 43 | #define AT91_RTC_EPOCH 1900UL /* just like arch/arm/common/rtctime.c */ |
44 | 44 | ||
45 | struct at91_rtc_config { | ||
46 | }; | ||
47 | |||
48 | static const struct at91_rtc_config *at91_rtc_config; | ||
45 | static DECLARE_COMPLETION(at91_rtc_updated); | 49 | static DECLARE_COMPLETION(at91_rtc_updated); |
46 | static unsigned int at91_alarm_year = AT91_RTC_EPOCH; | 50 | static unsigned int at91_alarm_year = AT91_RTC_EPOCH; |
47 | static void __iomem *at91_rtc_regs; | 51 | static void __iomem *at91_rtc_regs; |
@@ -250,6 +254,36 @@ static irqreturn_t at91_rtc_interrupt(int irq, void *dev_id) | |||
250 | return IRQ_NONE; /* not handled */ | 254 | return IRQ_NONE; /* not handled */ |
251 | } | 255 | } |
252 | 256 | ||
257 | static const struct at91_rtc_config at91rm9200_config = { | ||
258 | }; | ||
259 | |||
260 | #ifdef CONFIG_OF | ||
261 | static const struct of_device_id at91_rtc_dt_ids[] = { | ||
262 | { | ||
263 | .compatible = "atmel,at91rm9200-rtc", | ||
264 | .data = &at91rm9200_config, | ||
265 | }, { | ||
266 | /* sentinel */ | ||
267 | } | ||
268 | }; | ||
269 | MODULE_DEVICE_TABLE(of, at91_rtc_dt_ids); | ||
270 | #endif | ||
271 | |||
272 | static const struct at91_rtc_config * | ||
273 | at91_rtc_get_config(struct platform_device *pdev) | ||
274 | { | ||
275 | const struct of_device_id *match; | ||
276 | |||
277 | if (pdev->dev.of_node) { | ||
278 | match = of_match_node(at91_rtc_dt_ids, pdev->dev.of_node); | ||
279 | if (!match) | ||
280 | return NULL; | ||
281 | return (const struct at91_rtc_config *)match->data; | ||
282 | } | ||
283 | |||
284 | return &at91rm9200_config; | ||
285 | } | ||
286 | |||
253 | static const struct rtc_class_ops at91_rtc_ops = { | 287 | static const struct rtc_class_ops at91_rtc_ops = { |
254 | .read_time = at91_rtc_readtime, | 288 | .read_time = at91_rtc_readtime, |
255 | .set_time = at91_rtc_settime, | 289 | .set_time = at91_rtc_settime, |
@@ -268,6 +302,10 @@ static int __init at91_rtc_probe(struct platform_device *pdev) | |||
268 | struct resource *regs; | 302 | struct resource *regs; |
269 | int ret = 0; | 303 | int ret = 0; |
270 | 304 | ||
305 | at91_rtc_config = at91_rtc_get_config(pdev); | ||
306 | if (!at91_rtc_config) | ||
307 | return -ENODEV; | ||
308 | |||
271 | regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 309 | regs = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
272 | if (!regs) { | 310 | if (!regs) { |
273 | dev_err(&pdev->dev, "no mmio resource defined\n"); | 311 | dev_err(&pdev->dev, "no mmio resource defined\n"); |
@@ -383,14 +421,6 @@ static int at91_rtc_resume(struct device *dev) | |||
383 | 421 | ||
384 | static SIMPLE_DEV_PM_OPS(at91_rtc_pm_ops, at91_rtc_suspend, at91_rtc_resume); | 422 | static SIMPLE_DEV_PM_OPS(at91_rtc_pm_ops, at91_rtc_suspend, at91_rtc_resume); |
385 | 423 | ||
386 | #ifdef CONFIG_OF | ||
387 | static const struct of_device_id at91_rtc_dt_ids[] = { | ||
388 | { .compatible = "atmel,at91rm9200-rtc" }, | ||
389 | { /* sentinel */ } | ||
390 | }; | ||
391 | MODULE_DEVICE_TABLE(of, at91_rtc_dt_ids); | ||
392 | #endif | ||
393 | |||
394 | static struct platform_driver at91_rtc_driver = { | 424 | static struct platform_driver at91_rtc_driver = { |
395 | .remove = __exit_p(at91_rtc_remove), | 425 | .remove = __exit_p(at91_rtc_remove), |
396 | .driver = { | 426 | .driver = { |