1 /* rtc-parisc: RTC for HP PA-RISC firmware
3 * Copyright (C) 2008 Kyle McMartin <kyle@mcmartin.ca>
6 #include <linux/kernel.h>
7 #include <linux/module.h>
8 #include <linux/time.h>
9 #include <linux/platform_device.h>
13 /* as simple as can be, and no simpler. */
15 struct rtc_device *rtc;
19 static int parisc_get_time(struct device *dev, struct rtc_time *tm)
21 struct parisc_rtc *p = dev_get_drvdata(dev);
22 unsigned long flags, ret;
24 spin_lock_irqsave(&p->lock, flags);
25 ret = get_rtc_time(tm);
26 spin_unlock_irqrestore(&p->lock, flags);
28 if (ret & RTC_BATT_BAD)
34 static int parisc_set_time(struct device *dev, struct rtc_time *tm)
36 struct parisc_rtc *p = dev_get_drvdata(dev);
37 unsigned long flags, ret;
39 spin_lock_irqsave(&p->lock, flags);
40 ret = set_rtc_time(tm);
41 spin_unlock_irqrestore(&p->lock, flags);
49 static const struct rtc_class_ops parisc_rtc_ops = {
50 .read_time = parisc_get_time,
51 .set_time = parisc_set_time,
54 static int __devinit parisc_rtc_probe(struct platform_device *dev)
58 p = kzalloc(sizeof (*p), GFP_KERNEL);
62 spin_lock_init(&p->lock);
64 p->rtc = rtc_device_register("rtc-parisc", &dev->dev, &parisc_rtc_ops,
67 int err = PTR_ERR(p->rtc);
72 platform_set_drvdata(dev, p);
77 static int __devexit parisc_rtc_remove(struct platform_device *dev)
79 struct parisc_rtc *p = platform_get_drvdata(dev);
81 rtc_device_unregister(p->rtc);
87 static struct platform_driver parisc_rtc_driver = {
92 .probe = parisc_rtc_probe,
93 .remove = __devexit_p(parisc_rtc_remove),
96 static int __init parisc_rtc_init(void)
98 return platform_driver_register(&parisc_rtc_driver);
101 static void __exit parisc_rtc_fini(void)
103 platform_driver_unregister(&parisc_rtc_driver);
106 module_init(parisc_rtc_init);
107 module_exit(parisc_rtc_fini);
109 MODULE_AUTHOR("Kyle McMartin <kyle@mcmartin.ca>");
110 MODULE_LICENSE("GPL");
111 MODULE_DESCRIPTION("HP PA-RISC RTC driver");