summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--drivers/power/max17040_battery.c36
1 files changed, 19 insertions, 17 deletions
diff --git a/drivers/power/max17040_battery.c b/drivers/power/max17040_battery.c
index 417c9bb..f8115b8 100644
--- a/drivers/power/max17040_battery.c
+++ b/drivers/power/max17040_battery.c
@@ -57,18 +57,19 @@ static void max17040_reset(struct i2c_client *client)
{
struct max17040_chip *chip = i2c_get_clientdata(client);
- regmap_write(chip->regmap, MAX17040_CMD_MSB, 0x40);
- regmap_write(chip->regmap, MAX17040_CMD_LSB, 0x00);
+ regmap_write(chip->regmap, MAX17040_CMD_MSB, 0x4000);
}
static void max17040_get_vcell(struct i2c_client *client)
{
struct max17040_chip *chip = i2c_get_clientdata(client);
- u32 msb;
- u32 lsb;
+ u32 data;
+ u8 msb, lsb;
- regmap_read(chip->regmap, MAX17040_VCELL_MSB, &msb);
- regmap_read(chip->regmap, MAX17040_VCELL_LSB, &lsb);
+ regmap_read(chip->regmap, MAX17040_VCELL_MSB, &data);
+
+ msb = ((data & 0xFF00) >> 8);
+ lsb = (data & 0xFF);
chip->vcell = ((msb << 4) + (lsb >> 4)) * 1250 / 1000;
}
@@ -88,13 +89,16 @@ static void max17040_get_scaled_capacity(int *val)
static void max17040_get_soc(struct i2c_client *client)
{
struct max17040_chip *chip = i2c_get_clientdata(client);
- u32 msb, lsb;
+ u32 data;
+ u8 msb, lsb;
int soc;
- regmap_read(chip->regmap, MAX17040_SOC_MSB, &msb);
- regmap_read(chip->regmap, MAX17040_SOC_LSB, &lsb);
+ regmap_read(chip->regmap, MAX17040_SOC_MSB, &data);
+
+ msb = ((data & 0xFF00) >> 8);
+ lsb = (data & 0xFF);
- soc = (lsb * 100) + (msb * 100 / 256);
+ soc = (msb * 100) + (lsb * 100 / 256);
soc /= 10;
max17040_get_scaled_capacity(&soc);
@@ -115,13 +119,11 @@ static void max17040_get_soc(struct i2c_client *client)
static void max17040_get_version(struct i2c_client *client)
{
struct max17040_chip *chip = i2c_get_clientdata(client);
- u32 msb;
- u32 lsb;
+ u32 data;
- regmap_read(chip->regmap, MAX17040_VER_MSB, &msb);
- regmap_read(chip->regmap, MAX17040_VER_LSB, &lsb);
+ regmap_read(chip->regmap, MAX17040_VER_MSB, &data);
- dev_info(&client->dev, "MAX17040 Fuel-Gauge Ver %d%d\n", msb, lsb);
+ dev_info(&client->dev, "MAX17040 Fuel-Gauge Ver %d\n", data);
}
static void max17040_get_status(struct i2c_client *client)
@@ -180,8 +182,8 @@ static enum power_supply_property max17040_battery_props[] = {
static struct regmap_config max17040_regmap_config = {
.reg_bits = 8,
- .val_bits = 8,
- .val_format_endian = REGMAP_ENDIAN_NATIVE,
+ .val_bits = 16,
+ .val_format_endian = REGMAP_ENDIAN_BIG,
};
static int max17040_probe(struct i2c_client *client,