diff options
Diffstat (limited to 'drivers/hwmon/pmbus')
-rw-r--r-- | drivers/hwmon/pmbus/lm25066.c | 12 | ||||
-rw-r--r-- | drivers/hwmon/pmbus/pmbus.h | 1 | ||||
-rw-r--r-- | drivers/hwmon/pmbus/pmbus_core.c | 29 | ||||
-rw-r--r-- | drivers/hwmon/pmbus/ucd9000.c | 6 | ||||
-rw-r--r-- | drivers/hwmon/pmbus/ucd9200.c | 6 |
5 files changed, 44 insertions, 10 deletions
diff --git a/drivers/hwmon/pmbus/lm25066.c b/drivers/hwmon/pmbus/lm25066.c index d4bc114572de..ac254fba551b 100644 --- a/drivers/hwmon/pmbus/lm25066.c +++ b/drivers/hwmon/pmbus/lm25066.c | |||
@@ -161,6 +161,17 @@ static int lm25066_write_word_data(struct i2c_client *client, int page, int reg, | |||
161 | return ret; | 161 | return ret; |
162 | } | 162 | } |
163 | 163 | ||
164 | static int lm25066_write_byte(struct i2c_client *client, int page, u8 value) | ||
165 | { | ||
166 | if (page > 1) | ||
167 | return -EINVAL; | ||
168 | |||
169 | if (page == 0) | ||
170 | return pmbus_write_byte(client, 0, value); | ||
171 | |||
172 | return 0; | ||
173 | } | ||
174 | |||
164 | static int lm25066_probe(struct i2c_client *client, | 175 | static int lm25066_probe(struct i2c_client *client, |
165 | const struct i2c_device_id *id) | 176 | const struct i2c_device_id *id) |
166 | { | 177 | { |
@@ -204,6 +215,7 @@ static int lm25066_probe(struct i2c_client *client, | |||
204 | 215 | ||
205 | info->read_word_data = lm25066_read_word_data; | 216 | info->read_word_data = lm25066_read_word_data; |
206 | info->write_word_data = lm25066_write_word_data; | 217 | info->write_word_data = lm25066_write_word_data; |
218 | info->write_byte = lm25066_write_byte; | ||
207 | 219 | ||
208 | switch (id->driver_data) { | 220 | switch (id->driver_data) { |
209 | case lm25066: | 221 | case lm25066: |
diff --git a/drivers/hwmon/pmbus/pmbus.h b/drivers/hwmon/pmbus/pmbus.h index 0808d986d75b..a6ae20ffef6b 100644 --- a/drivers/hwmon/pmbus/pmbus.h +++ b/drivers/hwmon/pmbus/pmbus.h | |||
@@ -325,6 +325,7 @@ struct pmbus_driver_info { | |||
325 | int (*read_word_data)(struct i2c_client *client, int page, int reg); | 325 | int (*read_word_data)(struct i2c_client *client, int page, int reg); |
326 | int (*write_word_data)(struct i2c_client *client, int page, int reg, | 326 | int (*write_word_data)(struct i2c_client *client, int page, int reg, |
327 | u16 word); | 327 | u16 word); |
328 | int (*write_byte)(struct i2c_client *client, int page, u8 value); | ||
328 | /* | 329 | /* |
329 | * The identify function determines supported PMBus functionality. | 330 | * The identify function determines supported PMBus functionality. |
330 | * This function is only necessary if a chip driver supports multiple | 331 | * This function is only necessary if a chip driver supports multiple |
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index 5c1b6cf31701..397fc59b5682 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c | |||
@@ -182,6 +182,24 @@ int pmbus_write_byte(struct i2c_client *client, int page, u8 value) | |||
182 | } | 182 | } |
183 | EXPORT_SYMBOL_GPL(pmbus_write_byte); | 183 | EXPORT_SYMBOL_GPL(pmbus_write_byte); |
184 | 184 | ||
185 | /* | ||
186 | * _pmbus_write_byte() is similar to pmbus_write_byte(), but checks if | ||
187 | * a device specific mapping funcion exists and calls it if necessary. | ||
188 | */ | ||
189 | static int _pmbus_write_byte(struct i2c_client *client, int page, u8 value) | ||
190 | { | ||
191 | struct pmbus_data *data = i2c_get_clientdata(client); | ||
192 | const struct pmbus_driver_info *info = data->info; | ||
193 | int status; | ||
194 | |||
195 | if (info->write_byte) { | ||
196 | status = info->write_byte(client, page, value); | ||
197 | if (status != -ENODATA) | ||
198 | return status; | ||
199 | } | ||
200 | return pmbus_write_byte(client, page, value); | ||
201 | } | ||
202 | |||
185 | int pmbus_write_word_data(struct i2c_client *client, u8 page, u8 reg, u16 word) | 203 | int pmbus_write_word_data(struct i2c_client *client, u8 page, u8 reg, u16 word) |
186 | { | 204 | { |
187 | int rv; | 205 | int rv; |
@@ -281,7 +299,7 @@ static int _pmbus_read_byte_data(struct i2c_client *client, int page, int reg) | |||
281 | 299 | ||
282 | static void pmbus_clear_fault_page(struct i2c_client *client, int page) | 300 | static void pmbus_clear_fault_page(struct i2c_client *client, int page) |
283 | { | 301 | { |
284 | pmbus_write_byte(client, page, PMBUS_CLEAR_FAULTS); | 302 | _pmbus_write_byte(client, page, PMBUS_CLEAR_FAULTS); |
285 | } | 303 | } |
286 | 304 | ||
287 | void pmbus_clear_faults(struct i2c_client *client) | 305 | void pmbus_clear_faults(struct i2c_client *client) |
@@ -960,6 +978,8 @@ static void pmbus_find_max_attr(struct i2c_client *client, | |||
960 | struct pmbus_limit_attr { | 978 | struct pmbus_limit_attr { |
961 | u16 reg; /* Limit register */ | 979 | u16 reg; /* Limit register */ |
962 | bool update; /* True if register needs updates */ | 980 | bool update; /* True if register needs updates */ |
981 | bool low; /* True if low limit; for limits with compare | ||
982 | functions only */ | ||
963 | const char *attr; /* Attribute name */ | 983 | const char *attr; /* Attribute name */ |
964 | const char *alarm; /* Alarm attribute name */ | 984 | const char *alarm; /* Alarm attribute name */ |
965 | u32 sbit; /* Alarm attribute status bit */ | 985 | u32 sbit; /* Alarm attribute status bit */ |
@@ -1011,7 +1031,8 @@ static bool pmbus_add_limit_attrs(struct i2c_client *client, | |||
1011 | if (attr->compare) { | 1031 | if (attr->compare) { |
1012 | pmbus_add_boolean_cmp(data, name, | 1032 | pmbus_add_boolean_cmp(data, name, |
1013 | l->alarm, index, | 1033 | l->alarm, index, |
1014 | cbase, cindex, | 1034 | l->low ? cindex : cbase, |
1035 | l->low ? cbase : cindex, | ||
1015 | attr->sbase + page, l->sbit); | 1036 | attr->sbase + page, l->sbit); |
1016 | } else { | 1037 | } else { |
1017 | pmbus_add_boolean_reg(data, name, | 1038 | pmbus_add_boolean_reg(data, name, |
@@ -1348,11 +1369,13 @@ static const struct pmbus_sensor_attr power_attributes[] = { | |||
1348 | static const struct pmbus_limit_attr temp_limit_attrs[] = { | 1369 | static const struct pmbus_limit_attr temp_limit_attrs[] = { |
1349 | { | 1370 | { |
1350 | .reg = PMBUS_UT_WARN_LIMIT, | 1371 | .reg = PMBUS_UT_WARN_LIMIT, |
1372 | .low = true, | ||
1351 | .attr = "min", | 1373 | .attr = "min", |
1352 | .alarm = "min_alarm", | 1374 | .alarm = "min_alarm", |
1353 | .sbit = PB_TEMP_UT_WARNING, | 1375 | .sbit = PB_TEMP_UT_WARNING, |
1354 | }, { | 1376 | }, { |
1355 | .reg = PMBUS_UT_FAULT_LIMIT, | 1377 | .reg = PMBUS_UT_FAULT_LIMIT, |
1378 | .low = true, | ||
1356 | .attr = "lcrit", | 1379 | .attr = "lcrit", |
1357 | .alarm = "lcrit_alarm", | 1380 | .alarm = "lcrit_alarm", |
1358 | .sbit = PB_TEMP_UT_FAULT, | 1381 | .sbit = PB_TEMP_UT_FAULT, |
@@ -1381,11 +1404,13 @@ static const struct pmbus_limit_attr temp_limit_attrs[] = { | |||
1381 | static const struct pmbus_limit_attr temp_limit_attrs23[] = { | 1404 | static const struct pmbus_limit_attr temp_limit_attrs23[] = { |
1382 | { | 1405 | { |
1383 | .reg = PMBUS_UT_WARN_LIMIT, | 1406 | .reg = PMBUS_UT_WARN_LIMIT, |
1407 | .low = true, | ||
1384 | .attr = "min", | 1408 | .attr = "min", |
1385 | .alarm = "min_alarm", | 1409 | .alarm = "min_alarm", |
1386 | .sbit = PB_TEMP_UT_WARNING, | 1410 | .sbit = PB_TEMP_UT_WARNING, |
1387 | }, { | 1411 | }, { |
1388 | .reg = PMBUS_UT_FAULT_LIMIT, | 1412 | .reg = PMBUS_UT_FAULT_LIMIT, |
1413 | .low = true, | ||
1389 | .attr = "lcrit", | 1414 | .attr = "lcrit", |
1390 | .alarm = "lcrit_alarm", | 1415 | .alarm = "lcrit_alarm", |
1391 | .sbit = PB_TEMP_UT_FAULT, | 1416 | .sbit = PB_TEMP_UT_FAULT, |
diff --git a/drivers/hwmon/pmbus/ucd9000.c b/drivers/hwmon/pmbus/ucd9000.c index ace1c7319734..d0ddb60155c9 100644 --- a/drivers/hwmon/pmbus/ucd9000.c +++ b/drivers/hwmon/pmbus/ucd9000.c | |||
@@ -141,13 +141,11 @@ static int ucd9000_probe(struct i2c_client *client, | |||
141 | block_buffer[ret] = '\0'; | 141 | block_buffer[ret] = '\0'; |
142 | dev_info(&client->dev, "Device ID %s\n", block_buffer); | 142 | dev_info(&client->dev, "Device ID %s\n", block_buffer); |
143 | 143 | ||
144 | mid = NULL; | 144 | for (mid = ucd9000_id; mid->name[0]; mid++) { |
145 | for (i = 0; i < ARRAY_SIZE(ucd9000_id); i++) { | ||
146 | mid = &ucd9000_id[i]; | ||
147 | if (!strncasecmp(mid->name, block_buffer, strlen(mid->name))) | 145 | if (!strncasecmp(mid->name, block_buffer, strlen(mid->name))) |
148 | break; | 146 | break; |
149 | } | 147 | } |
150 | if (!mid || !strlen(mid->name)) { | 148 | if (!mid->name[0]) { |
151 | dev_err(&client->dev, "Unsupported device\n"); | 149 | dev_err(&client->dev, "Unsupported device\n"); |
152 | return -ENODEV; | 150 | return -ENODEV; |
153 | } | 151 | } |
diff --git a/drivers/hwmon/pmbus/ucd9200.c b/drivers/hwmon/pmbus/ucd9200.c index ffcc1cf3609d..c65e9da707cc 100644 --- a/drivers/hwmon/pmbus/ucd9200.c +++ b/drivers/hwmon/pmbus/ucd9200.c | |||
@@ -68,13 +68,11 @@ static int ucd9200_probe(struct i2c_client *client, | |||
68 | block_buffer[ret] = '\0'; | 68 | block_buffer[ret] = '\0'; |
69 | dev_info(&client->dev, "Device ID %s\n", block_buffer); | 69 | dev_info(&client->dev, "Device ID %s\n", block_buffer); |
70 | 70 | ||
71 | mid = NULL; | 71 | for (mid = ucd9200_id; mid->name[0]; mid++) { |
72 | for (i = 0; i < ARRAY_SIZE(ucd9200_id); i++) { | ||
73 | mid = &ucd9200_id[i]; | ||
74 | if (!strncasecmp(mid->name, block_buffer, strlen(mid->name))) | 72 | if (!strncasecmp(mid->name, block_buffer, strlen(mid->name))) |
75 | break; | 73 | break; |
76 | } | 74 | } |
77 | if (!mid || !strlen(mid->name)) { | 75 | if (!mid->name[0]) { |
78 | dev_err(&client->dev, "Unsupported device\n"); | 76 | dev_err(&client->dev, "Unsupported device\n"); |
79 | return -ENODEV; | 77 | return -ENODEV; |
80 | } | 78 | } |