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

Go to the source code of this file.

Data Structures

struct  asb100_data
 

Macros

#define pr_fmt(fmt)   KBUILD_MODNAME ": " fmt
 
#define ASB100_REG_IN(nr)   (0x20 + (nr))
 
#define ASB100_REG_IN_MAX(nr)   (0x2b + (nr * 2))
 
#define ASB100_REG_IN_MIN(nr)   (0x2c + (nr * 2))
 
#define ASB100_REG_FAN(nr)   (0x28 + (nr))
 
#define ASB100_REG_FAN_MIN(nr)   (0x3b + (nr))
 
#define ASB100_REG_TEMP(nr)   (asb100_reg_temp[nr])
 
#define ASB100_REG_TEMP_MAX(nr)   (asb100_reg_temp_max[nr])
 
#define ASB100_REG_TEMP_HYST(nr)   (asb100_reg_temp_hyst[nr])
 
#define ASB100_REG_TEMP2_CONFIG   0x0152
 
#define ASB100_REG_TEMP3_CONFIG   0x0252
 
#define ASB100_REG_CONFIG   0x40
 
#define ASB100_REG_ALARM1   0x41
 
#define ASB100_REG_ALARM2   0x42
 
#define ASB100_REG_SMIM1   0x43
 
#define ASB100_REG_SMIM2   0x44
 
#define ASB100_REG_VID_FANDIV   0x47
 
#define ASB100_REG_I2C_ADDR   0x48
 
#define ASB100_REG_CHIPID   0x49
 
#define ASB100_REG_I2C_SUBADDR   0x4a
 
#define ASB100_REG_PIN   0x4b
 
#define ASB100_REG_IRQ   0x4c
 
#define ASB100_REG_BANK   0x4e
 
#define ASB100_REG_CHIPMAN   0x4f
 
#define ASB100_REG_WCHIPID   0x58
 
#define ASB100_REG_PWM1   0x59
 
#define ASB100_IN_MIN   0
 
#define ASB100_IN_MAX   4080
 
#define ASB100_TEMP_MIN   -128000
 
#define ASB100_TEMP_MAX   127000
 
#define DIV_FROM_REG(val)   (1 << (val))
 
#define show_in_reg(reg)
 
#define set_in_reg(REG, reg)
 
#define sysfs_in(offset)
 
#define sysfs_fan(offset)
 
#define show_temp_reg(reg)
 
#define set_temp_reg(REG, reg)
 
#define sysfs_temp(num)
 

Functions

 module_param_array (force_subclients, short, NULL, 0)
 
 MODULE_PARM_DESC (force_subclients,"List of subclient addresses: ""{bus, clientaddr, subclientaddr1, subclientaddr2}")
 
 MODULE_DEVICE_TABLE (i2c, asb100_id)
 
 show_in_reg (in)
 
 sysfs_fan (1)
 
 sysfs_fan (2)
 
 sysfs_fan (3)
 
 show_temp_reg (temp)
 
 show_temp_reg (temp_max)
 
 show_temp_reg (temp_hyst)
 
 set_temp_reg (MAX, temp_max)
 
 set_temp_reg (HYST, temp_hyst)
 
 sysfs_temp (1)
 
 sysfs_temp (2)
 
 sysfs_temp (3)
 
 sysfs_temp (4)
 
 module_i2c_driver (asb100_driver)
 
 MODULE_AUTHOR ("Mark M. Hoffman <[email protected]>")
 
 MODULE_DESCRIPTION ("ASB100 Bach driver")
 
 MODULE_LICENSE ("GPL")
 

Macro Definition Documentation

#define ASB100_IN_MAX   4080

Definition at line 109 of file asb100.c.

#define ASB100_IN_MIN   0

Definition at line 108 of file asb100.c.

#define ASB100_REG_ALARM1   0x41

Definition at line 84 of file asb100.c.

#define ASB100_REG_ALARM2   0x42

Definition at line 85 of file asb100.c.

#define ASB100_REG_BANK   0x4e

Definition at line 94 of file asb100.c.

#define ASB100_REG_CHIPID   0x49

Definition at line 90 of file asb100.c.

#define ASB100_REG_CHIPMAN   0x4f

Definition at line 95 of file asb100.c.

#define ASB100_REG_CONFIG   0x40

Definition at line 83 of file asb100.c.

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

Definition at line 67 of file asb100.c.

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

Definition at line 68 of file asb100.c.

#define ASB100_REG_I2C_ADDR   0x48

Definition at line 89 of file asb100.c.

#define ASB100_REG_I2C_SUBADDR   0x4a

Definition at line 91 of file asb100.c.

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

Definition at line 62 of file asb100.c.

#define ASB100_REG_IN_MAX (   nr)    (0x2b + (nr * 2))

Definition at line 63 of file asb100.c.

#define ASB100_REG_IN_MIN (   nr)    (0x2c + (nr * 2))

Definition at line 64 of file asb100.c.

#define ASB100_REG_IRQ   0x4c

Definition at line 93 of file asb100.c.

#define ASB100_REG_PIN   0x4b

Definition at line 92 of file asb100.c.

#define ASB100_REG_PWM1   0x59

Definition at line 100 of file asb100.c.

#define ASB100_REG_SMIM1   0x43

Definition at line 86 of file asb100.c.

