msm_serial_hs_lite: Ignore break/error characters in RX queue

Disallow break/framing error characters from entering the
UARTDM RX queue, since this may stall the TX path and
prevent further console messages from being printed.

Change-Id: Ibe20d834978f78e64dcb6abb3d39499e8f8176c6
CRs-Fixed: 359256
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
msm_serial_hs_lite: Read back the NCF register after writing

The UARTDM core requires that the NCF value be read back
after being written to avoid data from being dropped from
the TX queue.

Change-Id: Ia8e9c85982d032ff5b1ca95d2a78c9827a8cbe37
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
msm_serial_hs_lite: Refactor wait_for_xmitr

Remove the second argument to wait_for_xmitr in preparation
for further refactoring of the console code, and because
all call sites wait for the same status bit.

Change-Id: I1688e2bc5048439a98dda7550b43ceaaaa84d437
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
msm_serial_hs_lite: Check SR[TXEMT] in wait_for_xmitr

Use SR[TXEMT] in addition to ISR[TX_READY] when determining
whether new data can be transmitted to work around a
condition where ISR[TX_READY] may not always give an
accurate indication of the state of the queue.

Change-Id: Ia3a590a485647a005c7c019660f11566208c2667
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
msm_serial_hs_lite: Write NCF when initializing the console

The console TX path does not write NCF until after TX_READY
is asserted, meaning that the wait_for_xmitr path could be
polling on a ready bit dictated by the last NCF value set
by the bootloader.

Change-Id: I6d7c9c2610e67d5d84dd2e9b84ee29f94ba4d180
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
msm_serial_hs: Cleanup regarding usage of clock enable/disable apis

Currently driver uses clock apis (clock_enable()/clock_disable()) before
accessing any UART Core register. Hence remove all usage of clock apis
which is just increasing the refcount of uart clock instead of turning
on/off the uart lock.

Change-Id: Idf39108e40b23eb7f17d55470247b339a7850a5f
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
msm_serial_hs: Fix the issue with device unregister/register

UART device can be removed/added dynamically based on the
requirement. Currently removing UART device using
platform_unregister_device(), device is crashing with NULL pointer
dereference error for debugfs entry node. Also add probe function
as __devinit instead of __init section.

Change-Id: I058c9093d79d90eb32fb34835cb4ebb1ef4fa704
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
msm_serial_hs: Release wakelock in case of failure case

msm_hs_init_clk() function is not releasing acquire wakelock
in case of uartclk enable is failing. Hence handle this case
and also correct the error handling in msm_hs_startup function
to release the acquire resources if any error condition encounter.

CRs-Fixed: 348734
Change-Id: Iba822a0bb36f8a6b78279574119bae6db4308c86
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Revert "IKHSS7-15987: Remove serial_hs TX wakelocks and make sure we release rx wakelock in shutdown."

This reverts commit 497ff4812b55cd9ecbcdc16a2695a04933dfabc7.
msm_serial_hs: Use new clock framework apis

Clock framework provides clk_prepare/clk_unprepare (callable from
non-atomic context only) and clk_enable/clk_disable (callable from
atomic/non-atomic context) APIs. Start using these new APIs.

To use these new Clock APIs below changes are done in driver.
1. wakeup irq is converted into wakeup threaded irq.
2. New mutex lock (clk_mutex) is introduced to guard the clock
off/on request and making sure that there is no race condition
exist between these two asynchronous calls.
3. current UART Tx/Rx activities and clock status is checked in
msm_hs_isr() function by calling msm_hs_check_clock_off_locked()
function. Based on the return value of it, clock off timer is
started. Now same functionality is achieved by clock_off_work and
it is used instead of explicit function call.

With these changes, HSUART_DM driver imposes below restrictions on
usage of exported Clock On/Off APIs.
1. Client driver shouldn't call msm_hs_request_clk_on() API from
atomic context. It must be called from non-atomic context.
2. Client driver can call msm_hs_requeset_clk_off() API from
both atomic / non-atomic context.

Change-Id: I75512f488bb53f4f9a08879a1d473706861f5cd4
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
msm_serial_hs: Fix section mismatch

WARNING: drivers/tty/serial/built-in.o(.devinit.text+0x284):
Section mismatch in reference from the function msm_hs_probe() to
the function .init.text:msm_serial_debugfs_init()
The function __devinit msm_hs_probe() references
a function __init msm_serial_debugfs_init().
If msm_serial_debugfs_init is only used by msm_hs_probe then
annotate msm_serial_debugfs_init with a matching annotation.

Change-Id: I2d1aa030e598423cde3f3634ae6e4e35d74b29ed
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
msm: dma: Add graceful argument to msm_dmov_flush

The graceful argument allows clients to specify whether they want
to flush now, or wait until the end of the current scatter gather or
box mode descriptor. This also helps us unify msm_dmov_flush and
msm_dmov_stop_cmd.

Change-Id: Ifdfe5da804e79343782cc2999ad3624d2afbec4d
Signed-off-by: Jeff Ohlstein <johlstei@codeaurora.org>
msm: dma: unify flush and stop_cmd interfaces

Previously there were two interfaces for flushing a channel, the
difference between them being rather ill defined. Both would end up
with the same result if used correctly, and they only varied in error
conditions.

Change-Id: If8dcf1d1b7fc2e7417508b67ca3ceeffe77fa658
Signed-off-by: Jeff Ohlstein <johlstei@codeaurora.org>
msm_serial_hs: Add flush state machine for UART Tx Transfer

Handle below error cases with UART Tx transfer:
1. Application doing I/O to UART port and is being terminated abnormally.
2. Used ADM Channel for UART TX transfer stalls.

In both above conditions, queued Tx command to ADM is not flushed. Hence
restarting of application shows list corruption for queueing next UART
Tx command to ADM. This change fixes it by having state machine for UART
Tx, identifying such condition and flushing the queue Tx command before
closing the UART device.

Change-Id: I4e567a539d890dffed50b5837dde58d5cd62d641
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
Revert "IKHSS7-23775: pm8xxx-adc: Make ADC complete interrupt wakeable"

This reverts commit ad2b34bd2a670e8e83b040c5c7887013a930d478.
Revert "IKHSS7-22454: Add retry mechanism if ADC times out"

This reverts commit f47a53b48404021bf5bb065637b705e934de54b6.
Revert "IKHSS7-22012: Wrap the pm8xxx ADC read function in a wakelock."

This reverts commit db4ed2e6f3833eb786cbc3fbdd0d98b3d256bdcb.
hwmon: pm8xxx-adc: Remove wakelocks

The PM8xxx ADC interrupt is configured as a
wakeable interrupt. Therefore the system can suspend
and still have the end of conversion interrupt be
serviced.

Add a timeout in the wait_for_completion in case
the end of conversion event is not received. This
is to rule out any side affects if a missed interrupt
occurs.

Change-Id: Iad36ad4fb7e550e563f0bf7803d3e5e861b7aacd
Signed-off-by: Siddartha Mohanadoss <smohanad@codeaurora.org>
[moto] pm8xxx-adc: fix missing interrupts

Slightly different than caf commit
f5285a2ed7918b941ac260e078c64c534a1d0e8d

Change-Id: I035f664e66807d93c866fd2af1ab289e609d8abb
[moto] Update emu-det driver

Change-Id: Ibdfc8649f7fc5d64085036ba141916379c12104f