summaryrefslogtreecommitdiff
path: root/drivers/hwmon
diff options
context:
space:
mode:
authorTimo Alho <talho@nvidia.com>2013-06-27 18:44:28 +0300
committerDan Willemsen <dwillemsen@nvidia.com>2013-09-14 13:41:41 -0700
commit88939f839370856e2dc93dafa822960e208310c2 (patch)
tree2e213d989012eeb6c4c2423649138c68c6aa60c4 /drivers/hwmon
parentf9416c26a0beef93ff8e7b4f6b8dd32cced2d76a (diff)
hwmon: ina230: enable current monitoring without resistor value
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>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r--drivers/hwmon/ina230.c13
1 files changed, 12 insertions, 1 deletions
diff --git a/drivers/hwmon/ina230.c b/drivers/hwmon/ina230.c
index 373a4062ef11..65b94eeb70cd 100644
--- a/drivers/hwmon/ina230.c
+++ b/drivers/hwmon/ina230.c
@@ -206,7 +206,18 @@ static s32 __locked_start_current_mon(struct i2c_client *client)
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;