diff options
author | Thomas Abraham <thomas.abraham@linaro.org> | 2012-09-17 14:16:38 -0400 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2012-10-03 10:05:15 -0400 |
commit | f90a0612f0e110a8af976835273124dff4fa8b3d (patch) | |
tree | ef683e834a1cf4780c00fad28f88603fda15a159 | |
parent | 1c2215b7c6f20a65877431a5ebb4f9a789df3811 (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>
-rw-r--r-- | drivers/mmc/host/dw_mmc.c | 52 | ||||
-rw-r--r-- | include/linux/mmc/dw_mmc.h | 4 |
2 files changed, 53 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 | |||
2149 | err_clk_ciu: | ||
2150 | if (!IS_ERR(host->ciu_clk)) { | ||
2151 | clk_disable_unprepare(host->ciu_clk); | ||
2152 | clk_put(host->ciu_clk); | ||
2153 | } | ||
2154 | err_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 | } |
2121 | EXPORT_SYMBOL(dw_mci_probe); | 2161 | EXPORT_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 | } |
2153 | EXPORT_SYMBOL(dw_mci_remove); | 2199 | EXPORT_SYMBOL(dw_mci_remove); |
2154 | 2200 | ||
diff --git a/include/linux/mmc/dw_mmc.h b/include/linux/mmc/dw_mmc.h index a37a573fa13c..787ad569c99b 100644 --- a/include/linux/mmc/dw_mmc.h +++ b/include/linux/mmc/dw_mmc.h | |||
@@ -78,6 +78,8 @@ struct mmc_data; | |||
78 | * @data_offset: Set the offset of DATA register according to VERID. | 78 | * @data_offset: Set the offset of DATA register according to VERID. |
79 | * @dev: Device associated with the MMC controller. | 79 | * @dev: Device associated with the MMC controller. |
80 | * @pdata: Platform data associated with the MMC controller. | 80 | * @pdata: Platform data associated with the MMC controller. |
81 | * @biu_clk: Pointer to bus interface unit clock instance. | ||
82 | * @ciu_clk: Pointer to card interface unit clock instance. | ||
81 | * @slot: Slots sharing this MMC controller. | 83 | * @slot: Slots sharing this MMC controller. |
82 | * @fifo_depth: depth of FIFO. | 84 | * @fifo_depth: depth of FIFO. |
83 | * @data_shift: log2 of FIFO item size. | 85 | * @data_shift: log2 of FIFO item size. |
@@ -158,6 +160,8 @@ struct dw_mci { | |||
158 | u16 data_offset; | 160 | u16 data_offset; |
159 | struct device *dev; | 161 | struct device *dev; |
160 | struct dw_mci_board *pdata; | 162 | struct dw_mci_board *pdata; |
163 | struct clk *biu_clk; | ||
164 | struct clk *ciu_clk; | ||
161 | struct dw_mci_slot *slot[MAX_MCI_SLOTS]; | 165 | struct dw_mci_slot *slot[MAX_MCI_SLOTS]; |
162 | 166 | ||
163 | /* FIFO push and pull */ | 167 | /* FIFO push and pull */ |