*
*/
+#include <linux/init.h>
#include <linux/platform_device.h>
#include <linux/module.h>
#include <linux/rtc.h>
#include <linux/seq_file.h>
#include <linux/interrupt.h>
-
-#include <asm/io.h>
+#include <linux/io.h>
#define TIMER_FREQ CLOCK_TICK_RATE
#define RTC_DEF_DIVIDER (32768 - 1)
.irq_set_freq = pxa_periodic_irq_set_freq,
};
-static int __devinit pxa_rtc_probe(struct platform_device *pdev)
+static int __init pxa_rtc_probe(struct platform_device *pdev)
{
struct device *dev = &pdev->dev;
struct pxa_rtc *pxa_rtc;
int ret;
u32 rttr;
- ret = -ENOMEM;
pxa_rtc = kzalloc(sizeof(struct pxa_rtc), GFP_KERNEL);
if (!pxa_rtc)
- goto err_alloc;
+ return -ENOMEM;
+
+ spin_lock_init(&pxa_rtc->lock);
+ platform_set_drvdata(pdev, pxa_rtc);
ret = -ENXIO;
pxa_rtc->ress = platform_get_resource(pdev, IORESOURCE_MEM, 0);
goto err_ress;
}
- pxa_rtc->rtc = rtc_device_register(pdev->name, &pdev->dev, &pxa_rtc_ops,
- THIS_MODULE);
- ret = PTR_ERR(pxa_rtc->rtc);
- if (IS_ERR(pxa_rtc->rtc)) {
- dev_err(dev, "Failed to register RTC device -> %d\n", ret);
- goto err_rtc_reg;
- }
-
- spin_lock_init(&pxa_rtc->lock);
- platform_set_drvdata(pdev, pxa_rtc);
-
ret = -ENOMEM;
pxa_rtc->base = ioremap(pxa_rtc->ress->start,
- pxa_rtc->ress->end - pxa_rtc->ress->start + 1);
+ resource_size(pxa_rtc->ress));
if (!pxa_rtc->base) {
dev_err(&pdev->dev, "Unable to map pxa RTC I/O memory\n");
goto err_map;
}
rtsr_clear_bits(pxa_rtc, RTSR_PIALE | RTSR_RDALE1 | RTSR_HZE);
+
+ pxa_rtc->rtc = rtc_device_register("pxa-rtc", &pdev->dev, &pxa_rtc_ops,
+ THIS_MODULE);
+ ret = PTR_ERR(pxa_rtc->rtc);
+ if (IS_ERR(pxa_rtc->rtc)) {
+ dev_err(dev, "Failed to register RTC device -> %d\n", ret);
+ goto err_rtc_reg;
+ }
+
device_init_wakeup(dev, 1);
return 0;
-err_map:
- platform_set_drvdata(pdev, NULL);
- rtc_device_unregister(pxa_rtc->rtc);
err_rtc_reg:
+ iounmap(pxa_rtc->base);
err_ress:
+err_map:
kfree(pxa_rtc);
-err_alloc:
return ret;
}
-static int __devexit pxa_rtc_remove(struct platform_device *pdev)
+static int __exit pxa_rtc_remove(struct platform_device *pdev)
{
struct pxa_rtc *pxa_rtc = platform_get_drvdata(pdev);
+ rtc_device_unregister(pxa_rtc->rtc);
+
spin_lock_irq(&pxa_rtc->lock);
iounmap(pxa_rtc->base);
- pxa_rtc->base = NULL;
- platform_set_drvdata(pdev, NULL);
spin_unlock_irq(&pxa_rtc->lock);
- rtc_device_unregister(pxa_rtc->rtc);
kfree(pxa_rtc);
return 0;
#endif
static struct platform_driver pxa_rtc_driver = {
- .probe = pxa_rtc_probe,
.remove = __exit_p(pxa_rtc_remove),
.suspend = pxa_rtc_suspend,
.resume = pxa_rtc_resume,
static int __init pxa_rtc_init(void)
{
if (cpu_is_pxa27x() || cpu_is_pxa3xx())
- return platform_driver_register(&pxa_rtc_driver);
+ return platform_driver_probe(&pxa_rtc_driver, pxa_rtc_probe);
return -ENODEV;
}