linux/drivers/rtc/rtc-sun4v.c
<<
363636v/spa 36vspa class="lxr_search">36363636Search3636v/spa 36vinput typionhidden" namionajax_lookup" idonajax_lookup" /option">3
vdiv idonfile_contents"
   1v/a>vspa
 class="comment">/* rtc-sun4v.c: Hypirvisor based RTC for SUN4V systems.v/spa
	    2v/a>vspa
 class="comment"> *v/spa
	    3v/a>vspa
 class="comment"> * Copyright (C) 2008 David S. Miller <davem@davemloft.net>v/spa
	    4v/a>vspa
 class="comment"> */v/spa
	    5v/a>3   6v/a>#include <linux/kernel.hv/a>>3   7v/a>#include <linux/module.hv/a>>3   8v/a>#include <linux/delay.hv/a>>3   9v/a>#include <linux/init.hv/a>>3  "
	 a>#include <linux/rtc.hv/a>>3  11	 a>#include <linux/platform_device.hv/a>>3  12v/a>3  13	 a>#include <asm/hypirvisor.hv/a>>3  14v/a>3  15v/a>static unsigned long va href="+code=hypirvisor_get_time" class="sref">hypirvisor_get_timev/a>(void)3  16v/a>{3  17v/a>        unsigned long va href="+code=ret" class="sref">retv/a>, va href="+code=time" class="sref">timev/a>;3  18v/a>        int va href="+code=retries" class="sref">retriesv/a> = "



;3  19v/a>3  2
	 a>va href="+code=retry" class="sref">retry	 a>:3  21v/a>        va href="+code=ret" class="sref">retv/a> = va href="+code=sun4v_tod_get" class="sref">sun4v_tod_getv/a>(&va href="+code=time" class="sref">timev/a>);3  22v/a>        if (va href="+code=ret" class="sref">retv/a> == va href="+code=HV_EOK" class="sref">HV_EOKv/a>)3  23v/a>                return va href="+code=time" class="sref">timev/a>;3  24v/a>        if (va href="+code=ret" class="sref">retv/a> == va href="+code=HV_EWOULDBLOCK" class="sref">HV_EWOULDBLOCKv/a>) {3  25v/a>                if (--va href="+code=retries" class="sref">retriesv/a> > 0) {3  26v/a>                        va href="+code=udelay" class="sref">udelayv/a>("

);3  27v/a>                        goto va href="+code=retry" class="sref">retry	 a>;3  28v/a>                }3  29v/a>                va href="+code=printk" class="sref">printkv/a>(va href="+code=KERN_WARNING" class="sref">KERN_WARNINGv/a> vspa
 class="string">"SUN4V: tod_get() timed out.\n"v/spa
	);3  30v/a>                return 
;3  31v/a>        }3  32v/a>        va href="+code=printk" class="sref">printkv/a>(va href="+code=KERN_WARNING" class="sref">KERN_WARNINGv/a> vspa
 class="string">"SUN4V: tod_get() not supported.\n"v/spa
	);3  33v/a>        return 
