diff options
| author | mattis fjallstrom <mattis@acm.org> | 2015-12-18 03:39:54 -0800 |
|---|---|---|
| committer | mattis fjallstrom <mattis@acm.org> | 2015-12-22 09:11:17 -0800 |
| commit | f3fe6c93fcb0efee43eb00bba5112696806b65c3 (patch) | |
| tree | 3be8ce0361c9d0fcfa3e3bf744dc3c70dd229ff5 | |
| parent | a2cf73d74dc87c054c3ca329eba11299f2efb95f (diff) | |
| download | olio-linux-3.10-f3fe6c93fcb0efee43eb00bba5112696806b65c3.tar.xz olio-linux-3.10-f3fe6c93fcb0efee43eb00bba5112696806b65c3.zip | |
Charge request code
Change-Id: Ic6e2ffb5fec4060245c7da74ec1d8a90d28320ea
| -rw-r--r-- | drivers/power/bq27x00_battery.c | 9 | ||||
| -rw-r--r-- | drivers/staging/triune/ts81001.c | 37 |
2 files changed, 36 insertions, 10 deletions
diff --git a/drivers/power/bq27x00_battery.c b/drivers/power/bq27x00_battery.c index c26859a2f84..ed6846f6133 100644 --- a/drivers/power/bq27x00_battery.c +++ b/drivers/power/bq27x00_battery.c @@ -975,6 +975,9 @@ static void bq27x00_update(struct bq27x00_device_info *di) bool is_bq276xx = di->chip == BQ276XX; cache.flags = bq27xxx_read(di, BQ27XXX_REG_FLAGS, !is_bq27500); + + printk ("%s OLIO Cache flags read from bq is 0x%x\n", __FUNCTION__, cache.flags); + if (cache.flags >= 0) { if (is_bq27200 && (cache.flags & BQ27200_FLAG_CI)) { dev_info(di->dev, "battery is not calibrated! ignoring capacity values\n"); @@ -1207,9 +1210,13 @@ static int bq27x00_charger_status(struct bq27x00_device_info *di) { olio_debug("Got client data for dev %s\n", dev_name(ts81001->dev)); +#ifdef CHG_FLAGS_WORKING if(di->cache.flags & BQ27XXX_FLAG_CHG) { +#endif ts81001->ops->request_charge(ts81001); +#ifdef CHG_FLAGS_WORKING } +#endif state = ts81001->ops->get_status(ts81001); @@ -1486,7 +1493,7 @@ static int __init bq27x00_powersupply_init(struct bq27x00_device_info *di) /* This device is a wakeup source */ - device_init_wakeup(di->dev, 1); + /* device_init_wakeup(di->dev, 1); */ wake_lock_init(&chg_wake_lock, WAKE_LOCK_SUSPEND, "chg_wake_lock"); diff --git a/drivers/staging/triune/ts81001.c b/drivers/staging/triune/ts81001.c index 9ede65febc9..b3cb6c64a1f 100644 --- a/drivers/staging/triune/ts81001.c +++ b/drivers/staging/triune/ts81001.c @@ -48,10 +48,16 @@ /* Globals */ -const int TS81001_ADDR=0x49; -const u8 TS81001_STATUS_REG=0x10; -const u8 TS81001_CURRENT_REG=0x20; -const u16 TS81001_CHARGE_CURRENT=390; +const int TS81001_ADDR = 0x49; +const u8 TS81001_STATUS_REG = 0x10; +const u8 TS81001_CURRENT_REG_LSB = 0x20; +const u8 TS81001_CURRENT_REG_MSB = 0x21; + +/* Trying 400mA since we can't actually set 390mA. */ + +const u16 TS81001_CHARGE_CURRENT = 400; +const u8 TS81001_CHARGE_CURRENT_LSB = 0x90; /* 0x186 -> 390 dec = 0x186 hex */ +const u8 TS81001_CHARGE_CURRENT_MSB = 0x01; /* 0x190 -> 400dec */ /*************************************************************************** @@ -66,7 +72,7 @@ static int ts81001_i2c_read (struct i2c_client * client, int err = 0; struct i2c_msg msg[2]; - olio_debug (" entered\n"); + olio_debug ("entered\n"); msg[0].addr = client->addr; msg[0].flags = client->flags; @@ -83,7 +89,7 @@ static int ts81001_i2c_read (struct i2c_client * client, else err = i2c_transfer(client->adapter, msg, 2); - olio_debug (" exiting\n"); + olio_debug ("exiting\n"); return err; } @@ -95,6 +101,8 @@ static int ts81001_write_i2c_blk(struct i2c_client * client, u8 reg, int ret; u8 buf[33]; + olio_debug ("entered\n"); + if (!client->adapter) return -ENODEV; @@ -103,10 +111,13 @@ static int ts81001_write_i2c_blk(struct i2c_client * client, u8 reg, msg.buf = buf; msg.addr = client->addr; - msg.flags = 0; + msg.flags = client->flags; msg.len = sz + 1; ret = i2c_transfer(client->adapter, &msg, 1); + + olio_debug ("exiting, ret = %d\n", ret); + if (ret < 0) return ret; @@ -152,10 +163,18 @@ static int ts81001_request_charge (struct ts81001 * ts) { int retries = 2; int err = 0; int i; - u16 request_current = TS81001_CHARGE_CURRENT; + /* u16 request_current = TS81001_CHARGE_CURRENT; */ + u8 data[2]; + + data[0] = TS81001_CHARGE_CURRENT_LSB; + data[1] = TS81001_CHARGE_CURRENT_MSB; + + olio_debug ("entered, requested current = 0x%x, 0x%x\n", + TS81001_CHARGE_CURRENT_LSB, TS81001_CHARGE_CURRENT_MSB); for (i = 0; i < retries; i++) { - err = ts81001_write_i2c_blk(ts->client, TS81001_CURRENT_REG, (u8*) &request_current, 2); + err = ts81001_write_i2c_blk(ts->client, TS81001_CURRENT_REG_LSB, + &data[0], 2); } return err; |