summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonghwa Lee <jonghwa3.lee@samsung.com>2014-10-23 10:51:42 +0900
committerChanho Park <chanho61.park@samsung.com>2014-11-18 12:01:03 +0900
commit3d720fc80afe332f78df507127629f86285a2d92 (patch)
tree62fb51f43dac035d788d998fb1bcba0d149c66a5
parent7e4af2a31658998a09604e0b8c7d65dabfcc9395 (diff)
downloadlinux-3.10-3d720fc80afe332f78df507127629f86285a2d92.tar.gz
linux-3.10-3d720fc80afe332f78df507127629f86285a2d92.tar.bz2
linux-3.10-3d720fc80afe332f78df507127629f86285a2d92.zip
power: max17040: Fix data transfering size from 8bits to 16bits.
Even max17040 fuelgauge chip's registers are segmented in size of 8bits (MSB, LSB), it transfers data only in 16bits. So, it should read both of MSB, LSB registers at once. Change-Id: I87150fbf9b14adf65fc9fdf912f963ab591586e3 Signed-off-by: Jonghwa Lee <jonghwa3.lee@samsung.com>
-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 417c9bb430e..f8115b80ee2 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,