diff options
author | Viresh Kumar <viresh.kumar@st.com> | 2011-08-05 06:02:39 -0400 |
---|---|---|
committer | Vinod Koul <vinod.koul@intel.com> | 2011-08-25 10:03:39 -0400 |
commit | 03af500f743f486648fc8afc38593e9844411945 (patch) | |
tree | 9fe2cf8cf09d9bdfb1ee6df9fa30c693507496d2 /drivers/dma | |
parent | fa6a940bf129c5417b602a4cdfe88b3dbd8e5898 (diff) |
dmaengine/amba-pl08x: Add prep_single_byte_llis() routine
Code for creating single byte llis is present at several places. Create a
routine to avoid code redundancy.
Also, we don't need one lli per single byte transfer, we can have single lli to
do all single byte transfer.
Signed-off-by: Viresh Kumar <viresh.kumar@st.com>
Acked-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Diffstat (limited to 'drivers/dma')
-rw-r--r-- | drivers/dma/amba-pl08x.c | 61 |
1 files changed, 33 insertions, 28 deletions
diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c index e5930d512b00..45d8a5d5bccd 100644 --- a/drivers/dma/amba-pl08x.c +++ b/drivers/dma/amba-pl08x.c | |||
@@ -559,6 +559,14 @@ static void pl08x_fill_lli_for_desc(struct pl08x_lli_build_data *bd, | |||
559 | bd->remainder -= len; | 559 | bd->remainder -= len; |
560 | } | 560 | } |
561 | 561 | ||
562 | static inline void prep_byte_width_lli(struct pl08x_lli_build_data *bd, | ||
563 | u32 *cctl, u32 len, int num_llis, size_t *total_bytes) | ||
564 | { | ||
565 | *cctl = pl08x_cctl_bits(*cctl, 1, 1, len); | ||
566 | pl08x_fill_lli_for_desc(bd, num_llis, len, *cctl); | ||
567 | (*total_bytes) += len; | ||
568 | } | ||
569 | |||
562 | /* | 570 | /* |
563 | * This fills in the table of LLIs for the transfer descriptor | 571 | * This fills in the table of LLIs for the transfer descriptor |
564 | * Note that we assume we never have to change the burst sizes | 572 | * Note that we assume we never have to change the burst sizes |
@@ -570,7 +578,7 @@ static int pl08x_fill_llis_for_desc(struct pl08x_driver_data *pl08x, | |||
570 | struct pl08x_bus_data *mbus, *sbus; | 578 | struct pl08x_bus_data *mbus, *sbus; |
571 | struct pl08x_lli_build_data bd; | 579 | struct pl08x_lli_build_data bd; |
572 | int num_llis = 0; | 580 | int num_llis = 0; |
573 | u32 cctl; | 581 | u32 cctl, early_bytes = 0; |
574 | size_t max_bytes_per_lli, total_bytes = 0; | 582 | size_t max_bytes_per_lli, total_bytes = 0; |
575 | struct pl08x_lli *llis_va; | 583 | struct pl08x_lli *llis_va; |
576 | 584 | ||
@@ -619,29 +627,27 @@ static int pl08x_fill_llis_for_desc(struct pl08x_driver_data *pl08x, | |||
619 | mbus == &bd.srcbus ? "src" : "dst", | 627 | mbus == &bd.srcbus ? "src" : "dst", |
620 | sbus == &bd.srcbus ? "src" : "dst"); | 628 | sbus == &bd.srcbus ? "src" : "dst"); |
621 | 629 | ||
622 | if (txd->len < mbus->buswidth) { | 630 | /* |
623 | /* Less than a bus width available - send as single bytes */ | 631 | * Send byte by byte for following cases |
624 | while (bd.remainder) { | 632 | * - Less than a bus width available |
625 | dev_vdbg(&pl08x->adev->dev, | 633 | * - until master bus is aligned |
626 | "%s single byte LLIs for a transfer of " | 634 | */ |
627 | "less than a bus width (remain 0x%08x)\n", | 635 | if (bd.remainder < mbus->buswidth) |
628 | __func__, bd.remainder); | 636 | early_bytes = bd.remainder; |
629 | cctl = pl08x_cctl_bits(cctl, 1, 1, 1); | 637 | else if ((mbus->addr) % (mbus->buswidth)) { |
630 | pl08x_fill_lli_for_desc(&bd, num_llis++, 1, cctl); | 638 | early_bytes = mbus->buswidth - (mbus->addr) % (mbus->buswidth); |
631 | total_bytes++; | 639 | if ((bd.remainder - early_bytes) < mbus->buswidth) |
632 | } | 640 | early_bytes = bd.remainder; |
633 | } else { | 641 | } |
634 | /* Make one byte LLIs until master bus is aligned */ | 642 | |
635 | while ((mbus->addr) % (mbus->buswidth)) { | 643 | if (early_bytes) { |
636 | dev_vdbg(&pl08x->adev->dev, | 644 | dev_vdbg(&pl08x->adev->dev, "%s byte width LLIs " |
637 | "%s adjustment lli for less than bus width " | 645 | "(remain 0x%08x)\n", __func__, bd.remainder); |
638 | "(remain 0x%08x)\n", | 646 | prep_byte_width_lli(&bd, &cctl, early_bytes, num_llis++, |
639 | __func__, bd.remainder); | 647 | &total_bytes); |
640 | cctl = pl08x_cctl_bits(cctl, 1, 1, 1); | 648 | } |
641 | pl08x_fill_lli_for_desc(&bd, num_llis++, 1, cctl); | ||
642 | total_bytes++; | ||
643 | } | ||
644 | 649 | ||
650 | if (bd.remainder) { | ||
645 | /* | 651 | /* |
646 | * Master now aligned | 652 | * Master now aligned |
647 | * - if slave is not then we must set its width down | 653 | * - if slave is not then we must set its width down |
@@ -692,13 +698,12 @@ static int pl08x_fill_llis_for_desc(struct pl08x_driver_data *pl08x, | |||
692 | /* | 698 | /* |
693 | * Send any odd bytes | 699 | * Send any odd bytes |
694 | */ | 700 | */ |
695 | while (bd.remainder) { | 701 | if (bd.remainder) { |
696 | cctl = pl08x_cctl_bits(cctl, 1, 1, 1); | ||
697 | dev_vdbg(&pl08x->adev->dev, | 702 | dev_vdbg(&pl08x->adev->dev, |
698 | "%s align with boundary, single odd byte (remain %zu)\n", | 703 | "%s align with boundary, send odd bytes (remain %zu)\n", |
699 | __func__, bd.remainder); | 704 | __func__, bd.remainder); |
700 | pl08x_fill_lli_for_desc(&bd, num_llis++, 1, cctl); | 705 | prep_byte_width_lli(&bd, &cctl, bd.remainder, |
701 | total_bytes++; | 706 | num_llis++, &total_bytes); |
702 | } | 707 | } |
703 | } | 708 | } |
704 | 709 | ||