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

Go to the source code of this file.

Data Structures

struct  w83791d_data
 

Macros

#define NUMBER_OF_VIN   10
 
#define NUMBER_OF_FANIN   5
 
#define NUMBER_OF_TEMPIN   3
 
#define NUMBER_OF_PWM   5
 
#define W83791D_REG_BANK   0x4E
 
#define W83791D_REG_TEMP2_CONFIG   0xC2
 
#define W83791D_REG_TEMP3_CONFIG   0xCA
 
#define W83791D_REG_BEEP_CONFIG   0x4D
 
#define W83791D_REG_GPIO   0x15
 
#define W83791D_REG_CONFIG   0x40
 
#define W83791D_REG_VID_FANDIV   0x47
 
#define W83791D_REG_DID_VID4   0x49
 
#define W83791D_REG_WCHIPID   0x58
 
#define W83791D_REG_CHIPMAN   0x4F
 
#define W83791D_REG_PIN   0x4B
 
#define W83791D_REG_I2C_SUBADDR   0x4A
 
#define W83791D_REG_ALARM1   0xA9 /* realtime status register1 */
 
#define W83791D_REG_ALARM2   0xAA /* realtime status register2 */
 
#define W83791D_REG_ALARM3   0xAB /* realtime status register3 */
 
#define W83791D_REG_VBAT   0x5D
 
#define W83791D_REG_I2C_ADDR   0x48
 
#define IN_TO_REG(val)   (SENSORS_LIMIT((((val) + 8) / 16), 0, 255))
 
#define IN_FROM_REG(val)   ((val) * 16)
 
#define FAN_FROM_REG(val, div)
 
#define TEMP1_FROM_REG(val)   ((val) * 1000)
 
#define TEMP1_TO_REG(val)
 
#define TEMP23_FROM_REG(val)   ((val) / 128 * 500)
 
#define TEMP23_TO_REG(val)
 
#define TARGET_TEMP_TO_REG(val)
 
#define TOL_TEMP_TO_REG(val)
 
#define BEEP_MASK_TO_REG(val)   ((val) & 0xffffff)
 
#define BEEP_MASK_FROM_REG(val)   ((val) & 0xffffff)
 
#define DIV_FROM_REG(val)   (1 << (val))
 
#define show_in_reg(reg)
 
#define store_in_reg(REG, reg)
 
#define show_fan_reg(reg)
 
#define GLOBAL_BEEP_ENABLE_SHIFT   15
 
#define GLOBAL_BEEP_ENABLE_MASK   (1 << GLOBAL_BEEP_ENABLE_SHIFT)
 
#define IN_UNIT_ATTRS(X)
 
#define FAN_UNIT_ATTRS(X)
 
#define TEMP_UNIT_ATTRS(X)
 

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 force a hardware chip reset")
 
 module_param (init, bool, 0)
 
 MODULE_PARM_DESC (init,"Set to one to force extra software initialization")
 
 MODULE_DEVICE_TABLE (i2c, w83791d_id)
 
 show_in_reg (in)
 
 show_in_reg (in_min)
 
 show_in_reg (in_max)
 
 store_in_reg (MIN, min)
 
 store_in_reg (MAX, max)
 
 show_fan_reg (fan)
 
 show_fan_reg (fan_min)
 
 module_i2c_driver (w83791d_driver)
 
 MODULE_AUTHOR ("Charles Spirakis <[email protected]>")
 
 MODULE_DESCRIPTION ("W83791D driver")
 
 MODULE_LICENSE ("GPL")
 

Macro Definition Documentation

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

Definition at line 267 of file w83791d.c.

#define BEEP_MASK_TO_REG (   val)    ((val) & 0xffffff)

Definition at line 266 of file w83791d.c.

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

Definition at line 269 of file w83791d.c.

#define FAN_FROM_REG (   val,
  div 
)
Value:
((val) == 0 ? -1 : \
((val) == 255 ? 0 : \
1350000 / ((val) * (div))))

Definition at line 234 of file w83791d.c.

#define FAN_UNIT_ATTRS (   X)
Value:
&sda_fan_input[X].dev_attr.attr, \
&sda_fan_min[X].dev_attr.attr, \
&sda_fan_div[X].dev_attr.attr, \
&sda_fan_beep[X].dev_attr.attr, \
&sda_fan_alarm[X].dev_attr.attr

Definition at line 1200 of file w83791d.c.

#define GLOBAL_BEEP_ENABLE_MASK   (1 << GLOBAL_BEEP_ENABLE_SHIFT)

Definition at line 1059 of file w83791d.c.

#define GLOBAL_BEEP_ENABLE_SHIFT   15

Definition at line 1058 of file w83791d.c.

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

Definition at line 224 of file w83791d.c.

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

Definition at line 223 of file w83791d.c.

#define IN_UNIT_ATTRS (   X)
Value:
&sda_in_input[X].dev_attr.attr, \
&sda_in_min[X].dev_attr.attr, \
&sda_in_max[X].dev_attr.attr, \
&sda_in_beep[X].dev_attr.attr, \
&sda_in_alarm[X].dev_attr.attr

Definition at line 1193 of file w83791d.c.

#define NUMBER_OF_FANIN   5

Definition at line 47 of file w83791d.c.

#define NUMBER_OF_PWM   5

Definition at line 49 of file w83791d.c.

#define NUMBER_OF_TEMPIN   3

Definition at line 48 of file w83791d.c.

#define NUMBER_OF_VIN   10

