ARM: dma-mapping: move all dma bounce code to separate dma ops structure

This patch removes dma bounce hooks from the common dma mapping
implementation on ARM architecture and creates a separate set of
dma_map_ops for dma bounce devices.

Change-Id: I42d7869b4f74ffa5f36a4a7526bc0c55aaf6bab7
[lauraa: conflicts due to code cruft]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Tested-By: Subash Patel <subash.ramaswamy@linaro.org>
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
ARM: dma-mapping: remove redundant code and do the cleanup

This patch just performs a global cleanup in DMA mapping implementation
for ARM architecture. Some of the tiny helper functions have been moved
to the caller code, some have been merged together.

Change-Id: I60b3450bd1180ea007e7326a63762d3a44b3c25d
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Tested-By: Subash Patel <subash.ramaswamy@linaro.org>
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
ARM: dma-mapping: use alloc, mmap, free from dma_ops

This patch converts dma_alloc/free/mmap_{coherent,writecombine}
functions to use generic alloc/free/mmap methods from dma_map_ops
structure. A new DMA_ATTR_WRITE_COMBINE DMA attribute have been
introduced to implement writecombine methods.

Change-Id: I2709e3ffc97546df2f505d555b29c3bb8148daec
[lauraa: context conflicts]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Acked-by: Arnd Bergmann <arnd@arndb.de>
Tested-By: Subash Patel <subash.ramaswamy@linaro.org>
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
ARM: dma-mapping: add support for IOMMU mapper

This patch add a complete implementation of DMA-mapping API for
devices which have IOMMU support.

This implementation tries to optimize dma address space usage by remapping
all possible physical memory chunks into a single dma address space chunk.

DMA address space is managed on top of the bitmap stored in the
dma_iommu_mapping structure stored in device->archdata. Platform setup
code has to initialize parameters of the dma address space (base address,
size, allocation precision order) with arm_iommu_create_mapping() function.
To reduce the size of the bitmap, all allocations are aligned to the
specified order of base 4 KiB pages.

dma_alloc_* functions allocate physical memory in chunks, each with
alloc_pages() function to avoid failing if the physical memory gets
fragmented. In worst case the allocated buffer is composed of 4 KiB page
chunks.

dma_map_sg() function minimizes the total number of dma address space
chunks by merging of physical memory chunks into one larger dma address
space chunk. If requested chunk (scatter list entry) boundaries
match physical page boundaries, most calls to dma_map_sg() requests will
result in creating only one chunk in dma address space.

dma_map_page() simply creates a mapping for the given page(s) in the dma
address space.

All dma functions also perform required cache operation like their
counterparts from the arm linear physical memory mapping version.

This patch contains code and fixes kindly provided by:
- Krishna Reddy <vdumpa@nvidia.com>,
- Andrzej Pietrasiewicz <andrzej.p@samsung.com>,
- Hiroshi DOYU <hdoyu@nvidia.com>

Change-Id: I4a9b155bef4d5f2b8a8dfe87751d82960b09b253
[lauraa: context conflicts]
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Acked-by: Kyungmin Park <kyungmin.park@samsung.com>
Reviewed-by: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
Tested-By: Subash Patel <subash.ramaswamy@linaro.org>
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
ARM: dma-mapping: use PMD size for section unmap

The dma_contiguous_remap() function clears existing section maps using
the wrong size (PGDIR_SIZE instead of PMD_SIZE).  This is a bug which
does not affect non-LPAE systems, where PGDIR_SIZE and PMD_SIZE are the same.
On LPAE systems, however, this bug causes the kernel to hang at this point.

This fix has been tested on both LPAE and non-LPAE kernel builds.

Change-Id: I63650057864907f1a2d8eed7257665cb2f648bbb
Signed-off-by: Vitaly Andrianov <vitalya@ti.com>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
ARM: dma-mapping: Add missing static storage class specifier

Fixes the following sparse warnings:
arch/arm/mm/dma-mapping.c:231:15: warning: symbol 'consistent_base' was not
declared. Should it be static?
arch/arm/mm/dma-mapping.c:326:8: warning: symbol 'coherent_pool_size' was not
declared. Should it be static?

Change-Id: I90e2ccdc4d132a37ebcd8ae7a8441ad3fede55bf
Signed-off-by: Sachin Kamat <sachin.kamat@linaro.org>
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
ARM: dma-mapping: fix buffer chunk allocation order

IOMMU-aware dma_alloc_attrs() implementation allocates buffers in
power-of-two chunks to improve performance and take advantage of large
page mappings provided by some IOMMU hardware. However current code, due
to a subtle bug, allocated those chunks in the smallest-to-largest
order, what completely killed all the advantages of using larger than
page chunks. If a 4KiB chunk has been mapped as a first chunk, the
consecutive chunks are not aligned correctly to the power-of-two which
match their size and IOMMU drivers were not able to use internal
mappings of size other than the 4KiB (largest common denominator of
alignment and chunk size).

This patch fixes this issue by changing to the correct largest-to-smallest
chunk size allocation sequence.

Change-Id: I5cc9c12322e832951faf3bba6387946c890e0ed4
Signed-off-by: Marek Szyprowski <m.szyprowski@samsung.com>
Signed-off-by: Laura Abbott <lauraa@codeaurora.org>
spmi: qpnp-int: Support wake interrupts

The irq framework already supports wakeup interrupts. We just
need to provide a dummy irq_set_wake so the framework does not
return an error. Also specify the MASK_ON_SUSPEND flag so that
non-wake interrupts are masked on suspend.

Change-Id: I7fa5717d79467e22647606c3ee93373a2bffc547
Signed-off-by: Michael Bohan <mbohan@codeaurora.org>
vidc: Use correct port setting for encoder during prepare buffer.

