Lines Matching +full:sd +full:- +full:hs

1 // SPDX-License-Identifier: GPL-2.0-only
8 * Date: 2016-8-24
21 #include "sdhci-pltfm.h"
22 #include "sdhci-xenon.h"
41 dev_err(mmc_dev(host->mmc), "Internal clock never stabilised.\n"); in xenon_enable_internal_clk()
42 return -ETIMEDOUT; in xenon_enable_internal_clk()
50 /* Set SDCLK-off-while-idle */
91 host->mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY; in xenon_enable_sdhc()
96 host->mmc->caps &= ~MMC_CAP_BUS_WIDTH_TEST; in xenon_enable_sdhc()
137 /* Disable the Re-Tuning Request functionality */ in xenon_retune_setup()
142 /* Disable the Re-tuning Interrupt */ in xenon_retune_setup()
151 host->tuning_mode = SDHCI_TUNING_MODE_1; in xenon_retune_setup()
152 /* Set re-tuning period */ in xenon_retune_setup()
153 host->tuning_count = 1 << (priv->tuning_count - 1); in xenon_retune_setup()
167 /* Disable tuning request and auto-retuning again */ in xenon_reset_exit()
183 xenon_reset_exit(host, priv->sdhc_id, mask); in xenon_reset()
219 struct mmc_host *mmc = host->mmc; in xenon_set_power()
220 u8 pwr = host->pwr; in xenon_set_power()
224 if (host->pwr == pwr) in xenon_set_power()
227 if (host->pwr == 0) in xenon_set_power()
230 if (!IS_ERR(mmc->supply.vmmc)) in xenon_set_power()
231 mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd); in xenon_set_power()
278 * HS400/HS200/eMMC HS doesn't have Preset Value register. in xenon_set_ios()
281 * eMMC HS with preset_enabled set will trigger a bug in in xenon_set_ios()
284 if ((ios->timing == MMC_TIMING_MMC_HS400) || in xenon_set_ios()
285 (ios->timing == MMC_TIMING_MMC_HS200) || in xenon_set_ios()
286 (ios->timing == MMC_TIMING_MMC_HS)) { in xenon_set_ios()
287 host->preset_enabled = false; in xenon_set_ios()
288 host->quirks2 |= SDHCI_QUIRK2_PRESET_VALUE_BROKEN; in xenon_set_ios()
289 host->flags &= ~SDHCI_PV_ENABLED; in xenon_set_ios()
295 host->quirks2 &= ~SDHCI_QUIRK2_PRESET_VALUE_BROKEN; in xenon_set_ios()
301 if (host->clock > XENON_DEFAULT_SDCLK_FREQ) in xenon_set_ios()
302 xenon_set_sdclk_off_idle(host, priv->sdhc_id, true); in xenon_set_ios()
311 * Before SD/SDIO set signal voltage, SD bus clock should be in xenon_start_signal_voltage_switch()
318 * since keeping internal clock active obeys SD spec. in xenon_start_signal_voltage_switch()
322 xenon_soc_pad_ctrl(host, ios->signal_voltage); in xenon_start_signal_voltage_switch()
329 if (PTR_ERR(mmc->supply.vqmmc) == -ENODEV) in xenon_start_signal_voltage_switch()
337 * priv->init_card_type will be used in PHY timing adjustment.
346 priv->init_card_type = card->type; in xenon_init_card()
353 if (host->timing == MMC_TIMING_UHS_DDR50 || in xenon_execute_tuning()
354 host->timing == MMC_TIMING_MMC_DDR52) in xenon_execute_tuning()
362 if (host->tuning_mode != SDHCI_TUNING_MODE_1) in xenon_execute_tuning()
374 u8 sdhc_id = priv->sdhc_id; in xenon_enable_sdio_irq()
396 host->mmc_host_ops.set_ios = xenon_set_ios; in xenon_replace_mmc_host_ops()
397 host->mmc_host_ops.start_signal_voltage_switch = in xenon_replace_mmc_host_ops()
399 host->mmc_host_ops.init_card = xenon_init_card; in xenon_replace_mmc_host_ops()
400 host->mmc_host_ops.execute_tuning = xenon_execute_tuning; in xenon_replace_mmc_host_ops()
401 host->mmc_host_ops.enable_sdio_irq = xenon_enable_sdio_irq; in xenon_replace_mmc_host_ops()
406 * sdhc-id: the index of current SDHC.
408 * tun-count: the interval between re-tuning
412 struct device_node *np = pdev->dev.of_node; in xenon_probe_dt()
414 struct mmc_host *mmc = host->mmc; in xenon_probe_dt()
421 if (of_device_is_compatible(np, "marvell,armada-ap806-sdhci")) in xenon_probe_dt()
422 host->quirks2 |= SDHCI_QUIRK2_BROKEN_HS200; in xenon_probe_dt()
425 if (!of_property_read_u32(np, "marvell,xenon-sdhc-id", &sdhc_id)) { in xenon_probe_dt()
431 return -EINVAL; in xenon_probe_dt()
434 priv->sdhc_id = sdhc_id; in xenon_probe_dt()
437 if (!of_property_read_u32(np, "marvell,xenon-tun-count", in xenon_probe_dt()
440 dev_err(mmc_dev(mmc), "Wrong Re-tuning Count. Set default value %d\n", in xenon_probe_dt()
445 priv->tuning_count = tuning_count; in xenon_probe_dt()
454 u8 sdhc_id = priv->sdhc_id; in xenon_sdhc_prepare()
465 /* Disable SDCLK-Off-While-Idle before card init */ in xenon_sdhc_prepare()
477 u8 sdhc_id = priv->sdhc_id; in xenon_sdhc_unprepare()
504 pltfm_host->clk = devm_clk_get(&pdev->dev, "core"); in xenon_probe()
505 if (IS_ERR(pltfm_host->clk)) { in xenon_probe()
506 err = PTR_ERR(pltfm_host->clk); in xenon_probe()
507 dev_err(&pdev->dev, "Failed to setup input clk: %d\n", err); in xenon_probe()
510 err = clk_prepare_enable(pltfm_host->clk); in xenon_probe()
514 priv->axi_clk = devm_clk_get(&pdev->dev, "axi"); in xenon_probe()
515 if (IS_ERR(priv->axi_clk)) { in xenon_probe()
516 err = PTR_ERR(priv->axi_clk); in xenon_probe()
517 if (err == -EPROBE_DEFER) in xenon_probe()
520 err = clk_prepare_enable(priv->axi_clk); in xenon_probe()
525 err = mmc_of_parse(host->mmc); in xenon_probe()
542 pm_runtime_get_noresume(&pdev->dev); in xenon_probe()
543 pm_runtime_set_active(&pdev->dev); in xenon_probe()
544 pm_runtime_set_autosuspend_delay(&pdev->dev, 50); in xenon_probe()
545 pm_runtime_use_autosuspend(&pdev->dev); in xenon_probe()
546 pm_runtime_enable(&pdev->dev); in xenon_probe()
547 pm_suspend_ignore_children(&pdev->dev, 1); in xenon_probe()
553 pm_runtime_put_autosuspend(&pdev->dev); in xenon_probe()
558 pm_runtime_disable(&pdev->dev); in xenon_probe()
559 pm_runtime_put_noidle(&pdev->dev); in xenon_probe()
562 clk_disable_unprepare(priv->axi_clk); in xenon_probe()
564 clk_disable_unprepare(pltfm_host->clk); in xenon_probe()
576 pm_runtime_get_sync(&pdev->dev); in xenon_remove()
577 pm_runtime_disable(&pdev->dev); in xenon_remove()
578 pm_runtime_put_noidle(&pdev->dev); in xenon_remove()
583 clk_disable_unprepare(priv->axi_clk); in xenon_remove()
584 clk_disable_unprepare(pltfm_host->clk); in xenon_remove()
601 priv->restore_needed = true; in xenon_suspend()
618 if (host->tuning_mode != SDHCI_TUNING_MODE_3) in xenon_runtime_suspend()
619 mmc_retune_needed(host->mmc); in xenon_runtime_suspend()
621 clk_disable_unprepare(pltfm_host->clk); in xenon_runtime_suspend()
623 * Need to update the priv->clock here, or when runtime resume in xenon_runtime_suspend()
627 priv->clock = 0; in xenon_runtime_suspend()
638 ret = clk_prepare_enable(pltfm_host->clk); in xenon_runtime_resume()
644 if (priv->restore_needed) { in xenon_runtime_resume()
648 priv->restore_needed = false; in xenon_runtime_resume()
656 clk_disable_unprepare(pltfm_host->clk); in xenon_runtime_resume()
670 { .compatible = "marvell,armada-ap806-sdhci",},
671 { .compatible = "marvell,armada-cp110-sdhci",},
672 { .compatible = "marvell,armada-3700-sdhci",},
679 .name = "xenon-sdhci",