'; /spay lspay id="currrgs_pndo cla"../.stat+v3.8.1/"> driver<>'; a"../.sts/rtc/rt">s/rtc/rt<>'; a"../.sts/rtc/rtc-da">c-da<>'; a"../.sts/rtc/rtc-da9052.c <">c-d2.c <<>'; l/spay l!-- --
rs/rtc/rtc-da9052.c < cy cimg../.static/js/lxrvicolefstype="alt="<<v cla < clrlen apjx_l="s/rtc/rtc-da9052.c <"d=(metho"men cy cspay id="tc/_ed || cy y csd || or id="t" id="t" on = han="up } e_tc/rx_ldata); '/lxr.linux.no/linux+v3.8.1/"> '; 'v3.8.'; ''; 's/rtc/rtc-da9052.c <');[ cy c/spal y c/form y ca cy href="../linux+v3.8.2/drivers/rtc/rtc-da9052.c"> cy cimg src="../.static/gfx/right.png" alt=">>"> c/spal cspal class="lxr_search"> c
cy cinput typ[i"hidden" nam[i"navtarget" data[i""> cy cinput typ[i"text" nam[i"search" idi"search"> cy cbutt_lotyp[i"submit">Search cy Prefs y c/a> c/spal cy c/div cy cform acjx_l="ajax+*" method="post" onsubmit="return false;"> cinput typ[i"hidden" nam[i"ajax_lookup" idi"ajax_lookup" data[i""> cy c/form cy cdiv class="headingbott_m">
cdiv idi"file_contents"
   1c/a>cspal class="comment">/*c/spal     2c/a>cspal class="comment"> * Real time clock driver for DA9052c/spal     3c/a>cspal class="comment"> *c/spal     4c/a>cspal class="comment"> * Copyright(c) 2012 Dialog Semiconductor Ltd.c/spal     5c/a>cspal class="comment"> *c/spal     6c/a>cspal class="comment"> * Author: Dajun Dajun Chen <dajun.chen@diasemi.com>c/spal     7c/a>cspal class="comment"> *c/spal     8c/a>cspal class="comment"> * This program is free software; you cal redistribute it and/or modifyc/spal     9c/a>cspal class="comment"> * it under the terms of the GNU General Public License as published byc/spal    10cspal class="comment"> * the Free Software Foundajx_l; either versx_lo2 of the License, orc/spal    11c/a>cspal class="comment"> * (at your opjx_l) any later versx_l.c/spal    12c/a>cspal class="comment"> *c/spal    13c/a>cspal class="comment"> */c/spal    14c/a>   15c/a>#include <linux/module.hc/a>>   16c/a>#include <linux/platform_device.hc/a>>   17c/a>#include <linux/rtc.hc/a>>   18c/a>   19c/a>#include <linux/mfd/da9052/da9052.hc/a>>   20c/a>#include <linux/mfd/da9052/reg.hc/a>>   21c/a>   22c/a>#define ca href="+code=rtc_err" class="sref">rtc_errc/a>(ca href="+code=da9052" class="sref">da9052c/a>, ca href="+code=fmt" class="sref">fmtc/a>, ...) \   23c/a>                ca href="+code=dev_err" class="sref">dev_errc/a>(ca href="+code=da9052" class="sref">da9052c/a>->ca href="+code=dev" class="sref">devc/a>, cspal class="string">"%s: "c/spal  ca href="+code=fmt" class="sref">fmtc/a>, ca href="+code=__func__" class="sref">__func__c/a>, ##__VA_ARGS__)   24c/a>   25c/a>struct ca href="+code=da9052_rtc" class="sref">da9052_rtcc/a> {   26c/a>        struct ca href="+code=rtc_device" class="sref">rtc_devicec/a> *ca href="+code=rtc" class="sref">rtcc/a>;   27c/a>        struct ca href="+code=da9052" class="sref">da9052c/a> *ca href="+code=da9052" class="sref">da9052c/a>;   28c/a>        int ca href="+code=irq" class="sref">irqc/a>;   29c/a>};   30c/a>   31c/a>static int ca href="+code=da9052_rtc_enable_alarm" class="sref">da9052_rtc_enable_alarmc/a>(struct ca href="+code=da9052" class="sref">da9052c/a> *ca href="+code=da9052" class="sref">da9052c/a>, ca href="+code=bool" class="sref">boolc/a> ca href="+code=enable" class="sref">enablec/a>)   32c/a>{   33c/a>        int ca href="+code=ret" class="sref">retc/a>;   34c/a>        if (ca href="+code=enable" class="sref">enablec/a>) {   35c/a>                ca href="+code=ret" class="sref">retc/a> = ca href="+code=da9052_reg_updaje" class="sref">da9052_reg_updajec/a>(ca href="+code=da9052" class="sref">da9052c/a>, ca href="+code=DA9052_ALARM_Y_REG" class="sref">DA9052_ALARM_Y_REGc/a>,   36c/a>                                        ca href="+code=DA9052_ALARM_Y_ALARM_ON" class="sref">DA9052_ALARM_Y_ALARM_ONc/a>,   37c/a>                                        ca href="+code=DA9052_ALARM_Y_ALARM_ON" class="sref">DA9052_ALARM_Y_ALARM_ONc/a>);   38c/a>                if (ca href="+code=ret" class="sref">retc/a> != 0)   39c/a>                        ca href="+code=rtc_err" class="sref">rtc_errc/a>(ca href="+code=da9052" class="sref">da9052c/a>, cspal class="string">"Failed to enable ALM: %d\n"c/spal , ca href="+code=ret" class="sref">retc/a>);   40c/a>        } else {   41c/a>                ca href="+code=ret" class="sref">retc/a> = ca href="+code=da9052_reg_updaje" class="sref">da9052_reg_updajec/a>(ca href="+code=da9052" class="sref">da9052c/a>, ca href="+code=DA9052_ALARM_Y_REG" class="sref">DA9052_ALARM_Y_REGc/a>,   42c/a>                                        ca href="+code=DA9052_ALARM_Y_ALARM_ON" class="sref">DA9052_ALARM_Y_ALARM_ONc/a>, 0);   43c/a>                if (ca href="+code=ret" class="sref">retc/a> != 0)   44c/a>                        ca href="+code=rtc_err" class="sref">rtc_errc/a>(ca href="+code=da9052" class="sref">da9052c/a>, cspal class="string">"Write error: %d\n"c/spal , ca href="+code=ret" class="sref">retc/a>);   45c/a>        }   46c/a>        return ca href="+code=ret" class="sref">retc/a>;   47c/a>}   48c/a>   49c/a>static ca href="+code=irqreturn_t" class="sref">irqreturn_tc/a> ca href="+code=da9052_rtc_irq" class="sref">da9052_rtc_irqc/a>(int ca href="+code=irq" class="sref">irqc/a>, void *ca href="+code=data" class="sref">datac/a>)   50c/a>{   51c/a>        struct ca href="+code=da9052_rtc" class="sref">da9052_rtcc/a> *ca href="+code=rtc" class="sref">rtcc/a> = ca href="+code=data" class="sref">datac/a>;   52c/a>        int ca href="+code=ret" class="sref">retc/a>;   53c/a>   54c/a>        ca href="+code=ret" class="sref">retc/a> = ca href="+code=da9052_reg_read" class="sref">da9052_reg_readc/a>(ca href="+code=rtc" class="sref">rtcc/a>->ca href="+code=da9052" class="sref">da9052c/a>, ca href="+code=DA9052_ALARM_MI_REG" class="sref">DA9052_ALARM_MI_REGc/a>);   55c/a>        if (ca href="+code=ret" class="sref">retc/a> < 0) {   56c/a>                ca href="+code=rtc_err" class="sref">rtc_errc/a>(ca href="+code=rtc" class="sref">rtcc/a>->ca href="+code=da9052" class="sref">da9052c/a>, cspal class="string">"Read error: %d\n"c/spal , ca href="+code=ret" class="sref">retc/a>);   57c/a>                return ca href="+code=IRQ_NONE" class="sref">IRQ_NONEc/a>;   58c/a>        }   59c/a>   60c/a>        if (ca href="+code=ret" class="sref">retc/a> & ca href="+code=DA9052_ALARMMI_ALARMTYPE" class="sref">DA9052_ALARMMI_ALARMTYPEc/a>) {   61c/a>                ca href="+code=da9052_rtc_enable_alarm" class="sref">da9052_rtc_enable_alarmc/a>(ca href="+code=rtc" class="sref">rtcc/a>->ca href="+code=da9052" class="sref">da9052c/a>, 0);   62c/a>                ca href="+code=rtc_updaje_irq" class="sref">rtc_updaje_irqc/a>(ca href="+code=rtc" class="sref">rtcc/a>->ca href="+code=rtc" class="sref">rtcc/a>, 1, ca href="+code=RTC_IRQF" class="sref">RTC_IRQFc/a> | ca href="+code=RTC_AF" class="sref">RTC_AFc/a>);   63c/a>        } else   64c/a>                ca href="+code=rtc_updaje_irq" class="sref">rtc_updaje_irqc/a>(ca href="+code=rtc" class="sref">rtcc/a>->ca href="+code=rtc" class="sref">rtcc/a>, 1, ca href="+code=RTC_IRQF" class="sref">RTC_IRQFc/a> | ca href="+code=RTC_PF" class="sref">RTC_PFc/a>);   65c/a>   66c/a>        return ca href="+code=IRQ_HANDLED" class="sref">IRQ_HANDLEDc/a>;   67c/a>}   68c/a>   69c/a>static int ca href="+code=da9052_read_alarm" class="sref">da9052_read_alarmc/a>(struct ca href="+code=da9052" class="sref">da9052c/a> *ca href="+code=da9052" class="sref">da9052c/a>, struct ca href="+code=rtc_time" class="sref">rtc_timec/a> *ca href="+code=rtc_tm" class="sref">rtc_tmc/a>)   70c/a>{   71c/a>        int ca href="+code=ret" class="sref">retc/a>;   72c/a>        ca href="+code=uint8_t" class="sref">uint8_tc/a> ca href="+code=v" class="sref">vc/a>[5];   73c/a>   74c/a>        ca href="+code=ret" class="sref">retc/a> = ca href="+code=da9052_group_read" class="sref">da9052_group_readc/a>(ca href="+code=da9052" class="sref">da9052c/a>, ca href="+code=DA9052_ALARM_MI_REG" class="sref">DA9052_ALARM_MI_REGc/a>, 5, ca href="+code=v" class="sref">vc/a>);   75c/a>        if (ca href="+code=ret" class="sref">retc/a> != 0) {   76c/a>                ca href="+code=rtc_err" class="sref">rtc_errc/a>(ca href="+code=da9052" class="sref">da9052c/a>, cspal class="string">"Failed to group read ALM: %d\n"c/spal , ca href="+code=ret" class="sref">retc/a>);   77c/a>                return ca href="+code=ret" class="sref">retc/a>;   78c/a>        }   79c/a>   80c/a>        ca href="+code=rtc_tm" class="sref">rtc_tmc/a>->ca href="+code=tm_year" class="sref">tm_yearc/a> = (ca href="+code=v" class="sref">vc/a>[4] & ca href="+code=DA9052_RTC_YEAR" class="sref">DA9052_RTC_YEARc/a>) + 100;   81c/a>        ca href="+code=rtc_tm" class="sref">rtc_tmc/a>->ca href="+code=tm_mon" class="sref">tm_monc/a>  = (ca href="+code=v" class="sref">vc/a>[3] & ca href="+code=DA9052_RTC_MONTH" class="sref">DA9052_RTC_MONTHc/a>) - 1;   82c/a>        ca href="+code=rtc_tm" class="sref">rtc_tmc/a>->ca href="+code=tm_mday" class="sref">tm_mdayc/a> = ca href="+code=v" class="sref">vc/a>[2] & ca href="+code=DA9052_RTC_DAY" class="sref">DA9052_RTC_DAYc/a>;   83c/a>        ca href="+code=rtc_tm" class="sref">rtc_tmc/a>->ca href="+code=tm_hour" class="sref">tm_hourc/a> = ca href="+code=v" class="sref">vc/a>[1] & ca href="+code=DA9052_RTC_HOUR" class="sref">DA9052_RTC_HOURc/a>;   84c/a>        ca href="+code=rtc_tm" class="sref">rtc_tmc/a>->ca href="+code=tm_min" class="sref">tm_minc/a>  = ca href="+code=v" class="sref">vc/a>[0] & ca href="+code=DA9052_RTC_MIN" class="sref">DA9052_RTC_MINc/a>;   85c/a>   86c/a>        ca href="+code=ret" class="sref">retc/a> = ca href="+code=rtc_valid_tm" class="sref">rtc_valid_tmc/a>(ca href="+code=rtc_tm" class="sref">rtc_tmc/a>);   87c/a>        if (ca href="+code=ret" class="sref">retc/a> != 0)   88c/a>                return ca href="+code=ret" class="sref">retc/a>;   89c/a>        return ca href="+code=ret" class="sref">retc/a>;   90c/a>}   91c/a>   92c/a>static int ca href="+code=da9052_set_alarm" class="sref">da9052_set_alarmc/a>(struct ca href="+code=da9052" class="sref">da9052c/a> *ca href="+code=da9052" class="sref">da9052c/a>, struct ca href="+code=rtc_time" class="sref">rtc_timec/a> *ca href="+code=rtc_tm" class="sref">rtc_tmc/a>)   93c/a>{   94c/a>        int ca href="+code=ret" class="sref">retc/a>;   95c/a>        ca href="+code=uint8_t" class="sref">uint8_tc/a> ca href="+code=v" class="sref">vc/a>[3];   96c/a>   97c/a>        ca href="+code=rtc_tm" class="sref">rtc_tmc/a>->ca href="+code=tm_year" class="sref">tm_yearc/a> -= 100;   98c/a>        ca href="+code=rtc_tm" class="sref">rtc_tmc/a>->ca href="+code=tm_mon" class="sref">tm_monc/a> += 1;   99c/a>  100c/a>        ca href="+code=ret" class="sref">retc/a> = ca href="+code=da9052_reg_updaje" class="sref">da9052_reg_updajec/a>(ca href="+code=da9052" class="sref">da9052c/a>, ca href="+code=DA9052_ALARM_MI_REG" class="sref">DA9052_ALARM_MI_REGc/a>,  101c/a>                                ca href="+code=DA9052_RTC_MIN" class="sref">DA9052_RTC_MINc/a>, ca href="+code=rtc_tm" class="sref">rtc_tmc/a>->ca href="+code=tm_min" class="sref">tm_minc/a>);  102c/a>        if (ca href="+code=ret" class="sref">retc/a> != 0) {  103c/a>                ca href="+code=rtc_err" class="sref">rtc_errc/a>(ca href="+code=da9052" class="sref">da9052c/a>, cspal class="string">"Failed to write ALRM MIN: %d\n"c/spal , ca href="+code=ret" class="sref">retc/a>);  104c/a>                return ca href="+code=ret" class="sref">retc/a>;  105c/a>        }  106c/a>  107c/a>        ca href="+code=v" class="sref">vc/a>[0] = ca href="+code=rtc_tm" class="sref">rtc_tmc/a>->ca href="+code=tm_hour" class="sref">tm_hourc/a>;  108c/a>        ca href="+code=v" class="sref">vc/a>[1] = ca href="+code=rtc_tm" class="sref">rtc_tmc/a>->ca href="+code=tm_mday" class="sref">tm_mdayc/a>;  109c/a>        ca href="+code=v" class="sref">vc/a>[2] = ca href="+code=rtc_tm" class="sref">rtc_tmc/a>->ca href="+code=tm_mon" class="sref">tm_monc/a>;  110c/a>  111c/a>        ca href="+code=ret" class="sref">retc/a> = ca href="+code=da9052_group_write" class="sref">da9052_group_writec/a>(ca href="+code=da9052" class="sref">da9052c/a>, ca href="+code=DA9052_ALARM_H_REG" class="sref">DA9052_ALARM_H_REGc/a>, 3, ca href="+code=v" class="sref">vc/a>);  112c/a>        if (ca href="+code=ret" class="sref">retc/a> < 0)  113c/a>                return ca href="+code=ret" class="sref">retc/a>;  114c/a>  115c/a>        ca href="+code=ret" class="sref">retc/a> = ca href="+code=da9052_reg_updaje" class="sref">da9052_reg_updajec/a>(ca href="+code=da9052" class="sref">da9052c/a>, ca href="+code=DA9052_ALARM_Y_REG" class="sref">DA9052_ALARM_Y_REGc/a>,  116c/a>                                ca href="+code=DA9052_RTC_YEAR" class="sref">DA9052_RTC_YEARc/a>, ca href="+code=rtc_tm" class="sref">rtc_tmc/a>->ca href="+code=tm_year" class="sref">tm_yearc/a>);  117c/a>        if (ca href="+code=ret" class="sref">retc/a> != 0)  118c/a>                ca href="+code=rtc_err" class="sref">rtc_errc/a>(ca href="+code=da9052" class="sref">da9052c/a>, cspal class="string">"Failed to write ALRM YEAR: %d\n"c/spal , ca href="+code=ret" class="sref">retc/a>);  119c/a>  120c/a>        return ca href="+code=ret" class="sref">retc/a>;  121c/a>}  122c/a>  123c/a>static int ca href="+code=da9052_rtc_get_alarm_status" class="sref">da9052_rtc_get_alarm_statusc/a>(struct ca href="+code=da9052" class="sref">da9052c/a> *ca href="+code=da9052" class="sref">da9052c/a>)  124c/a>{  125c/a>        int ca href="+code=ret" class="sref">retc/a>;  126c/a>  127c/a>        ca href="+code=ret" class="sref">retc/a> = ca href="+code=da9052_reg_read" class="sref">da9052_reg_readc/a>(ca href="+code=da9052" class="sref">da9052c/a>, ca href="+code=DA9052_ALARM_Y_REG" class="sref">DA9052_ALARM_Y_REGc/a>);  128c/a>        if (ca href="+code=ret" class="sref">retc/a> < 0) {  129c/a>                ca href="+code=rtc_err" class="sref">rtc_errc/a>(ca href="+code=da9052" class="sref">da9052c/a>, cspal class="string">"Failed to read ALM: %d\n"c/spal , ca href="+code=ret" class="sref">retc/a>);  130c/a>                return ca href="+code=ret" class="sref">retc/a>;  131c/a>        }  132c/a>        ca href="+code=ret" class="sref">retc/a> &= ca href="+code=DA9052_ALARM_Y_ALARM_ON" class="sref">DA9052_ALARM_Y_ALARM_ONc/a>;  133c/a>        return (ca href="+code=ret" class="sref">retc/a> > 0) ? 1 : 0;  134c/a>}  135c/a>  136c/a>static int ca href="+code=da9052_rtc_read_time" class="sref">da9052_rtc_read_timec/a>(struct ca href="+code=device" class="sref">devicec/a> *ca href="+code=dev" class="sref">devc/a>, struct ca href="+code=rtc_time" class="sref">rtc_timec/a> *ca href="+code=rtc_tm" class="sref">rtc_tmc/a>)  137c/a>{  138c/a>        struct ca href="+code=da9052_rtc" class="sref">da9052_rtcc/a> *ca href="+code=rtc" class="sref">rtcc/a> = ca href="+code=dev_get_drvdata" class="sref">dev_get_drvdatac/a>(ca href="+code=dev" class="sref">devc/a>);  139c/a>        ca href="+code=uint8_t" class="sref">uint8_tc/a> ca href="+code=v" class="sref">vc/a>[6];  140c/a>        int ca href="+code=ret" class="sref">retc/a>;  141c/a>  142c/a>        ca href="+code=ret" class="sref">retc/a> = ca href="+code=da9052_group_read" class="sref">da9052_group_readc/a>(ca href="+code=rtc" class="sref">rtcc/a>->ca href="+code=da9052" class="sref">da9052c/a>, ca href="+code=DA9052_COUNT_S_REG" class="sref">DA9052_COUNT_S_REGc/a>, 6, ca href="+code=v" class="sref">vc/a>);  143c/a>        if (ca href="+code=ret" class="sref">retc/a> < 0) {  144c/a>                ca href="+code=rtc_err" class="sref">rtc_errc/a>(ca href="+code=rtc" class="sref">rtcc/a>->ca href="+code=da9052" class="sref">da9052c/a>, cspal class="string">"Failed to read RTC time : %d\n"c/spal , ca href="+code=ret" class="sref">retc/a>);  145c/a>                return ca href="+code=ret" class="sref">retc/a>;  146c/a>        }  147c/a>  148c/a>        ca href="+code=rtc_tm" class="sref">rtc_tmc/a>->ca href="+code=tm_year" class="sref">tm_yearc/a> = (ca href="+code=v" class="sref">vc/a>[5] & ca href="+code=DA9052_RTC_YEAR" class="sref">DA9052_RTC_YEARc/a>) + 100;  149c/a>        ca href="+code=rtc_tm" class="sref">rtc_tmc/a>->ca href="+code=tm_mon" class="sref">tm_monc/a>  = (ca href="+code=v" class="sref">vc/a>[4] & ca href="+code=DA9052_RTC_MONTH" class="sref">DA9052_RTC_MONTHc/a>) - 1;  150c/a>        ca href="+code=rtc_tm" class="sref">rtc_tmc/a>->ca href="+code=tm_mday" class="sref">tm_mdayc/a> = ca href="+code=v" class="sref">vc/a>[3] & ca href="+code=DA9052_RTC_DAY" class="sref">DA9052_RTC_DAYc/a>;  151c/a>        ca href="+code=rtc_tm" class="sref">rtc_tmc/a>->ca href="+code=tm_hour" class="sref">tm_hourc/a> = ca href="+code=v" class="sref">vc/a>[2] & ca href="+code=DA9052_RTC_HOUR" class="sref">DA9052_RTC_HOURc/a>;  152c/a>        ca href="+code=rtc_tm" class="sref">rtc_tmc/a>->ca href="+code=tm_min" class="sref">tm_minc/a>  = ca href="+code=v" class="sref">vc/a>[1] & ca href="+code=DA9052_RTC_MIN" class="sref">DA9052_RTC_MINc/a>;  153c/a>        ca href="+code=rtc_tm" class="sref">rtc_tmc/a>->ca href="+code=tm_sec" class="sref">tm_secc/a>  = ca href="+code=v" class="sref">vc/a>[0] & ca href="+code=DA9052_RTC_SEC" class="sref">DA9052_RTC_SECc/a>;  154c/a>  155c/a>        ca href="+code=ret" class="sref">retc/a> = ca href="+code=rtc_valid_tm" class="sref">rtc_valid_tmc/a>(ca href="+code=rtc_tm" class="sref">rtc_tmc/a>);  156c/a>        if (ca href="+code=ret" class="sref">retc/a> != 0) {  157c/a>                ca href="+code=rtc_err" class="sref">rtc_errc/a>(ca href="+code=rtc" class="sref">rtcc/a>->ca href="+code=da9052" class="sref">da9052c/a>, cspal class="string">"rtc_valid_tm failed: %d\n"c/spal , ca href="+code=ret" class="sref">retc/a>);  158c/a>                return ca href="+code=ret" class="sref">retc/a>;  159c/a>        }  160c/a>  161c/a>        return 0;  162c/a>}  163c/a>  164c/a>static int ca href="+code=da9052_rtc_set_time" class="sref">da9052_rtc_set_timec/a>(struct ca href="+code=device" class="sref">devicec/a> *ca href="+code=dev" class="sref">devc/a>, struct ca href="+code=rtc_time" class="sref">rtc_timec/a> *ca href="+code=tm" class="sref">tmc/a>)  165c/a>{  166c/a>        struct ca href="+code=da9052_rtc" class="sref">da9052_rtcc/a> *ca href="+code=rtc" class="sref">rtcc/a>;  167c/a>        ca href="+code=uint8_t" class="sref">uint8_tc/a> ca href="+code=v" class="sref">vc/a>[6];  168c/a>  169c/a>        ca href="+code=rtc" class="sref">rtcc/a> = ca href="+code=dev_get_drvdata" class="sref">dev_get_drvdatac/a>(ca href="+code=dev" class="sref">devc/a>);  170c/a>  171c/a>        ca href="+code=v" class="sref">vc/a>[0] = ca href="+code=tm" class="sref">tmc/a>->ca href="+code=tm_sec" class="sref">tm_secc/a>;  172c/a>        ca href="+code=v" class="sref">vc/a>[1] = ca href="+code=tm" class="sref">tmc/a>->ca href="+code=tm_min" class="sref">tm_minc/a>;  173c/a>        ca href="+code=v" class="sref">vc/a>[2] = ca href="+code=tm" class="sref">tmc/a>->ca href="+code=tm_hour" class="sref">tm_hourc/a>;  174c/a>        ca href="+code=v" class="sref">vc/a>[3] = ca href="+code=tm" class="sref">tmc/a>->ca href="+code=tm_mday" class="sref">tm_mdayc/a>;  175c/a>        ca href="+code=v" class="sref">vc/a>[4] = ca href="+code=tm" class="sref">tmc/a>->ca href="+code=tm_mon" class="sref">tm_monc/a> + 1;  176c/a>        ca href="+code=v" class="sref">vc/a>[5] = ca href="+code=tm" class="sref">tmc/a>->ca href="+code=tm_year" class="sref">tm_yearc/a> - 100;  177c/a>  178c/a>        return ca href="+code=da9052_group_write" class="sref">da9052_group_writec/a>(ca href="+code=rtc" class="sref">rtcc/a>->ca href="+code=da9052" class="sref">da9052c/a>, ca href="+code=DA9052_COUNT_S_REG" class="sref">DA9052_COUNT_S_REGc/a>, 6, ca href="+code=v" class="sref">vc/a>);  179c/a>}  180c/a>  181c/a>static int ca href="+code=da9052_rtc_read_alarm" class="sref">da9052_rtc_read_alarmc/a>(struct ca href="+code=device" class="sref">devicec/a> *ca href="+code=dev" class="sref">devc/a>, struct ca href="+code=rtc_wkalrm" class="sref">rtc_wkalrmc/a> *ca href="+code=alrm" class="sref">alrmc/a>)  182c/a>{  183c/a>        int ca href="+code=ret" class="sref">retc/a>;  184c/a>        struct ca href="+code=rtc_time" class="sref">rtc_timec/a> *ca href="+code=tm" class="sref">tmc/a> = &ca href="+code=alrm" class="sref">alrmc/a>->ca href="+code=time" class="sref">timec/a>;  185c/a>        struct ca href="+code=da9052_rtc" class="sref">da9052_rtcc/a> *ca href="+code=rtc" class="sref">rtcc/a> = ca href="+code=dev_get_drvdata" class="sref">dev_get_drvdatac/a>(ca href="+code=dev" class="sref">devc/a>);  186c/a>  187c/a>        ca href="+code=ret" class="sref">retc/a> = ca href="+code=da9052_read_alarm" class="sref">da9052_read_alarmc/a>(ca href="+code=rtc" class="sref">rtcc/a>->ca href="+code=da9052" class="sref">da9052c/a>, ca href="+code=tm" class="sref">tmc/a>);  188c/a>  189c/a>        if (ca href="+code=ret" class="sref">retc/a>)  190c/a>                return ca href="+code=ret" class="sref">retc/a>;  191c/a>  192c/a>        ca href="+code=alrm" class="sref">alrmc/a>->ca href="+code=enabled" class="sref">enabledc/a> = ca href="+code=da9052_rtc_get_alarm_status" class="sref">da9052_rtc_get_alarm_statusc/a>(ca href="+code=rtc" class="sref">rtcc/a>->ca href="+code=da9052" class="sref">da9052c/a>);  193c/a>  194c/a>        return 0;  195c/a>}  196c/a>  197c/a>static int ca href="+code=da9052_rtc_set_alarm" class="sref">da9052_rtc_set_alarmc/a>(struct ca href="+code=device" class="sref">devicec/a> *ca href="+code=dev" class="sref">devc/a>, struct ca href="+code=rtc_wkalrm" class="sref">rtc_wkalrmc/a> *ca href="+code=alrm" class="sref">alrmc/a>)  198c/a>{  199c/a>        int ca href="+code=ret" class="sref">retc/a>;  200c/a>        struct ca href="+code=rtc_time" class="sref">rtc_timec/a> *ca href="+code=tm" class="sref">tmc/a> = &ca href="+code=alrm" class="sref">alrmc/a>->ca href="+code=time" class="sref">timec/a>;  201c/a>        struct ca href="+code=da9052_rtc" class="sref">da9052_rtcc/a> *ca href="+code=rtc" class="sref">rtcc/a> = ca href="+code=dev_get_drvdata" class="sref">dev_get_drvdatac/a>(ca href="+code=dev" class="sref">devc/a>);  202c/a>  203c/a>        ca href="+code=ret" class="sref">retc/a> = ca href="+code=da9052_rtc_enable_alarm" class="sref">da9052_rtc_enable_alarmc/a>(ca href="+code=rtc" class="sref">rtcc/a>->ca href="+code=da9052" class="sref">da9052c/a>, 0);  204c/a>        if (ca href="+code=ret" class="sref">retc/a> < 0)  205c/a>                return ca href="+code=ret" class="sref">retc/a>;  206c/a>  207c/a>        ca href="+code=ret" class="sref">retc/a> = ca href="+code=da9052_set_alarm" class="sref">da9052_set_alarmc/a>(ca href="+code=rtc" class="sref">rtcc/a>->ca href="+code=da9052" class="sref">da9052c/a>, ca href="+code=tm" class="sref">tmc/a>);  208c/a>        if (ca href="+code=ret" class="sref">retc/a>)  209c/a>                return ca href="+code=ret" class="sref">retc/a>;  210c/a>  211c/a>        ca href="+code=ret" class="sref">retc/a> = ca href="+code=da9052_rtc_enable_alarm" class="sref">da9052_rtc_enable_alarmc/a>(ca href="+code=rtc" class="sref">rtcc/a>->ca href="+code=da9052" class="sref">da9052c/a>, 1);  212c/a>  213c/a>        return ca href="+code=ret" class="sref">retc/a>;  214c/a>}  215c/a>  216c/a>static int ca href="+code=da9052_rtc_alarm_irq_enable" class="sref">da9052_rtc_alarm_irq_enablec/a>(struct ca href="+code=device" class="sref">devicec/a> *ca href="+code=dev" class="sref">devc/a>, unsigned int ca href="+code=enabled" class="sref">enabledc/a>)  217c/a>{  218c/a>        struct ca href="+code=da9052_rtc" class="sref">da9052_rtcc/a> *ca href="+code=rtc" class="sref">rtcc/a> = ca href="+code=dev_get_drvdata" class="sref">dev_get_drvdatac/a>(ca href="+code=dev" class="sref">devc/a>);  219c/a>  220c/a>        return ca href="+code=da9052_rtc_enable_alarm" class="sref">da9052_rtc_enable_alarmc/a>(ca href="+code=rtc" class="sref">rtcc/a>->ca href="+code=da9052" class="sref">da9052c/a>, ca href="+code=enabled" class="sref">enabledc/a>);  221c/a>}  222c/a>  223c/a>static const struct ca href="+code=rtc_class_ops" class="sref">rtc_class_opsc/a> ca href="+code=da9052_rtc_ops" class="sref">da9052_rtc_opsc/a> = {  224c/a>        .ca href="+code=read_time" class="sref">read_timec/a>      = ca href="+code=da9052_rtc_read_time" class="sref">da9052_rtc_read_timec/a>,  225c/a>        .ca href="+code=set_time" class="sref">set_timec/a>       = ca href="+code=da9052_rtc_set_time" class="sref">da9052_rtc_set_timec/a>,  226c/a>        .ca href="+code=read_alarm" class="sref">read_alarmc/a>     = ca href="+code=da9052_rtc_read_alarm" class="sref">da9052_rtc_read_alarmc/a>,  227c/a>        .ca href="+code=set_alarm" class="sref">set_alarmc/a>      = ca href="+code=da9052_rtc_set_alarm" class="sref">da9052_rtc_set_alarmc/a>,  228c/a>        .ca href="+code=alarm_irq_enable" class="sref">alarm_irq_enablec/a> = ca href="+code=da9052_rtc_alarm_irq_enable" class="sref">da9052_rtc_alarm_irq_enablec/a>,  229c/a>};  230c/a>  231c/a>static int ca href="+code=da9052_rtc_probe" class="sref">da9052_rtc_probec/a>(struct ca href="+code=platform_device" class="sref">platform_devicec/a> *ca href="+code=pdev" class="sref">pdevc/a>)  232c/a>{  233c/a>        struct ca href="+code=da9052_rtc" class="sref">da9052_rtcc/a> *ca href="+code=rtc" class="sref">rtcc/a>;  234c/a>        int ca href="+code=ret" class="sref">retc/a>;  235c/a>  236c/a>        ca href="+code=rtc" class="sref">rtcc/a> = ca href="+code=devm_kzalloc" class="sref">devm_kzallocc/a>(&ca href="+code=pdev" class="sref">pdevc/a>->ca href="+code=dev" class="sref">devc/a>, sizeof(struct ca href="+code=da9052_rtc" class="sref">da9052_rtcc/a>), ca href="+code=GFP_KERNEL" class="sref">GFP_KERNELc/a>);  237c/a>        if (!ca href="+code=rtc" class="sref">rtcc/a>)  238c/a>                return -ca href="+code=ENOMEM" class="sref">ENOMEMc/a>;  239c/a>  240c/a>        ca href="+code=rtc" class="sref">rtcc/a>->ca href="+code=da9052" class="sref">da9052c/a> = ca href="+code=dev_get_drvdata" class="sref">dev_get_drvdatac/a>(ca href="+code=pdev" class="sref">pdevc/a>->ca href="+code=dev" class="sref">devc/a>.ca href="+code=parent" class="sref">parentc/a>);  241c/a>        ca href="+code=platform_set_drvdata" class="sref">platform_set_drvdatac/a>(ca href="+code=pdev" class="sref">pdevc/a>, ca href="+code=rtc" class="sref">rtcc/a>);  242c/a>        ca href="+code=rtc" class="sref">rtcc/a>->ca href="+code=irq" class="sref">irqc/a> = ca href="+code=platform_get_irq_bynam[" class="sref">platform_get_irq_bynam[c/a>(ca href="+code=pdev" class="sref">pdevc/a>, cspal class="string">"ALM"c/spal );  243c/a>        ca href="+code=ret" class="sref">retc/a> = ca href="+code=request_threaded_irq" class="sref">request_threaded_irqc/a>(ca href="+code=rtc" class="sref">rtcc/a>->ca href="+code=irq" class="sref">irqc/a>, ca href="+code=NULL" class="sref">NULLc/a>, ca href="+code=da9052_rtc_irq" class="sref">da9052_rtc_irqc/a>,  244c/a>                                   ca href="+code=IRQF_TRIGGER_LOW" class="sref">IRQF_TRIGGER_LOWc/a> | ca href="+code=IRQF_ONESHOT" class="sref">IRQF_ONESHOTc/a>,  245c/a>                                   cspal class="string">"ALM"c/spal , ca href="+code=rtc" class="sref">rtcc/a>);  246c/a>        if (ca href="+code=ret" class="sref">retc/a> != 0) {  247c/a>                ca href="+code=rtc_err" class="sref">rtc_errc/a>(ca href="+code=rtc" class="sref">rtcc/a>->ca href="+code=da9052" class="sref">da9052c/a>, cspal class="string">"irq registration failed: %d\n"c/spal , ca href="+code=ret" class="sref">retc/a>);  248c/a>                return ca href="+code=ret" class="sref">retc/a>;  249c/a>        }  250c/a>  251c/a>        ca href="+code=rtc" class="sref">rtcc/a>->ca href="+code=rtc" class="sref">rtcc/a> = ca href="+code=rtc_device_register" class="sref">rtc_device_registerc/a>(ca href="+code=pdev" class="sref">pdevc/a>->ca href="+code=nam[" class="sref">nam[c/a>, &ca href="+code=pdev" class="sref">pdevc/a>->ca href="+code=dev" class="sref">devc/a>,  252c/a>                                       &ca href="+code=da9052_rtc_ops" class="sref">da9052_rtc_opsc/a>, ca href="+code=THIS_MODULE" class="sref">THIS_MODULEc/a>);  253c/a>        if (ca href="+code=IS_ERR" class="sref">IS_ERRc/a>(ca href="+code=rtc" class="sref">rtcc/a>->ca href="+code=rtc" class="sref">rtcc/a>)) {  254c/a>                ca href="+code=ret" class="sref">retc/a> = ca href="+code=PTR_ERR" class="sref">PTR_ERRc/a>(ca href="+code=rtc" class="sref">rtcc/a>->ca href="+code=rtc" class="sref">rtcc/a>);  255c/a>                goto ca href="+code=err_free_irq" class="sref">err_free_irqc/a>;  256c/a>        }  257c/a>  258c/a>        return 0;  259c/a>  260c/a>ca href="+code=err_free_irq" class="sref">err_free_irqc/a>:  261c/a>        ca href="+code=free_irq" class="sref">free_irqc/a>(ca href="+code=rtc" class="sref">rtcc/a>->ca href="+code=irq" class="sref">irqc/a>, ca href="+code=rtc" class="sref">rtcc/a>);  262c/a>        return ca href="+code=ret" class="sref">retc/a>;  263c/a>}  264c/a>  265c/a>static int ca href="+code=da9052_rtc_remove" class="sref">da9052_rtc_removec/a>(struct ca href="+code=platform_device" class="sref">platform_devicec/a> *ca href="+code=pdev" class="sref">pdevc/a>)  266c/a>{  267c/a>        struct ca href="+code=da9052_rtc" class="sref">da9052_rtcc/a> *ca href="+code=rtc" class="sref">rtcc/a> = ca href="+code=pdev" class="sref">pdevc/a>->ca href="+code=dev" class="sref">devc/a>.ca href="+code=platform_data" class="sref">platform_datac/a>;  268c/a>  269c/a>        ca href="+code=rtc_device_unregister" class="sref">rtc_device_unregisterc/a>(ca href="+code=rtc" class="sref">rtcc/a>->ca href="+code=rtc" class="sref">rtcc/a>);  270c/a>        ca href="+code=free_irq" class="sref">free_irqc/a>(ca href="+code=rtc" class="sref">rtcc/a>->ca href="+code=irq" class="sref">irqc/a>, ca href="+code=rtc" class="sref">rtcc/a>);  271c/a>        ca href="+code=platform_set_drvdata" class="sref">platform_set_drvdatac/a>(ca href="+code=pdev" class="sref">pdevc/a>, ca href="+code=NULL" class="sref">NULLc/a>);  272c/a>  273c/a>        return 0;  274c/a>}  275c/a>  276c/a>static struct ca href="+code=platform_driver" class="sref">platform_driverc/a> ca href="+code=da9052_rtc_driver" class="sref">da9052_rtc_driverc/a> = {  277c/a>        .ca href="+code=probe" class="sref">probec/a>  = ca href="+code=da9052_rtc_probe" class="sref">da9052_rtc_probec/a>,  278c/a>        .ca href="+code=remove" class="sref">removec/a> = ca href="+code=da9052_rtc_remove" class="sref">da9052_rtc_removec/a>,  279c/a>        .ca href="+code=driver" class="sref">driverc/a> = {  280c/a>                .ca href="+code=nam[" class="sref">nam[c/a>   = cspal class="string">"da9052-rtc"c/spal ,  281c/a>                .ca href="+code=owner" class="sref">ownerc/a>  = ca href="+code=THIS_MODULE" class="sref">THIS_MODULEc/a>,  282c/a>        },  283c/a>};  284c/a>  285c/a>ca href="+code=module_platform_driver" class="sref">module_platform_driverc/a>(ca href="+code=da9052_rtc_driver" class="sref">da9052_rtc_driverc/a>);  286c/a>  287c/a>ca href="+code=MODULE_AUTHOR" class="sref">MODULE_AUTHORc/a>(cspal class="string">"David Dajun Chen <dchen@diasemi.com>"c/spal );  288c/a>ca href="+code=MODULE_DESCRIPTION" class="sref">MODULE_DESCRIPTIONc/a>(cspal class="string">"RTC driver for Dialog DA9052 PMIC"c/spal );  289c/a>ca href="+code=MODULE_LICENSE" class="sref">MODULE_LICENSEc/a>(cspal class="string">"GPL"c/spal );  290c/a>ca href="+code=MODULE_ALIAS" class="sref">MODULE_ALIASc/a>(cspal class="string">"platform:da9052-rtc"c/spal );  291c/a>
lxr.linux.no kindly hosted by Redpill Linpro ASc/a>, provider of Linux consulting and operations services since 1995.