Copyright (c) 1998, 1999 Frodo Looijaard <frodol@dds.nl>
Copyright (c) 2002, 2003 Philip Pokorny <ppokorny@penguincomputing.com>
Copyright (c) 2003 Margit Schubert-While <margitsw@t-online.de>
+ Copyright (c) 2004 Justin Thiessen <jthiessen@penguincomputing.com>
Chip details at <http://www.national.com/ds/LM/LM85.pdf>
#include <linux/i2c.h>
#include <linux/i2c-sensor.h>
#include <linux/i2c-vid.h>
-/*
-#include <asm/io.h>
-*/
-
-#undef LM85EXTENDEDFUNC /* Extended functionality */
/* Addresses to scan */
static unsigned short normal_i2c[] = { 0x2c, 0x2d, 0x2e, I2C_CLIENT_END };
-static unsigned short normal_i2c_range[] = { I2C_CLIENT_END };
static unsigned int normal_isa[] = { I2C_CLIENT_ISA_END };
-static unsigned int normal_isa_range[] = { I2C_CLIENT_ISA_END };
/* Insmod parameters */
-SENSORS_INSMOD_4(lm85b, lm85c, adm1027, adt7463);
+SENSORS_INSMOD_5(lm85b, lm85c, adm1027, adt7463, emc6d100);
/* The LM85 registers */
#define LM85_DEVICE_ADX 0x27
#define LM85_COMPANY_NATIONAL 0x01
#define LM85_COMPANY_ANALOG_DEV 0x41
+#define LM85_COMPANY_SMSC 0x5c
+#define LM85_VERSTEP_VMASK 0xf0
#define LM85_VERSTEP_GENERIC 0x60
#define LM85_VERSTEP_LM85C 0x60
#define LM85_VERSTEP_LM85B 0x62
#define LM85_VERSTEP_ADM1027 0x60
#define LM85_VERSTEP_ADT7463 0x62
+#define LM85_VERSTEP_EMC6D100_A0 0x60
+#define LM85_VERSTEP_EMC6D100_A1 0x61
#define LM85_REG_CONFIG 0x40
#define ADT7463_REG_THERM 0x79
#define ADT7463_REG_THERM_LIMIT 0x7A
+#define EMC6D100_REG_ALARM3 0x7d
+/* IN5, IN6 and IN7 */
+#define EMC6D100_REG_IN(nr) (0x70 + ((nr)-5))
+#define EMC6D100_REG_IN_MIN(nr) (0x73 + ((nr)-5) * 2)
+#define EMC6D100_REG_IN_MAX(nr) (0x74 + ((nr)-5) * 2)
+
#define LM85_ALARM_IN0 0x0001
#define LM85_ALARM_IN1 0x0002
#define LM85_ALARM_IN2 0x0004
/* IN are scaled acording to built-in resistors */
static int lm85_scaling[] = { /* .001 Volts */
- 2500, 2250, 3300, 5000, 12000
+ 2500, 2250, 3300, 5000, 12000,
+ 3300, 1500, 1800 /*EMC6D100*/
};
#define SCALE(val,from,to) (((val)*(to) + ((from)/2))/(from))
#define INS_TO_REG(n,val) (SENSORS_LIMIT(SCALE(val,lm85_scaling[n],192),0,255))
#define EXT_FROM_REG(val,sensor) (((val)>>(sensor * 2))&0x03)
-#ifdef LM85EXTENDEDFUNC /* Extended functionality */
-
/* ZONEs have the following parameters:
* Limit (low) temp, 1. degC
* Hysteresis (below limit), 1. degC (0-15)
* Filter constant (or disabled) .1 seconds
*/
-/* These are the zone temperature range encodings */
-static int lm85_range_map[] = { /* .1 degC */
- 20, 25, 33, 40, 50, 66,
- 80, 100, 133, 160, 200, 266,
- 320, 400, 533, 800
+/* These are the zone temperature range encodings in .001 degree C */
+static int lm85_range_map[] = {
+ 2000, 2500, 3300, 4000, 5000, 6600,
+ 8000, 10000, 13300, 16000, 20000, 26600,
+ 32000, 40000, 53300, 80000
};
static int RANGE_TO_REG( int range )
{
int i;
- if( range >= lm85_range_map[15] ) { return 15 ; }
- for( i = 0 ; i < 15 ; ++i )
- if( range <= lm85_range_map[i] )
- break ;
+ if ( range < lm85_range_map[0] ) {
+ return 0 ;
+ } else if ( range > lm85_range_map[15] ) {
+ return 15 ;
+ } else { /* find closest match */
+ for ( i = 14 ; i >= 0 ; --i ) {
+ if ( range > lm85_range_map[i] ) { /* range bracketed */
+ if ((lm85_range_map[i+1] - range) <
+ (range - lm85_range_map[i])) {
+ i++;
+ break;
+ }
+ break;
+ }
+ }
+ }
return( i & 0x0f );
}
#define RANGE_FROM_REG(val) (lm85_range_map[(val)&0x0f])
* MSB (bit 3, value 8). If the enable bit is 0, the encoded value
* is ignored, or set to 0.
*/
-static int lm85_smooth_map[] = { /* .1 sec */
- 350, 176, 118, 70, 44, 30, 16, 8
-/* 35.4 * 1/1, 1/2, 1/3, 1/5, 1/8, 1/12, 1/24, 1/48 */
- };
-static int SMOOTH_TO_REG( int smooth )
-{
- int i;
-
- if( smooth <= 0 ) { return 0 ; } /* Disabled */
- for( i = 0 ; i < 7 ; ++i )
- if( smooth >= lm85_smooth_map[i] )
- break ;
- return( (i & 0x07) | 0x08 );
-}
-#define SMOOTH_FROM_REG(val) ((val)&0x08?lm85_smooth_map[(val)&0x07]:0)
-
-/* These are the fan spinup delay time encodings */
-static int lm85_spinup_map[] = { /* .1 sec */
- 0, 1, 2, 4, 7, 10, 20, 40
- };
-static int SPINUP_TO_REG( int spinup )
-{
- int i;
-
- if( spinup >= lm85_spinup_map[7] ) { return 7 ; }
- for( i = 0 ; i < 7 ; ++i )
- if( spinup <= lm85_spinup_map[i] )
- break ;
- return( i & 0x07 );
-}
-#define SPINUP_FROM_REG(val) (lm85_spinup_map[(val)&0x07])
-
/* These are the PWM frequency encodings */
static int lm85_freq_map[] = { /* .1 Hz */
- 100, 150, 230, 300, 380, 470, 620, 980
+ 100, 150, 230, 300, 380, 470, 620, 940
};
static int FREQ_TO_REG( int freq )
{
* -2 -- PWM responds to manual control
*/
-#endif /* Extended functionality */
-
static int lm85_zone_map[] = { 1, 2, 3, -1, 0, 23, 123, -2 };
#define ZONE_FROM_REG(val) (lm85_zone_map[((val)>>5)&0x07])
-#ifdef LM85EXTENDEDFUNC /* Extended functionality */
-
static int ZONE_TO_REG( int zone )
{
int i;
return( (i & 0x07)<<5 );
}
-#endif /* Extended functionality */
-
-#define HYST_TO_REG(val) (SENSORS_LIMIT((-(val)+5)/10,0,15))
-#define HYST_FROM_REG(val) (-(val)*10)
+#define HYST_TO_REG(val) (SENSORS_LIMIT(((val)+500)/1000,0,15))
+#define HYST_FROM_REG(val) ((val)*1000)
#define OFFSET_TO_REG(val) (SENSORS_LIMIT((val)/25,-127,127))
#define OFFSET_FROM_REG(val) ((val)*25)
u8 hyst; /* Low limit hysteresis. (0-15) */
u8 range; /* Temp range, encoded */
s8 critical; /* "All fans ON" temp limit */
+ u8 off_desired; /* Actual "off" temperature specified. Preserved
+ * to prevent "drift" as other autofan control
+ * values change.
+ */
+ u8 max_desired; /* Actual "max" temperature specified. Preserved
+ * to prevent "drift" as other autofan control
+ * values change.
+ */
};
struct lm85_autofan {
unsigned long last_reading; /* In jiffies */
unsigned long last_config; /* In jiffies */
- u8 in[5]; /* Register value */
- u8 in_max[5]; /* Register value */
- u8 in_min[5]; /* Register value */
+ u8 in[8]; /* Register value */
+ u8 in_max[8]; /* Register value */
+ u8 in_min[8]; /* Register value */
s8 temp[3]; /* Register value */
s8 temp_min[3]; /* Register value */
s8 temp_max[3]; /* Register value */
u16 tmin_ctl; /* Register value */
unsigned long therm_total; /* Cummulative therm count */
u8 therm_limit; /* Register value */
- u16 alarms; /* Register encoding, combined */
+ u32 alarms; /* Register encoding, combined */
struct lm85_autofan autofan[3];
struct lm85_zone zone[3];
};
};
/* Unique ID assigned to each LM85 detected */
-static int lm85_id = 0;
+static int lm85_id;
/* 4 Fans */
#define show_fan_offset(offset) \
static ssize_t show_fan_##offset (struct device *dev, char *buf) \
{ \
- return show_fan(dev, buf, 0x##offset - 1); \
+ return show_fan(dev, buf, offset - 1); \
} \
static ssize_t show_fan_##offset##_min (struct device *dev, char *buf) \
{ \
- return show_fan_min(dev, buf, 0x##offset - 1); \
+ return show_fan_min(dev, buf, offset - 1); \
} \
static ssize_t set_fan_##offset##_min (struct device *dev, \
const char *buf, size_t count) \
{ \
- return set_fan_min(dev, buf, count, 0x##offset - 1); \
+ return set_fan_min(dev, buf, count, offset - 1); \
} \
-static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, NULL);\
+static DEVICE_ATTR(fan##offset##_input, S_IRUGO, show_fan_##offset, \
+ NULL); \
static DEVICE_ATTR(fan##offset##_min, S_IRUGO | S_IWUSR, \
show_fan_##offset##_min, set_fan_##offset##_min);
#define show_pwm_reg(offset) \
static ssize_t show_pwm_##offset (struct device *dev, char *buf) \
{ \
- return show_pwm(dev, buf, 0x##offset - 1); \
+ return show_pwm(dev, buf, offset - 1); \
} \
static ssize_t set_pwm_##offset (struct device *dev, \
const char *buf, size_t count) \
{ \
- return set_pwm(dev, buf, count, 0x##offset - 1); \
+ return set_pwm(dev, buf, count, offset - 1); \
} \
static ssize_t show_pwm_enable##offset (struct device *dev, char *buf) \
{ \
- return show_pwm_enable(dev, buf, 0x##offset - 1); \
+ return show_pwm_enable(dev, buf, offset - 1); \
} \
-static DEVICE_ATTR(fan##offset##_pwm, S_IRUGO | S_IWUSR, \
+static DEVICE_ATTR(pwm##offset, S_IRUGO | S_IWUSR, \
show_pwm_##offset, set_pwm_##offset); \
-static DEVICE_ATTR(fan##offset##_pwm_enable, S_IRUGO, show_pwm_enable##offset, NULL);
+static DEVICE_ATTR(pwm##offset##_enable, S_IRUGO, \
+ show_pwm_enable##offset, NULL);
show_pwm_reg(1);
show_pwm_reg(2);
#define show_in_reg(offset) \
static ssize_t show_in_##offset (struct device *dev, char *buf) \
{ \
- return show_in(dev, buf, 0x##offset); \
+ return show_in(dev, buf, offset); \
} \
static ssize_t show_in_##offset##_min (struct device *dev, char *buf) \
{ \
- return show_in_min(dev, buf, 0x##offset); \
+ return show_in_min(dev, buf, offset); \
} \
static ssize_t show_in_##offset##_max (struct device *dev, char *buf) \
{ \
- return show_in_max(dev, buf, 0x##offset); \
+ return show_in_max(dev, buf, offset); \
} \
static ssize_t set_in_##offset##_min (struct device *dev, \
const char *buf, size_t count) \
{ \
- return set_in_min(dev, buf, count, 0x##offset); \
+ return set_in_min(dev, buf, count, offset); \
} \
static ssize_t set_in_##offset##_max (struct device *dev, \
const char *buf, size_t count) \
{ \
- return set_in_max(dev, buf, count, 0x##offset); \
+ return set_in_max(dev, buf, count, offset); \
} \
-static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in_##offset, NULL); \
+static DEVICE_ATTR(in##offset##_input, S_IRUGO, show_in_##offset, \
+ NULL); \
static DEVICE_ATTR(in##offset##_min, S_IRUGO | S_IWUSR, \
show_in_##offset##_min, set_in_##offset##_min); \
static DEVICE_ATTR(in##offset##_max, S_IRUGO | S_IWUSR, \
#define show_temp_reg(offset) \
static ssize_t show_temp_##offset (struct device *dev, char *buf) \
{ \
- return show_temp(dev, buf, 0x##offset - 1); \
+ return show_temp(dev, buf, offset - 1); \
} \
static ssize_t show_temp_##offset##_min (struct device *dev, char *buf) \
{ \
- return show_temp_min(dev, buf, 0x##offset - 1); \
+ return show_temp_min(dev, buf, offset - 1); \
} \
static ssize_t show_temp_##offset##_max (struct device *dev, char *buf) \
{ \
- return show_temp_max(dev, buf, 0x##offset - 1); \
+ return show_temp_max(dev, buf, offset - 1); \
} \
static ssize_t set_temp_##offset##_min (struct device *dev, \
const char *buf, size_t count) \
{ \
- return set_temp_min(dev, buf, count, 0x##offset - 1); \
+ return set_temp_min(dev, buf, count, offset - 1); \
} \
static ssize_t set_temp_##offset##_max (struct device *dev, \
const char *buf, size_t count) \
{ \
- return set_temp_max(dev, buf, count, 0x##offset - 1); \
+ return set_temp_max(dev, buf, count, offset - 1); \
} \
-static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, NULL); \
+static DEVICE_ATTR(temp##offset##_input, S_IRUGO, show_temp_##offset, \
+ NULL); \
static DEVICE_ATTR(temp##offset##_min, S_IRUGO | S_IWUSR, \
show_temp_##offset##_min, set_temp_##offset##_min); \
static DEVICE_ATTR(temp##offset##_max, S_IRUGO | S_IWUSR, \
show_temp_reg(3);
+/* Automatic PWM control */
+
+static ssize_t show_pwm_auto_channels(struct device *dev, char *buf, int nr)
+{
+ struct lm85_data *data = lm85_update_device(dev);
+ return sprintf(buf,"%d\n", ZONE_FROM_REG(data->autofan[nr].config));
+}
+static ssize_t set_pwm_auto_channels(struct device *dev, const char *buf,
+ size_t count, int nr)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct lm85_data *data = i2c_get_clientdata(client);
+ int val;
+
+ down(&data->update_lock);
+ val = simple_strtol(buf, NULL, 10);
+ data->autofan[nr].config = (data->autofan[nr].config & (~0xe0))
+ | ZONE_TO_REG(val) ;
+ lm85_write_value(client, LM85_REG_AFAN_CONFIG(nr),
+ data->autofan[nr].config);
+ up(&data->update_lock);
+ return count;
+}
+static ssize_t show_pwm_auto_pwm_min(struct device *dev, char *buf, int nr)
+{
+ struct lm85_data *data = lm85_update_device(dev);
+ return sprintf(buf,"%d\n", PWM_FROM_REG(data->autofan[nr].min_pwm));
+}
+static ssize_t set_pwm_auto_pwm_min(struct device *dev, const char *buf,
+ size_t count, int nr)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct lm85_data *data = i2c_get_clientdata(client);
+ int val;
+
+ down(&data->update_lock);
+ val = simple_strtol(buf, NULL, 10);
+ data->autofan[nr].min_pwm = PWM_TO_REG(val);
+ lm85_write_value(client, LM85_REG_AFAN_MINPWM(nr),
+ data->autofan[nr].min_pwm);
+ up(&data->update_lock);
+ return count;
+}
+static ssize_t show_pwm_auto_pwm_minctl(struct device *dev, char *buf, int nr)
+{
+ struct lm85_data *data = lm85_update_device(dev);
+ return sprintf(buf,"%d\n", data->autofan[nr].min_off);
+}
+static ssize_t set_pwm_auto_pwm_minctl(struct device *dev, const char *buf,
+ size_t count, int nr)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct lm85_data *data = i2c_get_clientdata(client);
+ int val;
+
+ down(&data->update_lock);
+ val = simple_strtol(buf, NULL, 10);
+ data->autofan[nr].min_off = val;
+ lm85_write_value(client, LM85_REG_AFAN_SPIKE1, data->smooth[0]
+ | data->syncpwm3
+ | (data->autofan[0].min_off ? 0x20 : 0)
+ | (data->autofan[1].min_off ? 0x40 : 0)
+ | (data->autofan[2].min_off ? 0x80 : 0)
+ );
+ up(&data->update_lock);
+ return count;
+}
+static ssize_t show_pwm_auto_pwm_freq(struct device *dev, char *buf, int nr)
+{
+ struct lm85_data *data = lm85_update_device(dev);
+ return sprintf(buf,"%d\n", FREQ_FROM_REG(data->autofan[nr].freq));
+}
+static ssize_t set_pwm_auto_pwm_freq(struct device *dev, const char *buf,
+ size_t count, int nr)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct lm85_data *data = i2c_get_clientdata(client);
+ int val;
+
+ down(&data->update_lock);
+ val = simple_strtol(buf, NULL, 10);
+ data->autofan[nr].freq = FREQ_TO_REG(val);
+ lm85_write_value(client, LM85_REG_AFAN_RANGE(nr),
+ (data->zone[nr].range << 4)
+ | data->autofan[nr].freq
+ );
+ up(&data->update_lock);
+ return count;
+}
+#define pwm_auto(offset) \
+static ssize_t show_pwm##offset##_auto_channels (struct device *dev, \
+ char *buf) \
+{ \
+ return show_pwm_auto_channels(dev, buf, offset - 1); \
+} \
+static ssize_t set_pwm##offset##_auto_channels (struct device *dev, \
+ const char *buf, size_t count) \
+{ \
+ return set_pwm_auto_channels(dev, buf, count, offset - 1); \
+} \
+static ssize_t show_pwm##offset##_auto_pwm_min (struct device *dev, \
+ char *buf) \
+{ \
+ return show_pwm_auto_pwm_min(dev, buf, offset - 1); \
+} \
+static ssize_t set_pwm##offset##_auto_pwm_min (struct device *dev, \
+ const char *buf, size_t count) \
+{ \
+ return set_pwm_auto_pwm_min(dev, buf, count, offset - 1); \
+} \
+static ssize_t show_pwm##offset##_auto_pwm_minctl (struct device *dev, \
+ char *buf) \
+{ \
+ return show_pwm_auto_pwm_minctl(dev, buf, offset - 1); \
+} \
+static ssize_t set_pwm##offset##_auto_pwm_minctl (struct device *dev, \
+ const char *buf, size_t count) \
+{ \
+ return set_pwm_auto_pwm_minctl(dev, buf, count, offset - 1); \
+} \
+static ssize_t show_pwm##offset##_auto_pwm_freq (struct device *dev, \
+ char *buf) \
+{ \
+ return show_pwm_auto_pwm_freq(dev, buf, offset - 1); \
+} \
+static ssize_t set_pwm##offset##_auto_pwm_freq(struct device *dev, \
+ const char *buf, size_t count) \
+{ \
+ return set_pwm_auto_pwm_freq(dev, buf, count, offset - 1); \
+} \
+static DEVICE_ATTR(pwm##offset##_auto_channels, S_IRUGO | S_IWUSR, \
+ show_pwm##offset##_auto_channels, \
+ set_pwm##offset##_auto_channels); \
+static DEVICE_ATTR(pwm##offset##_auto_pwm_min, S_IRUGO | S_IWUSR, \
+ show_pwm##offset##_auto_pwm_min, \
+ set_pwm##offset##_auto_pwm_min); \
+static DEVICE_ATTR(pwm##offset##_auto_pwm_minctl, S_IRUGO | S_IWUSR, \
+ show_pwm##offset##_auto_pwm_minctl, \
+ set_pwm##offset##_auto_pwm_minctl); \
+static DEVICE_ATTR(pwm##offset##_auto_pwm_freq, S_IRUGO | S_IWUSR, \
+ show_pwm##offset##_auto_pwm_freq, \
+ set_pwm##offset##_auto_pwm_freq);
+pwm_auto(1);
+pwm_auto(2);
+pwm_auto(3);
+
+/* Temperature settings for automatic PWM control */
+
+static ssize_t show_temp_auto_temp_off(struct device *dev, char *buf, int nr)
+{
+ struct lm85_data *data = lm85_update_device(dev);
+ return sprintf(buf,"%d\n", TEMP_FROM_REG(data->zone[nr].limit) -
+ HYST_FROM_REG(data->zone[nr].hyst));
+}
+static ssize_t set_temp_auto_temp_off(struct device *dev, const char *buf,
+ size_t count, int nr)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct lm85_data *data = i2c_get_clientdata(client);
+ int min, val;
+
+ down(&data->update_lock);
+ val = simple_strtol(buf, NULL, 10);
+ min = TEMP_FROM_REG(data->zone[nr].limit);
+ data->zone[nr].off_desired = TEMP_TO_REG(val);
+ data->zone[nr].hyst = HYST_TO_REG(min - val);
+ if ( nr == 0 || nr == 1 ) {
+ lm85_write_value(client, LM85_REG_AFAN_HYST1,
+ (data->zone[0].hyst << 4)
+ | data->zone[1].hyst
+ );
+ } else {
+ lm85_write_value(client, LM85_REG_AFAN_HYST2,
+ (data->zone[2].hyst << 4)
+ );
+ }
+ up(&data->update_lock);
+ return count;
+}
+static ssize_t show_temp_auto_temp_min(struct device *dev, char *buf, int nr)
+{
+ struct lm85_data *data = lm85_update_device(dev);
+ return sprintf(buf,"%d\n", TEMP_FROM_REG(data->zone[nr].limit) );
+}
+static ssize_t set_temp_auto_temp_min(struct device *dev, const char *buf,
+ size_t count, int nr)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct lm85_data *data = i2c_get_clientdata(client);
+ int val;
+
+ down(&data->update_lock);
+ val = simple_strtol(buf, NULL, 10);
+ data->zone[nr].limit = TEMP_TO_REG(val);
+ lm85_write_value(client, LM85_REG_AFAN_LIMIT(nr),
+ data->zone[nr].limit);
+
+/* Update temp_auto_max and temp_auto_range */
+ data->zone[nr].range = RANGE_TO_REG(
+ TEMP_FROM_REG(data->zone[nr].max_desired) -
+ TEMP_FROM_REG(data->zone[nr].limit));
+ lm85_write_value(client, LM85_REG_AFAN_RANGE(nr),
+ ((data->zone[nr].range & 0x0f) << 4)
+ | (data->autofan[nr].freq & 0x07));
+
+/* Update temp_auto_hyst and temp_auto_off */
+ data->zone[nr].hyst = HYST_TO_REG(TEMP_FROM_REG(
+ data->zone[nr].limit) - TEMP_FROM_REG(
+ data->zone[nr].off_desired));
+ if ( nr == 0 || nr == 1 ) {
+ lm85_write_value(client, LM85_REG_AFAN_HYST1,
+ (data->zone[0].hyst << 4)
+ | data->zone[1].hyst
+ );
+ } else {
+ lm85_write_value(client, LM85_REG_AFAN_HYST2,
+ (data->zone[2].hyst << 4)
+ );
+ }
+ up(&data->update_lock);
+ return count;
+}
+static ssize_t show_temp_auto_temp_max(struct device *dev, char *buf, int nr)
+{
+ struct lm85_data *data = lm85_update_device(dev);
+ return sprintf(buf,"%d\n", TEMP_FROM_REG(data->zone[nr].limit) +
+ RANGE_FROM_REG(data->zone[nr].range));
+}
+static ssize_t set_temp_auto_temp_max(struct device *dev, const char *buf,
+ size_t count, int nr)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct lm85_data *data = i2c_get_clientdata(client);
+ int min, val;
+
+ down(&data->update_lock);
+ min = TEMP_FROM_REG(data->zone[nr].limit);
+ val = simple_strtol(buf, NULL, 10);
+ data->zone[nr].max_desired = TEMP_TO_REG(val);
+ data->zone[nr].range = RANGE_TO_REG(
+ val - min);
+ lm85_write_value(client, LM85_REG_AFAN_RANGE(nr),
+ ((data->zone[nr].range & 0x0f) << 4)
+ | (data->autofan[nr].freq & 0x07));
+ up(&data->update_lock);
+ return count;
+}
+static ssize_t show_temp_auto_temp_crit(struct device *dev, char *buf, int nr)
+{
+ struct lm85_data *data = lm85_update_device(dev);
+ return sprintf(buf,"%d\n", TEMP_FROM_REG(data->zone[nr].critical));
+}
+static ssize_t set_temp_auto_temp_crit(struct device *dev, const char *buf,
+ size_t count, int nr)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct lm85_data *data = i2c_get_clientdata(client);
+ int val;
+
+ down(&data->update_lock);
+ val = simple_strtol(buf, NULL, 10);
+ data->zone[nr].critical = TEMP_TO_REG(val);
+ lm85_write_value(client, LM85_REG_AFAN_CRITICAL(nr),
+ data->zone[nr].critical);
+ up(&data->update_lock);
+ return count;
+}
+#define temp_auto(offset) \
+static ssize_t show_temp##offset##_auto_temp_off (struct device *dev, \
+ char *buf) \
+{ \
+ return show_temp_auto_temp_off(dev, buf, offset - 1); \
+} \
+static ssize_t set_temp##offset##_auto_temp_off (struct device *dev, \
+ const char *buf, size_t count) \
+{ \
+ return set_temp_auto_temp_off(dev, buf, count, offset - 1); \
+} \
+static ssize_t show_temp##offset##_auto_temp_min (struct device *dev, \
+ char *buf) \
+{ \
+ return show_temp_auto_temp_min(dev, buf, offset - 1); \
+} \
+static ssize_t set_temp##offset##_auto_temp_min (struct device *dev, \
+ const char *buf, size_t count) \
+{ \
+ return set_temp_auto_temp_min(dev, buf, count, offset - 1); \
+} \
+static ssize_t show_temp##offset##_auto_temp_max (struct device *dev, \
+ char *buf) \
+{ \
+ return show_temp_auto_temp_max(dev, buf, offset - 1); \
+} \
+static ssize_t set_temp##offset##_auto_temp_max (struct device *dev, \
+ const char *buf, size_t count) \
+{ \
+ return set_temp_auto_temp_max(dev, buf, count, offset - 1); \
+} \
+static ssize_t show_temp##offset##_auto_temp_crit (struct device *dev, \
+ char *buf) \
+{ \
+ return show_temp_auto_temp_crit(dev, buf, offset - 1); \
+} \
+static ssize_t set_temp##offset##_auto_temp_crit (struct device *dev, \
+ const char *buf, size_t count) \
+{ \
+ return set_temp_auto_temp_crit(dev, buf, count, offset - 1); \
+} \
+static DEVICE_ATTR(temp##offset##_auto_temp_off, S_IRUGO | S_IWUSR, \
+ show_temp##offset##_auto_temp_off, \
+ set_temp##offset##_auto_temp_off); \
+static DEVICE_ATTR(temp##offset##_auto_temp_min, S_IRUGO | S_IWUSR, \
+ show_temp##offset##_auto_temp_min, \
+ set_temp##offset##_auto_temp_min); \
+static DEVICE_ATTR(temp##offset##_auto_temp_max, S_IRUGO | S_IWUSR, \
+ show_temp##offset##_auto_temp_max, \
+ set_temp##offset##_auto_temp_max); \
+static DEVICE_ATTR(temp##offset##_auto_temp_crit, S_IRUGO | S_IWUSR, \
+ show_temp##offset##_auto_temp_crit, \
+ set_temp##offset##_auto_temp_crit);
+temp_auto(1);
+temp_auto(2);
+temp_auto(3);
+
int lm85_attach_adapter(struct i2c_adapter *adapter)
{
+ if (!(adapter->class & I2C_CLASS_HWMON))
+ return 0;
return i2c_detect(adapter, &addr_data, lm85_detect);
}
&& verstep == LM85_VERSTEP_LM85B ) {
kind = lm85b ;
} else if( company == LM85_COMPANY_NATIONAL
- && (verstep & 0xf0) == LM85_VERSTEP_GENERIC ) {
+ && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC ) {
dev_err(&adapter->dev, "Unrecognized version/stepping 0x%02x"
" Defaulting to LM85.\n", verstep);
kind = any_chip ;
&& verstep == LM85_VERSTEP_ADT7463 ) {
kind = adt7463 ;
} else if( company == LM85_COMPANY_ANALOG_DEV
- && (verstep & 0xf0) == LM85_VERSTEP_GENERIC ) {
+ && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC ) {
dev_err(&adapter->dev, "Unrecognized version/stepping 0x%02x"
- " Defaulting to ADM1027.\n", verstep);
- kind = adm1027 ;
- } else if( kind == 0 && (verstep & 0xf0) == 0x60) {
+ " Defaulting to Generic LM85.\n", verstep );
+ kind = any_chip ;
+ } else if( company == LM85_COMPANY_SMSC
+ && (verstep == LM85_VERSTEP_EMC6D100_A0
+ || verstep == LM85_VERSTEP_EMC6D100_A1) ) {
+ /* Unfortunately, we can't tell a '100 from a '101
+ * from the registers. Since a '101 is a '100
+ * in a package with fewer pins and therefore no
+ * 3.3V, 1.5V or 1.8V inputs, perhaps if those
+ * inputs read 0, then it's a '101.
+ */
+ kind = emc6d100 ;
+ } else if( company == LM85_COMPANY_SMSC
+ && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC) {
+ dev_err(&adapter->dev, "lm85: Detected SMSC chip\n");
+ dev_err(&adapter->dev, "lm85: Unrecognized version/stepping 0x%02x"
+ " Defaulting to Generic LM85.\n", verstep );
+ kind = any_chip ;
+ } else if( kind == any_chip
+ && (verstep & LM85_VERSTEP_VMASK) == LM85_VERSTEP_GENERIC) {
dev_err(&adapter->dev, "Generic LM85 Version 6 detected\n");
/* Leave kind as "any_chip" */
} else {
dev_dbg(&adapter->dev, "Autodetection failed\n");
/* Not an LM85 ... */
- if( kind == 0 ) { /* User used force=x,y */
+ if( kind == any_chip ) { /* User used force=x,y */
dev_err(&adapter->dev, "Generic LM85 Version 6 not"
" found at %d,0x%02x. Try force_lm85c.\n",
i2c_adapter_id(adapter), address );
type_name = "adm1027";
} else if ( kind == adt7463 ) {
type_name = "adt7463";
+ } else if ( kind == emc6d100){
+ type_name = "emc6d100";
}
strlcpy(new_client->name, type_name, I2C_NAME_SIZE);
device_create_file(&new_client->dev, &dev_attr_fan2_min);
device_create_file(&new_client->dev, &dev_attr_fan3_min);
device_create_file(&new_client->dev, &dev_attr_fan4_min);
- device_create_file(&new_client->dev, &dev_attr_fan1_pwm);
- device_create_file(&new_client->dev, &dev_attr_fan2_pwm);
- device_create_file(&new_client->dev, &dev_attr_fan3_pwm);
- device_create_file(&new_client->dev, &dev_attr_fan1_pwm_enable);
- device_create_file(&new_client->dev, &dev_attr_fan2_pwm_enable);
- device_create_file(&new_client->dev, &dev_attr_fan3_pwm_enable);
+ device_create_file(&new_client->dev, &dev_attr_pwm1);
+ device_create_file(&new_client->dev, &dev_attr_pwm2);
+ device_create_file(&new_client->dev, &dev_attr_pwm3);
+ device_create_file(&new_client->dev, &dev_attr_pwm1_enable);
+ device_create_file(&new_client->dev, &dev_attr_pwm2_enable);
+ device_create_file(&new_client->dev, &dev_attr_pwm3_enable);
device_create_file(&new_client->dev, &dev_attr_in0_input);
device_create_file(&new_client->dev, &dev_attr_in1_input);
device_create_file(&new_client->dev, &dev_attr_in2_input);
device_create_file(&new_client->dev, &dev_attr_vrm);
device_create_file(&new_client->dev, &dev_attr_cpu0_vid);
device_create_file(&new_client->dev, &dev_attr_alarms);
+ device_create_file(&new_client->dev, &dev_attr_pwm1_auto_channels);
+ device_create_file(&new_client->dev, &dev_attr_pwm2_auto_channels);
+ device_create_file(&new_client->dev, &dev_attr_pwm3_auto_channels);
+ device_create_file(&new_client->dev, &dev_attr_pwm1_auto_pwm_min);
+ device_create_file(&new_client->dev, &dev_attr_pwm2_auto_pwm_min);
+ device_create_file(&new_client->dev, &dev_attr_pwm3_auto_pwm_min);
+ device_create_file(&new_client->dev, &dev_attr_pwm1_auto_pwm_minctl);
+ device_create_file(&new_client->dev, &dev_attr_pwm2_auto_pwm_minctl);
+ device_create_file(&new_client->dev, &dev_attr_pwm3_auto_pwm_minctl);
+ device_create_file(&new_client->dev, &dev_attr_pwm1_auto_pwm_freq);
+ device_create_file(&new_client->dev, &dev_attr_pwm2_auto_pwm_freq);
+ device_create_file(&new_client->dev, &dev_attr_pwm3_auto_pwm_freq);
+ device_create_file(&new_client->dev, &dev_attr_temp1_auto_temp_off);
+ device_create_file(&new_client->dev, &dev_attr_temp2_auto_temp_off);
+ device_create_file(&new_client->dev, &dev_attr_temp3_auto_temp_off);
+ device_create_file(&new_client->dev, &dev_attr_temp1_auto_temp_min);
+ device_create_file(&new_client->dev, &dev_attr_temp2_auto_temp_min);
+ device_create_file(&new_client->dev, &dev_attr_temp3_auto_temp_min);
+ device_create_file(&new_client->dev, &dev_attr_temp1_auto_temp_max);
+ device_create_file(&new_client->dev, &dev_attr_temp2_auto_temp_max);
+ device_create_file(&new_client->dev, &dev_attr_temp3_auto_temp_max);
+ device_create_file(&new_client->dev, &dev_attr_temp1_auto_temp_crit);
+ device_create_file(&new_client->dev, &dev_attr_temp2_auto_temp_crit);
+ device_create_file(&new_client->dev, &dev_attr_temp3_auto_temp_crit);
return 0;
lm85_read_value(client, LM85_REG_PWM(i));
}
+ data->alarms = lm85_read_value(client, LM85_REG_ALARM1);
+
if ( data->type == adt7463 ) {
if( data->therm_total < ULONG_MAX - 256 ) {
data->therm_total +=
lm85_read_value(client, ADT7463_REG_THERM );
}
+ } else if ( data->type == emc6d100 ) {
+ /* Three more voltage sensors */
+ for (i = 5; i <= 7; ++i) {
+ data->in[i] =
+ lm85_read_value(client, EMC6D100_REG_IN(i));
+ }
+ /* More alarm bits */
+ data->alarms |=
+ lm85_read_value(client, EMC6D100_REG_ALARM3) << 16;
}
- data->alarms = lm85_read_value(client, LM85_REG_ALARM1);
-
data->last_reading = jiffies ;
}; /* last_reading */
lm85_read_value(client, LM85_REG_IN_MAX(i));
}
+ if ( data->type == emc6d100 ) {
+ for (i = 5; i <= 7; ++i) {
+ data->in_min[i] =
+ lm85_read_value(client, EMC6D100_REG_IN_MIN(i));
+ data->in_max[i] =
+ lm85_read_value(client, EMC6D100_REG_IN_MAX(i));
+ }
+ }
+
for (i = 0; i <= 3; ++i) {
data->fan_min[i] =
lm85_read_value(client, LM85_REG_FAN_MIN(i));
* post 2.7.0 CVS changes.
*/
MODULE_LICENSE("GPL");
-MODULE_AUTHOR("Philip Pokorny <ppokorny@penguincomputing.com>, Margit Schubert-While <margitsw@t-online.de>");
+MODULE_AUTHOR("Philip Pokorny <ppokorny@penguincomputing.com>, Margit Schubert-While <margitsw@t-online.de>, Justin Thiessen <jthiessen@penguincomputing.com");
MODULE_DESCRIPTION("LM85-B, LM85-C driver");
module_init(sm_lm85_init);