msm: wfd: Flush encoder before stop.

Flushes the encoder before stop to make
sure that encoder does not hold on to
any input/output buffers.

CRs-Fixed: 366268
Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>
(cherry picked from commit b6dd587b602ab3cf7149fa609cf912820d643577)

Change-Id: Ied753e48376a4a9835b5d598a847341f8d0c0816
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
(cherry picked from commit e142bc3d8f8a28e48ca074fc121caa8139e8ea29)

Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: camera: Adjust exposure setting

While changing between preview and snapshot modes, different
frame length line is configured. Coarse integration time may
become invalid for some frame length line values. Validate and
reconfigure coarse integration time while switching between
modes

CRs-fixed: 356564

Signed-off-by: Sreesudhan Ramakrish Ramkumar <srramku@codeaurora.org>
(cherry picked from commit 6a6ccd619fb9a8317e4f6673b9af76abe213633a)

Change-Id: I739c4c149ac4a9cfa51d7bc838e115479de19eda
msm: dsps: Revise handling of PPSS_PAUSE register.

Only modify the PPSS_PAUSE register if the apps processor controls
the DSPS power state. The Linux kernel shouldn't modify the register
if the DSPS is in control of its own power state.

Also move the definition of the PPSS_PAUSE_REG address to the devices
file, since it may be different on different platforms.

CRs-Fixed: 370236
Signed-off-by: Karthik Karuppasamy <kkaruppa@codeaurora.org>
(cherry picked from commit 9dac549aa64d2d86a156a075de1656cfd38fc60a)

Conflicts:

	arch/arm/mach-msm/devices-msm8x60.c
	arch/arm/mach-msm/include/mach/msm_dsps.h
	arch/arm/mach-msm/msm_dsps.c

Change-Id: I6141df35639d77103d94c13e437161b0afe573d6
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
(cherry picked from commit 74b4dae2862acadad22d91b530dbf3dce12dbebf)

Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: Use immediate operations instead of PC-relative loads

Use immediate operations for creating constants in
__enable_mmu to avoid a situation where the constant area
may not have been fully mapped by the initial identity
mapping.

CRs-Fixed: 375963
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
(cherry picked from commit c00dfe2cd0edb8d891261e7c3f24a50ccd233d17)

Change-Id: Ia607d5580f5ad9b26aff40ad4ff6f3a8f821283c
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
msm: idle-v7: Write Krait-specific bits before WFI

Certain variants of the Krait processor require a
modification of an implementation-defined register prior to
executing the WFI instruction.

Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
(cherry picked from commit ae920e776de8271232a524031f07e9fd605b5b30)

Change-Id: Id9b26685db9a9a8a59fd1ca425c3dd57970a97ff
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
arm: Make the WFE macro unconditional

Remove the condition argument from the WFE macro in the
spinlock code so it can support a WFE fixup needed on
certain Krait CPUs.

Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
(cherry picked from commit 470d134db676e23982676061971a3a201f32b4a6)

Change-Id: Ic5f072ed40d3802b4d0d7f3339d2f5688cebc828
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
arm: Convert spinlocks to new inline assembly style

Refactor the inline assembly code in spinlock.h in
preparation for supporting the Krait safe WFE sequence.

Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
(cherry picked from commit 68e1d7476e66911f9722a5dd82554e883cdb35ba)

Change-Id: I9f98c3a01fa1f0565723e7ba8e5a842a8f05e6b9
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
arm: Support the safe WFE sequence for Krait CPUs

Certain version of the Krait processor require a specific
code sequence to be executed prior to executing a WFE
instruction to permit that instruction to place the
processor into a low-power state.

Change-Id: I614f8ce24936c793c91d5c43c7a7931a04f11dda
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
msm: bam_dmux: Add locking around platform device calls

The channel state is used to determine if a platform device has been
registered on a particular channel.  In the case of a subsystem restart
while a channel is being opened, the subsystem restart can occur between
the channel state being set to opened and the platform device being
added.  This will result in the subsystem restart code seeing that the
channel is open and attempting to remove a platform device that has been
added.

This change adds mutex protection around the channel state updates and
the platform device add/remove calls to handle any race conditions.

CRs-Fixed: 378060
Signed-off-by: Eric Holmberg <eholmber@codeaurora.org>
(cherry picked from commit a623da8bda62e95acf5991905af2847e8e326e09)

Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
(cherry picked from commit 18111f0391832697ed0aaa1212169319328e6a0e)

Change-Id: Id113a056c7955956215a4e8d10355b16e358d9df
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
arm: Don't disable interrupts during WFE fixup

Disabling interrupts during the Krait WFE fixup can result
in deadlock if a thread tries to acquire a spinlock that is
released from an interrupt context. Instead of disabling
interrupts, modify the interrupt handler to reset the fixup
condition to put the processor into a safe state in the
event that the interrupt came in during the fixup window.

CRs-Fixed: 383670
Signed-off-by: Stepan Moskovchenko <stepanm@codeaurora.org>
(cherry picked from commit 1fd137804b489f7a0b4103d846cda13a07e26cdf)

Change-Id: Ie6d1adc42cc0a68bbbaeaa35f18cdda074d66cd5
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm: gpio-v2: Fix spurious interrupts when gpio-irq is unmasked

