Back to home page

OSCL-LXR

 
 

    


0001 /* rtc-starfire.c: Starfire platform RTC driver.
0002  *
0003  * Author: David S. Miller
0004  * License: GPL
0005  *
0006  * Copyright (C) 2008 David S. Miller <davem@davemloft.net>
0007  */
0008 
0009 #include <linux/kernel.h>
0010 #include <linux/init.h>
0011 #include <linux/rtc.h>
0012 #include <linux/platform_device.h>
0013 
0014 #include <asm/oplib.h>
0015 
0016 static u32 starfire_get_time(void)
0017 {
0018     static char obp_gettod[32];
0019     static u32 unix_tod;
0020 
0021     sprintf(obp_gettod, "h# %08x unix-gettod",
0022         (unsigned int) (long) &unix_tod);
0023     prom_feval(obp_gettod);
0024 
0025     return unix_tod;
0026 }
0027 
0028 static int starfire_read_time(struct device *dev, struct rtc_time *tm)
0029 {
0030     rtc_time64_to_tm(starfire_get_time(), tm);
0031     return 0;
0032 }
0033 
0034 static const struct rtc_class_ops starfire_rtc_ops = {
0035     .read_time  = starfire_read_time,
0036 };
0037 
0038 static int __init starfire_rtc_probe(struct platform_device *pdev)
0039 {
0040     struct rtc_device *rtc;
0041 
0042     rtc = devm_rtc_allocate_device(&pdev->dev);
0043     if (IS_ERR(rtc))
0044         return PTR_ERR(rtc);
0045 
0046     rtc->ops = &starfire_rtc_ops;
0047     rtc->range_max = U32_MAX;
0048 
0049     platform_set_drvdata(pdev, rtc);
0050 
0051     return devm_rtc_register_device(rtc);
0052 }
0053 
0054 static struct platform_driver starfire_rtc_driver = {
0055     .driver     = {
0056         .name   = "rtc-starfire",
0057     },
0058 };
0059 
0060 builtin_platform_driver_probe(starfire_rtc_driver, starfire_rtc_probe);