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