mmc: sdhci-of-dwcmshc: define sdio timeout clocks
authorLiam Fraser <liam@raspberrypi.com>
Thu, 14 Mar 2019 16:01:26 +0000 (16:01 +0000)
committerDom Cobley <popcornmix@gmail.com>
Mon, 19 Feb 2024 11:34:47 +0000 (11:34 +0000)
Signed-off-by: Liam Fraser <liam@raspberrypi.com>
drivers/mmc/host/sdhci-of-dwcmshc.c
drivers/mmc/host/sdhci-pltfm.c
drivers/mmc/host/sdhci-pltfm.h

index 6129591..0ce20f6 100644 (file)
@@ -343,6 +343,7 @@ static const struct sdhci_ops sdhci_dwcmshc_ops = {
        .set_bus_width          = sdhci_set_bus_width,
        .set_uhs_signaling      = dwcmshc_set_uhs_signaling,
        .get_max_clock          = dwcmshc_get_max_clock,
+       .get_timeout_clock      = sdhci_pltfm_clk_get_timeout_clock,
        .reset                  = sdhci_reset,
        .adma_write_desc        = dwcmshc_adma_write_desc,
 };
@@ -514,6 +515,16 @@ static int dwcmshc_probe(struct platform_device *pdev)
                        clk_prepare_enable(priv->bus_clk);
        }
 
+       pltfm_host->timeout_clk = devm_clk_get(&pdev->dev, "timeout");
+       if (IS_ERR(pltfm_host->timeout_clk)) {
+               err = PTR_ERR(pltfm_host->timeout_clk);
+               dev_err(&pdev->dev, "failed to get timeout clk: %d\n", err);
+               goto free_pltfm;
+       }
+       err = clk_prepare_enable(pltfm_host->timeout_clk);
+       if (err)
+               goto free_pltfm;
+
        err = mmc_of_parse(host->mmc);
        if (err)
                goto err_clk;
@@ -578,6 +589,7 @@ err_rpm:
        pm_runtime_put_noidle(dev);
 err_clk:
        clk_disable_unprepare(pltfm_host->clk);
+       clk_disable_unprepare(pltfm_host->timeout_clk);
        clk_disable_unprepare(priv->bus_clk);
        if (rk_priv)
                clk_bulk_disable_unprepare(RK35xx_MAX_CLKS,
index a72e123..58e5c46 100644 (file)
@@ -33,6 +33,14 @@ unsigned int sdhci_pltfm_clk_get_max_clock(struct sdhci_host *host)
 }
 EXPORT_SYMBOL_GPL(sdhci_pltfm_clk_get_max_clock);
 
+unsigned int sdhci_pltfm_clk_get_timeout_clock(struct sdhci_host *host)
+{
+       struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
+
+       return clk_get_rate(pltfm_host->timeout_clk);
+}
+EXPORT_SYMBOL_GPL(sdhci_pltfm_clk_get_timeout_clock);
+
 static const struct sdhci_ops sdhci_pltfm_ops = {
        .set_clock = sdhci_set_clock,
        .set_bus_width = sdhci_set_bus_width,
index b81d5b0..4eb7719 100644 (file)
@@ -20,6 +20,7 @@ struct sdhci_pltfm_data {
 
 struct sdhci_pltfm_host {
        struct clk *clk;
+       struct clk *timeout_clk;
 
        /* migrate from sdhci_of_host */
        unsigned int clock;
@@ -106,6 +107,8 @@ extern void sdhci_pltfm_remove(struct platform_device *pdev);
 
 extern unsigned int sdhci_pltfm_clk_get_max_clock(struct sdhci_host *host);
 
+extern unsigned int sdhci_pltfm_clk_get_timeout_clock(struct sdhci_host *host);
+
 static inline void *sdhci_pltfm_priv(struct sdhci_pltfm_host *host)
 {
        return host->private;