aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma/ste_dma40.c
diff options
context:
space:
mode:
authorRabin Vincent <rabin.vincent@stericsson.com>2011-01-25 05:18:31 -0500
committerDan Williams <dan.j.williams@intel.com>2011-01-31 01:27:20 -0500
commite65889c75ccb5b64dfb60f32e2d9448446cabcc7 (patch)
tree2e9d336969b1e24c965b725aeac8f6223dcee3d8 /drivers/dma/ste_dma40.c
parent7f933bed96e9872131014ea2bdd5b012e43fc316 (diff)
dma40: extract lcla code into separate function
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/dma/ste_dma40.c')
-rw-r--r--drivers/dma/ste_dma40.c92
1 files changed, 50 insertions, 42 deletions
diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index d9dfda2c65b5..4ec96ac1e41a 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -521,54 +521,62 @@ static void d40_phy_lli_load(struct d40_chan *chan, struct d40_desc *desc)
521 writel(lli_dst->reg_lnk, base + D40_CHAN_REG_SDLNK); 521 writel(lli_dst->reg_lnk, base + D40_CHAN_REG_SDLNK);
522} 522}
523 523
524static void d40_desc_load(struct d40_chan *d40c, struct d40_desc *d40d) 524static void d40_log_lli_to_lcxa(struct d40_chan *chan, struct d40_desc *desc)
525{ 525{
526 int curr_lcla = -EINVAL, next_lcla; 526 struct d40_lcla_pool *pool = &chan->base->lcla_pool;
527 527 struct d40_log_lli_bidir *lli = &desc->lli_log;
528 if (chan_is_physical(d40c)) { 528 int lli_current = desc->lli_current;
529 d40_phy_lli_load(d40c, d40d); 529 int lli_len = desc->lli_len;
530 d40d->lli_current = d40d->lli_len; 530 int curr_lcla = -EINVAL;
531 } else { 531
532 532 if (lli_len - lli_current > 1)
533 if ((d40d->lli_len - d40d->lli_current) > 1) 533 curr_lcla = d40_lcla_alloc_one(chan, desc);
534 curr_lcla = d40_lcla_alloc_one(d40c, d40d); 534
535 535 d40_log_lli_lcpa_write(chan->lcpa,
536 d40_log_lli_lcpa_write(d40c->lcpa, 536 &lli->dst[lli_current],
537 &d40d->lli_log.dst[d40d->lli_current], 537 &lli->src[lli_current],
538 &d40d->lli_log.src[d40d->lli_current], 538 curr_lcla);
539 curr_lcla); 539
540 540 lli_current++;
541 d40d->lli_current++; 541 for (; lli_current < lli_len; lli_current++) {
542 for (; d40d->lli_current < d40d->lli_len; d40d->lli_current++) { 542 unsigned int lcla_offset = chan->phy_chan->num * 1024 +
543 unsigned int lcla_offset = d40c->phy_chan->num * 1024 + 543 8 * curr_lcla * 2;
544 8 * curr_lcla * 2; 544 struct d40_log_lli *lcla = pool->base + lcla_offset;
545 struct d40_lcla_pool *pool = &d40c->base->lcla_pool; 545 int next_lcla;
546 struct d40_log_lli *lcla = pool->base + lcla_offset; 546
547 547 if (lli_current + 1 < lli_len)
548 if (d40d->lli_current + 1 < d40d->lli_len) 548 next_lcla = d40_lcla_alloc_one(chan, desc);
549 next_lcla = d40_lcla_alloc_one(d40c, d40d); 549 else
550 else 550 next_lcla = -EINVAL;
551 next_lcla = -EINVAL;
552
553 d40_log_lli_lcla_write(lcla,
554 &d40d->lli_log.dst[d40d->lli_current],
555 &d40d->lli_log.src[d40d->lli_current],
556 next_lcla);
557 551
558 dma_sync_single_range_for_device(d40c->base->dev, 552 d40_log_lli_lcla_write(lcla,
559 pool->dma_addr, lcla_offset, 553 &lli->dst[lli_current],
560 2 * sizeof(struct d40_log_lli), 554 &lli->src[lli_current],
561 DMA_TO_DEVICE); 555 next_lcla);
562 556
563 curr_lcla = next_lcla; 557 dma_sync_single_range_for_device(chan->base->dev,
558 pool->dma_addr, lcla_offset,
559 2 * sizeof(struct d40_log_lli),
560 DMA_TO_DEVICE);
564 561
565 if (curr_lcla == -EINVAL) { 562 curr_lcla = next_lcla;
566 d40d->lli_current++;
567 break;
568 }
569 563
564 if (curr_lcla == -EINVAL) {
565 lli_current++;
566 break;
570 } 567 }
571 } 568 }
569
570 desc->lli_current = lli_current;
571}
572
573static void d40_desc_load(struct d40_chan *d40c, struct d40_desc *d40d)
574{
575 if (chan_is_physical(d40c)) {
576 d40_phy_lli_load(d40c, d40d);
577 d40d->lli_current = d40d->lli_len;
578 } else
579 d40_log_lli_to_lcxa(d40c, d40d);
572} 580}
573 581
574static struct d40_desc *d40_first_active_get(struct d40_chan *d40c) 582static struct d40_desc *d40_first_active_get(struct d40_chan *d40c)