aboutsummaryrefslogtreecommitdiffstats
path: root/arch/arm/plat-samsung/dma-ops.c
diff options
context:
space:
mode:
authorBoojin Kim <boojin.kim@samsung.com>2012-06-19 00:26:53 -0400
committerKukjin Kim <kgene.kim@samsung.com>2012-06-19 19:07:35 -0400
commitfbb20e81bd26e41667d8d0929fd08ed60b24d9ec (patch)
treeac4c11ddc5d99377018c5bc6b4c05fe5c7281afd /arch/arm/plat-samsung/dma-ops.c
parent485802a6c524e62b5924849dd727ddbb1497cc71 (diff)
ARM: SAMSUNG: Add config() function in DMA common operations
This patch adds config() that configures DMA transmit option. This function was originally included in request(). But, Some DMA client driver requires to change the configuration after request(). So, This patch picks up it from request(). Signed-off-by: Boojin Kim <boojin.kim@samsung.com> Signed-off-by: Kukjin Kim <kgene.kim@samsung.com>
Diffstat (limited to 'arch/arm/plat-samsung/dma-ops.c')
-rw-r--r--arch/arm/plat-samsung/dma-ops.c77
1 files changed, 43 insertions, 34 deletions
diff --git a/arch/arm/plat-samsung/dma-ops.c b/arch/arm/plat-samsung/dma-ops.c
index eb9f4f534006..f9eb353d768c 100644
--- a/arch/arm/plat-samsung/dma-ops.c
+++ b/arch/arm/plat-samsung/dma-ops.c
@@ -19,72 +19,80 @@
19#include <mach/dma.h> 19#include <mach/dma.h>
20 20
21static unsigned samsung_dmadev_request(enum dma_ch dma_ch, 21static unsigned samsung_dmadev_request(enum dma_ch dma_ch,
22 struct samsung_dma_info *info) 22 struct samsung_dma_req *param)
23{ 23{
24 struct dma_chan *chan;
25 dma_cap_mask_t mask; 24 dma_cap_mask_t mask;
26 struct dma_slave_config slave_config;
27 void *filter_param; 25 void *filter_param;
28 26
29 dma_cap_zero(mask); 27 dma_cap_zero(mask);
30 dma_cap_set(info->cap, mask); 28 dma_cap_set(param->cap, mask);
31 29
32 /* 30 /*
33 * If a dma channel property of a device node from device tree is 31 * If a dma channel property of a device node from device tree is
34 * specified, use that as the fliter parameter. 32 * specified, use that as the fliter parameter.
35 */ 33 */
36 filter_param = (dma_ch == DMACH_DT_PROP) ? (void *)info->dt_dmach_prop : 34 filter_param = (dma_ch == DMACH_DT_PROP) ?
37 (void *)dma_ch; 35 (void *)param->dt_dmach_prop : (void *)dma_ch;
38 chan = dma_request_channel(mask, pl330_filter, filter_param); 36 return (unsigned)dma_request_channel(mask, pl330_filter, filter_param);
37}
39 38
40 if (info->direction == DMA_DEV_TO_MEM) { 39static int samsung_dmadev_release(unsigned ch,
40 struct s3c2410_dma_client *client)
41{
42 dma_release_channel((struct dma_chan *)ch);
43
44 return 0;
45}
46
47static int samsung_dmadev_config(unsigned ch,
48 struct samsung_dma_config *param)
49{
50 struct dma_chan *chan = (struct dma_chan *)ch;
51 struct dma_slave_config slave_config;
52
53 if (param->direction == DMA_DEV_TO_MEM) {
41 memset(&slave_config, 0, sizeof(struct dma_slave_config)); 54 memset(&slave_config, 0, sizeof(struct dma_slave_config));
42 slave_config.direction = info->direction; 55 slave_config.direction = param->direction;
43 slave_config.src_addr = info->fifo; 56 slave_config.src_addr = param->fifo;
44 slave_config.src_addr_width = info->width; 57 slave_config.src_addr_width = param->width;
45 slave_config.src_maxburst = 1; 58 slave_config.src_maxburst = 1;
46 dmaengine_slave_config(chan, &slave_config); 59 dmaengine_slave_config(chan, &slave_config);
47 } else if (info->direction == DMA_MEM_TO_DEV) { 60 } else if (param->direction == DMA_MEM_TO_DEV) {
48 memset(&slave_config, 0, sizeof(struct dma_slave_config)); 61 memset(&slave_config, 0, sizeof(struct dma_slave_config));
49 slave_config.direction = info->direction; 62 slave_config.direction = param->direction;
50 slave_config.dst_addr = info->fifo; 63 slave_config.dst_addr = param->fifo;
51 slave_config.dst_addr_width = info->width; 64 slave_config.dst_addr_width = param->width;
52 slave_config.dst_maxburst = 1; 65 slave_config.dst_maxburst = 1;
53 dmaengine_slave_config(chan, &slave_config); 66 dmaengine_slave_config(chan, &slave_config);
67 } else {
68 pr_warn("unsupported direction\n");
69 return -EINVAL;
54 } 70 }
55 71
56 return (unsigned)chan;
57}
58
59static int samsung_dmadev_release(unsigned ch,
60 struct s3c2410_dma_client *client)
61{
62 dma_release_channel((struct dma_chan *)ch);
63
64 return 0; 72 return 0;
65} 73}
66 74
67static int samsung_dmadev_prepare(unsigned ch, 75static int samsung_dmadev_prepare(unsigned ch,
68 struct samsung_dma_prep_info *info) 76 struct samsung_dma_prep *param)
69{ 77{
70 struct scatterlist sg; 78 struct scatterlist sg;
71 struct dma_chan *chan = (struct dma_chan *)ch; 79 struct dma_chan *chan = (struct dma_chan *)ch;
72 struct dma_async_tx_descriptor *desc; 80 struct dma_async_tx_descriptor *desc;
73 81
74 switch (info->cap) { 82 switch (param->cap) {
75 case DMA_SLAVE: 83 case DMA_SLAVE:
76 sg_init_table(&sg, 1); 84 sg_init_table(&sg, 1);
77 sg_dma_len(&sg) = info->len; 85 sg_dma_len(&sg) = param->len;
78 sg_set_page(&sg, pfn_to_page(PFN_DOWN(info->buf)), 86 sg_set_page(&sg, pfn_to_page(PFN_DOWN(param->buf)),
79 info->len, offset_in_page(info->buf)); 87 param->len, offset_in_page(param->buf));
80 sg_dma_address(&sg) = info->buf; 88 sg_dma_address(&sg) = param->buf;
81 89
82 desc = dmaengine_prep_slave_sg(chan, 90 desc = dmaengine_prep_slave_sg(chan,
83 &sg, 1, info->direction, DMA_PREP_INTERRUPT); 91 &sg, 1, param->direction, DMA_PREP_INTERRUPT);
84 break; 92 break;
85 case DMA_CYCLIC: 93 case DMA_CYCLIC:
86 desc = dmaengine_prep_dma_cyclic(chan, 94 desc = dmaengine_prep_dma_cyclic(chan, param->buf,
87 info->buf, info->len, info->period, info->direction); 95 param->len, param->period, param->direction);
88 break; 96 break;
89 default: 97 default:
90 dev_err(&chan->dev->device, "unsupported format\n"); 98 dev_err(&chan->dev->device, "unsupported format\n");
@@ -96,8 +104,8 @@ static int samsung_dmadev_prepare(unsigned ch,
96 return -EFAULT; 104 return -EFAULT;
97 } 105 }
98 106
99 desc->callback = info->fp; 107 desc->callback = param->fp;
100 desc->callback_param = info->fp_param; 108 desc->callback_param = param->fp_param;
101 109
102 dmaengine_submit((struct dma_async_tx_descriptor *)desc); 110 dmaengine_submit((struct dma_async_tx_descriptor *)desc);
103 111
@@ -119,6 +127,7 @@ static inline int samsung_dmadev_flush(unsigned ch)
119static struct samsung_dma_ops dmadev_ops = { 127static struct samsung_dma_ops dmadev_ops = {
120 .request = samsung_dmadev_request, 128 .request = samsung_dmadev_request,
121 .release = samsung_dmadev_release, 129 .release = samsung_dmadev_release,
130 .config = samsung_dmadev_config,
122 .prepare = samsung_dmadev_prepare, 131 .prepare = samsung_dmadev_prepare,
123 .trigger = samsung_dmadev_trigger, 132 .trigger = samsung_dmadev_trigger,
124 .started = NULL, 133 .started = NULL,