#define ASB100_REG_SMIM2   0x44

Definition at line 87 of file asb100.c.

#define ASB100_REG_TEMP (   nr)    (asb100_reg_temp[nr])

Definition at line 75 of file asb100.c.

#define ASB100_REG_TEMP2_CONFIG   0x0152

Definition at line 79 of file asb100.c.

#define ASB100_REG_TEMP3_CONFIG   0x0252

Definition at line 80 of file asb100.c.

#define ASB100_REG_TEMP_HYST (   nr)    (asb100_reg_temp_hyst[nr])

Definition at line 77 of file asb100.c.

#define ASB100_REG_TEMP_MAX (   nr)    (asb100_reg_temp_max[nr])

Definition at line 76 of file asb100.c.

#define ASB100_REG_VID_FANDIV   0x47

Definition at line 88 of file asb100.c.

#define ASB100_REG_WCHIPID   0x58

Definition at line 97 of file asb100.c.

#define ASB100_TEMP_MAX   127000

Definition at line 143 of file asb100.c.

#define ASB100_TEMP_MIN   -128000

Definition at line 142 of file asb100.c.

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

Definition at line 176 of file asb100.c.

#define pr_fmt (   fmt)    KBUILD_MODNAME ": " fmt

Definition at line 39 of file asb100.c.

#define set_in_reg (   REG,
  reg 
)
Value:
static ssize_t set_in_##reg(struct device *dev, struct device_attribute *attr, \
const char *buf, size_t count) \
{ \
int nr = to_sensor_dev_attr(attr)->index; \
struct asb100_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); \
asb100_write_value(client, ASB100_REG_IN_##REG(nr), \
data->in_##reg[nr]); \
mutex_unlock(&data->update_lock); \
return count; \
}
#define set_temp_reg (   REG,
  reg 
)
Value:
static ssize_t set_##reg(struct device *dev, struct device_attribute *attr, \
const char *buf, size_t count) \
{ \
int nr = to_sensor_dev_attr(attr)->index; \
struct asb100_data *data = i2c_get_clientdata(client); \
long val; \
int err = kstrtol(buf, 10, &val); \
if (err) \
return err; \
mutex_lock(&data->update_lock); \
switch (nr) { \
case 1: case 2: \
data->reg[nr] = LM75_TEMP_TO_REG(val); \
break; \
case 0: case 3: default: \
data->reg[nr] = TEMP_TO_REG(val); \
break; \
} \
asb100_write_value(client, ASB100_REG_TEMP_##REG(nr+1), \
data->reg[nr]); \
mutex_unlock(&data->update_lock); \
return count; \
}

Definition at line 443 of file asb100.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 asb100_data *data = asb100_update_device(dev); \
return sprintf(buf, "%d\n", IN_FROM_REG(data->reg[nr])); \
}

Definition at line 248 of file asb100.c.

#define show_temp_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 asb100_data *data = asb100_update_device(dev); \
return sprintf_temp_from_reg(data->reg[nr], buf, nr); \
}

Definition at line 430 of file asb100.c.

#define sysfs_fan (   offset)
Value:
static SENSOR_DEVICE_ATTR(fan##offset##_input, S_IRUGO, \
show_fan, NULL, offset - 1); \
show_fan_min, set_fan_min, offset - 1); \
show_fan_div, set_fan_div, offset - 1)

Definition at line 402 of file asb100.c.

#define sysfs_in (   offset)
Value:
static SENSOR_DEVICE_ATTR(in##offset##_input, S_IRUGO, \
show_in_min, set_in_min, offset); \
show_in_max, set_in_max, offset)
#define sysfs_temp (   num)
Value:
static SENSOR_DEVICE_ATTR(temp##num##_input, S_IRUGO, \
show_temp, NULL, num - 1); \
static SENSOR_DEVICE_ATTR(temp##num##_max, S_IRUGO | S_IWUSR, \
show_temp_max, set_temp_max, num - 1); \
static SENSOR_DEVICE_ATTR(temp##num##_max_hyst, S_IRUGO | S_IWUSR, \
show_temp_hyst, set_temp_hyst, num - 1)

Definition at line 472 of file asb100.c.

Function Documentation

MODULE_AUTHOR ( "Mark M. Hoffman <[email protected]>"  )
MODULE_DESCRIPTION ( "ASB100 Bach driver )
MODULE_DEVICE_TABLE ( i2c  ,
asb100_id   
)
module_i2c_driver ( asb100_driver  )
MODULE_LICENSE ( "GPL"  )
module_param_array ( force_subclients  ,
short  ,
NULL  ,
 
)
MODULE_PARM_DESC ( force_subclients  ,
"List of subclient addresses: ""{bus, clientaddr, subclientaddr1, subclientaddr2}"   
)
set_temp_reg ( MAX  ,
temp_max   
)
set_temp_reg ( HYST  ,
temp_hyst   
)
show_in_reg ( in  )

Definition at line 257 of file asb100.c.

show_temp_reg ( temp  )
show_temp_reg ( temp_max  )
show_temp_reg ( temp_hyst  )
sysfs_fan ( )
sysfs_fan ( )
sysfs_fan ( )
sysfs_temp ( )
sysfs_temp ( )
sysfs_temp ( )
sysfs_temp ( )