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>
MFD: twl6040-codec: cancel synch all active works on suspend

The TWL6040 vib_update work has to be canceled synchronously
before continue suspending, because of:
- it 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 TWL6040 device to sleep
state while vib_update work is still active.

Change-Id: I77b681188976378eec9242ea64dc5f001960d279
Signed-off-by: Grygorii Strashko <grygorii.strashko@ti.com>
ALSA: usb-audio: fixed usb audio subsystem initialization

If USB audio device is already present on bus during
snd_usb_audio_init initialization will fail and kernel
will reboot due to null-pointer dereference.

The snd_usb_audio_init consists of 2 steps:
1) usb_register() - registers USB audio driver
2) switch_dev_register() - initializes the switch_dev sdev structure

If there is no USB audio device present on the bus, the
snd_usb_audio_init will finish with initialized sdev structure.
After that if USB audio device is plugged, the usb_audio_probe
callback will initialize device (during this step we are accessing sdev)

But if USB audio device is already present on bus during
snd_usb_audio_init initialization, usb_audio_probe callback will
be called during usb_register() - when sdev isn't initialized yet.
We are getting reboot due to null-pointer dereference.

Changed order of described steps so sdev is initialized when
calling usb_register.

Change-Id: Id22356157af2b69038506f1138a6da78d8f1e727
Signed-off-by: Ruslan Bilovol <ruslan.bilovol@ti.com>
TI TFW: omap die governor: cancel synch panic guard work on suspend

The decrease_mpu_freq_work has to be canceled synchronously before
continue suspending.
The decrease_mpu_freq_work may sleep because of accessing to I2C bus as
result WFI may be reached in the middle of its execution which will
prevent system from entering to OFF state.

Change-Id: Ief29ba634b9d296f8aa82f94bd39687c65b331ec
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>
gcx: added pulse skipping enable to power off case.

This allows to at least enter the less power consuming
mode if power off is not possible at the moment.

Change-Id: If684849f1149da2805db2841dd3ecfd55110f43f
Signed-off-by: Alexei Shlychkov <x0177296@ti.com>
gcx: Disable write all permission for cache_status_every_irq

Android CTS requires that no sysfs entry is writeable by anyone

Change-Id: I55123b9ba69072a730b2b7889752ed5b1ab88770
Signed-off-by: Craig Stout <craig.stout@ti.com>
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>
SMC: Update to AG01.06p4 release

With this SMC driver version present in MSHIELD-DK 1.7.10 and using
corresponding PPA/PA, the crypto driver now uses DMA beyond a certain
data size threshold.

It fixes some statbility issues observed since introduction of DMA
in MSHIELD-DK release 1.7.2

        * start using GFP_ATOMIC instead of GFP_KERNEL in
                aes_sync_operate() and tf_digest_hw_perform_dma()
        * tf_clock_timer_start() now called in tf_clock_timer_cbis()
        * fixed potential memory leak in aes_sync_operate

Change-Id: Ifcb4653b0cad7dc2e5cf61bd58631c56d7738dd7
Signed-off-by: Trusted Logic <smc_support@trusted-logic.com>
Signed-off-by: Bryan Buckley <bryan.buckley@ti.com>
Signed-off-by: Srinivas Pulukuru <srinivas.pulukuru@ti.com>
UVC: Enable CONFIG_USB_VIDEO_CLASS to default.

Enables the USB camera support in V4L driver.

Change-Id: Ief86b72fb4216adcf1c4fb11cff0f4f5c61998f9
Signed-off-by: Solaiyappan Saravanan <saravanan.s@ti.com>
omap: rpmsg: switch over vring memory to use dynamic pool for dsp

The carveout memory for DSP is being switched over to use the
dynamically reserved memory pool. The memory addresses used to
configure the vring memory is therefore being switched over to
use the dynamic memory pool.

The vring memory is allocated in the rpmsg layer, while the
memory for other firmware sections is assigned by the remoteproc
driver. The remoteproc driver adjusts for the utilization of
this memory automatically through the presence of the vring
carveout section as the first of the carveout sections in the
resource table.

Change-Id: I5156028450fc7aec813bf3ce9b328acf06059de1
Signed-off-by: Jesse Villarreal <jesse.villarreal@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
OMAP: TILER: Optimize placement for NV12 buffers

This patch changes the behaviour when allocating 2D buffers.  If
the required alignment is less than 4KiB and a security token is set,
the allocation will be flagged specifically for this format.  All
subsequent buffers of the same format and size will be placed inside
this area until the area is exhausted.

For NV12 allocations, this means that all Y allocations will share
one area, and the UV allocations will share another.

Change-Id: I13d29257c0cbab627c2938d4623557918448ee86
Signed-off-by: Andy Gross <andy.gross@ti.com>