Marc Kleine-Budde | 61c6850 | 2010-07-22 11:45:34 +0200 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2010 Pengutronix, Marc Kleine-Budde <kernel@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 | */ |
Uwe Kleine-König | fc40d01 | 2010-11-04 12:02:35 +0100 | [diff] [blame] | 8 | #include <mach/hardware.h> |
Marc Kleine-Budde | 61c6850 | 2010-07-22 11:45:34 +0200 | [diff] [blame] | 9 | #include <mach/devices-common.h> |
| 10 | |
Uwe Kleine-König | fc40d01 | 2010-11-04 12:02:35 +0100 | [diff] [blame] | 11 | #define imx_flexcan_data_entry_single(soc, _id, _hwid, _size) \ |
| 12 | { \ |
| 13 | .id = _id, \ |
| 14 | .iobase = soc ## _CAN ## _hwid ## _BASE_ADDR, \ |
| 15 | .iosize = _size, \ |
| 16 | .irq = soc ## _INT_CAN ## _hwid, \ |
| 17 | } |
| 18 | |
| 19 | #define imx_flexcan_data_entry(soc, _id, _hwid, _size) \ |
| 20 | [_id] = imx_flexcan_data_entry_single(soc, _id, _hwid, _size) |
| 21 | |
Uwe Kleine-König | 972cc48 | 2010-11-11 18:35:01 +0100 | [diff] [blame] | 22 | #ifdef CONFIG_SOC_IMX25 |
Uwe Kleine-König | fc40d01 | 2010-11-04 12:02:35 +0100 | [diff] [blame] | 23 | const struct imx_flexcan_data imx25_flexcan_data[] __initconst = { |
| 24 | #define imx25_flexcan_data_entry(_id, _hwid) \ |
| 25 | imx_flexcan_data_entry(MX25, _id, _hwid, SZ_16K) |
| 26 | imx25_flexcan_data_entry(0, 1), |
| 27 | imx25_flexcan_data_entry(1, 2), |
| 28 | }; |
Uwe Kleine-König | 972cc48 | 2010-11-11 18:35:01 +0100 | [diff] [blame] | 29 | #endif /* ifdef CONFIG_SOC_IMX25 */ |
Uwe Kleine-König | fc40d01 | 2010-11-04 12:02:35 +0100 | [diff] [blame] | 30 | |
Uwe Kleine-König | a528bc8 | 2010-11-12 10:11:42 +0100 | [diff] [blame] | 31 | #ifdef CONFIG_SOC_IMX35 |
Uwe Kleine-König | fc40d01 | 2010-11-04 12:02:35 +0100 | [diff] [blame] | 32 | const struct imx_flexcan_data imx35_flexcan_data[] __initconst = { |
| 33 | #define imx35_flexcan_data_entry(_id, _hwid) \ |
| 34 | imx_flexcan_data_entry(MX35, _id, _hwid, SZ_16K) |
| 35 | imx35_flexcan_data_entry(0, 1), |
| 36 | imx35_flexcan_data_entry(1, 2), |
| 37 | }; |
Uwe Kleine-König | a528bc8 | 2010-11-12 10:11:42 +0100 | [diff] [blame] | 38 | #endif /* ifdef CONFIG_SOC_IMX35 */ |
Uwe Kleine-König | fc40d01 | 2010-11-04 12:02:35 +0100 | [diff] [blame] | 39 | |
| 40 | struct platform_device *__init imx_add_flexcan( |
| 41 | const struct imx_flexcan_data *data, |
Marc Kleine-Budde | 61c6850 | 2010-07-22 11:45:34 +0200 | [diff] [blame] | 42 | const struct flexcan_platform_data *pdata) |
| 43 | { |
| 44 | struct resource res[] = { |
| 45 | { |
Uwe Kleine-König | fc40d01 | 2010-11-04 12:02:35 +0100 | [diff] [blame] | 46 | .start = data->iobase, |
| 47 | .end = data->iobase + data->iosize - 1, |
Marc Kleine-Budde | 61c6850 | 2010-07-22 11:45:34 +0200 | [diff] [blame] | 48 | .flags = IORESOURCE_MEM, |
| 49 | }, { |
Uwe Kleine-König | fc40d01 | 2010-11-04 12:02:35 +0100 | [diff] [blame] | 50 | .start = data->irq, |
| 51 | .end = data->irq, |
Marc Kleine-Budde | 61c6850 | 2010-07-22 11:45:34 +0200 | [diff] [blame] | 52 | .flags = IORESOURCE_IRQ, |
| 53 | }, |
| 54 | }; |
| 55 | |
Uwe Kleine-König | fc40d01 | 2010-11-04 12:02:35 +0100 | [diff] [blame] | 56 | return imx_add_platform_device("flexcan", data->id, |
| 57 | res, ARRAY_SIZE(res), pdata, sizeof(*pdata)); |
Marc Kleine-Budde | 61c6850 | 2010-07-22 11:45:34 +0200 | [diff] [blame] | 58 | } |