Commit 9eb16864 authored by Kyle McMartin's avatar Kyle McMartin Committed by Kyle McMartin

parisc: add rtc platform driver

Signed-off-by: default avatarKyle McMartin <kyle@mcmartin.ca>
parent f0514ae3
...@@ -9,6 +9,8 @@ config PARISC ...@@ -9,6 +9,8 @@ config PARISC
def_bool y def_bool y
select HAVE_IDE select HAVE_IDE
select HAVE_OPROFILE select HAVE_OPROFILE
select RTC_CLASS
select RTC_DRV_PARISC
help help
The PA-RISC microprocessor is designed by Hewlett-Packard and used The PA-RISC microprocessor is designed by Hewlett-Packard and used
in many of their workstations & servers (HP9000 700 and 800 series, in many of their workstations & servers (HP9000 700 and 800 series,
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include <linux/smp.h> #include <linux/smp.h>
#include <linux/profile.h> #include <linux/profile.h>
#include <linux/clocksource.h> #include <linux/clocksource.h>
#include <linux/platform_device.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
#include <asm/io.h> #include <asm/io.h>
...@@ -215,6 +216,24 @@ void __init start_cpu_itimer(void) ...@@ -215,6 +216,24 @@ void __init start_cpu_itimer(void)
cpu_data[cpu].it_value = next_tick; cpu_data[cpu].it_value = next_tick;
} }
struct platform_device rtc_parisc_dev = {
.name = "rtc-parisc",
.id = -1,
};
static int __init rtc_init(void)
{
int ret;
ret = platform_device_register(&rtc_parisc_dev);
if (ret < 0)
printk(KERN_ERR "unable to register rtc device...\n");
/* not necessarily an error */
return 0;
}
module_init(rtc_init);
void __init time_init(void) void __init time_init(void)
{ {
static struct pdc_tod tod_data; static struct pdc_tod tod_data;
...@@ -245,4 +264,3 @@ void __init time_init(void) ...@@ -245,4 +264,3 @@ void __init time_init(void)
xtime.tv_nsec = 0; xtime.tv_nsec = 0;
} }
} }
...@@ -575,6 +575,14 @@ config RTC_DRV_RS5C313 ...@@ -575,6 +575,14 @@ config RTC_DRV_RS5C313
help help
If you say yes here you get support for the Ricoh RS5C313 RTC chips. If you say yes here you get support for the Ricoh RS5C313 RTC chips.
config RTC_DRV_PARISC
tristate "PA-RISC firmware RTC support"
depends on PARISC
help
Say Y or M here to enable RTC support on PA-RISC systems using
firmware calls. If you do not know what you are doing, you should
just say Y.
config RTC_DRV_PPC config RTC_DRV_PPC
tristate "PowerPC machine dependent RTC support" tristate "PowerPC machine dependent RTC support"
depends on PPC_MERGE depends on PPC_MERGE
......
...@@ -45,6 +45,7 @@ obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o ...@@ -45,6 +45,7 @@ obj-$(CONFIG_RTC_DRV_PCF8563) += rtc-pcf8563.o
obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o obj-$(CONFIG_RTC_DRV_PCF8583) += rtc-pcf8583.o
obj-$(CONFIG_RTC_DRV_PL030) += rtc-pl030.o obj-$(CONFIG_RTC_DRV_PL030) += rtc-pl030.o
obj-$(CONFIG_RTC_DRV_PL031) += rtc-pl031.o obj-$(CONFIG_RTC_DRV_PL031) += rtc-pl031.o
obj-$(CONFIG_RTC_DRV_PARISC) += rtc-parisc.o
obj-$(CONFIG_RTC_DRV_PPC) += rtc-ppc.o obj-$(CONFIG_RTC_DRV_PPC) += rtc-ppc.o
obj-$(CONFIG_RTC_DRV_R9701) += rtc-r9701.o obj-$(CONFIG_RTC_DRV_R9701) += rtc-r9701.o
obj-$(CONFIG_RTC_DRV_RS5C313) += rtc-rs5c313.o obj-$(CONFIG_RTC_DRV_RS5C313) += rtc-rs5c313.o
......
/* rtc-parisc: RTC for HP PA-RISC firmware
*
* Copyright (C) 2008 Kyle McMartin <kyle@mcmartin.ca>
*/
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/time.h>
#include <linux/platform_device.h>
#include <asm/rtc.h>
/* as simple as can be, and no simpler. */
struct parisc_rtc {
struct rtc_device *rtc;
spinlock_t lock;
};
static int parisc_get_time(struct device *dev, struct rtc_time *tm)
{
struct parisc_rtc *p = dev_get_drvdata(dev);
unsigned long flags, ret;
spin_lock_irqsave(&p->lock, flags);
ret = get_rtc_time(tm);
spin_unlock_irqrestore(&p->lock, flags);
if (ret & RTC_BATT_BAD)
return -EOPNOTSUPP;
return 0;
}
static int parisc_set_time(struct device *dev, struct rtc_time *tm)
{
struct parisc_rtc *p = dev_get_drvdata(dev);
unsigned long flags, ret;
spin_lock_irqsave(&p->lock, flags);
ret = set_rtc_time(tm);
spin_unlock_irqrestore(&p->lock, flags);
if (ret < 0)
return -EOPNOTSUPP;
return 0;
}
static const struct rtc_class_ops parisc_rtc_ops = {
.read_time = parisc_get_time,
.set_time = parisc_set_time,
};
static int __devinit parisc_rtc_probe(struct platform_device *dev)
{
struct parisc_rtc *p;
p = kzalloc(sizeof (*p), GFP_KERNEL);
if (!p)
return -ENOMEM;
spin_lock_init(&p->lock);
p->rtc = rtc_device_register("rtc-parisc", &dev->dev, &parisc_rtc_ops,
THIS_MODULE);
if (IS_ERR(p->rtc)) {
int err = PTR_ERR(p->rtc);
kfree(p);
return err;
}
platform_set_drvdata(dev, p);
return 0;
}
static int __devexit parisc_rtc_remove(struct platform_device *dev)
{
struct parisc_rtc *p = platform_get_drvdata(dev);
rtc_device_unregister(p->rtc);
kfree(p);
return 0;
}
static struct platform_driver parisc_rtc_driver = {
.driver = {
.name = "rtc-parisc",
.owner = THIS_MODULE,
},
.probe = parisc_rtc_probe,
.remove = __devexit_p(parisc_rtc_remove),
};
static int __init parisc_rtc_init(void)
{
return platform_driver_register(&parisc_rtc_driver);
}
static void __exit parisc_rtc_fini(void)
{
platform_driver_unregister(&parisc_rtc_driver);
}
module_init(parisc_rtc_init);
module_exit(parisc_rtc_fini);
MODULE_AUTHOR("Kyle McMartin <kyle@mcmartin.ca>");
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("HP PA-RISC RTC driver");
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