aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorRabin Vincent <rabin.vincent@stericsson.com>2011-01-25 05:18:26 -0500
committerDan Williams <dan.j.williams@intel.com>2011-01-31 01:27:19 -0500
commit5ed04b8575cb22920b1333aeb55121339449048f (patch)
tree4931e3f65f92da16a1967263b4c0f3623cce144d /drivers
parente24b36bdf873b4a64545fd66da13877214d235cf (diff)
dma40: unify d40_log_sg_to_lli funcs for mem and slave
Acked-by: Per Forlin <per.forlin@stericsson.com> Acked-by: Jonas Aaberg <jonas.aberg@stericsson.com> Signed-off-by: Rabin Vincent <rabin.vincent@stericsson.com> Signed-off-by: Linus Walleij <linus.walleij@stericsson.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/dma/ste_dma40.c41
-rw-r--r--drivers/dma/ste_dma40_ll.c63
-rw-r--r--drivers/dma/ste_dma40_ll.h10
3 files changed, 29 insertions, 85 deletions
diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index 6a7a00d5d682..c597dba713b0 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -1638,37 +1638,28 @@ d40_prep_sg_log(struct d40_chan *chan, struct d40_desc *desc,
1638 unsigned int sg_len, enum dma_data_direction direction, 1638 unsigned int sg_len, enum dma_data_direction direction,
1639 dma_addr_t dev_addr) 1639 dma_addr_t dev_addr)
1640{ 1640{
1641 dma_addr_t src_dev_addr = direction == DMA_FROM_DEVICE ? dev_addr : 0;
1642 dma_addr_t dst_dev_addr = direction == DMA_TO_DEVICE ? dev_addr : 0;
1641 struct stedma40_chan_cfg *cfg = &chan->dma_cfg; 1643 struct stedma40_chan_cfg *cfg = &chan->dma_cfg;
1642 struct stedma40_half_channel_info *src_info = &cfg->src_info; 1644 struct stedma40_half_channel_info *src_info = &cfg->src_info;
1643 struct stedma40_half_channel_info *dst_info = &cfg->dst_info; 1645 struct stedma40_half_channel_info *dst_info = &cfg->dst_info;
1646 int ret;
1644 1647
1645 if (direction == DMA_NONE) { 1648 ret = d40_log_sg_to_lli(sg_src, sg_len,
1646 /* memcpy */ 1649 src_dev_addr,
1647 (void) d40_log_sg_to_lli(sg_src, sg_len, 1650 desc->lli_log.src,
1648 desc->lli_log.src, 1651 chan->log_def.lcsp1,
1649 chan->log_def.lcsp1, 1652 src_info->data_width,
1650 src_info->data_width, 1653 dst_info->data_width);
1651 dst_info->data_width);
1652
1653 (void) d40_log_sg_to_lli(sg_dst, sg_len,
1654 desc->lli_log.dst,
1655 chan->log_def.lcsp3,
1656 dst_info->data_width,
1657 src_info->data_width);
1658 } else {
1659 unsigned int total_size;
1660 1654
1661 total_size = d40_log_sg_to_dev(sg_src, sg_len, 1655 ret = d40_log_sg_to_lli(sg_dst, sg_len,
1662 &desc->lli_log, 1656 dst_dev_addr,
1663 &chan->log_def, 1657 desc->lli_log.dst,
1664 src_info->data_width, 1658 chan->log_def.lcsp3,
1665 dst_info->data_width, 1659 dst_info->data_width,
1666 direction, dev_addr); 1660 src_info->data_width);
1667 if (total_size < 0)
1668 return -EINVAL;
1669 }
1670 1661
1671 return 0; 1662 return ret < 0 ? ret : 0;
1672} 1663}
1673 1664
1674static int 1665static int
diff --git a/drivers/dma/ste_dma40_ll.c b/drivers/dma/ste_dma40_ll.c
index fa6c3ab93fae..9935c6dbcfe0 100644
--- a/drivers/dma/ste_dma40_ll.c
+++ b/drivers/dma/ste_dma40_ll.c
@@ -369,53 +369,6 @@ static void d40_log_fill_lli(struct d40_log_lli *lli,
369 369
370} 370}
371 371
372int d40_log_sg_to_dev(struct scatterlist *sg,
373 int sg_len,
374 struct d40_log_lli_bidir *lli,
375 struct d40_def_lcsp *lcsp,
376 u32 src_data_width,
377 u32 dst_data_width,
378 enum dma_data_direction direction,
379 dma_addr_t dev_addr)
380{
381 int total_size = 0;
382 struct scatterlist *current_sg = sg;
383 int i;
384 struct d40_log_lli *lli_src = lli->src;
385 struct d40_log_lli *lli_dst = lli->dst;
386
387 for_each_sg(sg, current_sg, sg_len, i) {
388 dma_addr_t sg_addr = sg_dma_address(current_sg);
389 unsigned int len = sg_dma_len(current_sg);
390 dma_addr_t src;
391 dma_addr_t dst;
392
393 total_size += len;
394
395 if (direction == DMA_TO_DEVICE) {
396 src = sg_addr;
397 dst = dev_addr;
398 } else {
399 src = dev_addr;
400 dst = sg_addr;
401 }
402
403 lli_src = d40_log_buf_to_lli(lli_src, src, len,
404 lcsp->lcsp1,
405 src_data_width,
406 dst_data_width,
407 src == sg_addr);
408
409 lli_dst = d40_log_buf_to_lli(lli_dst, dst, len,
410 lcsp->lcsp3,
411 dst_data_width,
412 src_data_width,
413 dst == sg_addr);
414 }
415
416 return total_size;
417}
418
419struct d40_log_lli *d40_log_buf_to_lli(struct d40_log_lli *lli_sg, 372struct d40_log_lli *d40_log_buf_to_lli(struct d40_log_lli *lli_sg,
420 dma_addr_t addr, 373 dma_addr_t addr,
421 int size, 374 int size,
@@ -447,6 +400,7 @@ struct d40_log_lli *d40_log_buf_to_lli(struct d40_log_lli *lli_sg,
447 400
448int d40_log_sg_to_lli(struct scatterlist *sg, 401int d40_log_sg_to_lli(struct scatterlist *sg,
449 int sg_len, 402 int sg_len,
403 dma_addr_t dev_addr,
450 struct d40_log_lli *lli_sg, 404 struct d40_log_lli *lli_sg,
451 u32 lcsp13, /* src or dst*/ 405 u32 lcsp13, /* src or dst*/
452 u32 data_width1, u32 data_width2) 406 u32 data_width1, u32 data_width2)
@@ -455,14 +409,21 @@ int d40_log_sg_to_lli(struct scatterlist *sg,
455 struct scatterlist *current_sg = sg; 409 struct scatterlist *current_sg = sg;
456 int i; 410 int i;
457 struct d40_log_lli *lli = lli_sg; 411 struct d40_log_lli *lli = lli_sg;
412 bool autoinc = !dev_addr;
458 413
459 for_each_sg(sg, current_sg, sg_len, i) { 414 for_each_sg(sg, current_sg, sg_len, i) {
415 dma_addr_t sg_addr = sg_dma_address(current_sg);
416 unsigned int len = sg_dma_len(current_sg);
417 dma_addr_t addr = dev_addr ?: sg_addr;
418
460 total_size += sg_dma_len(current_sg); 419 total_size += sg_dma_len(current_sg);
461 lli = d40_log_buf_to_lli(lli, 420
462 sg_dma_address(current_sg), 421 lli = d40_log_buf_to_lli(lli, addr, len,
463 sg_dma_len(current_sg),
464 lcsp13, 422 lcsp13,
465 data_width1, data_width2, true); 423 data_width1,
424 data_width2,
425 autoinc);
466 } 426 }
427
467 return total_size; 428 return total_size;
468} 429}
diff --git a/drivers/dma/ste_dma40_ll.h b/drivers/dma/ste_dma40_ll.h
index 46578a661b28..867f23f6e098 100644
--- a/drivers/dma/ste_dma40_ll.h
+++ b/drivers/dma/ste_dma40_ll.h
@@ -321,17 +321,9 @@ struct d40_log_lli *d40_log_buf_to_lli(struct d40_log_lli *lli_sg,
321 u32 data_width1, u32 data_width2, 321 u32 data_width1, u32 data_width2,
322 bool addr_inc); 322 bool addr_inc);
323 323
324int d40_log_sg_to_dev(struct scatterlist *sg,
325 int sg_len,
326 struct d40_log_lli_bidir *lli,
327 struct d40_def_lcsp *lcsp,
328 u32 src_data_width,
329 u32 dst_data_width,
330 enum dma_data_direction direction,
331 dma_addr_t dev_addr);
332
333int d40_log_sg_to_lli(struct scatterlist *sg, 324int d40_log_sg_to_lli(struct scatterlist *sg,
334 int sg_len, 325 int sg_len,
326 dma_addr_t dev_addr,
335 struct d40_log_lli *lli_sg, 327 struct d40_log_lli *lli_sg,
336 u32 lcsp13, /* src or dst*/ 328 u32 lcsp13, /* src or dst*/
337 u32 data_width1, u32 data_width2); 329 u32 data_width1, u32 data_width2);