aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/dma/at_xdmac.c
diff options
context:
space:
mode:
authorMaxime Ripard <maxime.ripard@free-electrons.com>2015-05-27 10:01:52 -0400
committerVinod Koul <vinod.koul@intel.com>2015-06-12 08:43:13 -0400
commit87d001ef5366c4a24f7a1340246c4ce68190581c (patch)
tree2a4b7fdfc6d18461ab5562ab1f01f4505349e5ae /drivers/dma/at_xdmac.c
parent6007ccb57744fdd393385b135e7b7cea9bd4bd6b (diff)
dmaengine: Move icg helpers to global header
Now that we can have ICGs set for both the source and destination (using the icg field of struct data_chunk) or for only the source or the destination (using the dst_icg or src_icg respectively), and that these fields can be ignored depending on other parameters (src_inc, src_sgl, etc.), the logic to get the actual ICG value can be quite tricky. The XDMAC driver was already implementing it, but since we will need it in other drivers, we can move it to the main header file. Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> Acked-by: Ludovic Desroches <ludovic.desroches@atmel.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
Diffstat (limited to 'drivers/dma/at_xdmac.c')
-rw-r--r--drivers/dma/at_xdmac.c46
1 files changed, 4 insertions, 42 deletions
diff --git a/drivers/dma/at_xdmac.c b/drivers/dma/at_xdmac.c
index 9b602a67d40d..80e46e571bdd 100644
--- a/drivers/dma/at_xdmac.c
+++ b/drivers/dma/at_xdmac.c
@@ -862,20 +862,8 @@ at_xdmac_interleaved_queue_desc(struct dma_chan *chan,
862 862
863 desc->lld.mbr_sa = src; 863 desc->lld.mbr_sa = src;
864 desc->lld.mbr_da = dst; 864 desc->lld.mbr_da = dst;
865 865 desc->lld.mbr_sus = dmaengine_get_src_icg(xt, chunk);
866 if (xt->src_inc && xt->src_sgl) { 866 desc->lld.mbr_dus = dmaengine_get_dst_icg(xt, chunk);
867 if (chunk->src_icg)
868 desc->lld.mbr_sus = chunk->src_icg;
869 else
870 desc->lld.mbr_sus = chunk->icg;
871 }
872
873 if (xt->dst_inc && xt->dst_sgl) {
874 if (chunk->dst_icg)
875 desc->lld.mbr_dus = chunk->dst_icg;
876 else
877 desc->lld.mbr_dus = chunk->icg;
878 }
879 867
880 desc->lld.mbr_ubc = AT_XDMAC_MBR_UBC_NDV3 868 desc->lld.mbr_ubc = AT_XDMAC_MBR_UBC_NDV3
881 | AT_XDMAC_MBR_UBC_NDEN 869 | AT_XDMAC_MBR_UBC_NDEN
@@ -895,32 +883,6 @@ at_xdmac_interleaved_queue_desc(struct dma_chan *chan,
895 return desc; 883 return desc;
896} 884}
897 885
898static size_t at_xdmac_get_icg(bool inc, bool sgl, size_t icg, size_t dir_icg)
899{
900 if (inc) {
901 if (dir_icg)
902 return dir_icg;
903 else if (sgl)
904 return icg;
905 }
906
907 return 0;
908}
909
910static size_t at_xdmac_get_dst_icg(struct dma_interleaved_template *xt,
911 struct data_chunk *chunk)
912{
913 return at_xdmac_get_icg(xt->dst_inc, xt->dst_sgl,
914 chunk->icg, chunk->dst_icg);
915}
916
917static size_t at_xdmac_get_src_icg(struct dma_interleaved_template *xt,
918 struct data_chunk *chunk)
919{
920 return at_xdmac_get_icg(xt->src_inc, xt->src_sgl,
921 chunk->icg, chunk->src_icg);
922}
923
924static struct dma_async_tx_descriptor * 886static struct dma_async_tx_descriptor *
925at_xdmac_prep_interleaved(struct dma_chan *chan, 887at_xdmac_prep_interleaved(struct dma_chan *chan,
926 struct dma_interleaved_template *xt, 888 struct dma_interleaved_template *xt,
@@ -950,8 +912,8 @@ at_xdmac_prep_interleaved(struct dma_chan *chan,
950 912
951 chunk = xt->sgl + i; 913 chunk = xt->sgl + i;
952 914
953 dst_icg = at_xdmac_get_dst_icg(xt, chunk); 915 dst_icg = dmaengine_get_dst_icg(xt, chunk);
954 src_icg = at_xdmac_get_src_icg(xt, chunk); 916 src_icg = dmaengine_get_src_icg(xt, chunk);
955 917
956 src_skip = chunk->size + src_icg; 918 src_skip = chunk->size + src_icg;
957 dst_skip = chunk->size + dst_icg; 919 dst_skip = chunk->size + dst_icg;