OMAP4: otg: phy: fix charger detection

Charger detection feature is not correctly used
and thus makes some regressions if OTG was used in
the host mode. Charger detection takes 500 ms so
if some device is attached to the host after 500 ms
it will be suddenly resetted.

This feature is enabled by default after reset/cold boot
so always affects PHY usage, also it wasn't disabled during
calling omap4_charger_detect. So finally this was wrongly
interpreted as "phy requires 200ms to start" (in latest
versions - 300ms). After fixing this we can safely remove
uggly mdelay after powering on the PHY.

Change-Id: I901d1613f1f72df408158a086ce94c554aeab186
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com>
OMAP4: otg: phy: remove uggly mdelay(300)

The original issue with powering on the PHY (and using
300 ms delay after this) is not related to internal
processes in the PHY but is in the incorrect charger
detection future usage.

Now when it is fixed, we can safely remove this uggly
mdelay that sometimes was called in atomic context and
leads to unacceptable system freezing

Tested with different hubs, devices, and booting scenarios.

Change-Id: I54b770d27ab140dd1de4103397881dd3fb807221
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com>
OMAP4: USB: remove unused function twl6030_set_phy_clk

This function is redundant and not used anywhere.
Remove it and change associated code accordingly

Change-Id: I06ba222429cfe89a401b426a211d1752e646450a
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com>
fix jem/tate boards after twl6030_set_phy_clk removal

Change-Id: I6a9140a95a23c226673ed34fcdcdccca697f7352
remove unused file

Change-Id: I813eaf953618fa04d7ea9d60e95ecd628e4204c8
jem/tate board removal of dead code

Change-Id: I01c89578629d6e6bce292cbe436506c138e37c86
sound: remove extra debug

Change-Id: I673b01bdf5364df72fdb1cbdd7b2bc322deb9297
usb: gadget: android: Honor CONFIG_USB_GADGET_VBUS_DRAW

The maximum current draw was hard coded to 500 mA.  composite.c
has code that uses CONFIG_USB_GADGET_VBUS_DRAW to set the
bMaxPower and to set whether or not the device is self-powered if
they haven't been set.  This change removes the code in android.c
to allow composite.c to set them.

Change-Id: I9db37922e91ee86e9e5c0e14519e119e5c41ca48
Signed-off-by: Scott Anderson <saa@google.com>
remove unused cdrom sysfs entry for android gadget

Change-Id: I9d6f2b08d8041bcd388f6fa696098ebeb6a90437
MFD: TWL6030: cancel synch all active works on suspend

The TWL6030 battery works have to be canceled synchronously
before continue suspending, because of:
- they may sleep while accessing to I2C bus and, as result, WFI may be
reached in the middle of its execution and that may prevent system
from entering to OFF state.
- the device suspend handler may switch TWL6030 device to sleep
state while their works are still active.

Change-Id: Ie3ef579e05bded049e39f9186acb01b116283c87
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
twl6030_bci_battery remove use_eeprom_config

In all sensible use cases use_eeprom_config and use_hw_charger are
actually synonymous so simplify the code and remove the use_eeprom_config.

Change-Id: Ibf473ea8106a72038f646e9163665caa91de9e06
Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
twl6030_bci_battery read charger mode from register

For the twl6032 read the charger mode and power path usage from a register
on the chip.

Because of this change these parameters no longer need to be provided by
platform data so move these variable to the private structure.

This change also means that these variables being set also implies
twl6032 is the chip type so simplify the code by removing checks
for this from features at each usage of one of these variables.

Change-Id: If371db6270e40edf2ee315696300cf29bd9e8ea8
Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
twl6030_bci_battery correct the current readings.

Correct the current reading functions for current_now and current_avg.
This was done with advice on the correct algorithm from the design team
and application engineers.

Also by default twl6030 and twl6032 use different sense resistors and
according to design team these resistors may be tuned for certain boards.
So allow the resistor value to be passed as platform data but select
sensible defaults if it is not.

Change-Id: Ib60742ec5779708d7156a4c6b4acd16b84cc8f0c
Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
twl6030_bci_battery add seperate irq handlers for hw mode

As HW/Auto mode for the charger just wants to read status and convert
this to power supply class statuses. It is easier and cleaner to seperate
the handling of HW mode into seperate IRQ handlers.

Change-Id: Ic80fa0ff6b77a77e8c10b63027876bb8f613e0f8
Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
twl6030_bci_battery remove hw handling from sw irq

Now that hardware charging mode has seperate IRQs remove the hardware
mode handling from the software mode IRQs as it is not required here
anymore.

Change-Id: Ib2cd7ae43157014b9111a5bdd5da36e1caeb6602
Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
POWER: twl6030_bci_battery fix start/stop for hw mode

In use_hw_charger mode the charger should not be started or stopped
by disabling/enabled the DCDC/Linear charger. It should rather be
paused by setting HZ_MODE. This prevents the charger switching from
HW to SW mode.

Change-Id: I521b094a0fa4835466142219f1a1eef1ef4578b1
Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
POWER: twl6030_bci_battery fix boot charge state in hw mode

Change the method to detect the charging state on boot. The
_STS bits used previously did not contain the complete charging
state so in some situations state was incorrectly indicated.

Change-Id: I6e276765d36f41df263ef5588aef4c792c8cbb7e
Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
twl6030_bci_battery alter the hw mode start logic

In Active state the omap does not update the CHRG_DET_N signal so to
change the current limits based on the information of USB stack in
HW mode the CINLIMIT register needs to be written. This does not
take the charger out of HW mode.

Because the new logic started to make start fuction messy I have split
into seperate hw/sw start functions.

Change-Id: I647d2934a9b8e39e0d00049444c79ca196e8820b
Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
twl6030_bci_battery fix autogate logic

The logic in the autogate function was causing a storm of events causing
I2C transactions as fast as the bus could run. Add an extra check in
the if statement and correctly set the charger source to stop this
happening. This stops the monitor function being scheduled thousands
of times when USB cable is inserted.

Change-Id: Ib783b684c3b3913e2afb9aa6fd607683c9d555ec
Signed-off-by: Graeme Gregory <gg@slimlogic.co.uk>
Revert "OMAP4: battery: correcting measured battery temperature value"

This reverts commit 3ee53862e7af3ffa9f5d7e71db3b53c253c0eae0

Battery temperature now is reported in degrees Celsius, but
should be in tenths of degree Celsius. Insted of, for example,
300 it returns 30.

Change code to return battery temperature in thents of degree
Celsius.

Change-Id: Ic56eaf33c0950929fecbd07654c08d022a3029cb
Reported-by: Anand Gadiar <gadiyar@ti.com>
Signed-off-by: Oleksandr Kozaruk <oleksandr.kozaruk@ti.com>