staticint lm25066_read_word_data(struct i2c_client *client, int page, int phase, int reg)
{ conststruct pmbus_driver_info *info = pmbus_get_driver_info(client); conststruct lm25066_data *data = to_lm25066_data(info); int ret;
switch (reg) { case PMBUS_VIRT_READ_VMON:
ret = pmbus_read_word_data(client, 0, 0xff, LM25066_READ_VAUX); if (ret < 0) break; /* Adjust returned value to match VIN coefficients */ switch (data->id) { case lm25056: /* VIN: 6.14 mV VAUX: 293 uV LSB */
ret = DIV_ROUND_CLOSEST(ret * 293, 6140); break; case lm25066: /* VIN: 4.54 mV VAUX: 283.2 uV LSB */
ret = DIV_ROUND_CLOSEST(ret * 2832, 45400); break; case lm5064: /* VIN: 4.53 mV VAUX: 700 uV LSB */
ret = DIV_ROUND_CLOSEST(ret * 70, 453); break; case lm5066: case lm5066i: /* VIN: 2.18 mV VAUX: 725 uV LSB */
ret = DIV_ROUND_CLOSEST(ret * 725, 2180); break;
} break; case PMBUS_READ_IIN:
ret = pmbus_read_word_data(client, 0, 0xff,
LM25066_MFR_READ_IIN); break; case PMBUS_READ_PIN:
ret = pmbus_read_word_data(client, 0, 0xff,
LM25066_MFR_READ_PIN); break; case PMBUS_IIN_OC_WARN_LIMIT:
ret = pmbus_read_word_data(client, 0, 0xff,
LM25066_MFR_IIN_OC_WARN_LIMIT); break; case PMBUS_PIN_OP_WARN_LIMIT:
ret = pmbus_read_word_data(client, 0, 0xff,
LM25066_MFR_PIN_OP_WARN_LIMIT); break; case PMBUS_VIRT_READ_VIN_AVG:
ret = pmbus_read_word_data(client, 0, 0xff,
LM25066_READ_AVG_VIN); break; case PMBUS_VIRT_READ_VOUT_AVG:
ret = pmbus_read_word_data(client, 0, 0xff,
LM25066_READ_AVG_VOUT); break; case PMBUS_VIRT_READ_IIN_AVG:
ret = pmbus_read_word_data(client, 0, 0xff,
LM25066_READ_AVG_IIN); break; case PMBUS_VIRT_READ_PIN_AVG:
ret = pmbus_read_word_data(client, 0, 0xff,
LM25066_READ_AVG_PIN); break; case PMBUS_VIRT_READ_PIN_MAX:
ret = pmbus_read_word_data(client, 0, 0xff,
LM25066_READ_PIN_PEAK); break; case PMBUS_VIRT_RESET_PIN_HISTORY:
ret = 0; break; case PMBUS_VIRT_SAMPLES:
ret = pmbus_read_byte_data(client, 0, LM25066_SAMPLES_FOR_AVG); if (ret < 0) break;
ret = 1 << ret; break; default:
ret = -ENODATA; break;
} return ret;
}
staticint lm25056_read_word_data(struct i2c_client *client, int page, int phase, int reg)
{ int ret;
switch (reg) { case PMBUS_VIRT_VMON_UV_WARN_LIMIT:
ret = pmbus_read_word_data(client, 0, 0xff,
LM25056_VAUX_UV_WARN_LIMIT); if (ret < 0) break; /* Adjust returned value to match VIN coefficients */
ret = DIV_ROUND_CLOSEST(ret * 293, 6140); break; case PMBUS_VIRT_VMON_OV_WARN_LIMIT:
ret = pmbus_read_word_data(client, 0, 0xff,
LM25056_VAUX_OV_WARN_LIMIT); if (ret < 0) break; /* Adjust returned value to match VIN coefficients */
ret = DIV_ROUND_CLOSEST(ret * 293, 6140); break; default:
ret = lm25066_read_word_data(client, page, phase, reg); break;
} return ret;
}
staticint lm25056_read_byte_data(struct i2c_client *client, int page, int reg)
{ int ret, s;
switch (reg) { case PMBUS_VIRT_STATUS_VMON:
ret = pmbus_read_byte_data(client, 0,
PMBUS_STATUS_MFR_SPECIFIC); if (ret < 0) break;
s = 0; if (ret & LM25056_MFR_STS_VAUX_UV_WARN)
s |= PB_VOLTAGE_UV_WARNING; if (ret & LM25056_MFR_STS_VAUX_OV_WARN)
s |= PB_VOLTAGE_OV_WARNING;
ret = s; break; default:
ret = -ENODATA; break;
} return ret;
}
staticint lm25066_write_word_data(struct i2c_client *client, int page, int reg,
u16 word)
{ conststruct pmbus_driver_info *info = pmbus_get_driver_info(client); conststruct lm25066_data *data = to_lm25066_data(info); int ret;
switch (reg) { case PMBUS_POUT_OP_FAULT_LIMIT: case PMBUS_POUT_OP_WARN_LIMIT: case PMBUS_VOUT_UV_WARN_LIMIT: case PMBUS_OT_FAULT_LIMIT: case PMBUS_OT_WARN_LIMIT: case PMBUS_IIN_OC_FAULT_LIMIT: case PMBUS_VIN_UV_WARN_LIMIT: case PMBUS_VIN_UV_FAULT_LIMIT: case PMBUS_VIN_OV_FAULT_LIMIT: case PMBUS_VIN_OV_WARN_LIMIT:
word = ((s16)word < 0) ? 0 : clamp_val(word, 0, data->rlimit);
ret = pmbus_write_word_data(client, 0, reg, word); break; case PMBUS_IIN_OC_WARN_LIMIT:
word = ((s16)word < 0) ? 0 : clamp_val(word, 0, data->rlimit);
ret = pmbus_write_word_data(client, 0,
LM25066_MFR_IIN_OC_WARN_LIMIT,
word); break; case PMBUS_PIN_OP_WARN_LIMIT:
word = ((s16)word < 0) ? 0 : clamp_val(word, 0, data->rlimit);
ret = pmbus_write_word_data(client, 0,
LM25066_MFR_PIN_OP_WARN_LIMIT,
word); break; case PMBUS_VIRT_VMON_UV_WARN_LIMIT: /* Adjust from VIN coefficients (for LM25056) */
word = DIV_ROUND_CLOSEST((int)word * 6140, 293);
word = ((s16)word < 0) ? 0 : clamp_val(word, 0, data->rlimit);
ret = pmbus_write_word_data(client, 0,
LM25056_VAUX_UV_WARN_LIMIT, word); break; case PMBUS_VIRT_VMON_OV_WARN_LIMIT: /* Adjust from VIN coefficients (for LM25056) */
word = DIV_ROUND_CLOSEST((int)word * 6140, 293);
word = ((s16)word < 0) ? 0 : clamp_val(word, 0, data->rlimit);
ret = pmbus_write_word_data(client, 0,
LM25056_VAUX_OV_WARN_LIMIT, word); break; case PMBUS_VIRT_RESET_PIN_HISTORY:
ret = pmbus_write_byte(client, 0, LM25066_CLEAR_PIN_PEAK); break; case PMBUS_VIRT_SAMPLES:
word = clamp_val(word, 1, LM25066_SAMPLES_FOR_AVG_MAX);
ret = pmbus_write_byte_data(client, 0, LM25066_SAMPLES_FOR_AVG,
ilog2(word)); break; default:
ret = -ENODATA; break;
} return ret;
}
/* * Values in the TI datasheets are normalized for a 1mOhm sense * resistor; assume that unless DT specifies a value explicitly.
*/ if (of_property_read_u32(client->dev.of_node, "shunt-resistor-micro-ohms", &shunt))
shunt = 1000;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.