Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

hwmon: (pmbus/lm25066) Add support for LM25063

Signed-off-by: Guenter Roeck <linux@roeck-us.net>

+101 -10
+19 -1
Documentation/hwmon/lm25066
··· 8 8 Datasheets: 9 9 http://www.ti.com/lit/gpn/lm25056 10 10 http://www.ti.com/lit/gpn/lm25056a 11 + * TI LM25063 12 + Prefix: 'lm25063' 13 + Addresses scanned: - 14 + Datasheet: 15 + To be announced 11 16 * National Semiconductor LM25066 12 17 Prefix: 'lm25066' 13 18 Addresses scanned: - ··· 37 32 ----------- 38 33 39 34 This driver supports hardware montoring for National Semiconductor / TI LM25056, 40 - LM25066, LM5064, and LM5064 Power Management, Monitoring, Control, and 35 + LM25063, LM25066, LM5064, and LM5066 Power Management, Monitoring, Control, and 41 36 Protection ICs. 42 37 43 38 The driver is a client driver to the core PMBus driver. Please see ··· 69 64 in1_average Average measured input voltage. 70 65 in1_min Minimum input voltage. 71 66 in1_max Maximum input voltage. 67 + in1_crit Critical high input voltage (LM25063 only). 68 + in1_lcrit Critical low input voltage (LM25063 only). 72 69 in1_min_alarm Input voltage low alarm. 73 70 in1_max_alarm Input voltage high alarm. 71 + in1_lcrit_alarm Input voltage critical low alarm (LM25063 only). 72 + in1_crit_alarm Input voltage critical high alarm. (LM25063 only). 74 73 75 74 in2_label "vmon" 76 75 in2_input Measured voltage on VAUX pin ··· 89 80 in3_average Average measured output voltage. 90 81 in3_min Minimum output voltage. 91 82 in3_min_alarm Output voltage low alarm. 83 + in3_highest Historical minimum output voltage (LM25063 only). 84 + in3_lowest Historical maximum output voltage (LM25063 only). 92 85 93 86 curr1_label "iin" 94 87 curr1_input Measured input current. 95 88 curr1_average Average measured input current. 96 89 curr1_max Maximum input current. 90 + curr1_crit Critical input current (LM25063 only). 97 91 curr1_max_alarm Input current high alarm. 92 + curr1_crit_alarm Input current critical high alarm (LM25063 only). 98 93 99 94 power1_label "pin" 100 95 power1_input Measured input power. ··· 107 94 power1_alarm Input power alarm 108 95 power1_input_highest Historical maximum power. 109 96 power1_reset_history Write any value to reset maximum power history. 97 + 98 + power2_label "pout". LM25063 only. 99 + power2_input Measured output power. 100 + power2_max Maximum output power limit. 101 + power2_crit Critical output power limit. 110 102 111 103 temp1_input Measured temperature. 112 104 temp1_max Maximum temperature.
+82 -9
drivers/hwmon/pmbus/lm25066.c
··· 1 1 /* 2 - * Hardware monitoring driver for LM25056 / LM25066 / LM5064 / LM5066 2 + * Hardware monitoring driver for LM25056 / LM25063 / LM25066 / LM5064 / LM5066 3 3 * 4 4 * Copyright (c) 2011 Ericsson AB. 5 5 * Copyright (c) 2013 Guenter Roeck ··· 27 27 #include <linux/i2c.h> 28 28 #include "pmbus.h" 29 29 30 - enum chips { lm25056, lm25066, lm5064, lm5066 }; 30 + enum chips { lm25056, lm25063, lm25066, lm5064, lm5066 }; 31 31 32 32 #define LM25066_READ_VAUX 0xd0 33 33 #define LM25066_MFR_READ_IIN 0xd1 ··· 52 52 #define LM25056_MFR_STS_VAUX_OV_WARN (1 << 1) 53 53 #define LM25056_MFR_STS_VAUX_UV_WARN (1 << 0) 54 54 55 + /* LM25063 only */ 56 + 57 + #define LM25063_READ_VOUT_MAX 0xe5 58 + #define LM25063_READ_VOUT_MIN 0xe6 59 + 55 60 struct __coeff { 56 61 short m, b, R; 57 62 }; ··· 64 59 #define PSC_CURRENT_IN_L (PSC_NUM_CLASSES) 65 60 #define PSC_POWER_L (PSC_NUM_CLASSES + 1) 66 61 67 - static struct __coeff lm25066_coeff[4][PSC_NUM_CLASSES + 2] = { 62 + static struct __coeff lm25066_coeff[5][PSC_NUM_CLASSES + 2] = { 68 63 [lm25056] = { 69 64 [PSC_VOLTAGE_IN] = { 70 65 .m = 16296, ··· 119 114 }, 120 115 [PSC_TEMPERATURE] = { 121 116 .m = 16, 117 + }, 118 + }, 119 + [lm25063] = { 120 + [PSC_VOLTAGE_IN] = { 121 + .m = 16000, 122 + .R = -2, 123 + }, 124 + [PSC_VOLTAGE_OUT] = { 125 + .m = 16000, 126 + .R = -2, 127 + }, 128 + [PSC_CURRENT_IN] = { 129 + .m = 10000, 130 + .R = -2, 131 + }, 132 + [PSC_CURRENT_IN_L] = { 133 + .m = 10000, 134 + .R = -2, 135 + }, 136 + [PSC_POWER] = { 137 + .m = 5000, 138 + .R = -3, 139 + }, 140 + [PSC_POWER_L] = { 141 + .m = 5000, 142 + .R = -3, 143 + }, 144 + [PSC_TEMPERATURE] = { 145 + .m = 15596, 146 + .R = -3, 122 147 }, 123 148 }, 124 149 [lm5064] = { ··· 213 178 214 179 struct lm25066_data { 215 180 int id; 181 + u16 rlimit; /* Maximum register value */ 216 182 struct pmbus_driver_info info; 217 183 }; 218 184 ··· 235 199 case lm25056: 236 200 /* VIN: 6.14 mV VAUX: 293 uV LSB */ 237 201 ret = DIV_ROUND_CLOSEST(ret * 293, 6140); 202 + break; 203 + case lm25063: 204 + /* VIN: 6.25 mV VAUX: 200.0 uV LSB */ 205 + ret = DIV_ROUND_CLOSEST(ret * 20, 625); 238 206 break; 239 207 case lm25066: 240 208 /* VIN: 4.54 mV VAUX: 283.2 uV LSB */ ··· 288 248 break; 289 249 default: 290 250 ret = -ENODATA; 251 + break; 252 + } 253 + return ret; 254 + } 255 + 256 + static int lm25063_read_word_data(struct i2c_client *client, int page, int reg) 257 + { 258 + int ret; 259 + 260 + switch (reg) { 261 + case PMBUS_VIRT_READ_VOUT_MAX: 262 + ret = pmbus_read_word_data(client, 0, LM25063_READ_VOUT_MAX); 263 + break; 264 + case PMBUS_VIRT_READ_VOUT_MIN: 265 + ret = pmbus_read_word_data(client, 0, LM25063_READ_VOUT_MIN); 266 + break; 267 + default: 268 + ret = lm25066_read_word_data(client, page, reg); 291 269 break; 292 270 } 293 271 return ret; ··· 366 308 static int lm25066_write_word_data(struct i2c_client *client, int page, int reg, 367 309 u16 word) 368 310 { 311 + const struct pmbus_driver_info *info = pmbus_get_driver_info(client); 312 + const struct lm25066_data *data = to_lm25066_data(info); 369 313 int ret; 370 314 371 315 switch (reg) { 316 + case PMBUS_POUT_OP_FAULT_LIMIT: 317 + case PMBUS_POUT_OP_WARN_LIMIT: 372 318 case PMBUS_VOUT_UV_WARN_LIMIT: 373 319 case PMBUS_OT_FAULT_LIMIT: 374 320 case PMBUS_OT_WARN_LIMIT: 321 + case PMBUS_IIN_OC_FAULT_LIMIT: 375 322 case PMBUS_VIN_UV_WARN_LIMIT: 323 + case PMBUS_VIN_UV_FAULT_LIMIT: 324 + case PMBUS_VIN_OV_FAULT_LIMIT: 376 325 case PMBUS_VIN_OV_WARN_LIMIT: 377 - word = ((s16)word < 0) ? 0 : clamp_val(word, 0, 0x0fff); 326 + word = ((s16)word < 0) ? 0 : clamp_val(word, 0, data->rlimit); 378 327 ret = pmbus_write_word_data(client, 0, reg, word); 379 328 pmbus_clear_cache(client); 380 329 break; 381 330 case PMBUS_IIN_OC_WARN_LIMIT: 382 - word = ((s16)word < 0) ? 0 : clamp_val(word, 0, 0x0fff); 331 + word = ((s16)word < 0) ? 0 : clamp_val(word, 0, data->rlimit); 383 332 ret = pmbus_write_word_data(client, 0, 384 333 LM25066_MFR_IIN_OC_WARN_LIMIT, 385 334 word); 386 335 pmbus_clear_cache(client); 387 336 break; 388 337 case PMBUS_PIN_OP_WARN_LIMIT: 389 - word = ((s16)word < 0) ? 0 : clamp_val(word, 0, 0x0fff); 338 + word = ((s16)word < 0) ? 0 : clamp_val(word, 0, data->rlimit); 390 339 ret = pmbus_write_word_data(client, 0, 391 340 LM25066_MFR_PIN_OP_WARN_LIMIT, 392 341 word); ··· 402 337 case PMBUS_VIRT_VMON_UV_WARN_LIMIT: 403 338 /* Adjust from VIN coefficients (for LM25056) */ 404 339 word = DIV_ROUND_CLOSEST((int)word * 6140, 293); 405 - word = ((s16)word < 0) ? 0 : clamp_val(word, 0, 0x0fff); 340 + word = ((s16)word < 0) ? 0 : clamp_val(word, 0, data->rlimit); 406 341 ret = pmbus_write_word_data(client, 0, 407 342 LM25056_VAUX_UV_WARN_LIMIT, word); 408 343 pmbus_clear_cache(client); ··· 410 345 case PMBUS_VIRT_VMON_OV_WARN_LIMIT: 411 346 /* Adjust from VIN coefficients (for LM25056) */ 412 347 word = DIV_ROUND_CLOSEST((int)word * 6140, 293); 413 - word = ((s16)word < 0) ? 0 : clamp_val(word, 0, 0x0fff); 348 + word = ((s16)word < 0) ? 0 : clamp_val(word, 0, data->rlimit); 414 349 ret = pmbus_write_word_data(client, 0, 415 350 LM25056_VAUX_OV_WARN_LIMIT, word); 416 351 pmbus_clear_cache(client); ··· 464 399 info->func[0] |= PMBUS_HAVE_STATUS_VMON; 465 400 info->read_word_data = lm25056_read_word_data; 466 401 info->read_byte_data = lm25056_read_byte_data; 402 + data->rlimit = 0x0fff; 403 + } else if (data->id == lm25063) { 404 + info->func[0] |= PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT 405 + | PMBUS_HAVE_POUT; 406 + info->read_word_data = lm25063_read_word_data; 407 + data->rlimit = 0xffff; 467 408 } else { 468 409 info->func[0] |= PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT; 469 410 info->read_word_data = lm25066_read_word_data; 411 + data->rlimit = 0x0fff; 470 412 } 471 413 info->write_word_data = lm25066_write_word_data; 472 414 ··· 504 432 505 433 static const struct i2c_device_id lm25066_id[] = { 506 434 {"lm25056", lm25056}, 435 + {"lm25063", lm25063}, 507 436 {"lm25066", lm25066}, 508 437 {"lm5064", lm5064}, 509 438 {"lm5066", lm5066}, ··· 526 453 module_i2c_driver(lm25066_driver); 527 454 528 455 MODULE_AUTHOR("Guenter Roeck"); 529 - MODULE_DESCRIPTION("PMBus driver for LM25056/LM25066/LM5064/LM5066"); 456 + MODULE_DESCRIPTION("PMBus driver for LM25066 and compatible chips"); 530 457 MODULE_LICENSE("GPL");