Lines Matching refs:host

13 #include <linux/mmc/host.h>
82 static void *uniphier_sd_priv(struct tmio_mmc_host *host)
84 return container_of(host->pdata, struct uniphier_sd_priv, tmio_data);
87 static void uniphier_sd_dma_endisable(struct tmio_mmc_host *host, int enable)
89 sd_ctrl_write16(host, CTL_DMA_ENABLE, enable ? DMA_ENABLE_DMASDRW : 0);
95 struct tmio_mmc_host *host = from_tasklet(host, t, dma_issue);
96 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
98 uniphier_sd_dma_endisable(host, 1);
105 struct tmio_mmc_host *host = param;
106 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
109 dma_unmap_sg(mmc_dev(host->mmc), host->sg_ptr, host->sg_len,
112 spin_lock_irqsave(&host->lock, flags);
122 tmio_mmc_enable_mmc_irqs(host, TMIO_STAT_DATAEND);
124 host->data->error = -ETIMEDOUT;
125 tmio_mmc_do_data_irq(host);
128 spin_unlock_irqrestore(&host->lock, flags);
131 static void uniphier_sd_external_dma_start(struct tmio_mmc_host *host,
134 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
151 sg_len = dma_map_sg(mmc_dev(host->mmc), host->sg_ptr, host->sg_len,
156 desc = dmaengine_prep_slave_sg(priv->chan, host->sg_ptr, sg_len,
162 desc->callback_param = host;
168 host->dma_on = true;
173 dma_unmap_sg(mmc_dev(host->mmc), host->sg_ptr, host->sg_len,
176 uniphier_sd_dma_endisable(host, 0);
179 static void uniphier_sd_external_dma_enable(struct tmio_mmc_host *host,
184 static void uniphier_sd_external_dma_request(struct tmio_mmc_host *host,
187 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
190 chan = dma_request_chan(mmc_dev(host->mmc), "rx-tx");
192 dev_warn(mmc_dev(host->mmc),
199 host->chan_rx = chan;
200 host->chan_tx = chan;
202 tasklet_setup(&host->dma_issue, uniphier_sd_external_dma_issue);
205 static void uniphier_sd_external_dma_release(struct tmio_mmc_host *host)
207 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
213 static void uniphier_sd_external_dma_abort(struct tmio_mmc_host *host)
215 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
217 uniphier_sd_dma_endisable(host, 0);
223 static void uniphier_sd_external_dma_dataend(struct tmio_mmc_host *host)
225 uniphier_sd_dma_endisable(host, 0);
227 tmio_mmc_do_data_irq(host);
241 struct tmio_mmc_host *host = from_tasklet(host, t, dma_issue);
244 spin_lock_irqsave(&host->lock, flags);
245 tmio_mmc_enable_mmc_irqs(host, TMIO_STAT_DATAEND);
246 spin_unlock_irqrestore(&host->lock, flags);
248 uniphier_sd_dma_endisable(host, 1);
249 writel(UNIPHIER_SD_DMA_CTL_START, host->ctl + UNIPHIER_SD_DMA_CTL);
252 static void uniphier_sd_internal_dma_start(struct tmio_mmc_host *host,
255 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
256 struct scatterlist *sg = host->sg_ptr;
262 if ((data->flags & MMC_DATA_READ) && !host->chan_rx)
265 if (WARN_ON(host->sg_len != 1))
279 sg_len = dma_map_sg(mmc_dev(host->mmc), sg, 1, priv->dma_dir);
288 writel(dma_mode, host->ctl + UNIPHIER_SD_DMA_MODE);
291 writel(lower_32_bits(dma_addr), host->ctl + UNIPHIER_SD_DMA_ADDR_L);
292 writel(upper_32_bits(dma_addr), host->ctl + UNIPHIER_SD_DMA_ADDR_H);
294 host->dma_on = true;
298 uniphier_sd_dma_endisable(host, 0);
301 static void uniphier_sd_internal_dma_enable(struct tmio_mmc_host *host,
306 static void uniphier_sd_internal_dma_request(struct tmio_mmc_host *host,
309 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
316 host->chan_rx = (void *)0xdeadbeaf;
318 host->chan_tx = (void *)0xdeadbeaf;
320 tasklet_setup(&host->dma_issue, uniphier_sd_internal_dma_issue);
323 static void uniphier_sd_internal_dma_release(struct tmio_mmc_host *host)
326 host->chan_rx = NULL;
327 host->chan_tx = NULL;
330 static void uniphier_sd_internal_dma_abort(struct tmio_mmc_host *host)
334 uniphier_sd_dma_endisable(host, 0);
336 tmp = readl(host->ctl + UNIPHIER_SD_DMA_RST);
338 writel(tmp, host->ctl + UNIPHIER_SD_DMA_RST);
341 writel(tmp, host->ctl + UNIPHIER_SD_DMA_RST);
344 static void uniphier_sd_internal_dma_dataend(struct tmio_mmc_host *host)
346 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
348 uniphier_sd_dma_endisable(host, 0);
349 dma_unmap_sg(mmc_dev(host->mmc), host->sg_ptr, 1, priv->dma_dir);
351 tmio_mmc_do_data_irq(host);
363 static int uniphier_sd_clk_enable(struct tmio_mmc_host *host)
365 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
366 struct mmc_host *mmc = host->mmc;
410 static void uniphier_sd_clk_disable(struct tmio_mmc_host *host)
412 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
421 struct tmio_mmc_host *host = mmc_priv(mmc);
422 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
432 static void uniphier_sd_speed_switch(struct tmio_mmc_host *host)
434 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
438 if (!(host->mmc->caps & MMC_CAP_UHS))
441 if (host->mmc->ios.timing == MMC_TIMING_UHS_SDR50 ||
442 host->mmc->ios.timing == MMC_TIMING_UHS_SDR104)
451 static void uniphier_sd_uhs_enable(struct tmio_mmc_host *host, bool uhs_en)
453 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
457 if (!(host->mmc->caps & MMC_CAP_UHS))
468 static void uniphier_sd_set_clock(struct tmio_mmc_host *host,
471 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
475 tmp = readl(host->ctl + (CTL_SD_CARD_CLK_CTL << 1));
479 writel(tmp, host->ctl + (CTL_SD_CARD_CLK_CTL << 1));
481 uniphier_sd_speed_switch(host);
507 writel(tmp, host->ctl + (CTL_SD_CARD_CLK_CTL << 1));
510 writel(tmp, host->ctl + (CTL_SD_CARD_CLK_CTL << 1));
513 static void uniphier_sd_host_init(struct tmio_mmc_host *host)
515 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
530 writel(val, host->ctl + UNIPHIER_SD_HOST_MODE);
540 writel(val, host->ctl + (CTL_SD_CARD_CLK_CTL << 1));
546 struct tmio_mmc_host *host = mmc_priv(mmc);
547 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
566 tmp = readl(host->ctl + UNIPHIER_SD_VOLT);
569 writel(tmp, host->ctl + UNIPHIER_SD_VOLT);
576 uniphier_sd_uhs_enable(host, uhs_en);
581 static int uniphier_sd_uhs_init(struct tmio_mmc_host *host)
583 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
584 struct device *dev = &host->pdev->dev;
589 priv->pinctrl = devm_pinctrl_get(mmc_dev(host->mmc));
620 struct tmio_mmc_host *host;
639 priv->rst = devm_reset_control_get_shared(dev, "host");
641 dev_err(dev, "failed to get host reset\n");
658 host = tmio_mmc_host_alloc(pdev, tmio_data);
659 if (IS_ERR(host))
660 return PTR_ERR(host);
662 if (host->mmc->caps & MMC_CAP_HW_RESET) {
669 host->ops.card_hw_reset = uniphier_sd_hw_reset;
672 if (host->mmc->caps & MMC_CAP_UHS) {
673 ret = uniphier_sd_uhs_init(host);
678 host->mmc->caps &= ~MMC_CAP_UHS;
680 host->ops.start_signal_voltage_switch =
686 host->dma_ops = &uniphier_sd_internal_dma_ops;
688 host->dma_ops = &uniphier_sd_external_dma_ops;
690 host->bus_shift = 1;
691 host->clk_enable = uniphier_sd_clk_enable;
692 host->clk_disable = uniphier_sd_clk_disable;
693 host->set_clock = uniphier_sd_set_clock;
695 ret = uniphier_sd_clk_enable(host);
699 uniphier_sd_host_init(host);
702 if (host->mmc->caps & MMC_CAP_UHS)
708 sd_ctrl_write32_as_16_and_16(host, CTL_IRQ_MASK, TMIO_MASK_ALL);
711 dev_name(dev), host);
715 ret = tmio_mmc_host_probe(host);
722 uniphier_sd_clk_disable(host);
724 tmio_mmc_host_free(host);
731 struct tmio_mmc_host *host = platform_get_drvdata(pdev);
733 tmio_mmc_host_remove(host);
734 uniphier_sd_clk_disable(host);
735 tmio_mmc_host_free(host);
767 MODULE_DESCRIPTION("UniPhier SD/eMMC host controller driver");