Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions
gl518sm.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-sysfs.h>
#include <linux/err.h>
#include <linux/mutex.h>
#include <linux/sysfs.h>

Go to the source code of this file.

Data Structures

struct  gl518_data
 

Macros

#define GL518_REG_CHIP_ID   0x00
 
#define GL518_REG_REVISION   0x01
 
#define GL518_REG_VENDOR_ID   0x02
 
#define GL518_REG_CONF   0x03
 
#define GL518_REG_TEMP_IN   0x04
 
#define GL518_REG_TEMP_MAX   0x05
 
#define GL518_REG_TEMP_HYST   0x06
 
#define GL518_REG_FAN_COUNT   0x07
 
#define GL518_REG_FAN_LIMIT   0x08
 
#define GL518_REG_VIN1_LIMIT   0x09
 
#define GL518_REG_VIN2_LIMIT   0x0a
 
#define GL518_REG_VIN3_LIMIT   0x0b
 
#define GL518_REG_VDD_LIMIT   0x0c
 
#define GL518_REG_VIN3   0x0d
 
#define GL518_REG_MISC   0x0f
 
#define GL518_REG_ALARM   0x10
 
#define GL518_REG_MASK   0x11
 
#define GL518_REG_INT   0x12
 
#define GL518_REG_VIN2   0x13
 
#define GL518_REG_VIN1   0x14
 
#define GL518_REG_VDD   0x15
 
#define RAW_FROM_REG(val)   val
 
#define BOOL_FROM_REG(val)   ((val) ? 0 : 1)
 
#define BOOL_TO_REG(val)   ((val) ? 0 : 1)
 
#define TEMP_TO_REG(val)
 
#define TEMP_FROM_REG(val)   (((val) - 119) * 1000)
 
#define FAN_FROM_REG(val, div)   ((val) == 0 ? 0 : (480000 / ((val) * (div))))
 
#define IN_TO_REG(val)   SENSORS_LIMIT((((val) + 9) / 19), 0, 255)
 
#define IN_FROM_REG(val)   ((val) * 19)
 
#define VDD_TO_REG(val)   SENSORS_LIMIT((((val) * 4 + 47) / 95), 0, 255)
 
#define VDD_FROM_REG(val)   (((val) * 95 + 2) / 4)
 
#define DIV_FROM_REG(val)   (1 << (val))
 
#define BEEP_MASK_TO_REG(val)   ((val) & 0x7f & data->alarm_mask)
 
#define BEEP_MASK_FROM_REG(val)   ((val) & 0x7f)
 
#define show(type, suffix, value)
 
#define set(type, suffix, value, reg)
 
#define set_bits(type, suffix, value, reg, mask, shift)
 
#define set_low(type, suffix, value, reg)   set_bits(type, suffix, value, reg, 0x00ff, 0)
 
#define set_high(type, suffix, value, reg)   set_bits(type, suffix, value, reg, 0xff00, 8)
 

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_DEVICE_TABLE (i2c, gl518_id)
 
 show (TEMP, temp_input1, temp_in)
 
 show (TEMP, temp_max1, temp_max)
 
 show (TEMP, temp_hyst1, temp_hyst)
 
 show (BOOL, fan_auto1, fan_auto1)
 
 show (VDD, in_input0, voltage_in[0])
 
 show (IN, in_input1, voltage_in[1])
 
 show (IN, in_input2, voltage_in[2])
 
 show (IN, in_input3, voltage_in[3])
 
 show (VDD, in_min0, voltage_min[0])
 
 show (IN, in_min1, voltage_min[1])
 
 show (IN, in_min2, voltage_min[2])
 
 show (IN, in_min3, voltage_min[3])
 
 show (VDD, in_max0, voltage_max[0])
 
 show (IN, in_max1, voltage_max[1])
 
 show (IN, in_max2, voltage_max[2])
 
 show (IN, in_max3, voltage_max[3])
 
 show (RAW, alarms, alarms)
 
 show (BOOL, beep_enable, beep_enable)
 
 show (BEEP_MASK, beep_mask, beep_mask)
 
 set (TEMP, temp_max1, temp_max, GL518_REG_TEMP_MAX)
 
 set (TEMP, temp_hyst1, temp_hyst, GL518_REG_TEMP_HYST)
 
 set_bits (BOOL, fan_auto1, fan_auto1, GL518_REG_MISC, 0x08, 3)
 
 set_low (VDD, in_min0, voltage_min[0], GL518_REG_VDD_LIMIT)
 
 set_low (IN, in_min1, voltage_min[1], GL518_REG_VIN1_LIMIT)
 
 set_low (IN, in_min2, voltage_min[2], GL518_REG_VIN2_LIMIT)
 
 set_low (IN, in_min3, voltage_min[3], GL518_REG_VIN3_LIMIT)
 
 set_high (VDD, in_max0, voltage_max[0], GL518_REG_VDD_LIMIT)
 
 set_high (IN, in_max1, voltage_max[1], GL518_REG_VIN1_LIMIT)
 
 set_high (IN, in_max2, voltage_max[2], GL518_REG_VIN2_LIMIT)
 
 set_high (IN, in_max3, voltage_max[3], GL518_REG_VIN3_LIMIT)
 
 set_bits (BOOL, beep_enable, beep_enable, GL518_REG_CONF, 0x04, 2)
 
 set (BEEP_MASK, beep_mask, beep_mask, GL518_REG_ALARM)
 
 module_i2c_driver (gl518_driver)
 
 MODULE_AUTHOR ("Frodo Looijaard <[email protected]>, ""Kyosti Malkki <[email protected]> and ""Hong-Gunn Chew <[email protected]>")
 
 MODULE_DESCRIPTION ("GL518SM driver")
 
 MODULE_LICENSE ("GPL")
 

