dma: mmp_pdma: add protect when alloc/free phy channels

In mmp pdma, phy channels are allocated/freed dynamically
and frequently. But no proper protection is added.
Conflict will happen when multi-users are requesting phy
channels at the same time. Use spinlock to protect.

[zonque@gmail.com: add a jump label in lookup_phy to better
 logically structure the unlocking flow]

Signed-off-by: Xiang Wang <wangx@marvell.com>
dma: mmp_pdma: clear DRCMR when free a phy channel

In mmp pdma, phy channels are allocated/freed dynamically.
The mapping from DMA request to DMA channel number in DRCMR
should be cleared when a phy channel is freed. Otherwise
conflicts will happen when:
1. A is using channel 2 and free it after finished, but A
still maps to channel 2 in DRCMR of A.
2. Now another one B gets channel 2. So B maps to channel 2
too in DRCMR of B.
In the datasheet, it is described that "Do not map two active
requests to the same channel since it produces unpredictable
results" and we can observe that during test.

Signed-off-by: Xiang Wang <wangx@marvell.com>
dma: mmp_pdma: factor out DRCMR register calculation

The exact same calculation is done twice, so let's factor it out to a
macro.

Signed-off-by: Daniel Mack <zonque@gmail.com>
dma: mmp_pdma: fix maximum transfer length

There's no reason for limiting the maximum transfer length to 0x1000.
Take the actual bit mask instead; the PDMA is able to transfer chunks of
up to SZ_8K - 1.

Signed-off-by: Daniel Mack <zonque@gmail.com>
dma: mmp_pdma: add filter function

PXA peripherals need to obtain specific DMA request ids which will
eventually be stored in the DRCMR register.

Currently, clients are expected to store that number inside the slave
config block as slave_id, which is unfortunately incompatible with the
way DMA resources are handled in DT environments.

This patch adds a filter function which stores the filter parameter
passed in by of-dma.c into the channel's drcmr register.

For backward compatability, cfg->slave_id is still used if set to
a non-zero value.

Signed-off-by: Daniel Mack <zonque@gmail.com>
dma: mmp_pdma: make the controller a DMA provider

This patch makes the mmp_pdma controller able to provide DMA resources
in DT environments.

Signed-off-by: Daniel Mack <zonque@gmail.com>
dma: mmp_pdma: print the number of channels at probe time

That helps check the provided runtime information.

Signed-off-by: Daniel Mack <zonque@gmail.com>
dma: mmp_pdma: remove duplicate assignment

The DMA_SLAVE is currently set twice.

Signed-off-by: Daniel Mack <zonque@gmail.com>
dma: mmp_pdma: add support for byte-aligned transfers

The PXA DMA controller has a DALGN register which allows for
byte-aligned DMA transfers. Use it in case any of the transfer
descriptors is not aligned to a mask of ~0x7.

Signed-off-by: Daniel Mack <zonque@gmail.com>
dma: mmp_pdma: implement DMA_PAUSE and DMA_RESUME

This is needed at least for audio operation.

Signed-off-by: Daniel Mack <zonque@gmail.com>
dma: mmp_pdma: add support for residue reporting

In order to report the channel's residue, we have to memorize the first
dma buffer position when the channel is configured.

Signed-off-by: Daniel Mack <zonque@gmail.com>
dma: mmp_pdma: add support for cyclic DMA descriptors

Provide a callback to prepare cyclic DMA transfers.
This is for instance needed for audio channel transport.

Signed-off-by: Daniel Mack <zonque@gmail.com>
mtd: pxa3xx-nand: replace pxa_request_dma with dmaengine

[zonque@gmail.com: rebased in top of l2-mtd.git. The newly introduced
ARCH_HAS_DMA hack was changed into a check for CONFIG_HAS_DMA]

Signed-off-by: Zhangfei Gao <zhangfei.gao@marvell.com>
Signed-off-by: Daniel Mack <zonque@gmail.com>
mtd: pxa3xx-nand: use mmp_pdma_filter_fn and dma_request_slave_channel_compat

Signed-off-by: Daniel Mack <zonque@gmail.com>
ARM: pxa: ssp: add shortcut for &pdev->dev

No functional change, just a cosmetic cleanup.

Signed-off-by: Daniel Mack <zonque@gmail.com>
ARM: pxa: ssp: add DT bindings

This patch adds DT bindings for the pxa ssp driver.

Signed-off-by: Daniel Mack <zonque@gmail.com>
ARM: pxa: ssp: use devm_ functions

Use devm_ functions to allocate memory, ioremap, clk_get etc to clean up
the error unwind path.

Signed-off-by: Daniel Mack <zonque@gmail.com>
tty: serial: pxa: remove old cruft

This #if-0'd block wouldn't compile, so let's dispose it.

Signed-off-by: Daniel Mack <zonque@gmail.com>
spi: spi-pxa2xx: remove legacy PXA DMA bits

Generic DMA support was already implemented by commit cd7bed00
("spi/pxa2xx: break out the private DMA API usage into a separate
file") which moved all the legacy PXA DMA implementation code into
its own file.

With generic DMA available for PXA, we can now just trash this
file.

Signed-off-by: Daniel Mack <zonque@gmail.com>
Cc: Mika Westerberg <mika.westerberg@linux.intel.com>
Acked-by: Mark Brown <broonie@linaro.org>
mmc: host: pxamci: switch over to dmaengine use

Successfully testes on a PXA3xx board.

Signed-off-by: Daniel Mack <zonque@gmail.com>