*** import of Sony 6.2.B.1.96 LINUX 3.4 sources ***

Change-Id: I84792c25062ba37f9906e159ccbe27d4ccb60750
opensemc: fuji: disable MSM_RTB

Change-Id: If9165cf1edcb4735a5e6139d2cbeb86efc024ad6
mmc: msm_sdcc: Print data line status in case of errors

The MCI_TEST_INPUT register of the SDC controller depicts the status
of the data lines (if pulled down or not). Print its state in cases of
errors to isolate any device specific issues.

CRs-Fixed: 392889
Change-Id: I5d0dbcf3fb606e6a31ede58d7cc6b27f3fb80af7
Signed-off-by: Pratibhasagar V <pratibha@codeaurora.org>
(cherry picked from commit 74bff7cf272ebebc04de8e99a216c32519df52fa)

Signed-off-by: Sivasri Kumar Vanka <sivasri@codeaurora.org>
ASoc: msm: Add low latency playback and recording support.

- Add lowlatency pcm driver for Playback and Recording.
- Add support in target board files
- Add Recording Path to Multimedia5 FE DAI
- Add support in routing, platform, machine drivers
- Add low latency interfaces support in ASM and ADM drivers.

Change-Id: Ia81344ca942c7f53afa4f56e615e004d9518fc81
Signed-off-by: Jayasena Sangaraboina <jsanga@codeaurora.org>
(cherry picked from commit 95afa67e56331aaebc899270294eb335128cd4fa)

Signed-off-by: Sivasri Kumar Vanka <sivasri@codeaurora.org>
(cherry picked from commit 2185ff6161311d29760d04b950978d3349181fb8)

Signed-off-by: Sivasri Kumar Vanka <sivasri@codeaurora.org>
ASoc: msm: Add lowlatency playback and recording routing
controls

- Add BT, FM, PROXY routing controls for lowlatency playback and
  recording

Signed-off-by: Jayasena Sangaraboina <jsanga@codeaurora.org>
(cherry picked from commit b533a1bd441bbf208bb9c954327d07f90dc3de0a)

Change-Id: Ic4a7cad435f93e4f68cc96a670cef437c75e9112
Signed-off-by: Sivasri Kumar Vanka <sivasri@codeaurora.org>
(cherry picked from commit be3e3528762b893e0a251f26f00b106b62c47e85)

Signed-off-by: Sivasri Kumar Vanka <sivasri@codeaurora.org>
ASoC: msm: Update platform drivers to correctly access audio_client

Update platform driver open function call to access
audio_client pointer only after allocation to avoid crash.

Signed-off-by: Ashish Jain <ashishj@codeaurora.org>
(cherry picked from commit 21031b0abd81f3602415ac5735271ddc068b0f8d)

Change-Id: I482e4a0c28214538ece3ed617d9c1006ddd9eaca
Signed-off-by: Sivasri Kumar Vanka <sivasri@codeaurora.org>
ASoC: msm: Add support timestamp update VCAP playback usecase

Compressed data in HDMI IN or VCAP usecase is propagated with
timestamp from DSP with each buffer. For playback, the same or
interpolated timestamp is updated with the corresponding buffer.
DSP will render the buffer a) without any delay if timestamp mode is
synchronous to absolute timestamp b) with a delay if timestamp is more
than the absolute timestamp c) drop the buffer if the timestamp is
less than the absolute timestamp. Add support for the same.

Signed-off-by: Krishnankutty Kolathappilly <kkolat@codeaurora.org>
(cherry picked from commit d04445f5d1fa86d94e98918c2290fc79fdd9c6ad)

Change-Id: I155056aa63b1937163dda2b71ddc209fa3a1abed
Signed-off-by: Sivasri Kumar Vanka <sivasri@codeaurora.org>
ASoC: msm: implement drain command in compress platform driver

Currently, at the end of compress audio playback, session is
terminated without ensuring compressed audio stream is completely
rendered. Use ioctl drain to drain out all the data before EOS is
signalled and session is closed. This is to make sure all the
data is played out by DSP.

CRs-Fixed: 390897
Signed-off-by: Krishnankutty Kolathappilly <kkolat@codeaurora.org>
(cherry picked from commit 6171416a3068a6fa7032c2b7cc9637ac10d2a564)

