aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mmc/host/sdhci-esdhc.h7
-rw-r--r--drivers/mmc/host/sdhci-of-esdhc.c44
2 files changed, 50 insertions, 1 deletions
diff --git a/drivers/mmc/host/sdhci-esdhc.h b/drivers/mmc/host/sdhci-esdhc.h
index 6f16406c37cd..a2a06420e463 100644
--- a/drivers/mmc/host/sdhci-esdhc.h
+++ b/drivers/mmc/host/sdhci-esdhc.h
@@ -36,6 +36,13 @@
36/* pltfm-specific */ 36/* pltfm-specific */
37#define ESDHC_HOST_CONTROL_LE 0x20 37#define ESDHC_HOST_CONTROL_LE 0x20
38 38
39/*
40 * P2020 interpretation of the SDHCI_HOST_CONTROL register
41 */
42#define ESDHC_CTRL_4BITBUS (0x1 << 1)
43#define ESDHC_CTRL_8BITBUS (0x2 << 1)
44#define ESDHC_CTRL_BUSWIDTH_MASK (0x3 << 1)
45
39/* OF-specific */ 46/* OF-specific */
40#define ESDHC_DMA_SYSCTL 0x40c 47#define ESDHC_DMA_SYSCTL 0x40c
41#define ESDHC_DMA_SNOOP 0x00000040 48#define ESDHC_DMA_SNOOP 0x00000040
diff --git a/drivers/mmc/host/sdhci-of-esdhc.c b/drivers/mmc/host/sdhci-of-esdhc.c
index 2b7369729f91..b2a635e73aee 100644
--- a/drivers/mmc/host/sdhci-of-esdhc.c
+++ b/drivers/mmc/host/sdhci-of-esdhc.c
@@ -13,6 +13,7 @@
13 * your option) any later version. 13 * your option) any later version.
14 */ 14 */
15 15
16#include <linux/err.h>
16#include <linux/io.h> 17#include <linux/io.h>
17#include <linux/of.h> 18#include <linux/of.h>
18#include <linux/delay.h> 19#include <linux/delay.h>
@@ -230,6 +231,30 @@ static void esdhc_of_platform_init(struct sdhci_host *host)
230 host->quirks &= ~SDHCI_QUIRK_NO_BUSY_IRQ; 231 host->quirks &= ~SDHCI_QUIRK_NO_BUSY_IRQ;
231} 232}
232 233
234static int esdhc_pltfm_bus_width(struct sdhci_host *host, int width)
235{
236 u32 ctrl;
237
238 switch (width) {
239 case MMC_BUS_WIDTH_8:
240 ctrl = ESDHC_CTRL_8BITBUS;
241 break;
242
243 case MMC_BUS_WIDTH_4:
244 ctrl = ESDHC_CTRL_4BITBUS;
245 break;
246
247 default:
248 ctrl = 0;
249 break;
250 }
251
252 clrsetbits_be32(host->ioaddr + SDHCI_HOST_CONTROL,
253 ESDHC_CTRL_BUSWIDTH_MASK, ctrl);
254
255 return 0;
256}
257
233static const struct sdhci_ops sdhci_esdhc_ops = { 258static const struct sdhci_ops sdhci_esdhc_ops = {
234 .read_l = esdhc_readl, 259 .read_l = esdhc_readl,
235 .read_w = esdhc_readw, 260 .read_w = esdhc_readw,
@@ -247,6 +272,7 @@ static const struct sdhci_ops sdhci_esdhc_ops = {
247 .platform_resume = esdhc_of_resume, 272 .platform_resume = esdhc_of_resume,
248#endif 273#endif
249 .adma_workaround = esdhci_of_adma_workaround, 274 .adma_workaround = esdhci_of_adma_workaround,
275 .platform_bus_width = esdhc_pltfm_bus_width,
250}; 276};
251 277
252static const struct sdhci_pltfm_data sdhci_esdhc_pdata = { 278static const struct sdhci_pltfm_data sdhci_esdhc_pdata = {
@@ -262,7 +288,23 @@ static const struct sdhci_pltfm_data sdhci_esdhc_pdata = {
262 288
263static int sdhci_esdhc_probe(struct platform_device *pdev) 289static int sdhci_esdhc_probe(struct platform_device *pdev)
264{ 290{
265 return sdhci_pltfm_register(pdev, &sdhci_esdhc_pdata, 0); 291 struct sdhci_host *host;
292 int ret;
293
294 host = sdhci_pltfm_init(pdev, &sdhci_esdhc_pdata, 0);
295 if (IS_ERR(host))
296 return PTR_ERR(host);
297
298 sdhci_get_of_property(pdev);
299
300 /* call to generic mmc_of_parse to support additional capabilities */
301 mmc_of_parse(host->mmc);
302
303 ret = sdhci_add_host(host);
304 if (ret)
305 sdhci_pltfm_free(pdev);
306
307 return ret;
266} 308}
267 309
268static int sdhci_esdhc_remove(struct platform_device *pdev) 310static int sdhci_esdhc_remove(struct platform_device *pdev)