linux/drivers/hwmon/ltc4261.c
<<
>>
Prefs
   1/*
   2 * Driver for Linear Technology LTC4261 I2C Negative Voltage Hot Swap Controller
   3 *
   4 * Copyright (C) 2010 Ericsson AB.
   5 *
   6 * Derived from:
   7 *
   8 *  Driver for Linear Technology LTC4245 I2C Multiple Supply Hot Swap Controller
   9 *  Copyright (C) 2008 Ira W. Snyder <iws@ovro.caltech.edu>
  10 *
  11 * Datasheet: http://cds.linear.com/docs/Datasheet/42612fb.pdf
  12 *
  13 * This program is free software; you can redistribute it and/or modify
  14 * it under the terms of the GNU General Public License as published by
  15 * the Free Software Foundation; either version 2 of the License, or
  16 * (at your option) any later version.
  17 *
  18 * This program is distributed in the hope that it will be useful,
  19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
  20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  21 * GNU General Public License for more details.
  22 *
  23 * You should have received a copy of the GNU General Public License
  24 * along with this program; if not, write to the Free Software
  25 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  26 */
  27
  18#includeyder /a>
"../l/kernel.h  18.edu
"../l//orule.h  18.edu
"../l/init.h  18.edu
"../l/err.h  18.edu
"../l/slab.h  18.edu
"../l/i2c.h  18.edu
"../l/ers/h.h  18.edu
"../l/ers/h-sysfs.h  18.edu
 */
  18#deftho>
	  ogy LTC_STATUS  18  0x00>
   /a> */
ogy LTC_FAULT  18   0x01pan>
ogy LTC_ALERT  18   0x02pan>
ogy LTC_CONTROL  18 0x03pan>
ogy LTC_SENSE_H  18 0x04pan>
ogy LTC_SENSE_L  18 0x05pan>
ogy LTC_ADIN2_H  18 0x06pan>
ogy LTC_ADIN2_L  18 0x07pan>
ogy LTC_ADIN_H  18  0x08pan>
ogy LTC_ADIN_L  18  0x09pan>

/*
/*
 */
FAULT_OV  18        (1der der 0)pan>
FAULT_UV  18        (1der der 1)pan>
FAULT_OC  18        (1der der 2)pan>
mon/ltc_data  18 {
device  18 *
	  ers/h_dev  18u

mutex  18 
	  update_lock  18u
bool  18 
	  valid  18u
mast_updated  18u >
   /a> */
 */
u8  18 
	  avgs  18[10]u
mon/ltc_data  18 *
	  mon/ltc_update_device  18(struct>
	  device  18 *
	  dev  18)pan>

i2c_clicom  18 *
	  clicom  18 =>
	  to_i2c_clicom  18(
	  dev  18)u
mon/ltc_data  18 *
	  data  18 =>
	  i2c_get_clicomdata  18(
	  clicom  18)u
mon/ltc_data  18 *
	  rem  18 =>
	  data  18u
mutex_lock  18(&
	  data  18-.edu&	  update_lock  18)u
time_af dr  18(
	  jiffiei  18,>
	  data  18-.edu&	  mast_updated  18 +>
	  HZ  18 / 4) || !
	  data  18-.edu&	  valid  18) {
i  18u
 */
i  18 =>0;>
	  i  18yder >
	  NY WY_SIZE  18(
	  data  18-.edu&	  avgs  18);>
	  i  18++) {
val  18u
val  18 =>
	  i2c_smbus_read_byte_data  18(
	  clicom  18,>
	  i  18)u
unlikely  18(
	  val  18 der >0)) {
dev_dbg  18(
	  dev  18,
"Failed>to read ADCkup" v: errse %d\n"> */
val  18)u
rem  18 =>
	  ERR_PTR  18(
	  val  18)u
data  18-.edu&	  valid  18 =>0;
aborm  18u
data  18-.edu&	  avgs  18[
	  i  18] =>
	  val  18u
data  18-.edu&	  mast_updated  18 =>
	  jiffiei  18u
data  18-.edu&	  valid  18 =>1u
aborm  18:
mutex_unlock  18(&
	  data  18-.edu&	  update_lock  18)u
rem  18u

   1 */

	  mon/ltc_get_up" v  18(struct>
	  mon/ltc_data  18 *
	  data  18,>
	  u8  18 
	  avg  18)pan>