To unmask a gpio interrupt, the gpio driver sets the
INTR_RAW_STATUS_EN and INTR_ENABLE bits in the INTR_CFG register.
As soon as the INTR_RAW_STATUS_EN is set, the INTR_STATUS is updated
and this causes a spurious interrupt when the irq is enabled.
This is noticed frequently when the gpio is pulled high and requests
a rising edge interrupt or pulled low and is requesting a falling edge
interrupt.
Due the internal circuit design of the TLMM IRQ block, the above method
causes a spurious interrupt when the irq was initialized.
Hence, to avoid this behavior we set the INTR_RAW_STATUS_EN, clear the
INTR_STATUS only once during setup. Every mask and unmask only toggles
the INTR_ENABLE bit.

CRs-Fixed: 346861
Change-Id: Id8353286181fe38a419bd7421518b33f2f8b26aa
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
Signed-off-by: Taniya Das <tdas@codeaurora.org>
msm: gpio-v2: Re-arrange the write to RAW_STATUS_EN

Move enabling the RAW_STATUS_EN at the very beginning.
Hardware team clarified that it is better to write to
RAW_STATUS_EN before writing to any other INTR_CFG bits
in order to prevent spurious interrupts.
Removing writing to the GPIO_INTR_CFG_SU register
during every mask/unmask as it could cause spurious
interrupts as well.

Change-Id: Ifbd991364216ef5f163e5211bc35f7f145c75916
CRs-Fixed: 346861
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
msm: gpio-v2: Clear the interrupt status before unmasking

After the change to keep the RAW_STATUS_EN always on, the
interrupt status bit was latched and could be set during
other (non-interrupt) activity on the GPIO line. This would
end up triggering the interrupt as soon as it was unmasked.
Hence, clear the interrupt status before unmasking the gpio
interrupt.
This keeps the behavior and expectations same as when the
RAW_STATUS_EN was toggled and it prevented the interrupt
status from being updated while the interrupt was masked.

Change-Id: I2bbfa36e4ec0f4a961f05047f4061d7d8fc9fd2f
CRs-Fixed: 346861
Signed-off-by: Rohit Vaswani <rvaswani@codeaurora.org>
msm: camera: Assign Null to unmapped addresses

Observed unhandled virtual addresses with all the camera drivers
while performing reads and writes to the ioremap addresses in different
scenarios, Hence assigining NULL to all the hardware remapped addresses
immediately after the iounmap calls

Signed-off-by: Lakshmi Narayana Kalavala <lkalaval@codeaurora.org>
(cherry picked from commit 72ee044121488cc9f4cde91c5e3a2b820d7a0fad)

Change-Id: Ia0a74ca35e8575b18da8350cb6de83752ee0b11b
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
msm: fix vfe stop sequence.

Fix sequence of register writes during vfe stop. The interrupts
need to be disabled before CAMIF is stopped and AXI
needs to be halted. This ensures that there are no spurious
interrupts.

Change-Id: I3a6813d6cdd2f722fd72b3654fd66fe9721310c8
Signed-off-by: Ankit Premrajka <ankitp@codeaurora.org>
msm: camera: Change CSID configuration

1. Enable CSID irq mask only when debug flag is ON since
we don't handle error irq.
2. Remove unnecessary delay in csi_config.
3. Correct CID configuration for IMX074, IMX091 and
S5K3L1YX sensors.

CRs-fixed: 350008
Signed-off-by: Hody Hung <hhung@codeaurora.org>
(cherry picked from commit df04532712c6001b3b97da479a0a3a6483c35f6f)

Conflicts:

	drivers/media/video/msm/csi/msm_csid.c
	drivers/media/video/msm/sensors/imx091.c

Change-Id: I9317f1227940eae88a7a42af94b3a6a1a3350561
Signed-off-by: Shruthi Krishna <skrish@codeaurora.org>
Signed-off-by: Sudhir Sharma <sudsha@codeaurora.org>
msm: camera: Add proper csid irq release

Whem CSID is released and reopened interrupts
need to be freed and requested to ensure
proper handling of CSID interrupt resource.

Change-Id: Ie74b509236c3b2192563ccbce77bea3ad2797b64
Signed-off-by: Rajakumar Govindaram <rajakuma@codeaurora.org>
msm: camera: stop VPE cleanly when mediaserver crashes.

When mediaserver process crashes, we should disable the VPE first
and then unmap the base register address. Otherwise, subsequent
io reads and writes will cause a kernel fault.

CRs-Fixed: 357592
Signed-off-by: Ankit Premrajka <ankitp@codeaurora.org>
(cherry picked from commit 561894c4f585e277d97fc6147ea2469aff628509)

Change-Id: I13ece1c59f93979b91deafa3cf297e296fb69d3b
Signed-off-by: Ram Kumar Chakravarthy Chebathini <rcheba@codeaurora.org>
msm: fix for HDR with vfe31

On vfe31, we don't get update ack irqs for the frames that are
going to be dropped via the frame skip module. Hence, the snapshot
count decrement logic needs to move to the SOF irq handler to
maintain sanity when taking multiple snapshots in HDR.

Signed-off-by: Ankit Premrajka <ankitp@codeaurora.org>
(cherry picked from commit 227ff128d23fc0f509801562637500744ec03d3b)

Change-Id: Ifd87fbdf046fd633a59e908dfe363dc3f0e6e270
Signed-off-by: Srivalli Oguri <oguri@codeaurora.org>
msm: camera: Handle failure during camera open gracefully.

When the application tries to open the camera device and
the open command sent to the backend fails for some reason,
handle the error gracefully and rollback all the changes
done in the reverse order.

CRs-Fixed: 349291
Change-Id: I446db98512a0ea3b7ce7cfacad2dca45a8b91385
Signed-off-by: Kiran Kumar H N <hurlisal@codeaurora.org>