1 /* rtc-generic: RTC driver using the generic RTC abstraction
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>
10 #include <linux/rtc.h>
12 #if defined(CONFIG_M68K) || defined(CONFIG_PARISC) || \
13 defined(CONFIG_PPC) || defined(CONFIG_SUPERH32)
16 static int generic_get_time(struct device
*dev
, struct rtc_time
*tm
)
18 unsigned int ret
= get_rtc_time(tm
);
20 if (ret
& RTC_BATT_BAD
)
23 return rtc_valid_tm(tm
);
26 static int generic_set_time(struct device
*dev
, struct rtc_time
*tm
)
28 if (set_rtc_time(tm
) < 0)
34 static const struct rtc_class_ops generic_rtc_ops
= {
35 .read_time
= generic_get_time
,
36 .set_time
= generic_set_time
,
39 #define generic_rtc_ops *(struct rtc_class_ops*)NULL
42 static int __init
generic_rtc_probe(struct platform_device
*dev
)
44 struct rtc_device
*rtc
;
45 const struct rtc_class_ops
*ops
;
47 ops
= dev_get_platdata(&dev
->dev
);
49 ops
= &generic_rtc_ops
;
51 rtc
= devm_rtc_device_register(&dev
->dev
, "rtc-generic",
56 platform_set_drvdata(dev
, rtc
);
61 static struct platform_driver generic_rtc_driver
= {
63 .name
= "rtc-generic",
67 module_platform_driver_probe(generic_rtc_driver
, generic_rtc_probe
);
69 MODULE_AUTHOR("Kyle McMartin <kyle@mcmartin.ca>");
70 MODULE_LICENSE("GPL");
71 MODULE_DESCRIPTION("Generic RTC driver");
72 MODULE_ALIAS("platform:rtc-generic");