monarudo: fix 2d clocks
msm: clock: Return error upon invalid call to clk_set_rate.

Calls to clk_set_rate should only change the voltage vote if the clock
is prepared. However, they need to check if the rate is valid even if
the clock is not prepared.

Signed-off-by: Patrick Daly <pdaly@codeaurora.org>
(cherry picked from commit c009d9efe966f1f2ac300d43895bb448a9d27cc0)

Signed-off-by: Dhivya Subramanian <dthiru@codeaurora.org>
(cherry picked from commit 8b5d9d1b3b75cf42df5cf1faeda029ebfbdd308e)

Change-Id: I3a80401dcf76314441ad7624c69433c0ea1d1efe
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: clock-debug.c: Display clock vdd fmax values

Display the voltage level a clock votes for debugging.
The currently selected level is shown in square brackets.

Change-Id: I5062c5ea05408c94b63a1eeb376c42da9b7e5908
Signed-off-by: Patrick Daly <pdaly@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/clock.h
msm: clock: Remove warned flag

Now that all clock consumers have moved over to using the
clk_prepare/unprepare APIs we can remove the warned flag that
used to indicate that we had already warned about improper usage
of the clock APIs. In particular, we used this flag to avoid
printing warnings for "source" clocks such as PLLs and
crystals that no consumer directly controls but that the clock
driver calls clk_enable() on during clk_set_rate().

Let's use a local variable for clk->dbg_name too because we use
it many times and it makes lines too long.

Change-Id: I0cb3052fd3dec2e46788fbf039ac73f65551e9f9
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Neha Pandey <nehap@codeaurora.org>

Conflicts:
	arch/arm/mach-msm/clock-7x30.c
	arch/arm/mach-msm/clock-8974.c
	arch/arm/mach-msm/clock-8x60.c
	arch/arm/mach-msm/clock-9615.c
msm: msm_xo: Migrate to new clock APIs

Use the clk_prepare and clk_unprepare APIs to conform with the
changes to the clock APIs.

Change-Id: I3771ab992efcf83838d769776249379d9505ba28
Signed-off-by: Stephen Boyd <sboyd@codeaurora.org>
video: ensure esc_byte_ratio is set before controlling clocks

This was a diff from the correct CAF code and causes us to set
the clock divider incorrectly during the splash screen handoff.
monarudo-panel: set esc_byte_ratio to 2

In HTC's coding wisdom, they had this code in mipi_dsi.c:

        esc_byte_ratio = pinfo->mipi.esc_byte_ratio;
        esc_byte_ratio = 2;

which hard coded the esc_byte_ratio to 2.  Now that we have
changed the code to correctly use the board config, change the
panel's configuration to be 2.
msm_serial_hs: Improve UART Shutdown path

For uart port close operation, serial core calls msm_hs_stop_rx_locked()
which sends discard flush request to ADM driver after changing rx.flush
state machine from FLUSH_NONE to FLUSH_STOP value. Next serial core
calls msm_hs_shutdown()and it waits for discard flush completion with
rx.flush state machine to be set as FLUSH_SHUTDOWN to complete uart
port close operation. With this approach, transfer termination is not
known by UART Core which may still allow UART core to make CRCI request
with ADM Core if new data is being received from remote uart. Hence
invoke Force RxStale from msm_hs_stop_rx_locked() which informs UART
core to terminate current Rx transfer and do not make any new CRCI
request with ADM core for any new incoming data. On receiving RxStale
interrupt, it sends discard flush request to ADM driver to terminate
transfer with ADM hardware.

This new programming sequence is required to get both UART and ADM
hardwares in-sync for termination of transfer.

CRs-Fixed: 475230
Change-Id: I802a456294d4fd2fa51a5f4e918a4f4f22bc5ee3
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
msm_serial_hs: Fixing issue during UART shutdown

During UART port close in msm_hs_shutdown(), flag is_shutdown is
set as true and then UART interrupt is disabled and UART irq line
is freed. This is causing corner case in which even if uart shutdown
is in progress, UART interrupt can come as the UART interrupt is not
disabled and UART irq line not freed at this point. As flag
is_shutdown is set as true in msm_hs_shutdown() and then if UART
interrupt comes, it is hitting BUG_ON in UART Interrupt handler
msm_hs_isr(). To fix this issue, disable the UART irq and free
the UART irq line at the beginning of the msm_hs_shutdown() and
then set the flag is_shutdown.

