Skip to content

Commit 8048822

Browse files
Sowjanya KomatineniUlf Hansson
authored andcommitted
sdhci: tegra: Add missing TMCLK for data timeout
commit b5a84ec ("mmc: tegra: Add Tegra210 support") Tegra210 and later has a separate sdmmc_legacy_tm (TMCLK) used by Tegra SDMMC hawdware for data timeout to achive better timeout than using SDCLK and using TMCLK is recommended. USE_TMCLK_FOR_DATA_TIMEOUT bit in Tegra SDMMC register SDHCI_TEGRA_VENDOR_SYS_SW_CTRL can be used to choose either TMCLK or SDCLK for data timeout. Default USE_TMCLK_FOR_DATA_TIMEOUT bit is set to 1 and TMCLK is used for data timeout by Tegra SDMMC hardware and having TMCLK not enabled is not recommended. So, this patch adds quirk NVQUIRK_HAS_TMCLK for SoC having separate timeout clock and keeps TMCLK enabled all the time. Fixes: b5a84ec ("mmc: tegra: Add Tegra210 support") Cc: stable <stable@vger.kernel.org> # 5.4 Tested-by: Jon Hunter <jonathanh@nvidia.com> Reviewed-by: Jon Hunter <jonathanh@nvidia.com> Acked-by: Adrian Hunter <adrian.hunter@intel.com> Signed-off-by: Sowjanya Komatineni <skomatineni@nvidia.com> Link: https://lore.kernel.org/r/1598548861-32373-8-git-send-email-skomatineni@nvidia.com Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
1 parent c956c0c commit 8048822

1 file changed

Lines changed: 51 additions & 2 deletions

File tree

drivers/mmc/host/sdhci-tegra.c

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,12 @@
110110
#define NVQUIRK_DIS_CARD_CLK_CONFIG_TAP BIT(8)
111111
#define NVQUIRK_CQHCI_DCMD_R1B_CMD_TIMING BIT(9)
112112

113+
/*
114+
* NVQUIRK_HAS_TMCLK is for SoC's having separate timeout clock for Tegra
115+
* SDMMC hardware data timeout.
116+
*/
117+
#define NVQUIRK_HAS_TMCLK BIT(10)
118+
113119
/* SDMMC CQE Base Address for Tegra Host Ver 4.1 and Higher */
114120
#define SDHCI_TEGRA_CQE_BASE_ADDR 0xF000
115121

@@ -140,6 +146,7 @@ struct sdhci_tegra_autocal_offsets {
140146
struct sdhci_tegra {
141147
const struct sdhci_tegra_soc_data *soc_data;
142148
struct gpio_desc *power_gpio;
149+
struct clk *tmclk;
143150
bool ddr_signaling;
144151
bool pad_calib_required;
145152
bool pad_control_available;
@@ -1433,7 +1440,8 @@ static const struct sdhci_tegra_soc_data soc_data_tegra210 = {
14331440
NVQUIRK_HAS_PADCALIB |
14341441
NVQUIRK_DIS_CARD_CLK_CONFIG_TAP |
14351442
NVQUIRK_ENABLE_SDR50 |
1436-
NVQUIRK_ENABLE_SDR104,
1443+
NVQUIRK_ENABLE_SDR104 |
1444+
NVQUIRK_HAS_TMCLK,
14371445
.min_tap_delay = 106,
14381446
.max_tap_delay = 185,
14391447
};
@@ -1471,6 +1479,7 @@ static const struct sdhci_tegra_soc_data soc_data_tegra186 = {
14711479
NVQUIRK_DIS_CARD_CLK_CONFIG_TAP |
14721480
NVQUIRK_ENABLE_SDR50 |
14731481
NVQUIRK_ENABLE_SDR104 |
1482+
NVQUIRK_HAS_TMCLK |
14741483
NVQUIRK_CQHCI_DCMD_R1B_CMD_TIMING,
14751484
.min_tap_delay = 84,
14761485
.max_tap_delay = 136,
@@ -1483,7 +1492,8 @@ static const struct sdhci_tegra_soc_data soc_data_tegra194 = {
14831492
NVQUIRK_HAS_PADCALIB |
14841493
NVQUIRK_DIS_CARD_CLK_CONFIG_TAP |
14851494
NVQUIRK_ENABLE_SDR50 |
1486-
NVQUIRK_ENABLE_SDR104,
1495+
NVQUIRK_ENABLE_SDR104 |
1496+
NVQUIRK_HAS_TMCLK,
14871497
.min_tap_delay = 96,
14881498
.max_tap_delay = 139,
14891499
};
@@ -1611,6 +1621,43 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
16111621
goto err_power_req;
16121622
}
16131623

1624+
/*
1625+
* Tegra210 has a separate SDMMC_LEGACY_TM clock used for host
1626+
* timeout clock and SW can choose TMCLK or SDCLK for hardware
1627+
* data timeout through the bit USE_TMCLK_FOR_DATA_TIMEOUT of
1628+
* the register SDHCI_TEGRA_VENDOR_SYS_SW_CTRL.
1629+
*
1630+
* USE_TMCLK_FOR_DATA_TIMEOUT bit default is set to 1 and SDMMC uses
1631+
* 12Mhz TMCLK which is advertised in host capability register.
1632+
* With TMCLK of 12Mhz provides maximum data timeout period that can
1633+
* be achieved is 11s better than using SDCLK for data timeout.
1634+
*
1635+
* So, TMCLK is set to 12Mhz and kept enabled all the time on SoC's
1636+
* supporting separate TMCLK.
1637+
*/
1638+
1639+
if (soc_data->nvquirks & NVQUIRK_HAS_TMCLK) {
1640+
clk = devm_clk_get(&pdev->dev, "tmclk");
1641+
if (IS_ERR(clk)) {
1642+
rc = PTR_ERR(clk);
1643+
if (rc == -EPROBE_DEFER)
1644+
goto err_power_req;
1645+
1646+
dev_warn(&pdev->dev, "failed to get tmclk: %d\n", rc);
1647+
clk = NULL;
1648+
}
1649+
1650+
clk_set_rate(clk, 12000000);
1651+
rc = clk_prepare_enable(clk);
1652+
if (rc) {
1653+
dev_err(&pdev->dev,
1654+
"failed to enable tmclk: %d\n", rc);
1655+
goto err_power_req;
1656+
}
1657+
1658+
tegra_host->tmclk = clk;
1659+
}
1660+
16141661
clk = devm_clk_get(mmc_dev(host->mmc), NULL);
16151662
if (IS_ERR(clk)) {
16161663
rc = PTR_ERR(clk);
@@ -1654,6 +1701,7 @@ static int sdhci_tegra_probe(struct platform_device *pdev)
16541701
err_rst_get:
16551702
clk_disable_unprepare(pltfm_host->clk);
16561703
err_clk_get:
1704+
clk_disable_unprepare(tegra_host->tmclk);
16571705
err_power_req:
16581706
err_parse_dt:
16591707
sdhci_pltfm_free(pdev);
@@ -1671,6 +1719,7 @@ static int sdhci_tegra_remove(struct platform_device *pdev)
16711719
reset_control_assert(tegra_host->rst);
16721720
usleep_range(2000, 4000);
16731721
clk_disable_unprepare(pltfm_host->clk);
1722+
clk_disable_unprepare(tegra_host->tmclk);
16741723

16751724
sdhci_pltfm_free(pdev);
16761725

0 commit comments

Comments
 (0)