summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEvan Wilson <evan@oliodevices.com>2015-10-27 00:57:00 -0700
committermattis fjallstrom <mattis@acm.org>2015-11-05 19:17:12 -0800
commit1a235b233ce554a896806ee84e98e70e455434ae (patch)
treeef10d8b1fb2f176274c0bbf1094a38760978164d
parente9ce880268504a5141c595fb86bbeb60e50aca94 (diff)
downloadolio-linux-3.10-good-known-branch.tar.xz
olio-linux-3.10-good-known-branch.zip
Tuning some values for the fuel gauge. Also, we'll request more power from the charger if the fuel gauge CHG flag is setgood-known-branch
Change-Id: Ibc7248bfd9f7bceaf03ea2d1f7e17cdcc20d2a98
-rw-r--r--drivers/power/bq27x00_battery.c24
-rw-r--r--drivers/staging/triune/ts81001.c41
-rw-r--r--drivers/staging/triune/ts81001.h1
3 files changed, 59 insertions, 7 deletions
diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c
index 9a491f027a2..1cc928fe2c9 100644
--- a/drivers/power/bq27x00_battery.c
+++ b/drivers/power/bq27x00_battery.c
@@ -232,6 +232,7 @@ static __initdata u8 bq276xx_regs[NUM_REGS] = {
#define BQ27XXX_FLAG_DSC BIT(0)
#define BQ27XXX_FLAG_SOCF BIT(1) /* State-of-Charge threshold final */
#define BQ27XXX_FLAG_SOC1 BIT(2) /* State-of-Charge threshold 1 */
+#define BQ27XXX_FLAG_CHG BIT(8)
#define BQ27XXX_FLAG_FC BIT(9)
#define BQ27XXX_FLAG_OTD BIT(14)
#define BQ27XXX_FLAG_OTC BIT(15)
@@ -411,12 +412,15 @@ static __initdata enum power_supply_property bq276xx_battery_props[] = {
* Customize these values and, if necessary, add more based on system needs.
*/
static struct dm_reg bq274xx_dm_regs[] = {
+ {36, 6, 1, 90}, /* FC Clear % */
{82, 0, 2, 16384}, /* Qmax */
- {82, 5, 1, 0x81}, /* Load Select */
+ {82, 3, 2, 15}, /* Reserve Cap-mAh */
+ {82, 5, 1, 0x01}, /* Load Select */
{82, 10, 2, 300}, /* Design Capacity */
{82, 12, 2, 1140}, /* Design Energy */
- {82, 16, 2, 3090}, /* Terminate Voltage */
- {82, 27, 2, 40}, /* Taper rate */
+ {82, 16, 2, 3100}, /* Terminate Voltage */
+ {82, 26, 1, 5}, /* SOC Delta (5%) */
+ {82, 27, 2, 75}, /* Taper rate */
};
static struct dm_reg bq276xx_dm_regs[] = {
@@ -1203,6 +1207,10 @@ static int bq27x00_charger_status(struct bq27x00_device_info *di) {
olio_debug("Got client data for dev %s\n", dev_name(ts81001->dev));
+ if(di->cache.flags & BQ27XXX_FLAG_CHG) {
+ ts81001->ops->request_charge(ts81001);
+ }
+
state = ts81001->ops->get_status(ts81001);
olio_debug("Got status\n");
@@ -1241,12 +1249,14 @@ static int bq27x00_battery_status(struct bq27x00_device_info *di,
else
status = POWER_SUPPLY_STATUS_DISCHARGING;
} else {
+ #ifdef CONFIG_OLIO_TS81001
+ status = bq27x00_charger_status (di);
+ if(status != POWER_SUPPLY_STATUS_DISCHARGING && di->cache.flags & BQ27XXX_FLAG_FC) {
+ status = POWER_SUPPLY_STATUS_FULL;
+ }
+ #else
if (di->cache.flags & BQ27XXX_FLAG_FC)
status = POWER_SUPPLY_STATUS_FULL;
-#ifdef CONFIG_OLIO_TS81001
- else
- status = bq27x00_charger_status (di);
-#else
else if (di->cache.flags & BQ27XXX_FLAG_DSC)
status = POWER_SUPPLY_STATUS_DISCHARGING;
else
diff --git a/drivers/staging/triune/ts81001.c b/drivers/staging/triune/ts81001.c
index 0562f4c9526..9ede65febc9 100644
--- a/drivers/staging/triune/ts81001.c
+++ b/drivers/staging/triune/ts81001.c
@@ -50,6 +50,8 @@
const int TS81001_ADDR=0x49;
const u8 TS81001_STATUS_REG=0x10;
+const u8 TS81001_CURRENT_REG=0x20;
+const u16 TS81001_CHARGE_CURRENT=390;
/***************************************************************************
@@ -86,6 +88,31 @@ static int ts81001_i2c_read (struct i2c_client * client,
return err;
}
+static int ts81001_write_i2c_blk(struct i2c_client * client, u8 reg,
+ u8 *data, u8 sz)
+{
+ struct i2c_msg msg;
+ int ret;
+ u8 buf[33];
+
+ if (!client->adapter)
+ return -ENODEV;
+
+ buf[0] = reg;
+ memcpy(&buf[1], data, sz);
+
+ msg.buf = buf;
+ msg.addr = client->addr;
+ msg.flags = 0;
+ msg.len = sz + 1;
+
+ ret = i2c_transfer(client->adapter, &msg, 1);
+ if (ret < 0)
+ return ret;
+
+ return 0;
+}
+
/***************************************************************************
* ts81001_get_status - get current charger state.
*
@@ -121,9 +148,23 @@ static int ts81001_get_status (struct ts81001 * ts) {
return state;
}
+static int ts81001_request_charge (struct ts81001 * ts) {
+ int retries = 2;
+ int err = 0;
+ int i;
+ u16 request_current = TS81001_CHARGE_CURRENT;
+
+ for (i = 0; i < retries; i++) {
+ err = ts81001_write_i2c_blk(ts->client, TS81001_CURRENT_REG, (u8*) &request_current, 2);
+ }
+
+ return err;
+}
+
static struct ts81001_ops ts_ops = {
.get_status = ts81001_get_status,
+ .request_charge = ts81001_request_charge,
};
/***************************************************************************
diff --git a/drivers/staging/triune/ts81001.h b/drivers/staging/triune/ts81001.h
index 6d248254661..8978ca2f0d1 100644
--- a/drivers/staging/triune/ts81001.h
+++ b/drivers/staging/triune/ts81001.h
@@ -52,6 +52,7 @@ struct ts81001 {
struct ts81001_ops {
int (*get_status) (struct ts81001 * ts);
+ int (*request_charge) (struct ts81001 * ts);
};
#endif /* _CONFIG_TS81001_H */