MFD: twl6040-codec: Add test registers definitions

Add definitions for test registers.

Change-Id: Ic046f4639781981ca2421f5b75c0c5408a3dc976
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
MFD: twl6040-codec: Add uEvent based event notification

Add initial support for a kobject event based notification mechanism
to inform userspace about TWL6040 events like handsfree overcurrent,
vibrator overcurrent, thermal event.

Since the events can be handled in other drivers apart from the MFD,
a new API (twl6040_report_event) is created so that MFD clients can
notify their events using a single kobject.

Change-Id: I07f71d1693a6eb189ca07fffeb3ebc12e539d4ae
Signed-off-by: Chris Kelly <c-kelly@ti.com>
MFD: twl6040-codec: Add register cache

Add register cache and define register operations (read, write,
set_bits, clear_bits) on cache only. So register operations
performed on I2C registers are now differentiated.

Register operations APIs exported by TWL6040 MFD are a wrapper
to its I2C counterparts at the moment.

Change-Id: I76137099e6264de9ac3213c596f662a50299aa82
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
Signed-off-by: Gabriel M. Beddingfield <gabrbedd@ti.com>
Signed-off-by: Chris Kelly <c-kelly@ti.com>
MFD: twl6040-codec: Add register supply query APIs

Add a new set of APIs to TWL6040 MFD to query the supply of its
registers: twl6040_get_reg_supply(), twl6040_reg_is_vdd() and
twl6040_reg_is_vio().

Change-Id: Ic320ad7759c66d705f6025361cd6a296ac695dd9
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
Signed-off-by: Chris Kelly <c-kelly@ti.com>
Signed-off-by: Gabriel M. Beddingfield <gabrbedd@ti.com>
MFD: twl6040-codec: Add register context restore

Add register context restore per supply.

Change-Id: I4918efee4fcc83f4998f59f3d376b798822ca3ce
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
Signed-off-by: Chris Kelly <c-kelly@ti.com>
Signed-off-by: Gabriel M. Beddingfield <gabrbedd@ti.com>
MFD: twl6040-codec: Handle thermal interrupt

When the TWL6040 temperature increases above a threshold that could
damage the device, a thermal interrupt and shutdown are started
automatically by the hardware.

The thermal event handling involves the following steps:
1. Forcefully deassert AUDPWRON to avoid keeping TWL6040 is
   Power-On state any longer
2. The event is notified to Android userspace through the switch
   class based mechanism so that further actions can be taken
3. While the device is in thermal shutdown, accesses to VDD/VSS
   registers will affect only register cache
4. Once the device has recovered from the thermal event, it will
   be put back to Power-On state regardless of the state requested
   by MFD clients:
   4.1. If clients have requested Power-On state, then the context
        of VDD/VSS registers is restored
   4.2. If clients have requested Sleep state, then the request will
        be honored. The additional Power-On -> Sleep transition is
        required to ensure that reference system is disabled after
        thermal shutdown
5. An additional notification is sent to Android userspace to inform
   about thermal shutdown recovery.

Change-Id: I38afa98fea03210312fc01ab0d2c6ab2a10c447d
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
Signed-off-by: Chris Kelly <c-kelly@ti.com>
ASoC: twl6040: Handle handsfree overcurrent events

TWL6040 has a short circuit detection mechanism that report events
when the current exceeds 2.2A in its handsfree output stage. Upon
detection of handsfree overcurrent, the suggested action is to
disable handsfree drivers to prevent damage. Additionally, when
this event occurs it's reported to Android userspace layers through
an uEvent associated with the TWL6040 MFD.

Change-Id: Iea94c55286a9adb158caac10f7a15fae73827792
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
Signed-off-by: Chris Kelly <c-kelly@ti.com>
ASoC: DSP: Fix BE link state and hw_params in debugfs

BE state and hw_params were incorrectly shown in DSP state debugfs,
it was showing FE's values instead.

Change-Id: Ib5afb1537824634208741b0b635a31152c5aaddd
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
OMAP4: clock: Fixing clock internal source selection for ABE ports

ABE ports need a mask of two bits in order to select the
correct internal source clock. This patch fix this mask that
was only one bit and was overlaping with source clock bits.

Change-Id: I8597efd9cec6707e815da39598a0adb7a3ce3c61
Signed-off-by: Israel Cepeda <icepeda@ti.com>
misc: cdc tcxo: Add initial support

Add initial support for Texas Instruments CDC3S04. The misc
driver creates a set of APIs to allow external client drivers
to configure CDC clock settings, for example: request source
(internal, external) and internal request values.

Change-Id: Id83b57037be832af15462b75bc0af997783da603
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
OMAP4: Tablet: Enable CDC TCXO misc driver

Enable CDC TCXO misc driver and pass initial clock configuration
to output CLK1 based on REQ1 from OMAP. By default CLK1 is driven
based on an internal REQ1INT signal which is always set to 1.
Doing this helps gate sysclk (from CLK1) to OMAP while OMAP is
in sleep states.

Additionally, LDO is made decoder controlled so its state depends
on clock requests. This can lead to power savings when no clocks
are requested as the LDO will be off.

Change-Id: I737629ffafc1bf9acdcdb2d119ed81ed80b2cc4a
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
OMAP4: SDP4430: Enable CDC TCXO misc driver

