13 #include <linux/device.h>
24 #define TMIO_MMC_MIN_DMA_LEN 8
31 #if defined(CONFIG_SUPERH) || defined(CONFIG_ARCH_SHMOBILE)
42 dmaengine_terminate_all(host->
chan_rx);
44 dmaengine_terminate_all(host->
chan_tx);
57 bool aligned =
true, multiple =
true;
58 unsigned int align = (1 << pdata->
dma->alignment_shift) - 1;
61 if (sg_tmp->offset & align)
63 if (sg_tmp->length & align) {
91 desc = dmaengine_prep_slave_sg(chan, sg, ret,
95 cookie = dmaengine_submit(desc);
101 dev_dbg(&host->
pdev->dev,
"%s(): mapped %d -> %d, cookie %d, rq %p\n",
102 __func__, host->
sg_len, ret, cookie, host->
mrq);
118 "DMA failed: %d, falling back to PIO\n", ret);
122 dev_dbg(&host->
pdev->dev,
"%s(): desc %p, cookie %d, sg[%d]\n", __func__,
123 desc, cookie, host->
sg_len);
126 static void tmio_mmc_start_dma_tx(
struct tmio_mmc_host *host)
134 bool aligned =
true, multiple =
true;
135 unsigned int align = (1 << pdata->
dma->alignment_shift) - 1;
138 if (sg_tmp->offset & align)
140 if (sg_tmp->length & align) {
147 (align & PAGE_MASK))) || !multiple) {
162 void *sg_vaddr = tmio_mmc_kmap_atomic(sg, &flags);
165 tmio_mmc_kunmap_atomic(sg, &flags, sg_vaddr);
172 desc = dmaengine_prep_slave_sg(chan, sg, ret,
176 cookie = dmaengine_submit(desc);
182 dev_dbg(&host->
pdev->dev,
"%s(): mapped %d -> %d, cookie %d, rq %p\n",
183 __func__, host->
sg_len, ret, cookie, host->
mrq);
199 "DMA failed: %d, falling back to PIO\n", ret);
203 dev_dbg(&host->
pdev->dev,
"%s(): desc %p, cookie %d\n", __func__,
212 tmio_mmc_start_dma_rx(host);
215 tmio_mmc_start_dma_tx(host);
219 static void tmio_mmc_issue_tasklet_fn(
unsigned long priv)
224 spin_lock_irq(&host->
lock);
226 if (host && host->
data) {
233 spin_unlock_irq(&host->
lock);
238 dma_async_issue_pending(chan);
241 static void tmio_mmc_tasklet_fn(
unsigned long arg)
245 spin_lock_irq(&host->
lock);
261 spin_unlock_irq(&host->
lock);
265 static bool tmio_mmc_filter(
struct dma_chan *chan,
void *arg)
267 dev_dbg(chan->
device->dev,
"%s: slave data %p\n", __func__, arg);
285 pdata->
dma->chan_priv_tx);
286 dev_dbg(&host->
pdev->dev,
"%s: TX: got channel %p\n", __func__,
293 pdata->
dma->chan_priv_rx);
294 dev_dbg(&host->
pdev->dev,
"%s: RX: got channel %p\n", __func__,
305 tasklet_init(&host->dma_issue, tmio_mmc_issue_tasklet_fn, (
unsigned long)host);