Definition at line 46 of file w83791d.c.

#define show_fan_reg (   reg)
Value:
static ssize_t show_##reg(struct device *dev, struct device_attribute *attr, \
char *buf) \
{ \
to_sensor_dev_attr(attr); \
struct w83791d_data *data = w83791d_update_device(dev); \
int nr = sensor_attr->index; \
return sprintf(buf, "%d\n", \
FAN_FROM_REG(data->reg[nr], DIV_FROM_REG(data->fan_div[nr]))); \
}

Definition at line 535 of file w83791d.c.

#define show_in_reg (   reg)
Value:
static ssize_t show_##reg(struct device *dev, struct device_attribute *attr, \
char *buf) \
{ \
to_sensor_dev_attr(attr); \
struct w83791d_data *data = w83791d_update_device(dev); \
int nr = sensor_attr->index; \
return sprintf(buf, "%d\n", IN_FROM_REG(data->reg[nr])); \
}

Definition at line 369 of file w83791d.c.

#define store_in_reg (   REG,
  reg 
)
Value:
static ssize_t store_in_##reg(struct device *dev, \
const char *buf, size_t count) \
{ \
to_sensor_dev_attr(attr); \
struct w83791d_data *data = i2c_get_clientdata(client); \
int nr = sensor_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); \
w83791d_write(client, W83791D_REG_IN_##REG[nr], data->in_##reg[nr]); \
mutex_unlock(&data->update_lock); \
\
return count; \
}

Definition at line 384 of file w83791d.c.

#define TARGET_TEMP_TO_REG (   val)
Value:
((val) < 0 ? 0 : \
(val) >= 127000 ? 127 : \
((val) + 500) / 1000)

Definition at line 258 of file w83791d.c.

#define TEMP1_FROM_REG (   val)    ((val) * 1000)

Definition at line 239 of file w83791d.c.

#define TEMP1_TO_REG (   val)
Value:
((val) <= -128000 ? -128 : \
(val) >= 127000 ? 127 : \
(val) < 0 ? ((val) - 500) / 1000 : \
((val) + 500) / 1000)

Definition at line 240 of file w83791d.c.

#define TEMP23_FROM_REG (   val)    ((val) / 128 * 500)

Definition at line 251 of file w83791d.c.

#define TEMP23_TO_REG (   val)
Value:
((val) <= -128000 ? 0x8000 : \
(val) >= 127500 ? 0x7F80 : \
(val) < 0 ? ((val) - 250) / 500 * 128 : \
((val) + 250) / 500 * 128)

Definition at line 252 of file w83791d.c.

#define TEMP_UNIT_ATTRS (   X)
Value:
&sda_temp_input[X].dev_attr.attr, \
&sda_temp_max[X].dev_attr.attr, \
&sda_temp_max_hyst[X].dev_attr.attr, \
&sda_temp_beep[X].dev_attr.attr, \
&sda_temp_alarm[X].dev_attr.attr

Definition at line 1207 of file w83791d.c.

#define TOL_TEMP_TO_REG (   val)
Value:
((val) >= 15000 ? 15 : \
((val) + 500) / 1000)

Definition at line 263 of file w83791d.c.

#define W83791D_REG_ALARM1   0xA9 /* realtime status register1 */

Definition at line 195 of file w83791d.c.

#define W83791D_REG_ALARM2   0xAA /* realtime status register2 */

Definition at line 196 of file w83791d.c.

#define W83791D_REG_ALARM3   0xAB /* realtime status register3 */

Definition at line 197 of file w83791d.c.

#define W83791D_REG_BANK   0x4E

Definition at line 153 of file w83791d.c.

#define W83791D_REG_BEEP_CONFIG   0x4D

Definition at line 178 of file w83791d.c.

#define W83791D_REG_CHIPMAN   0x4F

Definition at line 191 of file w83791d.c.

#define W83791D_REG_CONFIG   0x40

Definition at line 187 of file w83791d.c.

#define W83791D_REG_DID_VID4   0x49

Definition at line 189 of file w83791d.c.

#define W83791D_REG_GPIO   0x15

Definition at line 186 of file w83791d.c.

#define W83791D_REG_I2C_ADDR   0x48

Definition at line 200 of file w83791d.c.

#define W83791D_REG_I2C_SUBADDR   0x4A

Definition at line 193 of file w83791d.c.

#define W83791D_REG_PIN   0x4B

Definition at line 192 of file w83791d.c.

#define W83791D_REG_TEMP2_CONFIG   0xC2

Definition at line 154 of file w83791d.c.

#define W83791D_REG_TEMP3_CONFIG   0xCA

Definition at line 155 of file w83791d.c.

#define W83791D_REG_VBAT   0x5D

Definition at line 199 of file w83791d.c.

#define W83791D_REG_VID_FANDIV   0x47

Definition at line 188 of file w83791d.c.

#define W83791D_REG_WCHIPID   0x58

Definition at line 190 of file w83791d.c.

Function Documentation

MODULE_AUTHOR ( "Charles Spirakis <[email protected]>"  )
MODULE_DESCRIPTION ( "W83791D driver )
MODULE_DEVICE_TABLE ( i2c  ,
w83791d_id   
)
module_i2c_driver ( w83791d_driver  )
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 force a hardware chip reset  
)
MODULE_PARM_DESC ( init  ,
"Set to one to force extra software 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  )
store_in_reg ( MIN  ,
min   
)
store_in_reg ( MAX  ,
max   
)