This patch adds support to current monitoring alert when resistor
value is not defined in the platform configuration (which is the
nominal case for most of the platforms).
Change-Id: I504a0d601713470f74853bada45c42806dd0febd
Signed-off-by: Timo Alho <talho@nvidia.com>
Reviewed-on: http://git-master/r/262563
Reviewed-by: Juha Tukkinen <jtukkinen@nvidia.com>
return retval;
}
- shunt_uV = data->pdata->resistor * data->pdata->current_threshold;
+ if (data->pdata->resistor) {
+ shunt_uV = data->pdata->resistor;
+ shunt_uV *= data->pdata->current_threshold;
+ } else {
+ s32 v;
+ /* no resistor value defined, compute shunt_uV the hard way */
+ v = data->pdata->precision_multiplier * 5120 * 25;
+ v /= data->pdata->calibration_data;
+ v *= data->pdata->current_threshold;
+ v /= data->pdata->power_lsb;
+ shunt_uV = (s16)(v & 0xffff);
+ }
if (data->pdata->shunt_polarity_inverted)
shunt_uV *= -1;