msm_serial_hs: Fix synchronization between ADM and UART Cores

With current UART Core programming sequence, it is seen that ADM
and UART Core are going out of sync in few usecases with regression.
It is fixed by using Force RxStale feature of UART Core from
set_termios() and sending discard flush to ADM which would terminate
currently queued UART RX CMD to ADM. Add termios_in_progress check
to make decision about what kind flush to send on receiving RxStale
interrupt. It makes set_termios() more reboust and also keeps ADM
and UART Core in-sync.

Add dma_in_flight to keep check of UART Rx CMD status and BUG_ON if
UART driver is trying to queue one more UART RX CMD to ADM as UART
driver re-uses same UART RX CMD.

This change also adds check of currently set uartclk rate and next
required uartclk rate for new baud rate. If both are same it would
not call clk_set_rate() to set same uartclk rate again.

UART baud rate change request (i.e. executing set_termios()) can come
asynchronously and time to program ADM hardware with queued CMD by ADM
driver is non-deterministic. It is required by UART driver to confirm
that queued RX CMD is programmed with ADM hardware before going with
requested baud rate change operation. Hence this change wait in
set_termios() for ADM driver to program queued RX CMD before going ahead
with baud rate. Otherwise ADM may encounter data bus error with UART RX
channel which is unrecoverable.

Change-Id: I678e91420b33a49ce8b6a5a29c6309f9ff6f5c4a
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
msm_serial_hs: Disable UART RxStale before Force RxStale in set_termios

There is possible race for handling normal RxStale event and Force
Rxstale event with UART Core, when Force RxStale is issued from
set_termios(). Hence on baud rate change request disable RxStale event
mechanism, and invoke Force RxStale. With RxStale event mechanism
disabled, Force RxStale still generates interrupt.

Fix possible race condition if before completion of previous UART RX CMD
flush, set_termios() request is received. With this case it is quite
possible that rx_tlet() queues one UART RX CMD with ADM driver and also
set_termios() queues one more UART RX CMD which would results with
queueing same UART RX CMD twice with ADM driver. With this device would
crash as the ADM driver will not be able to de-reference the second UART
RX CMD work. Hence add check in set_termios with rx.flush value as
FLUSH_DATA_READY which confirms that flush is initiated but it is not
completed and wait for rx.flush to become FLUSH_NONE which would happen
only once flush is completed and new UART RX CMD is being queued with ADM
driver.

Reduce waiting time for discard flush completion as it is already waited
for queued UART Rx CMD to be programmed with ADM hardware. Hence change
wait time out from 300 jiffies to 50 mseconds.

Add an API to get important UART core registers values which can be called
from error condition. Use the same when discard flush timeout happens with
set_termios(), when rx.dma_in_flight is not set with set_termios() and when
multiple UART RX CMD queueing condition is seen in msm_hs_start_rx_locked()
API.

CRs-Fixed: 486260
Change-Id: I9fd17e453fad619609e76e8b3a72a4f47210cff9
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
bluetooth: Remove bluesleep_bcm

Squash of the following commits:

Revert "bluetooth: Fix race conditions in BT LPM"

This reverts commit 096a4f8d351d1ed5e0cfea9dd896b89f78d2f438.

Conflicts:
	drivers/tty/serial/msm_serial_hs.c

Change-Id: Ie9f39e7976b085a80e838bba2bc820f312ee8a71

Revert "bluetooth: Add low-power mode to support Bluedroid"

This reverts commit 595c90c30e5cfa8f91b795fe57a6a796f00beb71.

Conflicts:
	drivers/tty/serial/msm_serial_hs.c

Change-Id: Ia4941f5b650dcd66a32a870e6c726b68dd46329c

Revert "Add bluedroid compatible bluesleep and utilize it."

This reverts commit df67b974ec101f4ee6b241a82313c8e85b44b237.

Change-Id: I7e1dd61062deb071c3a9d00872d63310234060b4
bluetooth: bluesleep: Bluetooth active power management driver

A new driver is implemented to actively manage the bluetooth module
power. bluesleep also tries to manage the power of the transport used.

Two signals (GPIOs) are used to manage the power events.

BT_WAKE  : signal from HOST to BT chip to intimate BT chip can sleep.
HOST_WAKE: signal from BT chip to HOST to intimate HOST should wakeup/
activate the transport modules required for BT communication.

Change-Id: I96202e1cc67dbcbcfa2be874aa2d845e8350f755
bluetooth: Fixed ld mismatched symbols

The driver data structure referenced a function point which is defined
as __init data. This caused symbol mismatch error. This could be fixed
by defined driver data with __init macro, otherwise, by cancel __init on
probe function. Have this done in a safe way.

This file is removed in upstream. It seems that is the only chance to
fix it in our own repository.

Reviewed-on: http://git-master/r/20931
Reviewed-by: David Schalig <dschalig@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Tested-by: Chao Jiang <chaoj@nvidia.com>

Change-Id: I3eba3578c84d8ec67707a276841d72f98c47267d
bluetooth: bluesleep: Exit early if device not registered

If the device isn't registered for this board, return out of the init
function early.

Reviewed-on: http://git-master/r/24254
Reviewed-by: Daniel Willemsen <dwillemsen@nvidia.com>
Tested-by: Daniel Willemsen <dwillemsen@nvidia.com>
Reviewed-by: Anantha Idapalapati <aidapalapati@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>

Change-Id: Ic806b4be1671a77a8fedc1c0376362bc177b0604
bluetooth: bluesleep: add suspend and resume

suspend and resume function() to avoid uart
api call when uart driver is not resumed.

bug 863564

Reviewed-on: http://git-master/r/48716
Reviewed-by: Rakesh Goyal <rgoyal@nvidia.com>
Tested-by: Rakesh Goyal <rgoyal@nvidia.com>
Reviewed-by: Bharat Nihalani <bnihalani@nvidia.com>
Tested-by: Bharat Nihalani <bnihalani@nvidia.com>

Change-Id: I036260f244b2067200050fd5252d91ec23518b86