blob: 772ba2dc3f5e3e2d3d3cf790d241305b7e3ed79e [file] [log] [blame]
Uwe Kleine-König124bf942010-11-19 21:03:33 +01001/*
2 * Copyright (C) 2010 Pengutronix, Wolfram Sang <w.sang@pengutronix.de>
3 *
4 * This program is free software; you can redistribute it and/or modify it under
5 * the terms of the GNU General Public License version 2 as published by the
6 * Free Software Foundation.
7 */
8
9#include <mach/hardware.h>
Arnd Bergmann82906b12012-08-24 15:14:29 +020010#include <linux/platform_data/mmc-esdhc-imx.h>
Shawn Guoe0557c02012-09-13 15:51:15 +080011#include "devices-common.h"
Uwe Kleine-König124bf942010-11-19 21:03:33 +010012
Shawn Guo57ed3312011-06-30 09:24:26 +080013#define imx_sdhci_esdhc_imx_data_entry_single(soc, _devid, _id, hwid) \
Uwe Kleine-König124bf942010-11-19 21:03:33 +010014 { \
Shawn Guo57ed3312011-06-30 09:24:26 +080015 .devid = _devid, \
Uwe Kleine-König124bf942010-11-19 21:03:33 +010016 .id = _id, \
17 .iobase = soc ## _ESDHC ## hwid ## _BASE_ADDR, \
18 .irq = soc ## _INT_ESDHC ## hwid, \
19 }
20
Shawn Guo57ed3312011-06-30 09:24:26 +080021#define imx_sdhci_esdhc_imx_data_entry(soc, devid, id, hwid) \
22 [id] = imx_sdhci_esdhc_imx_data_entry_single(soc, devid, id, hwid)
Uwe Kleine-König124bf942010-11-19 21:03:33 +010023
24#ifdef CONFIG_SOC_IMX25
25const struct imx_sdhci_esdhc_imx_data
26imx25_sdhci_esdhc_imx_data[] __initconst = {
27#define imx25_sdhci_esdhc_imx_data_entry(_id, _hwid) \
Shawn Guo57ed3312011-06-30 09:24:26 +080028 imx_sdhci_esdhc_imx_data_entry(MX25, "sdhci-esdhc-imx25", _id, _hwid)
Uwe Kleine-König124bf942010-11-19 21:03:33 +010029 imx25_sdhci_esdhc_imx_data_entry(0, 1),
30 imx25_sdhci_esdhc_imx_data_entry(1, 2),
31};
32#endif /* ifdef CONFIG_SOC_IMX25 */
33
34#ifdef CONFIG_SOC_IMX35
35const struct imx_sdhci_esdhc_imx_data
36imx35_sdhci_esdhc_imx_data[] __initconst = {
37#define imx35_sdhci_esdhc_imx_data_entry(_id, _hwid) \
Shawn Guo57ed3312011-06-30 09:24:26 +080038 imx_sdhci_esdhc_imx_data_entry(MX35, "sdhci-esdhc-imx35", _id, _hwid)
Uwe Kleine-König124bf942010-11-19 21:03:33 +010039 imx35_sdhci_esdhc_imx_data_entry(0, 1),
40 imx35_sdhci_esdhc_imx_data_entry(1, 2),
41 imx35_sdhci_esdhc_imx_data_entry(2, 3),
42};
43#endif /* ifdef CONFIG_SOC_IMX35 */
44
Fabio Estevamd94ed122010-11-26 12:25:58 -020045#ifdef CONFIG_SOC_IMX51
Uwe Kleine-König124bf942010-11-19 21:03:33 +010046const struct imx_sdhci_esdhc_imx_data
47imx51_sdhci_esdhc_imx_data[] __initconst = {
48#define imx51_sdhci_esdhc_imx_data_entry(_id, _hwid) \
Shawn Guo57ed3312011-06-30 09:24:26 +080049 imx_sdhci_esdhc_imx_data_entry(MX51, "sdhci-esdhc-imx51", _id, _hwid)
Uwe Kleine-König124bf942010-11-19 21:03:33 +010050 imx51_sdhci_esdhc_imx_data_entry(0, 1),
51 imx51_sdhci_esdhc_imx_data_entry(1, 2),
52 imx51_sdhci_esdhc_imx_data_entry(2, 3),
53 imx51_sdhci_esdhc_imx_data_entry(3, 4),
54};
Fabio Estevamd94ed122010-11-26 12:25:58 -020055#endif /* ifdef CONFIG_SOC_IMX51 */
Uwe Kleine-König124bf942010-11-19 21:03:33 +010056
Yong Shen410d34582011-01-07 12:25:34 +080057#ifdef CONFIG_SOC_IMX53
58const struct imx_sdhci_esdhc_imx_data
59imx53_sdhci_esdhc_imx_data[] __initconst = {
60#define imx53_sdhci_esdhc_imx_data_entry(_id, _hwid) \
Shawn Guo57ed3312011-06-30 09:24:26 +080061 imx_sdhci_esdhc_imx_data_entry(MX53, "sdhci-esdhc-imx53", _id, _hwid)
Yong Shen410d34582011-01-07 12:25:34 +080062 imx53_sdhci_esdhc_imx_data_entry(0, 1),
63 imx53_sdhci_esdhc_imx_data_entry(1, 2),
64 imx53_sdhci_esdhc_imx_data_entry(2, 3),
65 imx53_sdhci_esdhc_imx_data_entry(3, 4),
66};
67#endif /* ifdef CONFIG_SOC_IMX53 */
68
Shawn Guo913413c2011-06-21 22:41:51 +080069static const struct esdhc_platform_data default_esdhc_pdata __initconst = {
70 .wp_type = ESDHC_WP_NONE,
71 .cd_type = ESDHC_CD_NONE,
72};
73
Uwe Kleine-König124bf942010-11-19 21:03:33 +010074struct platform_device *__init imx_add_sdhci_esdhc_imx(
75 const struct imx_sdhci_esdhc_imx_data *data,
76 const struct esdhc_platform_data *pdata)
77{
78 struct resource res[] = {
79 {
80 .start = data->iobase,
81 .end = data->iobase + SZ_16K - 1,
82 .flags = IORESOURCE_MEM,
83 }, {
84 .start = data->irq,
85 .end = data->irq,
86 .flags = IORESOURCE_IRQ,
87 },
88 };
89
Shawn Guo913413c2011-06-21 22:41:51 +080090 /*
91 * If machine does not provide pdata, use the default one
92 * which means no WP/CD support
93 */
94 if (!pdata)
95 pdata = &default_esdhc_pdata;
96
Shawn Guo57ed3312011-06-30 09:24:26 +080097 return imx_add_platform_device(data->devid, data->id, res,
Uwe Kleine-König124bf942010-11-19 21:03:33 +010098 ARRAY_SIZE(res), pdata, sizeof(*pdata));
99}