Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions
w83781d.c File Reference
#include <linux/module.h>
#include <linux/init.h>
#include <linux/slab.h>
#include <linux/jiffies.h>
#include <linux/i2c.h>
#include <linux/hwmon.h>
#include <linux/hwmon-vid.h>
#include <linux/hwmon-sysfs.h>
#include <linux/sysfs.h>
#include <linux/err.h>
#include <linux/mutex.h>
#include "lm75.h"

Go to the source code of this file.

Data Structures

struct  w83781d_data
 

Macros

#define pr_fmt(fmt)   KBUILD_MODNAME ": " fmt
 
#define W83781D_EXTENT   8
 
#define W83781D_ADDR_REG_OFFSET   5
 
#define W83781D_DATA_REG_OFFSET   6
 
#define W83781D_REG_IN_MAX(nr)
 
#define W83781D_REG_IN_MIN(nr)
 
#define W83781D_REG_IN(nr)
 
#define W83781D_REG_FAN_MIN(nr)   (0x3b + (nr))
 
#define W83781D_REG_FAN(nr)   (0x28 + (nr))
 
#define W83781D_REG_BANK   0x4E
 
#define W83781D_REG_TEMP2_CONFIG   0x152
 
#define W83781D_REG_TEMP3_CONFIG   0x252
 
#define W83781D_REG_TEMP(nr)
 
#define W83781D_REG_TEMP_HYST(nr)
 
#define W83781D_REG_TEMP_OVER(nr)
 
#define W83781D_REG_CONFIG   0x40
 
#define W83781D_REG_ALARM1   0x41
 
#define W83781D_REG_ALARM2   0x42
 
#define W83782D_REG_ALARM1   0x459
 
#define W83782D_REG_ALARM2   0x45A
 
#define W83782D_REG_ALARM3   0x45B
 
#define W83781D_REG_BEEP_CONFIG   0x4D
 
#define W83781D_REG_BEEP_INTS1   0x56
 
#define W83781D_REG_BEEP_INTS2   0x57
 
#define W83781D_REG_BEEP_INTS3   0x453 /* not on W83781D */
 
#define W83781D_REG_VID_FANDIV   0x47
 
#define W83781D_REG_CHIPID   0x49
 
#define W83781D_REG_WCHIPID   0x58
 
#define W83781D_REG_CHIPMAN   0x4F
 
#define W83781D_REG_PIN   0x4B
 
#define W83781D_REG_VBAT   0x5D
 
#define W83781D_REG_PWMCLK12   0x5C
 
#define W83781D_REG_PWMCLK34   0x45C
 
#define W83781D_REG_I2C_ADDR   0x48
 
#define W83781D_REG_I2C_SUBADDR   0x4A
 
#define W83781D_REG_SCFG1   0x5D
 
#define W83781D_REG_SCFG2   0x59
 
#define W83781D_DEFAULT_BETA   3435
 
#define IN_TO_REG(val)   SENSORS_LIMIT(((val) + 8) / 16, 0, 255)
 
#define IN_FROM_REG(val)   ((val) * 16)
 
#define TEMP_TO_REG(val)   SENSORS_LIMIT((val) / 1000, -127, 128)
 
#define TEMP_FROM_REG(val)   ((val) * 1000)
 
#define BEEP_MASK_FROM_REG(val, type)
 
#define BEEP_MASK_TO_REG(val, type)
 
#define DIV_FROM_REG(val)   (1 << (val))
 
#define show_in_reg(reg)
 
#define store_in_reg(REG, reg)
 
#define sysfs_in_offsets(offset)
 
#define show_fan_reg(reg)
 
#define show_temp_reg(reg)
 
#define store_temp_reg(REG, reg)
 
#define sysfs_temp_offsets(offset)
 
#define IN_UNIT_ATTRS(X)
 
#define FAN_UNIT_ATTRS(X)
 
#define TEMP_UNIT_ATTRS(X)
 

Enumerations

