aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/mmc/host/Kconfig10
-rw-r--r--drivers/mmc/host/Makefile1
-rw-r--r--drivers/mmc/host/sdhci-esdhc-imx.c143
-rw-r--r--drivers/mmc/host/sdhci-pltfm.c3
-rw-r--r--drivers/mmc/host/sdhci-pltfm.h1
5 files changed, 158 insertions, 0 deletions
diff --git a/drivers/mmc/host/Kconfig b/drivers/mmc/host/Kconfig
index 0b7024a4ffc2..c9c2520a0c4a 100644
--- a/drivers/mmc/host/Kconfig
+++ b/drivers/mmc/host/Kconfig
@@ -130,6 +130,16 @@ config MMC_SDHCI_CNS3XXX
130 130
131 If unsure, say N. 131 If unsure, say N.
132 132
133config MMC_SDHCI_ESDHC_IMX
134 bool "SDHCI platform support for the Freescale eSDHC i.MX controller"
135 depends on MMC_SDHCI_PLTFM && (ARCH_MX25 || ARCH_MX35 || ARCH_MX5)
136 select MMC_SDHCI_IO_ACCESSORS
137 help
138 This selects the Freescale eSDHC controller support on the platform
139 bus, found on platforms like mx35/51.
140
141 If unsure, say N.
142
133config MMC_SDHCI_S3C 143config MMC_SDHCI_S3C
134 tristate "SDHCI support on Samsung S3C SoC" 144 tristate "SDHCI support on Samsung S3C SoC"
135 depends on MMC_SDHCI && PLAT_SAMSUNG 145 depends on MMC_SDHCI && PLAT_SAMSUNG
diff --git a/drivers/mmc/host/Makefile b/drivers/mmc/host/Makefile
index eae5d62711f7..6c4ac67f739f 100644
--- a/drivers/mmc/host/Makefile
+++ b/drivers/mmc/host/Makefile
@@ -37,6 +37,7 @@ obj-$(CONFIG_MMC_USHC) += ushc.o
37obj-$(CONFIG_MMC_SDHCI_PLTFM) += sdhci-platform.o 37obj-$(CONFIG_MMC_SDHCI_PLTFM) += sdhci-platform.o
38sdhci-platform-y := sdhci-pltfm.o 38sdhci-platform-y := sdhci-pltfm.o
39sdhci-platform-$(CONFIG_MMC_SDHCI_CNS3XXX) += sdhci-cns3xxx.o 39sdhci-platform-$(CONFIG_MMC_SDHCI_CNS3XXX) += sdhci-cns3xxx.o
40sdhci-platform-$(CONFIG_MMC_SDHCI_ESDHC_IMX) += sdhci-esdhc-imx.o
40 41
41obj-$(CONFIG_MMC_SDHCI_OF) += sdhci-of.o 42obj-$(CONFIG_MMC_SDHCI_OF) += sdhci-of.o
42sdhci-of-y := sdhci-of-core.o 43sdhci-of-y := sdhci-of-core.o
diff --git a/drivers/mmc/host/sdhci-esdhc-imx.c b/drivers/mmc/host/sdhci-esdhc-imx.c
new file mode 100644
index 000000000000..2e9cca19c90b
--- /dev/null
+++ b/drivers/mmc/host/sdhci-esdhc-imx.c
@@ -0,0 +1,143 @@
1/*
2 * Freescale eSDHC i.MX controller driver for the platform bus.
3 *
4 * derived from the OF-version.
5 *
6 * Copyright (c) 2010 Pengutronix e.K.
7 * Author: Wolfram Sang <w.sang@pengutronix.de>
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License.
12 */
13
14#include <linux/io.h>
15#include <linux/delay.h>
16#include <linux/err.h>
17#include <linux/clk.h>
18#include <linux/mmc/host.h>
19#include <linux/mmc/sdhci-pltfm.h>
20#include "sdhci.h"
21#include "sdhci-pltfm.h"
22#include "sdhci-esdhc.h"
23
24static inline void esdhc_clrset_le(struct sdhci_host *host, u32 mask, u32 val, int reg)
25{
26 void __iomem *base = host->ioaddr + (reg & ~0x3);
27 u32 shift = (reg & 0x3) * 8;
28
29 writel(((readl(base) & ~(mask << shift)) | (val << shift)), base);
30}
31
32static u16 esdhc_readw_le(struct sdhci_host *host, int reg)
33{
34 if (unlikely(reg == SDHCI_HOST_VERSION))
35 reg ^= 2;
36
37 return readw(host->ioaddr + reg);
38}
39
40static void esdhc_writew_le(struct sdhci_host *host, u16 val, int reg)
41{
42 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
43
44 switch (reg) {
45 case SDHCI_TRANSFER_MODE:
46 /*
47 * Postpone this write, we must do it together with a
48 * command write that is down below.
49 */
50 pltfm_host->scratchpad = val;
51 return;
52 case SDHCI_COMMAND:
53 writel(val << 16 | pltfm_host->scratchpad,
54 host->ioaddr + SDHCI_TRANSFER_MODE);
55 return;
56 case SDHCI_BLOCK_SIZE:
57 val &= ~SDHCI_MAKE_BLKSZ(0x7, 0);
58 break;
59 }
60 esdhc_clrset_le(host, 0xffff, val, reg);
61}
62
63static void esdhc_writeb_le(struct sdhci_host *host, u8 val, int reg)
64{
65 u32 new_val;
66
67 switch (reg) {
68 case SDHCI_POWER_CONTROL:
69 /*
70 * FSL put some DMA bits here
71 * If your board has a regulator, code should be here
72 */
73 return;
74 case SDHCI_HOST_CONTROL:
75 /* FSL messed up here, so we can just keep those two */
76 new_val = val & (SDHCI_CTRL_LED | SDHCI_CTRL_4BITBUS);
77 /* ensure the endianess */
78 new_val |= ESDHC_HOST_CONTROL_LE;
79 /* DMA mode bits are shifted */
80 new_val |= (val & SDHCI_CTRL_DMA_MASK) << 5;
81
82 esdhc_clrset_le(host, 0xffff, new_val, reg);
83 return;
84 }
85 esdhc_clrset_le(host, 0xff, val, reg);
86}
87
88static unsigned int esdhc_pltfm_get_max_clock(struct sdhci_host *host)
89{
90 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
91
92 return clk_get_rate(pltfm_host->clk);
93}
94
95static unsigned int esdhc_pltfm_get_min_clock(struct sdhci_host *host)
96{
97 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
98
99 return clk_get_rate(pltfm_host->clk) / 256 / 16;
100}
101
102static int esdhc_pltfm_init(struct sdhci_host *host, struct sdhci_pltfm_data *pdata)
103{
104 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
105 struct clk *clk;
106
107 clk = clk_get(mmc_dev(host->mmc), NULL);
108 if (IS_ERR(clk)) {
109 dev_err(mmc_dev(host->mmc), "clk err\n");
110 return PTR_ERR(clk);
111 }
112 clk_enable(clk);
113 pltfm_host->clk = clk;
114
115 return 0;
116}
117
118static void esdhc_pltfm_exit(struct sdhci_host *host)
119{
120 struct sdhci_pltfm_host *pltfm_host = sdhci_priv(host);
121
122 clk_disable(pltfm_host->clk);
123 clk_put(pltfm_host->clk);
124}
125
126static struct sdhci_ops sdhci_esdhc_ops = {
127 .read_w = esdhc_readw_le,
128 .write_w = esdhc_writew_le,
129 .write_b = esdhc_writeb_le,
130 .set_clock = esdhc_set_clock,
131 .get_max_clock = esdhc_pltfm_get_max_clock,
132 .get_min_clock = esdhc_pltfm_get_min_clock,
133};
134
135struct sdhci_pltfm_data sdhci_esdhc_imx_pdata = {
136 .quirks = ESDHC_DEFAULT_QUIRKS | SDHCI_QUIRK_NO_MULTIBLOCK
137 | SDHCI_QUIRK_BROKEN_ADMA,
138 /* ADMA has issues. Might be fixable */
139 /* NO_MULTIBLOCK might be MX35 only (Errata: ENGcm07207) */
140 .ops = &sdhci_esdhc_ops,
141 .init = esdhc_pltfm_init,
142 .exit = esdhc_pltfm_exit,
143};
diff --git a/drivers/mmc/host/sdhci-pltfm.c b/drivers/mmc/host/sdhci-pltfm.c
index 00e8a8ab638e..0502f89f662b 100644
--- a/drivers/mmc/host/sdhci-pltfm.c
+++ b/drivers/mmc/host/sdhci-pltfm.c
@@ -167,6 +167,9 @@ static const struct platform_device_id sdhci_pltfm_ids[] = {
167#ifdef CONFIG_MMC_SDHCI_CNS3XXX 167#ifdef CONFIG_MMC_SDHCI_CNS3XXX
168 { "sdhci-cns3xxx", (kernel_ulong_t)&sdhci_cns3xxx_pdata }, 168 { "sdhci-cns3xxx", (kernel_ulong_t)&sdhci_cns3xxx_pdata },
169#endif 169#endif
170#ifdef CONFIG_MMC_SDHCI_ESDHC_IMX
171 { "sdhci-esdhc-imx", (kernel_ulong_t)&sdhci_esdhc_imx_pdata },
172#endif
170 { }, 173 { },
171}; 174};
172MODULE_DEVICE_TABLE(platform, sdhci_pltfm_ids); 175MODULE_DEVICE_TABLE(platform, sdhci_pltfm_ids);
diff --git a/drivers/mmc/host/sdhci-pltfm.h b/drivers/mmc/host/sdhci-pltfm.h
index 562b92957f18..c1bfe48af56a 100644
--- a/drivers/mmc/host/sdhci-pltfm.h
+++ b/drivers/mmc/host/sdhci-pltfm.h
@@ -21,5 +21,6 @@ struct sdhci_pltfm_host {
21}; 21};
22 22
23extern struct sdhci_pltfm_data sdhci_cns3xxx_pdata; 23extern struct sdhci_pltfm_data sdhci_cns3xxx_pdata;
24extern struct sdhci_pltfm_data sdhci_esdhc_imx_pdata;
24 25
25#endif /* _DRIVERS_MMC_SDHCI_PLTFM_H */ 26#endif /* _DRIVERS_MMC_SDHCI_PLTFM_H */