Lines Matching +full:sdhci +full:- +full:caps

1 // SPDX-License-Identifier: GPL-2.0
11 #include <linux/platform_data/mmc-esdhc-mcf.h>
13 #include "sdhci-pltfm.h"
14 #include "sdhci-esdhc.h"
49 void __iomem *base = host->ioaddr + (reg & ~3); in esdhc_clrset_be()
62 * Note: mcf is big-endian, single bytes need to be accessed at big endian
67 void __iomem *base = host->ioaddr + (reg & ~3); in esdhc_mcf_writeb_be()
74 u8 tmp = readb(host->ioaddr + SDHCI_HOST_CONTROL + 1); in esdhc_mcf_writeb_be()
85 writel(host_ctrl, host->ioaddr + SDHCI_HOST_CONTROL); in esdhc_mcf_writeb_be()
97 void __iomem *base = host->ioaddr + (reg & ~3); in esdhc_mcf_writew_be()
103 mcf_data->aside = val; in esdhc_mcf_writew_be()
106 if (host->cmd->opcode == MMC_STOP_TRANSMISSION) in esdhc_mcf_writew_be()
113 writel(val << 16 | mcf_data->aside, in esdhc_mcf_writew_be()
114 host->ioaddr + SDHCI_TRANSFER_MODE); in esdhc_mcf_writew_be()
123 writel(val, host->ioaddr + reg); in esdhc_mcf_writel_be()
129 u8 __iomem *base = host->ioaddr + (reg & ~3); in esdhc_mcf_readb_be()
140 return readb(host->ioaddr + (reg ^ 0x3)); in esdhc_mcf_readb_be()
146 * For SDHCI_HOST_VERSION, sdhci specs defines 0xFE, in esdhc_mcf_readw_be()
150 reg -= 2; in esdhc_mcf_readw_be()
152 return readw(host->ioaddr + (reg ^ 0x2)); in esdhc_mcf_readw_be()
159 val = readl(host->ioaddr + reg); in esdhc_mcf_readl_be()
199 mcf_data->current_bus_width, SDHCI_HOST_CONTROL); in esdhc_mcf_reset()
201 sdhci_writel(host, host->ier, SDHCI_INT_ENABLE); in esdhc_mcf_reset()
202 sdhci_writel(host, host->ier, SDHCI_SIGNAL_ENABLE); in esdhc_mcf_reset()
209 return pltfm_host->clock; in esdhc_mcf_pltfm_get_max_clock()
216 return pltfm_host->clock / 256 / 16; in esdhc_mcf_pltfm_get_min_clock()
230 host->mmc->actual_clock = 0; in esdhc_mcf_pltfm_set_clock()
237 * pll -+-> / outdiv1 --> fsys in esdhc_mcf_pltfm_set_clock()
238 * +-> / outdiv3 --> eSDHC clock ---> / SDCCLKFS / DVS in esdhc_mcf_pltfm_set_clock()
249 fsys = pltfm_host->clock; in esdhc_mcf_pltfm_set_clock()
259 delta = abs(clock - finale); in esdhc_mcf_pltfm_set_clock()
270 * Apply divisors and re-enable all the clocks in esdhc_mcf_pltfm_set_clock()
272 temp = ((sdclkfs[ri] >> 1) << 8) | ((rq - 1) << 4) | in esdhc_mcf_pltfm_set_clock()
276 host->mmc->actual_clock = clock; in esdhc_mcf_pltfm_set_clock()
288 mcf_data->current_bus_width = ESDHC_CTRL_4BITBUS; in esdhc_mcf_pltfm_set_bus_width()
291 mcf_data->current_bus_width = 0; in esdhc_mcf_pltfm_set_bus_width()
296 mcf_data->current_bus_width, SDHCI_HOST_CONTROL); in esdhc_mcf_pltfm_set_bus_width()
306 if (!mrq->data || !mrq->data->bytes_xfered) in esdhc_mcf_request_done()
309 if (mmc_get_dma_dir(mrq->data) != DMA_FROM_DEVICE) in esdhc_mcf_request_done()
316 for_each_sg(mrq->data->sg, sg, mrq->data->sg_len, i) { in esdhc_mcf_request_done()
318 esdhc_mcf_buffer_swap32(buffer, sg->length); in esdhc_mcf_request_done()
322 mmc_request_done(host->mmc, mrq); in esdhc_mcf_request_done()
329 sg_copy_to_buffer(data->sg, data->sg_len, in esdhc_mcf_copy_to_bounce_buffer()
330 host->bounce_buffer, length); in esdhc_mcf_copy_to_bounce_buffer()
332 esdhc_mcf_buffer_swap32((u32 *)host->bounce_buffer, in esdhc_mcf_copy_to_bounce_buffer()
333 data->blksz * data->blocks); in esdhc_mcf_copy_to_bounce_buffer()
370 struct device *dev = mmc_dev(host->mmc); in esdhc_mcf_plat_init()
372 if (!dev->platform_data) { in esdhc_mcf_plat_init()
374 return -EINVAL; in esdhc_mcf_plat_init()
377 plat_data = (struct mcf_esdhc_platform_data *)dev->platform_data; in esdhc_mcf_plat_init()
380 switch (plat_data->cd_type) { in esdhc_mcf_plat_init()
384 host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION; in esdhc_mcf_plat_init()
387 host->mmc->caps |= MMC_CAP_NONREMOVABLE; in esdhc_mcf_plat_init()
393 switch (plat_data->max_bus_width) { in esdhc_mcf_plat_init()
395 host->mmc->caps |= MMC_CAP_4_BIT_DATA; in esdhc_mcf_plat_init()
399 host->quirks |= SDHCI_QUIRK_FORCE_1_BIT_DATA; in esdhc_mcf_plat_init()
422 host->sdma_boundary = 0; in sdhci_esdhc_mcf_probe()
424 host->flags |= SDHCI_AUTO_CMD12; in sdhci_esdhc_mcf_probe()
426 mcf_data->clk_ipg = devm_clk_get(&pdev->dev, "ipg"); in sdhci_esdhc_mcf_probe()
427 if (IS_ERR(mcf_data->clk_ipg)) { in sdhci_esdhc_mcf_probe()
428 err = PTR_ERR(mcf_data->clk_ipg); in sdhci_esdhc_mcf_probe()
432 mcf_data->clk_ahb = devm_clk_get(&pdev->dev, "ahb"); in sdhci_esdhc_mcf_probe()
433 if (IS_ERR(mcf_data->clk_ahb)) { in sdhci_esdhc_mcf_probe()
434 err = PTR_ERR(mcf_data->clk_ahb); in sdhci_esdhc_mcf_probe()
438 mcf_data->clk_per = devm_clk_get(&pdev->dev, "per"); in sdhci_esdhc_mcf_probe()
439 if (IS_ERR(mcf_data->clk_per)) { in sdhci_esdhc_mcf_probe()
440 err = PTR_ERR(mcf_data->clk_per); in sdhci_esdhc_mcf_probe()
444 pltfm_host->clk = mcf_data->clk_per; in sdhci_esdhc_mcf_probe()
445 pltfm_host->clock = clk_get_rate(pltfm_host->clk); in sdhci_esdhc_mcf_probe()
446 err = clk_prepare_enable(mcf_data->clk_per); in sdhci_esdhc_mcf_probe()
450 err = clk_prepare_enable(mcf_data->clk_ipg); in sdhci_esdhc_mcf_probe()
454 err = clk_prepare_enable(mcf_data->clk_ahb); in sdhci_esdhc_mcf_probe()
466 if (!host->bounce_buffer) { in sdhci_esdhc_mcf_probe()
467 dev_err(&pdev->dev, "bounce buffer not allocated"); in sdhci_esdhc_mcf_probe()
468 err = -ENOMEM; in sdhci_esdhc_mcf_probe()
481 clk_disable_unprepare(mcf_data->clk_ahb); in sdhci_esdhc_mcf_probe()
483 clk_disable_unprepare(mcf_data->clk_ipg); in sdhci_esdhc_mcf_probe()
485 clk_disable_unprepare(mcf_data->clk_per); in sdhci_esdhc_mcf_probe()
500 clk_disable_unprepare(mcf_data->clk_ipg); in sdhci_esdhc_mcf_remove()
501 clk_disable_unprepare(mcf_data->clk_ahb); in sdhci_esdhc_mcf_remove()
502 clk_disable_unprepare(mcf_data->clk_per); in sdhci_esdhc_mcf_remove()
509 .name = "sdhci-esdhc-mcf",
518 MODULE_DESCRIPTION("SDHCI driver for Freescale ColdFire eSDHC");