staticbool isl28022_is_writeable_reg(struct device *dev, unsignedint reg)
{ switch (reg) { case ISL28022_REG_CONFIG: case ISL28022_REG_CALIB: case ISL28022_REG_SHUNT_THR: case ISL28022_REG_BUS_THR: case ISL28022_REG_INT: case ISL28022_REG_AUX: returntrue;
}
returnfalse;
}
staticbool isl28022_is_volatile_reg(struct device *dev, unsignedint reg)
{ switch (reg) { case ISL28022_REG_CONFIG: case ISL28022_REG_SHUNT: case ISL28022_REG_BUS: case ISL28022_REG_POWER: case ISL28022_REG_CURRENT: case ISL28022_REG_INT: case ISL28022_REG_AUX: returntrue;
} returntrue;
}
err = regmap_read(data->regmap,
ISL28022_REG_SHUNT, ®val); if (err) return err;
/* print shunt voltage in micro volt */
seq_printf(seqf, "%d\n", regval * 10);
return 0;
}
DEFINE_SHOW_ATTRIBUTE(shunt_voltage);
/* * read property values and make consistency checks. * * following values for shunt range and resistor are allowed: * 40 mV -> gain 1, shunt min. 800 micro ohms * 80 mV -> gain 2, shunt min. 1600 micro ohms * 160 mV -> gain 4, shunt min. 3200 micro ohms * 320 mV -> gain 8, shunt min. 6400 micro ohms
*/ staticint isl28022_read_properties(struct device *dev, struct isl28022_data *data)
{
u32 val; int err;
err = device_property_read_u32(dev, "renesas,shunt-range-microvolt", &val); if (err == -EINVAL)
val = 320000; elseif (err < 0) return err;
switch (val) { case 40000:
data->gain = 1; if (data->shunt < 800) goto shunt_invalid; break; case 80000:
data->gain = 2; if (data->shunt < 1600) goto shunt_invalid; break; case 160000:
data->gain = 4; if (data->shunt < 3200) goto shunt_invalid; break; case 320000:
data->gain = 8; if (data->shunt < 6400) goto shunt_invalid; break; default: return dev_err_probe(dev, -EINVAL, "renesas,shunt-range-microvolt invalid value %d\n",
val);
}
err = device_property_read_u32(dev, "renesas,average-samples", &val); if (err == -EINVAL)
val = 1; elseif (err < 0) return err; if (val > 128 || hweight32(val) != 1) return dev_err_probe(dev, -EINVAL, "renesas,average-samples invalid value %d\n",
val);
data->average = val;
return 0;
shunt_invalid: return dev_err_probe(dev, -EINVAL, "renesas,shunt-resistor-microvolt invalid value %d\n",
data->shunt);
}
/* * write configuration and calibration registers * * The driver supports only shunt and bus continuous ADC mode at 15bit resolution * with averaging from 1 to 128 samples (pow of 2) on both channels. * Shunt voltage gain 1,2,4 or 8 is allowed. * The bus voltage range is 60V fixed.
*/ staticint isl28022_config(struct isl28022_data *data)
{ int err;
u16 config;
u16 calib;
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.