diff options
author | Hyungwoo Yang <hyungwooy@nvidia.com> | 2013-04-27 14:39:16 -0700 |
---|---|---|
committer | Harshada Kale <hkale@nvidia.com> | 2013-05-03 00:52:21 -0700 |
commit | 8de438d1bbd3516a067836a7697aead1ef20cdc2 (patch) | |
tree | 5fb67d08ed17e1105773bc7ebb751557d5beb9bf /drivers/hwmon | |
parent | 6d0cbb08d9283637559108ec88d99914bebcc3b5 (diff) |
hwmon: ina230: support inverted polarity for shunt voltage
This change supports the case for polarity of shunt voltage is inverted.
Bug 1240043
Change-Id: Idfb87fd80694b61f1ec66be9aa815d7aedc95324
Signed-off-by: Hyungwoo Yang <hyungwooy@nvidia.com>
Reviewed-on: http://git-master/r/223682
Reviewed-by: Automatic_Commit_Validation_User
GVS: Gerrit_Virtual_Submit
Reviewed-by: Sachin Nikam <snikam@nvidia.com>
Diffstat (limited to 'drivers/hwmon')
-rw-r--r-- | drivers/hwmon/ina230.c | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/drivers/hwmon/ina230.c b/drivers/hwmon/ina230.c index e7442202a1da..cb4ccb4816e0 100644 --- a/drivers/hwmon/ina230.c +++ b/drivers/hwmon/ina230.c @@ -3,7 +3,7 @@ * monitor sensor * * - * Copyright (c) 2011-2013, NVIDIA Corporation. All rights reserved. + * Copyright (c) 2009-2013, NVIDIA CORPORATION. All rights reserved. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -188,6 +188,7 @@ static s32 power_down_ina230(struct i2c_client *client) static s32 __locked_start_current_mon(struct i2c_client *client) { s32 retval; + s16 shunt_uV; s16 shunt_limit; s16 alert_mask; struct ina230_data *data = i2c_get_clientdata(client); @@ -205,8 +206,11 @@ static s32 __locked_start_current_mon(struct i2c_client *client) return retval; } - shunt_limit = uv_to_alert_register(data->pdata->resistor * - data->pdata->current_threshold); + shunt_uV = data->pdata->resistor * data->pdata->current_threshold; + if (data->pdata->shunt_polarity_inverted) + shunt_uV *= -1; + + shunt_limit = uv_to_alert_register(shunt_uV); retval = i2c_smbus_write_word_data(client, INA230_ALERT, cpu_to_be16(shunt_limit)); @@ -450,6 +454,9 @@ static s32 show_current(struct device *dev, ensure_enabled_end(client); mutex_unlock(&data->mutex); + if (data->pdata->shunt_polarity_inverted) + current_mA = (s16)current_mA * -1; + current_mA = (current_mA * data->pdata->power_lsb) / data->pdata->divisor; if (data->pdata->precision_multiplier) |