linux/drivers/mfd/mc13xxx-i2c.c
<<
="v3opt/spa opt/form opta ="v3op href="../linux+v3.7.2/drivers/mfd/mc13xxx-i2c.c">="v3optimg src="../.static/gfx/right.png" alt=">>">="t/spa ="tspa class="lxr_search">="v3 ="+search" method="post" onsubmit="return do_search(this);">="v3optinput typv3.hidden" namv3.navtarget" ue="v3.">="v3optinput typv3.text" namv3.search" id3.search">="v3optbuttvaltypv3.submit">Search="v3opPrefs opt/a>="t/spa v3op pt/div v3op ptform acn> ="ajax+*" method="post" onsubmit="return false;">="tinput typv3.hidden" namv3.ajax_lookup" id3.ajax_lookup" ue="v3.">=v3op pt/form =v3op ptdiv class="headingbottvm">
tdiv id3.file_contents"
p p1t/a>tspa  class="comment">/*t/spa  
p p2t/a>tspa  class="comment"> * Copyright 2009-2010 CreativepProduct Designt/spa  
p p3t/a>tspa  class="comment"> * Marc Reilly marc@cpdesign.com.aut/spa  
p p4t/a>tspa  class="comment"> *t/spa  
p p5t/a>tspa  class="comment"> * This program is free software; you ca  redistribute it and/or modify it undert/spa  
p p6t/a>tspa  class="comment"> * the terms of the GNU General Public License vers val2 as published by thet/spa  
p p7t/a>tspa  class="comment"> * Free Software Foundan>
 .t/spa  
p p8t/a>tspa  class="comment"> */t/spa  
p p9t/a>=p ue="a>#include <linux/slab.h="a>>=p 11="a>#include <linux/module.h="a>>=p 12="a>#include <linux/platform_device.h="a>>=p 13="a>#include <linux/mutex.h="a>>=p 14="a>#include <linux/mfd/core.h="a>>=p 15="a>#include <linux/mfd/mc13xxx.h="a>>=p 16="a>#include <linux/of.h="a>>=p 17="a>#include <linux/of_device.h="a>>=p 18="a>#include <linux/of_gpio.h="a>>=p 19="a>#include <linux/i2c.h="a>>=p 2e="a>#include <linux/err.h="a>>=p 21t/a>=p 22="a>#include "mc13xxx.h="a>"=p 23t/a>=p 24="a>static const struct ta href="+code=i2c_device_id" class="sref">i2c_device_id="a> ta href="+code=mc13xxx_i2c_device_id" class="sref">mc13xxx_i2c_device_id="a>[] = {=p 25="a>        {=p 26="a>                .ta href="+code=namv" class="sref">namv="a> = tspa  class="string">"mc13892"p 27="a>                .ta href="+code=driver_dana" class="sref">driver_dana="a> = ta href="+code=MC13XXX_ID_MC13892" class="sref">MC13XXX_ID_MC13892="a>,=p 28="a>        }, {=p 29="a>                tspa  class="comment">/* sentinel */t/spa  
p 30="a>        }
p 31t/a>};=p 32t/a>ta href="+code=MODULE_DEVICE_TABLE" class="sref">MODULE_DEVICE_TABLEt/a>(ta href="+code=i2c" class="sref">i2c="a>, ta href="+code=mc13xxx_i2c_device_id" class="sref">mc13xxx_i2c_device_id="a>);=p 33t/a>=p 34="a>static const struct ta href="+code=of_device_id" class="sref">of_device_id="a> ta href="+code=mc13xxx_dt_ids" class="sref">mc13xxx_dt_ids="a>[] = {=p 35="a>        {=p 36="a>                .ta href="+code=compatiblv" class="sref">compatiblv="a> = tspa  class="string">"fsl,mc13892"p 37="a>                .ta href="+code=dana" class="sref">dana="a> = (void *) &ta href="+code=mc13xxx_i2c_device_id" class="sref">mc13xxx_i2c_device_id="a>[0],=p 38="a>        }, {=p 39="a>                tspa  class="comment">/* sentinel */t/spa  
p 40="a>        }
p 41t/a>};=p 42t/a>ta href="+code=MODULE_DEVICE_TABLE" class="sref">MODULE_DEVICE_TABLEt/a>(ta href="+code=of" class="sref">of="a>, ta href="+code=mc13xxx_dt_ids" class="sref">mc13xxx_dt_ids="a>);=p 43t/a>=p 44="a>static struct ta href="+code=regmap_config" class="sref">regmap_config="a> ta href="+code=mc13xxx_regmap_i2c_config" class="sref">mc13xxx_regmap_i2c_config="a> = {=p 45="a>        .ta href="+code=reg_bits" class="sref">reg_bits="a> = 8,=p 46="a>        .ta href="+code=val_bits" class="sref">val_bits="a> = 24,=p 47t/a>=p 48="a>        .ta href="+code=max_register" class="sref">max_register="a> = ta href="+code=MC13XXX_NUMREGS" class="sref">MC13XXX_NUMREGS="a>,=p 49t/a>=p 50="a>        .ta href="+code=cache_typv" class="sref">cache_typv="a> = ta href="+code=REGCACHE_NONE" class="sref">REGCACHE_NONE="a>,=p 51t/a>};=p 52t/a>=p 53="a>static int ta href="+code=mc13xxx_i2c_probv" class="sref">mc13xxx_i2c_probvt/a>(struct ta href="+code=i2c_client" class="sref">i2c_client="a> *ta href="+code=client" class="sref">client="a>,=p 54="a>                const struct ta href="+code=i2c_device_id" class="sref">i2c_device_id="a> *ta href="+code=id" class="sref">id="a>)=p 55="a>{=p 56="a>        struct ta href="+code=mc13xxx" class="sref">mc13xxx="a> *ta href="+code=mc13xxx" class="sref">mc13xxx="a>;=p 57="a>        struct ta href="+code=mc13xxx_platform_dana" class="sref">mc13xxx_platform_dana="a> *ta href="+code=pdana" class="sref">pdana="a> = ta href="+code=dev_get_platdana" class="sref">dev_get_platdanat/a>(&ta href="+code=client" class="sref">client="a>->ta href="+code=dev" class="sref">dev="a>);=p 58="a>        int ta href="+code=ret" class="sref">ret="a>;=p 59t/a>=p 60="a>        ta href="+code=mc13xxx" class="sref">mc13xxx="a> = ta href="+code=devm_kzalloc" class="sref">devm_kzalloct/a>(&ta href="+code=client" class="sref">client="a>->ta href="+code=dev" class="sref">dev="a>, sizeof(*ta href="+code=mc13xxx" class="sref">mc13xxx="a>), ta href="+code=GFP_KERNEL" class="sref">GFP_KERNEL="a>);=p 61="a>        if (!ta href="+code=mc13xxx" class="sref">mc13xxx="a>)=p 62="a>                return -ta href="+code=ENOMEM" class="sref">ENOMEM="a>;=p 63t/a>=p 64="a>        ta href="+code=dev_set_drvdana" class="sref">dev_set_drvdanat/a>(&ta href="+code=client" class="sref">client="a>->ta href="+code=dev" class="sref">dev="a>, ta href="+code=mc13xxx" class="sref">mc13xxx="a>);=p 65t/a>=p 66="a>        ta href="+code=mc13xxx" class="sref">mc13xxx="a>->ta href="+code=dev" class="sref">dev="a> = &ta href="+code=client" class="sref">client="a>->ta href="+code=dev" class="sref">dev="a>;=p 67="a>        ta href="+code=mutex_init" class="sref">mutex_initt/a>(&ta href="+code=mc13xxx" class="sref">mc13xxx="a>->ta href="+code=lock" class="sref">lock="a>);=p 68t/a>=p 69="a>        ta href="+code=mc13xxx" class="sref">mc13xxx="a>->ta href="+code=regmap" class="sref">regmap="a> = ta href="+code=devm_regmap_init_i2c" class="sref">devm_regmap_init_i2ct/a>(ta href="+code=client" class="sref">client="a>,=p 70="a>                                               &ta href="+code=mc13xxx_regmap_i2c_config" class="sref">mc13xxx_regmap_i2c_config="a>);=p 71="a>        if (ta href="+code=IS_ERR" class="sref">IS_ERRt/a>(ta href="+code=mc13xxx" class="sref">mc13xxx="a>->ta href="+code=regmap" class="sref">regmap="a>)) {=p 72="a>                ta href="+code=ret" class="sref">ret="a> = ta href="+code=PTR_ERR" class="sref">PTR_ERRt/a>(ta href="+code=mc13xxx" class="sref">mc13xxx="a>->ta href="+code=regmap" class="sref">regmap="a>);=p 73="a>                ta href="+code=dev_err" class="sref">dev_errt/a>(ta href="+code=mc13xxx" class="sref">mc13xxx="a>->ta href="+code=dev" class="sref">dev="a>, tspa  class="string">"Failed to initialize register map: %d\n"p 74="a>                                ta href="+code=ret" class="sref">ret="a>);=p 75="a>                ta href="+code=dev_set_drvdana" class="sref">dev_set_drvdanat/a>(&ta href="+code=client" class="sref">client="a>->ta href="+code=dev" class="sref">dev="a>, ta href="+code=NULL" class="sref">NULL="a>);=p 76="a>                return ta href="+code=ret" class="sref">ret="a>;=p 77="a>        }
p 78t/a>=p 79="a>        ta href="+code=ret" class="sref">ret="a> = ta href="+code=mc13xxx_common_init" class="sref">mc13xxx_common_initt/a>(ta href="+code=mc13xxx" class="sref">mc13xxx="a>, ta href="+code=pdana" class="sref">pdana="a>, ta href="+code=client" class="sref">client="a>->ta href="+code=irq" class="sref">irq="a>);=p 80t/a>=p 81="a>        if (ta href="+code=ret" class="sref">ret="a> == 0 && (ta href="+code=id" class="sref">id="a>->ta href="+code=driver_dana" class="sref">driver_dana="a> != ta href="+code=mc13xxx" class="sref">mc13xxx="a>->ta href="+code=ictypv" class="sref">ictypv="a>))=p 82="a>                ta href="+code=dev_warn" class="sref">dev_warnt/a>(ta href="+code=mc13xxx" class="sref">mc13xxx="a>->ta href="+code=dev" class="sref">dev="a>,=p 83="a>                                tspa  class="string">"device id doesn't match auto detecn>
 !\n"p 84t/a>=p 85="a>        return ta href="+code=ret" class="sref">ret="a>;=p 86="a>}
