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  */
9 #include "../hardware.h"
10 #include "devices-common.h"
11 
12 #define imx_imx_uart_3irq_data_entry(soc, _id, _hwid, _size)		\
13 	[_id] = {							\
14 		.id = _id,						\
15 		.iobase = soc ## _UART ## _hwid ## _BASE_ADDR,		\
16 		.iosize = _size,					\
17 		.irqrx = soc ## _INT_UART ## _hwid ## RX,		\
18 		.irqtx = soc ## _INT_UART ## _hwid ## TX,		\
19 		.irqrts = soc ## _INT_UART ## _hwid ## RTS,		\
20 	}
21 
22 #define imx_imx_uart_1irq_data_entry(soc, _id, _hwid, _size)		\
23 	[_id] = {							\
24 		.id = _id,						\
25 		.iobase = soc ## _UART ## _hwid ## _BASE_ADDR,		\
26 		.iosize = _size,					\
27 		.irq = soc ## _INT_UART ## _hwid,			\
28 	}
29 
30 #ifdef CONFIG_SOC_IMX21
31 const struct imx_imx_uart_1irq_data imx21_imx_uart_data[] __initconst = {
32 #define imx21_imx_uart_data_entry(_id, _hwid)				\
33 	imx_imx_uart_1irq_data_entry(MX21, _id, _hwid, SZ_4K)
34 	imx21_imx_uart_data_entry(0, 1),
35 	imx21_imx_uart_data_entry(1, 2),
36 	imx21_imx_uart_data_entry(2, 3),
37 	imx21_imx_uart_data_entry(3, 4),
38 };
39 #endif
40 
41 #ifdef CONFIG_SOC_IMX27
42 const struct imx_imx_uart_1irq_data imx27_imx_uart_data[] __initconst = {
43 #define imx27_imx_uart_data_entry(_id, _hwid)				\
44 	imx_imx_uart_1irq_data_entry(MX27, _id, _hwid, SZ_4K)
45 	imx27_imx_uart_data_entry(0, 1),
46 	imx27_imx_uart_data_entry(1, 2),
47 	imx27_imx_uart_data_entry(2, 3),
48 	imx27_imx_uart_data_entry(3, 4),
49 	imx27_imx_uart_data_entry(4, 5),
50 	imx27_imx_uart_data_entry(5, 6),
51 };
52 #endif /* ifdef CONFIG_SOC_IMX27 */
53 
54 #ifdef CONFIG_SOC_IMX31
55 const struct imx_imx_uart_1irq_data imx31_imx_uart_data[] __initconst = {
56 #define imx31_imx_uart_data_entry(_id, _hwid)				\
57 	imx_imx_uart_1irq_data_entry(MX31, _id, _hwid, SZ_4K)
58 	imx31_imx_uart_data_entry(0, 1),
59 	imx31_imx_uart_data_entry(1, 2),
60 	imx31_imx_uart_data_entry(2, 3),
61 	imx31_imx_uart_data_entry(3, 4),
62 	imx31_imx_uart_data_entry(4, 5),
63 };
64 #endif /* ifdef CONFIG_SOC_IMX31 */
65 
66 #ifdef CONFIG_SOC_IMX35
67 const struct imx_imx_uart_1irq_data imx35_imx_uart_data[] __initconst = {
68 #define imx35_imx_uart_data_entry(_id, _hwid)				\
69 	imx_imx_uart_1irq_data_entry(MX35, _id, _hwid, SZ_16K)
70 	imx35_imx_uart_data_entry(0, 1),
71 	imx35_imx_uart_data_entry(1, 2),
72 	imx35_imx_uart_data_entry(2, 3),
73 };
74 #endif /* ifdef CONFIG_SOC_IMX35 */
75 
imx_add_imx_uart_1irq(const struct imx_imx_uart_1irq_data * data,const struct imxuart_platform_data * pdata)76 struct platform_device *__init imx_add_imx_uart_1irq(
77 		const struct imx_imx_uart_1irq_data *data,
78 		const struct imxuart_platform_data *pdata)
79 {
80 	struct resource res[] = {
81 		{
82 			.start = data->iobase,
83 			.end = data->iobase + data->iosize - 1,
84 			.flags = IORESOURCE_MEM,
85 		}, {
86 			.start = data->irq,
87 			.end = data->irq,
88 			.flags = IORESOURCE_IRQ,
89 		},
90 	};
91 
92 	/* i.mx21 type uart runs on all i.mx except i.mx1 */
93 	return imx_add_platform_device("imx21-uart", data->id,
94 			res, ARRAY_SIZE(res), pdata, sizeof(*pdata));
95 }
96