brcm2708: update linux 4.4 patches to latest version
[openwrt/staging/lynxis/omap.git] / target / linux / brcm2708 / patches-4.4 / 0400-dmaengine-bcm2835-add-dma_memcopy-support-to-bcm2835.patch
1 From ce27d8ba202467a2b811de711ed95d17b2bb27e5 Mon Sep 17 00:00:00 2001
2 From: Martin Sperl <kernel@martin.sperl.org>
3 Date: Wed, 16 Mar 2016 12:25:02 -0700
4 Subject: [PATCH 400/423] dmaengine: bcm2835: add dma_memcopy support to
5 bcm2835-dma
6
7 Also added check for an error condition in bcm2835_dma_create_cb_chain
8 that showed up during development of this patch.
9
10 Tested using dmatest for all enabled channels.
11
12 Signed-off-by: Martin Sperl <kernel@martin.sperl.org>
13 Reviewed-by: Eric Anholt <eric@anholt.net>
14 Signed-off-by: Eric Anholt <eric@anholt.net>
15 Signed-off-by: Vinod Koul <vinod.koul@intel.com>
16 ---
17 drivers/dma/bcm2835-dma.c | 36 +++++++++++++++++++++++++++++++++++-
18 1 file changed, 35 insertions(+), 1 deletion(-)
19
20 --- a/drivers/dma/bcm2835-dma.c
21 +++ b/drivers/dma/bcm2835-dma.c
22 @@ -310,6 +310,9 @@ static struct bcm2835_desc *bcm2835_dma_
23 struct bcm2835_cb_entry *cb_entry;
24 struct bcm2835_dma_cb *control_block;
25
26 + if (!frames)
27 + return NULL;
28 +
29 /* allocate and setup the descriptor. */
30 d = kzalloc(sizeof(*d) + frames * sizeof(struct bcm2835_cb_entry),
31 gfp);
32 @@ -597,6 +600,34 @@ static void bcm2835_dma_issue_pending(st
33 spin_unlock_irqrestore(&c->vc.lock, flags);
34 }
35
36 +struct dma_async_tx_descriptor *bcm2835_dma_prep_dma_memcpy(
37 + struct dma_chan *chan, dma_addr_t dst, dma_addr_t src,
38 + size_t len, unsigned long flags)
39 +{
40 + struct bcm2835_chan *c = to_bcm2835_dma_chan(chan);
41 + struct bcm2835_desc *d;
42 + u32 info = BCM2835_DMA_D_INC | BCM2835_DMA_S_INC;
43 + u32 extra = BCM2835_DMA_INT_EN | BCM2835_DMA_WAIT_RESP;
44 + size_t max_len = bcm2835_dma_max_frame_length(c);
45 + size_t frames;
46 +
47 + /* if src, dst or len is not given return with an error */
48 + if (!src || !dst || !len)
49 + return NULL;
50 +
51 + /* calculate number of frames */
52 + frames = bcm2835_dma_frames_for_length(len, max_len);
53 +
54 + /* allocate the CB chain - this also fills in the pointers */
55 + d = bcm2835_dma_create_cb_chain(chan, DMA_MEM_TO_MEM, false,
56 + info, extra, frames,
57 + src, dst, len, 0, GFP_KERNEL);
58 + if (!d)
59 + return NULL;
60 +
61 + return vchan_tx_prep(&c->vc, &d->vd, flags);
62 +}
63 +
64 static struct dma_async_tx_descriptor *bcm2835_dma_prep_slave_sg(
65 struct dma_chan *chan,
66 struct scatterlist *sgl, unsigned int sg_len,
67 @@ -880,17 +911,20 @@ static int bcm2835_dma_probe(struct plat
68 dma_cap_set(DMA_PRIVATE, od->ddev.cap_mask);
69 dma_cap_set(DMA_CYCLIC, od->ddev.cap_mask);
70 dma_cap_set(DMA_SLAVE, od->ddev.cap_mask);
71 + dma_cap_set(DMA_MEMCPY, od->ddev.cap_mask);
72 od->ddev.device_alloc_chan_resources = bcm2835_dma_alloc_chan_resources;
73 od->ddev.device_free_chan_resources = bcm2835_dma_free_chan_resources;
74 od->ddev.device_tx_status = bcm2835_dma_tx_status;
75 od->ddev.device_issue_pending = bcm2835_dma_issue_pending;
76 od->ddev.device_prep_dma_cyclic = bcm2835_dma_prep_dma_cyclic;
77 od->ddev.device_prep_slave_sg = bcm2835_dma_prep_slave_sg;
78 + od->ddev.device_prep_dma_memcpy = bcm2835_dma_prep_dma_memcpy;
79 od->ddev.device_config = bcm2835_dma_slave_config;
80 od->ddev.device_terminate_all = bcm2835_dma_terminate_all;
81 od->ddev.src_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_4_BYTES);
82 od->ddev.dst_addr_widths = BIT(DMA_SLAVE_BUSWIDTH_4_BYTES);
83 - od->ddev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV);
84 + od->ddev.directions = BIT(DMA_DEV_TO_MEM) | BIT(DMA_MEM_TO_DEV) |
85 + BIT(DMA_MEM_TO_MEM);
86 od->ddev.residue_granularity = DMA_RESIDUE_GRANULARITY_BURST;
87 od->ddev.dev = &pdev->dev;
88 INIT_LIST_HEAD(&od->ddev.channels);