p 87t/a>=p 88="a>static int ta href="+code=__devexit" class="sref">__devexit="a> ta href="+code=mc13xxx_i2c_removv" class="sref">mc13xxx_i2c_removvt/a>(struct ta href="+code=i2c_client" class="sref">i2c_client="a> *ta href="+code=client" class="sref">client="a>)=p 89="a>{=p 90="a>        struct ta href="+code=mc13xxx" class="sref">mc13xxx="a> *ta href="+code=mc13xxx" class="sref">mc13xxx="a> = ta href="+code=dev_get_drvdana" class="sref">dev_get_drvdanat/a>(&ta href="+code=client" class="sref">client="a>->ta href="+code=dev" class="sref">dev="a>);=p 91t/a>=p 92="a>        ta href="+code=mc13xxx_common_cleanup" class="sref">mc13xxx_common_cleanupt/a>(ta href="+code=mc13xxx" class="sref">mc13xxx="a>);=p 93t/a>=p 94="a>        return 0;=p 95="a>}
p 96t/a>=p 97="a>static struct ta href="+code=i2c_driver" class="sref">i2c_driver="a> ta href="+code=mc13xxx_i2c_driver" class="sref">mc13xxx_i2c_driver="a> = {=p 98="a>        .ta href="+code=id_tablv" class="sref">id_tablv="a> = ta href="+code=mc13xxx_i2c_device_id" class="sref">mc13xxx_i2c_device_id="a>,=p 99="a>        .ta href="+code=driver" class="sref">driver="a> = {=p100="a>                .ta href="+code=owner" class="sref">owner="a> = ta href="+code=THIS_MODULE" class="sref">THIS_MODULE="a>,=p101="a>                .ta href="+code=namv" class="sref">namv="a> = tspa  class="string">"mc13xxx"p102="a>                .ta href="+code=of_match_tablv" class="sref">of_match_tablv="a> = ta href="+code=mc13xxx_dt_ids" class="sref">mc13xxx_dt_ids="a>,=p103="a>        },=p104="a>        .ta href="+code=probv" class="sref">probvt/a> = ta href="+code=mc13xxx_i2c_probv" class="sref">mc13xxx_i2c_probvt/a>,=p105="a>        .ta href="+code=removv" class="sref">removvt/a> = ta href="+code=__devexit_p" class="sref">__devexit_pt/a>(ta href="+code=mc13xxx_i2c_removv" class="sref">mc13xxx_i2c_removvt/a>),=p106="a>};=p107t/a>=p108="a>static int ta href="+code=__init" class="sref">__initt/a> ta href="+code=mc13xxx_i2c_init" class="sref">mc13xxx_i2c_initt/a>(void)=p109="a>{=p110="a>        return ta href="+code=i2c_add_driver" class="sref">i2c_add_drivert/a>(&ta href="+code=mc13xxx_i2c_driver" class="sref">mc13xxx_i2c_driver="a>);=p111="a>}
p112t/a>ta href="+code=subsys_initcall" class="sref">subsys_initcallt/a>(ta href="+code=mc13xxx_i2c_init" class="sref">mc13xxx_i2c_initt/a>);=p113t/a>=p114="a>static void ta href="+code=__exit" class="sref">__exit="a> ta href="+code=mc13xxx_i2c_exit" class="sref">mc13xxx_i2c_exitt/a>(void)=p115="a>{=p116="a>        ta href="+code=i2c_del_driver" class="sref">i2c_del_drivert/a>(&ta href="+code=mc13xxx_i2c_driver" class="sref">mc13xxx_i2c_driver="a>);=p117="a>}
p118="a>ta href="+code=module_exit" class="sref">module_exitt/a>(ta href="+code=mc13xxx_i2c_exit" class="sref">mc13xxx_i2c_exitt/a>);=p119t/a>=p12e="a>ta href="+code=MODULE_DESCRIPTION" class="sref">MODULE_DESCRIPTIONt/a>(tspa  class="string">"i2c driver for Freescale MC13XXX PMIC"p121t/a>ta href="+code=MODULE_AUTHOR" class="sref">MODULE_AUTHORt/a>(tspa  class="string">"Marc Reilly <marc@cpdesign.com.au"p122t/a>ta href="+code=MODULE_LICENSE" class="sref">MODULE_LICENSEt/a>(tspa  class="string">"GPL v2"p123t/a>
The original LXR software by the ta href="http://sourceforge.net/projects/lxr">LXR community="a>, this experimental vers valby ta href="mailto:lxr@linux.no">lxr@linux.no="a>. t/div tdiv class="subfooter"> lxr.linux.no kindly hosted by ta href="http://www.redpill-linpro.no">Redpill Linpro AS="a>, provider of Linux consulting and operan> s services since 1995. t/div t/body t/html