When prepare buffer was called for encoder, the port configurations
were swapped. This change corrects this error.

Change-Id: I927cf66666dd02e0f4abbdc9d7be561a857ab2b0
Signed-off-by: Ashray Kulkarni <ashrayk@codeaurora.org>
vidc: Disable venus VBIF dynamic clock gating for video core.

Video core behaviour was inconsistent for different resolutions. This
was due to dynamic clock gating for venus VBIF was enabled. Disable Venus
VBIF clock gating to prevent this inconsistent behaviour.

Change-Id: Id7efd4b7f922efcb77c729f1dc119b1549cb8d74
Signed-off-by: Deva Ramasubramanian <dramasub@codeaurora.org>
Signed-off-by: Vinay Kalia <vkalia@codeaurora.org>
msm: usb_bam : Add support for CI2.0 HSUSB BAM

Add support for both HSUSB and SSUSB BAM devices using device
tree. User can select required BAM device using below commands:
->To select SSUSB BAM:
	echo ssusb > /sys/bus/platform/devices/usb_bam/enable
->To select HSUSB BAM:
	echo hsusb > /sys/bus/platform/devices/usb_bam/enable

On some targets there is no SPS dedicated pipe memory for USB
BAM, hence, allow user to specify the type of memory used by
the BAM devices, which can be one of the type:
-SPS's dedidated pipe memory (DEFAULT), or
-USB Core's dedicated internal memory, or
-System memory that should be allocated by this driver

Change-Id: I5e5421c45fa611bc1ab2cdc81813c77d1329a8af
Signed-off-by: Manu Gautam <mgautam@codeaurora.org>
msm: Change GPIO settings for lower power mode (LPM)

Change gsbi5, gsbi9, gsbi10, GPIO89 and GPIO90 LPM settings to get
250uA power saving in RBSC.

Change-Id: Ic08a2cace8914db201807e611658b9e5406b2ae5
Signed-off-by: Harry Yang <harryy@codeaurora.org>
net: usb: Define waitqueue head as static global variable

usbnet_terminate_urbs() defines waitqueue head as local variable.
There is a possibility that wake_up is called on this queue head
in workqueue context and usbnet_terminate_urbs() already returned
or dev->wait pointer becomes NULL while calling wake_up() from
workqueue context. Hence call wake_up() using waitqueue head
defined as static global variable.

CRs-Fixed: 388724
Change-Id: Ib7e6c3023b9d780af0466496b25e68113b2d3fd3
Signed-off-by: Hemant Kumar <hemantk@codeaurora.org>
msm: camera: Fix lens lock issue in actuator.

The actuator is not able to move beyond one region boundary.
This is because when there is region boundary between current
lens position and destination lens position, the lens is first moved
to region boundary and then moved to the destination target position.
Once region boundary(target lens position in this case) is reached
we should not assume it is the end of total lens movement. So
condition check (curr_lens_pos == target_lens_pos) is wrong. Hence
removing the inaccurate condition check.

Change-Id: I0346277b4e9a3f1e0e4ce7bd11c8dbaacfc288f7
Signed-off-by: Rajakumar Govindaram <rajakuma@codeaurora.org>
msm: kgsl: Change VBIF settings for adreno A330

Limit the number of pending requests from clients to just 1 for
better stability. More agressive values can be set later if things
are found to be stable.

Switch off gating next write request for certain clients, this
setting seems to be stable and should be better for performance

Set the register values for interleaving requests for A330 VBIF.

Do not set VBIF_OUT_AXI_AMEMTYPE_CONF0 since it was
only being set to POR value.

Change-Id: I2152a30b49545fdbf0c147106a088b71ed562e3f
Signed-off-by: Shubhraprakash Das <sadas@codeaurora.org>
Signed-off-by: Harsh Vardhan Dwivedi <hdwivedi@codeaurora.org>
msm: camera: Enhance start stop logic in axi

- Handle RDI start stop separately from PIX
- Add separate call for axi halt
- START_ACK is now redundant because PIX0_REG_UPDATE_ACK
  implies START_ACK.

Change-Id: I84fa25310c4eb27feda65a224bea5bb3f7e32945
Signed-off-by: Nishant Pandit <npandit@codeaurora.org>
camera: Remove isp_sdev for concurrent use case.

For concurrent use case, isp_config & isp_notify
should be specific to each use case, not to each
vfe subdev.

Change-Id: I1d82a37f19e2d824f2971ebf6810f62b816f5712
Signed-off-by: Shuzhen Wang <shuzhenw@codeaurora.org>
camera: vfe32: Init vfe subdev during axi subdev init.

This makes sure vfe subdev is initialized even when
user space doesn't call ioctl to initialize it in RDI
use case.

This is necessary because vfe subdev is used in axi
only case.

Change-Id: I1d8179b28b8cf065b50ae8dabbd14df6cd9a2fef
Signed-off-by: Shuzhen Wang <shuzhenw@codeaurora.org>
msm: camera: Move operation config from vfe to axi and split irq handling

- Move the operation config registers for rdi to axi for concurrent camera
- Split irq as shared and interface specific
- Move AXI related irq handling to AXI subdev.

Change-Id: I108dddadf96b3e987d0a91d0793dc89e815c380f
Signed-off-by: Nishant Pandit <npandit@codeaurora.org>
msm: camera: update rdi frame count from ISPIF SOF.

The RDI frame id count needs to be updated based on SOF
interrupts from ISPIF. This is unlike the PIX count
which can(possibly) depend on SOF interrupts from CAMIF.

Change-Id: I5a69f1d4dcc8aadc6defe896835c59415b84a445
Signed-off-by: Ankit Premrajka <ankitp@codeaurora.org>