In msm_hs_shutdown, disabling UART Interrupt and setting flag
is_shutdown is done with uart spinlock acquired. There is a
possibility that on other core, msm_hs_isr() might need to wait
for the same uart spinlock and later when msm_hs_isr() is executed
BUG_ON is hit. As by this time all UART Interrupt is disabled,
hence removing the BUG_ON and instead keep prints to notify the
same.

CRs-Fixed: 487945
Change-Id: I0a19b8f3098f1c9215935ca7fa9d9e5895c44a8c
Signed-off-by: Saket Saurabh <ssaurabh@codeaurora.org>
msm_serial_hs: Use RFR GPIO to communicate remote uart

CTS and RFR GPIOs are used for hardware flow control between
two uarts. RFR GPIO provides current status of uart receiver
to remote uart and based on this remote uart sends data.
Hence use this functionality to prevent remote uart to send
data when port is being opened, baud rate change operation
is in progress and port is being closed.

This change also set UART_DM_MR2 (Bit: 8 and 9) before
configuring connected UART GPIOs to prevent RX_BREAK character
and any character having PARTIY or FRAMING error which can be
generated due to configuration of those GPIOs. Allows those
character once port is opened successfuly.

This change also zeroed uart rx software buffer which would
help to see how many bytes copied by ADM from received data
with UART RX FIFO to this memory. This would be useful if
there is any Rx Stall issue is seen.

CRs-Fixed: 495564
Change-Id: I69382994356073c4c86f205015503c935ad09e8d
Signed-off-by: Mayank Rana <mrana@codeaurora.org>
msm_serial_hs: let bluesleep control uart clock

Change-Id: Ic2664734504085378099c14fe428cf8db2b23725
Merge pull request #25 from crpalmer/bt-sleep

Btluetooth sleep change from M7
Merge pull request #26 from crpalmer/flicker

Flicker
rpm-regulator: unprepare the clock when disabling it

This commit make massive locking changes which cause kernel
panics (scheduling in an atomic context) and a small change
to actually unprepare the tcxo clock.  Manually apply the
small change.

commit d86ca8a2805349c75b84b27f42c4644caf9a8647
Author: David Collins <collinsd@codeaurora.org>
Date:   Wed Oct 17 17:02:11 2012 -0700

    msm: rpm-regulator: Replace spinlocks with mutex locks

    All calls of rpm_vreg_set_voltage() now take place in process
    context.  Clock driver code on all targets has been written so
    that atomic regulator control is no longer needed.

    Refactor the rpm-regulator driver so that a mutex locks are used
    in place of a spinlocks for sleep-selectable regulators which are
    controlled via the rpm_vreg_set_voltage() function.

    At the same time, move clk_prepare() and clk_unprepare calls in
    the TCXO workaround so that these functions are correctly called
    during each workaround invocation.  This is needed so that TCXO
    isn't kept on forever after a single clk_prepare() call.

    Change-Id: I07caed041dac6da073a0644271df2227b6c5a96e
    Signed-off-by: David Collins <collinsd@codeaurora.org>
monarudo-display: panel_power: order of operations based on m7

The M7 display has basically the same set of operations, but they
are performed in a slightly different order with different sleep
values.

Move code around and change the sleeps to match how the M7 turns
the panel power on and off.
monarudo-display: initialize the writeback devices properly

This is taken from the M7 kernel.
monarudo-display: do display_on like the m7 instead of our hacky way

Conflicts:
	arch/arm/mach-msm/board-monarudo-display.c

Conflicts:
	arch/arm/mach-msm/board-monarudo-display.c
msm_fb: remove the monarudo display_on hack

Now that the board-monarudo-display code is turning the display on
correctly, we no longer need these changes to the real fb code.
monarudo-display: change min pwm for backlight

The m7 kernel has some special code for backlights below 21.
To try to fix flickering issues, bump our min up to 21 so that
none of the special code (if it were required) would matter.

I don't think that this is really necessary, so we can try
reverting it later.
monarudo-display: improve the gpio / display handling

* Pull repeated code into a common helper function to make things
  clearer (backlight_gpio_enable)
* Add locking around the display operations.  This shouldn't be
  required but the performance impact is neglible and it can protect
  us if ther are race conditions turning on/off/backlight.
* Add a sleep of 1ms after turning the backlight gpio on/off.
  This matches the gpio on code of the M7

This combination of changes fixes a problem where the backlight
doesn't always get set after moving to the correct display_on
handling (previously it would occasionally end up set to a very
low backlight).

These changes and the related changes based on the M7 kernel may
or may not help improve the flickering issue.  It is too early
to tell.