Linux Kernel  3.7.1
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Functions
w83l786ng.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  w83l786ng_data
 

Macros

#define W83L786NG_REG_IN_MIN(nr)   (0x2C + (nr) * 2)
 
#define W83L786NG_REG_IN_MAX(nr)   (0x2B + (nr) * 2)
 
#define W83L786NG_REG_IN(nr)   ((nr) + 0x20)
 
#define W83L786NG_REG_FAN(nr)   ((nr) + 0x28)
 
#define W83L786NG_REG_FAN_MIN(nr)   ((nr) + 0x3B)
 
#define W83L786NG_REG_CONFIG   0x40
 
#define W83L786NG_REG_ALARM1   0x41
 
#define W83L786NG_REG_ALARM2   0x42
 
#define W83L786NG_REG_GPIO_EN   0x47
 
#define W83L786NG_REG_MAN_ID2   0x4C
 
#define W83L786NG_REG_MAN_ID1   0x4D
 
#define W83L786NG_REG_CHIP_ID   0x4E
 
#define W83L786NG_REG_DIODE   0x53
 
#define W83L786NG_REG_FAN_DIV   0x54
 
#define W83L786NG_REG_FAN_CFG   0x80
 
#define W83L786NG_REG_TOLERANCE   0x8D
 
#define FAN_FROM_REG(val, div)
 
#define TEMP_TO_REG(val)
 
#define TEMP_FROM_REG(val)
 
#define IN_TO_REG(val)   (SENSORS_LIMIT((((val) + 4) / 8), 0, 255))
 
#define IN_FROM_REG(val)   ((val) * 8)
 
#define DIV_FROM_REG(val)   (1 << (val))
 
#define show_in_reg(reg)
 
#define store_in_reg(REG, reg)
 
#define show_fan_reg(reg)
 
#define show_pwm_reg(reg)
 
#define IN_UNIT_ATTRS(X)
 
#define FAN_UNIT_ATTRS(X)
 
#define TEMP_UNIT_ATTRS(X)
 
#define PWM_UNIT_ATTRS(X)
 
#define TOLERANCE_UNIT_ATTRS(X)   &sda_tolerance[X].dev_attr.attr
 

Functions

 module_param (reset, bool, 0)
 
 MODULE_PARM_DESC (reset,"Set to 1 to reset chip, not recommended")
 
 MODULE_DEVICE_TABLE (i2c, w83l786ng_id)
 
 show_in_reg (in)
 
 show_fan_reg (fan)
 
 show_fan_reg (fan_min)
 
 show_pwm_reg (pwm_mode)
 
 module_i2c_driver (w83l786ng_driver)
 
 MODULE_AUTHOR ("Kevin Lo")
 
 MODULE_DESCRIPTION ("w83l786ng driver")
 
 MODULE_LICENSE ("GPL")
 

Macro Definition Documentation

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

Definition at line 112 of file w83l786ng.c.

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

Definition at line 93 of file w83l786ng.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

Definition at line 592 of file w83l786ng.c.

#define IN_FROM_REG (   val)    ((val) * 8)

Definition at line 110 of file w83l786ng.c.

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

Definition at line 109 of file w83l786ng.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

Definition at line 587 of file w83l786ng.c.

#define PWM_UNIT_ATTRS (   X)
Value:
&sda_pwm[X].dev_attr.attr, \
&sda_pwm_mode[X].dev_attr.attr, \
&sda_pwm_enable[X].dev_attr.attr

Definition at line 602 of file w83l786ng.c.

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

Definition at line 246 of file w83l786ng.c.

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

Definition at line 191 of file w83l786ng.c.

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

Definition at line 430 of file w83l786ng.c.

#define store_in_reg (   REG,
  reg 
)
Value:
static ssize_t \
store_in_##reg(struct device *dev, struct device_attribute *attr, \
const char *buf, size_t count) \
{ \
int nr = to_sensor_dev_attr(attr)->index; \
struct w83l786ng_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] = IN_TO_REG(val); \
w83l786ng_write_value(client, W83L786NG_REG_IN_##REG(nr), \
data->in_##reg[nr]); \
mutex_unlock(&data->update_lock); \
return count; \
}
#define TEMP_FROM_REG (   val)
Value:
(((val) & 0x80 ? \
(val) - 0x100 : (val)) * 1000)

Definition at line 101 of file w83l786ng.c.

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

Definition at line 98 of file w83l786ng.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

Definition at line 597 of file w83l786ng.c.

#define TOLERANCE_UNIT_ATTRS (   X)    &sda_tolerance[X].dev_attr.attr

Definition at line 607 of file w83l786ng.c.

#define W83L786NG_REG_ALARM1   0x41

Definition at line 55 of file w83l786ng.c.

#define W83L786NG_REG_ALARM2   0x42

Definition at line 56 of file w83l786ng.c.

#define W83L786NG_REG_CHIP_ID   0x4E

Definition at line 60 of file w83l786ng.c.

#define W83L786NG_REG_CONFIG   0x40

Definition at line 54 of file w83l786ng.c.

#define W83L786NG_REG_DIODE   0x53

Definition at line 62 of file w83l786ng.c.

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

Definition at line 51 of file w83l786ng.c.

#define W83L786NG_REG_FAN_CFG   0x80

Definition at line 64 of file w83l786ng.c.

#define W83L786NG_REG_FAN_DIV   0x54

Definition at line 63 of file w83l786ng.c.

#define W83L786NG_REG_FAN_MIN (   nr)    ((nr) + 0x3B)

Definition at line 52 of file w83l786ng.c.

#define W83L786NG_REG_GPIO_EN   0x47

Definition at line 57 of file w83l786ng.c.

#define W83L786NG_REG_IN (   nr)    ((nr) + 0x20)

Definition at line 49 of file w83l786ng.c.

#define W83L786NG_REG_IN_MAX (   nr)    (0x2B + (nr) * 2)

Definition at line 48 of file w83l786ng.c.

#define W83L786NG_REG_IN_MIN (   nr)    (0x2C + (nr) * 2)

Definition at line 47 of file w83l786ng.c.

#define W83L786NG_REG_MAN_ID1   0x4D

Definition at line 59 of file w83l786ng.c.

#define W83L786NG_REG_MAN_ID2   0x4C

Definition at line 58 of file w83l786ng.c.

#define W83L786NG_REG_TOLERANCE   0x8D

Definition at line 66 of file w83l786ng.c.

Function Documentation

MODULE_AUTHOR ( "Kevin Lo"  )
MODULE_DESCRIPTION ( "w83l786ng driver )
MODULE_DEVICE_TABLE ( i2c  ,
w83l786ng_id   
)
module_i2c_driver ( w83l786ng_driver  )
MODULE_LICENSE ( "GPL"  )
module_param ( reset  ,
bool  ,
 
)
MODULE_PARM_DESC ( reset  ,
"Set to 1 to reset  chip,
not recommended"   
)
show_fan_reg ( fan  )
show_fan_reg ( fan_min  )
show_in_reg ( in  )

Definition at line 201 of file w83l786ng.c.

show_pwm_reg ( pwm_mode  )

Definition at line 439 of file w83l786ng.c.