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

Go to the source code of this file.

Data Structures

struct  w83792d_data
 

Macros

#define W83792D_REG_LOW_BITS1   0x3E /* Low Bits I in DataSheet */
 
#define W83792D_REG_LOW_BITS2   0x3F /* Low Bits II in DataSheet */
 
#define W83792D_REG_FAN_CFG   0x84 /* FAN Configuration in DataSheet */
 
#define W83792D_REG_BANK   0x4E
 
#define W83792D_REG_TEMP2_CONFIG   0xC2
 
#define W83792D_REG_TEMP3_CONFIG   0xCA
 
#define W83792D_REG_GPIO_EN   0x1A
 
#define W83792D_REG_CONFIG   0x40
 
#define W83792D_REG_VID_FANDIV   0x47
 
#define W83792D_REG_CHIPID   0x49
 
#define W83792D_REG_WCHIPID   0x58
 
#define W83792D_REG_CHIPMAN   0x4F
 
#define W83792D_REG_PIN   0x4B
 
#define W83792D_REG_I2C_SUBADDR   0x4A
 
#define W83792D_REG_ALARM1   0xA9 /* realtime status register1 */
 
#define W83792D_REG_ALARM2   0xAA /* realtime status register2 */
 
#define W83792D_REG_ALARM3   0xAB /* realtime status register3 */
 
#define W83792D_REG_CHASSIS   0x42 /* Bit 5: Case Open status bit */
 
#define W83792D_REG_CHASSIS_CLR   0x44 /* Bit 7: Case Open CLR_CHS/Reset bit */
 
#define W83792D_REG_VID_IN_B   0x17
 
#define W83792D_REG_VBAT   0x5D
 
#define W83792D_REG_I2C_ADDR   0x48
 
#define IN_FROM_REG(nr, val)
 
#define IN_TO_REG(nr, val)
 
#define FAN_FROM_REG(val, div)
 
#define TEMP1_TO_REG(val)
 
#define TEMP1_FROM_REG(val)   (((val) & 0x80 ? (val)-0x100 : (val)) * 1000)
 
#define TEMP_ADD_FROM_REG(val1, val2)
 
#define TEMP_ADD_TO_REG_HIGH(val)
 
#define TEMP_ADD_TO_REG_LOW(val)   ((val%1000) ? 0x80 : 0x00)
 
#define DIV_FROM_REG(val)   (1 << (val))
 
#define show_in_reg(reg)
 
#define store_in_reg(REG, reg)
 
#define show_fan_reg(reg)
 

Functions

 module_param_array (force_subclients, short, NULL, 0)
 
 MODULE_PARM_DESC (force_subclients,"List of subclient addresses: ""{bus, clientaddr, subclientaddr1, subclientaddr2}")
 
 module_param (init, bool, 0)
 
 MODULE_PARM_DESC (init,"Set to one to force chip initialization")
 
 MODULE_DEVICE_TABLE (i2c, w83792d_id)
 
 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 (w83792d_driver)
 
 MODULE_AUTHOR ("Chunhao Huang @ Winbond <[email protected]>")
 
 MODULE_DESCRIPTION ("W83792AD/D driver for linux-2.6")
 
 MODULE_LICENSE ("GPL")
 

Macro Definition Documentation

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

Definition at line 259 of file w83792d.c.

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

Definition at line 242 of file w83792d.c.

#define IN_FROM_REG (   nr,
  val 
)
Value:
(((nr) <= 1) ? ((val) * 2) : \
((((nr) == 6) || ((nr) == 7)) ? ((val) * 6) : ((val) * 4)))

Definition at line 228 of file w83792d.c.

#define IN_TO_REG (   nr,
  val 
)
Value:
(((nr) <= 1) ? ((val) / 2) : \
((((nr) == 6) || ((nr) == 7)) ? ((val) / 6) : ((val) / 4)))

Definition at line 230 of file w83792d.c.

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

Definition at line 410 of file w83792d.c.

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

Definition at line 370 of file w83792d.c.