enum  chips {
  ad7416, ad7417, ad7418, adm1021,
  adm1023, max1617, max1617a, thmc10,
  lm84, gl523sm, mc1066, adm1025,
  ne1619, adm1030, adm1031, adm9240,
  ds1780, lm81, adt7473, adt7475,
  adt7476, adt7490, amc6821, dme1737,
  sch5027, sch311x, sch5127, f71808e,
  f71808a, f71858fg, f71862fg, f71869,
  f71869a, f71882fg, f71889fg, f71889ed,
  f71889a, f8000, f81865f, f75373,
  f75375, f75387, fscpos, fscher,
  fscscy, fschrc, fschmd, fschds,
  fscsyl, gl518sm_r00, gl518sm_r80, it87,
  it8712, it8716, it8718, it8720,
  it8721, it8728, it8782, it8783,
  lm63, lm64, lm96163, lm78,
  lm79, lm83, lm82, any_chip,
  lm85b, lm85c, adm1027, adt7463,
  adt7468, emc6d100, emc6d102, emc6d103,
  emc6d103s, lm87, adm1024, lm90,
  adm1032, lm99, lm86, max6657,
  max6659, adt7461, max6680, max6646,
  w83l771, max6696, sa56004, g781,
  max1110, max1111, max1112, max1113,
  max16065, max16066, max16067, max16068,
  max16070, max16071, max1668, max1805,
  max1989, mcp3021, mcp3221, adm1075,
  adm1275, adm1276, lm25066, lm5064,
  lm5066, ltc2978, ltc3880, max34440,
  max34441, max34446, ucd9000, ucd90120,
  ucd90124, ucd9090, ucd90910, ucd9200,
  ucd9220, ucd9222, ucd9224, ucd9240,
  ucd9244, ucd9246, ucd9248, zl2004,
  zl2005, zl2006, zl2008, zl2105,
  zl2106, zl6100, zl6105, zl9101,
  zl9117, smm465, smm665, smm665c,
  smm764, smm766, smsc47m1, smsc47m2,
  thmc50, adm1022, tmp401, tmp411,
  tmp421, tmp422, tmp423, w83627hf,
  w83627thf, w83697hf, w83637hf, w83687thf,
  w83781d, w83782d, w83783s, as99127f,
  DC21040 = 0, DC21041 = 1, DC21140 = 2, DC21142 = 3,
  DC21143 = 3, LC82C168, MX98713, MX98715,
  MX98725, AX88140, PNIC2, COMET,
  COMPEX9881, I21145, DM910X, CONEXANT,
  TPS62360, TPS62361, TPS62362, TPS62363,
  sc18is602, sc18is602b, sc18is603, f71808fg,
  f71858fg, f71862fg, f71869, f71882fg,
  f71889fg
}
 

Functions

 module_param_array (force_subclients, short, NULL, 0)
 
 MODULE_PARM_DESC (force_subclients,"List of subclient addresses: ""{bus, clientaddr, subclientaddr1, subclientaddr2}")
 
 module_param (reset, bool, 0)
 
 MODULE_PARM_DESC (reset,"Set to one to reset chip on load")
 
 module_param (init, bool, 0)
 
 MODULE_PARM_DESC (init,"Set to zero to bypass chip initialization")
 
 show_in_reg (in)
 
 show_in_reg (in_min)
 
 show_in_reg (in_max)
 
 store_in_reg (MIN, min)
 
 store_in_reg (MAX, max)
 
 sysfs_in_offsets (0)
 
 sysfs_in_offsets (1)
 
 sysfs_in_offsets (2)
 
 sysfs_in_offsets (3)
 
 sysfs_in_offsets (4)
 
 sysfs_in_offsets (5)
 
 sysfs_in_offsets (6)
 
 sysfs_in_offsets (7)
 
 sysfs_in_offsets (8)
 
 show_fan_reg (fan)
 
 show_fan_reg (fan_min)
 
 show_temp_reg (temp)
 
 show_temp_reg (temp_max)
 
 show_temp_reg (temp_max_hyst)
 
 store_temp_reg (OVER, max)
 
 store_temp_reg (HYST, max_hyst)
 
 sysfs_temp_offsets (1)
 
 sysfs_temp_offsets (2)
 
 sysfs_temp_offsets (3)
 
 MODULE_DEVICE_TABLE (i2c, w83781d_ids)
 
 MODULE_AUTHOR ("Frodo Looijaard <[email protected]>, ""Philip Edelbrock <[email protected]>, ""and Mark Studebaker <[email protected]>")
 
 MODULE_DESCRIPTION ("W83781D driver")
 
 MODULE_LICENSE ("GPL")
 
 module_init (sensors_w83781d_init)
 
 module_exit (sensors_w83781d_exit)
 

