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

Go to the source code of this file.

Data Structures

struct  pwm_data
 
struct  adm1026_data
 

Macros

#define ADM1026_REG_CONFIG1   0x00
 
#define CFG1_MONITOR   0x01
 
#define CFG1_INT_ENABLE   0x02
 
#define CFG1_INT_CLEAR   0x04
 
#define CFG1_AIN8_9   0x08
 
#define CFG1_THERM_HOT   0x10
 
#define CFG1_DAC_AFC   0x20
 
#define CFG1_PWM_AFC   0x40
 
#define CFG1_RESET   0x80
 
#define ADM1026_REG_CONFIG2   0x01
 
#define ADM1026_REG_CONFIG3   0x07
 
#define CFG3_GPIO16_ENABLE   0x01
 
#define CFG3_CI_CLEAR   0x02
 
#define CFG3_VREF_250   0x04
 
#define CFG3_GPIO16_DIR   0x40
 
#define CFG3_GPIO16_POL   0x80
 
#define ADM1026_REG_E2CONFIG   0x13
 
#define E2CFG_READ   0x01
 
#define E2CFG_WRITE   0x02
 
#define E2CFG_ERASE   0x04
 
#define E2CFG_ROM   0x08
 
#define E2CFG_CLK_EXT   0x80
 
#define ADM1026_REG_FAN(nr)   (0x38 + (nr))
 
#define ADM1026_REG_FAN_MIN(nr)   (0x60 + (nr))
 
#define ADM1026_REG_FAN_DIV_0_3   0x02
 
#define ADM1026_REG_FAN_DIV_4_7   0x03
 
#define ADM1026_REG_DAC   0x04
 
#define ADM1026_REG_PWM   0x05
 
#define ADM1026_REG_GPIO_CFG_0_3   0x08
 
#define ADM1026_REG_GPIO_CFG_4_7   0x09
 
#define ADM1026_REG_GPIO_CFG_8_11   0x0a
 
#define ADM1026_REG_GPIO_CFG_12_15   0x0b
 
#define ADM1026_REG_GPIO_STATUS_0_7   0x24
 
#define ADM1026_REG_GPIO_STATUS_8_15   0x25
 
#define ADM1026_REG_GPIO_MASK_0_7   0x1c
 
#define ADM1026_REG_GPIO_MASK_8_15   0x1d
 
#define ADM1026_REG_COMPANY   0x16
 
#define ADM1026_REG_VERSTEP   0x17
 
#define ADM1026_COMPANY_ANALOG_DEV   0x41
 
#define ADM1026_VERSTEP_GENERIC   0x40
 
#define ADM1026_VERSTEP_ADM1026   0x44
 
#define ADM1026_REG_MASK1   0x18
 
#define ADM1026_REG_MASK2   0x19
 
#define ADM1026_REG_MASK3   0x1a
 
#define ADM1026_REG_MASK4   0x1b
 
#define ADM1026_REG_STATUS1   0x20
 
#define ADM1026_REG_STATUS2   0x21
 
#define ADM1026_REG_STATUS3   0x22
 
#define ADM1026_REG_STATUS4   0x23
 
#define ADM1026_FAN_ACTIVATION_TEMP_HYST   -6
 
#define ADM1026_FAN_CONTROL_TEMP_RANGE   20
 
#define ADM1026_PWM_MAX   255
 
#define NEG12_OFFSET   16000
 
#define SCALE(val, from, to)   (((val)*(to) + ((from)/2))/(from))
 
#define INS_TO_REG(n, val)
 
#define INS_FROM_REG(n, val)   (SCALE(val, 192, adm1026_scaling[n]))
 
#define FAN_TO_REG(val, div)
 
#define FAN_FROM_REG(val, div)
 
#define DIV_FROM_REG(val)   (1 << (val))
 
#define DIV_TO_REG(val)   ((val) >= 8 ? 3 : (val) >= 4 ? 2 : (val) >= 2 ? 1 : 0)
 
#define TEMP_TO_REG(val)
 
#define TEMP_FROM_REG(val)   ((val) * 1000)
 
#define OFFSET_TO_REG(val)
 
