[PATCH 4/7] bq27425: the DesignCapacity register is at a different offset

From: Juergen Borleis
Date: Tue Jun 10 2014 - 05:46:50 EST


For the BQ27425-g1 this register does not exists at all.
For the BQ27425-g2a this register is at offset 0x3C.

Signed-off-by: Juergen Borleis <jbe@xxxxxxxxxxxxxx>
---
drivers/power/bq27x00_battery.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)

diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c
index 39b5194..a5a88f1 100644
--- a/drivers/power/bq27x00_battery.c
+++ b/drivers/power/bq27x00_battery.c
@@ -78,6 +78,9 @@
#define BQ27425_REG_OFFSET 0x04
#define BQ27425_REG_SOC 0x20 /* Register address plus offset */

+/* register offsets above 0x20 are DEVICE_TYPE 0x0425 specifc */
+#define BQ27425_REG_DCAP 0x40 /* Design capacity plus offset */
+
#define BQ27000_RS 20 /* Resistor sense */
#define BQ27x00_POWER_CONSTANT (256 * 29200 / 1000)

@@ -265,9 +268,17 @@ static int bq27x00_battery_read_ilmd(struct bq27x00_device_info *di)
{
int ilmd;

- if (bq27xxx_is_chip_version_higher(di))
- ilmd = bq27x00_read(di, BQ27500_REG_DCAP, false);
- else
+ if (bq27xxx_is_chip_version_higher(di)) {
+ if (di->chip == BQ27425) {
+ if (di->chip_type == BQ27425_g2a)
+ ilmd = bq27x00_read(di, BQ27425_REG_DCAP,
+ false);
+ else
+ ilmd = -ENODATA;
+ } else {
+ ilmd = bq27x00_read(di, BQ27500_REG_DCAP, false);
+ }
+ } else
ilmd = bq27x00_read(di, BQ27000_REG_ILMD, true);

if (ilmd < 0) {
--
2.0.0.rc2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/