diff options
author | Oded Gabbay <ogabbay@advaoptical.com> | 2013-06-27 12:00:05 -0400 |
---|---|---|
committer | Chris Ball <cjb@laptop.org> | 2013-07-05 12:46:30 -0400 |
commit | 66b50a00992dca97b442e016a9b2dba892e2df61 (patch) | |
tree | 764fbe455ac9fffafd04f0778d673601ca786d16 | |
parent | 7c4f10ac5a940b3994be7f1801a606f8605e7a69 (diff) |
mmc: esdhc: Add support for 8-bit bus width and non-removable card
This patch adds support of connecting an MMC media using an 8-bit
bus width connection to Freescale's P2020 H/W SDHC controller. During
the probe function, the generic function mmc_of_parse is called to
detect whether the controller is configured with 8-bit bus width.
Also, the generic function detects if the non-removable property is
set in the device tree. The function esdhc_pltfm_bus_width was added
because the bus width configuration is platform specific.
Signed-off-by: Oded Gabbay <ogabbay@advaoptical.com>
Reviewed-by: Anton Vorontsov <anton@enomsg.org>
Signed-off-by: Chris Ball <cjb@laptop.org>
-rw-r--r-- | drivers/mmc/host/sdhci-esdhc.h | 7 | ||||
-rw-r--r-- | drivers/mmc/host/sdhci-of-esdhc.c | 44 |
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 | ||
234 | static 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 | |||
233 | static const struct sdhci_ops sdhci_esdhc_ops = { | 258 | static 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 | ||
252 | static const struct sdhci_pltfm_data sdhci_esdhc_pdata = { | 278 | static const struct sdhci_pltfm_data sdhci_esdhc_pdata = { |
@@ -262,7 +288,23 @@ static const struct sdhci_pltfm_data sdhci_esdhc_pdata = { | |||
262 | 288 | ||
263 | static int sdhci_esdhc_probe(struct platform_device *pdev) | 289 | static 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 | ||
268 | static int sdhci_esdhc_remove(struct platform_device *pdev) | 310 | static int sdhci_esdhc_remove(struct platform_device *pdev) |