Uwe Kleine-König | 124bf94 | 2010-11-19 21:03:33 +0100 | [diff] [blame] | 1 | /* |
| 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 Bergmann | 82906b1 | 2012-08-24 15:14:29 +0200 | [diff] [blame] | 10 | #include <linux/platform_data/mmc-esdhc-imx.h> |
Shawn Guo | e0557c0 | 2012-09-13 15:51:15 +0800 | [diff] [blame^] | 11 | #include "devices-common.h" |
Uwe Kleine-König | 124bf94 | 2010-11-19 21:03:33 +0100 | [diff] [blame] | 12 | |
Shawn Guo | 57ed331 | 2011-06-30 09:24:26 +0800 | [diff] [blame] | 13 | #define imx_sdhci_esdhc_imx_data_entry_single(soc, _devid, _id, hwid) \ |
Uwe Kleine-König | 124bf94 | 2010-11-19 21:03:33 +0100 | [diff] [blame] | 14 | { \ |
Shawn Guo | 57ed331 | 2011-06-30 09:24:26 +0800 | [diff] [blame] | 15 | .devid = _devid, \ |
Uwe Kleine-König | 124bf94 | 2010-11-19 21:03:33 +0100 | [diff] [blame] | 16 | .id = _id, \ |
| 17 | .iobase = soc ## _ESDHC ## hwid ## _BASE_ADDR, \ |
| 18 | .irq = soc ## _INT_ESDHC ## hwid, \ |
| 19 | } |
| 20 | |
Shawn Guo | 57ed331 | 2011-06-30 09:24:26 +0800 | [diff] [blame] | 21 | #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önig | 124bf94 | 2010-11-19 21:03:33 +0100 | [diff] [blame] | 23 | |
| 24 | #ifdef CONFIG_SOC_IMX25 |
| 25 | const struct imx_sdhci_esdhc_imx_data |
| 26 | imx25_sdhci_esdhc_imx_data[] __initconst = { |
| 27 | #define imx25_sdhci_esdhc_imx_data_entry(_id, _hwid) \ |
Shawn Guo | 57ed331 | 2011-06-30 09:24:26 +0800 | [diff] [blame] | 28 | imx_sdhci_esdhc_imx_data_entry(MX25, "sdhci-esdhc-imx25", _id, _hwid) |
Uwe Kleine-König | 124bf94 | 2010-11-19 21:03:33 +0100 | [diff] [blame] | 29 | 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 |
| 35 | const struct imx_sdhci_esdhc_imx_data |
| 36 | imx35_sdhci_esdhc_imx_data[] __initconst = { |
| 37 | #define imx35_sdhci_esdhc_imx_data_entry(_id, _hwid) \ |
Shawn Guo | 57ed331 | 2011-06-30 09:24:26 +0800 | [diff] [blame] | 38 | imx_sdhci_esdhc_imx_data_entry(MX35, "sdhci-esdhc-imx35", _id, _hwid) |
Uwe Kleine-König | 124bf94 | 2010-11-19 21:03:33 +0100 | [diff] [blame] | 39 | 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 Estevam | d94ed12 | 2010-11-26 12:25:58 -0200 | [diff] [blame] | 45 | #ifdef CONFIG_SOC_IMX51 |
Uwe Kleine-König | 124bf94 | 2010-11-19 21:03:33 +0100 | [diff] [blame] | 46 | const struct imx_sdhci_esdhc_imx_data |
| 47 | imx51_sdhci_esdhc_imx_data[] __initconst = { |
| 48 | #define imx51_sdhci_esdhc_imx_data_entry(_id, _hwid) \ |
Shawn Guo | 57ed331 | 2011-06-30 09:24:26 +0800 | [diff] [blame] | 49 | imx_sdhci_esdhc_imx_data_entry(MX51, "sdhci-esdhc-imx51", _id, _hwid) |
Uwe Kleine-König | 124bf94 | 2010-11-19 21:03:33 +0100 | [diff] [blame] | 50 | 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 Estevam | d94ed12 | 2010-11-26 12:25:58 -0200 | [diff] [blame] | 55 | #endif /* ifdef CONFIG_SOC_IMX51 */ |
Uwe Kleine-König | 124bf94 | 2010-11-19 21:03:33 +0100 | [diff] [blame] | 56 | |
Yong Shen | 410d3458 | 2011-01-07 12:25:34 +0800 | [diff] [blame] | 57 | #ifdef CONFIG_SOC_IMX53 |
| 58 | const struct imx_sdhci_esdhc_imx_data |
| 59 | imx53_sdhci_esdhc_imx_data[] __initconst = { |
| 60 | #define imx53_sdhci_esdhc_imx_data_entry(_id, _hwid) \ |
Shawn Guo | 57ed331 | 2011-06-30 09:24:26 +0800 | [diff] [blame] | 61 | imx_sdhci_esdhc_imx_data_entry(MX53, "sdhci-esdhc-imx53", _id, _hwid) |
Yong Shen | 410d3458 | 2011-01-07 12:25:34 +0800 | [diff] [blame] | 62 | 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 Guo | 913413c | 2011-06-21 22:41:51 +0800 | [diff] [blame] | 69 | static 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önig | 124bf94 | 2010-11-19 21:03:33 +0100 | [diff] [blame] | 74 | struct 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 Guo | 913413c | 2011-06-21 22:41:51 +0800 | [diff] [blame] | 90 | /* |
| 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 Guo | 57ed331 | 2011-06-30 09:24:26 +0800 | [diff] [blame] | 97 | return imx_add_platform_device(data->devid, data->id, res, |
Uwe Kleine-König | 124bf94 | 2010-11-19 21:03:33 +0100 | [diff] [blame] | 98 | ARRAY_SIZE(res), pdata, sizeof(*pdata)); |
| 99 | } |