blob: a5edd7d60266985472ac9de11e6fb9801f8eadeb [file] [log] [blame]
Uwe Kleine-König124bf942010-11-19 21:03:33 +01001/*
Wolfram Sang61b8c7b2015-04-20 15:51:38 +02002 * Copyright (C) 2010 Pengutronix, Wolfram Sang <kernel@pengutronix.de>
Uwe Kleine-König124bf942010-11-19 21:03:33 +01003 *
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
Arnd Bergmann82906b12012-08-24 15:14:29 +02009#include <linux/platform_data/mmc-esdhc-imx.h>
Shawn Guo50f2de62012-09-14 14:14:45 +080010
11#include "../hardware.h"
Shawn Guoe0557c02012-09-13 15:51:15 +080012#include "devices-common.h"
Uwe Kleine-König124bf942010-11-19 21:03:33 +010013
Shawn Guo57ed3312011-06-30 09:24:26 +080014#define imx_sdhci_esdhc_imx_data_entry_single(soc, _devid, _id, hwid) \
Uwe Kleine-König124bf942010-11-19 21:03:33 +010015 { \
Shawn Guo57ed3312011-06-30 09:24:26 +080016 .devid = _devid, \
Uwe Kleine-König124bf942010-11-19 21:03:33 +010017 .id = _id, \
18 .iobase = soc ## _ESDHC ## hwid ## _BASE_ADDR, \
19 .irq = soc ## _INT_ESDHC ## hwid, \
20 }
21
Shawn Guo57ed3312011-06-30 09:24:26 +080022#define imx_sdhci_esdhc_imx_data_entry(soc, devid, id, hwid) \
23 [id] = imx_sdhci_esdhc_imx_data_entry_single(soc, devid, id, hwid)
Uwe Kleine-König124bf942010-11-19 21:03:33 +010024
25#ifdef CONFIG_SOC_IMX25
26const struct imx_sdhci_esdhc_imx_data
27imx25_sdhci_esdhc_imx_data[] __initconst = {
28#define imx25_sdhci_esdhc_imx_data_entry(_id, _hwid) \
Shawn Guo57ed3312011-06-30 09:24:26 +080029 imx_sdhci_esdhc_imx_data_entry(MX25, "sdhci-esdhc-imx25", _id, _hwid)
Uwe Kleine-König124bf942010-11-19 21:03:33 +010030 imx25_sdhci_esdhc_imx_data_entry(0, 1),
31 imx25_sdhci_esdhc_imx_data_entry(1, 2),
32};
33#endif /* ifdef CONFIG_SOC_IMX25 */
34
35#ifdef CONFIG_SOC_IMX35
36const struct imx_sdhci_esdhc_imx_data
37imx35_sdhci_esdhc_imx_data[] __initconst = {
38#define imx35_sdhci_esdhc_imx_data_entry(_id, _hwid) \
Shawn Guo57ed3312011-06-30 09:24:26 +080039 imx_sdhci_esdhc_imx_data_entry(MX35, "sdhci-esdhc-imx35", _id, _hwid)
Uwe Kleine-König124bf942010-11-19 21:03:33 +010040 imx35_sdhci_esdhc_imx_data_entry(0, 1),
41 imx35_sdhci_esdhc_imx_data_entry(1, 2),
42 imx35_sdhci_esdhc_imx_data_entry(2, 3),
43};
44#endif /* ifdef CONFIG_SOC_IMX35 */
45
Shawn Guo913413c2011-06-21 22:41:51 +080046static const struct esdhc_platform_data default_esdhc_pdata __initconst = {
47 .wp_type = ESDHC_WP_NONE,
48 .cd_type = ESDHC_CD_NONE,
49};
50
Uwe Kleine-König124bf942010-11-19 21:03:33 +010051struct platform_device *__init imx_add_sdhci_esdhc_imx(
52 const struct imx_sdhci_esdhc_imx_data *data,
53 const struct esdhc_platform_data *pdata)
54{
55 struct resource res[] = {
56 {
57 .start = data->iobase,
58 .end = data->iobase + SZ_16K - 1,
59 .flags = IORESOURCE_MEM,
60 }, {
61 .start = data->irq,
62 .end = data->irq,
63 .flags = IORESOURCE_IRQ,
64 },
65 };
66
Shawn Guo913413c2011-06-21 22:41:51 +080067 /*
68 * If machine does not provide pdata, use the default one
69 * which means no WP/CD support
70 */
71 if (!pdata)
72 pdata = &default_esdhc_pdata;
73
Shawn Guo57ed3312011-06-30 09:24:26 +080074 return imx_add_platform_device(data->devid, data->id, res,
Uwe Kleine-König124bf942010-11-19 21:03:33 +010075 ARRAY_SIZE(res), pdata, sizeof(*pdata));
76}