platform-imx-uart.c 2.9 KB

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