Lines Matching +full:xenon +full:- +full:tun +full:- +full:count
1 // SPDX-License-Identifier: GPL-2.0-only
3 * Driver for Marvell Xenon SDHC as a platform device
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()
188 xenon_reset_exit(host, priv->sdhc_id, mask); in xenon_reset()
192 * Xenon defines different values for HS200 and HS400
224 struct mmc_host *mmc = host->mmc; in xenon_set_power()
225 u8 pwr = host->pwr; in xenon_set_power()
229 if (host->pwr == pwr) in xenon_set_power()
232 if (host->pwr == 0) in xenon_set_power()
235 if (!IS_ERR(mmc->supply.vmmc)) in xenon_set_power()
236 mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd); in xenon_set_power()
263 * Xenon Specific Operations in mmc_host_ops
279 if ((ios->timing == MMC_TIMING_MMC_HS400) || in xenon_set_ios()
280 (ios->timing == MMC_TIMING_MMC_HS200) || in xenon_set_ios()
281 (ios->timing == MMC_TIMING_MMC_HS)) { in xenon_set_ios()
282 host->preset_enabled = false; in xenon_set_ios()
283 host->quirks2 |= SDHCI_QUIRK2_PRESET_VALUE_BROKEN; in xenon_set_ios()
284 host->flags &= ~SDHCI_PV_ENABLED; in xenon_set_ios()
290 host->quirks2 &= ~SDHCI_QUIRK2_PRESET_VALUE_BROKEN; in xenon_set_ios()
296 if (host->clock > XENON_DEFAULT_SDCLK_FREQ) in xenon_set_ios()
297 xenon_set_sdclk_off_idle(host, priv->sdhc_id, true); in xenon_set_ios()
317 xenon_soc_pad_ctrl(host, ios->signal_voltage); in xenon_start_signal_voltage_switch()
324 if (PTR_ERR(mmc->supply.vqmmc) == -ENODEV) in xenon_start_signal_voltage_switch()
332 * priv->init_card_type will be used in PHY timing adjustment.
341 priv->init_card_type = card->type; in xenon_init_card()
348 if (host->timing == MMC_TIMING_UHS_DDR50 || in xenon_execute_tuning()
349 host->timing == MMC_TIMING_MMC_DDR52) in xenon_execute_tuning()
353 * Currently force Xenon driver back to support mode 1 only, in xenon_execute_tuning()
354 * even though Xenon might claim to support mode 2 or mode 3. in xenon_execute_tuning()
357 if (host->tuning_mode != SDHCI_TUNING_MODE_1) in xenon_execute_tuning()
369 u8 sdhc_id = priv->sdhc_id; in xenon_enable_sdio_irq()
391 host->mmc_host_ops.set_ios = xenon_set_ios; in xenon_replace_mmc_host_ops()
392 host->mmc_host_ops.start_signal_voltage_switch = in xenon_replace_mmc_host_ops()
394 host->mmc_host_ops.init_card = xenon_init_card; in xenon_replace_mmc_host_ops()
395 host->mmc_host_ops.execute_tuning = xenon_execute_tuning; in xenon_replace_mmc_host_ops()
396 host->mmc_host_ops.enable_sdio_irq = xenon_enable_sdio_irq; in xenon_replace_mmc_host_ops()
400 * Parse Xenon specific DT properties:
401 * sdhc-id: the index of current SDHC.
403 * tun-count: the interval between re-tuning
407 struct device_node *np = pdev->dev.of_node; in xenon_probe_dt()
409 struct mmc_host *mmc = host->mmc; in xenon_probe_dt()
416 if (of_device_is_compatible(np, "marvell,armada-ap806-sdhci")) in xenon_probe_dt()
417 host->quirks2 |= SDHCI_QUIRK2_BROKEN_HS200; in xenon_probe_dt()
420 if (!of_property_read_u32(np, "marvell,xenon-sdhc-id", &sdhc_id)) { in xenon_probe_dt()
426 return -EINVAL; in xenon_probe_dt()
429 priv->sdhc_id = sdhc_id; in xenon_probe_dt()
432 if (!of_property_read_u32(np, "marvell,xenon-tun-count", in xenon_probe_dt()
435 dev_err(mmc_dev(mmc), "Wrong Re-tuning Count. Set default value %d\n", in xenon_probe_dt()
440 priv->tuning_count = tuning_count; in xenon_probe_dt()
449 u8 sdhc_id = priv->sdhc_id; in xenon_sdhc_prepare()
460 /* Disable SDCLK-Off-While-Idle before card init */ in xenon_sdhc_prepare()
472 u8 sdhc_id = priv->sdhc_id; in xenon_sdhc_unprepare()
494 * Link Xenon specific mmc_host_ops function, in xenon_probe()
499 pltfm_host->clk = devm_clk_get(&pdev->dev, "core"); in xenon_probe()
500 if (IS_ERR(pltfm_host->clk)) { in xenon_probe()
501 err = PTR_ERR(pltfm_host->clk); in xenon_probe()
502 dev_err(&pdev->dev, "Failed to setup input clk: %d\n", err); in xenon_probe()
505 err = clk_prepare_enable(pltfm_host->clk); in xenon_probe()
509 priv->axi_clk = devm_clk_get(&pdev->dev, "axi"); in xenon_probe()
510 if (IS_ERR(priv->axi_clk)) { in xenon_probe()
511 err = PTR_ERR(priv->axi_clk); in xenon_probe()
512 if (err == -EPROBE_DEFER) in xenon_probe()
515 err = clk_prepare_enable(priv->axi_clk); in xenon_probe()
520 err = mmc_of_parse(host->mmc); in xenon_probe()
528 /* Xenon specific dt parse */ in xenon_probe()
537 pm_runtime_get_noresume(&pdev->dev); in xenon_probe()
538 pm_runtime_set_active(&pdev->dev); in xenon_probe()
539 pm_runtime_set_autosuspend_delay(&pdev->dev, 50); in xenon_probe()
540 pm_runtime_use_autosuspend(&pdev->dev); in xenon_probe()
541 pm_runtime_enable(&pdev->dev); in xenon_probe()
542 pm_suspend_ignore_children(&pdev->dev, 1); in xenon_probe()
548 pm_runtime_put_autosuspend(&pdev->dev); in xenon_probe()
553 pm_runtime_disable(&pdev->dev); in xenon_probe()
554 pm_runtime_put_noidle(&pdev->dev); in xenon_probe()
557 clk_disable_unprepare(priv->axi_clk); in xenon_probe()
559 clk_disable_unprepare(pltfm_host->clk); in xenon_probe()
571 pm_runtime_get_sync(&pdev->dev); in xenon_remove()
572 pm_runtime_disable(&pdev->dev); in xenon_remove()
573 pm_runtime_put_noidle(&pdev->dev); in xenon_remove()
578 clk_disable_unprepare(priv->axi_clk); in xenon_remove()
579 clk_disable_unprepare(pltfm_host->clk); in xenon_remove()
596 priv->restore_needed = true; in xenon_suspend()
613 if (host->tuning_mode != SDHCI_TUNING_MODE_3) in xenon_runtime_suspend()
614 mmc_retune_needed(host->mmc); in xenon_runtime_suspend()
616 clk_disable_unprepare(pltfm_host->clk); in xenon_runtime_suspend()
618 * Need to update the priv->clock here, or when runtime resume in xenon_runtime_suspend()
622 priv->clock = 0; in xenon_runtime_suspend()
633 ret = clk_prepare_enable(pltfm_host->clk); in xenon_runtime_resume()
639 if (priv->restore_needed) { in xenon_runtime_resume()
643 priv->restore_needed = false; in xenon_runtime_resume()
651 clk_disable_unprepare(pltfm_host->clk); in xenon_runtime_resume()
665 { .compatible = "marvell,armada-ap806-sdhci",},
666 { .compatible = "marvell,armada-cp110-sdhci",},
667 { .compatible = "marvell,armada-3700-sdhci",},
674 .name = "xenon-sdhci",
685 MODULE_DESCRIPTION("SDHCI platform driver for Marvell Xenon SDHC");