|
@@ -1,6 +1,6 @@
|
|
/*
|
|
/*
|
|
Copyright (C) 2001-2004 Aurelien Jarno <aurelien@aurel32.net>
|
|
Copyright (C) 2001-2004 Aurelien Jarno <aurelien@aurel32.net>
|
|
- Ported to Linux 2.6 by Aurelien Jarno <aurelien@aurel32.net> with
|
|
|
|
|
|
+ Ported to Linux 2.6 by Aurelien Jarno <aurelien@aurel32.net> with
|
|
the help of Jean Delvare <khali@linux-fr.org>
|
|
the help of Jean Delvare <khali@linux-fr.org>
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
This program is free software; you can redistribute it and/or modify
|
|
@@ -41,13 +41,13 @@ MODULE_PARM_DESC(input_mode,
|
|
" 3 = two differential inputs\n");
|
|
" 3 = two differential inputs\n");
|
|
|
|
|
|
/* The PCF8591 control byte
|
|
/* The PCF8591 control byte
|
|
- 7 6 5 4 3 2 1 0
|
|
|
|
|
|
+ 7 6 5 4 3 2 1 0
|
|
| 0 |AOEF| AIP | 0 |AINC| AICH | */
|
|
| 0 |AOEF| AIP | 0 |AINC| AICH | */
|
|
|
|
|
|
/* Analog Output Enable Flag (analog output active if 1) */
|
|
/* Analog Output Enable Flag (analog output active if 1) */
|
|
#define PCF8591_CONTROL_AOEF 0x40
|
|
#define PCF8591_CONTROL_AOEF 0x40
|
|
-
|
|
|
|
-/* Analog Input Programming
|
|
|
|
|
|
+
|
|
|
|
+/* Analog Input Programming
|
|
0x00 = four single ended inputs
|
|
0x00 = four single ended inputs
|
|
0x10 = three differential inputs
|
|
0x10 = three differential inputs
|
|
0x20 = single ended and differential mixed
|
|
0x20 = single ended and differential mixed
|
|
@@ -58,7 +58,7 @@ MODULE_PARM_DESC(input_mode,
|
|
#define PCF8591_CONTROL_AINC 0x04
|
|
#define PCF8591_CONTROL_AINC 0x04
|
|
|
|
|
|
/* Channel selection
|
|
/* Channel selection
|
|
- 0x00 = channel 0
|
|
|
|
|
|
+ 0x00 = channel 0
|
|
0x01 = channel 1
|
|
0x01 = channel 1
|
|
0x02 = channel 2
|
|
0x02 = channel 2
|
|
0x03 = channel 3 */
|
|
0x03 = channel 3 */
|
|
@@ -114,7 +114,7 @@ static ssize_t set_out0_output(struct device *dev, struct device_attribute *attr
|
|
return -EINVAL;
|
|
return -EINVAL;
|
|
}
|
|
}
|
|
|
|
|
|
-static DEVICE_ATTR(out0_output, S_IWUSR | S_IRUGO,
|
|
|
|
|
|
+static DEVICE_ATTR(out0_output, S_IWUSR | S_IRUGO,
|
|
show_out0_ouput, set_out0_output);
|
|
show_out0_ouput, set_out0_output);
|
|
|
|
|
|
static ssize_t show_out0_enable(struct device *dev, struct device_attribute *attr, char *buf)
|
|
static ssize_t show_out0_enable(struct device *dev, struct device_attribute *attr, char *buf)
|
|
@@ -139,7 +139,7 @@ static ssize_t set_out0_enable(struct device *dev, struct device_attribute *attr
|
|
return count;
|
|
return count;
|
|
}
|
|
}
|
|
|
|
|
|
-static DEVICE_ATTR(out0_enable, S_IWUSR | S_IRUGO,
|
|
|
|
|
|
+static DEVICE_ATTR(out0_enable, S_IWUSR | S_IRUGO,
|
|
show_out0_enable, set_out0_enable);
|
|
show_out0_enable, set_out0_enable);
|
|
|
|
|
|
static struct attribute *pcf8591_attributes[] = {
|
|
static struct attribute *pcf8591_attributes[] = {
|
|
@@ -196,7 +196,7 @@ static int pcf8591_probe(struct i2c_client *client,
|
|
err = -ENOMEM;
|
|
err = -ENOMEM;
|
|
goto exit;
|
|
goto exit;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
i2c_set_clientdata(client, data);
|
|
i2c_set_clientdata(client, data);
|
|
mutex_init(&data->update_lock);
|
|
mutex_init(&data->update_lock);
|
|
|
|
|
|
@@ -249,8 +249,8 @@ static void pcf8591_init_client(struct i2c_client *client)
|
|
data->aout = PCF8591_INIT_AOUT;
|
|
data->aout = PCF8591_INIT_AOUT;
|
|
|
|
|
|
i2c_smbus_write_byte_data(client, data->control, data->aout);
|
|
i2c_smbus_write_byte_data(client, data->control, data->aout);
|
|
-
|
|
|
|
- /* The first byte transmitted contains the conversion code of the
|
|
|
|
|
|
+
|
|
|
|
+ /* The first byte transmitted contains the conversion code of the
|
|
previous read cycle. FLUSH IT! */
|
|
previous read cycle. FLUSH IT! */
|
|
i2c_smbus_read_byte(client);
|
|
i2c_smbus_read_byte(client);
|
|
}
|
|
}
|
|
@@ -267,8 +267,8 @@ static int pcf8591_read_channel(struct device *dev, int channel)
|
|
data->control = (data->control & ~PCF8591_CONTROL_AICH_MASK)
|
|
data->control = (data->control & ~PCF8591_CONTROL_AICH_MASK)
|
|
| channel;
|
|
| channel;
|
|
i2c_smbus_write_byte(client, data->control);
|
|
i2c_smbus_write_byte(client, data->control);
|
|
-
|
|
|
|
- /* The first byte transmitted contains the conversion code of
|
|
|
|
|
|
+
|
|
|
|
+ /* The first byte transmitted contains the conversion code of
|
|
the previous read cycle. FLUSH IT! */
|
|
the previous read cycle. FLUSH IT! */
|
|
i2c_smbus_read_byte(client);
|
|
i2c_smbus_read_byte(client);
|
|
}
|
|
}
|