Macro Definition Documentation

#define BEEP_MASK_FROM_REG (   val)    ((val) & 0x7f)

Definition at line 113 of file gl518sm.c.

#define BEEP_MASK_TO_REG (   val)    ((val) & 0x7f & data->alarm_mask)

Definition at line 112 of file gl518sm.c.

#define BOOL_FROM_REG (   val)    ((val) ? 0 : 1)

Definition at line 86 of file gl518sm.c.

#define BOOL_TO_REG (   val)    ((val) ? 0 : 1)

Definition at line 87 of file gl518sm.c.

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

Definition at line 110 of file gl518sm.c.

#define FAN_FROM_REG (   val,
  div 
)    ((val) == 0 ? 0 : (480000 / ((val) * (div))))

Definition at line 102 of file gl518sm.c.

#define GL518_REG_ALARM   0x10

Definition at line 69 of file gl518sm.c.

#define GL518_REG_CHIP_ID   0x00

Definition at line 54 of file gl518sm.c.

#define GL518_REG_CONF   0x03

Definition at line 57 of file gl518sm.c.

#define GL518_REG_FAN_COUNT   0x07

Definition at line 61 of file gl518sm.c.

#define GL518_REG_FAN_LIMIT   0x08

Definition at line 62 of file gl518sm.c.

#define GL518_REG_INT   0x12

Definition at line 71 of file gl518sm.c.

#define GL518_REG_MASK   0x11

Definition at line 70 of file gl518sm.c.

#define GL518_REG_MISC   0x0f

Definition at line 68 of file gl518sm.c.

#define GL518_REG_REVISION   0x01

Definition at line 55 of file gl518sm.c.

#define GL518_REG_TEMP_HYST   0x06

Definition at line 60 of file gl518sm.c.

#define GL518_REG_TEMP_IN   0x04

Definition at line 58 of file gl518sm.c.

#define GL518_REG_TEMP_MAX   0x05

Definition at line 59 of file gl518sm.c.

#define GL518_REG_VDD   0x15

Definition at line 74 of file gl518sm.c.

#define GL518_REG_VDD_LIMIT   0x0c

Definition at line 66 of file gl518sm.c.

#define GL518_REG_VENDOR_ID   0x02

Definition at line 56 of file gl518sm.c.

#define GL518_REG_VIN1   0x14

Definition at line 73 of file gl518sm.c.

#define GL518_REG_VIN1_LIMIT   0x09

Definition at line 63 of file gl518sm.c.

#define GL518_REG_VIN2   0x13

Definition at line 72 of file gl518sm.c.

#define GL518_REG_VIN2_LIMIT   0x0a

Definition at line 64 of file gl518sm.c.

#define GL518_REG_VIN3   0x0d

Definition at line 67 of file gl518sm.c.

#define GL518_REG_VIN3_LIMIT   0x0b

Definition at line 65 of file gl518sm.c.

#define IN_FROM_REG (   val)    ((val) * 19)

Definition at line 105 of file gl518sm.c.

#define IN_TO_REG (   val)    SENSORS_LIMIT((((val) + 9) / 19), 0, 255)

Definition at line 104 of file gl518sm.c.

#define RAW_FROM_REG (   val)    val

Definition at line 84 of file gl518sm.c.

#define set (   type,
  suffix,
  value,
  reg 
)
Value:
static ssize_t set_##suffix(struct device *dev, \
const char *buf, size_t count) \
{ \
struct gl518_data *data = i2c_get_clientdata(client); \
long val; \
int err = kstrtol(buf, 10, &val); \
if (err) \
return err; \
mutex_lock(&data->update_lock); \
data->value = type##_TO_REG(val); \
gl518_write_value(client, reg, data->value); \
mutex_unlock(&data->update_lock); \
return count; \
}

Definition at line 226 of file gl518sm.c.

#define set_bits (   type,
  suffix,
  value,
  reg,
  mask,
  shift 
)
Value:
static ssize_t set_##suffix(struct device *dev, \
const char *buf, size_t count) \
{ \
struct gl518_data *data = i2c_get_clientdata(client); \
int regvalue; \
unsigned long val; \
int err = kstrtoul(buf, 10, &val); \
if (err) \
return err; \
mutex_lock(&data->update_lock); \
regvalue = gl518_read_value(client, reg); \
data->value = type##_TO_REG(val); \
regvalue = (regvalue & ~mask) | (data->value << shift); \
gl518_write_value(client, reg, regvalue); \
mutex_unlock(&data->update_lock); \
return count; \
}