#define OFFSET_FROM_REG(val)   ((val) * 1000)
 
#define PWM_TO_REG(val)   (SENSORS_LIMIT(val, 0, 255))
 
#define PWM_FROM_REG(val)   (val)
 
#define PWM_MIN_TO_REG(val)   ((val) & 0xf0)
 
#define PWM_MIN_FROM_REG(val)   (((val) & 0xf0) + ((val) >> 4))
 
#define DAC_TO_REG(val)   (SENSORS_LIMIT(((((val) * 255) + 500) / 2500), 0, 255))
 
#define DAC_FROM_REG(val)   (((val) * 2500) / 255)
 
#define ADM1026_DATA_INTERVAL   (1 * HZ)
 
#define ADM1026_CONFIG_INTERVAL   (5 * 60 * HZ)
 
#define in_reg(offset)
 
#define fan_offset(offset)
 
#define fan_offset_div(offset)
 
#define temp_reg(offset)
 
#define temp_offset_reg(offset)
 
#define temp_auto_point(offset)
 
#define temp_crit_enable(offset)
 
#define temp_crit_reg(offset)
 

Functions

 module_param_array (gpio_input, int, NULL, 0)
 
 MODULE_PARM_DESC (gpio_input,"List of GPIO pins (0-16) to program as inputs")
 
 module_param_array (gpio_output, int, NULL, 0)
 
 MODULE_PARM_DESC (gpio_output,"List of GPIO pins (0-16) to program as ""outputs")
 
 module_param_array (gpio_inverted, int, NULL, 0)
 
 MODULE_PARM_DESC (gpio_inverted,"List of GPIO pins (0-16) to program as ""inverted")
 
 module_param_array (gpio_normal, int, NULL, 0)
 
 MODULE_PARM_DESC (gpio_normal,"List of GPIO pins (0-16) to program as ""normal/non-inverted")
 
 module_param_array (gpio_fan, int, NULL, 0)
 
 MODULE_PARM_DESC (gpio_fan,"List of GPIO pins (0-7) to program as fan tachs")
 
 MODULE_DEVICE_TABLE (i2c, adm1026_id)
 
 in_reg (0)
 
 in_reg (1)
 
 in_reg (2)
 
 in_reg (3)
 
 in_reg (4)
 
 in_reg (5)
 
 in_reg (6)
 
 in_reg (7)
 
 in_reg (8)
 
 in_reg (9)
 
 in_reg (10)
 
 in_reg (11)
 
 in_reg (12)
 
 in_reg (13)
 
 in_reg (14)
 
 in_reg (15)
 
 fan_offset (1)
 
 fan_offset (2)
 
 fan_offset (3)
 
 fan_offset (4)
 
 fan_offset (5)
 
 fan_offset (6)
 
 fan_offset (7)
 
 fan_offset (8)
 
 fan_offset_div (1)
 
 fan_offset_div (2)
 
 fan_offset_div (3)
 
 fan_offset_div (4)
 
 fan_offset_div (5)
 
 fan_offset_div (6)
 
 fan_offset_div (7)
 
 fan_offset_div (8)
 
 temp_reg (1)
 
 temp_reg (2)
 
 temp_reg (3)
 
 temp_offset_reg (1)
 
 temp_offset_reg (2)
 
 temp_offset_reg (3)
 
 temp_auto_point (1)
 
 temp_auto_point (2)
 
 temp_auto_point (3)
 
 temp_crit_enable (1)
 
 temp_crit_enable (2)
 
 temp_crit_enable (3)
 
 temp_crit_reg (1)
 
 temp_crit_reg (2)
 
 temp_crit_reg (3)
 
 module_i2c_driver (adm1026_driver)
 
 MODULE_LICENSE ("GPL")
 
 MODULE_AUTHOR ("Philip Pokorny <[email protected]>, ""Justin Thiessen <[email protected]>")
 
 MODULE_DESCRIPTION ("ADM1026 driver")
 

Macro Definition Documentation

#define ADM1026_COMPANY_ANALOG_DEV   0x41

Definition at line 157 of file adm1026.c.

#define ADM1026_CONFIG_INTERVAL   (5 * 60 * HZ)

