aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMaxime Ripard <maxime.ripard@free-electrons.com>2014-11-17 08:42:22 -0500
committerVinod Koul <vinod.koul@intel.com>2014-12-22 01:59:00 -0500
commitf43a6fd400ba66b59bda41e72db2ae1bd5cd549b (patch)
tree05b57443f938aa04dc3928f5f05a60c89704cf5d
parenta0abd6719b73c995eac23aa8835a79f67681e872 (diff)
dmaengine: mmp-tdma: Split device_control
Split the device_control callback of the Marvell MMP TDMA driver to make use of the newly introduced callbacks, that will eventually be used to retrieve slave capabilities. Signed-off-by: Maxime Ripard <maxime.ripard@free-electrons.com> Signed-off-by: Vinod Koul <vinod.koul@intel.com>
-rw-r--r--drivers/dma/mmp_tdma.c82
1 files changed, 44 insertions, 38 deletions
diff --git a/drivers/dma/mmp_tdma.c b/drivers/dma/mmp_tdma.c
index bfb46957c3dc..a8a79b1763d5 100644
--- a/drivers/dma/mmp_tdma.c
+++ b/drivers/dma/mmp_tdma.c
@@ -164,33 +164,46 @@ static void mmp_tdma_enable_chan(struct mmp_tdma_chan *tdmac)
164 tdmac->status = DMA_IN_PROGRESS; 164 tdmac->status = DMA_IN_PROGRESS;
165} 165}
166 166
167static void mmp_tdma_disable_chan(struct mmp_tdma_chan *tdmac) 167static int mmp_tdma_disable_chan(struct dma_chan *chan)
168{ 168{
169 struct mmp_tdma_chan *tdmac = to_mmp_tdma_chan(chan);
170
169 writel(readl(tdmac->reg_base + TDCR) & ~TDCR_CHANEN, 171 writel(readl(tdmac->reg_base + TDCR) & ~TDCR_CHANEN,
170 tdmac->reg_base + TDCR); 172 tdmac->reg_base + TDCR);
171 173
172 tdmac->status = DMA_COMPLETE; 174 tdmac->status = DMA_COMPLETE;
175
176 return 0;
173} 177}
174 178
175static void mmp_tdma_resume_chan(struct mmp_tdma_chan *tdmac) 179static int mmp_tdma_resume_chan(struct dma_chan *chan)
176{ 180{
181 struct mmp_tdma_chan *tdmac = to_mmp_tdma_chan(chan);
182
177 writel(readl(tdmac->reg_base + TDCR) | TDCR_CHANEN, 183 writel(readl(tdmac->reg_base + TDCR) | TDCR_CHANEN,
178 tdmac->reg_base + TDCR); 184 tdmac->reg_base + TDCR);
179 tdmac->status = DMA_IN_PROGRESS; 185 tdmac->status = DMA_IN_PROGRESS;
186
187 return 0;
180} 188}
181 189
182static void mmp_tdma_pause_chan(struct mmp_tdma_chan *tdmac) 190static int mmp_tdma_pause_chan(struct dma_chan *chan)
183{ 191{
192 struct mmp_tdma_chan *tdmac = to_mmp_tdma_chan(chan);
193
184 writel(readl(tdmac->reg_base + TDCR) & ~TDCR_CHANEN, 194 writel(readl(tdmac->reg_base + TDCR) & ~TDCR_CHANEN,
185 tdmac->reg_base + TDCR); 195 tdmac->reg_base + TDCR);
186 tdmac->status = DMA_PAUSED; 196 tdmac->status = DMA_PAUSED;
197
198 return 0;
187} 199}
188 200
189static int mmp_tdma_config_chan(struct mmp_tdma_chan *tdmac) 201static int mmp_tdma_config_chan(struct dma_chan *chan)
190{ 202{
203 struct mmp_tdma_chan *tdmac = to_mmp_tdma_chan(chan);
191 unsigned int tdcr = 0; 204 unsigned int tdcr = 0;
192 205
193 mmp_tdma_disable_chan(tdmac); 206 mmp_tdma_disable_chan(chan);
194 207
195 if (tdmac->dir == DMA_MEM_TO_DEV) 208 if (tdmac->dir == DMA_MEM_TO_DEV)
196 tdcr = TDCR_DSTDIR_ADDR_HOLD | TDCR_SRCDIR_ADDR_INC; 209 tdcr = TDCR_DSTDIR_ADDR_HOLD | TDCR_SRCDIR_ADDR_INC;
@@ -452,42 +465,32 @@ err_out:
452 return NULL; 465 return NULL;
453} 466}
454 467
455static int mmp_tdma_control(struct dma_chan *chan, enum dma_ctrl_cmd cmd, 468static int mmp_tdma_terminate_all(struct dma_chan *chan)
456 unsigned long arg)
457{ 469{
458 struct mmp_tdma_chan *tdmac = to_mmp_tdma_chan(chan); 470 struct mmp_tdma_chan *tdmac = to_mmp_tdma_chan(chan);
459 struct dma_slave_config *dmaengine_cfg = (void *)arg; 471
460 int ret = 0; 472 mmp_tdma_disable_chan(chan);
461 473 /* disable interrupt */
462 switch (cmd) { 474 mmp_tdma_enable_irq(tdmac, false);
463 case DMA_TERMINATE_ALL: 475}
464 mmp_tdma_disable_chan(tdmac); 476
465 /* disable interrupt */ 477static int mmp_tdma_config(struct dma_chan *chan,
466 mmp_tdma_enable_irq(tdmac, false); 478 struct dma_slave_config *dmaengine_cfg)
467 break; 479{
468 case DMA_PAUSE: 480 struct mmp_tdma_chan *tdmac = to_mmp_tdma_chan(chan);
469 mmp_tdma_pause_chan(tdmac); 481
470 break; 482 if (dmaengine_cfg->direction == DMA_DEV_TO_MEM) {
471 case DMA_RESUME: 483 tdmac->dev_addr = dmaengine_cfg->src_addr;
472 mmp_tdma_resume_chan(tdmac); 484 tdmac->burst_sz = dmaengine_cfg->src_maxburst;
473 break; 485 tdmac->buswidth = dmaengine_cfg->src_addr_width;
474 case DMA_SLAVE_CONFIG: 486 } else {
475 if (dmaengine_cfg->direction == DMA_DEV_TO_MEM) { 487 tdmac->dev_addr = dmaengine_cfg->dst_addr;
476 tdmac->dev_addr = dmaengine_cfg->src_addr; 488 tdmac->burst_sz = dmaengine_cfg->dst_maxburst;
477 tdmac->burst_sz = dmaengine_cfg->src_maxburst; 489 tdmac->buswidth = dmaengine_cfg->dst_addr_width;
478 tdmac->buswidth = dmaengine_cfg->src_addr_width;
479 } else {
480 tdmac->dev_addr = dmaengine_cfg->dst_addr;
481 tdmac->burst_sz = dmaengine_cfg->dst_maxburst;
482 tdmac->buswidth = dmaengine_cfg->dst_addr_width;
483 }
484 tdmac->dir = dmaengine_cfg->direction;
485 return mmp_tdma_config_chan(tdmac);
486 default:
487 ret = -ENOSYS;
488 } 490 }
491 tdmac->dir = dmaengine_cfg->direction;
489 492
490 return ret; 493 return mmp_tdma_config_chan(chan);
491} 494}
492 495
493static enum dma_status mmp_tdma_tx_status(struct dma_chan *chan, 496static enum dma_status mmp_tdma_tx_status(struct dma_chan *chan,
@@ -668,7 +671,10 @@ static int mmp_tdma_probe(struct platform_device *pdev)
668 tdev->device.device_prep_dma_cyclic = mmp_tdma_prep_dma_cyclic; 671 tdev->device.device_prep_dma_cyclic = mmp_tdma_prep_dma_cyclic;
669 tdev->device.device_tx_status = mmp_tdma_tx_status; 672 tdev->device.device_tx_status = mmp_tdma_tx_status;
670 tdev->device.device_issue_pending = mmp_tdma_issue_pending; 673 tdev->device.device_issue_pending = mmp_tdma_issue_pending;
671 tdev->device.device_control = mmp_tdma_control; 674 tdev->device.device_config = mmp_tdma_config;
675 tdev->device.device_pause = mmp_tdma_pause_chan;
676 tdev->device.device_resume = mmp_tdma_resume_chan;
677 tdev->device.device_terminate_all = mmp_tdma_terminate_all;
672 tdev->device.copy_align = TDMA_ALIGNMENT; 678 tdev->device.copy_align = TDMA_ALIGNMENT;
673 679
674 dma_set_mask(&pdev->dev, DMA_BIT_MASK(64)); 680 dma_set_mask(&pdev->dev, DMA_BIT_MASK(64));