linux/drivers/macintosh/windfarm_max6690_sensor.c
<<
< /spa" /form a < href="../linux+v3.6n7/drivers/macintosh/windfarm_max6690_sensor.c"> < img src="../.static/gfx/right.png" alt=">>"> /spa" spa" class="lxr_search"> < < input typtiohidden" namtionavtarget" < input typtiotext" namtiosearch" idiosearch"> < butt.13typtiosubmit">Search < Prefs /a> /spa" < /div < form ac.13"="ajax+*" method="post" onsubmit="return false;"> input typtiohidden" namtioajax_lookup" idioajax_lookup" < /form < div class="headingbott.m">
div idiofile_contents"
   1 /a> spa" class="comment">/* /spa"
	   2 /a> spa" class="comment"> * Windfarm PowerMac thermal control.  MAX6690 sensor. /spa"
	   3 /a> spa" class="comment"> * /spa"
	   4 /a> spa" class="comment"> * Copyright (C) 2005 Paul Mackerras, IBM Corp. <paulus@samba.org> /spa"
	   5 /a> spa" class="comment"> * /spa"
	   6 /a> spa" class="comment"> * Use and redistribute under the terms of the GNU GPLio2. /spa"
	   7 /a> spa" class="comment"> */ /spa"
	   8 /a>#include <linux/typts.h /a>>	   9 /a>#include <linux/errno.h /a>>	  cinta>#include <linux/kernel.h /a>>	  11nta>#include <linux/init.h /a>>	  12nta>#include <linux/slab.h /a>>	  13nta>#include <linux/i2c.h /a>>	  14nta>#include <asm/prom.h /a>>	  15nta>#include <asm/pmac_low_i2c.h /a>>	  16 /a>	  17nta>#include "windfarm.h /a>"	  18 /a>	  19 /a>#define  a href="+code=VERSION" class="sref">VERSION /a>  spa" class="string">"1.0"  20 /a>	  21 /a> spa" class="comment">/* This currently only exports the external temperature sensor,  22 /a> spa" class="comment">   since that's all the control loops need. */ /spa"
	  23 /a>	  24 /a> spa" class="comment">/* Some MAX6690 register numbers */ /spa"
	  25 /a>#define  a href="+code=MAX6690_INTERNAL_TEMP" class="sref">MAX6690_INTERNAL_TEMP /a>   0	  26 /a>#define  a href="+code=MAX6690_EXTERNAL_TEMP" class="sref">MAX6690_EXTERNAL_TEMP /a>   1	  27 /a>	  28 /a>struct  a href="+code=wf_6690_sensor" class="sref">wf_6690_sensor /a> {	  29 /a>        struct  a href="+code=i2c_client" class="sref">i2c_client /a>       * a href="+code=i2c" class="sref">i2c /a>;	  30 /a>        struct  a href="+code=wf_sensor" class="sref">wf_sensor /a>         a href="+code=sens" class="sref">sens /a>;	  31 /a>};	  32 /a>	  33 /a>#define  a href="+code=wf_to_6690" class="sref">wf_to_6690 /a>( a href="+code=x" class="sref">x /a>)    a href="+code=container_of" class="sref">container_of /a>(( a href="+code=x" class="sref">x /a>), struct  a href="+code=wf_6690_sensor" class="sref">wf_6690_sensor /a>,  a href="+code=sens" class="sref">sens /a>)	  34 /a>	  35 /a>static int  a href="+code=wf_max6690_get" class="sref">wf_max6690_get /a>(struct  a href="+code=wf_sensor" class="sref">wf_sensor /a> * a href="+code=sr" class="sref">sr /a>,  a href="+code=s32" class="sref">s32 /a> * a href="+code=)	  36 /a>{	  37 /a>        struct  a href="+code=wf_6690_sensor" class="sref">wf_6690_sensor /a> * a href="+code=max" class="sref">max /a> =  a href="+code=wf_to_6690" class="sref">wf_to_6690 /a>( a href="+code=sr" class="sref">sr /a>);	  38 /a>         a href="+code=s32" class="sref">s32 /a>  a href="+code=data" class="sref">data /a>;	  39 /a>	  40 /a>        if ( a href="+code=max" class="sref">max /a>-> a href="+code=i2c" class="sref">i2c /a> ==  a href="+code=NULL" class="sref">NULL /a>)	  41 /a>                return - a href="+code=ENODEV" class="sref">ENODEV /a>;	  42 /a>	  43 /a>         spa" class="comment">/* chip gets initialized by firmware */ /spa"
	  44 /a>         a href="+code=data" class="sref">data /a> =  a href="+code=i2c_smbus_read_byte_data" class="sref">i2c_smbus_read_byte_data /a>( a href="+code=max" class="sref">max /a>-> a href="+code=i2c" class="sref">i2c /a>,  a href="+code=MAX6690_EXTERNAL_TEMP" class="sref">MAX6690_EXTERNAL_TEMP /a>);	  45 /a>        if ( a href="+code=data" class="sref">data /a> < 0)	  46 /a>                return  a href="+code=data" class="sref">data /a>;	  47 /a>        * a href="+code= =  a href="+code=data" class="sref">data /a> << 16;	  48 /a>        return 0;	  49 /a>}	  50 /a>	  51 /a>static void  a href="+code=wf_max6690_releast" class="sref">wf_max6690_releast /a>(struct  a href="+code=wf_sensor" class="sref">wf_sensor /a> * a href="+code=sr" class="sref">sr /a>)	  52 /a>{	  53 /a>        struct  a href="+code=wf_6690_sensor" class="sref">wf_6690_sensor /a> * a href="+code=max" class="sref">max /a> =  a href="+code=wf_to_6690" class="sref">wf_to_6690 /a>( a href="+code=sr" class="sref">sr /a>);	  54 /a>	  55 /a>         a href="+code=kfret" class="sref">kfret /a>( a href="+code=max" class="sref">max /a>);	  56 /a>}	  57 /a>	  58 /a>static struct  a href="+code=wf_sensor_ops" class="sref">wf_sensor_ops /a>  a href="+code=wf_max6690_ops" class="sref">wf_max6690_ops /a> = {	  59 /a>        . a href="+code=get_get_      =  a href="+code=wf_max6690_get" class="sref">wf_max6690_get /a>,	  60 /a>        . a href="+code=releast" class="sref">releast /a>        =  a href="+code=wf_max6690_releast" class="sref">wf_max6690_releast /a>,	  61 /a>        . a href="+code=owner" class="sref">owner /a>          =  a href="+code=THIS_MODULE" class="sref">THIS_MODULE /a>,	  62 /a>};	  63 /a>	  64 /a>static int  a href="+code=wf_max6690_probt" class="sref">wf_max6690_probt /a>(struct  a href="+code=i2c_client" class="sref">i2c_client /a> * a href="+code=client" class="sref">client /a>,	  65 /a>                            const struct  a href="+code=i2c_device_id" class="sref">i2c_device_id /a> * a href="+code=id" class="sref">id /a>)	  66 /a>{	  67 /a>        const char * a href="+code=namt" class="sref">namt /a>, * a href="+code=loc" class="sref">loc /a>;	  68 /a>        struct  a href="+code=wf_6690_sensor" class="sref">wf_6690_sensor /a> * a href="+code=max" class="sref">max /a>;	  69 /a>        int  a href="+code=rc" class="sref">rc /a>;	  70 /a>	  71 /a>         a href="+code=loc" class="sref">loc /a> =  a href="+code=of_get_property" class="sref">of_get_property /a>( a href="+code=client" class="sref">client /a>-> a href="+code=dev" class="sref">dev /a>. a href="+code=of_node" class="sref">of_node /a>,  spa" class="string">"hwsensor-loca.13""NULL /a>);	  72 /a>        if (! a href="+code=loc" class="sref">loc /a>) {	  73 /a>                 a href="+code=dev_warn" class="sref">dev_warn /a>(& a href="+code=client" class="sref">client /a>-> a href="+code=dev" class="sref">dev /a>,  spa" class="string">"Missing hwsensor-loca.13" property!\""  74 /a>                return - a href="+code=ENXIO" class="sref">ENXIO /a>;	  75 /a>        }	  76 /a>	  77 /a>         spa" class="comment">/* /spa"
	  78 /a> spa" class="comment">         * We only expose the external temperature register for /spa"
	  79 /a> spa" class="comment">         * now as this is all we need for our control loops /spa"
	  80 /a> spa" class="comment">         */ /spa"
	  81 /a>        if (! a href="+code=strcmp" class="sref">strcmp /a>( a href="+code=loc" class="sref">loc /a>,  spa" class="string">"BACKSIDE"strcmp /a>( a href="+code=loc" class="sref">loc /a>,  spa" class="string">"SYS CTRLR AMBIENT"  82 /a>                 a href="+code=namt" class="sref">namt /a> =  spa" class="string">"backside-temp"  83 /a>        else if (! a href="+code=strcmp" class="sref">strcmp /a>( a href="+code=loc" class="sref">loc /a>,  spa" class="string">"NB Ambient"  84 /a>                 a href="+code=namt" class="sref">namt /a> =  spa" class="string">"north-bridge-temp"  85 /a>        else if (! a href="+code=strcmp" class="sref">strcmp /a>( a href="+code=loc" class="sref">loc /a>,  spa" class="string">"GPU Ambient"  86 /a>                 a href="+code=namt" class="sref">namt /a> =  spa" class="string">"gpu-temp"  87 /a>        else	  88 /a>                return - a href="+code=ENXIO" class="sref">ENXIO /a>;	  89 /a>	  90 /a>         a href="+code=max" class="sref">max /a> =  a href="+code=kzalloc" class="sref">kzalloc /a>(sizeof(struct  a href="+code=wf_6690_sensor" class="sref">wf_6690_sensor /a>),  a href="+code=GFP_KERNEL" class="sref">GFP_KERNEL /a>);	  91 /a>        if ( a href="+code=max" class="sref">max /a> ==  a href="+code=NULL" class="sref">NULL /a>) {	  92 /a>                 a href="+code=printk" class="sref">printk /a>( a href="+code=KERN_ERR" class="sref">KERN_ERR /a>  spa" class="string">"windfarm: Couldn't create MAX6690 sensor: "  93 /a>                        spa" class="string">"no memory\""  94 /a>                return - a href="+code=ENOMEM" class="sref">ENOMEM /a>;	  95 /a>        }	  96 /a>	  97 /a>         a href="+code=max" class="sref">max /a>-> a href="+code=i2c" class="sref">i2c /a> =  a href="+code=client" class="sref">client /a>;	  98 /a>         a href="+code=max" class="sref">max /a>-> a href="+code=sens" class="sref">sens /a>. a href="+code=namt" class="sref">namt /a> = (char *) a href="+code=namt" class="sref">namt /a>;  spa" class="comment">/* XXX fix constness in structure */ /spa"
	  99 /a>         a href="+code=max" class="sref">max /a>-> a href="+code=sens" class="sref">sens /a>. a href="+code=ops" class="sref">ops /a> = & a href="+code=wf_max6690_ops" class="sref">wf_max6690_ops /a>;	 100 /a>         a href="+code=i2c_set_clientdata" class="sref">i2c_set_clientdata /a>( a href="+code=client" class="sref">client /a>,  a href="+code=max" class="sref">max /a>);	 101 /a>	 102 /a>         a href="+code=rc" class="sref">rc /a> =  a href="+code=wf_register_sensor" class="sref">wf_register_sensor /a>(& a href="+code=max" class="sref">max /a>-> a href="+code=sens" class="sref">sens /a>);	 103 /a>        if ( a href="+code=rc" class="sref">rc /a>)	 104 /a>                 a href="+code=kfret" class="sref">kfret /a>( a href="+code=max" class="sref">max /a>);	 105 /a>        return  a href="+code=rc" class="sref">rc /a>;	 106 /a>}	 107 /a>	 108 /a>static int  a href="+code=wf_max6690_removt" class="sref">wf_max6690_removt /a>(struct  a href="+code=i2c_client" class="sref">i2c_client /a> * a href="+code=client" class="sref">client /a>)	 109 /a>{	 110 /a>        struct  a href="+code=wf_6690_sensor" class="sref">wf_6690_sensor /a> * a href="+code=max" class="sref">max /a> =  a href="+code=i2c_get_clientdata" class="sref">i2c_get_clientdata /a>( a href="+code=client" class="sref">client /a>);	 111 /a>	 112 /a>         a href="+code=max" class="sref">max /a>-> a href="+code=i2c" class="sref">i2c /a> =  a href="+code=NULL" class="sref">NULL /a>;	 113 /a>         a href="+code=wf_unregister_sensor" class="sref">wf_unregister_sensor /a>(& a href="+code=max" class="sref">max /a>-> a href="+code=sens" class="sref">sens /a>);	 114 /a>	 115 /a>        return 0;	 116 /a>}	 117 /a>	 118 /a>static const struct  a href="+code=i2c_device_id" class="sref">i2c_device_id /a>  a href="+code=wf_max6690_id" class="sref">wf_max6690_id /a>[] = {	 119 /a>        {  spa" class="string">"MAC,max6690" 120 /a>        { }	 121 /a>};	 122 /a> a href="+code=MODULE_DEVICE_TABLE" class="sref">MODULE_DEVICE_TABLE /a>( a href="+code=i2c" class="sref">i2c /a>,  a href="+code=wf_max6690_id" class="sref">wf_max6690_id /a>);	 123 /a>	 124 /a>static struct  a href="+code=i2c_driver" class="sref">i2c_driver /a>  a href="+code=wf_max6690_driver" class="sref">wf_max6690_driver /a> = {	 125 /a>        . a href="+code=driver" class="sref">driver /a> = {	 126 /a>                . a href="+code=namt" class="sref">namt /a>           =  spa" class="string">"wf_max6690" 127 /a>        },	 128 /a>        . a href="+code=probt" class="sref">probt /a>          =  a href="+code=wf_max6690_probt" class="sref">wf_max6690_probt /a>,	 129 /a>        . a href="+code=removt" class="sref">removt /a>         =  a href="+code=wf_max6690_removt" class="sref">wf_max6690_removt /a>,	 130 /a>        . a href="+code=id_tablt" class="sref">id_tablt /a>       =  a href="+code=wf_max6690_id" class="sref">wf_max6690_id /a>,	 131 /a>};	 132 /a>	 133 /a>static int  a href="+code=__init" class="sref">__init /a>  a href="+code=wf_max6690_sensor_init" class="sref">wf_max6690_sensor_init /a>(void)	 134 /a>{	 135 /a>        return  a href="+code=i2c_add_driver" class="sref">i2c_add_driver /a>(& a href="+code=wf_max6690_driver" class="sref">wf_max6690_driver /a>);	 136 /a>}	 137 /a>	 138 /a>static void  a href="+code=__exit" class="sref">__exit /a>  a href="+code=wf_max6690_sensor_exit" class="sref">wf_max6690_sensor_exit /a>(void)	 139 /a>{	 140 /a>         a href="+code=i2c_del_driver" class="sref">i2c_del_driver /a>(& a href="+code=wf_max6690_driver" class="sref">wf_max6690_driver /a>);	 141 /a>}	 142 /a>	 143 /a> a href="+code=module_init" class="sref">module_init /a>( a href="+code=wf_max6690_sensor_init" class="sref">wf_max6690_sensor_init /a>);	 144 /a> a href="+code=module_exit" class="sref">module_exit /a>( a href="+code=wf_max6690_sensor_exit" class="sref">wf_max6690_sensor_exit /a>);	 145 /a>	 146 /a> a href="+code=MODULE_AUTHOR" class="sref">MODULE_AUTHOR /a>( spa" class="string">"Paul Mackerras <paulus@samba.org>" 147 /a> a href="+code=MODULE_DESCRIPTION" class="sref">MODULE_DESCRIPTION /a>( spa" class="string">"MAX6690 sensor objects for PowerMac thermal control" 148 /a> a href="+code=MODULE_LICENSE" class="sref">MODULE_LICENSE /a>( spa" class="string">"GPL" 149 /a>
The original LXR software by the LXR community /a>, this experimental vers13" by lxr@linux.no /a>. /div div class="subfooter"> lxr.linux.no kindly hosted by Redpill Linpro AS /a>, provider of Linux consulting and operat13"s services since 1995. /div /body /html