Lines Matching refs:host

17 #include <linux/mmc/host.h>
26 void tmio_mmc_enable_dma(struct tmio_mmc_host *host, bool enable)
28 if (!host->chan_tx || !host->chan_rx)
31 if (host->pdata->flags & TMIO_MMC_HAVE_CTL_DMA_REG)
32 sd_ctrl_write16(host, CTL_DMA_ENABLE, enable ? 2 : 0);
35 void tmio_mmc_abort_dma(struct tmio_mmc_host *host)
37 tmio_mmc_enable_dma(host, false);
39 if (host->chan_rx)
40 dmaengine_terminate_all(host->chan_rx);
41 if (host->chan_tx)
42 dmaengine_terminate_all(host->chan_tx);
44 tmio_mmc_enable_dma(host, true);
47 static void tmio_mmc_start_dma_rx(struct tmio_mmc_host *host)
49 struct scatterlist *sg = host->sg_ptr, *sg_tmp;
51 struct dma_chan *chan = host->chan_rx;
52 struct tmio_mmc_data *pdata = host->pdata;
58 for_each_sg(sg, sg_tmp, host->sg_len, i) {
67 if ((!aligned && (host->sg_len > 1 || sg->length > PAGE_CACHE_SIZE ||
74 host->force_pio = true;
78 tmio_mmc_disable_mmc_irqs(host, TMIO_STAT_RXRDY);
82 sg_init_one(&host->bounce_sg, host->bounce_buf, sg->length);
83 host->sg_ptr = &host->bounce_sg;
84 sg = host->sg_ptr;
87 ret = dma_map_sg(chan->device->dev, sg, host->sg_len, DMA_FROM_DEVICE);
99 dev_dbg(&host->pdev->dev, "%s(): mapped %d -> %d, cookie %d, rq %p\n",
100 __func__, host->sg_len, ret, cookie, host->mrq);
105 tmio_mmc_enable_dma(host, false);
108 host->chan_rx = NULL;
111 chan = host->chan_tx;
113 host->chan_tx = NULL;
116 dev_warn(&host->pdev->dev,
120 dev_dbg(&host->pdev->dev, "%s(): desc %p, cookie %d, sg[%d]\n", __func__,
121 desc, cookie, host->sg_len);
124 static void tmio_mmc_start_dma_tx(struct tmio_mmc_host *host)
126 struct scatterlist *sg = host->sg_ptr, *sg_tmp;
128 struct dma_chan *chan = host->chan_tx;
129 struct tmio_mmc_data *pdata = host->pdata;
135 for_each_sg(sg, sg_tmp, host->sg_len, i) {
144 if ((!aligned && (host->sg_len > 1 || sg->length > PAGE_CACHE_SIZE ||
151 host->force_pio = true;
155 tmio_mmc_disable_mmc_irqs(host, TMIO_STAT_TXRQ);
161 sg_init_one(&host->bounce_sg, host->bounce_buf, sg->length);
162 memcpy(host->bounce_buf, sg_vaddr, host->bounce_sg.length);
164 host->sg_ptr = &host->bounce_sg;
165 sg = host->sg_ptr;
168 ret = dma_map_sg(chan->device->dev, sg, host->sg_len, DMA_TO_DEVICE);
180 dev_dbg(&host->pdev->dev, "%s(): mapped %d -> %d, cookie %d, rq %p\n",
181 __func__, host->sg_len, ret, cookie, host->mrq);
186 tmio_mmc_enable_dma(host, false);
189 host->chan_tx = NULL;
192 chan = host->chan_rx;
194 host->chan_rx = NULL;
197 dev_warn(&host->pdev->dev,
201 dev_dbg(&host->pdev->dev, "%s(): desc %p, cookie %d\n", __func__,
205 void tmio_mmc_start_dma(struct tmio_mmc_host *host,
209 if (host->chan_rx)
210 tmio_mmc_start_dma_rx(host);
212 if (host->chan_tx)
213 tmio_mmc_start_dma_tx(host);
219 struct tmio_mmc_host *host = (struct tmio_mmc_host *)priv;
222 spin_lock_irq(&host->lock);
224 if (host && host->data) {
225 if (host->data->flags & MMC_DATA_READ)
226 chan = host->chan_rx;
228 chan = host->chan_tx;
231 spin_unlock_irq(&host->lock);
233 tmio_mmc_enable_mmc_irqs(host, TMIO_STAT_DATAEND);
241 struct tmio_mmc_host *host = (struct tmio_mmc_host *)arg;
243 spin_lock_irq(&host->lock);
245 if (!host->data)
248 if (host->data->flags & MMC_DATA_READ)
249 dma_unmap_sg(host->chan_rx->device->dev,
250 host->sg_ptr, host->sg_len,
253 dma_unmap_sg(host->chan_tx->device->dev,
254 host->sg_ptr, host->sg_len,
257 tmio_mmc_do_data_irq(host);
259 spin_unlock_irq(&host->lock);
262 void tmio_mmc_request_dma(struct tmio_mmc_host *host, struct tmio_mmc_data *pdata)
265 if (!pdata->dma || (!host->pdev->dev.of_node &&
269 if (!host->chan_tx && !host->chan_rx) {
270 struct resource *res = platform_get_resource(host->pdev,
282 host->chan_tx = dma_request_slave_channel_compat(mask,
284 &host->pdev->dev, "tx");
285 dev_dbg(&host->pdev->dev, "%s: TX: got channel %p\n", __func__,
286 host->chan_tx);
288 if (!host->chan_tx)
294 cfg.dst_addr = res->start + (CTL_SD_DATA_PORT << host->pdata->bus_shift);
297 ret = dmaengine_slave_config(host->chan_tx, &cfg);
301 host->chan_rx = dma_request_slave_channel_compat(mask,
303 &host->pdev->dev, "rx");
304 dev_dbg(&host->pdev->dev, "%s: RX: got channel %p\n", __func__,
305 host->chan_rx);
307 if (!host->chan_rx)
316 ret = dmaengine_slave_config(host->chan_rx, &cfg);
320 host->bounce_buf = (u8 *)__get_free_page(GFP_KERNEL | GFP_DMA);
321 if (!host->bounce_buf)
324 tasklet_init(&host->dma_complete, tmio_mmc_tasklet_fn, (unsigned long)host);
325 tasklet_init(&host->dma_issue, tmio_mmc_issue_tasklet_fn, (unsigned long)host);
328 tmio_mmc_enable_dma(host, true);
334 dma_release_channel(host->chan_rx);
335 host->chan_rx = NULL;
338 dma_release_channel(host->chan_tx);
339 host->chan_tx = NULL;
342 void tmio_mmc_release_dma(struct tmio_mmc_host *host)
344 if (host->chan_tx) {
345 struct dma_chan *chan = host->chan_tx;
346 host->chan_tx = NULL;
349 if (host->chan_rx) {
350 struct dma_chan *chan = host->chan_rx;
351 host->chan_rx = NULL;
354 if (host->bounce_buf) {
355 free_pages((unsigned long)host->bounce_buf, 0);
356 host->bounce_buf = NULL;