Lines Matching +full:ast2500 +full:- +full:sd +full:- +full:controller

1 // SPDX-License-Identifier: GPL-2.0-or-later
17 #include "sdhci-pltfm.h"
43 spin_lock(&sdc->lock); in aspeed_sdc_configure_8bit_mode()
44 info = readl(sdc->regs + ASPEED_SDC_INFO); in aspeed_sdc_configure_8bit_mode()
46 info |= sdhci->width_mask; in aspeed_sdc_configure_8bit_mode()
48 info &= ~sdhci->width_mask; in aspeed_sdc_configure_8bit_mode()
49 writel(info, sdc->regs + ASPEED_SDC_INFO); in aspeed_sdc_configure_8bit_mode()
50 spin_unlock(&sdc->lock); in aspeed_sdc_configure_8bit_mode()
61 parent = clk_get_rate(pltfm_host->clk); in aspeed_sdhci_set_clock()
68 if (WARN_ON(clock > host->max_clk)) in aspeed_sdhci_set_clock()
69 clock = host->max_clk; in aspeed_sdhci_set_clock()
84 if (host->mmc->f_max) in aspeed_sdhci_get_max_clock()
85 return host->mmc->f_max; in aspeed_sdhci_get_max_clock()
99 aspeed_sdc = aspeed_sdhci->parent; in aspeed_sdhci_set_bus_width()
101 /* Set/clear 8-bit mode */ in aspeed_sdhci_set_bus_width()
116 u32 val = readl(host->ioaddr + reg); in aspeed_sdhci_readl()
119 (host->mmc->caps2 & MMC_CAP2_CD_ACTIVE_HIGH)) in aspeed_sdhci_readl()
146 return -EINVAL; in aspeed_sdhci_calculate_slot()
148 if (res->start < dev->parent->res->start) in aspeed_sdhci_calculate_slot()
149 return -EINVAL; in aspeed_sdhci_calculate_slot()
151 delta = res->start - dev->parent->res->start; in aspeed_sdhci_calculate_slot()
152 if (delta & (0x100 - 1)) in aspeed_sdhci_calculate_slot()
153 return -EINVAL; in aspeed_sdhci_calculate_slot()
155 return (delta / 0x100) - 1; in aspeed_sdhci_calculate_slot()
173 dev->parent = dev_get_drvdata(pdev->dev.parent); in aspeed_sdhci_probe()
181 return -EINVAL; in aspeed_sdhci_probe()
183 dev_info(&pdev->dev, "Configuring for slot %d\n", slot); in aspeed_sdhci_probe()
184 dev->width_mask = !slot ? ASPEED_SDC_S0MMC8 : ASPEED_SDC_S1MMC8; in aspeed_sdhci_probe()
188 pltfm_host->clk = devm_clk_get(&pdev->dev, NULL); in aspeed_sdhci_probe()
189 if (IS_ERR(pltfm_host->clk)) in aspeed_sdhci_probe()
190 return PTR_ERR(pltfm_host->clk); in aspeed_sdhci_probe()
192 ret = clk_prepare_enable(pltfm_host->clk); in aspeed_sdhci_probe()
194 dev_err(&pdev->dev, "Unable to enable SDIO clock\n"); in aspeed_sdhci_probe()
198 ret = mmc_of_parse(host->mmc); in aspeed_sdhci_probe()
209 clk_disable_unprepare(pltfm_host->clk); in aspeed_sdhci_probe()
226 clk_disable_unprepare(pltfm_host->clk); in aspeed_sdhci_remove()
234 { .compatible = "aspeed,ast2400-sdhci", },
235 { .compatible = "aspeed,ast2500-sdhci", },
236 { .compatible = "aspeed,ast2600-sdhci", },
242 .name = "sdhci-aspeed",
257 sdc = devm_kzalloc(&pdev->dev, sizeof(*sdc), GFP_KERNEL); in aspeed_sdc_probe()
259 return -ENOMEM; in aspeed_sdc_probe()
261 spin_lock_init(&sdc->lock); in aspeed_sdc_probe()
263 sdc->clk = devm_clk_get(&pdev->dev, NULL); in aspeed_sdc_probe()
264 if (IS_ERR(sdc->clk)) in aspeed_sdc_probe()
265 return PTR_ERR(sdc->clk); in aspeed_sdc_probe()
267 ret = clk_prepare_enable(sdc->clk); in aspeed_sdc_probe()
269 dev_err(&pdev->dev, "Unable to enable SDCLK\n"); in aspeed_sdc_probe()
273 sdc->res = platform_get_resource(pdev, IORESOURCE_MEM, 0); in aspeed_sdc_probe()
274 sdc->regs = devm_ioremap_resource(&pdev->dev, sdc->res); in aspeed_sdc_probe()
275 if (IS_ERR(sdc->regs)) { in aspeed_sdc_probe()
276 ret = PTR_ERR(sdc->regs); in aspeed_sdc_probe()
280 dev_set_drvdata(&pdev->dev, sdc); in aspeed_sdc_probe()
282 parent = pdev->dev.of_node; in aspeed_sdc_probe()
286 cpdev = of_platform_device_create(child, NULL, &pdev->dev); in aspeed_sdc_probe()
289 ret = -ENODEV; in aspeed_sdc_probe()
297 clk_disable_unprepare(sdc->clk); in aspeed_sdc_probe()
303 struct aspeed_sdc *sdc = dev_get_drvdata(&pdev->dev); in aspeed_sdc_remove()
305 clk_disable_unprepare(sdc->clk); in aspeed_sdc_remove()
311 { .compatible = "aspeed,ast2400-sd-controller", },
312 { .compatible = "aspeed,ast2500-sd-controller", },
313 { .compatible = "aspeed,ast2600-sd-controller", },
321 .name = "sd-controller-aspeed",
353 MODULE_DESCRIPTION("Driver for the ASPEED SD/SDIO/SDHCI Controllers");