aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/mmc
diff options
context:
space:
mode:
authorLars-Peter Clausen <lars@metafoo.de>2013-01-28 13:27:12 -0500
committerChris Ball <cjb@laptop.org>2013-02-24 14:37:09 -0500
commitd005d94359a8df84ea6e5ac137393707f9e87e81 (patch)
tree1cf5e1c0c6fc304e387705d00d72a82c50f82b10 /drivers/mmc
parent20b92a30b5610a5222060417961bc4ccb42ea5a5 (diff)
mmc: sdhci-pltfm: Add a common clk API implementation of get_timeout_clock
Quite a few drivers have a implementation of the get_timeout_clock callback which simply returns the result of clk_get_rate on the device's clock. This patch adds a common implementation of this to the sdhci-pltfm module and replaces all custom implementations with the common one. Signed-off-by: Lars-Peter Clausen <lars@metafoo.de> Tested-by: Stephen Warren <swarren@wwwdotorg.org> Acked-by: Shawn Guo <shawn.guo@linaro.org> Tested-by: Kevin Liu <kliu5@marvell.com> Signed-off-by: Chris Ball <cjb@laptop.org>
Diffstat (limited to 'drivers/mmc')
-rw-r--r--drivers/mmc/host/sdhci-bcm2835.c27
-rw-r--r--drivers/mmc/host/sdhci-esdhc-imx.c9
-rw-r--r--drivers/mmc/host/sdhci-pltfm.c8
-rw-r--r--drivers/mmc/host/sdhci-pltfm.h2
-rw-r--r--drivers/mmc/host/sdhci-pxav2.c9
-rw-r--r--drivers/mmc/host/sdhci-pxav3.c9
6 files changed, 18 insertions, 46 deletions
diff --git a/drivers/mmc/host/sdhci-bcm2835.c b/drivers/mmc/host/sdhci-bcm2835.c
index 453825fcc5cf..1e97b89dac66 100644
--- a/drivers/mmc/host/sdhci-bcm2835.c
+++ b/drivers/mmc/host/sdhci-bcm2835.c
@@ -51,7 +51,6 @@
51#define BCM2835_SDHCI_WRITE_DELAY (((2 * 1000000) / MIN_FREQ) + 1) 51#define BCM2835_SDHCI_WRITE_DELAY (((2 * 1000000) / MIN_FREQ) + 1)
52 52
53struct bcm2835_sdhci { 53struct bcm2835_sdhci {
54 struct clk *clk;
55 u32 shadow; 54 u32 shadow;
56}; 55};
57 56
@@ -120,27 +119,11 @@ static u8 bcm2835_sdhci_readb(struct sdhci_host *host, int reg)
120 return byte; 119 return byte;
121} 120}
122 121
123static unsigned int bcm2835_sdhci_get_max_clock(struct sdhci_host *host)
124{
125 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
126 struct bcm2835_sdhci *bcm2835_host = pltfm_host->priv;
127
128 return clk_get_rate(bcm2835_host->clk);
129}
130
131unsigned int bcm2835_sdhci_get_min_clock(struct sdhci_host *host) 122unsigned int bcm2835_sdhci_get_min_clock(struct sdhci_host *host)
132{ 123{
133 return MIN_FREQ; 124 return MIN_FREQ;
134} 125}
135 126
136unsigned int bcm2835_sdhci_get_timeout_clock(struct sdhci_host *host)
137{
138 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
139 struct bcm2835_sdhci *bcm2835_host = pltfm_host->priv;
140
141 return clk_get_rate(bcm2835_host->clk);
142}
143
144static struct sdhci_ops bcm2835_sdhci_ops = { 127static struct sdhci_ops bcm2835_sdhci_ops = {
145 .write_l = bcm2835_sdhci_writel, 128 .write_l = bcm2835_sdhci_writel,
146 .write_w = bcm2835_sdhci_writew, 129 .write_w = bcm2835_sdhci_writew,
@@ -148,9 +131,9 @@ static struct sdhci_ops bcm2835_sdhci_ops = {
148 .read_l = bcm2835_sdhci_readl, 131 .read_l = bcm2835_sdhci_readl,
149 .read_w = bcm2835_sdhci_readw, 132 .read_w = bcm2835_sdhci_readw,
150 .read_b = bcm2835_sdhci_readb, 133 .read_b = bcm2835_sdhci_readb,
151 .get_max_clock = bcm2835_sdhci_get_max_clock, 134 .get_max_clock = sdhci_pltfm_clk_get_max_clock,
152 .get_min_clock = bcm2835_sdhci_get_min_clock, 135 .get_min_clock = bcm2835_sdhci_get_min_clock,
153 .get_timeout_clock = bcm2835_sdhci_get_timeout_clock, 136 .get_timeout_clock = sdhci_pltfm_clk_get_max_clock,
154}; 137};
155 138
156static struct sdhci_pltfm_data bcm2835_sdhci_pdata = { 139static struct sdhci_pltfm_data bcm2835_sdhci_pdata = {
@@ -180,9 +163,9 @@ static int bcm2835_sdhci_probe(struct platform_device *pdev)
180 pltfm_host = sdhci_priv(host); 163 pltfm_host = sdhci_priv(host);
181 pltfm_host->priv = bcm2835_host; 164 pltfm_host->priv = bcm2835_host;
182 165
183 bcm2835_host->clk = devm_clk_get(&pdev->dev, NULL); 166 pltfm_host->clk = devm_clk_get(&pdev->dev, NULL);
184 if (IS_ERR(bcm2835_host->clk)) { 167 if (IS_ERR(pltfm_host->clk)) {
185 ret = PTR_ERR(bcm2835_host->clk); 168 ret = PTR_ERR(pltfm_host->clk);
186 goto err; 169 goto err;
187 } 170 }
188 171
diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
index f7ee5e67516c..78ac00227c1a 100644
--- a/drivers/mmc/host/sdhci-esdhc-imx.c
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -351,13 +351,6 @@ static void esdhc_writeb_le(struct sdhci_host *host, u8 val, int reg)
351 } 351 }
352} 352}
353 353
354static unsigned int esdhc_pltfm_get_max_clock(struct sdhci_host *host)
355{
356 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
357
358 return clk_get_rate(pltfm_host->clk);
359}
360
361static unsigned int esdhc_pltfm_get_min_clock(struct sdhci_host *host) 354static unsigned int esdhc_pltfm_get_min_clock(struct sdhci_host *host)
362{ 355{
363 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host); 356 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
@@ -413,7 +406,7 @@ static struct sdhci_ops sdhci_esdhc_ops = {
413 .write_w = esdhc_writew_le, 406 .write_w = esdhc_writew_le,
414 .write_b = esdhc_writeb_le, 407 .write_b = esdhc_writeb_le,
415 .set_clock = esdhc_set_clock, 408 .set_clock = esdhc_set_clock,
416 .get_max_clock = esdhc_pltfm_get_max_clock, 409 .get_max_clock = sdhci_pltfm_clk_get_max_clock,
417 .get_min_clock = esdhc_pltfm_get_min_clock, 410 .get_min_clock = esdhc_pltfm_get_min_clock,
418 .get_ro = esdhc_pltfm_get_ro, 411 .get_ro = esdhc_pltfm_get_ro,
419 .platform_bus_width = esdhc_pltfm_bus_width, 412 .platform_bus_width = esdhc_pltfm_bus_width,
diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c
index d4283ef5917a..3145a780b035 100644
--- a/drivers/mmc/host/sdhci-pltfm.c
+++ b/drivers/mmc/host/sdhci-pltfm.c
@@ -36,6 +36,14 @@
36#endif 36#endif
37#include "sdhci-pltfm.h" 37#include "sdhci-pltfm.h"
38 38
39unsigned int sdhci_pltfm_clk_get_max_clock(struct sdhci_host *host)
40{
41 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
42
43 return clk_get_rate(pltfm_host->clk);
44}
45EXPORT_SYMBOL_GPL(sdhci_pltfm_clk_get_max_clock);
46
39static struct sdhci_ops sdhci_pltfm_ops = { 47static struct sdhci_ops sdhci_pltfm_ops = {
40}; 48};
41 49
diff --git a/drivers/mmc/host/sdhci-pltfm.h b/drivers/mmc/host/sdhci-pltfm.h
index 37e0e184a0bb..153b6c509ebe 100644
--- a/drivers/mmc/host/sdhci-pltfm.h
+++ b/drivers/mmc/host/sdhci-pltfm.h
@@ -98,6 +98,8 @@ extern int sdhci_pltfm_register(struct platform_device *pdev,
98 struct sdhci_pltfm_data *pdata); 98 struct sdhci_pltfm_data *pdata);
99extern int sdhci_pltfm_unregister(struct platform_device *pdev); 99extern int sdhci_pltfm_unregister(struct platform_device *pdev);
100 100
101extern unsigned int sdhci_pltfm_clk_get_max_clock(struct sdhci_host *host);
102
101#ifdef CONFIG_PM 103#ifdef CONFIG_PM
102extern const struct dev_pm_ops sdhci_pltfm_pmops; 104extern const struct dev_pm_ops sdhci_pltfm_pmops;
103#define SDHCI_PLTFM_PMOPS (&sdhci_pltfm_pmops) 105#define SDHCI_PLTFM_PMOPS (&sdhci_pltfm_pmops)
diff --git a/drivers/mmc/host/sdhci-pxav2.c b/drivers/mmc/host/sdhci-pxav2.c
index 7e5756593b68..eeb7d439db1d 100644
--- a/drivers/mmc/host/sdhci-pxav2.c
+++ b/drivers/mmc/host/sdhci-pxav2.c
@@ -111,15 +111,8 @@ static int pxav2_mmc_set_width(struct sdhci_host *host, int width)
111 return 0; 111 return 0;
112} 112}
113 113
114static u32 pxav2_get_max_clock(struct sdhci_host *host)
115{
116 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
117
118 return clk_get_rate(pltfm_host->clk);
119}
120
121static struct sdhci_ops pxav2_sdhci_ops = { 114static struct sdhci_ops pxav2_sdhci_ops = {
122 .get_max_clock = pxav2_get_max_clock, 115 .get_max_clock = sdhci_pltfm_clk_get_max_clock,
123 .platform_reset_exit = pxav2_set_private_registers, 116 .platform_reset_exit = pxav2_set_private_registers,
124 .platform_bus_width = pxav2_mmc_set_width, 117 .platform_bus_width = pxav2_mmc_set_width,
125}; 118};
diff --git a/drivers/mmc/host/sdhci-pxav3.c b/drivers/mmc/host/sdhci-pxav3.c
index 3d20c10fc571..f09877fcc3ec 100644
--- a/drivers/mmc/host/sdhci-pxav3.c
+++ b/drivers/mmc/host/sdhci-pxav3.c
@@ -163,18 +163,11 @@ static int pxav3_set_uhs_signaling(struct sdhci_host *host, unsigned int uhs)
163 return 0; 163 return 0;
164} 164}
165 165
166static u32 pxav3_get_max_clock(struct sdhci_host *host)
167{
168 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
169
170 return clk_get_rate(pltfm_host->clk);
171}
172
173static struct sdhci_ops pxav3_sdhci_ops = { 166static struct sdhci_ops pxav3_sdhci_ops = {
174 .platform_reset_exit = pxav3_set_private_registers, 167 .platform_reset_exit = pxav3_set_private_registers,
175 .set_uhs_signaling = pxav3_set_uhs_signaling, 168 .set_uhs_signaling = pxav3_set_uhs_signaling,
176 .platform_send_init_74_clocks = pxav3_gen_init_74_clocks, 169 .platform_send_init_74_clocks = pxav3_gen_init_74_clocks,
177 .get_max_clock = pxav3_get_max_clock, 170 .get_max_clock = sdhci_pltfm_clk_get_max_clock,
178}; 171};
179 172
180#ifdef CONFIG_OF 173#ifdef CONFIG_OF