···88 Datasheets:99 http://www.ti.com/lit/gpn/lm250561010 http://www.ti.com/lit/gpn/lm25056a1111+ * TI LM250631212+ Prefix: 'lm25063'1313+ Addresses scanned: -1414+ Datasheet:1515+ To be announced1116 * National Semiconductor LM250661217 Prefix: 'lm25066'1318 Addresses scanned: -···3732-----------38333934This driver supports hardware montoring for National Semiconductor / TI LM25056,4040-LM25066, LM5064, and LM5064 Power Management, Monitoring, Control, and3535+LM25063, LM25066, LM5064, and LM5066 Power Management, Monitoring, Control, and4136Protection ICs.42374338The driver is a client driver to the core PMBus driver. Please see···6964in1_average Average measured input voltage.7065in1_min Minimum input voltage.7166in1_max Maximum input voltage.6767+in1_crit Critical high input voltage (LM25063 only).6868+in1_lcrit Critical low input voltage (LM25063 only).7269in1_min_alarm Input voltage low alarm.7370in1_max_alarm Input voltage high alarm.7171+in1_lcrit_alarm Input voltage critical low alarm (LM25063 only).7272+in1_crit_alarm Input voltage critical high alarm. (LM25063 only).74737574in2_label "vmon"7675in2_input Measured voltage on VAUX pin···8980in3_average Average measured output voltage.9081in3_min Minimum output voltage.9182in3_min_alarm Output voltage low alarm.8383+in3_highest Historical minimum output voltage (LM25063 only).8484+in3_lowest Historical maximum output voltage (LM25063 only).92859386curr1_label "iin"9487curr1_input Measured input current.9588curr1_average Average measured input current.9689curr1_max Maximum input current.9090+curr1_crit Critical input current (LM25063 only).9791curr1_max_alarm Input current high alarm.9292+curr1_crit_alarm Input current critical high alarm (LM25063 only).98939994power1_label "pin"10095power1_input Measured input power.···10794power1_alarm Input power alarm10895power1_input_highest Historical maximum power.10996power1_reset_history Write any value to reset maximum power history.9797+9898+power2_label "pout". LM25063 only.9999+power2_input Measured output power.100100+power2_max Maximum output power limit.101101+power2_crit Critical output power limit.110102111103temp1_input Measured temperature.112104temp1_max Maximum temperature.
+82-9
drivers/hwmon/pmbus/lm25066.c
···11/*22- * Hardware monitoring driver for LM25056 / LM25066 / LM5064 / LM506622+ * Hardware monitoring driver for LM25056 / LM25063 / LM25066 / LM5064 / LM506633 *44 * Copyright (c) 2011 Ericsson AB.55 * Copyright (c) 2013 Guenter Roeck···2727#include <linux/i2c.h>2828#include "pmbus.h"29293030-enum chips { lm25056, lm25066, lm5064, lm5066 };3030+enum chips { lm25056, lm25063, lm25066, lm5064, lm5066 };31313232#define LM25066_READ_VAUX 0xd03333#define LM25066_MFR_READ_IIN 0xd1···5252#define LM25056_MFR_STS_VAUX_OV_WARN (1 << 1)5353#define LM25056_MFR_STS_VAUX_UV_WARN (1 << 0)54545555+/* LM25063 only */5656+5757+#define LM25063_READ_VOUT_MAX 0xe55858+#define LM25063_READ_VOUT_MIN 0xe65959+5560struct __coeff {5661 short m, b, R;5762};···6459#define PSC_CURRENT_IN_L (PSC_NUM_CLASSES)6560#define PSC_POWER_L (PSC_NUM_CLASSES + 1)66616767-static struct __coeff lm25066_coeff[4][PSC_NUM_CLASSES + 2] = {6262+static struct __coeff lm25066_coeff[5][PSC_NUM_CLASSES + 2] = {6863 [lm25056] = {6964 [PSC_VOLTAGE_IN] = {7065 .m = 16296,···119114 },120115 [PSC_TEMPERATURE] = {121116 .m = 16,117117+ },118118+ },119119+ [lm25063] = {120120+ [PSC_VOLTAGE_IN] = {121121+ .m = 16000,122122+ .R = -2,123123+ },124124+ [PSC_VOLTAGE_OUT] = {125125+ .m = 16000,126126+ .R = -2,127127+ },128128+ [PSC_CURRENT_IN] = {129129+ .m = 10000,130130+ .R = -2,131131+ },132132+ [PSC_CURRENT_IN_L] = {133133+ .m = 10000,134134+ .R = -2,135135+ },136136+ [PSC_POWER] = {137137+ .m = 5000,138138+ .R = -3,139139+ },140140+ [PSC_POWER_L] = {141141+ .m = 5000,142142+ .R = -3,143143+ },144144+ [PSC_TEMPERATURE] = {145145+ .m = 15596,146146+ .R = -3,122147 },123148 },124149 [lm5064] = {···213178214179struct lm25066_data {215180 int id;181181+ u16 rlimit; /* Maximum register value */216182 struct pmbus_driver_info info;217183};218184···235199 case lm25056:236200 /* VIN: 6.14 mV VAUX: 293 uV LSB */237201 ret = DIV_ROUND_CLOSEST(ret * 293, 6140);202202+ break;203203+ case lm25063:204204+ /* VIN: 6.25 mV VAUX: 200.0 uV LSB */205205+ ret = DIV_ROUND_CLOSEST(ret * 20, 625);238206 break;239207 case lm25066:240208 /* VIN: 4.54 mV VAUX: 283.2 uV LSB */···288248 break;289249 default:290250 ret = -ENODATA;251251+ break;252252+ }253253+ return ret;254254+}255255+256256+static int lm25063_read_word_data(struct i2c_client *client, int page, int reg)257257+{258258+ int ret;259259+260260+ switch (reg) {261261+ case PMBUS_VIRT_READ_VOUT_MAX:262262+ ret = pmbus_read_word_data(client, 0, LM25063_READ_VOUT_MAX);263263+ break;264264+ case PMBUS_VIRT_READ_VOUT_MIN:265265+ ret = pmbus_read_word_data(client, 0, LM25063_READ_VOUT_MIN);266266+ break;267267+ default:268268+ ret = lm25066_read_word_data(client, page, reg);291269 break;292270 }293271 return ret;···366308static int lm25066_write_word_data(struct i2c_client *client, int page, int reg,367309 u16 word)368310{311311+ const struct pmbus_driver_info *info = pmbus_get_driver_info(client);312312+ const struct lm25066_data *data = to_lm25066_data(info);369313 int ret;370314371315 switch (reg) {316316+ case PMBUS_POUT_OP_FAULT_LIMIT:317317+ case PMBUS_POUT_OP_WARN_LIMIT:372318 case PMBUS_VOUT_UV_WARN_LIMIT:373319 case PMBUS_OT_FAULT_LIMIT:374320 case PMBUS_OT_WARN_LIMIT:321321+ case PMBUS_IIN_OC_FAULT_LIMIT:375322 case PMBUS_VIN_UV_WARN_LIMIT:323323+ case PMBUS_VIN_UV_FAULT_LIMIT:324324+ case PMBUS_VIN_OV_FAULT_LIMIT:376325 case PMBUS_VIN_OV_WARN_LIMIT:377377- word = ((s16)word < 0) ? 0 : clamp_val(word, 0, 0x0fff);326326+ word = ((s16)word < 0) ? 0 : clamp_val(word, 0, data->rlimit);378327 ret = pmbus_write_word_data(client, 0, reg, word);379328 pmbus_clear_cache(client);380329 break;381330 case PMBUS_IIN_OC_WARN_LIMIT:382382- word = ((s16)word < 0) ? 0 : clamp_val(word, 0, 0x0fff);331331+ word = ((s16)word < 0) ? 0 : clamp_val(word, 0, data->rlimit);383332 ret = pmbus_write_word_data(client, 0,384333 LM25066_MFR_IIN_OC_WARN_LIMIT,385334 word);386335 pmbus_clear_cache(client);387336 break;388337 case PMBUS_PIN_OP_WARN_LIMIT:389389- word = ((s16)word < 0) ? 0 : clamp_val(word, 0, 0x0fff);338338+ word = ((s16)word < 0) ? 0 : clamp_val(word, 0, data->rlimit);390339 ret = pmbus_write_word_data(client, 0,391340 LM25066_MFR_PIN_OP_WARN_LIMIT,392341 word);···402337 case PMBUS_VIRT_VMON_UV_WARN_LIMIT:403338 /* Adjust from VIN coefficients (for LM25056) */404339 word = DIV_ROUND_CLOSEST((int)word * 6140, 293);405405- word = ((s16)word < 0) ? 0 : clamp_val(word, 0, 0x0fff);340340+ word = ((s16)word < 0) ? 0 : clamp_val(word, 0, data->rlimit);406341 ret = pmbus_write_word_data(client, 0,407342 LM25056_VAUX_UV_WARN_LIMIT, word);408343 pmbus_clear_cache(client);···410345 case PMBUS_VIRT_VMON_OV_WARN_LIMIT:411346 /* Adjust from VIN coefficients (for LM25056) */412347 word = DIV_ROUND_CLOSEST((int)word * 6140, 293);413413- word = ((s16)word < 0) ? 0 : clamp_val(word, 0, 0x0fff);348348+ word = ((s16)word < 0) ? 0 : clamp_val(word, 0, data->rlimit);414349 ret = pmbus_write_word_data(client, 0,415350 LM25056_VAUX_OV_WARN_LIMIT, word);416351 pmbus_clear_cache(client);···464399 info->func[0] |= PMBUS_HAVE_STATUS_VMON;465400 info->read_word_data = lm25056_read_word_data;466401 info->read_byte_data = lm25056_read_byte_data;402402+ data->rlimit = 0x0fff;403403+ } else if (data->id == lm25063) {404404+ info->func[0] |= PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT405405+ | PMBUS_HAVE_POUT;406406+ info->read_word_data = lm25063_read_word_data;407407+ data->rlimit = 0xffff;467408 } else {468409 info->func[0] |= PMBUS_HAVE_VOUT | PMBUS_HAVE_STATUS_VOUT;469410 info->read_word_data = lm25066_read_word_data;411411+ data->rlimit = 0x0fff;470412 }471413 info->write_word_data = lm25066_write_word_data;472414···504432505433static const struct i2c_device_id lm25066_id[] = {506434 {"lm25056", lm25056},435435+ {"lm25063", lm25063},507436 {"lm25066", lm25066},508437 {"lm5064", lm5064},509438 {"lm5066", lm5066},···526453module_i2c_driver(lm25066_driver);527454528455MODULE_AUTHOR("Guenter Roeck");529529-MODULE_DESCRIPTION("PMBus driver for LM25056/LM25066/LM5064/LM5066");456456+MODULE_DESCRIPTION("PMBus driver for LM25066 and compatible chips");530457MODULE_LICENSE("GPL");