aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc/host/dw_mmc.c
diff options
context:
space:
mode:
authorThomas Abraham <thomas.abraham@linaro.org>2012-09-17 14:16:38 -0400
committerChris Ball <cjb@laptop.org>2012-10-03 10:05:15 -0400
commitf90a0612f0e110a8af976835273124dff4fa8b3d (patch)
treeef683e834a1cf4780c00fad28f88603fda15a159 /drivers/mmc/host/dw_mmc.c
parent1c2215b7c6f20a65877431a5ebb4f9a789df3811 (diff)
mmc: dw_mmc: lookup for optional biu and ciu clocks
Some platforms allow for clock gating and control of bus interface unit clock and card interface unit clock. Add support for clock lookup of optional biu and ciu clocks for clock gating and clock speed determination. Signed-off-by: Abhilash Kesavan <a.kesavan@samsung.com> Signed-off-by: Thomas Abraham <thomas.abraham@linaro.org> Acked-by: Will Newton <will.newton@imgtec.com> Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc/host/dw_mmc.c')
-rw-r--r--drivers/mmc/host/dw_mmc.c52
1 files changed, 49 insertions, 3 deletions
diff --git a/drivers/mmc/host/dw_mmc.c b/drivers/mmc/host/dw_mmc.c
index 227c42ef18c5..de45ad24becb 100644
--- a/drivers/mmc/host/dw_mmc.c
+++ b/drivers/mmc/host/dw_mmc.c
@@ -1960,13 +1960,42 @@ int dw_mci_probe(struct dw_mci *host)
1960 return -ENODEV; 1960 return -ENODEV;
1961 } 1961 }
1962 1962
1963 if (!host->pdata->bus_hz) { 1963 host->biu_clk = clk_get(host->dev, "biu");
1964 if (IS_ERR(host->biu_clk)) {
1965 dev_dbg(host->dev, "biu clock not available\n");
1966 } else {
1967 ret = clk_prepare_enable(host->biu_clk);
1968 if (ret) {
1969 dev_err(host->dev, "failed to enable biu clock\n");
1970 clk_put(host->biu_clk);
1971 return ret;
1972 }
1973 }
1974
1975 host->ciu_clk = clk_get(host->dev, "ciu");
1976 if (IS_ERR(host->ciu_clk)) {
1977 dev_dbg(host->dev, "ciu clock not available\n");
1978 } else {
1979 ret = clk_prepare_enable(host->ciu_clk);
1980 if (ret) {
1981 dev_err(host->dev, "failed to enable ciu clock\n");
1982 clk_put(host->ciu_clk);
1983 goto err_clk_biu;
1984 }
1985 }
1986
1987 if (IS_ERR(host->ciu_clk))
1988 host->bus_hz = host->pdata->bus_hz;
1989 else
1990 host->bus_hz = clk_get_rate(host->ciu_clk);
1991
1992 if (!host->bus_hz) {
1964 dev_err(host->dev, 1993 dev_err(host->dev,
1965 "Platform data must supply bus speed\n"); 1994 "Platform data must supply bus speed\n");
1966 return -ENODEV; 1995 ret = -ENODEV;
1996 goto err_clk_ciu;
1967 } 1997 }
1968 1998
1969 host->bus_hz = host->pdata->bus_hz;
1970 host->quirks = host->pdata->quirks; 1999 host->quirks = host->pdata->quirks;
1971 2000
1972 spin_lock_init(&host->lock); 2001 spin_lock_init(&host->lock);
@@ -2116,6 +2145,17 @@ err_dmaunmap:
2116 regulator_disable(host->vmmc); 2145 regulator_disable(host->vmmc);
2117 regulator_put(host->vmmc); 2146 regulator_put(host->vmmc);
2118 } 2147 }
2148
2149err_clk_ciu:
2150 if (!IS_ERR(host->ciu_clk)) {
2151 clk_disable_unprepare(host->ciu_clk);
2152 clk_put(host->ciu_clk);
2153 }
2154err_clk_biu:
2155 if (!IS_ERR(host->biu_clk)) {
2156 clk_disable_unprepare(host->biu_clk);
2157 clk_put(host->biu_clk);
2158 }
2119 return ret; 2159 return ret;
2120} 2160}
2121EXPORT_SYMBOL(dw_mci_probe); 2161EXPORT_SYMBOL(dw_mci_probe);
@@ -2149,6 +2189,12 @@ void dw_mci_remove(struct dw_mci *host)
2149 regulator_put(host->vmmc); 2189 regulator_put(host->vmmc);
2150 } 2190 }
2151 2191
2192 if (!IS_ERR(host->ciu_clk))
2193 clk_disable_unprepare(host->ciu_clk);
2194 if (!IS_ERR(host->biu_clk))
2195 clk_disable_unprepare(host->biu_clk);
2196 clk_put(host->ciu_clk);
2197 clk_put(host->biu_clk);
2152} 2198}
2153EXPORT_SYMBOL(dw_mci_remove); 2199EXPORT_SYMBOL(dw_mci_remove);
2154 2200