Skip to contentSkip to conversation

hwmon: add support for MCP3204/3208

RFC PATCH In review Paul Fertser 2 participants 5 messages Oct 31, 2011 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

RFC PATCH 1/1 hwmon: add support for MCP3204/3208

Add support for these simple low-power cheap ADC ICs.

---

Well, adc*_in and adc_diff*_in are not mentioned in the sysfs-attributes.txt but at least the max1111 uses the former. Waiting for your feedback.

 drivers/hwmon/Kconfig   |   12 +++
 drivers/hwmon/Makefile  |    1 +
 drivers/hwmon/mcp3208.c |  254 +++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 267 insertions(+), 0 deletions(-)
 create mode 100644 drivers/hwmon/mcp3208.c
drivers/hwmon/Kconfig +12 -0
index 0b62c3c..48ac1ab 100644
@@ -787,6 +787,18 @@ config SENSORS_MAX6650
 	  This driver can also be built as a module.  If so, the module
 	  will be called max6650.
 
+config SENSORS_MCP3208
+	tristate "Microchip MCP3204/3208 Multichannel, Serial 12-bit ADC chip"
+	depends on SPI_MASTER
+	help
+	  Say y here to support Microchips's MCP3204/3208 ADC chips.
+
+	  Since MCP3204 has only half the channels, use only adc[0-3]_in and
+	  adc_diff[0-1]_in with it.
+
+	  This driver can also be built as a module.  If so, the module
+	  will be called mcp3208.
+
 config SENSORS_NTC_THERMISTOR
 	tristate "NTC thermistor support"
 	depends on EXPERIMENTAL
drivers/hwmon/Makefile +1 -0
index 3c9ccef..847f6af 100644
@@ -93,6 +93,7 @@ obj-$(CONFIG_SENSORS_MAX6639)	+= max6639.o
 obj-$(CONFIG_SENSORS_MAX6642)	+= max6642.o
 obj-$(CONFIG_SENSORS_MAX6650)	+= max6650.o
 obj-$(CONFIG_SENSORS_MC13783_ADC)+= mc13783-adc.o
+obj-$(CONFIG_SENSORS_MCP3208)	+= mcp3208.o
 obj-$(CONFIG_SENSORS_NTC_THERMISTOR)	+= ntc_thermistor.o
 obj-$(CONFIG_SENSORS_PC87360)	+= pc87360.o
 obj-$(CONFIG_SENSORS_PC87427)	+= pc87427.o
drivers/hwmon/mcp3208.c new file +254 -0

254 lines not on this page · raw message

Signature · 7 lines
1.7.2.3


_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#1 lore raw
Quoted 6 lines · Paul Fertser

Add support for these simple low-power cheap ADC ICs.

---

Well, adc*_in and adc_diff*_in are not mentioned in the sysfs-attributes.txt

Indeed, and this alone means a bold NACK without even reviewing your code. Sticking to Documentation/hwmon/sysfs-attributes is mandatory.

Quoted 1 line

but at least the max1111 uses the former. Waiting for your feedback.

Thanks for pointing this out. I don't know how it managed to sneak in, but it shouldn't have. I'll ask the driver author to align with the standard interface quickly, otherwise we'll have to delete the driver altogether.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#2 lore raw
In reply to Paul Fertser
Quoted 6 lines · Jean Delvare
Quoted 1 line

but at least the max1111 uses the former. Waiting for your feedback.

Thanks for pointing this out. I don't know how it managed to sneak in, but it shouldn't have. I'll ask the driver author to align with the standard interface quickly, otherwise we'll have to delete the driver altogether.

What do you propose to use for raw ADC data then? How should i proceed?

Signature · 7 lines
Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software!
mailto:[email protected]

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#3 lore raw
In reply to Paul Fertser

Hi Paul,

Quoted 10 lines · Paul Fertser
Quoted 6 lines · Jean Delvare
Quoted 1 line

but at least the max1111 uses the former. Waiting for your feedback.

Thanks for pointing this out. I don't know how it managed to sneak in, but it shouldn't have. I'll ask the driver author to align with the standard interface quickly, otherwise we'll have to delete the driver altogether.

What do you propose to use for raw ADC data then? How should i proceed?

Raw ADC data isn't supposed to be exported by hardware monitoring drivers in the first place. If you need to do this, then hwmon is the wrong place. Look at iio instead, maybe it allows this (not even sure). hwmon drivers expose voltage values to user-space in mV, always. If the LSB weight depends on the platform somehow, you may be able to pass it as platform data to the I2C slave device, so that the driver can scale properly.

Signature · 6 lines
Jean Delvare

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors
#4 lore raw
In reply to Paul Fertser
Quoted 3 lines · Jean Delvare

If the LSB weight depends on the platform somehow, you may be able to pass it as platform data to the I2C slave device, so that the driver can scale properly.

Sure, will rework the driver accordingly. Thanks for the fast response!

Signature · 7 lines
Be free, use free (http://www.gnu.org/philosophy/free-sw.html) software!
mailto:[email protected]

_______________________________________________
lm-sensors mailing list
[email protected]
http://lists.lm-sensors.org/mailman/listinfo/lm-sensors