aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGuenter Roeck <guenter.roeck@ericsson.com>2011-07-14 14:55:35 -0400
committerGuenter Roeck <guenter.roeck@ericsson.com>2011-10-24 14:09:35 -0400
commit5cf231a346fb80d7945aa46e90186a068a3a001b (patch)
tree642f84017b93f745b72360b7b2d619ec2403224f
parentc5e6763667ffc94eaad4634841cb1b7ecd951fb7 (diff)
hwmon: (pmbus/adm1275) Add support for ADM1276
ADM1276 is mostly compatible to ADM1275, with added support for input power measurement. Add support for it to the ADM1275 driver. Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com> Acked-by: Jean Delvare <khali@linux-fr.org>
-rw-r--r--Documentation/hwmon/adm127532
-rw-r--r--drivers/hwmon/pmbus/Kconfig5
-rw-r--r--drivers/hwmon/pmbus/adm1275.c59
3 files changed, 72 insertions, 24 deletions
diff --git a/Documentation/hwmon/adm1275 b/Documentation/hwmon/adm1275
index c438c98bdbc8..ab70d96d2dfd 100644
--- a/Documentation/hwmon/adm1275
+++ b/Documentation/hwmon/adm1275
@@ -6,6 +6,10 @@ Supported chips:
6 Prefix: 'adm1275' 6 Prefix: 'adm1275'
7 Addresses scanned: - 7 Addresses scanned: -
8 Datasheet: www.analog.com/static/imported-files/data_sheets/ADM1275.pdf 8 Datasheet: www.analog.com/static/imported-files/data_sheets/ADM1275.pdf
9 * Analog Devices ADM1276
10 Prefix: 'adm1276'
11 Addresses scanned: -
12 Datasheet: www.analog.com/static/imported-files/data_sheets/ADM1276.pdf
9 13
10Author: Guenter Roeck <guenter.roeck@ericsson.com> 14Author: Guenter Roeck <guenter.roeck@ericsson.com>
11 15
@@ -13,13 +17,13 @@ Author: Guenter Roeck <guenter.roeck@ericsson.com>
13Description 17Description
14----------- 18-----------
15 19
16This driver supports hardware montoring for Analog Devices ADM1275 Hot-Swap 20This driver supports hardware montoring for Analog Devices ADM1275 and ADM1276
17Controller and Digital Power Monitor. 21Hot-Swap Controller and Digital Power Monitor.
18 22
19The ADM1275 is a hot-swap controller that allows a circuit board to be removed 23ADM1275 and ADM1276 are hot-swap controllers that allow a circuit board to be
20from or inserted into a live backplane. It also features current and voltage 24removed from or inserted into a live backplane. They also feature current and
21readback via an integrated 12-bit analog-to-digital converter (ADC), accessed 25voltage readback via an integrated 12-bit analog-to-digital converter (ADC),
22using a PMBus. interface. 26accessed using a PMBus interface.
23 27
24The driver is a client driver to the core PMBus driver. Please see 28The driver is a client driver to the core PMBus driver. Please see
25Documentation/hwmon/pmbus for details on PMBus client drivers. 29Documentation/hwmon/pmbus for details on PMBus client drivers.
@@ -48,18 +52,18 @@ attributes are write-only, all other attributes are read-only.
48 52
49in1_label "vin1" or "vout1" depending on chip variant and 53in1_label "vin1" or "vout1" depending on chip variant and
50 configuration. 54 configuration.
51in1_input Measured voltage. From READ_VOUT register. 55in1_input Measured voltage.
52in1_min Minumum Voltage. From VOUT_UV_WARN_LIMIT register. 56in1_min Minumum Voltage.
53in1_max Maximum voltage. From VOUT_OV_WARN_LIMIT register. 57in1_max Maximum voltage.
54in1_min_alarm Voltage low alarm. From VOLTAGE_UV_WARNING status. 58in1_min_alarm Voltage low alarm.
55in1_max_alarm Voltage high alarm. From VOLTAGE_OV_WARNING status. 59in1_max_alarm Voltage high alarm.
56in1_highest Historical maximum voltage. 60in1_highest Historical maximum voltage.
57in1_reset_history Write any value to reset history. 61in1_reset_history Write any value to reset history.
58 62
59curr1_label "iout1" 63curr1_label "iout1"
60curr1_input Measured current. From READ_IOUT register. 64curr1_input Measured current.
61curr1_max Maximum current. From IOUT_OC_WARN_LIMIT register. 65curr1_max Maximum current.
62curr1_max_alarm Current high alarm. From IOUT_OC_WARN_LIMIT register. 66curr1_max_alarm Current high alarm.
63curr1_lcrit Critical minimum current. Depending on the chip 67curr1_lcrit Critical minimum current. Depending on the chip
64 configuration, either curr1_lcrit or curr1_crit is 68 configuration, either curr1_lcrit or curr1_crit is
65 supported, but not both. 69 supported, but not both.
diff --git a/drivers/hwmon/pmbus/Kconfig b/drivers/hwmon/pmbus/Kconfig
index c9237b9dcff2..37575582e51a 100644
--- a/drivers/hwmon/pmbus/Kconfig
+++ b/drivers/hwmon/pmbus/Kconfig
@@ -26,11 +26,12 @@ config SENSORS_PMBUS
26 be called pmbus. 26 be called pmbus.
27 27
28config SENSORS_ADM1275 28config SENSORS_ADM1275
29 tristate "Analog Devices ADM1275" 29 tristate "Analog Devices ADM1275 and compatibles"
30 default n 30 default n
31 help 31 help
32 If you say yes here you get hardware monitoring support for Analog 32 If you say yes here you get hardware monitoring support for Analog
33 Devices ADM1275 Hot-Swap Controller and Digital Power Monitor. 33 Devices ADM1275 and ADM1276 Hot-Swap Controller and Digital Power
34 Monitor.
34 35
35 This driver can also be built as a module. If so, the module will 36 This driver can also be built as a module. If so, the module will
36 be called adm1275. 37 be called adm1275.
diff --git a/drivers/hwmon/pmbus/adm1275.c b/drivers/hwmon/pmbus/adm1275.c
index 7a9f2d9dbba4..fa1811274c27 100644
--- a/drivers/hwmon/pmbus/adm1275.c
+++ b/drivers/hwmon/pmbus/adm1275.c
@@ -23,6 +23,8 @@
23#include <linux/i2c.h> 23#include <linux/i2c.h>
24#include "pmbus.h" 24#include "pmbus.h"
25 25
26enum chips { adm1275, adm1276 };
27
26#define ADM1275_PEAK_IOUT 0xd0 28#define ADM1275_PEAK_IOUT 0xd0
27#define ADM1275_PEAK_VIN 0xd1 29#define ADM1275_PEAK_VIN 0xd1
28#define ADM1275_PEAK_VOUT 0xd2 30#define ADM1275_PEAK_VOUT 0xd2
@@ -36,9 +38,12 @@
36 38
37#define ADM1275_IOUT_WARN2_SELECT (1 << 4) 39#define ADM1275_IOUT_WARN2_SELECT (1 << 4)
38 40
41#define ADM1276_PEAK_PIN 0xda
42
39#define ADM1275_MFR_STATUS_IOUT_WARN2 (1 << 0) 43#define ADM1275_MFR_STATUS_IOUT_WARN2 (1 << 0)
40 44
41struct adm1275_data { 45struct adm1275_data {
46 int id;
42 bool have_oc_fault; 47 bool have_oc_fault;
43 struct pmbus_driver_info info; 48 struct pmbus_driver_info info;
44}; 49};
@@ -49,7 +54,7 @@ static int adm1275_read_word_data(struct i2c_client *client, int page, int reg)
49{ 54{
50 const struct pmbus_driver_info *info = pmbus_get_driver_info(client); 55 const struct pmbus_driver_info *info = pmbus_get_driver_info(client);
51 const struct adm1275_data *data = to_adm1275_data(info); 56 const struct adm1275_data *data = to_adm1275_data(info);
52 int ret; 57 int ret = 0;
53 58
54 if (page) 59 if (page)
55 return -ENXIO; 60 return -ENXIO;
@@ -78,10 +83,20 @@ static int adm1275_read_word_data(struct i2c_client *client, int page, int reg)
78 case PMBUS_VIRT_READ_VIN_MAX: 83 case PMBUS_VIRT_READ_VIN_MAX:
79 ret = pmbus_read_word_data(client, 0, ADM1275_PEAK_VIN); 84 ret = pmbus_read_word_data(client, 0, ADM1275_PEAK_VIN);
80 break; 85 break;
86 case PMBUS_VIRT_READ_PIN_MAX:
87 if (data->id != adm1276) {
88 ret = -ENXIO;
89 break;
90 }
91 ret = pmbus_read_word_data(client, 0, ADM1276_PEAK_PIN);
92 break;
81 case PMBUS_VIRT_RESET_IOUT_HISTORY: 93 case PMBUS_VIRT_RESET_IOUT_HISTORY:
82 case PMBUS_VIRT_RESET_VOUT_HISTORY: 94 case PMBUS_VIRT_RESET_VOUT_HISTORY:
83 case PMBUS_VIRT_RESET_VIN_HISTORY: 95 case PMBUS_VIRT_RESET_VIN_HISTORY:
84 ret = 0; 96 break;
97 case PMBUS_VIRT_RESET_PIN_HISTORY:
98 if (data->id != adm1276)
99 ret = -ENXIO;
85 break; 100 break;
86 default: 101 default:
87 ret = -ENODATA; 102 ret = -ENODATA;
@@ -113,6 +128,9 @@ static int adm1275_write_word_data(struct i2c_client *client, int page, int reg,
113 case PMBUS_VIRT_RESET_VIN_HISTORY: 128 case PMBUS_VIRT_RESET_VIN_HISTORY:
114 ret = pmbus_write_word_data(client, 0, ADM1275_PEAK_VIN, 0); 129 ret = pmbus_write_word_data(client, 0, ADM1275_PEAK_VIN, 0);
115 break; 130 break;
131 case PMBUS_VIRT_RESET_PIN_HISTORY:
132 ret = pmbus_write_word_data(client, 0, ADM1276_PEAK_PIN, 0);
133 break;
116 default: 134 default:
117 ret = -ENODATA; 135 ret = -ENODATA;
118 break; 136 break;
@@ -180,6 +198,7 @@ static int adm1275_probe(struct i2c_client *client,
180 goto err_mem; 198 goto err_mem;
181 } 199 }
182 200
201 data->id = id->driver_data;
183 info = &data->info; 202 info = &data->info;
184 203
185 info->pages = 1; 204 info->pages = 1;
@@ -214,10 +233,33 @@ static int adm1275_probe(struct i2c_client *client,
214 if (device_config & ADM1275_IOUT_WARN2_SELECT) 233 if (device_config & ADM1275_IOUT_WARN2_SELECT)
215 data->have_oc_fault = true; 234 data->have_oc_fault = true;
216 235
217 if (config & ADM1275_VIN_VOUT_SELECT) 236 switch (id->driver_data) {
218 info->func[0] |= PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT; 237 case adm1275:
219 else 238 if (config & ADM1275_VIN_VOUT_SELECT)
220 info->func[0] |= PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT; 239 info->func[0] |=
240 PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT;
241 else
242 info->func[0] |=
243 PMBUS_HAVE_VIN | PMBUS_HAVE_STATUS_INPUT;
244 break;
245 case adm1276:
246 info->format[PSC_POWER] = direct;
247 info->func[0] |= PMBUS_HAVE_VIN | PMBUS_HAVE_PIN
248 | PMBUS_HAVE_STATUS_INPUT;
249 if (config & ADM1275_VIN_VOUT_SELECT)
250 info->func[0] |=
251 PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT;
252 if (config & ADM1275_VRANGE) {
253 info->m[PSC_POWER] = 6043;
254 info->b[PSC_POWER] = 0;
255 info->R[PSC_POWER] = -2;
256 } else {
257 info->m[PSC_POWER] = 2115;
258 info->b[PSC_POWER] = 0;
259 info->R[PSC_POWER] = -1;
260 }
261 break;
262 }
221 263
222 ret = pmbus_do_probe(client, id, info); 264 ret = pmbus_do_probe(client, id, info);
223 if (ret) 265 if (ret)
@@ -240,7 +282,8 @@ static int adm1275_remove(struct i2c_client *client)
240} 282}
241 283
242static const struct i2c_device_id adm1275_id[] = { 284static const struct i2c_device_id adm1275_id[] = {
243 {"adm1275", 0}, 285 { "adm1275", adm1275 },
286 { "adm1276", adm1276 },
244 { } 287 { }
245}; 288};
246MODULE_DEVICE_TABLE(i2c, adm1275_id); 289MODULE_DEVICE_TABLE(i2c, adm1275_id);
@@ -265,7 +308,7 @@ static void __exit adm1275_exit(void)
265} 308}
266 309
267MODULE_AUTHOR("Guenter Roeck"); 310MODULE_AUTHOR("Guenter Roeck");
268MODULE_DESCRIPTION("PMBus driver for Analog Devices ADM1275"); 311MODULE_DESCRIPTION("PMBus driver for Analog Devices ADM1275 and compatibles");
269MODULE_LICENSE("GPL"); 312MODULE_LICENSE("GPL");
270module_init(adm1275_init); 313module_init(adm1275_init);
271module_exit(adm1275_exit); 314module_exit(adm1275_exit);