aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/rtc
diff options
context:
space:
mode:
authorJean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com>2012-02-15 08:24:46 -0500
committerNicolas Ferre <nicolas.ferre@atmel.com>2012-02-23 08:57:58 -0500
commitb3af8b49befdcc53cb5d89e57662c359bc0b6989 (patch)
tree7c53b06733ae3f00a4971b0a3e7f4deee83169d1 /drivers/rtc
parent4e9267f1b42b4f7b66214161b55f1f73365692cd (diff)
ARM: at91/rtc-at91sam9: pass the GPBR to use via resources
The GPBR registers are used for storing RTC values. The GPBR registers to use are now provided using standard resource entry. The array is filled in SoC specific code. rtc-at91sam9 RTT as RTC driver is modified to retrieve this information. Signed-off-by: Jean-Christophe PLAGNIOL-VILLARD <plagnioj@jcrosoft.com> [nicolas.ferre@atmel.com: rework resources assignment] Signed-off-by: Nicolas Ferre <nicolas.ferre@atmel.com> Reviewed-by: Ryan Mallon <rmallon@gmail.com>
Diffstat (limited to 'drivers/rtc')
-rw-r--r--drivers/rtc/rtc-at91sam9.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/drivers/rtc/rtc-at91sam9.c b/drivers/rtc/rtc-at91sam9.c
index 08b69fdf2a7e..729fb843a2fc 100644
--- a/drivers/rtc/rtc-at91sam9.c
+++ b/drivers/rtc/rtc-at91sam9.c
@@ -57,6 +57,7 @@ struct sam9_rtc {
57 void __iomem *rtt; 57 void __iomem *rtt;
58 struct rtc_device *rtcdev; 58 struct rtc_device *rtcdev;
59 u32 imr; 59 u32 imr;
60 void __iomem *gpbr;
60}; 61};
61 62
62#define rtt_readl(rtc, field) \ 63#define rtt_readl(rtc, field) \
@@ -65,9 +66,9 @@ struct sam9_rtc {
65 __raw_writel((val), (rtc)->rtt + AT91_RTT_ ## field) 66 __raw_writel((val), (rtc)->rtt + AT91_RTT_ ## field)
66 67
67#define gpbr_readl(rtc) \ 68#define gpbr_readl(rtc) \
68 at91_sys_read(AT91_GPBR + 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR) 69 __raw_readl((rtc)->gpbr)
69#define gpbr_writel(rtc, val) \ 70#define gpbr_writel(rtc, val) \
70 at91_sys_write(AT91_GPBR + 4 * CONFIG_RTC_DRV_AT91SAM9_GPBR, (val)) 71 __raw_writel((val), (rtc)->gpbr)
71 72
72/* 73/*
73 * Read current time and date in RTC 74 * Read current time and date in RTC
@@ -289,14 +290,17 @@ static const struct rtc_class_ops at91_rtc_ops = {
289 */ 290 */
290static int __devinit at91_rtc_probe(struct platform_device *pdev) 291static int __devinit at91_rtc_probe(struct platform_device *pdev)
291{ 292{
292 struct resource *r; 293 struct resource *r, *r_gpbr;
293 struct sam9_rtc *rtc; 294 struct sam9_rtc *rtc;
294 int ret; 295 int ret;
295 u32 mr; 296 u32 mr;
296 297
297 r = platform_get_resource(pdev, IORESOURCE_MEM, 0); 298 r = platform_get_resource(pdev, IORESOURCE_MEM, 0);
298 if (!r) 299 r_gpbr = platform_get_resource(pdev, IORESOURCE_MEM, 1);
300 if (!r || !r_gpbr) {
301 dev_err(&pdev->dev, "need 2 ressources\n");
299 return -ENODEV; 302 return -ENODEV;
303 }
300 304
301 rtc = kzalloc(sizeof *rtc, GFP_KERNEL); 305 rtc = kzalloc(sizeof *rtc, GFP_KERNEL);
302 if (!rtc) 306 if (!rtc)
@@ -314,6 +318,13 @@ static int __devinit at91_rtc_probe(struct platform_device *pdev)
314 goto fail; 318 goto fail;
315 } 319 }
316 320
321 rtc->gpbr = ioremap(r_gpbr->start, resource_size(r_gpbr));
322 if (!rtc->gpbr) {
323 dev_err(&pdev->dev, "failed to map gpbr registers, aborting.\n");
324 ret = -ENOMEM;
325 goto fail_gpbr;
326 }
327
317 mr = rtt_readl(rtc, MR); 328 mr = rtt_readl(rtc, MR);
318 329
319 /* unless RTT is counting at 1 Hz, re-initialize it */ 330 /* unless RTT is counting at 1 Hz, re-initialize it */
@@ -340,7 +351,7 @@ static int __devinit at91_rtc_probe(struct platform_device *pdev)
340 if (ret) { 351 if (ret) {
341 dev_dbg(&pdev->dev, "can't share IRQ %d?\n", AT91_ID_SYS); 352 dev_dbg(&pdev->dev, "can't share IRQ %d?\n", AT91_ID_SYS);
342 rtc_device_unregister(rtc->rtcdev); 353 rtc_device_unregister(rtc->rtcdev);
343 goto fail; 354 goto fail_register;
344 } 355 }
345 356
346 /* NOTE: sam9260 rev A silicon has a ROM bug which resets the 357 /* NOTE: sam9260 rev A silicon has a ROM bug which resets the
@@ -356,6 +367,8 @@ static int __devinit at91_rtc_probe(struct platform_device *pdev)
356 return 0; 367 return 0;
357 368
358fail_register: 369fail_register:
370 iounmap(rtc->gpbr);
371fail_gpbr:
359 iounmap(rtc->rtt); 372 iounmap(rtc->rtt);
360fail: 373fail:
361 platform_set_drvdata(pdev, NULL); 374 platform_set_drvdata(pdev, NULL);
@@ -377,6 +390,7 @@ static int __devexit at91_rtc_remove(struct platform_device *pdev)
377 390
378 rtc_device_unregister(rtc->rtcdev); 391 rtc_device_unregister(rtc->rtcdev);
379 392
393 iounmap(rtc->gpbr);
380 iounmap(rtc->rtt); 394 iounmap(rtc->rtt);
381 platform_set_drvdata(pdev, NULL); 395 platform_set_drvdata(pdev, NULL);
382 kfree(rtc); 396 kfree(rtc);