1 // SPDX-License-Identifier: GPL-2.0-only
2 /*
3  * Copyright (C) 2010 Pengutronix, Marc Kleine-Budde <kernel@pengutronix.de>
4  */
5 #include "../hardware.h"
6 #include "devices-common.h"
7 
8 #define imx_flexcan_data_entry_single(soc, _id, _hwid, _size)		\
9 	{								\
10 		.id = _id,						\
11 		.iobase = soc ## _CAN ## _hwid ## _BASE_ADDR,		\
12 		.iosize = _size,					\
13 		.irq = soc ## _INT_CAN ## _hwid,			\
14 	}
15 
16 #define imx_flexcan_data_entry(soc, _id, _hwid, _size)			\
17 	[_id] = imx_flexcan_data_entry_single(soc, _id, _hwid, _size)
18 
19 #ifdef CONFIG_SOC_IMX35
20 const struct imx_flexcan_data imx35_flexcan_data[] __initconst = {
21 #define imx35_flexcan_data_entry(_id, _hwid)				\
22 	imx_flexcan_data_entry(MX35, _id, _hwid, SZ_16K)
23 	imx35_flexcan_data_entry(0, 1),
24 	imx35_flexcan_data_entry(1, 2),
25 };
26 #endif /* ifdef CONFIG_SOC_IMX35 */
27 
imx_add_flexcan(const struct imx_flexcan_data * data)28 struct platform_device *__init imx_add_flexcan(
29 		const struct imx_flexcan_data *data)
30 {
31 	struct resource res[] = {
32 		{
33 			.start = data->iobase,
34 			.end = data->iobase + data->iosize - 1,
35 			.flags = IORESOURCE_MEM,
36 		}, {
37 			.start = data->irq,
38 			.end = data->irq,
39 			.flags = IORESOURCE_IRQ,
40 		},
41 	};
42 
43 	return imx_add_platform_device("flexcan", data->id,
44 			res, ARRAY_SIZE(res), NULL, 0);
45 }
46