linux/drivers/rtc/rtc-nuc900.c
<<
.25" ti/spav33 ti/form33 tia .25" t href="../linux+v37.25" tiimg src="../.static/gfx/right.png" alt=">>">.2i/spav33.2ispav class="lxr_search">.25".25" tiinput typ3o2hidden" nam3o2navtarget" e"v33o2">.25" tiinput typ3o2text" nam3o2search" ido2search">.25" tibuttal2typ3o2submit">Search.25" tPrefs3 ti/a>.2i/spav335" t ti/div335" t tiform ac2e"v="ajax+*" method="post" onsubmit="return false;">.2iinput typ3o2hidden" nam3o2ajax_lookup" ido2ajax_lookup" e"v33o2">.5" t ti/form33.5" t tidiv class="headingbottam">3 idiv ido2file_contents"3
t t1i/a>ispav class="comment">/*i/spav33t t2i/a>ispav class="comment"> * Copyright (c) 2008-2009 Nuvotal2technology corpora2e"v.i/spav33t t3i/a>ispav class="comment"> *i/spav33t t4i/a>ispav class="comment"> * Wav ZongShun <mcuos.com@gmail.com>i/spav33t t5i/a>ispav class="comment"> *i/spav33t t6i/a>ispav class="comment"> * This program is free software; you cav redistribute it and/or modifyi/spav33t t7i/a>ispav class="comment"> * it under the2terms of the2GNU General Public License as published byi/spav33t t8i/a>ispav class="comment"> * the2Free Software Founda2e"v;versval22 of the2License.i/spav33t t9i/a>ispav class="comment"> *i/spav33t 4	 sa>ispav class="comment"> */i/spav33t 11i/a>3t 12i/a>#include <linux/module.hi/a>>3t 13i/a>#include <linux/init.hi/a>>3t 14i/a>#include <linux/platform_device.hi/a>>3t 15i/a>#include <linux/slab.hi/a>>3t 16i/a>#include <linux/rtc.hi/a>>3t 17i/a>#include <linux/delay.hi/a>>3t 18i/a>#include <linux/io.hi/a>>3t 19i/a>#include <linux/bcd.hi/a>>3t 20i/a>3t 21i/a>ispav class="comment">/* RTC Control Registers */i/spav33t 22i/a>#definetia href="+code=REG_RTC_INIR" class="sref">REG_RTC_INIRi/a>            0x003t 23i/a>#definetia href="+code=REG_RTC_AER" class="sref">REG_RTC_AERi/a>             0x043t 24i/a>#definetia href="+code=REG_RTC_FCR" class="sref">REG_RTC_FCRi/a>             0x083t 25i/a>#definetia href="+code=REG_RTC_TLR" class="sref">REG_RTC_TLRi/a>             0x0C3t 26i/a>#definetia href="+code=REG_RTC_CLR" class="sref">REG_RTC_CLRi/a>             0x103t 27i/a>#definetia href="+code=REG_RTC_TSSR" class="sref">REG_RTC_TSSRi/a>            0x143t 28i/a>#definetia href="+code=REG_RTC_DWR" class="sref">REG_RTC_DWRi/a>             0x183t 29i/a>#definetia href="+code=REG_RTC_TAR" class="sref">REG_RTC_TARi/a>             0x1C3t 30i/a>#definetia href="+code=REG_RTC_CAR" class="sref">REG_RTC_CARi/a>             0x203t 31i/a>#definetia href="+code=REG_RTC_LIR" class="sref">REG_RTC_LIRi/a>             0x243t 32i/a>#definetia href="+code=REG_RTC_RIER" class="sref">REG_RTC_RIERi/a>            0x283t 33i/a>#definetia href="+code=REG_RTC_RIIR" class="sref">REG_RTC_RIIRi/a>            0x2C3t 34i/a>#definetia href="+code=REG_RTC_TTR" class="sref">REG_RTC_TTRi/a>             0x303t 35i/a>3t 36i/a>#definetia href="+code=RTCSET" class="sref">RTCSETi/a>                  0x013t 37i/a>#definetia href="+code=AERRWENB" class="sref">AERRWENBi/a>                0x100003t 38i/a>#definetia href="+code=INIRRESET" class="sref">INIRRESETi/a>               0xa5eb13573t 39i/a>#definetia href="+code=AERPOWERON" class="sref">AERPOWERONi/a>              0xA9653t 40i/a>#definetia href="+code=AERPOWEROFF" class="sref">AERPOWEROFFi/a>             0x00003t 41i/a>#definetia href="+code=LEAPYEAR" class="sref">LEAPYEARi/a>                0x00013t 42i/a>#definetia href="+code=TICKENB" class="sref">TICKENBi/a>                 0x803t 43i/a>#definetia href="+code=TICKINTENB" class="sref">TICKINTENBi/a>              0x00023t 44i/a>#definetia href="+code=ALARMINTENB" class="sref">ALARMINTENBi/a>             0x00013t 45i/a>#definetia href="+code=MODE24" class="sref">MODE24i/a>                  0x00013t 46i/a>3t 47i/a>structtia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a> {3t 48i/a>        int                    tia href="+code=irq_num" class="sref">irq_numi/a>;3t 49i/a>        voidtia href="+code=__iomem" class="sref">__iomemi/a>            *ia href="+code=rtc_reg" class="sref">rtc_regi/a>;3t 50i/a>        structtia href="+code=rtc_device" class="sref">rtc_devicei/a>       *ia href="+code=rtcdev" class="sref">rtcdevi/a>;3t 51i/a>};3t 52i/a>3t 53i/a>structtia href="+code=nuc900_bcd_time" class="sref">nuc900_bcd_timei/a> {3t 54i/a>        int ia href="+code=bcd_sec" class="sref">bcd_seci/a>;3t 55i/a>        int ia href="+code=bcd_min" class="sref">bcd_mini/a>;3t 56i/a>        int ia href="+code=bcd_hour" class="sref">bcd_houri/a>;3t 57i/a>        int ia href="+code=bcd_mday" class="sref">bcd_mdayi/a>;3t 58i/a>        int ia href="+code=bcd_mon" class="sref">bcd_moni/a>;3t 59i/a>        int ia href="+code=bcd_year" class="sref">bcd_yeari/a>;3t 60i/a>};3t 61i/a>3t 62i/a>statictia href="+code=irqreturn_t" class="sref">irqreturn_ti/a> ia href="+code=nuc900_rtc_interrupt" class="sref">nuc900_rtc_interrupti/a>(int ia href="+code=irq" class="sref">irqi/a>, voidt*ia href="+code=_rtc" class="sref">_rtci/a>)3t 63i/a>{3t 64i/a>        structtia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a> *ia href="+code=rtc" class="sref">rtci/a> =tia href="+code=_rtc" class="sref">_rtci/a>;3t 65i/a>        unsigned longtia href="+code=events" class="sref">eventsi/a> =t0,tia href="+code=rtc_irq" class="sref">rtc_irqi/a>;3t 66i/a>3t 67i/a>        ia href="+code=rtc_irq" class="sref">rtc_irqi/a> =tia href="+code=__raw_readl" class="sref">__raw_readli/a>(ia href="+code=rtc" class="sref">rtci/a>->ia href="+code=rtc_reg" class="sref">rtc_regi/a> +tia href="+code=REG_RTC_RIIR" class="sref">REG_RTC_RIIRi/a>);3t 68i/a>3t 69i/a>        if (ia href="+code=rtc_irq" class="sref">rtc_irqi/a> &tia href="+code=ALARMINTENB" class="sref">ALARMINTENBi/a>) {3t 70i/a>                ia href="+code=rtc_irq" class="sref">rtc_irqi/a> &= ~ia href="+code=ALARMINTENB" class="sref">ALARMINTENBi/a>;3t 71i/a>                ia href="+code=__raw_writel" class="sref">__raw_writeli/a>(ia href="+code=rtc_irq" class="sref">rtc_irqi/a>,tia href="+code=rtc" class="sref">rtci/a>->ia href="+code=rtc_reg" class="sref">rtc_regi/a> +tia href="+code=REG_RTC_RIIR" class="sref">REG_RTC_RIIRi/a>);3t 72i/a>                ia href="+code=events" class="sref">eventsi/a> |=tia href="+code=RTC_AF" class="sref">RTC_AFi/a> |tia href="+code=RTC_IRQF" class="sref">RTC_IRQFi/a>;3t 73i/a>        }3t 74i/a>3t 75i/a>        if (ia href="+code=rtc_irq" class="sref">rtc_irqi/a> &tia href="+code=TICKINTENB" class="sref">TICKINTENBi/a>) {3t 76i/a>                ia href="+code=rtc_irq" class="sref">rtc_irqi/a> &= ~ia href="+code=TICKINTENB" class="sref">TICKINTENBi/a>;3t 77i/a>                ia href="+code=__raw_writel" class="sref">__raw_writeli/a>(ia href="+code=rtc_irq" class="sref">rtc_irqi/a>,tia href="+code=rtc" class="sref">rtci/a>->ia href="+code=rtc_reg" class="sref">rtc_regi/a> +tia href="+code=REG_RTC_RIIR" class="sref">REG_RTC_RIIRi/a>);3t 78i/a>                ia href="+code=events" class="sref">eventsi/a> |=tia href="+code=RTC_UF" class="sref">RTC_UFi/a> |tia href="+code=RTC_IRQF" class="sref">RTC_IRQFi/a>;3t 79i/a>        }3t 80i/a>3t 81i/a>        ia href="+code=rtc_update_irq" class="sref">rtc_update_irqi/a>(ia href="+code=rtc" class="sref">rtci/a>->ia href="+code=rtcdev" class="sref">rtcdevi/a>, 1,tia href="+code=events" class="sref">eventsi/a>);3t 82i/a>3t 83i/a>        return ia href="+code=IRQ_HANDLED" class="sref">IRQ_HANDLEDi/a>;3t 84i/a>}3t 85i/a>3t 86i/a>statictint *ia href="+code=check_rtc_access_enable" class="sref">check_rtc_access_enablei/a>(structtia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a> *ia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a>)3t 87i/a>{3t 88i/a>        unsigned int ia href="+code=timeout" class="sref">timeouti/a> =t0x1000;3t 89i/a>        ia href="+code=__raw_writel" class="sref">__raw_writeli/a>(ia href="+code=INIRRESET" class="sref">INIRRESETi/a>,tia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a>->ia href="+code=rtc_reg" class="sref">rtc_regi/a> +tia href="+code=REG_RTC_INIR" class="sref">REG_RTC_INIRi/a>);3t 90i/a>3t 91i/a>        ia href="+code=mdelay" class="sref">mdelayi/a>(10);3t 92i/a>3t 93i/a>        ia href="+code=__raw_writel" class="sref">__raw_writeli/a>(ia href="+code=AERPOWERON" class="sref">AERPOWERONi/a>,tia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a>->ia href="+code=rtc_reg" class="sref">rtc_regi/a> +tia href="+code=REG_RTC_AER" class="sref">REG_RTC_AERi/a>);3t 94i/a>3t 95i/a>        while (!(ia href="+code=__raw_readl" class="sref">__raw_readli/a>(ia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a>->ia href="+code=rtc_reg" class="sref">rtc_regi/a> +tia href="+code=REG_RTC_AER" class="sref">REG_RTC_AERi/a>) &tia href="+code=AERRWENB" class="sref">AERRWENBi/a>)3t 96i/a>                                                                &&tia href="+code=timeout" class="sref">timeouti/a>--)3t 97i/a>                ia href="+code=mdelay" class="sref">mdelayi/a>(1);3t 98i/a>3t 99i/a>        if (!ia href="+code=timeout" class="sref">timeouti/a>)3t100i/a>                return ia href="+code=ERR_PTR" class="sref">ERR_PTRi/a>(-ia href="+code=EPERM" class="sref">EPERMi/a>);3t101i/a>3t102i/a>        return 0;3t103i/a>}3t104i/a>3t105i/a>statictint ia href="+code=nuc900_rtc_bcd2bin" class="sref">nuc900_rtc_bcd2bini/a>(unsigned int ia href="+code=timereg" class="sref">timeregi/a>,3t106i/a>                                unsigned int ia href="+code=calreg" class="sref">calregi/a>,tstructtia href="+code=rtc_time" class="sref">rtc_timei/a> *ia href="+code=tm" class="sref">tmi/a>)3t107i/a>{3t108i/a>        ia href="+code=tm" class="sref">tmi/a>->ia href="+code=tm_mday" class="sref">tm_mdayi/a>     =tia href="+code=bcd2bin" class="sref">bcd2bini/a>(ia href="+code=calreg" class="sref">calregi/a> >> 0);3t109i/a>        ia href="+code=tm" class="sref">tmi/a>->ia href="+code=tm_mon" class="sref">tm_moni/a>      =tia href="+code=bcd2bin" class="sref">bcd2bini/a>(ia href="+code=calreg" class="sref">calregi/a> >> 8);3t110i/a>        ia href="+code=tm" class="sref">tmi/a>->ia href="+code=tm_year" class="sref">tm_yeari/a>     =tia href="+code=bcd2bin" class="sref">bcd2bini/a>(ia href="+code=calreg" class="sref">calregi/a> >> 16) +t100;3t111i/a>3t112i/a>        ia href="+code=tm" class="sref">tmi/a>->ia href="+code=tm_sec" class="sref">tm_seci/a>      =tia href="+code=bcd2bin" class="sref">bcd2bini/a>(ia href="+code=timereg" class="sref">timeregi/a> >> 0);3t113i/a>        ia href="+code=tm" class="sref">tmi/a>->ia href="+code=tm_min" class="sref">tm_mini/a>      =tia href="+code=bcd2bin" class="sref">bcd2bini/a>(ia href="+code=timereg" class="sref">timeregi/a> >> 8);3t114i/a>        ia href="+code=tm" class="sref">tmi/a>->ia href="+code=tm_hour" class="sref">tm_houri/a>     =tia href="+code=bcd2bin" class="sref">bcd2bini/a>(ia href="+code=timereg" class="sref">timeregi/a> >> 16);3t115i/a>3t116i/a>        return ia href="+code=rtc_valid_tm" class="sref">rtc_valid_tmi/a>(ia href="+code=tm" class="sref">tmi/a>);3t117i/a>}3t118i/a>3t119i/a>statictvoidtia href="+code=nuc900_rtc_bin2bcd" class="sref">nuc900_rtc_bin2bcdi/a>(structtia href="+code=device" class="sref">devicei/a> *ia href="+code=dev" class="sref">devi/a>, structtia href="+code=rtc_time" class="sref">rtc_timei/a> *ia href="+code=settm" class="sref">settmi/a>,3t120i/a>                                                structtia href="+code=nuc900_bcd_time" class="sref">nuc900_bcd_timei/a> *ia href="+code=gettm" class="sref">gettmi/a>)3t121i/a>{3t122i/a>        ia href="+code=gettm" class="sref">gettmi/a>->ia href="+code=bcd_mday" class="sref">bcd_mdayi/a> =tia href="+code=bin2bcd" class="sref">bin2bcdi/a>(ia href="+code=settm" class="sref">settmi/a>->ia href="+code=tm_mday" class="sref">tm_mdayi/a>) << 0;3t123i/a>        ia href="+code=gettm" class="sref">gettmi/a>->ia href="+code=bcd_mon" class="sref">bcd_moni/a>  =tia href="+code=bin2bcd" class="sref">bin2bcdi/a>(ia href="+code=settm" class="sref">settmi/a>->ia href="+code=tm_mon" class="sref">tm_moni/a>) << 8;3t124i/a>3t125i/a>        if (ia href="+code=settm" class="sref">settmi/a>->ia href="+code=tm_year" class="sref">tm_yeari/a> < 100) {3t126i/a>                ia href="+code=dev_warn" class="sref">dev_warni/a>(ia href="+code=dev" class="sref">devi/a>, ispav class="string">"The year will be between 1970-1999, right?\n"i/spav3);3t127i/a>                ia href="+code=gettm" class="sref">gettmi/a>->ia href="+code=bcd_year" class="sref">bcd_yeari/a> =tia href="+code=bin2bcd" class="sref">bin2bcdi/a>(ia href="+code=settm" class="sref">settmi/a>->ia href="+code=tm_year" class="sref">tm_yeari/a>) << 16;3t128i/a>        } else {3t129i/a>                ia href="+code=gettm" class="sref">gettmi/a>->ia href="+code=bcd_year" class="sref">bcd_yeari/a> =tia href="+code=bin2bcd" class="sref">bin2bcdi/a>(ia href="+code=settm" class="sref">settmi/a>->ia href="+code=tm_year" class="sref">tm_yeari/a> - 100) << 16;3t130i/a>        }3t131i/a>3t132i/a>        ia href="+code=gettm" class="sref">gettmi/a>->ia href="+code=bcd_sec" class="sref">bcd_seci/a>  =tia href="+code=bin2bcd" class="sref">bin2bcdi/a>(ia href="+code=settm" class="sref">settmi/a>->ia href="+code=tm_sec" class="sref">tm_seci/a>) << 0;3t133i/a>        ia href="+code=gettm" class="sref">gettmi/a>->ia href="+code=bcd_min" class="sref">bcd_mini/a>  =tia href="+code=bin2bcd" class="sref">bin2bcdi/a>(ia href="+code=settm" class="sref">settmi/a>->ia href="+code=tm_min" class="sref">tm_mini/a>) << 8;3t134i/a>        ia href="+code=gettm" class="sref">gettmi/a>->ia href="+code=bcd_hour" class="sref">bcd_houri/a> =tia href="+code=bin2bcd" class="sref">bin2bcdi/a>(ia href="+code=settm" class="sref">settmi/a>->ia href="+code=tm_hour" class="sref">tm_houri/a>) << 16;3t135i/a>}3t136i/a>3t137i/a>statictint ia href="+code=nuc900_alarm_irq_enable" class="sref">nuc900_alarm_irq_enablei/a>(structtia href="+code=device" class="sref">devicei/a> *ia href="+code=dev" class="sref">devi/a>, unsigned int ia href="+code=enabled" class="sref">enabledi/a>)3t138i/a>{3t139i/a>        structtia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a> *ia href="+code=rtc" class="sref">rtci/a> =tia href="+code=dev_get_drvdata" class="sref">dev_get_drvdatai/a>(ia href="+code=dev" class="sref">devi/a>);3t140i/a>3t141i/a>        if (ia href="+code=enabled" class="sref">enabledi/a>)3t142i/a>                ia href="+code=__raw_writel" class="sref">__raw_writeli/a>(ia href="+code=__raw_readl" class="sref">__raw_readli/a>(ia href="+code=rtc" class="sref">rtci/a>->ia href="+code=rtc_reg" class="sref">rtc_regi/a> +tia href="+code=REG_RTC_RIER" class="sref">REG_RTC_RIERi/a>)|3t143i/a>                                (ia href="+code=ALARMINTENB" class="sref">ALARMINTENBi/a>),tia href="+code=rtc" class="sref">rtci/a>->ia href="+code=rtc_reg" class="sref">rtc_regi/a> +tia href="+code=REG_RTC_RIER" class="sref">REG_RTC_RIERi/a>);3t144i/a>        else3t145i/a>                ia href="+code=__raw_writel" class="sref">__raw_writeli/a>(ia href="+code=__raw_readl" class="sref">__raw_readli/a>(ia href="+code=rtc" class="sref">rtci/a>->ia href="+code=rtc_reg" class="sref">rtc_regi/a> +tia href="+code=REG_RTC_RIER" class="sref">REG_RTC_RIERi/a>)&3t146i/a>                                (~ia href="+code=ALARMINTENB" class="sref">ALARMINTENBi/a>),tia href="+code=rtc" class="sref">rtci/a>->ia href="+code=rtc_reg" class="sref">rtc_regi/a> +tia href="+code=REG_RTC_RIER" class="sref">REG_RTC_RIERi/a>);3t147i/a>3t148i/a>        return 0;3t149i/a>}3t150i/a>3t151i/a>statictint ia href="+code=nuc900_rtc_read_time" class="sref">nuc900_rtc_read_timei/a>(structtia href="+code=device" class="sref">devicei/a> *ia href="+code=dev" class="sref">devi/a>, structtia href="+code=rtc_time" class="sref">rtc_timei/a> *ia href="+code=tm" class="sref">tmi/a>)3t152i/a>{3t153i/a>        structtia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a> *ia href="+code=rtc" class="sref">rtci/a> =tia href="+code=dev_get_drvdata" class="sref">dev_get_drvdatai/a>(ia href="+code=dev" class="sref">devi/a>);3t154i/a>        unsigned int ia href="+code=timeval" class="sref">timevali/a>, ia href="+code=clrval" class="sref">clrvali/a>;3t155i/a>3t156i/a>        ia href="+code=timeval" class="sref">timevali/a> =tia href="+code=__raw_readl" class="sref">__raw_readli/a>(ia href="+code=rtc" class="sref">rtci/a>->ia href="+code=rtc_reg" class="sref">rtc_regi/a> +tia href="+code=REG_RTC_TLR" class="sref">REG_RTC_TLRi/a>);3t157i/a>        ia href="+code=clrval" class="sref">clrvali/a>  =tia href="+code=__raw_readl" class="sref">__raw_readli/a>(ia href="+code=rtc" class="sref">rtci/a>->ia href="+code=rtc_reg" class="sref">rtc_regi/a> +tia href="+code=REG_RTC_CLR" class="sref">REG_RTC_CLRi/a>);3t158i/a>3t159i/a>        return ia href="+code=nuc900_rtc_bcd2bin" class="sref">nuc900_rtc_bcd2bini/a>(ia href="+code=timeval" class="sref">timevali/a>, ia href="+code=clrval" class="sref">clrvali/a>, ia href="+code=tm" class="sref">tmi/a>);3t160i/a>}3t161i/a>3t162i/a>statictint ia href="+code=nuc900_rtc_set_time" class="sref">nuc900_rtc_set_timei/a>(structtia href="+code=device" class="sref">devicei/a> *ia href="+code=dev" class="sref">devi/a>, structtia href="+code=rtc_time" class="sref">rtc_timei/a> *ia href="+code=tm" class="sref">tmi/a>)3t163i/a>{3t164i/a>        structtia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a> *ia href="+code=rtc" class="sref">rtci/a> =tia href="+code=dev_get_drvdata" class="sref">dev_get_drvdatai/a>(ia href="+code=dev" class="sref">devi/a>);3t165i/a>        structtia href="+code=nuc900_bcd_time" class="sref">nuc900_bcd_timei/a> ia href="+code=gettm" class="sref">gettmi/a>;3t166i/a>        unsigned longtia href="+code=val" class="sref">vali/a>;3t167i/a>        int *ia href="+code=err" class="sref">erri/a>;3t168i/a>3t169i/a>        ia href="+code=nuc900_rtc_bin2bcd" class="sref">nuc900_rtc_bin2bcdi/a>(ia href="+code=dev" class="sref">devi/a>, ia href="+code=tm" class="sref">tmi/a>, &ia href="+code=gettm" class="sref">gettmi/a>);3t170i/a>3t171i/a>        ia href="+code=err" class="sref">erri/a> =tia href="+code=check_rtc_access_enable" class="sref">check_rtc_access_enablei/a>(ia href="+code=rtc" class="sref">rtci/a>);3t172i/a>        if (ia href="+code=IS_ERR" class="sref">IS_ERRi/a>(ia href="+code=err" class="sref">erri/a>))3t173i/a>                return ia href="+code=PTR_ERR" class="sref">PTR_ERRi/a>(ia href="+code=err" class="sref">erri/a>);3t174i/a>3t175i/a>        ia href="+code=val" class="sref">vali/a> =tia href="+code=gettm" class="sref">gettmi/a>.ia href="+code=bcd_mday" class="sref">bcd_mdayi/a> |tia href="+code=gettm" class="sref">gettmi/a>.ia href="+code=bcd_mon" class="sref">bcd_moni/a> |tia href="+code=gettm" class="sref">gettmi/a>.ia href="+code=bcd_year" class="sref">bcd_yeari/a>;3t176i/a>        ia href="+code=__raw_writel" class="sref">__raw_writeli/a>(ia href="+code=val" class="sref">vali/a>,tia href="+code=rtc" class="sref">rtci/a>->ia href="+code=rtc_reg" class="sref">rtc_regi/a> +tia href="+code=REG_RTC_CLR" class="sref">REG_RTC_CLRi/a>);3t177i/a>3t178i/a>        ia href="+code=val" class="sref">vali/a> =tia href="+code=gettm" class="sref">gettmi/a>.ia href="+code=bcd_sec" class="sref">bcd_seci/a> |tia href="+code=gettm" class="sref">gettmi/a>.ia href="+code=bcd_min" class="sref">bcd_mini/a> |tia href="+code=gettm" class="sref">gettmi/a>.ia href="+code=bcd_hour" class="sref">bcd_houri/a>;3t179i/a>        ia href="+code=__raw_writel" class="sref">__raw_writeli/a>(ia href="+code=val" class="sref">vali/a>,tia href="+code=rtc" class="sref">rtci/a>->ia href="+code=rtc_reg" class="sref">rtc_regi/a> +tia href="+code=REG_RTC_TLR" class="sref">REG_RTC_TLRi/a>);3t180i/a>3t181i/a>        return 0;3t182i/a>}3t183i/a>3t184i/a>statictint ia href="+code=nuc900_rtc_read_alarm" class="sref">nuc900_rtc_read_alarmi/a>(structtia href="+code=device" class="sref">devicei/a> *ia href="+code=dev" class="sref">devi/a>, structtia href="+code=rtc_wkalrm" class="sref">rtc_wkalrmi/a> *ia href="+code=alrm" class="sref">alrmi/a>)3t185i/a>{3t186i/a>        structtia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a> *ia href="+code=rtc" class="sref">rtci/a> =tia href="+code=dev_get_drvdata" class="sref">dev_get_drvdatai/a>(ia href="+code=dev" class="sref">devi/a>);3t187i/a>        unsigned int ia href="+code=timeval" class="sref">timevali/a>, ia href="+code=carval" class="sref">carvali/a>;3t188i/a>3t189i/a>        ia href="+code=timeval" class="sref">timevali/a> =tia href="+code=__raw_readl" class="sref">__raw_readli/a>(ia href="+code=rtc" class="sref">rtci/a>->ia href="+code=rtc_reg" class="sref">rtc_regi/a> +tia href="+code=REG_RTC_TAR" class="sref">REG_RTC_TARi/a>);3t190i/a>        ia href="+code=carval" class="sref">carvali/a>  =tia href="+code=__raw_readl" class="sref">__raw_readli/a>(ia href="+code=rtc" class="sref">rtci/a>->ia href="+code=rtc_reg" class="sref">rtc_regi/a> +tia href="+code=REG_RTC_CAR" class="sref">REG_RTC_CARi/a>);3t191i/a>3t192i/a>        return ia href="+code=nuc900_rtc_bcd2bin" class="sref">nuc900_rtc_bcd2bini/a>(ia href="+code=timeval" class="sref">timevali/a>, ia href="+code=carval" class="sref">carvali/a>, &ia href="+code=alrm" class="sref">alrmi/a>->ia href="+code=time" class="sref">timei/a>);3t193i/a>}3t194i/a>3t195i/a>statictint ia href="+code=nuc900_rtc_set_alarm" class="sref">nuc900_rtc_set_alarmi/a>(structtia href="+code=device" class="sref">devicei/a> *ia href="+code=dev" class="sref">devi/a>, structtia href="+code=rtc_wkalrm" class="sref">rtc_wkalrmi/a> *ia href="+code=alrm" class="sref">alrmi/a>)3t196i/a>{3t197i/a>        structtia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a> *ia href="+code=rtc" class="sref">rtci/a> =tia href="+code=dev_get_drvdata" class="sref">dev_get_drvdatai/a>(ia href="+code=dev" class="sref">devi/a>);3t198i/a>        structtia href="+code=nuc900_bcd_time" class="sref">nuc900_bcd_timei/a> ia href="+code=tm" class="sref">tmi/a>;3t199i/a>        unsigned longtia href="+code=val" class="sref">vali/a>;3t200i/a>        int *ia href="+code=err" class="sref">erri/a>;3t201i/a>3t202i/a>        ia href="+code=nuc900_rtc_bin2bcd" class="sref">nuc900_rtc_bin2bcdi/a>(ia href="+code=dev" class="sref">devi/a>, &ia href="+code=alrm" class="sref">alrmi/a>->ia href="+code=time" class="sref">timei/a>, &ia href="+code=tm" class="sref">tmi/a>);3t203i/a>3t204i/a>        ia href="+code=err" class="sref">erri/a> =tia href="+code=check_rtc_access_enable" class="sref">check_rtc_access_enablei/a>(ia href="+code=rtc" class="sref">rtci/a>);3t205i/a>        if (ia href="+code=IS_ERR" class="sref">IS_ERRi/a>(ia href="+code=err" class="sref">erri/a>))3t206i/a>                return ia href="+code=PTR_ERR" class="sref">PTR_ERRi/a>(ia href="+code=err" class="sref">erri/a>);3t207i/a>3t208i/a>        ia href="+code=val" class="sref">vali/a> =tia href="+code=tm" class="sref">tmi/a>.ia href="+code=bcd_mday" class="sref">bcd_mdayi/a> |tia href="+code=tm" class="sref">tmi/a>.ia href="+code=bcd_mon" class="sref">bcd_moni/a> |tia href="+code=tm" class="sref">tmi/a>.ia href="+code=bcd_year" class="sref">bcd_yeari/a>;3t209i/a>        ia href="+code=__raw_writel" class="sref">__raw_writeli/a>(ia href="+code=val" class="sref">vali/a>,tia href="+code=rtc" class="sref">rtci/a>->ia href="+code=rtc_reg" class="sref">rtc_regi/a> +tia href="+code=REG_RTC_CAR" class="sref">REG_RTC_CARi/a>);3t210i/a>3t211i/a>        ia href="+code=val" class="sref">vali/a> =tia href="+code=tm" class="sref">tmi/a>.ia href="+code=bcd_sec" class="sref">bcd_seci/a> |tia href="+code=tm" class="sref">tmi/a>.ia href="+code=bcd_min" class="sref">bcd_mini/a> |tia href="+code=tm" class="sref">tmi/a>.ia href="+code=bcd_hour" class="sref">bcd_houri/a>;3t212i/a>        ia href="+code=__raw_writel" class="sref">__raw_writeli/a>(ia href="+code=val" class="sref">vali/a>,tia href="+code=rtc" class="sref">rtci/a>->ia href="+code=rtc_reg" class="sref">rtc_regi/a> +tia href="+code=REG_RTC_TAR" class="sref">REG_RTC_TARi/a>);3t213i/a>3t214i/a>        return 0;3t215i/a>}3t216i/a>3t217i/a>statictstructtia href="+code=rtc_class_ops" class="sref">rtc_class_opsi/a> ia href="+code=nuc900_rtc_ops" class="sref">nuc900_rtc_opsi/a> =t{3t218i/a>        .ia href="+code=read_time" class="sref">read_timei/a> =tia href="+code=nuc900_rtc_read_time" class="sref">nuc900_rtc_read_timei/a>,3t219i/a>        .ia href="+code=set_time" class="sref">set_timei/a> =tia href="+code=nuc900_rtc_set_time" class="sref">nuc900_rtc_set_timei/a>,3t220i/a>        .ia href="+code=read_alarm" class="sref">read_alarmi/a> =tia href="+code=nuc900_rtc_read_alarm" class="sref">nuc900_rtc_read_alarmi/a>,3t221i/a>        .ia href="+code=set_alarm" class="sref">set_alarmi/a> =tia href="+code=nuc900_rtc_set_alarm" class="sref">nuc900_rtc_set_alarmi/a>,3t222i/a>        .ia href="+code=alarm_irq_enable" class="sref">alarm_irq_enablei/a> =tia href="+code=nuc900_alarm_irq_enable" class="sref">nuc900_alarm_irq_enablei/a>,3t223i/a>};3t224i/a>3t225i/a>statictint ia href="+code=__devinit" class="sref">__deviniti/a> ia href="+code=nuc900_rtc_probe" class="sref">nuc900_rtc_probei/a>(structtia href="+code=platform_device" class="sref">platform_devicei/a> *ia href="+code=pdev" class="sref">pdevi/a>)3t226i/a>{3t227i/a>        structtia href="+code=resource" class="sref">resourcei/a> *ia href="+code=res" class="sref">resi/a>;3t228i/a>        structtia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a> *ia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a>;3t229i/a>        int ia href="+code=err" class="sref">erri/a> =t0;3t230i/a>3t231i/a>        ia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a> =tia href="+code=kzalloc" class="sref">kzalloci/a>(sizeof(structtia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a>),tia href="+code=GFP_KERNEL" class="sref">GFP_KERNELi/a>);3t232i/a>        if (!ia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a>)t{3t233i/a>                ia href="+code=dev_err" class="sref">dev_erri/a>(&ia href="+code=pdev" class="sref">pdevi/a>->ia href="+code=dev" class="sref">devi/a>, ispav class="string">"kzalloc nuc900_rtc failed\n"i/spav3);3t234i/a>                return -ia href="+code=ENOMEM" class="sref">ENOMEMi/a>;3t235i/a>        }3t236i/a>        ia href="+code=res" class="sref">resi/a> =tia href="+code=platform_get_resource" class="sref">platform_get_resourcei/a>(ia href="+code=pdev" class="sref">pdevi/a>,tia href="+code=IORESOURCE_MEM" class="sref">IORESOURCE_MEMi/a>,t0);3t237i/a>        if (!ia href="+code=res" class="sref">resi/a>)t{3t238i/a>                ia href="+code=dev_err" class="sref">dev_erri/a>(&ia href="+code=pdev" class="sref">pdevi/a>->ia href="+code=dev" class="sref">devi/a>, ispav class="string">"platform_get_resource failed\n"i/spav3);3t239i/a>                ia href="+code=err" class="sref">erri/a> =t-ia href="+code=ENXIO" class="sref">ENXIOi/a>;3t240i/a>                goto ia href="+code=fail1" class="sref">fail1i/a>;3t241i/a>        }3t242i/a>3t243i/a>        if (!ia href="+code=request_mem_region" class="sref">request_mem_regioni/a>(ia href="+code=res" class="sref">resi/a>->ia href="+code=start" class="sref">starti/a>,tia href="+code=resource_size" class="sref">resource_sizei/a>(ia href="+code=res" class="sref">resi/a>),3t244i/a>                                ia href="+code=pdev" class="sref">pdevi/a>->ia href="+code=nam3" class="sref">namei/a>))t{3t245i/a>                ia href="+code=dev_err" class="sref">dev_erri/a>(&ia href="+code=pdev" class="sref">pdevi/a>->ia href="+code=dev" class="sref">devi/a>, ispav class="string">"request_mem_region failed\n"i/spav3);3t246i/a>                ia href="+code=err" class="sref">erri/a> =t-ia href="+code=EBUSY" class="sref">EBUSYi/a>;3t247i/a>                goto ia href="+code=fail1" class="sref">fail1i/a>;3t248i/a>        }3t249i/a>3t250i/a>        ia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a>->ia href="+code=rtc_reg" class="sref">rtc_regi/a> =tia href="+code=ioremap" class="sref">ioremapi/a>(ia href="+code=res" class="sref">resi/a>->ia href="+code=start" class="sref">starti/a>,tia href="+code=resource_size" class="sref">resource_sizei/a>(ia href="+code=res" class="sref">resi/a>));3t251i/a>        if (!ia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a>->ia href="+code=rtc_reg" class="sref">rtc_regi/a>)t{3t252i/a>                ia href="+code=dev_err" class="sref">dev_erri/a>(&ia href="+code=pdev" class="sref">pdevi/a>->ia href="+code=dev" class="sref">devi/a>, ispav class="string">"ioremap rtc_reg failed\n"i/spav3);3t253i/a>                ia href="+code=err" class="sref">erri/a> =t-ia href="+code=ENOMEM" class="sref">ENOMEMi/a>;3t254i/a>                goto ia href="+code=fail2" class="sref">fail2i/a>;3t255i/a>        }3t256i/a>3t257i/a>        ia href="+code=platform_set_drvdata" class="sref">platform_set_drvdatai/a>(ia href="+code=pdev" class="sref">pdevi/a>,tia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a>);3t258i/a>3t259i/a>        ia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a>->ia href="+code=rtcdev" class="sref">rtcdevi/a> =tia href="+code=rtc_device_register" class="sref">rtc_device_registeri/a>(ia href="+code=pdev" class="sref">pdevi/a>->ia href="+code=nam3" class="sref">namei/a>, &ia href="+code=pdev" class="sref">pdevi/a>->ia href="+code=dev" class="sref">devi/a>,3t260i/a>                                                &ia href="+code=nuc900_rtc_ops" class="sref">nuc900_rtc_opsi/a>,tia href="+code=THIS_MODULE" class="sref">THIS_MODULEi/a>);3t261i/a>        if (ia href="+code=IS_ERR" class="sref">IS_ERRi/a>(ia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a>->ia href="+code=rtcdev" class="sref">rtcdevi/a>))t{3t262i/a>                ia href="+code=dev_err" class="sref">dev_erri/a>(&ia href="+code=pdev" class="sref">pdevi/a>->ia href="+code=dev" class="sref">devi/a>, ispav class="string">"rtc device register failed\n"i/spav3);3t263i/a>                ia href="+code=err" class="sref">erri/a> =tia href="+code=PTR_ERR" class="sref">PTR_ERRi/a>(ia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a>->ia href="+code=rtcdev" class="sref">rtcdevi/a>);3t264i/a>                goto ia href="+code=fail3" class="sref">fail3i/a>;3t265i/a>        }3t266i/a>3t267i/a>        ia href="+code=__raw_writel" class="sref">__raw_writeli/a>(ia href="+code=__raw_readl" class="sref">__raw_readli/a>(ia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a>->ia href="+code=rtc_reg" class="sref">rtc_regi/a> +tia href="+code=REG_RTC_TSSR" class="sref">REG_RTC_TSSRi/a>)t|tia href="+code=MODE24" class="sref">MODE24i/a>,3t268i/a>                                        ia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a>->ia href="+code=rtc_reg" class="sref">rtc_regi/a> +tia href="+code=REG_RTC_TSSR" class="sref">REG_RTC_TSSRi/a>);3t269i/a>3t270i/a>        ia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a>->ia href="+code=irq_num" class="sref">irq_numi/a> =tia href="+code=platform_get_irq" class="sref">platform_get_irqi/a>(ia href="+code=pdev" class="sref">pdevi/a>,t0);3t271i/a>        if (ia href="+code=request_irq" class="sref">request_irqi/a>(ia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a>->ia href="+code=irq_num" class="sref">irq_numi/a>,tia href="+code=nuc900_rtc_interrupt" class="sref">nuc900_rtc_interrupti/a>,3t272i/a>                                0, ispav class="string">"nuc900rtc"i/spav3,tia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a>))t{3t273i/a>                ia href="+code=dev_err" class="sref">dev_erri/a>(&ia href="+code=pdev" class="sref">pdevi/a>->ia href="+code=dev" class="sref">devi/a>, ispav class="string">"NUC900 RTC request irq failed\n"i/spav3);3t274i/a>                ia href="+code=err" class="sref">erri/a> =t-ia href="+code=EBUSY" class="sref">EBUSYi/a>;3t275i/a>                goto ia href="+code=fail4" class="sref">fail4i/a>;3t276i/a>        }3t277i/a>3t278i/a>        return 0;3t279i/a>3t280i/a>ia href="+code=fail4" class="sref">fail4i/a>:  ia href="+code=rtc_device_unregister" class="sref">rtc_device_unregisteri/a>(ia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a>->ia href="+code=rtcdev" class="sref">rtcdevi/a>);3t281i/a>ia href="+code=fail3" class="sref">fail3i/a>:  ia href="+code=iounmap" class="sref">iounmapi/a>(ia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a>->ia href="+code=rtc_reg" class="sref">rtc_regi/a>);3t282i/a>ia href="+code=fail2" class="sref">fail2i/a>:  ia href="+code=release_mem_region" class="sref">release_mem_regioni/a>(ia href="+code=res" class="sref">resi/a>->ia href="+code=start" class="sref">starti/a>,tia href="+code=resource_size" class="sref">resource_sizei/a>(ia href="+code=res" class="sref">resi/a>));3t283i/a>ia href="+code=fail1" class="sref">fail1i/a>:  ia href="+code=kfree" class="sref">kfreei/a>(ia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a>);3t284i/a>        return ia href="+code=err" class="sref">erri/a>;3t285i/a>}3t286i/a>3t287i/a>statictint ia href="+code=__devexit" class="sref">__devexiti/a> ia href="+code=nuc900_rtc_remove" class="sref">nuc900_rtc_removei/a>(structtia href="+code=platform_device" class="sref">platform_devicei/a> *ia href="+code=pdev" class="sref">pdevi/a>)3t288i/a>{3t289i/a>        structtia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a> *ia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a> =tia href="+code=platform_get_drvdata" class="sref">platform_get_drvdatai/a>(ia href="+code=pdev" class="sref">pdevi/a>);3t290i/a>        structtia href="+code=resource" class="sref">resourcei/a> *ia href="+code=res" class="sref">resi/a>;3t291i/a>3t292i/a>        ia href="+code=free_irq" class="sref">free_irqi/a>(ia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a>->ia href="+code=irq_num" class="sref">irq_numi/a>,tia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a>);3t293i/a>        ia href="+code=rtc_device_unregister" class="sref">rtc_device_unregisteri/a>(ia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a>->ia href="+code=rtcdev" class="sref">rtcdevi/a>);3t294i/a>        ia href="+code=iounmap" class="sref">iounmapi/a>(ia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a>->ia href="+code=rtc_reg" class="sref">rtc_regi/a>);3t295i/a>3t296i/a>        ia href="+code=res" class="sref">resi/a> =tia href="+code=platform_get_resource" class="sref">platform_get_resourcei/a>(ia href="+code=pdev" class="sref">pdevi/a>,tia href="+code=IORESOURCE_MEM" class="sref">IORESOURCE_MEMi/a>,t0);3t297i/a>        ia href="+code=release_mem_region" class="sref">release_mem_regioni/a>(ia href="+code=res" class="sref">resi/a>->ia href="+code=start" class="sref">starti/a>,tia href="+code=resource_size" class="sref">resource_sizei/a>(ia href="+code=res" class="sref">resi/a>));3t298i/a>3t299i/a>        ia href="+code=kfree" class="sref">kfreei/a>(ia href="+code=nuc900_rtc" class="sref">nuc900_rtci/a>);3t300i/a>3t301i/a>        ia href="+code=platform_set_drvdata" class="sref">platform_set_drvdatai/a>(ia href="+code=pdev" class="sref">pdevi/a>,tia href="+code=NULL" class="sref">NULLi/a>);3t302i/a>3t303i/a>        return 0;3t304i/a>}3t305i/a>3t306i/a>statictstructtia href="+code=platform_driver" class="sref">platform_driveri/a> ia href="+code=nuc900_rtc_driver" class="sref">nuc900_rtc_driveri/a> =t{3t307i/a>        .ia href="+code=remove" class="sref">removei/a>         =tia href="+code=__devexit_p" class="sref">__devexit_pi/a>(ia href="+code=nuc900_rtc_remove" class="sref">nuc900_rtc_removei/a>),3t308i/a>        .ia href="+code=driver" class="sref">driveri/a>         =t{3t309i/a>                .ia href="+code=nam3" class="sref">namei/a>   =tispav class="string">"nuc900-rtc"i/spav3,3t310i/a>                .ia href="+code=owner" class="sref">owneri/a>  =tia href="+code=THIS_MODULE" class="sref">THIS_MODULEi/a>,3t311i/a>        },3t312i/a>};3t313i/a>3t314i/a>statictint ia href="+code=__init" class="sref">__initi/a> ia href="+code=nuc900_rtc_init" class="sref">nuc900_rtc_initi/a>(void)3t315i/a>{3t316i/a>        return ia href="+code=platform_driver_probe" class="sref">platform_driver_probei/a>(&ia href="+code=nuc900_rtc_driver" class="sref">nuc900_rtc_driveri/a>,tia href="+code=nuc900_rtc_probe" class="sref">nuc900_rtc_probei/a>);3t317i/a>}3t318i/a>3t319i/a>statictvoid ia href="+code=__exit" class="sref">__exiti/a> ia href="+code=nuc900_rtc_exit" class="sref">nuc900_rtc_exiti/a>(void)3t320i/a>{3t321i/a>        ia href="+code=platform_driver_unregister" class="sref">platform_driver_unregisteri/a>(&ia href="+code=nuc900_rtc_driver" class="sref">nuc900_rtc_driveri/a>);3t322i/a>}3t323i/a>3t324i/a>ia href="+code=module_init" class="sref">module_initi/a>(ia href="+code=nuc900_rtc_init" class="sref">nuc900_rtc_initi/a>);3t325i/a>ia href="+code=module_exit" class="sref">module_exiti/a>(ia href="+code=nuc900_rtc_exit" class="sref">nuc900_rtc_exiti/a>);3t326i/a>3t327i/a>ia href="+code=MODULE_AUTHOR" class="sref">MODULE_AUTHORi/a>(ispav class="string">"Wav ZongShun <mcuos.com@gmail.com>"i/spav3);3t328i/a>ia href="+code=MODULE_DESCRIPTION" class="sref">MODULE_DESCRIPTIONi/a>(ispav class="string">"nuc910/nuc920 RTC driver"i/spav3);3t329i/a>ia href="+code=MODULE_LICENSE" class="sref">MODULE_LICENSEi/a>(ispav class="string">"GPL"i/spav3);3t330i/a>ia href="+code=MODULE_ALIAS" class="sref">MODULE_ALIASi/a>(ispav class="string">"platform:nuc900-rtc"i/spav3);3t331i/a>
lxr.linux.no kindly hosted by Redpill Linpro ASi/a>, provider of Linux consulting and operations services sincet1995.