aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/hwmon/pmbus/pmbus.c
diff options
context:
space:
mode:
authorGuenter Roeck <guenter.roeck@ericsson.com>2011-06-25 14:21:49 -0400
committerGuenter Roeck <guenter.roeck@ericsson.com>2011-07-28 18:31:11 -0400
commit1061d8518f8bde548a03a5ff77dbe9a4202ad826 (patch)
treee5bd62c9c7d065c4acb249bc60e057b64023c32c /drivers/hwmon/pmbus/pmbus.c
parent9d2ecfb768bd2f8b41816a23b0f1dda026fef41d (diff)
hwmon: (pmbus) Add support for VID output voltage mode
In VID mode, output voltages are measured and reported as VID values, and have to be converted to voltages using VID conversion tables or functions. Support is added for VR11 only at this time. This patch enables support for PMBus devices supporting VID VR11 based output voltage selection such as NCP4200 and NCP4208. Signed-off-by: Guenter Roeck <guenter.roeck@ericsson.com> Reviewed-by: Robert Coulson <robert.coulson@ericsson.com>
Diffstat (limited to 'drivers/hwmon/pmbus/pmbus.c')
-rw-r--r--drivers/hwmon/pmbus/pmbus.c34
1 files changed, 31 insertions, 3 deletions
diff --git a/drivers/hwmon/pmbus/pmbus.c b/drivers/hwmon/pmbus/pmbus.c
index 9b1f0c37ef77..4d8e31bcd7a3 100644
--- a/drivers/hwmon/pmbus/pmbus.c
+++ b/drivers/hwmon/pmbus/pmbus.c
@@ -96,6 +96,8 @@ static void pmbus_find_sensor_groups(struct i2c_client *client,
96static int pmbus_identify(struct i2c_client *client, 96static int pmbus_identify(struct i2c_client *client,
97 struct pmbus_driver_info *info) 97 struct pmbus_driver_info *info)
98{ 98{
99 int ret = 0;
100
99 if (!info->pages) { 101 if (!info->pages) {
100 /* 102 /*
101 * Check if the PAGE command is supported. If it is, 103 * Check if the PAGE command is supported. If it is,
@@ -117,6 +119,27 @@ static int pmbus_identify(struct i2c_client *client,
117 } 119 }
118 } 120 }
119 121
122 if (pmbus_check_byte_register(client, 0, PMBUS_VOUT_MODE)) {
123 int vout_mode;
124
125 vout_mode = pmbus_read_byte_data(client, 0, PMBUS_VOUT_MODE);
126 if (vout_mode >= 0 && vout_mode != 0xff) {
127 switch (vout_mode >> 5) {
128 case 0:
129 break;
130 case 1:
131 info->format[PSC_VOLTAGE_OUT] = vid;
132 break;
133 case 2:
134 info->format[PSC_VOLTAGE_OUT] = direct;
135 break;
136 default:
137 ret = -ENODEV;
138 goto abort;
139 }
140 }
141 }
142
120 /* 143 /*
121 * We should check if the COEFFICIENTS register is supported. 144 * We should check if the COEFFICIENTS register is supported.
122 * If it is, and the chip is configured for direct mode, we can read 145 * If it is, and the chip is configured for direct mode, we can read
@@ -125,13 +148,18 @@ static int pmbus_identify(struct i2c_client *client,
125 * 148 *
126 * To do this, we will need access to a chip which actually supports the 149 * To do this, we will need access to a chip which actually supports the
127 * COEFFICIENTS command, since the command is too complex to implement 150 * COEFFICIENTS command, since the command is too complex to implement
128 * without testing it. 151 * without testing it. Until then, abort if a chip configured for direct
152 * mode was detected.
129 */ 153 */
154 if (info->format[PSC_VOLTAGE_OUT] == direct) {
155 ret = -ENODEV;
156 goto abort;
157 }
130 158
131 /* Try to find sensor groups */ 159 /* Try to find sensor groups */
132 pmbus_find_sensor_groups(client, info); 160 pmbus_find_sensor_groups(client, info);
133 161abort:
134 return 0; 162 return ret;
135} 163}
136 164
137static int pmbus_probe(struct i2c_client *client, 165static int pmbus_probe(struct i2c_client *client,