Lines Matching refs:host

26 void tmio_mmc_enable_dma(struct tmio_mmc_host *host, bool enable)  in tmio_mmc_enable_dma()  argument
28 if (!host->chan_tx || !host->chan_rx) in tmio_mmc_enable_dma()
31 if (host->dma->enable) in tmio_mmc_enable_dma()
32 host->dma->enable(host, enable); in tmio_mmc_enable_dma()
35 void tmio_mmc_abort_dma(struct tmio_mmc_host *host) in tmio_mmc_abort_dma() argument
37 tmio_mmc_enable_dma(host, false); in tmio_mmc_abort_dma()
39 if (host->chan_rx) in tmio_mmc_abort_dma()
40 dmaengine_terminate_all(host->chan_rx); in tmio_mmc_abort_dma()
41 if (host->chan_tx) in tmio_mmc_abort_dma()
42 dmaengine_terminate_all(host->chan_tx); in tmio_mmc_abort_dma()
44 tmio_mmc_enable_dma(host, true); in tmio_mmc_abort_dma()
47 static void tmio_mmc_start_dma_rx(struct tmio_mmc_host *host) in tmio_mmc_start_dma_rx() argument
49 struct scatterlist *sg = host->sg_ptr, *sg_tmp; in tmio_mmc_start_dma_rx()
51 struct dma_chan *chan = host->chan_rx; in tmio_mmc_start_dma_rx()
55 unsigned int align = (1 << host->pdata->alignment_shift) - 1; in tmio_mmc_start_dma_rx()
57 for_each_sg(sg, sg_tmp, host->sg_len, i) { in tmio_mmc_start_dma_rx()
66 if ((!aligned && (host->sg_len > 1 || sg->length > PAGE_CACHE_SIZE || in tmio_mmc_start_dma_rx()
73 host->force_pio = true; in tmio_mmc_start_dma_rx()
77 tmio_mmc_disable_mmc_irqs(host, TMIO_STAT_RXRDY); in tmio_mmc_start_dma_rx()
81 sg_init_one(&host->bounce_sg, host->bounce_buf, sg->length); in tmio_mmc_start_dma_rx()
82 host->sg_ptr = &host->bounce_sg; in tmio_mmc_start_dma_rx()
83 sg = host->sg_ptr; in tmio_mmc_start_dma_rx()
86 ret = dma_map_sg(chan->device->dev, sg, host->sg_len, DMA_FROM_DEVICE); in tmio_mmc_start_dma_rx()
98 dev_dbg(&host->pdev->dev, "%s(): mapped %d -> %d, cookie %d, rq %p\n", in tmio_mmc_start_dma_rx()
99 __func__, host->sg_len, ret, cookie, host->mrq); in tmio_mmc_start_dma_rx()
104 tmio_mmc_enable_dma(host, false); in tmio_mmc_start_dma_rx()
107 host->chan_rx = NULL; in tmio_mmc_start_dma_rx()
110 chan = host->chan_tx; in tmio_mmc_start_dma_rx()
112 host->chan_tx = NULL; in tmio_mmc_start_dma_rx()
115 dev_warn(&host->pdev->dev, in tmio_mmc_start_dma_rx()
119 dev_dbg(&host->pdev->dev, "%s(): desc %p, cookie %d, sg[%d]\n", __func__, in tmio_mmc_start_dma_rx()
120 desc, cookie, host->sg_len); in tmio_mmc_start_dma_rx()
123 static void tmio_mmc_start_dma_tx(struct tmio_mmc_host *host) in tmio_mmc_start_dma_tx() argument
125 struct scatterlist *sg = host->sg_ptr, *sg_tmp; in tmio_mmc_start_dma_tx()
127 struct dma_chan *chan = host->chan_tx; in tmio_mmc_start_dma_tx()
131 unsigned int align = (1 << host->pdata->alignment_shift) - 1; in tmio_mmc_start_dma_tx()
133 for_each_sg(sg, sg_tmp, host->sg_len, i) { in tmio_mmc_start_dma_tx()
142 if ((!aligned && (host->sg_len > 1 || sg->length > PAGE_CACHE_SIZE || in tmio_mmc_start_dma_tx()
149 host->force_pio = true; in tmio_mmc_start_dma_tx()
153 tmio_mmc_disable_mmc_irqs(host, TMIO_STAT_TXRQ); in tmio_mmc_start_dma_tx()
159 sg_init_one(&host->bounce_sg, host->bounce_buf, sg->length); in tmio_mmc_start_dma_tx()
160 memcpy(host->bounce_buf, sg_vaddr, host->bounce_sg.length); in tmio_mmc_start_dma_tx()
162 host->sg_ptr = &host->bounce_sg; in tmio_mmc_start_dma_tx()
163 sg = host->sg_ptr; in tmio_mmc_start_dma_tx()
166 ret = dma_map_sg(chan->device->dev, sg, host->sg_len, DMA_TO_DEVICE); in tmio_mmc_start_dma_tx()
178 dev_dbg(&host->pdev->dev, "%s(): mapped %d -> %d, cookie %d, rq %p\n", in tmio_mmc_start_dma_tx()
179 __func__, host->sg_len, ret, cookie, host->mrq); in tmio_mmc_start_dma_tx()
184 tmio_mmc_enable_dma(host, false); in tmio_mmc_start_dma_tx()
187 host->chan_tx = NULL; in tmio_mmc_start_dma_tx()
190 chan = host->chan_rx; in tmio_mmc_start_dma_tx()
192 host->chan_rx = NULL; in tmio_mmc_start_dma_tx()
195 dev_warn(&host->pdev->dev, in tmio_mmc_start_dma_tx()
199 dev_dbg(&host->pdev->dev, "%s(): desc %p, cookie %d\n", __func__, in tmio_mmc_start_dma_tx()
203 void tmio_mmc_start_dma(struct tmio_mmc_host *host, in tmio_mmc_start_dma() argument
207 if (host->chan_rx) in tmio_mmc_start_dma()
208 tmio_mmc_start_dma_rx(host); in tmio_mmc_start_dma()
210 if (host->chan_tx) in tmio_mmc_start_dma()
211 tmio_mmc_start_dma_tx(host); in tmio_mmc_start_dma()
217 struct tmio_mmc_host *host = (struct tmio_mmc_host *)priv; in tmio_mmc_issue_tasklet_fn() local
220 spin_lock_irq(&host->lock); in tmio_mmc_issue_tasklet_fn()
222 if (host && host->data) { in tmio_mmc_issue_tasklet_fn()
223 if (host->data->flags & MMC_DATA_READ) in tmio_mmc_issue_tasklet_fn()
224 chan = host->chan_rx; in tmio_mmc_issue_tasklet_fn()
226 chan = host->chan_tx; in tmio_mmc_issue_tasklet_fn()
229 spin_unlock_irq(&host->lock); in tmio_mmc_issue_tasklet_fn()
231 tmio_mmc_enable_mmc_irqs(host, TMIO_STAT_DATAEND); in tmio_mmc_issue_tasklet_fn()
239 struct tmio_mmc_host *host = (struct tmio_mmc_host *)arg; in tmio_mmc_tasklet_fn() local
241 spin_lock_irq(&host->lock); in tmio_mmc_tasklet_fn()
243 if (!host->data) in tmio_mmc_tasklet_fn()
246 if (host->data->flags & MMC_DATA_READ) in tmio_mmc_tasklet_fn()
247 dma_unmap_sg(host->chan_rx->device->dev, in tmio_mmc_tasklet_fn()
248 host->sg_ptr, host->sg_len, in tmio_mmc_tasklet_fn()
251 dma_unmap_sg(host->chan_tx->device->dev, in tmio_mmc_tasklet_fn()
252 host->sg_ptr, host->sg_len, in tmio_mmc_tasklet_fn()
255 tmio_mmc_do_data_irq(host); in tmio_mmc_tasklet_fn()
257 spin_unlock_irq(&host->lock); in tmio_mmc_tasklet_fn()
260 void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdata) in tmio_mmc_request_dma() argument
263 if (!host->dma || (!host->pdev->dev.of_node && in tmio_mmc_request_dma()
267 if (!host->chan_tx && !host->chan_rx) { in tmio_mmc_request_dma()
268 struct resource *res = platform_get_resource(host->pdev, in tmio_mmc_request_dma()
280 host->chan_tx = dma_request_slave_channel_compat(mask, in tmio_mmc_request_dma()
281 host->dma->filter, pdata->chan_priv_tx, in tmio_mmc_request_dma()
282 &host->pdev->dev, "tx"); in tmio_mmc_request_dma()
283 dev_dbg(&host->pdev->dev, "%s: TX: got channel %p\n", __func__, in tmio_mmc_request_dma()
284 host->chan_tx); in tmio_mmc_request_dma()
286 if (!host->chan_tx) in tmio_mmc_request_dma()
290 cfg.dst_addr = res->start + (CTL_SD_DATA_PORT << host->bus_shift); in tmio_mmc_request_dma()
291 cfg.dst_addr_width = host->dma->dma_buswidth; in tmio_mmc_request_dma()
295 ret = dmaengine_slave_config(host->chan_tx, &cfg); in tmio_mmc_request_dma()
299 host->chan_rx = dma_request_slave_channel_compat(mask, in tmio_mmc_request_dma()
300 host->dma->filter, pdata->chan_priv_rx, in tmio_mmc_request_dma()
301 &host->pdev->dev, "rx"); in tmio_mmc_request_dma()
302 dev_dbg(&host->pdev->dev, "%s: RX: got channel %p\n", __func__, in tmio_mmc_request_dma()
303 host->chan_rx); in tmio_mmc_request_dma()
305 if (!host->chan_rx) in tmio_mmc_request_dma()
309 cfg.src_addr = cfg.dst_addr + host->pdata->dma_rx_offset; in tmio_mmc_request_dma()
310 cfg.src_addr_width = host->dma->dma_buswidth; in tmio_mmc_request_dma()
314 ret = dmaengine_slave_config(host->chan_rx, &cfg); in tmio_mmc_request_dma()
318 host->bounce_buf = (u8 *)__get_free_page(GFP_KERNEL | GFP_DMA); in tmio_mmc_request_dma()
319 if (!host->bounce_buf) in tmio_mmc_request_dma()
322 tasklet_init(&host->dma_complete, tmio_mmc_tasklet_fn, (unsigned long)host); in tmio_mmc_request_dma()
323 tasklet_init(&host->dma_issue, tmio_mmc_issue_tasklet_fn, (unsigned long)host); in tmio_mmc_request_dma()
326 tmio_mmc_enable_dma(host, true); in tmio_mmc_request_dma()
332 dma_release_channel(host->chan_rx); in tmio_mmc_request_dma()
333 host->chan_rx = NULL; in tmio_mmc_request_dma()
336 dma_release_channel(host->chan_tx); in tmio_mmc_request_dma()
337 host->chan_tx = NULL; in tmio_mmc_request_dma()
340 void tmio_mmc_release_dma(struct tmio_mmc_host *host) in tmio_mmc_release_dma() argument
342 if (host->chan_tx) { in tmio_mmc_release_dma()
343 struct dma_chan *chan = host->chan_tx; in tmio_mmc_release_dma()
344 host->chan_tx = NULL; in tmio_mmc_release_dma()
347 if (host->chan_rx) { in tmio_mmc_release_dma()
348 struct dma_chan *chan = host->chan_rx; in tmio_mmc_release_dma()
349 host->chan_rx = NULL; in tmio_mmc_release_dma()
352 if (host->bounce_buf) { in tmio_mmc_release_dma()
353 free_pages((unsigned long)host->bounce_buf, 0); in tmio_mmc_release_dma()
354 host->bounce_buf = NULL; in tmio_mmc_release_dma()