Enable CDC TCXO misc driver and pass initial clock configuration
to output CLK1 based on REQ1 from OMAP. By default CLK1 is driven
based on an internal REQ1INT signal which is always set to 1.
Doing this helps gate sysclk (from CLK1) to OMAP while OMAP is
in sleep states.

Additionally, LDO is made decoder controlled so its state depends
on clock requests. This can lead to power savings when no clocks
are requested as the LDO will be off.

Change-Id: I005b25d70d79bd660f958cc247282c1a3d890ab3
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
ASoC: sdp4430: Control CDC CLK2 based on TWL6040 power mode

TWL6040 requires MCLK to be active as long as high-performance
mode is in use, as glitch-free mux cannot tolerate MCLK gating.
TWL6040 doesn't require MCLK for low-power mode as it uses 32k
clock. SDP4430 machine driver can control CDC CLK2 request by
driving it through internal request and controlling internal
request value depending on power-mode.

Change-Id: I7314bc35c2811a5a3d94b6317778bc05f807e755
Signed-off-by: Misael Lopez Cruz <misael.lopez@ti.com>
TWL6030: Fix false GPADC conversion timeout.

When scheduler preempts just started GPADC conversion,
the timeout appears because a time is exhausted
but actual status register value is not updated yet.
Simple scenario:
1. GPADC convertion is started before this function starts to run.
2. reg = twl6030_gpadc_read(gpadc, status_reg);
3.  if (!(reg & TWL6030_GPADC_BUSY) && (reg & TWL6030_GPADC_EOC_SW))
            return 0;
    GPADC is not yet ready, so function does not return.
4.  This moment the context is switched to another thread(s)
      ----------------------------------------------------------------------->
5.                           thread(s) work(s) for    timeout_ms   or more  time.
                             GPADC convertion is finished.
6.    <-----------------------------------------------------------------------
      The context is switched back.
7.  } while (!time_after(jiffies, timeout))
      Next cycle pass does not start, even if GPADC is yet ready.
8.  The Timeout Error is returned.

Additional GPADC status register reading is added for such cases.

	modified:   drivers/mfd/twl6030-gpadc.c

Change-Id: I94b61bb8318c6a03972ad057ab3fd026d1b4c13f
Signed-off-by: x0169938 <vasyl.yushchyshen@ti.com>
TWL6030: relaxing the GPADC busy loop with a sleep.

After GPADC conversion is started, we wait for finish it with
a busy flag polling in twl6030_gpadc_wait_conversion_ready().
Actually the GPADC busy loop finishes immediately, but for the
worst case condition the sleep is added.

      modified:   drivers/mfd/twl6030-gpadc.c

Change-Id: If20a9bfe6943814bcce98e591fd876d66f986e44
Signed-off-by: x0169938 <vasyl.yushchyshen@ti.com>
omap: iommu: lower trace level in iommu_enable

The version of the iommu is printed using dev_info in iommu_enable.
This trace is quite rudimentary and hence is converted to use a
dev_dbg. The iommu_enable function is invoked every-time a processor
has to be booted, and so this conversion also helps with the overall
processor init time.

Change-Id: Ia6cfbdf7e6424a917b5d49083c994c88103c0049
Signed-off-by: Subramaniam C.A <subramaniam.ca@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
remoteproc: use dev_dbg to print image version

The version of the remote processor's resource table format is printed
using dev_info during the startup path of a remoteproc. The version
changes very rarely and hence is converted to use a dev_dbg. An error
message is printed anyway in case of a mismatch, so this conversion is
useful in helping improve the overall processor init time.

Also, version info can be looked up using an offline readrprc utility.

Change-Id: I546d3c73582bb7a3fdb2b32b4e3df03ce3a6e7f2
Signed-off-by: Subramaniam C.A <subramaniam.ca@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
rpmsg: use dev_dbg for channel creation/deletion messages

The number of rpmsg channels is decently high enough during
both the initialization and tear-up/recovery of the remote
processor to effect overall boot time. The trace level of this
print is therefore reduced to improves the overall image init
time. It also helps with the runtime performance of usecases as
they have to create and delete a channel.

Change-Id: I96c293d990bc41f1a9dcd6710ef1388fa2ce2cec
Signed-off-by: Subramaniam C.A <subramaniam.ca@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
rpmsg: fix device definitions in rpmsg client drivers

The rpmsg client drivers - rpmsg_omx, rpmsg_resmgr and the rpmsg
sample drivers - rpmsg_client_sample & rpmsg_server_sample, are
all defining the supported devices incorrectly as a 'platform'
device.

The devices these drivers support should all be 'rpmsg' devices,
and the device id tables declared by these drivers has been
corrected accordingly.

Change-Id: Ib1a0f0de5ffad48fe52937730e90a3254265a2f6
Reported-by: Xavier Boudet <x-boudet@ti.com>
Signed-off-by: Suman Anna <s-anna@ti.com>
omap: remoteproc: add a notification for loading error

When calling rproc_get for the first time, the loading of
the remoteproc image will be requested using a non-blocking
request_firmware_no_wait, and the caller can continue before
the actual loading is complete.

The loader later can return an error due to a non-existing
or wrong image and there should be a way to notify about this
to users having a rproc handle.

This functionality is added and is leveraged by rpmsg to
release some resources it had already acquired since requesting
a firmware load.

Change-Id: I1d3523efbcfd613bca74d363084791ceaaaa9989
Signed-off-by: Miguel Vadillo <vadillo@ti.com>