Definition at line 252 of file adm1026.c.

#define ADM1026_DATA_INTERVAL   (1 * HZ)

Definition at line 251 of file adm1026.c.

#define ADM1026_FAN_ACTIVATION_TEMP_HYST   -6

Definition at line 171 of file adm1026.c.

#define ADM1026_FAN_CONTROL_TEMP_RANGE   20

Definition at line 172 of file adm1026.c.

#define ADM1026_PWM_MAX   255

Definition at line 173 of file adm1026.c.

#define ADM1026_REG_COMPANY   0x16

Definition at line 154 of file adm1026.c.

#define ADM1026_REG_CONFIG1   0x00

Definition at line 66 of file adm1026.c.

#define ADM1026_REG_CONFIG2   0x01

Definition at line 76 of file adm1026.c.

#define ADM1026_REG_CONFIG3   0x07

Definition at line 79 of file adm1026.c.

#define ADM1026_REG_DAC   0x04

Definition at line 139 of file adm1026.c.

#define ADM1026_REG_E2CONFIG   0x13

Definition at line 86 of file adm1026.c.

#define ADM1026_REG_FAN (   nr)    (0x38 + (nr))

Definition at line 134 of file adm1026.c.

#define ADM1026_REG_FAN_DIV_0_3   0x02

Definition at line 136 of file adm1026.c.

#define ADM1026_REG_FAN_DIV_4_7   0x03

Definition at line 137 of file adm1026.c.

#define ADM1026_REG_FAN_MIN (   nr)    (0x60 + (nr))

Definition at line 135 of file adm1026.c.

#define ADM1026_REG_GPIO_CFG_0_3   0x08

Definition at line 142 of file adm1026.c.

#define ADM1026_REG_GPIO_CFG_12_15   0x0b

Definition at line 145 of file adm1026.c.

#define ADM1026_REG_GPIO_CFG_4_7   0x09

Definition at line 143 of file adm1026.c.

#define ADM1026_REG_GPIO_CFG_8_11   0x0a

Definition at line 144 of file adm1026.c.

#define ADM1026_REG_GPIO_MASK_0_7   0x1c

Definition at line 150 of file adm1026.c.

#define ADM1026_REG_GPIO_MASK_8_15   0x1d

Definition at line 151 of file adm1026.c.

#define ADM1026_REG_GPIO_STATUS_0_7   0x24

Definition at line 147 of file adm1026.c.

#define ADM1026_REG_GPIO_STATUS_8_15   0x25

Definition at line 148 of file adm1026.c.

#define ADM1026_REG_MASK1   0x18

Definition at line 161 of file adm1026.c.

#define ADM1026_REG_MASK2   0x19

Definition at line 162 of file adm1026.c.

#define ADM1026_REG_MASK3   0x1a

Definition at line 163 of file adm1026.c.

#define ADM1026_REG_MASK4   0x1b

Definition at line 164 of file adm1026.c.

#define ADM1026_REG_PWM   0x05

Definition at line 140 of file adm1026.c.

#define ADM1026_REG_STATUS1   0x20

Definition at line 166 of file adm1026.c.

#define ADM1026_REG_STATUS2   0x21

Definition at line 167 of file adm1026.c.

#define ADM1026_REG_STATUS3   0x22

Definition at line 168 of file adm1026.c.

#define ADM1026_REG_STATUS4   0x23

Definition at line 169 of file adm1026.c.

#define ADM1026_REG_VERSTEP   0x17

Definition at line 155 of file adm1026.c.

#define ADM1026_VERSTEP_ADM1026   0x44

Definition at line 159 of file adm1026.c.

#define ADM1026_VERSTEP_GENERIC   0x40

Definition at line 158 of file adm1026.c.

#define CFG1_AIN8_9   0x08

Definition at line 70 of file adm1026.c.

#define CFG1_DAC_AFC   0x20

Definition at line 72 of file adm1026.c.

#define CFG1_INT_CLEAR   0x04

Definition at line 69 of file adm1026.c.

#define CFG1_INT_ENABLE   0x02

Definition at line 68 of file adm1026.c.

#define CFG1_MONITOR   0x01

Definition at line 67 of file adm1026.c.

