Lines Matching +full:non +full:- +full:muxed
1 // SPDX-License-Identifier: GPL-2.0-only
17 #include <linux/mmc/slot-gpio.h>
24 #include "sdhci-pltfm.h"
57 mc1r = readb(host->ioaddr + SDMMC_MC1R); in sdhci_at91_set_force_card_detect()
59 writeb(mc1r, host->ioaddr + SDMMC_MC1R); in sdhci_at91_set_force_card_detect()
66 host->mmc->actual_clock = 0; in sdhci_at91_set_clock()
71 * internal clock, changing the configuration and re-enabling the in sdhci_at91_set_clock()
83 clk = sdhci_calc_clk(host, clock, &host->mmc->actual_clock); in sdhci_at91_set_clock()
92 mmc_hostname(host->mmc)); in sdhci_at91_set_clock()
116 if ((host->mmc->caps & MMC_CAP_NONREMOVABLE) in sdhci_at91_reset()
117 || mmc_gpio_get_cd(host->mmc) >= 0) in sdhci_at91_reset()
120 if (priv->cal_always_on && (mask & SDHCI_RESET_ALL)) { in sdhci_at91_reset()
128 dev_err(mmc_dev(host->mmc), "Failed to calibrate\n"); in sdhci_at91_reset()
156 { .compatible = "atmel,sama5d2-sdhci", .data = &soc_data_sama5d2 },
157 { .compatible = "microchip,sam9x60-sdhci", .data = &soc_data_sam9x60 },
172 clk_prepare_enable(priv->hclock); in sdhci_at91_set_clks_presets()
173 caps0 = readl(host->ioaddr + SDHCI_CAPABILITIES); in sdhci_at91_set_clks_presets()
174 caps1 = readl(host->ioaddr + SDHCI_CAPABILITIES_1); in sdhci_at91_set_clks_presets()
176 gck_rate = clk_get_rate(priv->gck); in sdhci_at91_set_clks_presets()
177 if (priv->soc_data->baseclk_is_generated_internally) in sdhci_at91_set_clks_presets()
178 clk_base_rate = gck_rate / priv->soc_data->divider_for_baseclk; in sdhci_at91_set_clks_presets()
180 clk_base_rate = clk_get_rate(priv->mainck); in sdhci_at91_set_clks_presets()
183 clk_mul = gck_rate / clk_base_rate - 1; in sdhci_at91_set_clks_presets()
190 writel(SDMMC_CACR_KEY | SDMMC_CACR_CAPWREN, host->ioaddr + SDMMC_CACR); in sdhci_at91_set_clks_presets()
191 writel(caps0, host->ioaddr + SDHCI_CAPABILITIES); in sdhci_at91_set_clks_presets()
192 writel(caps1, host->ioaddr + SDHCI_CAPABILITIES_1); in sdhci_at91_set_clks_presets()
194 writel(0, host->ioaddr + SDMMC_CACR); in sdhci_at91_set_clks_presets()
205 preset_div = DIV_ROUND_UP(gck_rate, 24000000) - 1; in sdhci_at91_set_clks_presets()
207 host->ioaddr + SDHCI_PRESET_FOR_SDR12); in sdhci_at91_set_clks_presets()
208 preset_div = DIV_ROUND_UP(gck_rate, 50000000) - 1; in sdhci_at91_set_clks_presets()
210 host->ioaddr + SDHCI_PRESET_FOR_SDR25); in sdhci_at91_set_clks_presets()
211 preset_div = DIV_ROUND_UP(gck_rate, 100000000) - 1; in sdhci_at91_set_clks_presets()
213 host->ioaddr + SDHCI_PRESET_FOR_SDR50); in sdhci_at91_set_clks_presets()
214 preset_div = DIV_ROUND_UP(gck_rate, 120000000) - 1; in sdhci_at91_set_clks_presets()
216 host->ioaddr + SDHCI_PRESET_FOR_SDR104); in sdhci_at91_set_clks_presets()
217 preset_div = DIV_ROUND_UP(gck_rate, 50000000) - 1; in sdhci_at91_set_clks_presets()
219 host->ioaddr + SDHCI_PRESET_FOR_DDR50); in sdhci_at91_set_clks_presets()
221 clk_prepare_enable(priv->mainck); in sdhci_at91_set_clks_presets()
222 clk_prepare_enable(priv->gck); in sdhci_at91_set_clks_presets()
237 priv->restore_needed = true; in sdhci_at91_suspend()
253 if (host->tuning_mode != SDHCI_TUNING_MODE_3) in sdhci_at91_runtime_suspend()
254 mmc_retune_needed(host->mmc); in sdhci_at91_runtime_suspend()
256 clk_disable_unprepare(priv->gck); in sdhci_at91_runtime_suspend()
257 clk_disable_unprepare(priv->hclock); in sdhci_at91_runtime_suspend()
258 clk_disable_unprepare(priv->mainck); in sdhci_at91_runtime_suspend()
270 if (priv->restore_needed) { in sdhci_at91_runtime_resume()
275 priv->restore_needed = false; in sdhci_at91_runtime_resume()
279 ret = clk_prepare_enable(priv->mainck); in sdhci_at91_runtime_resume()
285 ret = clk_prepare_enable(priv->hclock); in sdhci_at91_runtime_resume()
291 ret = clk_prepare_enable(priv->gck); in sdhci_at91_runtime_resume()
318 match = of_match_device(sdhci_at91_dt_match, &pdev->dev); in sdhci_at91_probe()
320 return -EINVAL; in sdhci_at91_probe()
321 soc_data = match->data; in sdhci_at91_probe()
323 host = sdhci_pltfm_init(pdev, soc_data->pdata, sizeof(*priv)); in sdhci_at91_probe()
329 priv->soc_data = soc_data; in sdhci_at91_probe()
331 priv->mainck = devm_clk_get(&pdev->dev, "baseclk"); in sdhci_at91_probe()
332 if (IS_ERR(priv->mainck)) { in sdhci_at91_probe()
333 if (soc_data->baseclk_is_generated_internally) { in sdhci_at91_probe()
334 priv->mainck = NULL; in sdhci_at91_probe()
336 dev_err(&pdev->dev, "failed to get baseclk\n"); in sdhci_at91_probe()
337 ret = PTR_ERR(priv->mainck); in sdhci_at91_probe()
342 priv->hclock = devm_clk_get(&pdev->dev, "hclock"); in sdhci_at91_probe()
343 if (IS_ERR(priv->hclock)) { in sdhci_at91_probe()
344 dev_err(&pdev->dev, "failed to get hclock\n"); in sdhci_at91_probe()
345 ret = PTR_ERR(priv->hclock); in sdhci_at91_probe()
349 priv->gck = devm_clk_get(&pdev->dev, "multclk"); in sdhci_at91_probe()
350 if (IS_ERR(priv->gck)) { in sdhci_at91_probe()
351 dev_err(&pdev->dev, "failed to get multclk\n"); in sdhci_at91_probe()
352 ret = PTR_ERR(priv->gck); in sdhci_at91_probe()
356 ret = sdhci_at91_set_clks_presets(&pdev->dev); in sdhci_at91_probe()
360 priv->restore_needed = false; in sdhci_at91_probe()
366 priv->cal_always_on = in sdhci_at91_probe()
367 device_property_read_bool(&pdev->dev, in sdhci_at91_probe()
368 "microchip,sdcal-inverted"); in sdhci_at91_probe()
370 ret = mmc_of_parse(host->mmc); in sdhci_at91_probe()
376 pm_runtime_get_noresume(&pdev->dev); in sdhci_at91_probe()
377 pm_runtime_set_active(&pdev->dev); in sdhci_at91_probe()
378 pm_runtime_enable(&pdev->dev); in sdhci_at91_probe()
379 pm_runtime_set_autosuspend_delay(&pdev->dev, 50); in sdhci_at91_probe()
380 pm_runtime_use_autosuspend(&pdev->dev); in sdhci_at91_probe()
383 host->quirks2 |= SDHCI_QUIRK2_BROKEN_HS200; in sdhci_at91_probe()
393 * For that reason, it is not planned to wake-up on a card detect irq in sdhci_at91_probe()
395 * If we want to use runtime PM and to be able to wake-up on card in sdhci_at91_probe()
400 * to enable polling via device tree with broken-cd property. in sdhci_at91_probe()
402 if (mmc_card_is_removable(host->mmc) && in sdhci_at91_probe()
403 mmc_gpio_get_cd(host->mmc) < 0) { in sdhci_at91_probe()
404 host->mmc->caps |= MMC_CAP_NEEDS_POLL; in sdhci_at91_probe()
405 host->quirks &= ~SDHCI_QUIRK_BROKEN_CARD_DETECTION; in sdhci_at91_probe()
412 * detect pin is not muxed to SDHCI controller, a default value is in sdhci_at91_probe()
415 * avoid this case, if the device is non removable then the card in sdhci_at91_probe()
422 if ((host->mmc->caps & MMC_CAP_NONREMOVABLE) in sdhci_at91_probe()
423 || mmc_gpio_get_cd(host->mmc) >= 0) in sdhci_at91_probe()
426 pm_runtime_put_autosuspend(&pdev->dev); in sdhci_at91_probe()
431 pm_runtime_disable(&pdev->dev); in sdhci_at91_probe()
432 pm_runtime_set_suspended(&pdev->dev); in sdhci_at91_probe()
433 pm_runtime_put_noidle(&pdev->dev); in sdhci_at91_probe()
435 clk_disable_unprepare(priv->gck); in sdhci_at91_probe()
436 clk_disable_unprepare(priv->mainck); in sdhci_at91_probe()
437 clk_disable_unprepare(priv->hclock); in sdhci_at91_probe()
448 struct clk *gck = priv->gck; in sdhci_at91_remove()
449 struct clk *hclock = priv->hclock; in sdhci_at91_remove()
450 struct clk *mainck = priv->mainck; in sdhci_at91_remove()
452 pm_runtime_get_sync(&pdev->dev); in sdhci_at91_remove()
453 pm_runtime_disable(&pdev->dev); in sdhci_at91_remove()
454 pm_runtime_put_noidle(&pdev->dev); in sdhci_at91_remove()
467 .name = "sdhci-at91",