Definition at line 245 of file gl518sm.c.

#define set_high (   type,
  suffix,
  value,
  reg 
)    set_bits(type, suffix, value, reg, 0xff00, 8)

Definition at line 269 of file gl518sm.c.

#define set_low (   type,
  suffix,
  value,
  reg 
)    set_bits(type, suffix, value, reg, 0x00ff, 0)

Definition at line 267 of file gl518sm.c.

#define show (   type,
  suffix,
  value 
)
Value:
static ssize_t show_##suffix(struct device *dev, \
struct device_attribute *attr, char *buf) \
{ \
struct gl518_data *data = gl518_update_device(dev); \
return sprintf(buf, "%d\n", type##_FROM_REG(data->value)); \
}

Definition at line 172 of file gl518sm.c.

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

Definition at line 92 of file gl518sm.c.

#define TEMP_TO_REG (   val)
Value:
SENSORS_LIMIT(((((val) < 0 ? \
(val) - 500 : \
(val) + 500) / 1000) + 119), 0, 255)

Definition at line 89 of file gl518sm.c.

#define VDD_FROM_REG (   val)    (((val) * 95 + 2) / 4)

Definition at line 108 of file gl518sm.c.

#define VDD_TO_REG (   val)    SENSORS_LIMIT((((val) * 4 + 47) / 95), 0, 255)

Definition at line 107 of file gl518sm.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 49 of file gl518sm.c.

Function Documentation

MODULE_AUTHOR ( "Frodo Looijaard <[email protected] ,
""Kyosti Malkki< kmalkki @cc.hut.fi > and""Hong-Gunn Chew< hglinux @gunnet.org >"   
)
MODULE_DESCRIPTION ( "GL518SM driver )
MODULE_DEVICE_TABLE ( i2c  ,
gl518_id   
)
module_i2c_driver ( gl518_driver  )
MODULE_LICENSE ( "GPL"  )
set ( TEMP  ,
temp_max1  ,
temp_max  ,
GL518_REG_TEMP_MAX   
)
set ( TEMP  ,
temp_hyst1  ,
temp_hyst  ,
GL518_REG_TEMP_HYST   
)
set ( BEEP_MASK  ,
beep_mask  ,
beep_mask  ,
GL518_REG_ALARM   
)
set_bits ( BOOL  ,
fan_auto1  ,
fan_auto1  ,
GL518_REG_MISC  ,
0x08  ,
 
)
set_bits ( BOOL  ,
beep_enable  ,
beep_enable  ,
GL518_REG_CONF  ,
0x04  ,
 
)
set_high ( VDD  ,
in_max0  ,
voltage_max  [0],
GL518_REG_VDD_LIMIT   
)
set_high ( IN  ,
in_max1  ,
voltage_max  [1],
GL518_REG_VIN1_LIMIT   
)
set_high ( IN  ,
in_max2  ,
voltage_max  [2],
GL518_REG_VIN2_LIMIT   
)
set_high ( IN  ,
in_max3  ,
voltage_max  [3],
GL518_REG_VIN3_LIMIT   
)
set_low ( VDD  ,
in_min0  ,
voltage_min  [0],
GL518_REG_VDD_LIMIT   
)
set_low ( IN  ,
in_min1  ,
voltage_min  [1],
GL518_REG_VIN1_LIMIT   
)
set_low ( IN  ,
in_min2  ,
voltage_min  [2],
GL518_REG_VIN2_LIMIT   
)
set_low ( IN  ,
in_min3  ,
voltage_min  [3],
GL518_REG_VIN3_LIMIT   
)
show ( TEMP  ,
temp_input1  ,
temp_in   
)
show ( TEMP  ,
temp_max1  ,
temp_max   
)
show ( TEMP  ,
temp_hyst1  ,
temp_hyst   
)
show ( BOOL  ,
fan_auto1  ,
fan_auto1   
)
show ( VDD  ,
in_input0  ,
voltage_in  [0] 
)
show ( IN  ,
in_input1  ,
voltage_in  [1] 
)
show ( IN  ,
in_input2  ,
voltage_in  [2] 
)
show ( IN  ,
in_input3  ,
voltage_in  [3] 
)
show ( VDD  ,
in_min0  ,
voltage_min  [0] 
)
show ( IN  ,
in_min1  ,
voltage_min  [1] 
)
show ( IN  ,
in_min2  ,
voltage_min  [2] 
)
show ( IN  ,
in_min3  ,
voltage_min  [3] 
)
show ( VDD  ,
in_max0  ,
voltage_max  [0] 
)
show ( IN  ,
in_max1  ,
voltage_max  [1] 
)
show ( IN  ,
in_max2  ,
voltage_max  [2] 
)
show ( IN  ,
in_max3  ,
voltage_max  [3] 
)
show ( RAW  ,
alarms  ,
alarms   
)
show ( BOOL  ,
beep_enable  ,
beep_enable   
)
show ( BEEP_MASK  ,
beep_mask  ,
beep_mask   
)