Uwe Kleine-König | 0287073 | 2010-06-21 18:02:55 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2009-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 | */ |
Uwe Kleine-König | 35bab05 | 2010-09-09 21:02:02 +0200 | [diff] [blame] | 9 | #include <mach/hardware.h> |
Uwe Kleine-König | 0287073 | 2010-06-21 18:02:55 +0200 | [diff] [blame] | 10 | #include <mach/devices-common.h> |
| 11 | |
Uwe Kleine-König | 35bab05 | 2010-09-09 21:02:02 +0200 | [diff] [blame] | 12 | #define imx_spi_imx_data_entry_single(soc, type, _devid, _id, hwid, _size) \ |
| 13 | { \ |
| 14 | .id = _id, \ |
| 15 | .iobase = soc ## _ ## type ## hwid ## _BASE_ADDR, \ |
| 16 | .iosize = _size, \ |
| 17 | .irq = soc ## _INT_ ## type ## hwid, \ |
| 18 | } |
| 19 | |
| 20 | #define imx_spi_imx_data_entry(soc, type, devid, id, hwid, size) \ |
| 21 | [id] = imx_spi_imx_data_entry_single(soc, type, devid, id, hwid, size) |
| 22 | |
| 23 | #ifdef CONFIG_SOC_IMX21 |
| 24 | const struct imx_spi_imx_data imx21_cspi_data[] __initconst = { |
| 25 | #define imx21_cspi_data_entry(_id, _hwid) \ |
| 26 | imx_spi_imx_data_entry(MX21, CSPI, "imx21-cspi", _id, _hwid, SZ_4K) |
| 27 | imx21_cspi_data_entry(0, 1), |
| 28 | imx21_cspi_data_entry(1, 2), |
| 29 | #endif |
| 30 | |
| 31 | #ifdef CONFIG_ARCH_MX25 |
| 32 | const struct imx_spi_imx_data imx25_cspi_data[] __initconst = { |
| 33 | #define imx25_cspi_data_entry(_id, _hwid) \ |
| 34 | imx_spi_imx_data_entry(MX25, CSPI, "imx25-cspi", _id, _hwid, SZ_16K) |
| 35 | imx25_cspi_data_entry(0, 1), |
| 36 | imx25_cspi_data_entry(1, 2), |
| 37 | imx25_cspi_data_entry(2, 3), |
| 38 | }; |
| 39 | #endif /* ifdef CONFIG_ARCH_MX25 */ |
| 40 | |
| 41 | #ifdef CONFIG_SOC_IMX27 |
| 42 | const struct imx_spi_imx_data imx27_cspi_data[] __initconst = { |
| 43 | #define imx27_cspi_data_entry(_id, _hwid) \ |
| 44 | imx_spi_imx_data_entry(MX27, CSPI, "imx27-cspi", _id, _hwid, SZ_4K) |
| 45 | imx27_cspi_data_entry(0, 1), |
| 46 | imx27_cspi_data_entry(1, 2), |
| 47 | imx27_cspi_data_entry(2, 3), |
| 48 | }; |
| 49 | #endif /* ifdef CONFIG_SOC_IMX27 */ |
| 50 | |
| 51 | #ifdef CONFIG_ARCH_MX31 |
| 52 | const struct imx_spi_imx_data imx31_cspi_data[] __initconst = { |
| 53 | #define imx31_cspi_data_entry(_id, _hwid) \ |
| 54 | imx_spi_imx_data_entry(MX31, CSPI, "imx31-cspi", _id, _hwid, SZ_4K) |
| 55 | imx31_cspi_data_entry(0, 1), |
| 56 | imx31_cspi_data_entry(1, 2), |
| 57 | imx31_cspi_data_entry(2, 3), |
| 58 | }; |
| 59 | #endif /* ifdef CONFIG_ARCH_MX31 */ |
| 60 | |
| 61 | #ifdef CONFIG_ARCH_MX35 |
| 62 | const struct imx_spi_imx_data imx35_cspi_data[] __initconst = { |
| 63 | #define imx35_cspi_data_entry(_id, _hwid) \ |
| 64 | imx_spi_imx_data_entry(MX35, CSPI, "imx35-cspi", _id, _hwid, SZ_4K) |
| 65 | imx35_cspi_data_entry(0, 1), |
| 66 | imx35_cspi_data_entry(1, 2), |
| 67 | }; |
| 68 | #endif /* ifdef CONFIG_ARCH_MX35 */ |
| 69 | |
| 70 | struct platform_device *__init imx_add_spi_imx( |
| 71 | const struct imx_spi_imx_data *data, |
Uwe Kleine-König | 0287073 | 2010-06-21 18:02:55 +0200 | [diff] [blame] | 72 | const struct spi_imx_master *pdata) |
| 73 | { |
| 74 | struct resource res[] = { |
| 75 | { |
Uwe Kleine-König | 35bab05 | 2010-09-09 21:02:02 +0200 | [diff] [blame] | 76 | .start = data->iobase, |
| 77 | .end = data->iobase + data->iosize - 1, |
Uwe Kleine-König | 0287073 | 2010-06-21 18:02:55 +0200 | [diff] [blame] | 78 | .flags = IORESOURCE_MEM, |
| 79 | }, { |
Uwe Kleine-König | 35bab05 | 2010-09-09 21:02:02 +0200 | [diff] [blame] | 80 | .start = data->irq, |
| 81 | .end = data->irq, |
Uwe Kleine-König | 0287073 | 2010-06-21 18:02:55 +0200 | [diff] [blame] | 82 | .flags = IORESOURCE_IRQ, |
| 83 | }, |
| 84 | }; |
| 85 | |
Uwe Kleine-König | 35bab05 | 2010-09-09 21:02:02 +0200 | [diff] [blame] | 86 | return imx_add_platform_device("spi_imx", data->id, |
| 87 | res, ARRAY_SIZE(res), pdata, sizeof(*pdata)); |
Uwe Kleine-König | 0287073 | 2010-06-21 18:02:55 +0200 | [diff] [blame] | 88 | } |