1*93ab4718SWade Farnsworth /* 2*93ab4718SWade Farnsworth * Setup code for PC-style Real-Time Clock. 3*93ab4718SWade Farnsworth * 4*93ab4718SWade Farnsworth * Author: Wade Farnsworth <wfarnsworth@mvista.com> 5*93ab4718SWade Farnsworth * 6*93ab4718SWade Farnsworth * 2007 (c) MontaVista Software, Inc. This file is licensed under 7*93ab4718SWade Farnsworth * the terms of the GNU General Public License version 2. This program 8*93ab4718SWade Farnsworth * is licensed "as is" without any warranty of any kind, whether express 9*93ab4718SWade Farnsworth * or implied. 10*93ab4718SWade Farnsworth */ 11*93ab4718SWade Farnsworth 12*93ab4718SWade Farnsworth #include <linux/platform_device.h> 13*93ab4718SWade Farnsworth #include <linux/err.h> 14*93ab4718SWade Farnsworth #include <linux/init.h> 15*93ab4718SWade Farnsworth #include <linux/mc146818rtc.h> 16*93ab4718SWade Farnsworth 17*93ab4718SWade Farnsworth #include <asm/prom.h> 18*93ab4718SWade Farnsworth 19*93ab4718SWade Farnsworth static int __init add_rtc(void) 20*93ab4718SWade Farnsworth { 21*93ab4718SWade Farnsworth struct device_node *np; 22*93ab4718SWade Farnsworth struct platform_device *pd; 23*93ab4718SWade Farnsworth struct resource res; 24*93ab4718SWade Farnsworth int ret; 25*93ab4718SWade Farnsworth 26*93ab4718SWade Farnsworth np = of_find_compatible_node(NULL, NULL, "pnpPNP,b00"); 27*93ab4718SWade Farnsworth if (!np) 28*93ab4718SWade Farnsworth return -ENODEV; 29*93ab4718SWade Farnsworth 30*93ab4718SWade Farnsworth ret = of_address_to_resource(np, 0, &res); 31*93ab4718SWade Farnsworth of_node_put(np); 32*93ab4718SWade Farnsworth if (ret) 33*93ab4718SWade Farnsworth return ret; 34*93ab4718SWade Farnsworth 35*93ab4718SWade Farnsworth /* 36*93ab4718SWade Farnsworth * RTC_PORT(x) is hardcoded in asm/mc146818rtc.h. Verify that the 37*93ab4718SWade Farnsworth * address provided by the device node matches. 38*93ab4718SWade Farnsworth */ 39*93ab4718SWade Farnsworth if (res.start != RTC_PORT(0)) 40*93ab4718SWade Farnsworth return -EINVAL; 41*93ab4718SWade Farnsworth 42*93ab4718SWade Farnsworth pd = platform_device_register_simple("rtc_cmos", -1, 43*93ab4718SWade Farnsworth &res, 1); 44*93ab4718SWade Farnsworth if (IS_ERR(pd)) 45*93ab4718SWade Farnsworth return PTR_ERR(pd); 46*93ab4718SWade Farnsworth 47*93ab4718SWade Farnsworth return 0; 48*93ab4718SWade Farnsworth } 49*93ab4718SWade Farnsworth fs_initcall(add_rtc); 50