#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.
|
#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) |
|
|
| 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") |
|
#define ADM1026_COMPANY_ANALOG_DEV 0x41 |
#define ADM1026_CONFIG_INTERVAL (5 * 60 * HZ) |
#define ADM1026_DATA_INTERVAL (1 * HZ) |
#define ADM1026_FAN_ACTIVATION_TEMP_HYST -6 |
#define ADM1026_FAN_CONTROL_TEMP_RANGE 20 |
#define ADM1026_PWM_MAX 255 |
#define ADM1026_REG_COMPANY 0x16 |
#define ADM1026_REG_CONFIG1 0x00 |
#define ADM1026_REG_CONFIG2 0x01 |
#define ADM1026_REG_CONFIG3 0x07 |
#define ADM1026_REG_DAC 0x04 |
#define ADM1026_REG_E2CONFIG 0x13 |
#define ADM1026_REG_FAN |
( |
|
nr | ) |
(0x38 + (nr)) |
#define ADM1026_REG_FAN_DIV_0_3 0x02 |
#define ADM1026_REG_FAN_DIV_4_7 0x03 |
#define ADM1026_REG_FAN_MIN |
( |
|
nr | ) |
(0x60 + (nr)) |
#define ADM1026_REG_GPIO_CFG_0_3 0x08 |
#define ADM1026_REG_GPIO_CFG_12_15 0x0b |
#define ADM1026_REG_GPIO_CFG_4_7 0x09 |
#define ADM1026_REG_GPIO_CFG_8_11 0x0a |
#define ADM1026_REG_GPIO_MASK_0_7 0x1c |
#define ADM1026_REG_GPIO_MASK_8_15 0x1d |
#define ADM1026_REG_GPIO_STATUS_0_7 0x24 |
#define ADM1026_REG_GPIO_STATUS_8_15 0x25 |
#define ADM1026_REG_MASK1 0x18 |
#define ADM1026_REG_MASK2 0x19 |
#define ADM1026_REG_MASK3 0x1a |
#define ADM1026_REG_MASK4 0x1b |
#define ADM1026_REG_PWM 0x05 |
#define ADM1026_REG_STATUS1 0x20 |
#define ADM1026_REG_STATUS2 0x21 |
#define ADM1026_REG_STATUS3 0x22 |
#define ADM1026_REG_STATUS4 0x23 |
#define ADM1026_REG_VERSTEP 0x17 |
#define ADM1026_VERSTEP_ADM1026 0x44 |
#define ADM1026_VERSTEP_GENERIC 0x40 |
#define CFG1_DAC_AFC 0x20 |
#define CFG1_INT_CLEAR 0x04 |
#define CFG1_INT_ENABLE 0x02 |
#define CFG1_MONITOR 0x01 |
#define CFG1_PWM_AFC 0x40 |
#define CFG1_THERM_HOT 0x10 |
#define CFG3_CI_CLEAR 0x02 |
#define CFG3_GPIO16_DIR 0x40 |
#define CFG3_GPIO16_ENABLE 0x01 |
#define CFG3_GPIO16_POL 0x80 |
#define CFG3_VREF_250 0x04 |
#define DAC_FROM_REG |
( |
|
val | ) |
(((val) * 2500) / 255) |
#define DAC_TO_REG |
( |
|
val | ) |
(SENSORS_LIMIT(((((val) * 255) + 500) / 2500), 0, 255)) |
#define DIV_FROM_REG |
( |
|
val | ) |
(1 << (val)) |
#define DIV_TO_REG |
( |
|
val | ) |
((val) >= 8 ? 3 : (val) >= 4 ? 2 : (val) >= 2 ? 1 : 0) |
#define E2CFG_CLK_EXT 0x80 |
#define FAN_FROM_REG |
( |
|
val, |
|
|
|
div |
|
) |
| |
#define fan_offset_div |
( |
|
offset | ) |
|
#define FAN_TO_REG |
( |
|
val, |
|
|
|
div |
|
) |
| |
Value:
SENSORS_LIMIT(1350000 / ((
val) * (
div)), \
1, 254))
Definition at line 209 of file adm1026.c.
#define INS_FROM_REG |
( |
|
n, |
|
|
|
val |
|
) |
| (SCALE(val, 192, adm1026_scaling[n])) |
#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 |
#define OFFSET_FROM_REG |
( |
|
val | ) |
((val) * 1000) |
#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) |
#define PWM_MIN_FROM_REG |
( |
|
val | ) |
(((val) & 0xf0) + ((val) >> 4)) |
#define PWM_MIN_TO_REG |
( |
|
val | ) |
((val) & 0xf0) |
#define PWM_TO_REG |
( |
|
val | ) |
(SENSORS_LIMIT(val, 0, 255)) |
#define temp_auto_point |
( |
|
offset | ) |
|
Value:
set_temp_auto_point1_temp,
offset - 1); \
show_temp_auto_point1_temp_hyst,
NULL,
offset - 1); \
Definition at line 1173 of file adm1026.c.
#define temp_crit_enable |
( |
|
offset | ) |
|
Value:
show_temp_crit_enable, set_temp_crit_enable);
Definition at line 1215 of file adm1026.c.
#define temp_crit_reg |
( |
|
offset | ) |
|
#define TEMP_FROM_REG |
( |
|
val | ) |
((val) * 1000) |
#define temp_offset_reg |
( |
|
offset | ) |
|
Value:
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.
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_param_array |
( |
gpio_input |
, |
|
|
int |
, |
|
|
NULL |
, |
|
|
0 |
|
|
) |
| |
module_param_array |
( |
gpio_output |
, |
|
|
int |
, |
|
|
NULL |
, |
|
|
0 |
|
|
) |
| |
module_param_array |
( |
gpio_inverted |
, |
|
|
int |
, |
|
|
NULL |
, |
|
|
0 |
|
|
) |
| |
module_param_array |
( |
gpio_normal |
, |
|
|
int |
, |
|
|
NULL |
, |
|
|
0 |
|
|
) |
| |
module_param_array |
( |
gpio_fan |
, |
|
|
int |
, |
|
|
NULL |
, |
|
|
0 |
|
|
) |
| |
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" |
|
|
) |
| |