aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--drivers/dma/dw/core.c31
-rw-r--r--drivers/dma/dw/dw.c18
-rw-r--r--drivers/dma/dw/idma32.c13
-rw-r--r--drivers/dma/dw/regs.h11
4 files changed, 47 insertions, 26 deletions
diff --git a/drivers/dma/dw/core.c b/drivers/dma/dw/core.c
index 6a23203e601d..b7e4dab28f8a 100644
--- a/drivers/dma/dw/core.c
+++ b/drivers/dma/dw/core.c
@@ -37,27 +37,6 @@
37 * support descriptor writeback. 37 * support descriptor writeback.
38 */ 38 */
39 39
40#define DWC_DEFAULT_CTLLO(_chan) ({ \
41 struct dw_dma_chan *_dwc = to_dw_dma_chan(_chan); \
42 struct dma_slave_config *_sconfig = &_dwc->dma_sconfig; \
43 bool _is_slave = is_slave_direction(_dwc->direction); \
44 u8 _smsize = _is_slave ? _sconfig->src_maxburst : \
45 DW_DMA_MSIZE_16; \
46 u8 _dmsize = _is_slave ? _sconfig->dst_maxburst : \
47 DW_DMA_MSIZE_16; \
48 u8 _dms = (_dwc->direction == DMA_MEM_TO_DEV) ? \
49 _dwc->dws.p_master : _dwc->dws.m_master; \
50 u8 _sms = (_dwc->direction == DMA_DEV_TO_MEM) ? \
51 _dwc->dws.p_master : _dwc->dws.m_master; \
52 \
53 (DWC_CTLL_DST_MSIZE(_dmsize) \
54 | DWC_CTLL_SRC_MSIZE(_smsize) \
55 | DWC_CTLL_LLP_D_EN \
56 | DWC_CTLL_LLP_S_EN \
57 | DWC_CTLL_DMS(_dms) \
58 | DWC_CTLL_SMS(_sms)); \
59 })
60
61/* The set of bus widths supported by the DMA controller */ 40/* The set of bus widths supported by the DMA controller */
62#define DW_DMA_BUSWIDTHS \ 41#define DW_DMA_BUSWIDTHS \
63 BIT(DMA_SLAVE_BUSWIDTH_UNDEFINED) | \ 42 BIT(DMA_SLAVE_BUSWIDTH_UNDEFINED) | \
@@ -596,7 +575,7 @@ dwc_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
596 575
597 src_width = dst_width = __ffs(data_width | src | dest | len); 576 src_width = dst_width = __ffs(data_width | src | dest | len);
598 577
599 ctllo = DWC_DEFAULT_CTLLO(chan) 578 ctllo = dw->prepare_ctllo(dwc)
600 | DWC_CTLL_DST_WIDTH(dst_width) 579 | DWC_CTLL_DST_WIDTH(dst_width)
601 | DWC_CTLL_SRC_WIDTH(src_width) 580 | DWC_CTLL_SRC_WIDTH(src_width)
602 | DWC_CTLL_DST_INC 581 | DWC_CTLL_DST_INC
@@ -676,10 +655,10 @@ dwc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
676 case DMA_MEM_TO_DEV: 655 case DMA_MEM_TO_DEV:
677 reg_width = __ffs(sconfig->dst_addr_width); 656 reg_width = __ffs(sconfig->dst_addr_width);
678 reg = sconfig->dst_addr; 657 reg = sconfig->dst_addr;
679 ctllo = (DWC_DEFAULT_CTLLO(chan) 658 ctllo = dw->prepare_ctllo(dwc)
680 | DWC_CTLL_DST_WIDTH(reg_width) 659 | DWC_CTLL_DST_WIDTH(reg_width)
681 | DWC_CTLL_DST_FIX 660 | DWC_CTLL_DST_FIX
682 | DWC_CTLL_SRC_INC); 661 | DWC_CTLL_SRC_INC;
683 662
684 ctllo |= sconfig->device_fc ? DWC_CTLL_FC(DW_DMA_FC_P_M2P) : 663 ctllo |= sconfig->device_fc ? DWC_CTLL_FC(DW_DMA_FC_P_M2P) :
685 DWC_CTLL_FC(DW_DMA_FC_D_M2P); 664 DWC_CTLL_FC(DW_DMA_FC_D_M2P);
@@ -726,10 +705,10 @@ slave_sg_todev_fill_desc:
726 case DMA_DEV_TO_MEM: 705 case DMA_DEV_TO_MEM:
727 reg_width = __ffs(sconfig->src_addr_width); 706 reg_width = __ffs(sconfig->src_addr_width);
728 reg = sconfig->src_addr; 707 reg = sconfig->src_addr;
729 ctllo = (DWC_DEFAULT_CTLLO(chan) 708 ctllo = dw->prepare_ctllo(dwc)
730 | DWC_CTLL_SRC_WIDTH(reg_width) 709 | DWC_CTLL_SRC_WIDTH(reg_width)
731 | DWC_CTLL_DST_INC 710 | DWC_CTLL_DST_INC
732 | DWC_CTLL_SRC_FIX); 711 | DWC_CTLL_SRC_FIX;
733 712
734 ctllo |= sconfig->device_fc ? DWC_CTLL_FC(DW_DMA_FC_P_P2M) : 713 ctllo |= sconfig->device_fc ? DWC_CTLL_FC(DW_DMA_FC_P_P2M) :
735 DWC_CTLL_FC(DW_DMA_FC_D_P2M); 714 DWC_CTLL_FC(DW_DMA_FC_D_P2M);
diff --git a/drivers/dma/dw/dw.c b/drivers/dma/dw/dw.c
index 156088f768f2..7a085b3c1854 100644
--- a/drivers/dma/dw/dw.c
+++ b/drivers/dma/dw/dw.c
@@ -4,6 +4,7 @@
4// Copyright (C) 2013,2018 Intel Corporation 4// Copyright (C) 2013,2018 Intel Corporation
5 5
6#include <linux/bitops.h> 6#include <linux/bitops.h>
7#include <linux/dmaengine.h>
7#include <linux/errno.h> 8#include <linux/errno.h>
8#include <linux/slab.h> 9#include <linux/slab.h>
9#include <linux/types.h> 10#include <linux/types.h>
@@ -63,6 +64,22 @@ static size_t dw_dma_block2bytes(struct dw_dma_chan *dwc, u32 block, u32 width)
63 return DWC_CTLH_BLOCK_TS(block) << width; 64 return DWC_CTLH_BLOCK_TS(block) << width;
64} 65}
65 66
67static u32 dw_dma_prepare_ctllo(struct dw_dma_chan *dwc)
68{
69 struct dma_slave_config *sconfig = &dwc->dma_sconfig;
70 bool is_slave = is_slave_direction(dwc->direction);
71 u8 smsize = is_slave ? sconfig->src_maxburst : DW_DMA_MSIZE_16;
72 u8 dmsize = is_slave ? sconfig->dst_maxburst : DW_DMA_MSIZE_16;
73 u8 p_master = dwc->dws.p_master;
74 u8 m_master = dwc->dws.m_master;
75 u8 dms = (dwc->direction == DMA_MEM_TO_DEV) ? p_master : m_master;
76 u8 sms = (dwc->direction == DMA_DEV_TO_MEM) ? p_master : m_master;
77
78 return DWC_CTLL_LLP_D_EN | DWC_CTLL_LLP_S_EN |
79 DWC_CTLL_DST_MSIZE(dmsize) | DWC_CTLL_SRC_MSIZE(smsize) |
80 DWC_CTLL_DMS(dms) | DWC_CTLL_SMS(sms);
81}
82
66static void dw_dma_encode_maxburst(struct dw_dma_chan *dwc, u32 *maxburst) 83static void dw_dma_encode_maxburst(struct dw_dma_chan *dwc, u32 *maxburst)
67{ 84{
68 /* 85 /*
@@ -99,6 +116,7 @@ int dw_dma_probe(struct dw_dma_chip *chip)
99 dw->initialize_chan = dw_dma_initialize_chan; 116 dw->initialize_chan = dw_dma_initialize_chan;
100 dw->suspend_chan = dw_dma_suspend_chan; 117 dw->suspend_chan = dw_dma_suspend_chan;
101 dw->resume_chan = dw_dma_resume_chan; 118 dw->resume_chan = dw_dma_resume_chan;
119 dw->prepare_ctllo = dw_dma_prepare_ctllo;
102 dw->encode_maxburst = dw_dma_encode_maxburst; 120 dw->encode_maxburst = dw_dma_encode_maxburst;
103 dw->bytes2block = dw_dma_bytes2block; 121 dw->bytes2block = dw_dma_bytes2block;
104 dw->block2bytes = dw_dma_block2bytes; 122 dw->block2bytes = dw_dma_block2bytes;
diff --git a/drivers/dma/dw/idma32.c b/drivers/dma/dw/idma32.c
index cd23b9238333..f00657308811 100644
--- a/drivers/dma/dw/idma32.c
+++ b/drivers/dma/dw/idma32.c
@@ -2,6 +2,7 @@
2// Copyright (C) 2013,2018 Intel Corporation 2// Copyright (C) 2013,2018 Intel Corporation
3 3
4#include <linux/bitops.h> 4#include <linux/bitops.h>
5#include <linux/dmaengine.h>
5#include <linux/errno.h> 6#include <linux/errno.h>
6#include <linux/slab.h> 7#include <linux/slab.h>
7#include <linux/types.h> 8#include <linux/types.h>
@@ -69,6 +70,17 @@ static size_t idma32_block2bytes(struct dw_dma_chan *dwc, u32 block, u32 width)
69 return IDMA32C_CTLH_BLOCK_TS(block); 70 return IDMA32C_CTLH_BLOCK_TS(block);
70} 71}
71 72
73static u32 idma32_prepare_ctllo(struct dw_dma_chan *dwc)
74{
75 struct dma_slave_config *sconfig = &dwc->dma_sconfig;
76 bool is_slave = is_slave_direction(dwc->direction);
77 u8 smsize = is_slave ? sconfig->src_maxburst : IDMA32_MSIZE_8;
78 u8 dmsize = is_slave ? sconfig->dst_maxburst : IDMA32_MSIZE_8;
79
80 return DWC_CTLL_LLP_D_EN | DWC_CTLL_LLP_S_EN |
81 DWC_CTLL_DST_MSIZE(dmsize) | DWC_CTLL_SRC_MSIZE(smsize);
82}
83
72static void idma32_encode_maxburst(struct dw_dma_chan *dwc, u32 *maxburst) 84static void idma32_encode_maxburst(struct dw_dma_chan *dwc, u32 *maxburst)
73{ 85{
74 *maxburst = *maxburst > 1 ? fls(*maxburst) - 1 : 0; 86 *maxburst = *maxburst > 1 ? fls(*maxburst) - 1 : 0;
@@ -126,6 +138,7 @@ int idma32_dma_probe(struct dw_dma_chip *chip)
126 dw->initialize_chan = idma32_initialize_chan; 138 dw->initialize_chan = idma32_initialize_chan;
127 dw->suspend_chan = idma32_suspend_chan; 139 dw->suspend_chan = idma32_suspend_chan;
128 dw->resume_chan = idma32_resume_chan; 140 dw->resume_chan = idma32_resume_chan;
141 dw->prepare_ctllo = idma32_prepare_ctllo;
129 dw->encode_maxburst = idma32_encode_maxburst; 142 dw->encode_maxburst = idma32_encode_maxburst;
130 dw->bytes2block = idma32_bytes2block; 143 dw->bytes2block = idma32_bytes2block;
131 dw->block2bytes = idma32_block2bytes; 144 dw->block2bytes = idma32_block2bytes;
diff --git a/drivers/dma/dw/regs.h b/drivers/dma/dw/regs.h
index 6cf299facf45..07f91325e559 100644
--- a/drivers/dma/dw/regs.h
+++ b/drivers/dma/dw/regs.h
@@ -222,6 +222,16 @@ enum dw_dma_msize {
222 222
223/* iDMA 32-bit support */ 223/* iDMA 32-bit support */
224 224
225/* bursts size */
226enum idma32_msize {
227 IDMA32_MSIZE_1,
228 IDMA32_MSIZE_2,
229 IDMA32_MSIZE_4,
230 IDMA32_MSIZE_8,
231 IDMA32_MSIZE_16,
232 IDMA32_MSIZE_32,
233};
234
225/* Bitfields in CTL_HI */ 235/* Bitfields in CTL_HI */
226#define IDMA32C_CTLH_BLOCK_TS_MASK GENMASK(16, 0) 236#define IDMA32C_CTLH_BLOCK_TS_MASK GENMASK(16, 0)
227#define IDMA32C_CTLH_BLOCK_TS(x) ((x) & IDMA32C_CTLH_BLOCK_TS_MASK) 237#define IDMA32C_CTLH_BLOCK_TS(x) ((x) & IDMA32C_CTLH_BLOCK_TS_MASK)
@@ -316,6 +326,7 @@ struct dw_dma {
316 void (*initialize_chan)(struct dw_dma_chan *dwc); 326 void (*initialize_chan)(struct dw_dma_chan *dwc);
317 void (*suspend_chan)(struct dw_dma_chan *dwc, bool drain); 327 void (*suspend_chan)(struct dw_dma_chan *dwc, bool drain);
318 void (*resume_chan)(struct dw_dma_chan *dwc, bool drain); 328 void (*resume_chan)(struct dw_dma_chan *dwc, bool drain);
329 u32 (*prepare_ctllo)(struct dw_dma_chan *dwc);
319 void (*encode_maxburst)(struct dw_dma_chan *dwc, u32 *maxburst); 330 void (*encode_maxburst)(struct dw_dma_chan *dwc, u32 *maxburst);
320 u32 (*bytes2block)(struct dw_dma_chan *dwc, size_t bytes, 331 u32 (*bytes2block)(struct dw_dma_chan *dwc, size_t bytes,
321 unsigned int width, size_t *len); 332 unsigned int width, size_t *len);