/* Return the voltage from the given register in mV or mA */ staticint ltc4222_get_value(struct device *dev, u8 reg)
{ struct regmap *regmap = dev_get_drvdata(dev); unsignedint val;
u8 buf[2]; int ret;
ret = regmap_bulk_read(regmap, reg, buf, 2); if (ret < 0) return ret;
val = ((buf[0] << 8) + buf[1]) >> 6;
switch (reg) { case LTC4222_ADIN1: case LTC4222_ADIN2: /* 1.25 mV resolution. Convert to mV. */
val = DIV_ROUND_CLOSEST(val * 5, 4); break; case LTC4222_SOURCE1: case LTC4222_SOURCE2: /* 31.25 mV resolution. Convert to mV. */
val = DIV_ROUND_CLOSEST(val * 125, 4); break; case LTC4222_SENSE1: case LTC4222_SENSE2: /* * 62.5 uV resolution. Convert to current as measured with * an 1 mOhm sense resistor, in mA. If a different sense * resistor is installed, calculate the actual current by * dividing the reported current by the sense resistor value * in mOhm.
*/
val = DIV_ROUND_CLOSEST(val * 125, 2); break; default: return -EINVAL;
} return val;
}
/* * Voltage alarms * UV/OV faults are associated with the input voltage, and power bad and fet * faults are associated with the output voltage.
*/ static SENSOR_DEVICE_ATTR_2_RO(in1_min_alarm, ltc4222_bool, LTC4222_FAULT1,
FAULT_UV); static SENSOR_DEVICE_ATTR_2_RO(in1_max_alarm, ltc4222_bool, LTC4222_FAULT1,
FAULT_OV); static SENSOR_DEVICE_ATTR_2_RO(in2_alarm, ltc4222_bool, LTC4222_FAULT1,
FAULT_POWER_BAD | FAULT_FET_BAD);
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.