u32  18>
	  val  18u

val  18 =>(
	  data  18-.edu&	  avgs  18[
	  avg  18] der der  2) +>(
	  data  18-.edu&	  avgs  18[
	  avg  18 +>1] dt="> 6)u
  27
(
	  avg  18) {

	  ogy LTC_ADIN_H  18:
ogy LTC_ADIN2_H  18:
to mV.nt"> */
val  18 =>
	  val  18 t 25 /2e=u
ogy LTC_SENSE_H  18:
/*
  16to currcomensemeasurmpliith">/*
  17 */actualan>
   191* but WITHOUT ANY WARRANTY; wn/ltc4261.c#L23" idivi
   "> */repon/rs/n>
 */rcomes License on/ltc_ltc4261.c#L12" id="L12" class="line" name=ee="L1110 201* MERCHANTABILITY or FITNESS n/ltc4261.c#L23" ispaniffon/ltc4261.c#L17" id="L17" class="line" namee="L21"> 1 211* GNU General Public License n/ltc4261.c#L23" on/ltc42611.c#L12" idd="L12" class="line" na2="L12">  112val  18 =>
	  val  18 t 25 /2e=u
 1 2312a href="drivers/hwmon/ltc42611.c#L14" idd="L14" class="line" nae="L24"> 1 2412ogy LTC_SENSEdefhref2611.c#L15" idd="L15" class="line" nae="L25"> 1 2512ass="comment">/*
 */developrefmessrs/up" on/ltc42611.c#L12" idd="L12" class="line" na2ee="L11"> 2612            
	   1 27
42611.c#L13" idd="L13" class="line" naeee="L11uo 18#includeyder /a>
   18#includeyder /a>
rem  18u
  1131de="..6110c#L10" id=="L10" class="line" na3="L24"> 1 18#includeyder /a>
val  18u

	  mon/lt
	  dev  18)pan>
"aults" clasisf">mon/lt
	  data  18,>
	  ucharf">data  18,>
	  bufa hrecode=avgsubufltc426110c#L13" id0="L13" class="line" na3="L2636 1 27
device  18 *rcomor_
	  data  18,>
	  atwihref="drivers/hwtwiasisf">val  18 t 25 /2t typomor_
	 _atwihref="drivers/ht typomor_
	 _atwisisf">data  18-.edu&	 a hrecode=avgsultisf"426110c#L17" id0="L17" class="line" na3#L18"3> 1 18#deftho>
	  device  18 *c_data  18 *
	  data  18 =>
	  f">mon/ltc_update_device  18(struct>
	  
   18#deftho>
	  val  18u

	  p" v c_da26110c#L17" id0="L17" class="line" na4="L2040 1 18#deftho>
	  unlikely  IS_ERa hrecode=valultIS_ERasisf">data  18-.edu&	 a hrecode=i2c_get_clicomd)26110c#L13" id0="L13" class="line" na4="L2242 1 18#deftho>
	  asisf">rem  18u
data  18-.edu&	 a hrecode=i2c_get_clicomd)26110c#L17" id0="L17" class="line" na4="L13">   18#deftho>
	  u32  18>
	  
	  p" v c_daataults" clasisf">f">mon/let_up" v  18(struct>
	  data  18,>
	  u8  18 
	  avgs  18[
	  rem  18u
data  18,>
	  bufa hrecode=avgsubufltc4>u8  18 
	  u8to read ADCkup" v: errse &f="drivers/hwmon/ltc42>u32  18>
	  
	  p" v c_da)26110c#L17" id0="L17" class="line" na4="L2636 1 18#deftho>
	  
val  18u
mon/lt
	  dev  18)pan>
14    goto &	  mon/lt
	  data  18,>
	  ucharf">data  18,>
	  bufa hrecode=avgsubufltc426110c#L13" id0="L13" class="line" na5="L205> 1 2015e=mon/ltc_dataults" clasisf">mon/ltrcomor_
	  data  18,>
	  atwihref="drivers/hwtwiasisf">val  18 t 25 /2t typomor_
	 _atwihref="drivers/ht typomor_
	 _atwisisf">data  18-.edu&	 a hrecode=avgsultisf"426110c#L17" id0="L17" class="line" n15="L2252 1 18#deftho>
	  mon/ltom  18 *
	  clicom  18 =>
	  to_i2c_clicom  18(
	  dev  18)u