Macro Definition Documentation

#define BEEP_MASK_FROM_REG (   val,
  type 
)
Value:
((type) == as99127f ? \
(~(val)) & 0x7fff : (val) & 0xff7fff)

Definition at line 187 of file w83781d.c.

#define BEEP_MASK_TO_REG (   val,
  type 
)
Value:
((type) == as99127f ? \
(~(val)) & 0x7fff : (val) & 0xff7fff)

Definition at line 189 of file w83781d.c.

#define DIV_FROM_REG (   val)    (1 << (val))

Definition at line 192 of file w83781d.c.

#define FAN_UNIT_ATTRS (   X)
Value:
&sensor_dev_attr_fan##X##_input.dev_attr.attr, \
&sensor_dev_attr_fan##X##_min.dev_attr.attr, \
&sensor_dev_attr_fan##X##_div.dev_attr.attr, \
&sensor_dev_attr_fan##X##_alarm.dev_attr.attr, \
&sensor_dev_attr_fan##X##_beep.dev_attr.attr

Definition at line 941 of file w83781d.c.

#define IN_FROM_REG (   val)    ((val) * 16)

Definition at line 163 of file w83781d.c.

#define IN_TO_REG (   val)    SENSORS_LIMIT(((val) + 8) / 16, 0, 255)

Definition at line 162 of file w83781d.c.

#define IN_UNIT_ATTRS (   X)
Value:
&sensor_dev_attr_in##X##_input.dev_attr.attr, \
&sensor_dev_attr_in##X##_min.dev_attr.attr, \
&sensor_dev_attr_in##X##_max.dev_attr.attr, \
&sensor_dev_attr_in##X##_alarm.dev_attr.attr, \
&sensor_dev_attr_in##X##_beep.dev_attr.attr

Definition at line 934 of file w83781d.c.

#define pr_fmt (   fmt)    KBUILD_MODNAME ": " fmt

Definition at line 36 of file w83781d.c.

#define show_fan_reg (   reg)
Value:
static ssize_t show_##reg(struct device *dev, struct device_attribute *da, \
char *buf) \
{ \
struct w83781d_data *data = w83781d_update_device(dev); \
return sprintf(buf, "%ld\n", \
FAN_FROM_REG(data->reg[attr->index], \
DIV_FROM_REG(data->fan_div[attr->index]))); \
}

Definition at line 313 of file w83781d.c.

#define show_in_reg (   reg)
Value:
static ssize_t show_##reg(struct device *dev, struct device_attribute *da, \
char *buf) \
{ \
struct w83781d_data *data = w83781d_update_device(dev); \
return sprintf(buf, "%ld\n", \
(long)IN_FROM_REG(data->reg[attr->index])); \
}

Definition at line 260 of file w83781d.c.