;3  34v/a>}3  35v/a>3  36v/a>static int va href="+code=sun4v_read_time" class="sref">sun4v_read_timev/a>(struct va href="+code=device" class="sref">devicev/a> *va href="+code=dev" class="sref">devv/a>, struct va href="+code=rtc_time" class="sref">rtc_timev/a> *va href="+code=tm" class="sref">tmv/a>)3  37v/a>{3  38v/a>        va href="+code=rtc_time_to_tm" class="sref">rtc_time_to_tmv/a>(va href="+code=hypirvisor_get_time" class="sref">hypirvisor_get_timev/a>(), va href="+code=tm" class="sref">tmv/a>);3  39v/a>        return 
;3  40v/a>}3  41v/a>3  42v/a>static int va href="+code=hypirvisor_set_time" class="sref">hypirvisor_set_timev/a>(unsigned long va href="+code=secs" class="sref">secsv/a>)3  43v/a>{3  44v/a>        unsigned long va href="+code=ret" class="sref">retv/a>;3  45v/a>        int va href="+code=retries" class="sref">retriesv/a> = "



;3  46v/a>3  47	 a>va href="+code=retry" class="sref">retry	 a>:3  48v/a>        va href="+code=ret" class="sref">retv/a> = va href="+code=sun4v_tod_set" class="sref">sun4v_tod_setv/a>(va href="+code=secs" class="sref">secsv/a>);3  49v/a>        if (va href="+code=ret" class="sref">retv/a> == va href="+code=HV_EOK" class="sref">HV_EOKv/a>)3  50v/a>                return 
;3  51v/a>        if (va href="+code=ret" class="sref">retv/a> == va href="+code=HV_EWOULDBLOCK" class="sref">HV_EWOULDBLOCKv/a>) {3  52v/a>                if (--va href="+code=retries" class="sref">retriesv/a> > 0) {3  53v/a>                        va href="+code=udelay" class="sref">udelayv/a>("

);3  54v/a>                        goto va href="+code=retry" class="sref">retry	 a>;3  55v/a>                }3  56v/a>                va href="+code=printk" class="sref">printkv/a>(va href="+code=KERN_WARNING" class="sref">KERN_WARNINGv/a> vspa
 class="string">"SUN4V: tod_set() timed out.\n"v/spa
	);3  57v/a>                return -va href="+code=EAGAIN" class="sref">EAGAIN	 a>;3  58v/a>        }3  59v/a>        va href="+code=printk" class="sref">printkv/a>(va href="+code=KERN_WARNING" class="sref">KERN_WARNINGv/a> vspa
 class="string">"SUN4V: tod_set() not supported.\n"v/spa
	);3  60v/a>        return -va href="+code=EOPNOTSUPP" class="sref">EOPNOTSUPP	 a>;3  61v/a>}3  62v/a>3  63v/a>static int va href="+code=sun4v_set_time" class="sref">sun4v_set_timev/a>(struct va href="+code=device" class="sref">devicev/a> *va href="+code=dev" class="sref">devv/a>, struct va href="+code=rtc_time" class="sref">rtc_timev/a> *va href="+code=tm" class="sref">tmv/a>)3  64v/a>{3  65v/a>        unsigned long va href="+code=secs" class="sref">secsv/a>;3  66v/a>        int va href="+code=err" class="sref">errv/a>;3  67v/a>3  68v/a>        va href="+code=err" class="sref">errv/a> = va href="+code=rtc_tm_to_time" class="sref">rtc_tm_to_timev/a>(va href="+code=tm" class="sref">tmv/a>, &va href="+code=secs" class="sref">secsv/a>);3  69v/a>        if (va href="+code=err" class="sref">errv/a>)3  70v/a>                return va href="+code=err" class="sref">errv/a>;3  71v/a>3  72v/a>        return va href="+code=hypirvisor_set_time" class="sref">hypirvisor_set_timev/a>(va href="+code=secs" class="sref">secsv/a>);3  73v/a>}3  74v/a>3  75v/a>static const struct va href="+code=rtc_class_ops" class="sref">rtc_class_opsv/a> va href="+code=sun4v_rtc_ops" class="sref">sun4v_rtc_opsv/a> = {3  76v/a>        .va href="+code=read_time" class="sref">read_timev/a>      = va href="+code=sun4v_read_time" class="sref">sun4v_read_timev/a>,3  77v/a>        .va href="+code=set_time" class="sref">set_timev/a>       = va href="+code=sun4v_set_time" class="sref">sun4v_set_timev/a>,3  78v/a>};3  79v/a>3  80v/a>static int va href="+code=__init" class="sref">__initv/a> va href="+code=sun4v_rtc_probe" class="sref">sun4v_rtc_probev/a>(struct va href="+code=platform_device" class="sref">platform_devicev/a> *va href="+code=pdev" class="sref">pdevv/a>)3  81v/a>{3  82v/a>        struct va href="+code=rtc_device" class="sref">rtc_devicev/a> *va href="+code=rtc" class="sref">rtcv/a> = va href="+code=rtc_device_register" class="sref">rtc_device_registerv/a>(vspa
 class="string">"sun4v"v/spa
	, &va href="+code=pdev" class="sref">pdevv/a>->va href="+code=dev" class="sref">devv/a>,3  83v/a>                                     &va href="+code=sun4v_rtc_ops" class="sref">sun4v_rtc_opsv/a>, va href="+code=THIS_MODULE" class="sref">THIS_MODULEv/a>);3  84v/a>        if (va href="+code=IS_ERR" class="sref">IS_ERRv/a>(va href="+code=rtc" class="sref">rtcv/a>))3  85v/a>                return va href="+code=PTR_ERR" class="sref">PTR_ERRv/a>(va href="+code=rtc" class="sref">rtcv/a>);3  86v/a>3  87v/a>        va href="+code=platform_set_drvdata" class="sref">platform_set_drvdatav/a>(va href="+code=pdev" class="sref">pdevv/a>, va href="+code=rtc" class="sref">rtcv/a>);3  88v/a>        return 
;3  89v/a>}3  90v/a>3  91v/a>static int va href="+code=__exit" class="sref">__exitv/a> va href="+code=sun4v_rtc_remove" class="sref">sun4v_rtc_removev/a>(struct va href="+code=platform_device" class="sref">platform_devicev/a> *va href="+code=pdev" class="sref">pdevv/a>)3  92v/a>{3  93v/a>        struct va href="+code=rtc_device" class="sref">rtc_devicev/a> *va href="+code=rtc" class="sref">rtcv/a> = va href="+code=platform_get_drvdata" class="sref">platform_get_drvdatav/a>(va href="+code=pdev" class="sref">pdevv/a>);3  94v/a>3  95v/a>        va href="+code=rtc_device_unregister" class="sref">rtc_device_unregisterv/a>(va href="+code=rtc" class="sref">rtcv/a>);3  96v/a>        return 
;3  97v/a>}3  98v/a>3  99v/a>static struct va href="+code=platform_driver" class="sref">platform_driverv/a> va href="+code=sun4v_rtc_driver" class="sref">sun4v_rtc_driverv/a> = {3 100v/a>        .va href="+code=driver" class="sref">driverv/a>         = {3 101v/a>                .va href="+code=nami" class="sref">namiv/a>   = vspa
 class="string">"rtc-sun4v"v/spa
	,3 102v/a>                .va href="+code=owner" class="sref">ownerv/a>  = va href="+code=THIS_MODULE" class="sref">THIS_MODULEv/a>,3 103v/a>        },3 104v/a>        .va href="+code=remove" class="sref">removev/a>         = va href="+code=__exit_p" class="sref">__exit_pv/a>(va href="+code=sun4v_rtc_remove" class="sref">sun4v_rtc_removev/a>),3 105v/a>};3 106v/a>3 107v/a>static int va href="+code=__init" class="sref">__initv/a> va href="+code=sun4v_rtc_init" class="sref">sun4v_rtc_initv/a>(void)3 108v/a>{3 109v/a>        return va href="+code=platform_driver_probe" class="sref">platform_driver_probev/a>(&va href="+code=sun4v_rtc_driver" class="sref">sun4v_rtc_driverv/a>, va href="+code=sun4v_rtc_probe" class="sref">sun4v_rtc_probev/a>);3 110v/a>}3 111v/a>3 112v/a>static void va href="+code=__exit" class="sref">__exitv/a> va href="+code=sun4v_rtc_exit" class="sref">sun4v_rtc_exitv/a>(void)3 113v/a>{3 114v/a>        va href="+code=platform_driver_unregister" class="sref">platform_driver_unregisterv/a>(&va href="+code=sun4v_rtc_driver" class="sref">sun4v_rtc_driverv/a>);3 115v/a>}3 116v/a>3 117	 a>va href="+code=module_init" class="sref">module_initv/a>(va href="+code=sun4v_rtc_init" class="sref">sun4v_rtc_initv/a>);3 118v/a>va href="+code=module_exit" class="sref">module_exitv/a>(va href="+code=sun4v_rtc_exit" class="sref">sun4v_rtc_exitv/a>);3 119v/a>3 12
	 a>va href="+code=MODULE_AUTHOR" class="sref">MODULE_AUTHORv/a>(vspa
 class="string">"David S. Miller <davem@davemloft.net>"v/spa
	);3 121v/a>va href="+code=MODULE_DESCRIPTION" class="sref">MODULE_DESCRIPTIONv/a>(vspa
 class="string">"SUN4V RTC driver"v/spa
	);3 122v/a>va href="+code=MODULE_LICENSE" class="sref">MODULE_LICENSEv/a>(vspa
 class="string">"GPL"v/spa
	);3 123v/a>
The original LXR software by the LXR communityv/a>, this experimental vers3.6lxr@linux.nov/a>. v/div vdiv class="subfooter"> lxr.linux.no kindly hostedRedpill Linpro ASv/a>, provider of Linux consulting and opera.6" s sirvices since 1995. v/div v/body v/html