Commit 0e79f9ae1610c15f5e5959c39d7c39071619de97
Committed by
Vinod Koul
1 parent
1ff8df4f53
Exists in
smarc-l5.0.0_1.0.0-ga
and in
5 other branches
mmc: sh_mmcif: switch to the new DMA channel allocation and configuration
Using the "private" field from struct dma_chan is deprecated. The sh dmaengine driver now also supports the preferred DMA channel allocation and configuration method, using a standard filter function and a channel configuration operation. This patch updates sh_mmcif to use this new method. Signed-off-by: Guennadi Liakhovetski <g.liakhovetski@gmx.de> Cc: Chris Ball <cjb@laptop.org> Signed-off-by: Vinod Koul <vinod.koul@linux.intel.com>
Showing 1 changed file with 47 additions and 35 deletions Side-by-side Diff
drivers/mmc/host/sh_mmcif.c
... | ... | @@ -211,8 +211,6 @@ |
211 | 211 | struct mmc_host *mmc; |
212 | 212 | struct mmc_request *mrq; |
213 | 213 | struct platform_device *pd; |
214 | - struct sh_dmae_slave dma_slave_tx; | |
215 | - struct sh_dmae_slave dma_slave_rx; | |
216 | 214 | struct clk *hclk; |
217 | 215 | unsigned int clk; |
218 | 216 | int bus_width; |
219 | 217 | |
220 | 218 | |
221 | 219 | |
222 | 220 | |
223 | 221 | |
224 | 222 | |
225 | 223 | |
226 | 224 | |
227 | 225 | |
228 | 226 | |
... | ... | @@ -371,52 +369,66 @@ |
371 | 369 | desc, cookie); |
372 | 370 | } |
373 | 371 | |
374 | -static bool sh_mmcif_filter(struct dma_chan *chan, void *arg) | |
375 | -{ | |
376 | - dev_dbg(chan->device->dev, "%s: slave data %p\n", __func__, arg); | |
377 | - chan->private = arg; | |
378 | - return true; | |
379 | -} | |
380 | - | |
381 | 372 | static void sh_mmcif_request_dma(struct sh_mmcif_host *host, |
382 | 373 | struct sh_mmcif_plat_data *pdata) |
383 | 374 | { |
384 | - struct sh_dmae_slave *tx, *rx; | |
375 | + struct resource *res = platform_get_resource(host->pd, IORESOURCE_MEM, 0); | |
376 | + struct dma_slave_config cfg; | |
377 | + dma_cap_mask_t mask; | |
378 | + int ret; | |
379 | + | |
385 | 380 | host->dma_active = false; |
386 | 381 | |
382 | + if (pdata->slave_id_tx <= 0 || pdata->slave_id_rx <= 0) | |
383 | + return; | |
384 | + | |
387 | 385 | /* We can only either use DMA for both Tx and Rx or not use it at all */ |
388 | - tx = &host->dma_slave_tx; | |
389 | - tx->shdma_slave.slave_id = pdata->slave_id_tx; | |
390 | - rx = &host->dma_slave_rx; | |
391 | - rx->shdma_slave.slave_id = pdata->slave_id_rx; | |
386 | + dma_cap_zero(mask); | |
387 | + dma_cap_set(DMA_SLAVE, mask); | |
392 | 388 | |
393 | - if (tx->shdma_slave.slave_id > 0 && rx->shdma_slave.slave_id > 0) { | |
394 | - dma_cap_mask_t mask; | |
389 | + host->chan_tx = dma_request_channel(mask, shdma_chan_filter, | |
390 | + (void *)pdata->slave_id_tx); | |
391 | + dev_dbg(&host->pd->dev, "%s: TX: got channel %p\n", __func__, | |
392 | + host->chan_tx); | |
395 | 393 | |
396 | - dma_cap_zero(mask); | |
397 | - dma_cap_set(DMA_SLAVE, mask); | |
394 | + if (!host->chan_tx) | |
395 | + return; | |
398 | 396 | |
399 | - host->chan_tx = dma_request_channel(mask, sh_mmcif_filter, | |
400 | - &tx->shdma_slave); | |
401 | - dev_dbg(&host->pd->dev, "%s: TX: got channel %p\n", __func__, | |
402 | - host->chan_tx); | |
397 | + cfg.slave_id = pdata->slave_id_tx; | |
398 | + cfg.direction = DMA_MEM_TO_DEV; | |
399 | + cfg.dst_addr = res->start + MMCIF_CE_DATA; | |
400 | + cfg.src_addr = 0; | |
401 | + ret = dmaengine_slave_config(host->chan_tx, &cfg); | |
402 | + if (ret < 0) | |
403 | + goto ecfgtx; | |
403 | 404 | |
404 | - if (!host->chan_tx) | |
405 | - return; | |
405 | + host->chan_rx = dma_request_channel(mask, shdma_chan_filter, | |
406 | + (void *)pdata->slave_id_rx); | |
407 | + dev_dbg(&host->pd->dev, "%s: RX: got channel %p\n", __func__, | |
408 | + host->chan_rx); | |
406 | 409 | |
407 | - host->chan_rx = dma_request_channel(mask, sh_mmcif_filter, | |
408 | - &rx->shdma_slave); | |
409 | - dev_dbg(&host->pd->dev, "%s: RX: got channel %p\n", __func__, | |
410 | - host->chan_rx); | |
410 | + if (!host->chan_rx) | |
411 | + goto erqrx; | |
411 | 412 | |
412 | - if (!host->chan_rx) { | |
413 | - dma_release_channel(host->chan_tx); | |
414 | - host->chan_tx = NULL; | |
415 | - return; | |
416 | - } | |
413 | + cfg.slave_id = pdata->slave_id_rx; | |
414 | + cfg.direction = DMA_DEV_TO_MEM; | |
415 | + cfg.dst_addr = 0; | |
416 | + cfg.src_addr = res->start + MMCIF_CE_DATA; | |
417 | + ret = dmaengine_slave_config(host->chan_rx, &cfg); | |
418 | + if (ret < 0) | |
419 | + goto ecfgrx; | |
417 | 420 | |
418 | - init_completion(&host->dma_complete); | |
419 | - } | |
421 | + init_completion(&host->dma_complete); | |
422 | + | |
423 | + return; | |
424 | + | |
425 | +ecfgrx: | |
426 | + dma_release_channel(host->chan_rx); | |
427 | + host->chan_rx = NULL; | |
428 | +erqrx: | |
429 | +ecfgtx: | |
430 | + dma_release_channel(host->chan_tx); | |
431 | + host->chan_tx = NULL; | |
420 | 432 | } |
421 | 433 | |
422 | 434 | static void sh_mmcif_release_dma(struct sh_mmcif_host *host) |