Skip to contentSkip to conversation

max1236-9 ADC support

PATCH In review Jonathan Cameron 2 participants 2 messages May 5, 2008 Hardware monitoring

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 max1236-9 ADC support

Initial support for Maxim MAX1236, MAX1237, MAX1238 and MAX1239 ADCs.

---

The max123x chips are 4 / 12 input 12-bit ADCs.
I'm not sure Hardware Monitoring is the correct place to put this in the kernel, but it seemed the most appropriate as you already have one straight ADC and the particular board I have with one of these on is using it for power monitoring.

All comments / feedback welcomed as I am still fairly new to driver writing.

 Kconfig   |   10 +
 Makefile  |    1
 max123x.c |  449 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 460 insertions(+)

--

drivers/hwmon/Kconfig +10 -0
@@ -489,6 +489,16 @@ config SENSORS_LM93
 	  This driver can also be built as a module.  If so, the module
 	  will be called lm93.
 
+config SENSORS_MAX123X
+       tristate "Maxim MAX1236 - MAX1239 ADC chips"
+       depends on I2C && EXPERIMENTAL
+       help 
+         If you say yes here you get support for the MAX1236 and MAX1237
+	 4 input ADC chips and the MAX1238 and MAX1239 12 input ADC chips.
+
+	 This driver can also be built as a module. If so, the module
+	 will be called max123x.
+
 config SENSORS_MAX1619
 	tristate "Maxim MAX1619 sensor chip"
 	depends on I2C
drivers/hwmon/Makefile +1 -0
@@ -56,6 +56,7 @@ obj-$(CONFIG_SENSORS_LM87)	+= lm87.o
 obj-$(CONFIG_SENSORS_LM90)	+= lm90.o
 obj-$(CONFIG_SENSORS_LM92)	+= lm92.o
 obj-$(CONFIG_SENSORS_LM93)	+= lm93.o
+obj-$(CONFIG_SENSORS_MAX123X)   += max123x.o
 obj-$(CONFIG_SENSORS_MAX1619)	+= max1619.o
 obj-$(CONFIG_SENSORS_MAX6650)	+= max6650.o
 obj-$(CONFIG_SENSORS_PC87360)	+= pc87360.o
drivers/hwmon/max123x.c +449 -0

449 lines not on this page · raw message

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

#1 lore raw

drivers/hwmon/max123x.c line 46

Quoted 3 lines · Jonathan Cameron
drivers/hwmon/max123x.c +3 -0
+/* The max123x registers */
+#define MAX123X_SETUP_BYTE(a)     0x80 | a
+#define MAX123X_CONF_BYTE(a)      0x00 | a

Avoid defining macros like this. Should be:

#define MAX123X_SETUP_BYTE(a)     (0x80 | (a))
#define MAX123X_CONF_BYTE(a)      (0x00 | (a)) /* what is the point to OR it with 0x00??? */

For example MAX123X_SETUP_BYTE(0x02 & 0x03) & 0x01 in your case will be expanded as:
0x80 | 0x02 & 0x03 & 0x01 = 0x80
in my case:
(0x80 | (0x02 & 0x03)) & 0x01 = 0x00

As you can see the result will be totally different!

Regards,
Paulius Zaleckas

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