#define show_temp_reg (   reg)
Value:
static ssize_t show_##reg(struct device *dev, struct device_attribute *da, \
char *buf) \
{ \
struct w83781d_data *data = w83781d_update_device(dev); \
int nr = attr->index; \
if (nr >= 2) { /* TEMP2 and TEMP3 */ \
return sprintf(buf, "%d\n", \
LM75_TEMP_FROM_REG(data->reg##_add[nr-2])); \
} else { /* TEMP1 */ \
return sprintf(buf, "%ld\n", (long)TEMP_FROM_REG(data->reg)); \
} \
}

Definition at line 360 of file w83781d.c.

#define store_in_reg (   REG,
  reg 
)
Value:
static ssize_t store_in_##reg(struct device *dev, struct device_attribute \
*da, const char *buf, size_t count) \
{ \
int nr = attr->index; \
unsigned long val; \
int err = kstrtoul(buf, 10, &val); \
if (err) \
return err; \
mutex_lock(&data->update_lock); \
data->in_##reg[nr] = IN_TO_REG(val); \
w83781d_write_value(data, W83781D_REG_IN_##REG(nr), \
data->in_##reg[nr]); \
mutex_unlock(&data->update_lock); \
return count; \
}

Definition at line 273 of file w83781d.c.

#define store_temp_reg (   REG,
  reg 
)
Value:
static ssize_t store_temp_##reg(struct device *dev, \
struct device_attribute *da, const char *buf, size_t count) \
{ \
int nr = attr->index; \
long val; \
int err = kstrtol(buf, 10, &val); \
if (err) \
return err; \
mutex_lock(&data->update_lock); \
if (nr >= 2) { /* TEMP2 and TEMP3 */ \
data->temp_##reg##_add[nr-2] = LM75_TEMP_TO_REG(val); \
w83781d_write_value(data, W83781D_REG_TEMP_##REG(nr), \
data->temp_##reg##_add[nr-2]); \
} else { /* TEMP1 */ \
data->temp_##reg = TEMP_TO_REG(val); \
w83781d_write_value(data, W83781D_REG_TEMP_##REG(nr), \
data->temp_##reg); \
} \
mutex_unlock(&data->update_lock); \
return count; \
}

Definition at line 378 of file w83781d.c.

#define sysfs_in_offsets (   offset)
Value:
static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \
show_in_min, store_in_min, offset); \
show_in_max, store_in_max, offset)

Definition at line 295 of file w83781d.c.

#define sysfs_temp_offsets (   offset)
Value:
show_temp_max, store_temp_max, offset); \
static SENSOR_DEVICE_ATTR(temp##offset##_max_hyst, S_IRUGO | S_IWUSR, \
show_temp_max_hyst, store_temp_max_hyst, offset);

Definition at line 407 of file w83781d.c.

#define TEMP_FROM_REG (   val)    ((val) * 1000)

Definition at line 185 of file w83781d.c.

#define TEMP_TO_REG (   val)    SENSORS_LIMIT((val) / 1000, -127, 128)

Definition at line 184 of file w83781d.c.

#define TEMP_UNIT_ATTRS (   X)
Value:
&sensor_dev_attr_temp##X##_input.dev_attr.attr, \
&sensor_dev_attr_temp##X##_max.dev_attr.attr, \
&sensor_dev_attr_temp##X##_max_hyst.dev_attr.attr, \
&sensor_dev_attr_temp##X##_alarm.dev_attr.attr, \
&sensor_dev_attr_temp##X##_beep.dev_attr.attr

Definition at line 948 of file w83781d.c.

#define W83781D_ADDR_REG_OFFSET   5

Definition at line 84 of file w83781d.c.

#define W83781D_DATA_REG_OFFSET   6

Definition at line 85 of file w83781d.c.

#define W83781D_DEFAULT_BETA   3435

Definition at line 159 of file w83781d.c.

#define W83781D_EXTENT   8

Definition at line 81 of file w83781d.c.

#define W83781D_REG_ALARM1   0x41

Definition at line 117 of file w83781d.c.

#define W83781D_REG_ALARM2   0x42

Definition at line 118 of file w83781d.c.

#define W83781D_REG_BANK   0x4E

Definition at line 100 of file w83781d.c.

#define W83781D_REG_BEEP_CONFIG   0x4D

Definition at line 125 of file w83781d.c.

#define W83781D_REG_BEEP_INTS1   0x56

Definition at line 126 of file w83781d.c.

#define W83781D_REG_BEEP_INTS2   0x57

Definition at line 127 of file w83781d.c.

#define W83781D_REG_BEEP_INTS3   0x453 /* not on W83781D */

Definition at line 128 of file w83781d.c.

#define W83781D_REG_CHIPID   0x49

Definition at line 132 of file w83781d.c.

#define W83781D_REG_CHIPMAN   0x4F

Definition at line 134 of file w83781d.c.

#define W83781D_REG_CONFIG   0x40

Definition at line 114 of file w83781d.c.

