OMAP4: battery: capacity detection.

Capacity could be detected when it is not charging.
If charge status set to POWER_SUPPLY_STATUS_NOT_CHARGING
capacity detection path is omitted.

Add this state to let capacity detection happen.

Change-Id: I34a8295470457423d25cc2ec42e2498682339dcc
Signed-off-by: Oleksandr Kozaruk <oleksandr.kozaruk@ti.com>
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>

Conflicts:
	arch/arm/mach-omap2/board-44xx-power.c
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>
OMAP4: battery: correct refreshing temperature algorithm

Previously temperature of the battery was refreshed only if adc ch1 value
was in range from 100 to 950. Now the temperature of the battery measured
correctly. If the temperature is less then -2 degrees Celsius then
-2 degrees Celsius returned and if the temperature is more then +62 degrees
Celsius then +62 degrees Celsius returned.

Change-Id: I8f91b88e76fc3c00e0d7a22267de16f096584e13
Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@ti.com>

Conflicts:
	drivers/power/twl6030_bci_battery.c
OMAP4: battery: fix temperature conversion.

Battery driver reads ADC channel 1 to wich NTC resistor
is connected to detect battery temperature.
There is a table that matches ADC value to temperature.
The driver, for looking corresponding temperature uses
ADC value converted to millivolts, instead of ADC value,
which is incorrect.
Use ADC value for temperature conversion.

Change-Id: I25812a4f3d94ce971475546145803513e346dd9a
Signed-off-by: Oleksandr Kozaruk <oleksandr.kozaruk@ti.com>
OMAP4470: battery: correct temperature conversion.

TWL6032 has 12-bit ADC, TWL6030 has 10-bit ADC, battery temperature
table is calculated for the TWL6030. So battery temperature measured
correctly only for OMAP4430 and OMAP4460. Patch rejects two lower
bits of ADC channel for TWL6032 and temperature measured correctly
for all OMAP controllers.

Change-Id: I88b6f2e6fbde11fa05642d1772c797b61b2fd1ce
Signed-off-by: Oleksandr Dmytryshyn <oleksandr.dmytryshyn@ti.com>
POWER: TWL6030_BCI: Integrate Fuel Gauge

Change-Id: I7564fb0c3eb617c1beba2dc0162db25b5799a8e5
Signed-off-by: Max Herman <mherman@fsisys.com>

Conflicts:
	drivers/power/twl6030_bci_battery.c
OMAPDSS: DSS: Fixing display's state-machine for suspend

Issue with entering blaze to suspend state fixed.
Also fixed error during hdmi driver resume when actual
hdmi device was not connected.

Change-Id: Iffb151982f020afb40dc2b39b35aa80a03091b32
Signed-off-by: Andrii Guriev <x0160204@ti.com>
OMAP4: HDMI : Support default display configuration for HDMI

Added get_resolution and get_fb_resolution function to HDMI
driver so that we can configure defaults via board files when
HDMI is default panel.

Change-Id: I36cafb4b0bd42c150c1c1a03be4607edec31b4db
Co-Author-by: Victor Kleinik <x0150886@ti.com>
Co-Author-by: Artem Rudenko <artemrudenko@ti.com>
Signed-off-by: Dandawate Saket <dsaket@ti.com>
Signed-off-by: Muralidhar Dixit <murali.dixit@ti.com>
OMAPDSS: connection to HDMI during suspend

This change adds capability to activate HDMI connection if
cable was plugged in during suspend mode.

Change-Id: I3f17489f16a3157fe20ae4ab86b4964a672f595f
Signed-off-by: Mykhailo Denysiuk <x0172934@ti.com>
smc: remove duplicate flags
SMC: Fix compiler warnings

security/smc/tf_device.c:174: missing braces around initializer
security/smc/tf_device.c:174: (near initialization for 'g_tf_dev.kobj')

Change-Id: Ia8b3b9420ab3b860900d1db9fe0ed925b96fc200
Signed-off-by: Bryan Buckley <bryan.buckley@ti.com>