aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorSven Schuchmann <schuchmann@schleissheimer.de>2012-09-21 07:04:22 -0400
committerGuenter Roeck <linux@roeck-us.net>2012-09-24 00:08:36 -0400
commit592758b12f2e327bb5902dabd3d36b2e86049871 (patch)
treea6dfcb123de6fb8b09b394a28d0f5d66e2387e6c /drivers/hwmon
parent8b662f38e066d8fc1b73a8655da547c348206904 (diff)
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>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/Kconfig7
-rw-r--r--drivers/hwmon/mcp3021.c21
2 files changed, 22 insertions, 6 deletions
diff --git a/drivers/hwmon/Kconfig b/drivers/hwmon/Kconfig
index 6bc49cfb9f7b..c74e73b2069a 100644
--- a/drivers/hwmon/Kconfig
+++ b/drivers/hwmon/Kconfig
@@ -855,11 +855,12 @@ config SENSORS_MAX6650
855 will be called max6650. 855 will be called max6650.
856 856
857config SENSORS_MCP3021 857config SENSORS_MCP3021
858 tristate "Microchip MCP3021" 858 tristate "Microchip MCP3021 and compatibles"
859 depends on I2C 859 depends on I2C
860 help 860 help
861 If you say yes here you get support for the MCP3021 chip 861 If you say yes here you get support for MCP3021 and MCP3221.
862 that is a A/D converter (ADC) with 10-bit resolution. 862 The MCP3021 is a A/D converter (ADC) with 10-bit and the MCP3221
863 with 12-bit resolution.
863 864
864 This driver can also be built as a module. If so, the module 865 This driver can also be built as a module. If so, the module
865 will be called mcp3021. 866 will be called mcp3021.
diff --git a/drivers/hwmon/mcp3021.c b/drivers/hwmon/mcp3021.c
index d700b9271174..eedb32292d6d 100644
--- a/drivers/hwmon/mcp3021.c
+++ b/drivers/hwmon/mcp3021.c
@@ -1,5 +1,5 @@
1/* 1/*
2 * mcp3021.c - driver for the Microchip MCP3021 chip 2 * mcp3021.c - driver for Microchip MCP3021 and MCP3221
3 * 3 *
4 * Copyright (C) 2008-2009, 2012 Freescale Semiconductor, Inc. 4 * Copyright (C) 2008-2009, 2012 Freescale Semiconductor, Inc.
5 * Author: Mingkai Hu <Mingkai.hu@freescale.com> 5 * Author: Mingkai Hu <Mingkai.hu@freescale.com>
@@ -35,9 +35,16 @@
35#define MCP3021_OUTPUT_RES 10 /* 10-bit resolution */ 35#define MCP3021_OUTPUT_RES 10 /* 10-bit resolution */
36#define MCP3021_OUTPUT_SCALE 4 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
38enum chips { 43enum chips {
39 mcp3021 44 mcp3021,
45 mcp3221
40}; 46};
47
41/* 48/*
42 * Client data (each client gets its own) 49 * Client data (each client gets its own)
43 */ 50 */
@@ -127,6 +134,13 @@ static int mcp3021_probe(struct i2c_client *client,
127 data->output_res = MCP3021_OUTPUT_RES; 134 data->output_res = MCP3021_OUTPUT_RES;
128 data->output_scale = MCP3021_OUTPUT_SCALE; 135 data->output_scale = MCP3021_OUTPUT_SCALE;
129 break; 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 if (client->dev.platform_data) { 146 if (client->dev.platform_data) {
@@ -165,6 +179,7 @@ static int mcp3021_remove(struct i2c_client *client)
165 179
166static const struct i2c_device_id mcp3021_id[] = { 180static const struct i2c_device_id mcp3021_id[] = {
167 { "mcp3021", mcp3021 }, 181 { "mcp3021", mcp3021 },
182 { "mcp3221", mcp3221 },
168 { } 183 { }
169}; 184};
170MODULE_DEVICE_TABLE(i2c, mcp3021_id); 185MODULE_DEVICE_TABLE(i2c, mcp3021_id);
@@ -181,5 +196,5 @@ static struct i2c_driver mcp3021_driver = {
181module_i2c_driver(mcp3021_driver); 196module_i2c_driver(mcp3021_driver);
182 197
183MODULE_AUTHOR("Mingkai Hu <Mingkai.hu@freescale.com>"); 198MODULE_AUTHOR("Mingkai Hu <Mingkai.hu@freescale.com>");
184MODULE_DESCRIPTION("Microchip MCP3021 driver"); 199MODULE_DESCRIPTION("Microchip MCP3021/MCP3221 driver");
185MODULE_LICENSE("GPL"); 200MODULE_LICENSE("GPL");