#define store_in_reg (   REG,
  reg 
)
Value:
static ssize_t store_in_##reg(struct device *dev, \
const char *buf, size_t count) \
{ \
int nr = sensor_attr->index; \
struct w83792d_data *data = i2c_get_clientdata(client); \
unsigned long val; \
int err = kstrtoul(buf, 10, &val); \
if (err) \
return err; \
mutex_lock(&data->update_lock); \
data->in_##reg[nr] = SENSORS_LIMIT(IN_TO_REG(nr, val) / 4, 0, 255); \
w83792d_write_value(client, W83792D_REG_IN_##REG[nr], \
data->in_##reg[nr]); \
mutex_unlock(&data->update_lock); \
\
return count; \
}

Definition at line 385 of file w83792d.c.

#define TEMP1_FROM_REG (   val)    (((val) & 0x80 ? (val)-0x100 : (val)) * 1000)

Definition at line 249 of file w83792d.c.

#define TEMP1_TO_REG (   val)
Value:
(SENSORS_LIMIT(((val) < 0 ? (val)+0x100*1000 \
: (val)) / 1000, 0, 0xff))

Definition at line 247 of file w83792d.c.

#define TEMP_ADD_FROM_REG (   val1,
  val2 
)
Value:
((((val1) & 0x80 ? (val1)-0x100 \
: (val1)) * 1000) + ((val2 & 0x80) ? 500 : 0))

Definition at line 251 of file w83792d.c.

#define TEMP_ADD_TO_REG_HIGH (   val)
Value:
(SENSORS_LIMIT(((val) < 0 ? (val)+0x100*1000 \
: (val)) / 1000, 0, 0xff))

Definition at line 254 of file w83792d.c.

#define TEMP_ADD_TO_REG_LOW (   val)    ((val%1000) ? 0x80 : 0x00)

Definition at line 257 of file w83792d.c.

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

Definition at line 210 of file w83792d.c.

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

Definition at line 211 of file w83792d.c.

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

Definition at line 212 of file w83792d.c.

#define W83792D_REG_BANK   0x4E

Definition at line 134 of file w83792d.c.

#define W83792D_REG_CHASSIS   0x42 /* Bit 5: Case Open status bit */

Definition at line 213 of file w83792d.c.

#define W83792D_REG_CHASSIS_CLR   0x44 /* Bit 7: Case Open CLR_CHS/Reset bit */

Definition at line 214 of file w83792d.c.

#define W83792D_REG_CHIPID   0x49

Definition at line 204 of file w83792d.c.

#define W83792D_REG_CHIPMAN   0x4F

Definition at line 206 of file w83792d.c.

#define W83792D_REG_CONFIG   0x40

Definition at line 202 of file w83792d.c.

#define W83792D_REG_FAN_CFG   0x84 /* FAN Configuration in DataSheet */

Definition at line 118 of file w83792d.c.

#define W83792D_REG_GPIO_EN   0x1A

Definition at line 201 of file w83792d.c.

#define W83792D_REG_I2C_ADDR   0x48

Definition at line 220 of file w83792d.c.

#define W83792D_REG_I2C_SUBADDR   0x4A

Definition at line 208 of file w83792d.c.

#define W83792D_REG_LOW_BITS1   0x3E /* Low Bits I in DataSheet */

Definition at line 76 of file w83792d.c.

#define W83792D_REG_LOW_BITS2   0x3F /* Low Bits II in DataSheet */

Definition at line 77 of file w83792d.c.

#define W83792D_REG_PIN   0x4B

Definition at line 207 of file w83792d.c.

#define W83792D_REG_TEMP2_CONFIG   0xC2

Definition at line 135 of file w83792d.c.

#define W83792D_REG_TEMP3_CONFIG   0xCA

Definition at line 136 of file w83792d.c.

#define W83792D_REG_VBAT   0x5D

Definition at line 219 of file w83792d.c.

#define W83792D_REG_VID_FANDIV   0x47

Definition at line 203 of file w83792d.c.

#define W83792D_REG_VID_IN_B   0x17

Definition at line 217 of file w83792d.c.

#define W83792D_REG_WCHIPID   0x58

Definition at line 205 of file w83792d.c.

Function Documentation

MODULE_AUTHOR ( "Chunhao Huang @ Winbond <[email protected]>"  )
MODULE_DESCRIPTION ( "W83792AD/D driver for linux-2.6"  )
MODULE_DEVICE_TABLE ( i2c  ,
w83792d_id   
)
module_i2c_driver ( w83792d_driver  )
MODULE_LICENSE ( "GPL"  )
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 ( init  ,
"Set to one to force chip initialization"   
)
show_fan_reg ( fan  )
show_fan_reg ( fan_min  )
show_in_reg ( in_min  )
show_in_reg ( in_max  )
store_in_reg ( MIN  ,
min   
)
store_in_reg ( MAX  ,
max   
)