twl6030 battery: don't disable gas gauge in suspend

We need the gas gauge to continue measuring power drain in suspend.
Keep it always enabled.

Change-Id: I5b6dd4d8f63e3269dacf8d8dfb814670bfa8937a
Signed-off-by: Sivakumar Pothireddy <sivakumar.pothireddy@ti.com>
Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
twl6030 battery: add lookup table for initial capacity estimation

Add a lookup table for estimating battery capacity at bootup
using the battery voltage measrued at that time.

The table was constructed using actual measured values for Blaze
Tablets. The values don't correspond to the arbitrary values currently
used in the driver.

This table is something that a board file should pass to the
driver. This will be introduced in a later patch - for now, we
keep the values in the driver just like the current design.

Change-Id: I78b35b68c7a41b67d67925dae8015405efb44b0d
Signed-off-by: Sivakumar Pothireddy <sivakumar.pothireddy@ti.com>
Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
twl6030 battery: clear gas gauge at enable time

Otherwise previous register values (from bootloader, or warm reboot)
will distort our calculations.

Change-Id: I302eb3f05cacdc9136c937556dd5a9d5d8baf4d4
Signed-off-by: Sivakumar Pothireddy <sivakumar.pothireddy@ti.com>
Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
twl6030 battery: use gas gauge for capacity estimation

Use the gas gauge in twl6030 to estimate the remaining battery
capacity.

At bootup, we use an estimate of initial capacity using the measured
battery voltage at bootup. From that point on, all future battery
capacity estimations are done by using the gas gauge to measure
all addition/removal of charge from the battery.

Clamp battery value to 99% if the measured value exceeds 99%.
A later patch will add the code to update the initial estimate
once the battery is fully charged.

TODO: Minimum safe battery voltage reporting needs to be worked on

Change-Id: Iab157b559f9de432a93664e8d78c003af3c75b67
Signed-off-by: Sivakumar Pothireddy <sivakumar.pothireddy@ti.com>
Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
twl6030 battery: remove ac_next_refresh

We now update capacity estimates using the gas gauge. No need to
schedule voltage-based estimates except when voltage is critically low.
(This reconciliation based on voltages will be done in a later patch).
So remove this code.

Change-Id: I46706c954e32667a84a4e64c9a0831a706755da8
Signed-off-by: Sivakumar Pothireddy <sivakumar.pothireddy@ti.com>
Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
twl6030 battery: pass nominal capacity from board file

Pass the nominal battery capacity from the board file instead of
hardcoding it in the driver.

TODO: This needs to be done for the blaze as well, although it's
rarely run off the battery

Change-Id: I15cba65f062c70f3b1e26f3c03db59e3af0d6ea9
Signed-off-by: Sivakumar Pothireddy <sivakumar.pothireddy@ti.com>
Signed-off-by: Anand Gadiyar <gadiyar@ti.com>
twl6030 battery: assume default capacity if not specified

If platform data does not pass down the nominal battery capacity,
then assume a sane default value.

Change-Id: Icba698fb0d2f14cc778740734ed8f2c573e67f0d
Signed-off-by: Sivakumar Pothireddy <sivakumar.pothireddy@ti.com>
Signed-off-by: Anand Gadiyar <gadiyar@ti.com>