summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/power/max17040_battery.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/power/max17040_battery.c b/drivers/power/max17040_battery.c
index f8115b80ee2..8a098f54523 100644
--- a/drivers/power/max17040_battery.c
+++ b/drivers/power/max17040_battery.c
@@ -51,6 +51,9 @@ struct max17040_chip {
int soc;
/* State Of Charge */
int status;
+
+ /* If true, SoC's shown in double */
+ bool using_19_bits;
};
static void max17040_reset(struct i2c_client *client)
@@ -101,6 +104,15 @@ static void max17040_get_soc(struct i2c_client *client)
soc = (msb * 100) + (lsb * 100 / 256);
soc /= 10;
+ /* FIXME:
+ * No information about actual meaning of using 19 bits,
+ * it's just copied from vendor's code.
+ * However, It is clear that it represents doubled SoC
+ * if the chip is marked with 'using 19 bits'.
+ */
+ if (chip->using_19_bits)
+ soc /= 2;
+
max17040_get_scaled_capacity(&soc);
/* capacity should be between 0% and 100%
* (0.1% degree)
@@ -207,6 +219,11 @@ static int max17040_probe(struct i2c_client *client,
return -EINVAL;
}
+ /* A flag for value of SoC in double or not */
+ if (client->dev.of_node)
+ chip->using_19_bits = of_property_read_bool(client->dev.of_node,
+ "using-19-bits");
+
chip->pdata = client->dev.platform_data;
if (!chip->pdata) {