Commit 8cfde8c1 authored by Mark A. Greer's avatar Mark A. Greer Committed by Linus Torvalds

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: default avatarMark A. Greer <mgreer@mvista.com>
Acked-by: default avatarDavid Brownell <dbrownell@users.sourceforge.net>
Acked-by: default avatarKevin Hilman <khilman@deeprootsystems.com>
Acked-by: default avatarTony Lindgren <tony@atomide.com>
Signed-off-by: default avatarAlessandro Zummo <a.zummo@towertech.it>
Signed-off-by: default avatarAndrew Morton <akpm@linux-foundation.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@linux-foundation.org>
parent 43299f28
...@@ -597,10 +597,11 @@ comment "on-CPU RTC drivers" ...@@ -597,10 +597,11 @@ comment "on-CPU RTC drivers"
config RTC_DRV_OMAP config RTC_DRV_OMAP
tristate "TI OMAP1" tristate "TI OMAP1"
depends on ARCH_OMAP15XX || ARCH_OMAP16XX || ARCH_OMAP730 depends on ARCH_OMAP15XX || ARCH_OMAP16XX || ARCH_OMAP730 || ARCH_DAVINCI_DA8XX
help help
Say "yes" here to support the real time clock on TI OMAP1 chips. Say "yes" here to support the real time clock on TI OMAP1 and
This driver can also be built as a module called rtc-omap. DA8xx/OMAP-L13x chips. This driver can also be built as a
module called rtc-omap.
config RTC_DRV_S3C config RTC_DRV_S3C
tristate "Samsung S3C series SoC RTC" tristate "Samsung S3C series SoC RTC"
......
...@@ -87,9 +87,10 @@ ...@@ -87,9 +87,10 @@
#define OMAP_RTC_INTERRUPTS_IT_ALARM (1<<3) #define OMAP_RTC_INTERRUPTS_IT_ALARM (1<<3)
#define OMAP_RTC_INTERRUPTS_IT_TIMER (1<<2) #define OMAP_RTC_INTERRUPTS_IT_TIMER (1<<2)
static void __iomem *rtc_base;
#define rtc_read(addr) omap_readb(OMAP_RTC_BASE + (addr)) #define rtc_read(addr) __raw_readb(rtc_base + (addr))
#define rtc_write(val, addr) omap_writeb(val, OMAP_RTC_BASE + (addr)) #define rtc_write(val, addr) __raw_writeb(val, rtc_base + (addr))
/* we rely on the rtc framework to handle locking (rtc->ops_lock), /* 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,32 +331,31 @@ static int __init omap_rtc_probe(struct platform_device *pdev)
return -ENOENT; return -ENOENT;
} }
/* NOTE: using static mapping for RTC registers */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0); res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (res && res->start != OMAP_RTC_BASE) { if (!res) {
pr_debug("%s: RTC registers at %08x, expected %08x\n", pr_debug("%s: RTC resource data missing\n", pdev->name);
pdev->name, (unsigned) res->start, OMAP_RTC_BASE);
return -ENOENT; return -ENOENT;
} }
if (res) mem = request_mem_region(res->start, resource_size(res), pdev->name);
mem = request_mem_region(res->start,
res->end - res->start + 1,
pdev->name);
else
mem = NULL;
if (!mem) { if (!mem) {
pr_debug("%s: RTC registers at %08x are not free\n", pr_debug("%s: RTC registers at %08x are not free\n",
pdev->name, OMAP_RTC_BASE); pdev->name, res->start);
return -EBUSY; return -EBUSY;
} }
rtc_base = ioremap(res->start, resource_size(res));
if (!rtc_base) {
pr_debug("%s: RTC registers can't be mapped\n", pdev->name);
goto fail;
}
rtc = rtc_device_register(pdev->name, &pdev->dev, rtc = rtc_device_register(pdev->name, &pdev->dev,
&omap_rtc_ops, THIS_MODULE); &omap_rtc_ops, THIS_MODULE);
if (IS_ERR(rtc)) { if (IS_ERR(rtc)) {
pr_debug("%s: can't register RTC device, err %ld\n", pr_debug("%s: can't register RTC device, err %ld\n",
pdev->name, PTR_ERR(rtc)); pdev->name, PTR_ERR(rtc));
goto fail; goto fail0;
} }
platform_set_drvdata(pdev, rtc); platform_set_drvdata(pdev, rtc);
dev_set_drvdata(&rtc->dev, mem); dev_set_drvdata(&rtc->dev, mem);
...@@ -380,13 +380,14 @@ static int __init omap_rtc_probe(struct platform_device *pdev) ...@@ -380,13 +380,14 @@ static int __init omap_rtc_probe(struct platform_device *pdev)
dev_name(&rtc->dev), rtc)) { dev_name(&rtc->dev), rtc)) {
pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n", pr_debug("%s: RTC timer interrupt IRQ%d already claimed\n",
pdev->name, omap_rtc_timer); pdev->name, omap_rtc_timer);
goto fail0; goto fail1;
} }
if (request_irq(omap_rtc_alarm, rtc_irq, IRQF_DISABLED, if ((omap_rtc_timer != omap_rtc_alarm) &&
dev_name(&rtc->dev), rtc)) { (request_irq(omap_rtc_alarm, rtc_irq, IRQF_DISABLED,
dev_name(&rtc->dev), rtc))) {
pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n", pr_debug("%s: RTC alarm interrupt IRQ%d already claimed\n",
pdev->name, omap_rtc_alarm); pdev->name, omap_rtc_alarm);
goto fail1; goto fail2;
} }
/* On boards with split power, RTC_ON_NOFF won't reset the RTC */ /* 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,10 +420,12 @@ static int __init omap_rtc_probe(struct platform_device *pdev)
return 0; return 0;
fail1: fail2:
free_irq(omap_rtc_timer, NULL); free_irq(omap_rtc_timer, NULL);
fail0: fail1:
rtc_device_unregister(rtc); rtc_device_unregister(rtc);
fail0:
iounmap(rtc_base);
fail: fail:
release_resource(mem); release_resource(mem);
return -EIO; return -EIO;
...@@ -438,7 +441,9 @@ static int __exit omap_rtc_remove(struct platform_device *pdev) ...@@ -438,7 +441,9 @@ static int __exit omap_rtc_remove(struct platform_device *pdev)
rtc_write(0, OMAP_RTC_INTERRUPTS_REG); rtc_write(0, OMAP_RTC_INTERRUPTS_REG);
free_irq(omap_rtc_timer, rtc); free_irq(omap_rtc_timer, rtc);
free_irq(omap_rtc_alarm, rtc);
if (omap_rtc_timer != omap_rtc_alarm)
free_irq(omap_rtc_alarm, rtc);
release_resource(dev_get_drvdata(&rtc->dev)); release_resource(dev_get_drvdata(&rtc->dev));
rtc_device_unregister(rtc); rtc_device_unregister(rtc);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment