Uwe Kleine-König | 9d3d945 | 2010-11-05 17:26:09 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 Pengutronix |
| 3 | * Uwe Kleine-Koenig <u.kleine-koenig@pengutronix.de> |
| 4 | * |
| 5 | * This program is free software; you can redistribute it and/or modify it under |
| 6 | * the terms of the GNU General Public License version 2 as published by the |
| 7 | * Free Software Foundation. |
| 8 | */ |
Alexey Dobriyan | b7f080c | 2011-06-16 11:01:34 +0000 | [diff] [blame] | 9 | #include <linux/dma-mapping.h> |
Shawn Guo | 50f2de6 | 2012-09-14 14:14:45 +0800 | [diff] [blame] | 10 | |
| 11 | #include "../hardware.h" |
Shawn Guo | e0557c0 | 2012-09-13 15:51:15 +0800 | [diff] [blame] | 12 | #include "devices-common.h" |
Uwe Kleine-König | 9d3d945 | 2010-11-05 17:26:09 +0100 | [diff] [blame] | 13 | |
Shawn Guo | 7f917a8 | 2012-09-16 16:54:30 +0800 | [diff] [blame] | 14 | #define imx_mxc_mmc_data_entry_single(soc, _devid, _id, _hwid, _size) \ |
Uwe Kleine-König | 9d3d945 | 2010-11-05 17:26:09 +0100 | [diff] [blame] | 15 | { \ |
Shawn Guo | 7f917a8 | 2012-09-16 16:54:30 +0800 | [diff] [blame] | 16 | .devid = _devid, \ |
Uwe Kleine-König | 9d3d945 | 2010-11-05 17:26:09 +0100 | [diff] [blame] | 17 | .id = _id, \ |
| 18 | .iobase = soc ## _SDHC ## _hwid ## _BASE_ADDR, \ |
Uwe Kleine-König | 6a697e3 | 2010-11-12 11:10:55 +0100 | [diff] [blame] | 19 | .iosize = _size, \ |
Uwe Kleine-König | 9d3d945 | 2010-11-05 17:26:09 +0100 | [diff] [blame] | 20 | .irq = soc ## _INT_SDHC ## _hwid, \ |
| 21 | .dmareq = soc ## _DMA_REQ_SDHC ## _hwid, \ |
| 22 | } |
Shawn Guo | 7f917a8 | 2012-09-16 16:54:30 +0800 | [diff] [blame] | 23 | #define imx_mxc_mmc_data_entry(soc, _devid, _id, _hwid, _size) \ |
| 24 | [_id] = imx_mxc_mmc_data_entry_single(soc, _devid, _id, _hwid, _size) |
Uwe Kleine-König | 9d3d945 | 2010-11-05 17:26:09 +0100 | [diff] [blame] | 25 | |
| 26 | #ifdef CONFIG_SOC_IMX21 |
| 27 | const struct imx_mxc_mmc_data imx21_mxc_mmc_data[] __initconst = { |
| 28 | #define imx21_mxc_mmc_data_entry(_id, _hwid) \ |
Shawn Guo | 7f917a8 | 2012-09-16 16:54:30 +0800 | [diff] [blame] | 29 | imx_mxc_mmc_data_entry(MX21, "imx21-mmc", _id, _hwid, SZ_4K) |
Uwe Kleine-König | 9d3d945 | 2010-11-05 17:26:09 +0100 | [diff] [blame] | 30 | imx21_mxc_mmc_data_entry(0, 1), |
| 31 | imx21_mxc_mmc_data_entry(1, 2), |
| 32 | }; |
| 33 | #endif /* ifdef CONFIG_SOC_IMX21 */ |
| 34 | |
| 35 | #ifdef CONFIG_SOC_IMX27 |
| 36 | const struct imx_mxc_mmc_data imx27_mxc_mmc_data[] __initconst = { |
| 37 | #define imx27_mxc_mmc_data_entry(_id, _hwid) \ |
Shawn Guo | 7f917a8 | 2012-09-16 16:54:30 +0800 | [diff] [blame] | 38 | imx_mxc_mmc_data_entry(MX27, "imx21-mmc", _id, _hwid, SZ_4K) |
Uwe Kleine-König | 9d3d945 | 2010-11-05 17:26:09 +0100 | [diff] [blame] | 39 | imx27_mxc_mmc_data_entry(0, 1), |
| 40 | imx27_mxc_mmc_data_entry(1, 2), |
| 41 | }; |
| 42 | #endif /* ifdef CONFIG_SOC_IMX27 */ |
| 43 | |
Uwe Kleine-König | 6a697e3 | 2010-11-12 11:10:55 +0100 | [diff] [blame] | 44 | #ifdef CONFIG_SOC_IMX31 |
| 45 | const struct imx_mxc_mmc_data imx31_mxc_mmc_data[] __initconst = { |
| 46 | #define imx31_mxc_mmc_data_entry(_id, _hwid) \ |
Shawn Guo | 7f917a8 | 2012-09-16 16:54:30 +0800 | [diff] [blame] | 47 | imx_mxc_mmc_data_entry(MX31, "imx31-mmc", _id, _hwid, SZ_16K) |
Uwe Kleine-König | 6a697e3 | 2010-11-12 11:10:55 +0100 | [diff] [blame] | 48 | imx31_mxc_mmc_data_entry(0, 1), |
| 49 | imx31_mxc_mmc_data_entry(1, 2), |
| 50 | }; |
| 51 | #endif /* ifdef CONFIG_SOC_IMX31 */ |
| 52 | |
Uwe Kleine-König | 9d3d945 | 2010-11-05 17:26:09 +0100 | [diff] [blame] | 53 | struct platform_device *__init imx_add_mxc_mmc( |
| 54 | const struct imx_mxc_mmc_data *data, |
| 55 | const struct imxmmc_platform_data *pdata) |
| 56 | { |
| 57 | struct resource res[] = { |
| 58 | { |
| 59 | .start = data->iobase, |
Fabio Estevam | 973a6a7 | 2012-10-09 16:25:13 -0300 | [diff] [blame] | 60 | .end = data->iobase + data->iosize - 1, |
Uwe Kleine-König | 9d3d945 | 2010-11-05 17:26:09 +0100 | [diff] [blame] | 61 | .flags = IORESOURCE_MEM, |
| 62 | }, { |
| 63 | .start = data->irq, |
| 64 | .end = data->irq, |
| 65 | .flags = IORESOURCE_IRQ, |
| 66 | }, { |
| 67 | .start = data->dmareq, |
| 68 | .end = data->dmareq, |
| 69 | .flags = IORESOURCE_DMA, |
| 70 | }, |
| 71 | }; |
Shawn Guo | 7f917a8 | 2012-09-16 16:54:30 +0800 | [diff] [blame] | 72 | return imx_add_platform_device_dmamask(data->devid, data->id, |
Uwe Kleine-König | 9d3d945 | 2010-11-05 17:26:09 +0100 | [diff] [blame] | 73 | res, ARRAY_SIZE(res), |
| 74 | pdata, sizeof(*pdata), DMA_BIT_MASK(32)); |
| 75 | } |