Change-Id: Iab0132adf6b8bbe888fb344fe4d3ebb9a0bc5490
Signed-off-by: Sivasri Kumar Vanka <sivasri@codeaurora.org>
msm_serial_hs : handle uart_flush_buffer

Serial core allocates circular buffer for uart tx transfer.
Circular buffer head and tail is updated in serial core and
circular buffer tail is updated in uart driver.While uart
transfer is happening, uart client bluetooth hci_ldisc,calls
uart_flush_buffer in serial core and sets circular buffer
head and tail to zero.As uart driver does not know when
uart_flush_buffer is called in serial core by uart client,it
updates circular buffer tail for the previous ADM Tx completion.
This leads to queueing Tx command to ADM although no data is
there in circular buffer.Because of this,uart client is not
functional.

Hence adding msm_hs_flush_buffer api which notifies to uart driver
that uart_flush_buffer is called in serial core by uart client and
set tty_flush_receive flag to true.In uart interrupt handler ,do
not update circular buffer tail if uart_flush_buffer is already
called in serial core by uart client else update circular buffer
tail on ADM Tx completion.

CRs-Fixed: 419054
Signed-off-by: Saket Saurabh <ssaurabh@codeaurora.org>
(cherry picked from commit ce39410ad3db5b9fb446bf5da126585d58fa872a)

Change-Id: I91feb551ee74b8d12993de045176e30d24859f8c
Signed-off-by: Sivasri Kumar Vanka <sivasri@codeaurora.org>
msm_serial_hs: Don't configure gpios into UART Mode always

UARTDM device is used as interface to connect external devices through
GPIOs. Currently those GPIOs are configured in active mode once driver's
probe() is called and configured in suspend mode once its remove() is
called. Probe() is called once only and remove is not called until UARTDM
platform device is removed. With this current implementation, although
external device (ex. Bluetooth SoC) is not operational mode, used UARTDM
GPIOs are configured in active mode which is causing more leakage current
and more power consumption.

Hence configure those UARTDM GPIOs in active mode only when used UARTDM
device is opened and under used. Configure UARTDM GPIOs back to suspend
mode when UARTDM device is closed and under not used.

CRs-Fixed: 422217
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
(cherry picked from commit 40836784d344c6e9def081f47a693488ed2d2857)

Change-Id: Iace76a2cc7ed4d23523ee744b2fb81598eaefada
Signed-off-by: Sivasri Kumar Vanka <sivasri@codeaurora.org>

Conflicts:

	drivers/tty/serial/msm_serial_hs.c
mmc: sdio: fix resume failure

If SDIO keep power flag (MMC_PM_KEEP_POWER) is not set, card would
be reinitialized during resume but as we are not resetting
(CMD52 reset) the SDIO card during this reinitialization, card may
fail to respond back to subsequent commands (CMD5 etc...).

This change resets the card before the reinitialization of card
during resume.

CRs-Fixed: 424805
Signed-off-by: Subhash Jadavani <subhashj@codeaurora.org>
(cherry picked from commit 2679307563a616af7ab189706604a245c6a3be92)

Change-Id: I9043483d7b4b43bbc3ea550d3820a20502f72c5b
Signed-off-by: Sivasri Kumar Vanka <sivasri@codeaurora.org>
base: genlock: handle error while creating lock/handle inode

A lock/handle inode is required in order to successfully create a
new lock/handle. Failure to report the lock/handle inode error can
result in errors for subsequent function calls.

Change-Id: I622af24e695f4781c4dbf46363931a7da09df677
Signed-off-by: Jeff Boody <jboody@codeaurora.org>
msm: Rename pmem variables and macros

Since MSM no longer uses PMEM, the variables, macros, and kernel
config (CONFIG_KERNEL_PMEM_EBI_REGION) relating to PMEM should be
renamed to something more generic.

Change-Id: I4ca909098c96317853d4f040850b63f37db4811e
Signed-off-by: Mitchel Humpherys <mitchelh@codeaurora.org>
ARM: proc: Add Krait proc info

Add processor info for the Qualcomm, Inc. Krait family of
processors, to use the generic ARMv7 initialisation
procedure but explicitly enable the IDIV hardware
capability flag.

