Lines Matching defs:host
12 #include <linux/mmc/host.h>
73 static void *uniphier_sd_priv(struct tmio_mmc_host *host)
75 return container_of(host->pdata, struct uniphier_sd_priv, tmio_data);
78 static void uniphier_sd_dma_endisable(struct tmio_mmc_host *host, int enable)
80 sd_ctrl_write16(host, CTL_DMA_ENABLE, enable ? DMA_ENABLE_DMASDRW : 0);
86 struct tmio_mmc_host *host = (void *)arg;
87 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
89 uniphier_sd_dma_endisable(host, 1);
96 struct tmio_mmc_host *host = param;
97 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
100 dma_unmap_sg(mmc_dev(host->mmc), host->sg_ptr, host->sg_len,
103 spin_lock_irqsave(&host->lock, flags);
113 tmio_mmc_enable_mmc_irqs(host, TMIO_STAT_DATAEND);
115 host->data->error = -ETIMEDOUT;
116 tmio_mmc_do_data_irq(host);
119 spin_unlock_irqrestore(&host->lock, flags);
122 static void uniphier_sd_external_dma_start(struct tmio_mmc_host *host,
125 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
142 sg_len = dma_map_sg(mmc_dev(host->mmc), host->sg_ptr, host->sg_len,
147 desc = dmaengine_prep_slave_sg(priv->chan, host->sg_ptr, sg_len,
153 desc->callback_param = host;
159 host->dma_on = true;
164 dma_unmap_sg(mmc_dev(host->mmc), host->sg_ptr, host->sg_len,
167 uniphier_sd_dma_endisable(host, 0);
170 static void uniphier_sd_external_dma_enable(struct tmio_mmc_host *host,
175 static void uniphier_sd_external_dma_request(struct tmio_mmc_host *host,
178 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
181 chan = dma_request_chan(mmc_dev(host->mmc), "rx-tx");
183 dev_warn(mmc_dev(host->mmc),
190 host->chan_rx = chan;
191 host->chan_tx = chan;
193 tasklet_init(&host->dma_issue, uniphier_sd_external_dma_issue,
194 (unsigned long)host);
197 static void uniphier_sd_external_dma_release(struct tmio_mmc_host *host)
199 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
205 static void uniphier_sd_external_dma_abort(struct tmio_mmc_host *host)
207 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
209 uniphier_sd_dma_endisable(host, 0);
215 static void uniphier_sd_external_dma_dataend(struct tmio_mmc_host *host)
217 uniphier_sd_dma_endisable(host, 0);
219 tmio_mmc_do_data_irq(host);
233 struct tmio_mmc_host *host = (void *)arg;
236 spin_lock_irqsave(&host->lock, flags);
237 tmio_mmc_enable_mmc_irqs(host, TMIO_STAT_DATAEND);
238 spin_unlock_irqrestore(&host->lock, flags);
240 uniphier_sd_dma_endisable(host, 1);
241 writel(UNIPHIER_SD_DMA_CTL_START, host->ctl + UNIPHIER_SD_DMA_CTL);
244 static void uniphier_sd_internal_dma_start(struct tmio_mmc_host *host,
247 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
248 struct scatterlist *sg = host->sg_ptr;
254 if ((data->flags & MMC_DATA_READ) && !host->chan_rx)
257 if (WARN_ON(host->sg_len != 1))
271 sg_len = dma_map_sg(mmc_dev(host->mmc), sg, 1, priv->dma_dir);
280 writel(dma_mode, host->ctl + UNIPHIER_SD_DMA_MODE);
283 writel(lower_32_bits(dma_addr), host->ctl + UNIPHIER_SD_DMA_ADDR_L);
284 writel(upper_32_bits(dma_addr), host->ctl + UNIPHIER_SD_DMA_ADDR_H);
286 host->dma_on = true;
290 uniphier_sd_dma_endisable(host, 0);
293 static void uniphier_sd_internal_dma_enable(struct tmio_mmc_host *host,
298 static void uniphier_sd_internal_dma_request(struct tmio_mmc_host *host,
301 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
308 host->chan_rx = (void *)0xdeadbeaf;
310 host->chan_tx = (void *)0xdeadbeaf;
312 tasklet_init(&host->dma_issue, uniphier_sd_internal_dma_issue,
313 (unsigned long)host);
316 static void uniphier_sd_internal_dma_release(struct tmio_mmc_host *host)
319 host->chan_rx = NULL;
320 host->chan_tx = NULL;
323 static void uniphier_sd_internal_dma_abort(struct tmio_mmc_host *host)
327 uniphier_sd_dma_endisable(host, 0);
329 tmp = readl(host->ctl + UNIPHIER_SD_DMA_RST);
331 writel(tmp, host->ctl + UNIPHIER_SD_DMA_RST);
334 writel(tmp, host->ctl + UNIPHIER_SD_DMA_RST);
337 static void uniphier_sd_internal_dma_dataend(struct tmio_mmc_host *host)
339 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
341 uniphier_sd_dma_endisable(host, 0);
342 dma_unmap_sg(mmc_dev(host->mmc), host->sg_ptr, 1, priv->dma_dir);
344 tmio_mmc_do_data_irq(host);
356 static int uniphier_sd_clk_enable(struct tmio_mmc_host *host)
358 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
359 struct mmc_host *mmc = host->mmc;
403 static void uniphier_sd_clk_disable(struct tmio_mmc_host *host)
405 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
414 struct tmio_mmc_host *host = mmc_priv(mmc);
415 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
425 static void uniphier_sd_set_clock(struct tmio_mmc_host *host,
428 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
432 tmp = readl(host->ctl + (CTL_SD_CARD_CLK_CTL << 1));
436 writel(tmp, host->ctl + (CTL_SD_CARD_CLK_CTL << 1));
462 writel(tmp, host->ctl + (CTL_SD_CARD_CLK_CTL << 1));
465 writel(tmp, host->ctl + (CTL_SD_CARD_CLK_CTL << 1));
468 static void uniphier_sd_host_init(struct tmio_mmc_host *host)
470 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
485 writel(val, host->ctl + UNIPHIER_SD_HOST_MODE);
495 writel(val, host->ctl + (CTL_SD_CARD_CLK_CTL << 1));
501 struct tmio_mmc_host *host = mmc_priv(mmc);
502 struct uniphier_sd_priv *priv = uniphier_sd_priv(host);
518 tmp = readl(host->ctl + UNIPHIER_SD_VOLT);
521 writel(tmp, host->ctl + UNIPHIER_SD_VOLT);
531 static int uniphier_sd_uhs_init(struct tmio_mmc_host *host,
534 priv->pinctrl = devm_pinctrl_get(mmc_dev(host->mmc));
542 host->ops.start_signal_voltage_switch =
553 struct tmio_mmc_host *host;
572 priv->rst = devm_reset_control_get_shared(dev, "host");
574 dev_err(dev, "failed to get host reset\n");
590 host = tmio_mmc_host_alloc(pdev, tmio_data);
591 if (IS_ERR(host))
592 return PTR_ERR(host);
594 if (host->mmc->caps & MMC_CAP_HW_RESET) {
601 host->ops.hw_reset = uniphier_sd_hw_reset;
604 if (host->mmc->caps & MMC_CAP_UHS) {
605 ret = uniphier_sd_uhs_init(host, priv);
610 host->mmc->caps &= ~MMC_CAP_UHS;
615 host->dma_ops = &uniphier_sd_internal_dma_ops;
617 host->dma_ops = &uniphier_sd_external_dma_ops;
619 host->bus_shift = 1;
620 host->clk_enable = uniphier_sd_clk_enable;
621 host->clk_disable = uniphier_sd_clk_disable;
622 host->set_clock = uniphier_sd_set_clock;
624 ret = uniphier_sd_clk_enable(host);
628 uniphier_sd_host_init(host);
631 if (host->mmc->caps & MMC_CAP_UHS)
637 ret = tmio_mmc_host_probe(host);
642 dev_name(dev), host);
649 tmio_mmc_host_remove(host);
651 uniphier_sd_clk_disable(host);
653 tmio_mmc_host_free(host);
660 struct tmio_mmc_host *host = platform_get_drvdata(pdev);
662 tmio_mmc_host_remove(host);
663 uniphier_sd_clk_disable(host);
664 tmio_mmc_host_free(host);
698 MODULE_DESCRIPTION("UniPhier SD/eMMC host controller driver");