0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012 #include <linux/platform_device.h>
0013 #include <linux/err.h>
0014 #include <linux/init.h>
0015 #include <linux/module.h>
0016 #include <linux/mc146818rtc.h>
0017 #include <linux/of_address.h>
0018
0019
0020 static int __init add_rtc(void)
0021 {
0022 struct device_node *np;
0023 struct platform_device *pd;
0024 struct resource res[2];
0025 unsigned int num_res = 1;
0026 int ret;
0027
0028 memset(&res, 0, sizeof(res));
0029
0030 np = of_find_compatible_node(NULL, NULL, "pnpPNP,b00");
0031 if (!np)
0032 return -ENODEV;
0033
0034 ret = of_address_to_resource(np, 0, &res[0]);
0035 of_node_put(np);
0036 if (ret)
0037 return ret;
0038
0039
0040
0041
0042
0043 if (res[0].start != RTC_PORT(0))
0044 return -EINVAL;
0045
0046 np = of_find_compatible_node(NULL, NULL, "chrp,iic");
0047 if (!np)
0048 np = of_find_compatible_node(NULL, NULL, "pnpPNP,000");
0049 if (np) {
0050 of_node_put(np);
0051
0052
0053
0054
0055
0056 res[1].start = 8;
0057 res[1].end = 8;
0058 res[1].flags = IORESOURCE_IRQ;
0059 num_res++;
0060 }
0061
0062 pd = platform_device_register_simple("rtc_cmos", -1,
0063 &res[0], num_res);
0064
0065 return PTR_ERR_OR_ZERO(pd);
0066 }
0067 fs_initcall(add_rtc);
0068
0069 MODULE_LICENSE("GPL");