Commit 592758b12f2e327bb5902dabd3d36b2e86049871

Authored by Sven Schuchmann
Committed by Guenter Roeck
1 parent 8b662f38e0

hwmon: (mcp3021) Add MCP3221 support

This Patch adds support for mcp3221 chip to the
mcp3021 driver.

Signed-off-by: Sven Schuchmann <schuchmann@schleissheimer.de>
Signed-off-by: Guenter Roeck <linux@roeck-us.net>

Showing 3 changed files with 37 additions and 14 deletions Side-by-side Diff

Documentation/hwmon/mcp3021
... ... @@ -5,19 +5,26 @@
5 5 * Microchip Technology MCP3021
6 6 Prefix: 'mcp3021'
7 7 Datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/21805a.pdf
  8 + * Microchip Technology MCP3221
  9 + Prefix: 'mcp3221'
  10 + Datasheet: http://ww1.microchip.com/downloads/en/DeviceDoc/21732c.pdf
8 11  
9   -Author: Mingkai Hu
  12 +Authors:
  13 + Mingkai Hu
  14 + Sven Schuchmann <schuchmann@schleissheimer.de>
10 15  
11 16 Description
12 17 -----------
13 18  
14   -This driver implements support for the Microchip Technology MCP3021 chip.
  19 +This driver implements support for the Microchip Technology MCP3021 and
  20 +MCP3221 chip.
15 21  
16 22 The Microchip Technology Inc. MCP3021 is a successive approximation A/D
17   -converter (ADC) with 10-bit resolution.
18   -This device provides one single-ended input with very low power consumption.
19   -Communication to the MCP3021 is performed using a 2-wire I2C compatible
20   -interface. Standard (100 kHz) and Fast (400 kHz) I2C modes are available.
21   -The default I2C device address is 0x4d (contact the Microchip factory for
22   -additional address options).
  23 +converter (ADC) with 10-bit resolution. The MCP3221 has 12-bit resolution.
  24 +
  25 +These devices provide one single-ended input with very low power consumption.
  26 +Communication to the MCP3021/MCP3221 is performed using a 2-wire I2C
  27 +compatible interface. Standard (100 kHz) and Fast (400 kHz) I2C modes are
  28 +available. The default I2C device address is 0x4d (contact the Microchip
  29 +factory for additional address options).
drivers/hwmon/Kconfig
... ... @@ -855,11 +855,12 @@
855 855 will be called max6650.
856 856  
857 857 config SENSORS_MCP3021
858   - tristate "Microchip MCP3021"
  858 + tristate "Microchip MCP3021 and compatibles"
859 859 depends on I2C
860 860 help
861   - If you say yes here you get support for the MCP3021 chip
862   - that is a A/D converter (ADC) with 10-bit resolution.
  861 + If you say yes here you get support for MCP3021 and MCP3221.
  862 + The MCP3021 is a A/D converter (ADC) with 10-bit and the MCP3221
  863 + with 12-bit resolution.
863 864  
864 865 This driver can also be built as a module. If so, the module
865 866 will be called mcp3021.
drivers/hwmon/mcp3021.c
1 1 /*
2   - * mcp3021.c - driver for the Microchip MCP3021 chip
  2 + * mcp3021.c - driver for Microchip MCP3021 and MCP3221
3 3 *
4 4 * Copyright (C) 2008-2009, 2012 Freescale Semiconductor, Inc.
5 5 * Author: Mingkai Hu <Mingkai.hu@freescale.com>
6 6  
7 7  
... ... @@ -35,9 +35,16 @@
35 35 #define MCP3021_OUTPUT_RES 10 /* 10-bit resolution */
36 36 #define MCP3021_OUTPUT_SCALE 4
37 37  
  38 +#define MCP3221_SAR_SHIFT 0
  39 +#define MCP3221_SAR_MASK 0xfff
  40 +#define MCP3221_OUTPUT_RES 12 /* 12-bit resolution */
  41 +#define MCP3221_OUTPUT_SCALE 1
  42 +
38 43 enum chips {
39   - mcp3021
  44 + mcp3021,
  45 + mcp3221
40 46 };
  47 +
41 48 /*
42 49 * Client data (each client gets its own)
43 50 */
... ... @@ -127,6 +134,13 @@
127 134 data->output_res = MCP3021_OUTPUT_RES;
128 135 data->output_scale = MCP3021_OUTPUT_SCALE;
129 136 break;
  137 +
  138 + case mcp3221:
  139 + data->sar_shift = MCP3221_SAR_SHIFT;
  140 + data->sar_mask = MCP3221_SAR_MASK;
  141 + data->output_res = MCP3221_OUTPUT_RES;
  142 + data->output_scale = MCP3221_OUTPUT_SCALE;
  143 + break;
130 144 }
131 145  
132 146 if (client->dev.platform_data) {
... ... @@ -165,6 +179,7 @@
165 179  
166 180 static const struct i2c_device_id mcp3021_id[] = {
167 181 { "mcp3021", mcp3021 },
  182 + { "mcp3221", mcp3221 },
168 183 { }
169 184 };
170 185 MODULE_DEVICE_TABLE(i2c, mcp3021_id);
... ... @@ -181,6 +196,6 @@
181 196 module_i2c_driver(mcp3021_driver);
182 197  
183 198 MODULE_AUTHOR("Mingkai Hu <Mingkai.hu@freescale.com>");
184   -MODULE_DESCRIPTION("Microchip MCP3021 driver");
  199 +MODULE_DESCRIPTION("Microchip MCP3021/MCP3221 driver");
185 200 MODULE_LICENSE("GPL");