#define CFG1_PWM_AFC   0x40

Definition at line 73 of file adm1026.c.

#define CFG1_RESET   0x80

Definition at line 74 of file adm1026.c.

#define CFG1_THERM_HOT   0x10

Definition at line 71 of file adm1026.c.

#define CFG3_CI_CLEAR   0x02

Definition at line 81 of file adm1026.c.

#define CFG3_GPIO16_DIR   0x40

Definition at line 83 of file adm1026.c.

#define CFG3_GPIO16_ENABLE   0x01

Definition at line 80 of file adm1026.c.

#define CFG3_GPIO16_POL   0x80

Definition at line 84 of file adm1026.c.

#define CFG3_VREF_250   0x04

Definition at line 82 of file adm1026.c.

#define DAC_FROM_REG (   val)    (((val) * 2500) / 255)

Definition at line 237 of file adm1026.c.

#define DAC_TO_REG (   val)    (SENSORS_LIMIT(((((val) * 255) + 500) / 2500), 0, 255))

Definition at line 236 of file adm1026.c.

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

Definition at line 214 of file adm1026.c.

#define DIV_TO_REG (   val)    ((val) >= 8 ? 3 : (val) >= 4 ? 2 : (val) >= 2 ? 1 : 0)

Definition at line 215 of file adm1026.c.

#define E2CFG_CLK_EXT   0x80

Definition at line 91 of file adm1026.c.

#define E2CFG_ERASE   0x04

Definition at line 89 of file adm1026.c.

#define E2CFG_READ   0x01

Definition at line 87 of file adm1026.c.

#define E2CFG_ROM   0x08

Definition at line 90 of file adm1026.c.

#define E2CFG_WRITE   0x02

Definition at line 88 of file adm1026.c.

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

Definition at line 212 of file adm1026.c.

#define fan_offset (   offset)
Value:
offset - 1); \
show_fan_min, set_fan_min, offset - 1);

Definition at line 908 of file adm1026.c.

#define fan_offset_div (   offset)
Value:
show_fan_div, set_fan_div, offset - 1);

Definition at line 992 of file adm1026.c.

#define FAN_TO_REG (   val,
  div 
)
Value:
((val) <= 0 ? 0xff : \
SENSORS_LIMIT(1350000 / ((val) * (div)), \
1, 254))

Definition at line 209 of file adm1026.c.

#define in_reg (   offset)
Value:
NULL, offset); \
show_in_min, set_in_min, offset); \
show_in_max, set_in_max, offset);

Definition at line 775 of file adm1026.c.

#define INS_FROM_REG (   n,
  val 
)    (SCALE(val, 192, adm1026_scaling[n]))

Definition at line 202 of file adm1026.c.

#define INS_TO_REG (   n,
  val 
)
Value:
(SENSORS_LIMIT(SCALE(val, adm1026_scaling[n], 192),\
0, 255))

Definition at line 200 of file adm1026.c.

#define NEG12_OFFSET   16000

Definition at line 198 of file adm1026.c.

#define OFFSET_FROM_REG (   val)    ((val) * 1000)

Definition at line 223 of file adm1026.c.

#define OFFSET_TO_REG (   val)
Value:
(SENSORS_LIMIT(((val) + ((val) < 0 ? -500 : 500)) \
/ 1000, -127, 127))

Definition at line 221 of file adm1026.c.

#define PWM_FROM_REG (   val)    (val)

Definition at line 226 of file adm1026.c.

#define PWM_MIN_FROM_REG (   val)    (((val) & 0xf0) + ((val) >> 4))

Definition at line 229 of file adm1026.c.

#define PWM_MIN_TO_REG (   val)    ((val) & 0xf0)

Definition at line 228 of file adm1026.c.

#define PWM_TO_REG (   val)    (SENSORS_LIMIT(val, 0, 255))

Definition at line 225 of file adm1026.c.

#define SCALE (   val,
  from,
  to 
)    (((val)*(to) + ((from)/2))/(from))

Definition at line 199 of file adm1026.c.

