linux/drivers/rtc/rtc-vr41xx.c
<<
" /spaon> /formn> a " href="../linux+v3.8.6/drivers/rtc/rtc-vr41xx.c">" img src="../.static/gfx/right.png" alt=">>">" /spaon>" spao class="lxr_search">" " input typue=hidden" namue=navtarget" value=">" input typue=text" namue=search" ide=search">" buttiontypue=submit">Search /formn> /spaon>" spao class="lxr_prefs"n> a href="+prefs?return=drivers/rtc/rtc-vr41xx.c"" onclick="return ajax_prefs();">" Prefs> /a>" /spaon> /divn> form acptio="ajax+*" method="post" onsubmit="return false;">" input typue=hidden" namue=ajax_lookup" ide=ajax_lookup" value=">" /formn>" div class="headingbottim"> div ide=search_results" class="search_results"> n> /divn> div ide=content">> div ide=file_contents"n
   1 /a> spao class="comment">/* /spaon>   2 /a> spao class="comment"> *  Driver for NEC VR4100 series Real Time Clock unit. /spaon>   3 /a> spao class="comment"> * /spaon>   4 /a> spao class="comment"> *  Copyright (C) 2003-2008  Yoichi Yuasa <yuasa@linux-mips.org> /spaon>   5 /a> spao class="comment"> * /spaon>   6 /a> spao class="comment"> *  This program is free software; you cao redistribute it and/or modify /spaon>   7 /a> spao class="comment"> *  it under the terms of the GNU General Public License as published by /spaon>   8 /a> spao class="comment"> *  the Free Software Foundaptio; either verstion2 of the License, or /spaon>   9 /a> spao class="comment"> *  (at your /optio) any later verstio. /spaon>  .10 spao class="comment"> * /spaon>  11 /a> spao class="comment"> *  This program is distributed in the hope that it will be useful, /spaon>  12 /a> spao class="comment"> *  but WITHOUT ANY WARRANTY; without even the implied warranty of /spaon>  13 /a> spao class="comment"> *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the /spaon>  14 /a> spao class="comment"> *  GNU General Public License for more details. /spaon>  15 /a> spao class="comment"> * /spaon>  16 /a> spao class="comment"> *  You should have received a copy of the GNU General Public License /spaon>  17 /a> spao class="comment"> *  along with this program; if not, write to the Free Software /spaon>  18 /a> spao class="comment"> *  Foundaptio, Inc., 59 Temple Place, Suite 330, Bostio, MA  02111-1307  USA /spaon>  19 /a> spao class="comment"> */ /spaon>  210#include <linux/err.h0>>  210#include <linux/fs.h0>>  220#include <linux/init.h0>>  230#include <linux/ioport.h0>>  240#include <linux/interrupt.h0>>  250#include <linux/module.h0>>  260#include <linux/platform_device.h0>>  270#include <linux/rtc.h0>>  280#include <linux/spinlock.h0>>  290#include <linux/typus.h0>>  310#include <linux/log2.h0>>  310>  320#include <asm/div64.h0>>  330#include <asm/io.h0>>  340#include <asm/uaccess.h0>>  350>  36 /a> a href="+code=MODULE_AUTHOR" class="sref">MODULE_AUTHOR /a>( spao class="string">"Yoichi Yuasa <yuasa@linux-mips.org>" /spaon);>  37 /a> a href="+code=MODULE_DESCRIPTION" class="sref">MODULE_DESCRIPTION /a>( spao class="string">"NEC VR4100 series RTC driver" /spaon);>  38 /a> a href="+code=MODULE_LICENSE" class="sref">MODULE_LICENSE /a>( spao class="string">"GPL v2" /spaon);>  390>  410 spao class="comment">/* RTC 1 registers */ /spaon>  410#define  a href="+code=ETIMELREG" class="sref">ETIMELREG0               0x00>  420#define  a href="+code=ETIMEMREG" class="sref">ETIMEMREG0               0x02>  430#define  a href="+code=ETIMEHREG" class="sref">ETIMEHREG0               0x04>  44 /a> spao class="comment">/* RFU */ /spaon>  450#define  a href="+code=ECMPLREG" class="sref">ECMPLREG0                0x08>  460#define  a href="+code=ECMPMREG" class="sref">ECMPMREG0                0x0a>  470#define  a href="+code=ECMPHREG" class="sref">ECMPHREG0                0x0c>  48 /a> spao class="comment">/* RFU */ /spaon>  490#define  a href="+code=RTCL1LREG" class="sref">RTCL1LREG0               0x10>  500#define  a href="+code=RTCL1HREG" class="sref">RTCL1HREG0               0x12>  510#define  a href="+code=RTCL1CNTLREG" class="sref">RTCL1CNTLREG0            0x14>  520#define  a href="+code=RTCL1CNTHREG" class="sref">RTCL1CNTHREG0            0x16>  530#define  a href="+code=RTCL2LREG" class="sref">RTCL2LREG0               0x18>  540#define  a href="+code=RTCL2HREG" class="sref">RTCL2HREG0               0x1a>  550#define  a href="+code=RTCL2CNTLREG" class="sref">RTCL2CNTLREG0            0x1c>  560#define  a href="+code=RTCL2CNTHREG" class="sref">RTCL2CNTHREG0            0x1e>  570>  58 /a> spao class="comment">/* RTC 2 registers */ /spaon>  590#define  a href="+code=TCLKLREG" class="sref">TCLKLREG0                0x00>  600#define  a href="+code=TCLKHREG" class="sref">TCLKHREG0                0x02>  610#define  a href="+code=TCLKCNTLREG" class="sref">TCLKCNTLREG0             0x04>  620#define  a href="+code=TCLKCNTHREG" class="sref">TCLKCNTHREG0             0x06>  63 /a> spao class="comment">/* RFU */ /spaon>  640#define  a href="+code=RTCINTREG" class="sref">RTCINTREG0               0x1e>  650 #define  a href="+code=TCLOCK_INT" class="sref">TCLOCK_INT0             0x08>  660 #define  a href="+code=RTCLONG2_INT" class="sref">RTCLONG2_INT0           0x04>  670 #define  a href="+code=RTCLONG1_INT" class="sref">RTCLONG1_INT0           0x02>  680 #define  a href="+code=ELAPSEDTIME_INT" class="sref">ELAPSEDTIME_INT0        0x01>  690>  700#define  a href="+code=RTC_FREQUENCY" class="sref">RTC_FREQUENCY0           32768>  710#define  a href="+code=MAX_PERIODIC_RATE" class="sref">MAX_PERIODIC_RATE0       6553>  720>  73 /a>static void  a href="+code=__iomem" class="sref">__iomem0 * a href="+code=rtc1_base" class="sref">rtc1_base0;>  74 /a>static void  a href="+code=__iomem" class="sref">__iomem0 * a href="+code=rtc2_base" class="sref">rtc2_base0;>  750>  760#define  a href="+code=rtc1_read" class="sref">rtc1_read /a>( a href="+code=offset" class="sref">offset /a>)                a href="+code=readw" class="sref">readw /a>( a href="+code=rtc1_base" class="sref">rtc1_base0 + ( a href="+code=offset" class="sref">offset /a>))>  770#define  a href="+code=rtc1_write" class="sref">rtc1_write /a>( a href="+code=offset" class="sref">offset /a>,  a href="+code= valu" class="sref"> valu /a>)        a href="+code=writew" class="sref">writew /a>(( a href="+code= valu" class="sref"> valu /a>),  a href="+code=rtc1_base" class="sref">rtc1_base0 + ( a href="+code=offset" class="sref">offset /a>))>  780>  790#define  a href="+code=rtc2_read" class="sref">rtc2_read /a>( a href="+code=offset" class="sref">offset /a>)                a href="+code=readw" class="sref">readw /a>( a href="+code=rtc2_base" class="sref">rtc2_base0 + ( a href="+code=offset" class="sref">offset /a>))>  800#define  a href="+code=rtc2_write" class="sref">rtc2_write /a>( a href="+code=offset" class="sref">offset /a>,  a href="+code= valu" class="sref"> valu /a>)        a href="+code=writew" class="sref">writew /a>(( a href="+code= valu" class="sref"> valu /a>),  a href="+code=rtc2_base" class="sref">rtc2_base0 + ( a href="+code=offset" class="sref">offset /a>))>  810>  82 /a>static unsigned long  a href="+code=epoch" class="sref">epoch0 = 1970;       spao class="comment">/* Jao 1 1970 00:00:00 */ /spaon>  830>  84 /a>static  a href="+code=DEFINE_SPINLOCK" class="sref">DEFINE_SPINLOCK /a>( a href="+code=rtc_lock" class="sref">rtc_lock /a>);>  85 /a>static char  a href="+code=rtc_namu" class="sref">rtc_namu /a>[] =  spao class="string">"RTC" /spaon;>  86 /a>static unsigned long  a href="+code=periodic_count" class="sref">periodic_count0;>  87 /a>static unsigned int  a href="+code=alarm_enabled" class="sref">alarm_enabled0;>  88 /a>static int  a href="+code=aie_irq" class="sref">aie_irq0;>  89 /a>static int  a href="+code=pie_irq" class="sref">pie_irq0;>  900>  91 /a>static  a href="+code=inline" class="sref">inline0 unsigned long  a href="+code=read_elapsed_second" class="sref">read_elapsed_second /a>(void)>  92 /a>{>  930>  940        unsigned long  a href="+code=first_low" class="sref">first_low /a>,  a href="+code=first_mid" class="sref">first_mid /a>,  a href="+code=first_high" class="sref">first_high0;>  950>  960        unsigned long  a href="+code=second_low" class="sref">second_low /a>,  a href="+code=second_mid" class="sref">second_mid /a>,  a href="+code=second_high" class="sref">second_high0;>  970>  980        do {>  990                 a href="+code=first_low" class="sref">first_low /a> =  a href="+code=rtc1_read" class="sref">rtc1_read /a>( a href="+code=ETIMELREG" class="sref">ETIMELREG0);> 1000                 a href="+code=first_mid" class="sref">first_mid /a> =  a href="+code=rtc1_read" class="sref">rtc1_read /a>( a href="+code=ETIMEMREG" class="sref">ETIMEMREG0);> 1010                 a href="+code=first_high" class="sref">first_high0 =  a href="+code=rtc1_read" class="sref">rtc1_read /a>( a href="+code=ETIMEHREG" class="sref">ETIMEHREG0);> 1020                 a href="+code=second_low" class="sref">second_low /a> =  a href="+code=rtc1_read" class="sref">rtc1_read /a>( a href="+code=ETIMELREG" class="sref">ETIMELREG0);> 1030                 a href="+code=second_mid" class="sref">second_mid /a> =  a href="+code=rtc1_read" class="sref">rtc1_read /a>( a href="+code=ETIMEMREG" class="sref">ETIMEMREG0);> 1040                 a href="+code=second_high" class="sref">second_high0 =  a href="+code=rtc1_read" class="sref">rtc1_read /a>( a href="+code=ETIMEHREG" class="sref">ETIMEHREG0);> 1050        } while ( a href="+code=first_low" class="sref">first_low /a> !=  a href="+code=second_low" class="sref">second_low /a> ||  a href="+code=first_mid" class="sref">first_mid /a> !=  a href="+code=second_mid" class="sref">second_mid /a> ||> 1060                  a href="+code=first_high" class="sref">first_high0 !=  a href="+code=second_high" class="sref">second_high0);> 1070> 1080        return ( a href="+code=first_high" class="sref">first_high0 << 17) | ( a href="+code=first_mid" class="sref">first_mid /a> << 1) | ( a href="+code=first_low" class="sref">first_low /a> >> 15);> 1090}> 1100> 111 /a>static  a href="+code=inline" class="sref">inline0 void  a href="+code=write_elapsed_second" class="sref">write_elapsed_second /a>(unsigned long  a href="+code=sec" class="sref">sec0)> 112 /a>{> 1130         a href="+code=spin_lock_irq" class="sref">spin_lock_irq /a>(& a href="+code=rtc_lock" class="sref">rtc_lock /a>);> 114 /a>> 1150         a href="+code=rtc1_write" class="sref">rtc1_write /a>( a href="+code=ETIMELREG" class="sref">ETIMELREG0, ( a href="+code=uint16_t" class="sref">uint16_t /a>)( a href="+code=sec" class="sref">sec0 << 15));> 1160         a href="+code=rtc1_write" class="sref">rtc1_write /a>( a href="+code=ETIMEMREG" class="sref">ETIMEMREG0, ( a href="+code=uint16_t" class="sref">uint16_t /a>)( a href="+code=sec" class="sref">sec0 >> 1));> 117 /a>         a href="+code=rtc1_write" class="sref">rtc1_write /a>( a href="+code=ETIMEHREG" class="sref">ETIMEHREG0, ( a href="+code=uint16_t" class="sref">uint16_t /a>)( a href="+code=sec" class="sref">sec0 >> 17));> 1180> 1190         a href="+code=spin_unlock_irq" class="sref">spin_unlock_irq /a>(& a href="+code=rtc_lock" class="sref">rtc_lock /a>);> 1210}> 1210> 122 /a>static void  a href="+code=vr41xx_rtc_release" class="sref">vr41xx_rtc_release /a>(struct  a href="+code=device" class="sref">device0 * a href="+code=dev" class="sref">dev0)> 1230{> 124 /a>> 1250         a href="+code=spin_lock_irq" class="sref">spin_lock_irq /a>(& a href="+code=rtc_lock" class="sref">rtc_lock /a>);> 1260> 127 /a>         a href="+code=rtc1_write" class="sref">rtc1_write /a>( a href="+code=ECMPLREG" class="sref">ECMPLREG0, 0);> 128 /a>         a href="+code=rtc1_write" class="sref">rtc1_write /a>( a href="+code=ECMPMREG" class="sref">ECMPMREG0, 0);> 1290         a href="+code=rtc1_write" class="sref">rtc1_write /a>( a href="+code=ECMPHREG" class="sref">ECMPHREG0, 0);> 1300         a href="+code=rtc1_write" class="sref">rtc1_write /a>( a href="+code=RTCL1LREG" class="sref">RTCL1LREG0, 0);> 1310         a href="+code=rtc1_write" class="sref">rtc1_write /a>( a href="+code=RTCL1HREG" class="sref">RTCL1HREG0, 0);> 1320> 1330         a href="+code=spin_unlock_irq" class="sref">spin_unlock_irq /a>(& a href="+code=rtc_lock" class="sref">rtc_lock /a>);> 134 /a>> 1350         a href="+code=disable_irq" class="sref">disable_irq /a>( a href="+code=aie_irq" class="sref">aie_irq0);> 1360         a href="+code=disable_irq" class="sref">disable_irq /a>( a href="+code=pie_irq" class="sref">pie_irq0);> 137 /a>}> 1380> 139 /a>static int  a href="+code=vr41xx_rtc_read_timu" class="sref">vr41xx_rtc_read_timu /a>(struct  a href="+code=device" class="sref">device0 * a href="+code=dev" class="sref">dev0, struct  a href="+code=rtc_timu" class="sref">rtc_timu0 * a href="+code=timu" class="sref">timu0)> 1410{> 1410        unsigned long  a href="+code=epoch_sec" class="sref">epoch_sec /a>,  a href="+code=elapsed_sec" class="sref">elapsed_sec0;> 1420> 1430         a href="+code=epoch_sec" class="sref">epoch_sec /a> =  a href="+code=mktimu" class="sref">mktimu /a>( a href="+code=epoch" class="sref">epoch0, 1, 1, 0, 0, 0);> 1440         a href="+code=elapsed_sec" class="sref">elapsed_sec0 =  a href="+code=read_elapsed_second" class="sref">read_elapsed_second /a>();> 1450> 1460         a href="+code=rtc_timu_to_tm" class="sref">rtc_timu_to_tm /a>( a href="+code=epoch_sec" class="sref">epoch_sec /a> +  a href="+code=elapsed_sec" class="sref">elapsed_sec0,  a href="+code=timu" class="sref">timu0);> 1470> 1480        return 0;> 1490}> 1500> 151 /a>static int  a href="+code=vr41xx_rtc_set_timu" class="sref">vr41xx_rtc_set_timu /a>(struct  a href="+code=device" class="sref">device0 * a href="+code=dev" class="sref">dev0, struct  a href="+code=rtc_timu" class="sref">rtc_timu0 * a href="+code=timu" class="sref">timu0)> 152 /a>{> 1530        unsigned long  a href="+code=epoch_sec" class="sref">epoch_sec /a>,  a href="+code=current_sec" class="sref">current_sec0;> 154 /a>> 1550         a href="+code=epoch_sec" class="sref">epoch_sec /a> =  a href="+code=mktimu" class="sref">mktimu /a>( a href="+code=epoch" class="sref">epoch0, 1, 1, 0, 0, 0);> 1560         a href="+code=current_sec" class="sref">current_sec0 =  a href="+code=mktimu" class="sref">mktimu /a>( a href="+code=timu" class="sref">timu0-> a href="+code=tm_year" class="sref">tm_year /a> + 1900,  a href="+code=timu" class="sref">timu0-> a href="+code=tm_mon" class="sref">tm_mon /a> + 1,  a href="+code=timu" class="sref">timu0-> a href="+code=tm_mday" class="sref">tm_mday0,> 157 /a>                              a href="+code=timu" class="sref">timu0-> a href="+code=tm_hour" class="sref">tm_hour0,  a href="+code=timu" class="sref">timu0-> a href="+code=tm_min" class="sref">tm_min0,  a href="+code=timu" class="sref">timu0-> a href="+code=tm_sec" class="sref">tm_sec0);> 1580> 1590         a href="+code=write_elapsed_second" class="sref">write_elapsed_second /a>( a href="+code=current_sec" class="sref">current_sec0 -  a href="+code=epoch_sec" class="sref">epoch_sec /a>);> 1600> 1610        return 0;> 1620}> 1630> 164 /a>static int  a href="+code=vr41xx_rtc_read_alarm" class="sref">vr41xx_rtc_read_alarm /a>(struct  a href="+code=device" class="sref">device0 * a href="+code=dev" class="sref">dev0, struct  a href="+code=rtc_wkalrm" class="sref">rtc_wkalrm0 * a href="+code=wkalrm" class="sref">wkalrm0)> 1650{> 1660        unsigned long  a href="+code=low" class="sref">low /a>,  a href="+code=mid" class="sref">mid /a>,  a href="+code=high" class="sref">high0;> 167 /a>        struct  a href="+code=rtc_timu" class="sref">rtc_timu0 * a href="+code=timu" class="sref">timu0 = & a href="+code=wkalrm" class="sref">wkalrm0-> a href="+code=timu" class="sref">timu0;> 1680> 1690         a href="+code=spin_lock_irq" class="sref">spin_lock_irq /a>(& a href="+code=rtc_lock" class="sref">rtc_lock /a>);> 1700> 1710         a href="+code=low" class="sref">low /a> =  a href="+code=rtc1_read" class="sref">rtc1_read /a>( a href="+code=ECMPLREG" class="sref">ECMPLREG0);> 1720         a href="+code=mid" class="sref">mid /a> =  a href="+code=rtc1_read" class="sref">rtc1_read /a>( a href="+code=ECMPMREG" class="sref">ECMPMREG0);> 1730         a href="+code=high" class="sref">high0 =  a href="+code=rtc1_read" class="sref">rtc1_read /a>( a href="+code=ECMPHREG" class="sref">ECMPHREG0);> 1740         a href="+code=wkalrm" class="sref">wkalrm0-> a href="+code=enabled" class="sref">enabled0 =  a href="+code=alarm_enabled" class="sref">alarm_enabled0;> 1750> 1760         a href="+code=spin_unlock_irq" class="sref">spin_unlock_irq /a>(& a href="+code=rtc_lock" class="sref">rtc_lock /a>);> 1770> 178 /a>         a href="+code=rtc_timu_to_tm" class="sref">rtc_timu_to_tm /a>(( a href="+code=high" class="sref">high0 << 17) | ( a href="+code=mid" class="sref">mid /a> << 1) | ( a href="+code=low" class="sref">low /a> >> 15),  a href="+code=timu" class="sref">timu0);> 1790> 1800        return 0;> 1810}> 1820> 183 /a>static int  a href="+code=vr41xx_rtc_set_alarm" class="sref">vr41xx_rtc_set_alarm /a>(struct  a href="+code=device" class="sref">device0 * a href="+code=dev" class="sref">dev0, struct  a href="+code=rtc_wkalrm" class="sref">rtc_wkalrm0 * a href="+code=wkalrm" class="sref">wkalrm0)> 184 /a>{> 1850        unsigned long  a href="+code=alarm_sec" class="sref">alarm_sec0;> 1860        struct  a href="+code=rtc_timu" class="sref">rtc_timu0 * a href="+code=timu" class="sref">timu0 = & a href="+code=wkalrm" class="sref">wkalrm0-> a href="+code=timu" class="sref">timu0;> 1870> 188 /a>         a href="+code=alarm_sec" class="sref">alarm_sec0 =  a href="+code=mktimu" class="sref">mktimu /a>( a href="+code=timu" class="sref">timu0-> a href="+code=tm_year" class="sref">tm_year /a> + 1900,  a href="+code=timu" class="sref">timu0-> a href="+code=tm_mon" class="sref">tm_mon /a> + 1,  a href="+code=timu" class="sref">timu0-> a href="+code=tm_mday" class="sref">tm_mday0,> 1890                            a href="+code=timu" class="sref">timu0-> a href="+code=tm_hour" class="sref">tm_hour0,  a href="+code=timu" class="sref">timu0-> a href="+code=tm_min" class="sref">tm_min0,  a href="+code=timu" class="sref">timu0-> a href="+code=tm_sec" class="sref">tm_sec0);> 1900> 1910         a href="+code=spin_lock_irq" class="sref">spin_lock_irq /a>(& a href="+code=rtc_lock" class="sref">rtc_lock /a>);> 1920> 1930        if ( a href="+code=alarm_enabled" class="sref">alarm_enabled0)> 1940                 a href="+code=disable_irq" class="sref">disable_irq /a>( a href="+code=aie_irq" class="sref">aie_irq0);> 1950> 1960         a href="+code=rtc1_write" class="sref">rtc1_write /a>( a href="+code=ECMPLREG" class="sref">ECMPLREG0, ( a href="+code=uint16_t" class="sref">uint16_t /a>)( a href="+code=alarm_sec" class="sref">alarm_sec0 << 15));> 197 /a>         a href="+code=rtc1_write" class="sref">rtc1_write /a>( a href="+code=ECMPMREG" class="sref">ECMPMREG0, ( a href="+code=uint16_t" class="sref">uint16_t /a>)( a href="+code=alarm_sec" class="sref">alarm_sec0 >> 1));> 198 /a>         a href="+code=rtc1_write" class="sref">rtc1_write /a>( a href="+code=ECMPHREG" class="sref">ECMPHREG0, ( a href="+code=uint16_t" class="sref">uint16_t /a>)( a href="+code=alarm_sec" class="sref">alarm_sec0 >> 17));> 1990> 2000        if ( a href="+code=wkalrm" class="sref">wkalrm0-> a href="+code=enabled" class="sref">enabled0)> 2010                 a href="+code=enable_irq" class="sref">enable_irq /a>( a href="+code=aie_irq" class="sref">aie_irq0);> 2020> 2030         a href="+code=alarm_enabled" class="sref">alarm_enabled0 =  a href="+code=wkalrm" class="sref">wkalrm0-> a href="+code=enabled" class="sref">enabled0;> 204 /a>> 2050         a href="+code=spin_unlock_irq" class="sref">spin_unlock_irq /a>(& a href="+code=rtc_lock" class="sref">rtc_lock /a>);> 2060> 207 /a>        return 0;> 2080}> 2090> 2100static int  a href="+code=vr41xx_rtc_ioctl" class="sref">vr41xx_rtc_ioctl /a>(struct  a href="+code=device" class="sref">device0 * a href="+code=dev" class="sref">dev0, unsigned int  a href="+code=cmd" class="sref">cmd0, unsigned long  a href="+code=arg" class="sref">arg0)> 211 /a>{> 2120        switch ( a href="+code=cmd" class="sref">cmd0) {> 2130        case  a href="+code=RTC_EPOCH_READ" class="sref">RTC_EPOCH_READ0:> 2140                return  a href="+code=put_user" class="sref">put_user /a>( a href="+code=epoch" class="sref">epoch0, (unsigned long  a href="+code=__user" class="sref">__user /a> *) a href="+code=arg" class="sref">arg0);> 2150        case  a href="+code=RTC_EPOCH_SET" class="sref">RTC_EPOCH_SET0:> 2160                 spao class="comment">/* Doesn't support before 1900 */ /spaon> 217 /a>                if ( a href="+code=arg" class="sref">arg0 < 1900)> 218 /a>                        return - a href="+code=EINVAL" class="sref">EINVAL0;> 2190                 a href="+code=epoch" class="sref">epoch0 =  a href="+code=arg" class="sref">arg0;> 2200                break;> 2210        default:> 2220                return - a href="+code=ENOIOCTLCMD" class="sref">ENOIOCTLCMD0;> 2230        }> 224 /a>> 2250        return 0;> 2260}> 2270> 228 /a>static int  a href="+code=vr41xx_rtc_alarm_irq_enable" class="sref">vr41xx_rtc_alarm_irq_enable /a>(struct  a href="+code=device" class="sref">device0 * a href="+code=dev" class="sref">dev0, unsigned int  a href="+code=enabled" class="sref">enabled0)> 2290{> 2300         a href="+code=spin_lock_irq" class="sref">spin_lock_irq /a>(& a href="+code=rtc_lock" class="sref">rtc_lock /a>);> 2310        if ( a href="+code=enabled" class="sref">enabled0) {> 2320                if (! a href="+code=alarm_enabled" class="sref">alarm_enabled0) {> 2330                         a href="+code=enable_irq" class="sref">enable_irq /a>( a href="+code=aie_irq" class="sref">aie_irq0);> 2340                         a href="+code=alarm_enabled" class="sref">alarm_enabled0 = 1;> 2350                }> 2360        } else {> 237 /a>                if ( a href="+code=alarm_enabled" class="sref">alarm_enabled0) {> 238 /a>                         a href="+code=disable_irq" class="sref">disable_irq /a>( a href="+code=aie_irq" class="sref">aie_irq0);> 2390                         a href="+code=alarm_enabled" class="sref">alarm_enabled0 = 0;> 2400                }> 2410        }> 2420         a href="+code=spin_unlock_irq" class="sref">spin_unlock_irq /a>(& a href="+code=rtc_lock" class="sref">rtc_lock /a>);> 2430        return 0;> 2440}> 2450> 246 /a>static  a href="+code=irqreturn_t" class="sref">irqreturn_t0  a href="+code=elapsedtimu_interrupt" class="sref">elapsedtimu_interrupt /a>(int  a href="+code=irq" class="sref">irq /a>, void * a href="+code=dev_id" class="sref">dev_id0)> 2470{> 2480        struct  a href="+code=platform_device" class="sref">platform_device0 * a href="+code=pdev" class="sref">pdev0 = (struct  a href="+code=platform_device" class="sref">platform_device0 *) a href="+code=dev_id" class="sref">dev_id0;> 2490        struct  a href="+code=rtc_device" class="sref">rtc_device0 * a href="+code=rtc" class="sref">rtc0 =  a href="+code=platform_get_drvdata" class="sref">platform_get_drvdata /a>( a href="+code=pdev" class="sref">pdev0);> 2500> 2510         a href="+code=rtc2_write" class="sref">rtc2_write /a>( a href="+code=RTCINTREG" class="sref">RTCINTREG /a>,  a href="+code=ELAPSEDTIME_INT" class="sref">ELAPSEDTIME_INT0);> 2520> 2530         a href="+code=rtc_update_irq" class="sref">rtc_update_irq /a>( a href="+code=rtc" class="sref">rtc0, 1,  a href="+code=RTC_AF" class="sref">RTC_AF0);> 254 /a>> 2550        return  a href="+code=IRQ_HANDLED" class="sref">IRQ_HANDLED0;> 2560}> 2570> 258 /a>static  a href="+code=irqreturn_t" class="sref">irqreturn_t0  a href="+code=rtclong1_interrupt" class="sref">rtclong1_interrupt /a>(int  a href="+code=irq" class="sref">irq /a>, void * a href="+code=dev_id" class="sref">dev_id0)> 2590{> 2600        struct  a href="+code=platform_device" class="sref">platform_device0 * a href="+code=pdev" class="sref">pdev0 = (struct  a href="+code=platform_device" class="sref">platform_device0 *) a href="+code=dev_id" class="sref">dev_id0;> 2610        struct  a href="+code=rtc_device" class="sref">rtc_device0 * a href="+code=rtc" class="sref">rtc0 =  a href="+code=platform_get_drvdata" class="sref">platform_get_drvdata /a>( a href="+code=pdev" class="sref">pdev0);> 2620        unsigned long  a href="+code=count" class="sref">count0 =  a href="+code=periodic_count" class="sref">periodic_count0;> 2630> 2640         a href="+code=rtc2_write" class="sref">rtc2_write /a>( a href="+code=RTCINTREG" class="sref">RTCINTREG /a>,  a href="+code=RTCLONG1_INT" class="sref">RTCLONG1_INT0);> 2650> 2660         a href="+code=rtc1_write" class="sref">rtc1_write /a>( a href="+code=RTCL1LREG" class="sref">RTCL1LREG0,  a href="+code=count" class="sref">count0);> 267 /a>         a href="+code=rtc1_write" class="sref">rtc1_write /a>( a href="+code=RTCL1HREG" class="sref">RTCL1HREG0,  a href="+code=count" class="sref">count0 >> 16);> 2680> 2690         a href="+code=rtc_update_irq" class="sref">rtc_update_irq /a>( a href="+code=rtc" class="sref">rtc0, 1,  a href="+code=RTC_PF" class="sref">RTC_PF0);> 2700> 2710        return  a href="+code=IRQ_HANDLED" class="sref">IRQ_HANDLED0;> 2720}> 2730> 274 /a>static const struct  a href="+code=rtc_class_ops" class="sref">rtc_class_ops0  a href="+code=vr41xx_rtc_ops" class="sref">vr41xx_rtc_ops0 = {> 2750        . a href="+code=release" class="sref">release /a>        =  a href="+code=vr41xx_rtc_release" class="sref">vr41xx_rtc_release /a>,> 2760        . a href="+code=ioctl" class="sref">ioctl /a>          =  a href="+code=vr41xx_rtc_ioctl" class="sref">vr41xx_rtc_ioctl /a>,> 2770        . a href="+code=read_timu" class="sref">read_timu /a>      =  a href="+code=vr41xx_rtc_read_timu" class="sref">vr41xx_rtc_read_timu /a>,> 278 /a>        . a href="+code=set_timu" class="sref">set_timu /a>       =  a href="+code=vr41xx_rtc_set_timu" class="sref">vr41xx_rtc_set_timu /a>,> 2790        . a href="+code=read_alarm" class="sref">read_alarm /a>     =  a href="+code=vr41xx_rtc_read_alarm" class="sref">vr41xx_rtc_read_alarm /a>,> 2800        . a href="+code=set_alarm" class="sref">set_alarm /a>      =  a href="+code=vr41xx_rtc_set_alarm" class="sref">vr41xx_rtc_set_alarm /a>,> 2810};> 2820> 283 /a>static int  a href="+code=rtc_probe" class="sref">rtc_probe /a>(struct  a href="+code=platform_device" class="sref">platform_device0 * a href="+code=pdev" class="sref">pdev0)> 284 /a>{> 2850        struct  a href="+code=resource" class="sref">resource0 * a href="+code=res" class="sref">res0;> 2860        struct  a href="+code=rtc_device" class="sref">rtc_device0 * a href="+code=rtc" class="sref">rtc0;> 2870        int  a href="+code=retval" class="sref">retval0;> 2880> 2890        if ( a href="+code=pdev" class="sref">pdev0-> a href="+code=num_resources" class="sref">num_resources0 != 4)> 2900                return - a href="+code=EBUSY" class="sref">EBUSY0;> 2910> 2920         a href="+code=res" class="sref">res0 =  a href="+code=platform_get_resource" class="sref">platform_get_resource /a>( a href="+code=pdev" class="sref">pdev0,  a href="+code=IORESOURCE_MEM" class="sref">IORESOURCE_MEM0, 0);> 2930        if (! a href="+code=res" class="sref">res0)> 2940                return - a href="+code=EBUSY" class="sref">EBUSY0;> 2950> 2960         a href="+code=rtc1_base" class="sref">rtc1_base0 =  a href="+code=ioremap" class="sref">ioremap /a>( a href="+code=res" class="sref">res0-> a href="+code=start" class="sref">start0,  a href="+code=resource_size" class="sref">resource_size /a>( a href="+code=res" class="sref">res0));> 297 /a>        if (! a href="+code=rtc1_base" class="sref">rtc1_base0)> 298 /a>                return - a href="+code=EBUSY" class="sref">EBUSY0;> 2990> 3000         a href="+code=res" class="sref">res0 =  a href="+code=platform_get_resource" class="sref">platform_get_resource /a>( a href="+code=pdev" class="sref">pdev0,  a href="+code=IORESOURCE_MEM" class="sref">IORESOURCE_MEM0, 1);> 3010        if (! a href="+code=res" class="sref">res0) {> 3020                 a href="+code=retval" class="sref">retval0 = - a href="+code=EBUSY" class="sref">EBUSY0;> 3030                goto  a href="+code=err_rtc1_iounmap" class="sref">err_rtc1_iounmap0;> 3040        }> 3050> 3060         a href="+code=rtc2_base" class="sref">rtc2_base0 =  a href="+code=ioremap" class="sref">ioremap /a>( a href="+code=res" class="sref">res0-> a href="+code=start" class="sref">start0,  a href="+code=resource_size" class="sref">resource_size /a>( a href="+code=res" class="sref">res0));> 307 /a>        if (! a href="+code=rtc2_base" class="sref">rtc2_base0) {> 308 /a>                 a href="+code=retval" class="sref">retval0 = - a href="+code=EBUSY" class="sref">EBUSY0;> 3090                goto  a href="+code=err_rtc1_iounmap" class="sref">err_rtc1_iounmap0;> 3100        }> 3110> 3120         a href="+code=rtc" class="sref">rtc0 =  a href="+code=rtc_device_register" class="sref">rtc_device_register /a>( a href="+code=rtc_namu" class="sref">rtc_namu0, & a href="+code=pdev" class="sref">pdev0-> a href="+code=dev" class="sref">dev0, & a href="+code=vr41xx_rtc_ops" class="sref">vr41xx_rtc_ops0,  a href="+code=THIS_MODULE" class="sref">THIS_MODULE0);> 3130        if ( a href="+code=IS_ERR" class="sref">IS_ERR /a>( a href="+code=rtc" class="sref">rtc0)) {> 3140                 a href="+code=retval" class="sref">retval0 =  a href="+code=PTR_ERR" class="sref">PTR_ERR /a>( a href="+code=rtc" class="sref">rtc0);> 3150                goto  a href="+code=err_iounmap_all" class="sref">err_iounmap_all0;> 3160        }> 3170> 318 /a>         a href="+code=rtc" class="sref">rtc0-> a href="+code=max_user_freq" class="sref">max_user_freq0 =  a href="+code=MAX_PERIODIC_RATE" class="sref">MAX_PERIODIC_RATE0;> 3190> 3200         a href="+code=spin_lock_irq" class="sref">spin_lock_irq /a>(& a href="+code=rtc_lock" class="sref">rtc_lock /a>);> 3210> 3220         a href="+code=rtc1_write" class="sref">rtc1_write /a>( a href="+code=ECMPLREG" class="sref">ECMPLREG0, 0);> 3230         a href="+code=rtc1_write" class="sref">rtc1_write /a>( a href="+code=ECMPMREG" class="sref">ECMPMREG0, 0);> 3240         a href="+code=rtc1_write" class="sref">rtc1_write /a>( a href="+code=ECMPHREG" class="sref">ECMPHREG0, 0);> 3250         a href="+code=rtc1_write" class="sref">rtc1_write /a>( a href="+code=RTCL1LREG" class="sref">RTCL1LREG0, 0);> 3260         a href="+code=rtc1_write" class="sref">rtc1_write /a>( a href="+code=RTCL1HREG" class="sref">RTCL1HREG0, 0);> 3270> 328 /a>         a href="+code=spin_unlock_irq" class="sref">spin_unlock_irq /a>(& a href="+code=rtc_lock" class="sref">rtc_lock /a>);> 3290> 3300         a href="+code=aie_irq" class="sref">aie_irq0 =  a href="+code=platform_get_irq" class="sref">platform_get_irq /a>( a href="+code=pdev" class="sref">pdev0, 0);> 3310        if ( a href="+code=aie_irq" class="sref">aie_irq0 <= 0) {> 3320                 a href="+code=retval" class="sref">retval0 = - a href="+code=EBUSY" class="sref">EBUSY0;> 3330                goto  a href="+code=err_device_unregister" class="sref">err_device_unregister0;> 3340        }> 3350> 3360         a href="+code=retval" class="sref">retval0 =  a href="+code=request_irq" class="sref">request_irq /a>( a href="+code=aie_irq" class="sref">aie_irq0,  a href="+code=elapsedtimu_interrupt" class="sref">elapsedtimu_interrupt /a>, 0,> 337 /a>                              spao class="string">"elapsed_timu" /spaon,  a href="+code=pdev" class="sref">pdev0);> 338 /a>        if ( a href="+code=retval" class="sref">retval0 < 0)> 3390                goto  a href="+code=err_device_unregister" class="sref">err_device_unregister0;> 3400> 3410         a href="+code=pie_irq" class="sref">pie_irq0 =  a href="+code=platform_get_irq" class="sref">platform_get_irq /a>( a href="+code=pdev" class="sref">pdev0, 1);> 3420        if ( a href="+code=pie_irq" class="sref">pie_irq0 <= 0)> 3430                goto  a href="+code=err_free_irq" class="sref">err_free_irq0;> 344 /a>> 3450         a href="+code=retval" class="sref">retval0 =  a href="+code=request_irq" class="sref">request_irq /a>( a href="+code=pie_irq" class="sref">pie_irq0,  a href="+code=rtclong1_interrupt" class="sref">rtclong1_interrupt /a>, 0,> 3460                              spao class="string">"rtclong1" /spaon,  a href="+code=pdev" class="sref">pdev0);> 347 /a>        if ( a href="+code=retval" class="sref">retval0 < 0)> 348 /a>                goto  a href="+code=err_free_irq" class="sref">err_free_irq0;> 3490> 3500         a href="+code=platform_set_drvdata" class="sref">platform_set_drvdata /a>( a href="+code=pdev" class="sref">pdev0,  a href="+code=rtc" class="sref">rtc0);> 3510> 3520         a href="+code=disable_irq" class="sref">disable_irq /a>( a href="+code=aie_irq" class="sref">aie_irq0);> 3530         a href="+code=disable_irq" class="sref">disable_irq /a>( a href="+code=pie_irq" class="sref">pie_irq0);> 354 /a>> 3550         a href="+code=printk" class="sref">printk /a>( a href="+code=KERN_INFO" class="sref">KERN_INFO0  spao class="string">"rtc: Real Timu Clock of NEC VR4100 series\n" /spaon);> 3560> 357 /a>        return 0;> 3580> 3590 a href="+code=err_free_irq" class="sref">err_free_irq0:> 3600         a href="+code=free_irq" class="sref">free_irq0( a href="+code=aie_irq" class="sref">aie_irq0,  a href="+code=pdev" class="sref">pdev0);> 3610> 3620 a href="+code=err_device_unregister" class="sref">err_device_unregister0:> 3630         a href="+code=rtc_device_unregister" class="sref">rtc_device_unregister /a>( a href="+code=rtc" class="sref">rtc0);> 364 /a>> 3650 a href="+code=err_iounmap_all" class="sref">err_iounmap_all0:> 3660         a href="+code=iounmap" class="sref">iounmap0( a href="+code=rtc2_base" class="sref">rtc2_base0);> 367 /a>         a href="+code=rtc2_base" class="sref">rtc2_base0 =  a href="+code=NULL" class="sref">NULL0;> 3680> 3690 a href="+code=err_rtc1_iounmap" class="sref">err_rtc1_iounmap0:> 3700         a href="+code=iounmap" class="sref">iounmap0( a href="+code=rtc1_base" class="sref">rtc1_base0);> 3710         a href="+code=rtc1_base" class="sref">rtc1_base0 =  a href="+code=NULL" class="sref">NULL0;> 3720> 3730        return  a href="+code=retval" class="sref">retval0;> 3740}> 3750> 376 /a>static int  a href="+code=rtc_removu" class="sref">rtc_removu0(struct  a href="+code=platform_device" class="sref">platform_device0 * a href="+code=pdev" class="sref">pdev0)> 3770{> 3780        struct  a href="+code=rtc_device" class="sref">rtc_device0 * a href="+code=rtc" class="sref">rtc0;> 3790> 3800         a href="+code=rtc" class="sref">rtc0 =  a href="+code=platform_get_drvdata" class="sref">platform_get_drvdata /a>( a href="+code=pdev" class="sref">pdev0);> 3810        if ( a href="+code=rtc" class="sref">rtc0)> 3820                 a href="+code=rtc_device_unregister" class="sref">rtc_device_unregister /a>( a href="+code=rtc" class="sref">rtc0);> 3830> 3840         a href="+code=platform_set_drvdata" class="sref">platform_set_drvdata /a>( a href="+code=pdev" class="sref">pdev0,  a href="+code=NULL" class="sref">NULL0);> 3850> 3860         a href="+code=free_irq" class="sref">free_irq0( a href="+code=aie_irq" class="sref">aie_irq0,  a href="+code=pdev" class="sref">pdev0);> 387 /a>         a href="+code=free_irq" class="sref">free_irq0( a href="+code=pie_irq" class="sref">pie_irq0,  a href="+code=pdev" class="sref">pdev0);> 388 /a>        if ( a href="+code=rtc1_base" class="sref">rtc1_base0)> 3890                 a href="+code=iounmap" class="sref">iounmap0( a href="+code=rtc1_base" class="sref">rtc1_base0);> 3900        if ( a href="+code=rtc2_base" class="sref">rtc2_base0)> 3910                 a href="+code=iounmap" class="sref">iounmap0( a href="+code=rtc2_base" class="sref">rtc2_base0);> 3920> 3930        return 0;> 3940}> 3950> 3960 spao class="comment">/* work with hotplug and coldplug */ /spaon> 397 /a> a href="+code=MODULE_ALIAS" class="sref">MODULE_ALIAS0( spao class="string">"platform:RTC" /spaon);> 3980> 3990static struct  a href="+code=platform_driver" class="sref">platform_driver0  a href="+code=rtc_platform_driver" class="sref">rtc_platform_driver0 = {> 4000        . a href="+code=probe" class="sref">probe /a>          =  a href="+code=rtc_probe" class="sref">rtc_probe /a>,> 4010        . a href="+code=removu" class="sref">removu0         =  a href="+code=rtc_removu" class="sref">rtc_removu0,> 4020        . a href="+code=driver" class="sref">driver0         = {> 4030                . a href="+code=namu" class="sref">namu0   =  a href="+code=rtc_namu" class="sref">rtc_namu0,> 4040                . a href="+code=owner" class="sref">owner0  =  a href="+code=THIS_MODULE" class="sref">THIS_MODULE0,> 4050        },> 4060};> 4070> 408 /a> a href="+code=module_platform_driver" class="sref">module_platform_driver0( a href="+code=rtc_platform_driver" class="sref">rtc_platform_driver0);> 4090
lxr.linux.no kindly hosted by a href="http://www.redpill-linpro.no">Redpill Linpro AS0, provider of Linux consulting and operations services since 1995.