]> rtime.felk.cvut.cz Git - sojka/nv-tegra/linux-3.10.git/commitdiff
hwmon: ina230: enable current monitoring without resistor value
authorTimo Alho <talho@nvidia.com>
Thu, 27 Jun 2013 15:44:28 +0000 (18:44 +0300)
committerDan Willemsen <dwillemsen@nvidia.com>
Sat, 14 Sep 2013 20:41:41 +0000 (13:41 -0700)
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>
drivers/hwmon/ina230.c

index 373a4062ef11bd44ee0f3bc819dfd8173fb8f73d..65b94eeb70cd85075792b6bad388e5d4cc6b840b 100644 (file)
@@ -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;