#define temp_auto_point (   offset)
Value:
static SENSOR_DEVICE_ATTR(temp##offset##_auto_point1_temp, \
S_IRUGO | S_IWUSR, show_temp_auto_point1_temp, \
set_temp_auto_point1_temp, offset - 1); \
static SENSOR_DEVICE_ATTR(temp##offset##_auto_point1_temp_hyst, S_IRUGO,\
show_temp_auto_point1_temp_hyst, NULL, offset - 1); \
static SENSOR_DEVICE_ATTR(temp##offset##_auto_point2_temp, S_IRUGO, \
show_temp_auto_point2_temp, NULL, offset - 1);

Definition at line 1173 of file adm1026.c.

#define temp_crit_enable (   offset)
Value:
static DEVICE_ATTR(temp##offset##_crit_enable, S_IRUGO | S_IWUSR, \
show_temp_crit_enable, set_temp_crit_enable);

Definition at line 1215 of file adm1026.c.

#define temp_crit_reg (   offset)
Value:
show_temp_crit, set_temp_crit, offset - 1);

Definition at line 1253 of file adm1026.c.

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

Definition at line 220 of file adm1026.c.

#define temp_offset_reg (   offset)
Value:
show_temp_offset, set_temp_offset, offset - 1);

Definition at line 1117 of file adm1026.c.

#define temp_reg (   offset)
Value:
NULL, offset - 1); \
show_temp_min, set_temp_min, offset - 1); \
show_temp_max, set_temp_max, offset - 1);

Definition at line 1073 of file adm1026.c.

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

Definition at line 218 of file adm1026.c.

Function Documentation

fan_offset ( )
fan_offset ( )
fan_offset ( )
fan_offset ( )
fan_offset ( )
fan_offset ( )
fan_offset ( )
fan_offset ( )
fan_offset_div ( )
fan_offset_div ( )
fan_offset_div ( )
fan_offset_div ( )
fan_offset_div ( )
fan_offset_div ( )
fan_offset_div ( )
fan_offset_div ( )
in_reg ( )
in_reg ( )
in_reg ( )
in_reg ( )
in_reg ( )
in_reg ( )
in_reg ( )
in_reg ( )
in_reg ( )
in_reg ( )
in_reg ( 10  )
in_reg ( 11  )
in_reg ( 12  )
in_reg ( 13  )
in_reg ( 14  )
in_reg ( 15  )
MODULE_AUTHOR ( "Philip Pokorny <[email protected] ,
""Justin Thiessen< jthiessen @penguincomputing.com >"   
)
MODULE_DESCRIPTION ( "ADM1026 driver )
MODULE_DEVICE_TABLE ( i2c  ,
adm1026_id   
)
module_i2c_driver ( adm1026_driver  )
MODULE_LICENSE ( "GPL"  )
module_param_array ( gpio_input  ,
int  ,
NULL  ,
 
)
module_param_array ( gpio_output  ,
int  ,
NULL  ,
 
)
module_param_array ( gpio_inverted  ,
int  ,
NULL  ,
 
)
module_param_array ( gpio_normal  ,
int  ,
NULL  ,
 
)
module_param_array ( gpio_fan  ,
int  ,
NULL  ,
 
)
MODULE_PARM_DESC ( gpio_input  ,
"List of GPIO pins (0-16) to program as inputs"   
)
MODULE_PARM_DESC ( gpio_output  ,
"List of GPIO pins (0-16) to program as ""outputs"   
)
MODULE_PARM_DESC ( gpio_inverted  ,
"List of GPIO pins (0-16) to program as ""inverted"   
)
MODULE_PARM_DESC ( gpio_normal  ,
"List of GPIO pins (0-16) to program as ""normal/non-inverted"   
)
MODULE_PARM_DESC ( gpio_fan  ,
"List of GPIO pins (0-7) to program as fan tachs"   
)
temp_auto_point ( )
temp_auto_point ( )
temp_auto_point ( )
temp_crit_enable ( )
temp_crit_enable ( )
temp_crit_enable ( )
temp_crit_reg ( )
temp_crit_reg ( )
temp_crit_reg ( )
temp_offset_reg ( )
temp_offset_reg ( )
temp_offset_reg ( )
temp_reg ( )
temp_reg ( )
temp_reg ( )