blob: 6962cff4a9504569cc333b6e538bdbc54dfa1a36 [file] [log] [blame]
Uwe Kleine-König2db68232010-06-22 14:49:20 +02001/*
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 */
Shawn Guo50f2de62012-09-14 14:14:45 +08009#include "../hardware.h"
Shawn Guoe0557c02012-09-13 15:51:15 +080010#include "devices-common.h"
Uwe Kleine-König2db68232010-06-22 14:49:20 +020011
Uwe Kleine-König5162de02010-08-10 22:57:24 +020012#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_IMX1
31const struct imx_imx_uart_3irq_data imx1_imx_uart_data[] __initconst = {
32#define imx1_imx_uart_data_entry(_id, _hwid) \
33 imx_imx_uart_3irq_data_entry(MX1, _id, _hwid, 0xd0)
34 imx1_imx_uart_data_entry(0, 1),
35 imx1_imx_uart_data_entry(1, 2),
36};
37#endif /* ifdef CONFIG_SOC_IMX1 */
38
39#ifdef CONFIG_SOC_IMX21
40const struct imx_imx_uart_1irq_data imx21_imx_uart_data[] __initconst = {
41#define imx21_imx_uart_data_entry(_id, _hwid) \
42 imx_imx_uart_1irq_data_entry(MX21, _id, _hwid, SZ_4K)
43 imx21_imx_uart_data_entry(0, 1),
44 imx21_imx_uart_data_entry(1, 2),
45 imx21_imx_uart_data_entry(2, 3),
46 imx21_imx_uart_data_entry(3, 4),
47};
48#endif
49
Uwe Kleine-König5162de02010-08-10 22:57:24 +020050#ifdef CONFIG_SOC_IMX27
51const struct imx_imx_uart_1irq_data imx27_imx_uart_data[] __initconst = {
52#define imx27_imx_uart_data_entry(_id, _hwid) \
53 imx_imx_uart_1irq_data_entry(MX27, _id, _hwid, SZ_4K)
54 imx27_imx_uart_data_entry(0, 1),
55 imx27_imx_uart_data_entry(1, 2),
56 imx27_imx_uart_data_entry(2, 3),
57 imx27_imx_uart_data_entry(3, 4),
58 imx27_imx_uart_data_entry(4, 5),
59 imx27_imx_uart_data_entry(5, 6),
60};
61#endif /* ifdef CONFIG_SOC_IMX27 */
62
Uwe Kleine-Königa528bc82010-11-12 10:11:42 +010063#ifdef CONFIG_SOC_IMX31
Uwe Kleine-König5162de02010-08-10 22:57:24 +020064const struct imx_imx_uart_1irq_data imx31_imx_uart_data[] __initconst = {
65#define imx31_imx_uart_data_entry(_id, _hwid) \
66 imx_imx_uart_1irq_data_entry(MX31, _id, _hwid, SZ_4K)
67 imx31_imx_uart_data_entry(0, 1),
68 imx31_imx_uart_data_entry(1, 2),
69 imx31_imx_uart_data_entry(2, 3),
70 imx31_imx_uart_data_entry(3, 4),
71 imx31_imx_uart_data_entry(4, 5),
72};
Uwe Kleine-Königa528bc82010-11-12 10:11:42 +010073#endif /* ifdef CONFIG_SOC_IMX31 */
Uwe Kleine-König5162de02010-08-10 22:57:24 +020074
Uwe Kleine-Königa528bc82010-11-12 10:11:42 +010075#ifdef CONFIG_SOC_IMX35
Uwe Kleine-König5162de02010-08-10 22:57:24 +020076const struct imx_imx_uart_1irq_data imx35_imx_uart_data[] __initconst = {
77#define imx35_imx_uart_data_entry(_id, _hwid) \
Oskar Schirmer9954c572012-09-10 09:19:35 +000078 imx_imx_uart_1irq_data_entry(MX35, _id, _hwid, SZ_16K)
Uwe Kleine-König5162de02010-08-10 22:57:24 +020079 imx35_imx_uart_data_entry(0, 1),
80 imx35_imx_uart_data_entry(1, 2),
81 imx35_imx_uart_data_entry(2, 3),
82};
Uwe Kleine-Königa528bc82010-11-12 10:11:42 +010083#endif /* ifdef CONFIG_SOC_IMX35 */
Uwe Kleine-König5162de02010-08-10 22:57:24 +020084
85struct platform_device *__init imx_add_imx_uart_3irq(
86 const struct imx_imx_uart_3irq_data *data,
Uwe Kleine-König2db68232010-06-22 14:49:20 +020087 const struct imxuart_platform_data *pdata)
88{
89 struct resource res[] = {
90 {
Uwe Kleine-König5162de02010-08-10 22:57:24 +020091 .start = data->iobase,
92 .end = data->iobase + data->iosize - 1,
Uwe Kleine-König2db68232010-06-22 14:49:20 +020093 .flags = IORESOURCE_MEM,
94 }, {
Uwe Kleine-König5162de02010-08-10 22:57:24 +020095 .start = data->irqrx,
96 .end = data->irqrx,
Uwe Kleine-König2db68232010-06-22 14:49:20 +020097 .flags = IORESOURCE_IRQ,
98 }, {
Uwe Kleine-König5162de02010-08-10 22:57:24 +020099 .start = data->irqtx,
100 .end = data->irqtx,
Uwe Kleine-König2db68232010-06-22 14:49:20 +0200101 .flags = IORESOURCE_IRQ,
102 }, {
Uwe Kleine-König5162de02010-08-10 22:57:24 +0200103 .start = data->irqrts,
104 .end = data->irqrx,
Uwe Kleine-König2db68232010-06-22 14:49:20 +0200105 .flags = IORESOURCE_IRQ,
106 },
107 };
108
Shawn Guofe6b5402011-06-25 02:04:33 +0800109 return imx_add_platform_device("imx1-uart", data->id, res,
Uwe Kleine-König5162de02010-08-10 22:57:24 +0200110 ARRAY_SIZE(res), pdata, sizeof(*pdata));
Uwe Kleine-König2db68232010-06-22 14:49:20 +0200111}
112
Uwe Kleine-König5162de02010-08-10 22:57:24 +0200113struct platform_device *__init imx_add_imx_uart_1irq(
114 const struct imx_imx_uart_1irq_data *data,
Uwe Kleine-König2db68232010-06-22 14:49:20 +0200115 const struct imxuart_platform_data *pdata)
116{
117 struct resource res[] = {
118 {
Uwe Kleine-König5162de02010-08-10 22:57:24 +0200119 .start = data->iobase,
120 .end = data->iobase + data->iosize - 1,
Uwe Kleine-König2db68232010-06-22 14:49:20 +0200121 .flags = IORESOURCE_MEM,
122 }, {
Uwe Kleine-König5162de02010-08-10 22:57:24 +0200123 .start = data->irq,
124 .end = data->irq,
Uwe Kleine-König2db68232010-06-22 14:49:20 +0200125 .flags = IORESOURCE_IRQ,
126 },
127 };
128
Shawn Guofe6b5402011-06-25 02:04:33 +0800129 /* i.mx21 type uart runs on all i.mx except i.mx1 */
130 return imx_add_platform_device("imx21-uart", data->id,
131 res, ARRAY_SIZE(res), pdata, sizeof(*pdata));
Uwe Kleine-König2db68232010-06-22 14:49:20 +0200132}