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

1 // SPDX-License-Identifier: GPL-2.0-only
8 * Date: 2016-8-24
22 #include "sdhci-pltfm.h"
23 #include "sdhci-xenon.h"
42 dev_err(mmc_dev(host->mmc), "Internal clock never stabilised.\n"); in xenon_enable_internal_clk()
43 return -ETIMEDOUT; in xenon_enable_internal_clk()
51 /* Set SDCLK-off-while-idle */
92 host->mmc->caps |= MMC_CAP_WAIT_WHILE_BUSY; in xenon_enable_sdhc()
97 host->mmc->caps &= ~MMC_CAP_BUS_WIDTH_TEST; in xenon_enable_sdhc()
138 /* Disable the Re-Tuning Request functionality */ in xenon_retune_setup()
143 /* Disable the Re-tuning Interrupt */ in xenon_retune_setup()
152 host->tuning_mode = SDHCI_TUNING_MODE_1; in xenon_retune_setup()
153 /* Set re-tuning period */ in xenon_retune_setup()
154 host->tuning_count = 1 << (priv->tuning_count - 1); in xenon_retune_setup()
168 /* Disable tuning request and auto-retuning again */ in xenon_reset_exit()
189 xenon_reset_exit(host, priv->sdhc_id, mask); in xenon_reset()
225 struct mmc_host *mmc = host->mmc; in xenon_set_power()
226 u8 pwr = host->pwr; in xenon_set_power()
230 if (host->pwr == pwr) in xenon_set_power()
233 if (host->pwr == 0) in xenon_set_power()
236 if (!IS_ERR(mmc->supply.vmmc)) in xenon_set_power()
237 mmc_regulator_set_ocr(mmc, mmc->supply.vmmc, vdd); in xenon_set_power()
250 if (pltfm_host->clk) in xenon_get_max_clock()
253 return pltfm_host->clock; in xenon_get_max_clock()
290 if ((ios->timing == MMC_TIMING_MMC_HS400) || in xenon_set_ios()
291 (ios->timing == MMC_TIMING_MMC_HS200) || in xenon_set_ios()
292 (ios->timing == MMC_TIMING_MMC_HS)) { in xenon_set_ios()
293 host->preset_enabled = false; in xenon_set_ios()
294 host->quirks2 |= SDHCI_QUIRK2_PRESET_VALUE_BROKEN; in xenon_set_ios()
295 host->flags &= ~SDHCI_PV_ENABLED; in xenon_set_ios()
301 host->quirks2 &= ~SDHCI_QUIRK2_PRESET_VALUE_BROKEN; in xenon_set_ios()
307 if (host->clock > XENON_DEFAULT_SDCLK_FREQ) in xenon_set_ios()
308 xenon_set_sdclk_off_idle(host, priv->sdhc_id, true); in xenon_set_ios()
328 xenon_soc_pad_ctrl(host, ios->signal_voltage); in xenon_start_signal_voltage_switch()
335 if (PTR_ERR(mmc->supply.vqmmc) == -ENODEV) in xenon_start_signal_voltage_switch()
343 * priv->init_card_type will be used in PHY timing adjustment.
352 priv->init_card_type = card->type; in xenon_init_card()
359 if (host->timing == MMC_TIMING_UHS_DDR50 || in xenon_execute_tuning()
360 host->timing == MMC_TIMING_MMC_DDR52) in xenon_execute_tuning()
368 if (host->tuning_mode != SDHCI_TUNING_MODE_1) in xenon_execute_tuning()
380 u8 sdhc_id = priv->sdhc_id; in xenon_enable_sdio_irq()
402 host->mmc_host_ops.set_ios = xenon_set_ios; in xenon_replace_mmc_host_ops()
403 host->mmc_host_ops.start_signal_voltage_switch = in xenon_replace_mmc_host_ops()
405 host->mmc_host_ops.init_card = xenon_init_card; in xenon_replace_mmc_host_ops()
406 host->mmc_host_ops.execute_tuning = xenon_execute_tuning; in xenon_replace_mmc_host_ops()
407 host->mmc_host_ops.enable_sdio_irq = xenon_enable_sdio_irq; in xenon_replace_mmc_host_ops()
412 * sdhc-id: the index of current SDHC.
414 * tun-count: the interval between re-tuning
418 struct device *dev = &pdev->dev; in xenon_probe_params()
420 struct mmc_host *mmc = host->mmc; in xenon_probe_params()
427 if (priv->hw_version == XENON_AP806) in xenon_probe_params()
428 host->quirks2 |= SDHCI_QUIRK2_BROKEN_HS200; in xenon_probe_params()
431 if (!device_property_read_u32(dev, "marvell,xenon-sdhc-id", &sdhc_id)) { in xenon_probe_params()
437 return -EINVAL; in xenon_probe_params()
440 priv->sdhc_id = sdhc_id; in xenon_probe_params()
443 if (!device_property_read_u32(dev, "marvell,xenon-tun-count", in xenon_probe_params()
446 dev_err(mmc_dev(mmc), "Wrong Re-tuning Count. Set default value %d\n", in xenon_probe_params()
451 priv->tuning_count = tuning_count; in xenon_probe_params()
460 u8 sdhc_id = priv->sdhc_id; in xenon_sdhc_prepare()
471 /* Disable SDCLK-Off-While-Idle before card init */ in xenon_sdhc_prepare()
483 u8 sdhc_id = priv->sdhc_id; in xenon_sdhc_unprepare()
492 struct device *dev = &pdev->dev; in xenon_probe()
505 priv->hw_version = (unsigned long)device_get_match_data(&pdev->dev); in xenon_probe()
513 if (dev->of_node) { in xenon_probe()
514 pltfm_host->clk = devm_clk_get(&pdev->dev, "core"); in xenon_probe()
515 if (IS_ERR(pltfm_host->clk)) { in xenon_probe()
516 err = PTR_ERR(pltfm_host->clk); in xenon_probe()
517 dev_err(&pdev->dev, "Failed to setup input clk: %d\n", err); in xenon_probe()
520 err = clk_prepare_enable(pltfm_host->clk); in xenon_probe()
524 priv->axi_clk = devm_clk_get(&pdev->dev, "axi"); in xenon_probe()
525 if (IS_ERR(priv->axi_clk)) { in xenon_probe()
526 err = PTR_ERR(priv->axi_clk); in xenon_probe()
527 if (err == -EPROBE_DEFER) in xenon_probe()
530 err = clk_prepare_enable(priv->axi_clk); in xenon_probe()
536 err = mmc_of_parse(host->mmc); in xenon_probe()
553 pm_runtime_get_noresume(&pdev->dev); in xenon_probe()
554 pm_runtime_set_active(&pdev->dev); in xenon_probe()
555 pm_runtime_set_autosuspend_delay(&pdev->dev, 50); in xenon_probe()
556 pm_runtime_use_autosuspend(&pdev->dev); in xenon_probe()
557 pm_runtime_enable(&pdev->dev); in xenon_probe()
558 pm_suspend_ignore_children(&pdev->dev, 1); in xenon_probe()
564 pm_runtime_put_autosuspend(&pdev->dev); in xenon_probe()
569 pm_runtime_disable(&pdev->dev); in xenon_probe()
570 pm_runtime_put_noidle(&pdev->dev); in xenon_probe()
573 clk_disable_unprepare(priv->axi_clk); in xenon_probe()
575 clk_disable_unprepare(pltfm_host->clk); in xenon_probe()
587 pm_runtime_get_sync(&pdev->dev); in xenon_remove()
588 pm_runtime_disable(&pdev->dev); in xenon_remove()
589 pm_runtime_put_noidle(&pdev->dev); in xenon_remove()
594 clk_disable_unprepare(priv->axi_clk); in xenon_remove()
595 clk_disable_unprepare(pltfm_host->clk); in xenon_remove()
610 priv->restore_needed = true; in xenon_suspend()
627 if (host->tuning_mode != SDHCI_TUNING_MODE_3) in xenon_runtime_suspend()
628 mmc_retune_needed(host->mmc); in xenon_runtime_suspend()
630 clk_disable_unprepare(pltfm_host->clk); in xenon_runtime_suspend()
632 * Need to update the priv->clock here, or when runtime resume in xenon_runtime_suspend()
636 priv->clock = 0; in xenon_runtime_suspend()
647 ret = clk_prepare_enable(pltfm_host->clk); in xenon_runtime_resume()
653 if (priv->restore_needed) { in xenon_runtime_resume()
657 priv->restore_needed = false; in xenon_runtime_resume()
665 clk_disable_unprepare(pltfm_host->clk); in xenon_runtime_resume()
679 { .compatible = "marvell,armada-ap806-sdhci", .data = (void *)XENON_AP806},
680 { .compatible = "marvell,armada-ap807-sdhci", .data = (void *)XENON_AP807},
681 { .compatible = "marvell,armada-cp110-sdhci", .data = (void *)XENON_CP110},
682 { .compatible = "marvell,armada-3700-sdhci", .data = (void *)XENON_A3700},
699 .name = "xenon-sdhci",
711 MODULE_DESCRIPTION("SDHCI platform driver for Marvell Xenon SDHC");