Change-Id: I080f60189fada2e4f87c79c6b8ef522cdc070759
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
Revert "Revert "USB: android: Avoid re-enabling the same configuration""

This reverts commit aaa5a3957f37b47215e7ce2904096df2bd90c188.
Revert "USB: android: Avoid re-enabling the same configuration"

Commit d9b1897713 doesn't allow re-enumeration of USB default composition
on bus reset. if adb close and adb open has been called within 1 second
of duration. with adb usb command, it restarts the adb into USB mode after
closing the adb device and re-opening the same within 1 second. To the
user it looks as if command is stuck. Terminating adb usb based command
prompt, killing adb server and doing adb shell again gets the adb
functionality. Here user doesn't see any USB re-enumeration with it. Hence
revert commit d9b1897713 which doesn't block the adb usb command and
re-enumeration of USB.

(cherry picked from commit ff3e0492ee60c8594b3f48eed87e086f4b3d5b0b)

Change-Id: I50ab56f94293b2e02b66c548ee703d26284bcc57
CRs-Fixed: 385973
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
USB: android: Don't disable configuration for every adb close

Certain ADB commands like "adb usb" and "adb root" restart the
adb daemon running on the device.  These commands require USB
bus reset, otherwise adb commands on the host side would stuck
for ever.

USB bus reset can be forced from device side by re-enabling the
same composition.  Earlier, configuration is disabled when adb
daemon closes /dev/android_usb device file.  The configuration
is enabled again after adb daemon opens the device file. This
approach solves the "adb usb" problem with the below side effects.

1. When USB cable is disconnected, the Rx request is flushed and
an error code is returned to user space.  The adb daemon is simply
restarted in this case which cause an unnecessary rebinding of
all functions.
2. The above scenario can happen if host reset the bus when device
is in configured state.  If device disable pull-up during, bus
reset, USB CV CH9 test cases are failing.

The commit d9b1897 (USB: android: Avoid re-enabling the same
configuration) fixed the above side effects. But silently ignores the
original "adb usb" problem.

This commit is another attempt to solve all the above mentioned problems
by forcing re-enumeration only when device is in connected state.  That
means, "adb usb" and "adb root" commands force usb bus reset where as
plugging out a cable does not.

(cherry picked from commit 1aa235a6c0a3d67bff24609766baf5a7d5d8e3e4)

Change-Id: I984f1320c6adfa925ed2f3beca5ae1464981e5fc
CRs-Fixed: 407882
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
USB: android: Fix adb device file closing bug

adb device file closing and config disabling can happen in
parallel during composition switch.  If adb device file
is closed prior to config disable, adb function driver request
android to disable configuration.  But this is not undone later
when adb device file is opened.  Due to this bug config remains
disabled after composition switch completion.  Fix this bug.

(cherry picked from commit c4d8e2ca7cfb2118bcc9f14a97568bfe42b76bcc)

Change-Id: Ia2b7024cfcc438f4e17ca1f165be03abcf380230
CRs-Fixed: 414360
Signed-off-by: Pavankumar Kondeti <pkondeti@codeaurora.org>
msm: cpufreq: fix a race between hotplug and cpufreq

When msm_cpufreq_target() is called without holding the policy
semaphore, there is a rare chance that the cpu gets hotplugged in
the acpuclk_set_rate. The probability of this issue increases
when cross-calling is used or using interactive governor which
tries to set all cpu frequencies from a single thread.

Add a hotplug notifier and set the device_suspended flag holding
the suspend mutex, when cpu is going down. This mutex is always
held when frequency changes are done.

Signed-off-by: Narayanan Gopalakrishnan <nargop@codeaurora.org>
(cherry picked from commit 56f5a6de7f2ab48ed0538da727ad52673fb801a2)

Change-Id: I802c47125c9377f3571ce482c6ecc308f4d4f84c
Signed-off-by: Sridhar Gujje <sgujje@codeaurora.org>
usb: force 500Ma charging current on unknown chargers

- fixes charging with car chargers and unknown wall chargers

Change-Id: I6cfb306d5b01ad1449e989af459f0f5fc35cbfb0