diff options
author | Mark A. Greer <mgreer@mvista.com> | 2009-12-15 19:46:11 -0500 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2009-12-16 10:20:00 -0500 |
commit | 8cfde8c1df31724f881de1a37f878ccbba4f178f (patch) | |
tree | d5317c59d3fabac6c77812e56b9f29e275aea46a | |
parent | 43299f285937c907abcdd987c670c755194943cc (diff) |
rtc: make rtc-omap driver ioremap its register space
The rtc-omap driver currently assumes that the rtc's registers are at a
fixed address and already mapped into virtual memory space. Remove those
assumptions so the same driver can be used for similar devices that reside
at different physical addresses (e.g., TI's DA8xx/OMAP-L13x SoC's).
Also allow the possibility for the timer and alarm interrupts to use the
same IRQ.
Signed-off-by: Mark A. Greer <mgreer@mvista.com>
Acked-by: David Brownell <dbrownell@users.sourceforge.net>
Acked-by: Kevin Hilman <khilman@deeprootsystems.com>
Acked-by: Tony Lindgren <tony@atomide.com>
Signed-off-by: Alessandro Zummo <a.zummo@towertech.it>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
-rw-r--r-- | drivers/rtc/Kconfig | 7 | ||||
-rw-r--r-- | drivers/rtc/rtc-omap.c | 47 |
2 files changed, 30 insertions, 24 deletions
diff --git a/drivers/rtc/Kconfig b/drivers/rtc/Kconfig index 564f3d173b19..9930d79fa51f 100644 --- a/drivers/rtc/Kconfig +++ b/drivers/rtc/Kconfig | |||
@@ -597,10 +597,11 @@ comment "on-CPU RTC drivers" | |||
597 | 597 | ||
598 | config RTC_DRV_OMAP | 598 | config RTC_DRV_OMAP |
599 | tristate "TI OMAP1" | 599 | tristate "TI OMAP1" |
600 | depends on ARCH_OMAP15XX || ARCH_OMAP16XX || ARCH_OMAP730 | 600 | depends on ARCH_OMAP15XX || ARCH_OMAP16XX || ARCH_OMAP730 || ARCH_DAVINCI_DA8XX |
601 | help | 601 | help |
602 | Say "yes" here to support the real time clock on TI OMAP1 chips. | 602 | Say "yes" here to support the real time clock on TI OMAP1 and |
603 | This driver can also be built as a module called rtc-omap. | 603 | DA8xx/OMAP-L13x chips. This driver can also be built as a |
604 | module called rtc-omap. | ||
604 | 605 | ||
605 | config RTC_DRV_S3C | 606 | config RTC_DRV_S3C |
606 | tristate "Samsung S3C series SoC RTC" | 607 | tristate "Samsung S3C series SoC RTC" |
diff --git a/drivers/rtc/rtc-omap.c b/drivers/rtc/rtc-omap.c index 0587d53987fe..64d9727b7229 100644 --- a/drivers/rtc/rtc-omap.c +++ b/drivers/rtc/rtc-omap.c | |||
@@ -87,9 +87,10 @@ | |||
87 | #define OMAP_RTC_INTERRUPTS_IT_ALARM (1<<3) | 87 | #define OMAP_RTC_INTERRUPTS_IT_ALARM (1<<3) |
88 | #define OMAP_RTC_INTERRUPTS_IT_TIMER (1<<2) | 88 | #define OMAP_RTC_INTERRUPTS_IT_TIMER (1<<2) |
89 | 89 | ||
90 | static void __iomem *rtc_base; | ||
90 | 91 | ||
91 | #define rtc_read(addr) omap_readb(OMAP_RTC_BASE + (addr)) | 92 | #define rtc_read(addr) __raw_readb(rtc_base + (addr)) |
92 | #define rtc_write(val, addr) omap_writeb(val, OMAP_RTC_BASE + (addr)) | 93 | #define rtc_write(val, addr) __raw_writeb(val, rtc_base + (addr)) |
93 | 94 | ||
94 | 95 | ||
95 | /* we rely on the rtc framework to handle locking (rtc->ops_lock), | 96 | /* we rely on the rtc framework to handle locking (rtc->ops_lock), |
@@ -330,32 +331,31 @@ static int __init omap_rtc_probe(struct platform_device *pdev) | |||
330 | return -ENOENT; | 331 | return -ENOENT; |
331 | } | 332 | } |
332 | 333 | ||
333 | /* NOTE: using static mapping for RTC registers */ | ||
334 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); | 334 | res = platform_get_resource(pdev, IORESOURCE_MEM, 0); |
335 | if (res && res->start != OMAP_RTC_BASE) { | 335 | if (!res) { |
336 | pr_debug("%s: RTC registers at %08x, expected %08x\n", | 336 | pr_debug("%s: RTC resource data missing\n", pdev->name); |
337 | pdev->name, (unsigned) res->start, OMAP_RTC_BASE); | ||
338 | return -ENOENT; | 337 | return -ENOENT; |
339 | } | 338 | } |
340 | 339 | ||
341 | if (res) | 340 | mem = request_mem_region(res->start, resource_size(res), pdev->name); |
342 | mem = request_mem_region(res->start, | ||
343 | res->end - res->start + 1, | ||
344 | pdev->name); | ||
345 | else | ||
346 | mem = NULL; | ||
347 | if (!mem) { | 341 | if (!mem) { |
348 | pr_debug("%s: RTC registers at %08x are not free\n", | 342 | pr_debug("%s: RTC registers at %08x are not free\n", |
349 | pdev->name, OMAP_RTC_BASE); | 343 | pdev->name, res->start); |
350 | return -EBUSY; | 344 | return -EBUSY; |
351 | } | 345 | } |
352 | 346 | ||
347 | rtc_base = ioremap(res->start, resource_size(res)); | ||
348 | if (!rtc_base) { | ||
349 | pr_debug("%s: RTC registers can't be mapped\n", pdev->name); | ||
350 | goto fail; | ||
351 | } | ||
352 | |||
353 | rtc = rtc_device_register(pdev->name, &pdev->dev, | 353 | rtc = rtc_device_register(pdev->name, &pdev->dev, |
354 | &omap_rtc_ops, THIS_MODULE); | 354 | &omap_rtc_ops, THIS_MODULE); |
355 | if (IS_ERR(rtc)) { | 355 | if (IS_ERR(rtc)) { |
356 | pr_debug("%s: can't register RTC device, err %ld\n", | 356 | pr_debug("%s: can't register RTC device, err %ld\n", |
357 | pdev->name, PTR_ERR(rtc)); | 357 | pdev->name, PTR_ERR(rtc)); |
358 | goto fail; | 358 | goto fail0; |
359 | } | 359 | } |
360 | platform_set_drvdata(pdev, rtc); | 360 | platform_set_drvdata(pdev, rtc); |
361 | dev_set_drvdata(&rtc->dev, mem); | 361 | dev_set_drvdata(&rtc->dev, mem); |
@@ -380,13 +380,14 @@ static int __init omap_rtc_probe(struct platform_device *pdev) | |||
380 | dev_name(&rtc->dev), rtc)) { | 380 | dev_name(&rtc->dev), rtc)) { |
381 | pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n", | 381 | pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n", |
382 | pdev->name, omap_rtc_timer); | 382 | pdev->name, omap_rtc_timer); |
383 | goto fail0; | 383 | goto fail1; |
384 | } | 384 | } |
385 | if (request_irq(omap_rtc_alarm, rtc_irq, IRQF_DISABLED, | 385 | if ((omap_rtc_timer != omap_rtc_alarm) && |
386 | dev_name(&rtc->dev), rtc)) { | 386 | (request_irq(omap_rtc_alarm, rtc_irq, IRQF_DISABLED, |
387 | dev_name(&rtc->dev), rtc))) { | ||
387 | pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n", | 388 | pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n", |
388 | pdev->name, omap_rtc_alarm); | 389 | pdev->name, omap_rtc_alarm); |
389 | goto fail1; | 390 | goto fail2; |
390 | } | 391 | } |
391 | 392 | ||
392 | /* On boards with split power, RTC_ON_NOFF won't reset the RTC */ | 393 | /* On boards with split power, RTC_ON_NOFF won't reset the RTC */ |
@@ -419,10 +420,12 @@ static int __init omap_rtc_probe(struct platform_device *pdev) | |||
419 | 420 | ||
420 | return 0; | 421 | return 0; |
421 | 422 | ||
422 | fail1: | 423 | fail2: |
423 | free_irq(omap_rtc_timer, NULL); | 424 | free_irq(omap_rtc_timer, NULL); |
424 | fail0: | 425 | fail1: |
425 | rtc_device_unregister(rtc); | 426 | rtc_device_unregister(rtc); |
427 | fail0: | ||
428 | iounmap(rtc_base); | ||
426 | fail: | 429 | fail: |
427 | release_resource(mem); | 430 | release_resource(mem); |
428 | return -EIO; | 431 | return -EIO; |
@@ -438,7 +441,9 @@ static int __exit omap_rtc_remove(struct platform_device *pdev) | |||
438 | rtc_write(0, OMAP_RTC_INTERRUPTS_REG); | 441 | rtc_write(0, OMAP_RTC_INTERRUPTS_REG); |
439 | 442 | ||
440 | free_irq(omap_rtc_timer, rtc); | 443 | free_irq(omap_rtc_timer, rtc); |
441 | free_irq(omap_rtc_alarm, rtc); | 444 | |
445 | if (omap_rtc_timer != omap_rtc_alarm) | ||
446 | free_irq(omap_rtc_alarm, rtc); | ||
442 | 447 | ||
443 | release_resource(dev_get_drvdata(&rtc->dev)); | 448 | release_resource(dev_get_drvdata(&rtc->dev)); |
444 | rtc_device_unregister(rtc); | 449 | rtc_device_unregister(rtc); |