#define W83781D_REG_FAN (   nr)    (0x28 + (nr))

Definition at line 98 of file w83781d.c.

#define W83781D_REG_FAN_MIN (   nr)    (0x3b + (nr))

Definition at line 97 of file w83781d.c.

#define W83781D_REG_I2C_ADDR   0x48

Definition at line 145 of file w83781d.c.

#define W83781D_REG_I2C_SUBADDR   0x4A

Definition at line 146 of file w83781d.c.

#define W83781D_REG_IN (   nr)
Value:
((nr < 7) ? (0x20 + (nr)) : \
(0x550 + (nr) - 7))

Definition at line 93 of file w83781d.c.

#define W83781D_REG_IN_MAX (   nr)
Value:
((nr < 7) ? (0x2b + (nr) * 2) : \
(0x554 + (((nr) - 7) * 2)))

Definition at line 89 of file w83781d.c.

#define W83781D_REG_IN_MIN (   nr)
Value:
((nr < 7) ? (0x2c + (nr) * 2) : \
(0x555 + (((nr) - 7) * 2)))

Definition at line 91 of file w83781d.c.

#define W83781D_REG_PIN   0x4B

Definition at line 135 of file w83781d.c.

#define W83781D_REG_PWMCLK12   0x5C

Definition at line 142 of file w83781d.c.

#define W83781D_REG_PWMCLK34   0x45C

Definition at line 143 of file w83781d.c.

#define W83781D_REG_SCFG1   0x5D

Definition at line 153 of file w83781d.c.

#define W83781D_REG_SCFG2   0x59

Definition at line 156 of file w83781d.c.

#define W83781D_REG_TEMP (   nr)
Value:
((nr == 3) ? (0x0250) : \
((nr == 2) ? (0x0150) : \
(0x27)))

Definition at line 104 of file w83781d.c.

#define W83781D_REG_TEMP2_CONFIG   0x152

Definition at line 101 of file w83781d.c.

#define W83781D_REG_TEMP3_CONFIG   0x252

Definition at line 102 of file w83781d.c.

#define W83781D_REG_TEMP_HYST (   nr)
Value:
((nr == 3) ? (0x253) : \
((nr == 2) ? (0x153) : \
(0x3A)))

Definition at line 107 of file w83781d.c.

#define W83781D_REG_TEMP_OVER (   nr)
Value:
((nr == 3) ? (0x255) : \
((nr == 2) ? (0x155) : \
(0x39)))

Definition at line 110 of file w83781d.c.

#define W83781D_REG_VBAT   0x5D

Definition at line 138 of file w83781d.c.

#define W83781D_REG_VID_FANDIV   0x47

Definition at line 130 of file w83781d.c.

#define W83781D_REG_WCHIPID   0x58

Definition at line 133 of file w83781d.c.

#define W83782D_REG_ALARM1   0x459

Definition at line 121 of file w83781d.c.

#define W83782D_REG_ALARM2   0x45A

Definition at line 122 of file w83781d.c.

#define W83782D_REG_ALARM3   0x45B

Definition at line 123 of file w83781d.c.

Enumeration Type Documentation