mon/ltc_data  18 *
	  data  18 =>
	  f">mon/ltc_update_device  18(struct>
	  
u8  18 
	  avgs  18[10]uunlikely  IS_ERa hrecode=valultIS_ERasisf">data  18-.edu&	 a hrecode=i2c_get_clicomd)26110c#L13" id0="L13" class="line" na5="L2757 1 18        struct>
	  rem  18u
data  18-.edu&	 a hrecode=i2c_get_clicomd)26110c#L17" id0="L17" class="line" na5#L18"58 1 27
avgs  18[10]udata  18u
avgs  18[
	  avg  18 +>1] dtTC_FAULT  18   0x01pan>
avgs  18[
	  unlikely  fhrefode=avgsults" cfhrefc_da) 
mon/ltom  recodepan>
s_read_byte_data  18(
	  
s_read_bytsisf">data  18-.edu&
	  i  18)u

unlikely  fhrefode=avgsults" cfhrefc_da)26110c#L17" id0="L17" class="line" na6="L2252 1 27
rem  18u
data  18,>
	  bufa hrecode=avgsubufltc4>u8  18 
	  u8to read ADCkup" v: errse &f="drivers/hwmon/ltc42>u32  18>
	  
iusrrite ters/h_creode=group()iversake aters/h"device ne" n/ltc42615c#L21" i5="L21" class="line" nam16="L1959 1 18        struct>
	  ieach"drivers/on/ltc4261.c#L17" id="L17" class="line" name=="L2060 1 18        struct>
	  /*
ogy LTC_SENVALU  data  18,>
	  driv u8  18 
	  u8  18 
	  
	  u8  18 
	  
u8  18 
	  ogy LTC_ADINBO 18 0x03pan>
  117<1span 1lass="comme/* val  18u
u8  18 
	  
ut>data  18,>
	  mas&
	  /*mon/ltc42611.c#L16" idd="L16" class="line" na8="L2181 1 27
ogy LTC_SENVALU  data  18,>
	  in1_x_loorecode=update_lin1_x_loosf">i  18)u

ogy LTC_SENVALU  data  18,>
	  in2_x_loorecode=update_lin2_x_loosf">i  18)u


 osTaalarms wmon/ltc4261.c#L25" id="L25" class="line" nam18="L1989 1 18                     1     18 but WITHOUT ANY WARRANTY; witANYocimltsrite to e /hwmo ypomor, du
/*
ogy LTC_SENBO 18 0x03pan>
i  18)u

ogy LTC_SENBO 18 0x03pan>
i  18)u

aborm  18:
i  18)u

aborm  18:
i  18)u



ogy LTC_SENVALU  data  18,>
	  n>
<1_x_loorecode=update_ln>
<1_x_loosf">i  18)u


	  
    18{
ogy LTC_SENBO 18 0x03pan>
i  18)u

    18        
	  
mon/ltatwill be hrecode=devultatwill beasisf">data  18,>
	  dataultsatwill berecode=avgults" dataultsatwill berisf">sf">26110c#L19" id0="L19" class="line" n2me06"L2e=2  18        
	  sisf">data  18-.edu&ypomor_
	 _atwi_in1_x_loorecode=update_lypomor_
	 _atwi_in1_x_loos" c.dev  18)pan>

sisf">data  18-.edu&ypomor_
	 _atwi_in1_min_alarmrecode=update_lypomor_
	 _atwi_in1_min_alarms" c.dev  18)pan>
    18        switch>(
	  2a hre2ode=avgults" csisf">data  18-.edu&ypomor_
	 _atwi_in1_max_alarmrecode=update_lypomor_
	 _atwi_in1_max_alarms" c.dev  18)pan>
data  18-.edu&ypomor_
	 _atwi_in2_x_loorecode=update_lypomor_
	 _atwi_in2_x_loos" c.dev  18)pan>
data  18-.edu&ypomor_
	 _atwi_in2_min_alarmrecode=update_lypomor_
	 _atwi_in2_min_alarms" c.dev  18)pan>
2span 2lass="comment sisf">data  18-.edu&ypomor_
	 _atwi_in2_max_alarmrecode=update_lypomor_
	 _atwi_in2_max_alarms" c.dev  18)pan>
data  18-.edu&ypomor_
	 _atwi_n>
<1_x_loorecode=update_lypomor_
	 _atwi_n>
<1_x_loos" c.dev  18)pan>
    18        caso>
	  data  18-.edu&ypomor_
	 _atwi_n>
<1_max_alarmrecode=update_lypomor_
	 _atwi_n>
<1_max_alarmsf">.dev  18)pan>
2span 21ltc42615c#L26" i5="L26" class="line" nam2mee="L11"2  16val  18 =>(
	  NUL8  0x09pan>
615c#L26" i5="L26" class="line" nam2me07"L2e=2  17 2 192* but ltc_datronautaults" clasisf">mon/ltatwill be=group hrecode=devultatwill be=groups" cl>data  18,>
	  dataultsgroup hrecode=devultdataultsgroups" cl">26110c#L19" id0="L19" class="line" n2=ee="L1112 2022ogy LTC_ADIN2.dev  18)pan>
>data  18,>
	  dataultsatwill berecode=avgults" dataultsatwill berisf">615c#L26" i5="L26" class="line" nam2e="L21"> 2 212* GNU 42616.c#L6" idd="L6" class="line" nam22="L12"> 2112 2 2322a hre_get_up" vults" clasisf">mon/ltc_gprob  18(struct>
	  mon/ltom  18 *
	  clicom  18 =>
	  615c#L26" i5="L26" class="line" nam2e="L24">   2422ogy LTC_SENSEEEEEEEEEEEEEEEEEEronautaults" clasisf">mon/lticom
	  
clicom  18 =a>
 2 2522ass="26110c#L19" id0="L19" class="line" n2=ee="L11"2 2622            
aults" clasisf">mon/lticomadap
	  clicom  18 =adap
	  >data  18,>
	  >
	  avgs  18[
	  
device  18 *c_data  18 *
	  data  18 =>
	  m href="drivers/hwmon/ltc42619.c#L9" idd="L9" class="line" nam2e="L19"> 2 18#includeyder /a>
data  18-.edu&icommheck_funcrmplalitdata  18,>
	  adap
	  
- 18)u
 2113233ts" clasisf"clas>data  18-.edu&icom">i2c_smbus_read_byte_data  18(
	  clicom  18,>
	  i  18)u

 2 18#includeyder /a>
data  18-.edu&		 _erihref="drivers/h
	 _erilasissisf">data  18-.edu&>
	  avgs  18[
	  < href="drivers/hwmon/ltc42d>to read ADCkup" v: errse %d\n"> auetus/drivers/vers/hwmon/ltc4)26110c#L17" id0="L17" class="line" n23="L2535 2 18#includeyder /a>
- 18)u

 2 18#deftho>
	  
on/m_kzallocef="drivers/hwmon/m_kzalloclasissisf">data  18-.edu&>
	  avgs  18[
	  < href="drivers/hwmon/ltc42dsizeof(">data  18 =>
	  

 2 18#deftho>
	  data  18-.edu& - 18)u
data  18-.edu&icom"et_clicomdata  18(
	  clicom  18)u
data  18-.edu&	   2 18#deftho>
	  mutex_lock  18inidata  18-.edu&	  update_lock  18)u
val  18 =>(
	  om  recodepan>
s_read_byte_data  18(
	  
s_read_bytsisf">data  18-.edu&
	  i  18)u


 2 1924e=mutexults" >avgs  18[10]uERR_PTR  18ers/h_creode=grouprecode=update_lyrs/h_creode=grouplasissisf">data  18-.edu&>
	  avgs  18[
	  < href="drivers/hwmon/ltc4.dev  18)pan>
data  18-.edu&dataultsgroup hrecode=devultdataultsgroups" c42619.c#L8" i9d="L8" class="line" nam25="L205> 2 20unlikely  a hrecode=ERR_PTRmlts" cl)6110c#L17" id0="L17" class="line" n25="L215> 2 2125ass="comment 2.5mVLreasisf">lts" clasisf">m href="drivers/hwmon/ltc42619.c#L9" idd="L9" class="line" nam25="L2252 2 18#deftho>
	  mutex_lo	  update_ clas_ href="drivers/hwm clas_ hr" clasisf">ERR_PTR  18 clas_ hr data  18-.edu&>
	  avgs  18[
	  < href="drivers/hwmon/ltc442619.c#L8" i9d="L8" class="line" nam25="L2444 2 18#deftho>
	  uclasisf">unlikely  IS_ERa hrecode=valultIS_ERasisf">data  18-.edu&	 a hrecode=i2c_get_clicomdts" clasisf">update_ clas_ href="drivers/hwm clas_ hr" cltc42618.c#L4" i8d="L4" class="line" nam2e="L2555 2 27
/*ERR_PTR  18PTR_ERa hrecode=valultPTR_ERasisf">data  18-.edu&	 a hrecode=i2c_get_clicomdts" clasisf">update_ clas_ href="drivers/hwm clas_ hr" clt2619.c#L8" i9d="L8" class="line" nam25="L2636 2 18struct>
	  aborm  18u
42611.c#L13" idd="L13" class="line" n26="L2060 2 18        
	  aborm  18udata  18-.edu&yrs/h_remove=grouprecode=update_lyrs/h_remove=grouplasissisf">data  18-.edu&>
	  avgs  18[
	  < href="drivers/hwmon/ltc4.dev  18)pan>
data  18-.edu&dataultsgroup hrecode=devultdataultsgroups" c42619.c#L8" i9d="L8" class="line" nam26="L2363 2 18        
/a>rem  18u
mon/ltc_gremove hrecode=devultdataultsremovec_dataults" clasisf">mon/ltom  18 *
	  clicom  18 =>
	  
device  18 *c_data  18 *
	  data  18 =>
	  icomget_clicomdata  18(
	  clicom  18)u

	  data  18-.edu& clas_ hr data  18-.edu&	 a hrecode=i2c_get_clicomdts" clasisf">update_ clas_ href="drivers/hwm clas_ hr" clt2619.c#L8" i9d="L8" class="line" nam27="L2171 2 18        struct>
	  data  18-.edu&yrs/h_remove=grouprecode=update_lyrs/h_remove=grouplasissisf">data  18-.edu&>
	  avgs  18[
	  < href="drivers/hwmon/ltc4.dev  18)pan>
data  18-.edu&dataultsgroup hrecode=devultdataultsgroups" c42619.c#L8" i9d="L8" class="line" nam27="L2272 2 27
42611.c#L13" idd="L13" class="line" n27="L2454 2 27
mon/lticom
	  
clas>sf">26110c#L19" id0="L19" class="line" n27="L17"> 2117<2span 2lass="comme/* {26110c#L10" id=="L10" class="line" n27="L1959 2 18                nse (2
	  <2 hreco42616.c#L6" idd="L6" class="line" nam28="L2080 2 18                     2   in28ltc426110c#L11" id0="L11" class="line" n28="L2181 2 27
aborm  18udata  18-.edu&ico
i  18)u

 */d6d="Ln>
mon/lticom
d="L2
data  18-.edu&dataults
d="L2


 2 18                     2     28    
	  

	  prob c_dal">>data  18,>
	  dataultsprob  18(struct>
	  
>data  18,>
	  dataultsremove hrecode=devultdataultsremovec_da26110c#L19" id0="L19" class="line" n2=="L2080 2 18                     2   }<29ogy LTC_ADIN2.dev  18)pan>
>data  18,>
	  dataultsa>
ogymodule_icom
d="L2
data  18-.edu&dataults
d="L2
ogyMODULE_AUTHOa hrecode=valultMODULE_AUTHOasisf">to read ADCkup" v: errse &Guved"LnRoeckhwmon}aborm  18:to read ADCkup" v: errse &ref="dr/d6d="Lrs/hwmon/ltc4)26110c#L17" id0="L17" class="line" n29="L17"> 2 18        
	  aborm  18:to read ADCkup" v: errse &GPLrs/hwmon/ltc4)26110c#L17" id0="L17" class="line" n29#L18"68 2 18        it="ret
	  


Thehoriginal LXR softwn 2 mo"> */110c#L17"http://sourceforge.net/projecmo/lx/e>LXR eceiunit ss"experiivedal 0="Lmplcmo"110c#L17"mailto:lx/@}
dx/.}