aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnd Bergmann <arnd@arndb.de>2012-07-10 08:12:05 -0400
committerArnd Bergmann <arnd@arndb.de>2012-07-10 08:12:05 -0400
commit31dfec74c0dc49521b2e17543ff9dd9dd0221702 (patch)
treec97607d7d6db0597dffd2dc96854e706b54a8088
parentbd0a521e88aa7a06ae7aabaed7ae196ed4ad867a (diff)
parent3688be49e901551756f4c570a8eb3b98b1e2bbe5 (diff)
Merge branch 'next/devel-dma-ops' of git://git.kernel.org/pub/scm/linux/kernel/git/kgene/linux-samsung into next/dma
From Kukjin Kim <kgene.kim@samsung.com>: Here is updating DMA common operation for Samsung SoCs. Since some DMA client driver such as spi needs to change the configuration after dma_request() so this branch adds dma_config() can configure DMA transmit option which is included in dma_request() after that. Note, according to the changes, needs to update spi and ASoC drivers for Samsung SoCs and only got the ack from Mark Brown not Grant Likely and as I know, he is busy for moving. But I think, the spi change has no problem and it is simple. * 'next/devel-dma-ops' of git://git.kernel.org/pub/scm/linux/kernel/git/kgene/linux-samsung: ARM: SAMSUNG: Fix compiler warning in dma-ops.c file ASoC: follow the updated samsung DMA common operations spi/s3c64xx: Add the use of DMA config operation ARM: SAMSUNG: Add config() function in DMA common operations Signed-off-by: Arnd Bergmann <arnd@arndb.de>
-rw-r--r--arch/arm/plat-samsung/dma-ops.c76
-rw-r--r--arch/arm/plat-samsung/include/plat/dma-ops.h20
-rw-r--r--arch/arm/plat-samsung/s3c-dma-ops.c39
-rw-r--r--drivers/spi/spi-s3c64xx.c33
-rw-r--r--sound/soc/samsung/dma.c18
5 files changed, 105 insertions, 81 deletions
diff --git a/arch/arm/plat-samsung/dma-ops.c b/arch/arm/plat-samsung/dma-ops.c
index eb9f4f534006..c38d75489240 100644
--- a/arch/arm/plat-samsung/dma-ops.c
+++ b/arch/arm/plat-samsung/dma-ops.c
@@ -19,72 +19,79 @@
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}
38
39static int samsung_dmadev_release(unsigned ch, void *param)
40{
41 dma_release_channel((struct dma_chan *)ch);
39 42
40 if (info->direction == DMA_DEV_TO_MEM) { 43 return 0;
44}
45
46static int samsung_dmadev_config(unsigned ch,
47 struct samsung_dma_config *param)
48{
49 struct dma_chan *chan = (struct dma_chan *)ch;
50 struct dma_slave_config slave_config;
51
52 if (param->direction == DMA_DEV_TO_MEM) {
41 memset(&slave_config, 0, sizeof(struct dma_slave_config)); 53 memset(&slave_config, 0, sizeof(struct dma_slave_config));
42 slave_config.direction = info->direction; 54 slave_config.direction = param->direction;
43 slave_config.src_addr = info->fifo; 55 slave_config.src_addr = param->fifo;
44 slave_config.src_addr_width = info->width; 56 slave_config.src_addr_width = param->width;
45 slave_config.src_maxburst = 1; 57 slave_config.src_maxburst = 1;
46 dmaengine_slave_config(chan, &slave_config); 58 dmaengine_slave_config(chan, &slave_config);
47 } else if (info->direction == DMA_MEM_TO_DEV) { 59 } else if (param->direction == DMA_MEM_TO_DEV) {
48 memset(&slave_config, 0, sizeof(struct dma_slave_config)); 60 memset(&slave_config, 0, sizeof(struct dma_slave_config));
49 slave_config.direction = info->direction; 61 slave_config.direction = param->direction;
50 slave_config.dst_addr = info->fifo; 62 slave_config.dst_addr = param->fifo;
51 slave_config.dst_addr_width = info->width; 63 slave_config.dst_addr_width = param->width;
52 slave_config.dst_maxburst = 1; 64 slave_config.dst_maxburst = 1;
53 dmaengine_slave_config(chan, &slave_config); 65 dmaengine_slave_config(chan, &slave_config);
66 } else {
67 pr_warn("unsupported direction\n");
68 return -EINVAL;
54 } 69 }
55 70
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; 71 return 0;
65} 72}
66 73
67static int samsung_dmadev_prepare(unsigned ch, 74static int samsung_dmadev_prepare(unsigned ch,
68 struct samsung_dma_prep_info *info) 75 struct samsung_dma_prep *param)
69{ 76{
70 struct scatterlist sg; 77 struct scatterlist sg;
71 struct dma_chan *chan = (struct dma_chan *)ch; 78 struct dma_chan *chan = (struct dma_chan *)ch;
72 struct dma_async_tx_descriptor *desc; 79 struct dma_async_tx_descriptor *desc;
73 80
74 switch (info->cap) { 81 switch (param->cap) {
75 case DMA_SLAVE: 82 case DMA_SLAVE:
76 sg_init_table(&sg, 1); 83 sg_init_table(&sg, 1);
77 sg_dma_len(&sg) = info->len; 84 sg_dma_len(&sg) = param->len;
78 sg_set_page(&sg, pfn_to_page(PFN_DOWN(info->buf)), 85 sg_set_page(&sg, pfn_to_page(PFN_DOWN(param->buf)),
79 info->len, offset_in_page(info->buf)); 86 param->len, offset_in_page(param->buf));
80 sg_dma_address(&sg) = info->buf; 87 sg_dma_address(&sg) = param->buf;
81 88
82 desc = dmaengine_prep_slave_sg(chan, 89 desc = dmaengine_prep_slave_sg(chan,
83 &sg, 1, info->direction, DMA_PREP_INTERRUPT); 90 &sg, 1, param->direction, DMA_PREP_INTERRUPT);
84 break; 91 break;
85 case DMA_CYCLIC: 92 case DMA_CYCLIC:
86 desc = dmaengine_prep_dma_cyclic(chan, 93 desc = dmaengine_prep_dma_cyclic(chan, param->buf,
87 info->buf, info->len, info->period, info->direction); 94 param->len, param->period, param->direction);
88 break; 95 break;
89 default: 96 default:
90 dev_err(&chan->dev->device, "unsupported format\n"); 97 dev_err(&chan->dev->device, "unsupported format\n");
@@ -96,8 +103,8 @@ static int samsung_dmadev_prepare(unsigned ch,
96 return -EFAULT; 103 return -EFAULT;
97 } 104 }
98 105
99 desc->callback = info->fp; 106 desc->callback = param->fp;
100 desc->callback_param = info->fp_param; 107 desc->callback_param = param->fp_param;
101 108
102 dmaengine_submit((struct dma_async_tx_descriptor *)desc); 109 dmaengine_submit((struct dma_async_tx_descriptor *)desc);
103 110
@@ -119,6 +126,7 @@ static inline int samsung_dmadev_flush(unsigned ch)
119static struct samsung_dma_ops dmadev_ops = { 126static struct samsung_dma_ops dmadev_ops = {
120 .request = samsung_dmadev_request, 127 .request = samsung_dmadev_request,
121 .release = samsung_dmadev_release, 128 .release = samsung_dmadev_release,
129 .config = samsung_dmadev_config,
122 .prepare = samsung_dmadev_prepare, 130 .prepare = samsung_dmadev_prepare,
123 .trigger = samsung_dmadev_trigger, 131 .trigger = samsung_dmadev_trigger,
124 .started = NULL, 132 .started = NULL,
diff --git a/arch/arm/plat-samsung/include/plat/dma-ops.h b/arch/arm/plat-samsung/include/plat/dma-ops.h
index 71a6827c7706..f5144cdd3001 100644
--- a/arch/arm/plat-samsung/include/plat/dma-ops.h
+++ b/arch/arm/plat-samsung/include/plat/dma-ops.h
@@ -16,7 +16,13 @@
16#include <linux/dmaengine.h> 16#include <linux/dmaengine.h>
17#include <mach/dma.h> 17#include <mach/dma.h>
18 18
19struct samsung_dma_prep_info { 19struct samsung_dma_req {
20 enum dma_transaction_type cap;
21 struct property *dt_dmach_prop;
22 struct s3c2410_dma_client *client;
23};
24
25struct samsung_dma_prep {
20 enum dma_transaction_type cap; 26 enum dma_transaction_type cap;
21 enum dma_transfer_direction direction; 27 enum dma_transfer_direction direction;
22 dma_addr_t buf; 28 dma_addr_t buf;
@@ -26,19 +32,17 @@ struct samsung_dma_prep_info {
26 void *fp_param; 32 void *fp_param;
27}; 33};
28 34
29struct samsung_dma_info { 35struct samsung_dma_config {
30 enum dma_transaction_type cap;
31 enum dma_transfer_direction direction; 36 enum dma_transfer_direction direction;
32 enum dma_slave_buswidth width; 37 enum dma_slave_buswidth width;
33 dma_addr_t fifo; 38 dma_addr_t fifo;
34 struct s3c2410_dma_client *client;
35 struct property *dt_dmach_prop;
36}; 39};
37 40
38struct samsung_dma_ops { 41struct samsung_dma_ops {
39 unsigned (*request)(enum dma_ch ch, struct samsung_dma_info *info); 42 unsigned (*request)(enum dma_ch ch, struct samsung_dma_req *param);
40 int (*release)(unsigned ch, struct s3c2410_dma_client *client); 43 int (*release)(unsigned ch, void *param);
41 int (*prepare)(unsigned ch, struct samsung_dma_prep_info *info); 44 int (*config)(unsigned ch, struct samsung_dma_config *param);
45 int (*prepare)(unsigned ch, struct samsung_dma_prep *param);
42 int (*trigger)(unsigned ch); 46 int (*trigger)(unsigned ch);
43 int (*started)(unsigned ch); 47 int (*started)(unsigned ch);
44 int (*flush)(unsigned ch); 48 int (*flush)(unsigned ch);
diff --git a/arch/arm/plat-samsung/s3c-dma-ops.c b/arch/arm/plat-samsung/s3c-dma-ops.c
index 781494912827..f99448c48d30 100644
--- a/arch/arm/plat-samsung/s3c-dma-ops.c
+++ b/arch/arm/plat-samsung/s3c-dma-ops.c
@@ -36,30 +36,26 @@ static void s3c_dma_cb(struct s3c2410_dma_chan *channel, void *param,
36} 36}
37 37
38static unsigned s3c_dma_request(enum dma_ch dma_ch, 38static unsigned s3c_dma_request(enum dma_ch dma_ch,
39 struct samsung_dma_info *info) 39 struct samsung_dma_req *param)
40{ 40{
41 struct cb_data *data; 41 struct cb_data *data;
42 42
43 if (s3c2410_dma_request(dma_ch, info->client, NULL) < 0) { 43 if (s3c2410_dma_request(dma_ch, param->client, NULL) < 0) {
44 s3c2410_dma_free(dma_ch, info->client); 44 s3c2410_dma_free(dma_ch, param->client);
45 return 0; 45 return 0;
46 } 46 }
47 47
48 if (param->cap == DMA_CYCLIC)
49 s3c2410_dma_setflags(dma_ch, S3C2410_DMAF_CIRCULAR);
50
48 data = kzalloc(sizeof(struct cb_data), GFP_KERNEL); 51 data = kzalloc(sizeof(struct cb_data), GFP_KERNEL);
49 data->ch = dma_ch; 52 data->ch = dma_ch;
50 list_add_tail(&data->node, &dma_list); 53 list_add_tail(&data->node, &dma_list);
51 54
52 s3c2410_dma_devconfig(dma_ch, info->direction, info->fifo);
53
54 if (info->cap == DMA_CYCLIC)
55 s3c2410_dma_setflags(dma_ch, S3C2410_DMAF_CIRCULAR);
56
57 s3c2410_dma_config(dma_ch, info->width);
58
59 return (unsigned)dma_ch; 55 return (unsigned)dma_ch;
60} 56}
61 57
62static int s3c_dma_release(unsigned ch, struct s3c2410_dma_client *client) 58static int s3c_dma_release(unsigned ch, void *param)
63{ 59{
64 struct cb_data *data; 60 struct cb_data *data;
65 61
@@ -68,16 +64,24 @@ static int s3c_dma_release(unsigned ch, struct s3c2410_dma_client *client)
68 break; 64 break;
69 list_del(&data->node); 65 list_del(&data->node);
70 66
71 s3c2410_dma_free(ch, client); 67 s3c2410_dma_free(ch, param);
72 kfree(data); 68 kfree(data);
73 69
74 return 0; 70 return 0;
75} 71}
76 72
77static int s3c_dma_prepare(unsigned ch, struct samsung_dma_prep_info *info) 73static int s3c_dma_config(unsigned ch, struct samsung_dma_config *param)
74{
75 s3c2410_dma_devconfig(ch, param->direction, param->fifo);
76 s3c2410_dma_config(ch, param->width);
77
78 return 0;
79}
80
81static int s3c_dma_prepare(unsigned ch, struct samsung_dma_prep *param)
78{ 82{
79 struct cb_data *data; 83 struct cb_data *data;
80 int len = (info->cap == DMA_CYCLIC) ? info->period : info->len; 84 int len = (param->cap == DMA_CYCLIC) ? param->period : param->len;
81 85
82 list_for_each_entry(data, &dma_list, node) 86 list_for_each_entry(data, &dma_list, node)
83 if (data->ch == ch) 87 if (data->ch == ch)
@@ -85,11 +89,11 @@ static int s3c_dma_prepare(unsigned ch, struct samsung_dma_prep_info *info)
85 89
86 if (!data->fp) { 90 if (!data->fp) {
87 s3c2410_dma_set_buffdone_fn(ch, s3c_dma_cb); 91 s3c2410_dma_set_buffdone_fn(ch, s3c_dma_cb);
88 data->fp = info->fp; 92 data->fp = param->fp;
89 data->fp_param = info->fp_param; 93 data->fp_param = param->fp_param;
90 } 94 }
91 95
92 s3c2410_dma_enqueue(ch, (void *)data, info->buf, len); 96 s3c2410_dma_enqueue(ch, (void *)data, param->buf, len);
93 97
94 return 0; 98 return 0;
95} 99}
@@ -117,6 +121,7 @@ static inline int s3c_dma_stop(unsigned ch)
117static struct samsung_dma_ops s3c_dma_ops = { 121static struct samsung_dma_ops s3c_dma_ops = {
118 .request = s3c_dma_request, 122 .request = s3c_dma_request,
119 .release = s3c_dma_release, 123 .release = s3c_dma_release,
124 .config = s3c_dma_config,
120 .prepare = s3c_dma_prepare, 125 .prepare = s3c_dma_prepare,
121 .trigger = s3c_dma_trigger, 126 .trigger = s3c_dma_trigger,
122 .started = s3c_dma_started, 127 .started = s3c_dma_started,
diff --git a/drivers/spi/spi-s3c64xx.c b/drivers/spi/spi-s3c64xx.c
index 972a94c58be3..3c36cfaa1b93 100644
--- a/drivers/spi/spi-s3c64xx.c
+++ b/drivers/spi/spi-s3c64xx.c
@@ -262,14 +262,24 @@ static void prepare_dma(struct s3c64xx_spi_dma_data *dma,
262 unsigned len, dma_addr_t buf) 262 unsigned len, dma_addr_t buf)
263{ 263{
264 struct s3c64xx_spi_driver_data *sdd; 264 struct s3c64xx_spi_driver_data *sdd;
265 struct samsung_dma_prep_info info; 265 struct samsung_dma_prep info;
266 struct samsung_dma_config config;
266 267
267 if (dma->direction == DMA_DEV_TO_MEM) 268 if (dma->direction == DMA_DEV_TO_MEM) {
268 sdd = container_of((void *)dma, 269 sdd = container_of((void *)dma,
269 struct s3c64xx_spi_driver_data, rx_dma); 270 struct s3c64xx_spi_driver_data, rx_dma);
270 else 271 config.direction = sdd->rx_dma.direction;
272 config.fifo = sdd->sfr_start + S3C64XX_SPI_RX_DATA;
273 config.width = sdd->cur_bpw / 8;
274 sdd->ops->config(sdd->rx_dma.ch, &config);
275 } else {
271 sdd = container_of((void *)dma, 276 sdd = container_of((void *)dma,
272 struct s3c64xx_spi_driver_data, tx_dma); 277 struct s3c64xx_spi_driver_data, tx_dma);
278 config.direction = sdd->tx_dma.direction;
279 config.fifo = sdd->sfr_start + S3C64XX_SPI_TX_DATA;
280 config.width = sdd->cur_bpw / 8;
281 sdd->ops->config(sdd->tx_dma.ch, &config);
282 }
273 283
274 info.cap = DMA_SLAVE; 284 info.cap = DMA_SLAVE;
275 info.len = len; 285 info.len = len;
@@ -284,20 +294,15 @@ static void prepare_dma(struct s3c64xx_spi_dma_data *dma,
284 294
285static int acquire_dma(struct s3c64xx_spi_driver_data *sdd) 295static int acquire_dma(struct s3c64xx_spi_driver_data *sdd)
286{ 296{
287 struct samsung_dma_info info; 297 struct samsung_dma_req req;
288 298
289 sdd->ops = samsung_dma_get_ops(); 299 sdd->ops = samsung_dma_get_ops();
290 300
291 info.cap = DMA_SLAVE; 301 req.cap = DMA_SLAVE;
292 info.client = &s3c64xx_spi_dma_client; 302 req.client = &s3c64xx_spi_dma_client;
293 info.width = sdd->cur_bpw / 8; 303
294 304 sdd->rx_dma.ch = sdd->ops->request(sdd->rx_dma.dmach, &req);
295 info.direction = sdd->rx_dma.direction; 305 sdd->tx_dma.ch = sdd->ops->request(sdd->tx_dma.dmach, &req);
296 info.fifo = sdd->sfr_start + S3C64XX_SPI_RX_DATA;
297 sdd->rx_dma.ch = sdd->ops->request(sdd->rx_dma.dmach, &info);
298 info.direction = sdd->tx_dma.direction;
299 info.fifo = sdd->sfr_start + S3C64XX_SPI_TX_DATA;
300 sdd->tx_dma.ch = sdd->ops->request(sdd->tx_dma.dmach, &info);
301 306
302 return 1; 307 return 1;
303} 308}
diff --git a/sound/soc/samsung/dma.c b/sound/soc/samsung/dma.c
index ddc6cde14e2a..f3ebc38c10fe 100644
--- a/sound/soc/samsung/dma.c
+++ b/sound/soc/samsung/dma.c
@@ -74,7 +74,7 @@ static void dma_enqueue(struct snd_pcm_substream *substream)
74 struct runtime_data *prtd = substream->runtime->private_data; 74 struct runtime_data *prtd = substream->runtime->private_data;
75 dma_addr_t pos = prtd->dma_pos; 75 dma_addr_t pos = prtd->dma_pos;
76 unsigned int limit; 76 unsigned int limit;
77 struct samsung_dma_prep_info dma_info; 77 struct samsung_dma_prep dma_info;
78 78
79 pr_debug("Entered %s\n", __func__); 79 pr_debug("Entered %s\n", __func__);
80 80
@@ -146,7 +146,8 @@ static int dma_hw_params(struct snd_pcm_substream *substream,
146 unsigned long totbytes = params_buffer_bytes(params); 146 unsigned long totbytes = params_buffer_bytes(params);
147 struct s3c_dma_params *dma = 147 struct s3c_dma_params *dma =
148 snd_soc_dai_get_dma_data(rtd->cpu_dai, substream); 148 snd_soc_dai_get_dma_data(rtd->cpu_dai, substream);
149 struct samsung_dma_info dma_info; 149 struct samsung_dma_req req;
150 struct samsung_dma_config config;
150 151
151 pr_debug("Entered %s\n", __func__); 152 pr_debug("Entered %s\n", __func__);
152 153
@@ -166,16 +167,17 @@ static int dma_hw_params(struct snd_pcm_substream *substream,
166 167
167 prtd->params->ops = samsung_dma_get_ops(); 168 prtd->params->ops = samsung_dma_get_ops();
168 169
169 dma_info.cap = (samsung_dma_has_circular() ? 170 req.cap = (samsung_dma_has_circular() ?
170 DMA_CYCLIC : DMA_SLAVE); 171 DMA_CYCLIC : DMA_SLAVE);
171 dma_info.client = prtd->params->client; 172 req.client = prtd->params->client;
172 dma_info.direction = 173 config.direction =
173 (substream->stream == SNDRV_PCM_STREAM_PLAYBACK 174 (substream->stream == SNDRV_PCM_STREAM_PLAYBACK
174 ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM); 175 ? DMA_MEM_TO_DEV : DMA_DEV_TO_MEM);
175 dma_info.width = prtd->params->dma_size; 176 config.width = prtd->params->dma_size;
176 dma_info.fifo = prtd->params->dma_addr; 177 config.fifo = prtd->params->dma_addr;
177 prtd->params->ch = prtd->params->ops->request( 178 prtd->params->ch = prtd->params->ops->request(
178 prtd->params->channel, &dma_info); 179 prtd->params->channel, &req);
180 prtd->params->ops->config(prtd->params->ch, &config);
179 } 181 }
180 182
181 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer); 183 snd_pcm_set_runtime_buffer(substream, &substream->dma_buffer);