enum chips
Enumerator:
ad7416 
ad7417 
ad7418 
adm1021 
adm1023 
max1617 
max1617a 
thmc10 
lm84 
gl523sm 
mc1066 
adm1025 
ne1619 
adm1030 
adm1031 
adm9240 
ds1780 
lm81 
adt7473 
adt7475 
adt7476 
adt7490 
amc6821 
dme1737 
sch5027 
sch311x 
sch5127 
f71808e 
f71808a 
f71858fg 
f71862fg 
f71869 
f71869a 
f71882fg 
f71889fg 
f71889ed 
f71889a 
f8000 
f81865f 
f75373 
f75375 
f75387 
fscpos 
fscher 
fscscy 
fschrc 
fschmd 
fschds 
fscsyl 
gl518sm_r00 
gl518sm_r80 
it87 
it8712 
it8716 
it8718 
it8720 
it8721 
it8728 
it8782 
it8783 
lm63 
lm64 
lm96163 
lm78 
lm79 
lm83 
lm82 
any_chip 
lm85b 
lm85c 
adm1027 
adt7463 
adt7468 
emc6d100 
emc6d102 
emc6d103 
emc6d103s 
lm87 
adm1024 
lm90 
adm1032 
lm99 
lm86 
max6657 
max6659 
adt7461 
max6680 
max6646 
w83l771 
max6696 
sa56004 
g781 
max1110 
max1111 
max1112 
max1113 
max16065 
max16066 
max16067 
max16068 
max16070 
max16071 
max1668 
max1805 
max1989 
mcp3021 
mcp3221 
adm1075 
adm1275 
adm1276 
lm25066 
lm5064 
lm5066 
ltc2978 
ltc3880 
max34440 
max34441 
max34446 
ucd9000 
ucd90120 
ucd90124 
ucd9090 
ucd90910 
ucd9200 
ucd9220 
ucd9222 
ucd9224 
ucd9240 
ucd9244 
ucd9246 
ucd9248 
zl2004 
zl2005 
zl2006 
zl2008 
zl2105 
zl2106 
zl6100 
zl6105 
zl9101 
zl9117 
smm465 
smm665 
smm665c 
smm764 
smm766 
smsc47m1 
smsc47m2 
thmc50 
adm1022 
tmp401 
tmp411 
tmp421 
tmp422 
tmp423 
w83627hf 
w83627thf 
w83697hf 
w83637hf 
w83687thf 
w83781d 
w83782d 
w83783s 
as99127f 
DC21040 
DC21041 
DC21140 
DC21142 
DC21143 
LC82C168 
MX98713 
MX98715 
MX98725 
AX88140 
PNIC2 
COMET 
COMPEX9881 
I21145 
DM910X 
CONEXANT 
TPS62360 
TPS62361 
TPS62362 
TPS62363 
sc18is602 
sc18is602b 
sc18is603 
f71808fg 
f71858fg 
f71862fg 
f71869 
f71882fg 
f71889fg 

Definition at line 62 of file w83781d.c.

Function Documentation

MODULE_AUTHOR ( "Frodo Looijaard <[email protected] ,
""Philip Edelbrock< phil @netroedge.com >  ,
""and Mark Studebaker< mdsxyz123 @yahoo.com >"   
)
MODULE_DESCRIPTION ( "W83781D driver )
MODULE_DEVICE_TABLE ( i2c  ,
w83781d_ids   
)
module_exit ( sensors_w83781d_exit  )
module_init ( sensors_w83781d_init  )
MODULE_LICENSE ( "GPL"  )
module_param ( reset  ,
bool  ,
 
)
module_param ( init  ,
bool  ,
 
)
module_param_array ( force_subclients  ,
short  ,
NULL  ,
 
)
MODULE_PARM_DESC ( force_subclients  ,
"List of subclient addresses: ""{bus, clientaddr, subclientaddr1, subclientaddr2}"   
)
MODULE_PARM_DESC ( reset  ,
"Set to one to reset chip on load  
)
MODULE_PARM_DESC ( init  ,
"Set to zero to bypass chip initialization"   
)
show_fan_reg ( fan  )
show_fan_reg ( fan_min  )
show_in_reg ( in  )

Definition at line 257 of file asb100.c.

show_in_reg ( in_min  )
show_in_reg ( in_max  )
show_temp_reg ( temp  )
show_temp_reg ( temp_max  )
show_temp_reg ( temp_max_hyst  )
store_in_reg ( MIN  ,
min   
)
store_in_reg ( MAX  ,
max   
)
store_temp_reg ( OVER  ,
max   
)
store_temp_reg ( HYST  ,
max_hyst   
)
sysfs_in_offsets ( )
sysfs_in_offsets ( )
sysfs_in_offsets ( )
sysfs_in_offsets ( )
sysfs_in_offsets ( )
sysfs_in_offsets ( )
sysfs_in_offsets ( )
sysfs_in_offsets ( )
sysfs_in_offsets ( )
sysfs_temp_offsets ( )
sysfs_temp_offsets ( )
sysfs_temp_offsets ( )