Kyle Swenson | 8d8f654 | 2021-03-15 11:02:55 -0600 | [diff] [blame^] | 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_IMX1 |
| 31 | const 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 |
| 40 | const 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 | |
| 50 | #ifdef CONFIG_SOC_IMX27 |
| 51 | const 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 | |
| 63 | #ifdef CONFIG_SOC_IMX31 |
| 64 | const 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 | }; |
| 73 | #endif /* ifdef CONFIG_SOC_IMX31 */ |
| 74 | |
| 75 | #ifdef CONFIG_SOC_IMX35 |
| 76 | const struct imx_imx_uart_1irq_data imx35_imx_uart_data[] __initconst = { |
| 77 | #define imx35_imx_uart_data_entry(_id, _hwid) \ |
| 78 | imx_imx_uart_1irq_data_entry(MX35, _id, _hwid, SZ_16K) |
| 79 | imx35_imx_uart_data_entry(0, 1), |
| 80 | imx35_imx_uart_data_entry(1, 2), |
| 81 | imx35_imx_uart_data_entry(2, 3), |
| 82 | }; |
| 83 | #endif /* ifdef CONFIG_SOC_IMX35 */ |
| 84 | |
| 85 | struct platform_device *__init imx_add_imx_uart_3irq( |
| 86 | const struct imx_imx_uart_3irq_data *data, |
| 87 | const struct imxuart_platform_data *pdata) |
| 88 | { |
| 89 | struct resource res[] = { |
| 90 | { |
| 91 | .start = data->iobase, |
| 92 | .end = data->iobase + data->iosize - 1, |
| 93 | .flags = IORESOURCE_MEM, |
| 94 | }, { |
| 95 | .start = data->irqrx, |
| 96 | .end = data->irqrx, |
| 97 | .flags = IORESOURCE_IRQ, |
| 98 | }, { |
| 99 | .start = data->irqtx, |
| 100 | .end = data->irqtx, |
| 101 | .flags = IORESOURCE_IRQ, |
| 102 | }, { |
| 103 | .start = data->irqrts, |
| 104 | .end = data->irqrx, |
| 105 | .flags = IORESOURCE_IRQ, |
| 106 | }, |
| 107 | }; |
| 108 | |
| 109 | return imx_add_platform_device("imx1-uart", data->id, res, |
| 110 | ARRAY_SIZE(res), pdata, sizeof(*pdata)); |
| 111 | } |
| 112 | |
| 113 | struct platform_device *__init imx_add_imx_uart_1irq( |
| 114 | const struct imx_imx_uart_1irq_data *data, |
| 115 | const struct imxuart_platform_data *pdata) |
| 116 | { |
| 117 | struct resource res[] = { |
| 118 | { |
| 119 | .start = data->iobase, |
| 120 | .end = data->iobase + data->iosize - 1, |
| 121 | .flags = IORESOURCE_MEM, |
| 122 | }, { |
| 123 | .start = data->irq, |
| 124 | .end = data->irq, |
| 125 | .flags = IORESOURCE_IRQ, |
| 126 | }, |
| 127 | }; |
| 128 | |
| 129 | /* 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)); |
| 132 | } |