serial.c 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*
  2. * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved.
  3. * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
  4. *
  5. * This program is free software; you can redistribute it and/or
  6. * modify it under the terms of the GNU General Public License
  7. * as published by the Free Software Foundation; either version 2
  8. * of the License, or (at your option) any later version.
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  17. * MA 02110-1301, USA.
  18. */
  19. #include <linux/module.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/serial.h>
  22. #include <asm/hardware.h>
  23. #include <asm/arch/imx-uart.h>
  24. static struct resource uart0[] = {
  25. {
  26. .start = UART1_BASE_ADDR,
  27. .end = UART1_BASE_ADDR + 0x0B5,
  28. .flags = IORESOURCE_MEM,
  29. }, {
  30. .start = MXC_INT_UART1,
  31. .end = MXC_INT_UART1,
  32. .flags = IORESOURCE_IRQ,
  33. },
  34. };
  35. static struct platform_device mxc_uart_device0 = {
  36. .name = "imx-uart",
  37. .id = 0,
  38. .resource = uart0,
  39. .num_resources = ARRAY_SIZE(uart0),
  40. };
  41. static struct resource uart1[] = {
  42. {
  43. .start = UART2_BASE_ADDR,
  44. .end = UART2_BASE_ADDR + 0x0B5,
  45. .flags = IORESOURCE_MEM,
  46. }, {
  47. .start = MXC_INT_UART2,
  48. .end = MXC_INT_UART2,
  49. .flags = IORESOURCE_IRQ,
  50. },
  51. };
  52. static struct platform_device mxc_uart_device1 = {
  53. .name = "imx-uart",
  54. .id = 1,
  55. .resource = uart1,
  56. .num_resources = ARRAY_SIZE(uart1),
  57. };
  58. static struct resource uart2[] = {
  59. {
  60. .start = UART3_BASE_ADDR,
  61. .end = UART3_BASE_ADDR + 0x0B5,
  62. .flags = IORESOURCE_MEM,
  63. }, {
  64. .start = MXC_INT_UART3,
  65. .end = MXC_INT_UART3,
  66. .flags = IORESOURCE_IRQ,
  67. },
  68. };
  69. static struct platform_device mxc_uart_device2 = {
  70. .name = "imx-uart",
  71. .id = 2,
  72. .resource = uart2,
  73. .num_resources = ARRAY_SIZE(uart2),
  74. };
  75. static struct resource uart3[] = {
  76. {
  77. .start = UART4_BASE_ADDR,
  78. .end = UART4_BASE_ADDR + 0x0B5,
  79. .flags = IORESOURCE_MEM,
  80. }, {
  81. .start = MXC_INT_UART4,
  82. .end = MXC_INT_UART4,
  83. .flags = IORESOURCE_IRQ,
  84. },
  85. };
  86. static struct platform_device mxc_uart_device3 = {
  87. .name = "imx-uart",
  88. .id = 3,
  89. .resource = uart3,
  90. .num_resources = ARRAY_SIZE(uart3),
  91. };
  92. static struct resource uart4[] = {
  93. {
  94. .start = UART5_BASE_ADDR,
  95. .end = UART5_BASE_ADDR + 0x0B5,
  96. .flags = IORESOURCE_MEM,
  97. }, {
  98. .start = MXC_INT_UART5,
  99. .end = MXC_INT_UART5,
  100. .flags = IORESOURCE_IRQ,
  101. },
  102. };
  103. static struct platform_device mxc_uart_device4 = {
  104. .name = "imx-uart",
  105. .id = 4,
  106. .resource = uart4,
  107. .num_resources = ARRAY_SIZE(uart4),
  108. };
  109. static struct resource uart5[] = {
  110. {
  111. .start = UART6_BASE_ADDR,
  112. .end = UART6_BASE_ADDR + 0x0B5,
  113. .flags = IORESOURCE_MEM,
  114. }, {
  115. .start = MXC_INT_UART6,
  116. .end = MXC_INT_UART6,
  117. .flags = IORESOURCE_IRQ,
  118. },
  119. };
  120. static struct platform_device mxc_uart_device5 = {
  121. .name = "imx-uart",
  122. .id = 5,
  123. .resource = uart5,
  124. .num_resources = ARRAY_SIZE(uart5),
  125. };
  126. /*
  127. * Register only those UARTs that physically exists
  128. */
  129. int __init imx_init_uart(int uart_no, struct imxuart_platform_data *pdata)
  130. {
  131. switch (uart_no) {
  132. case 0:
  133. mxc_uart_device0.dev.platform_data = pdata;
  134. platform_device_register(&mxc_uart_device0);
  135. break;
  136. case 1:
  137. mxc_uart_device1.dev.platform_data = pdata;
  138. platform_device_register(&mxc_uart_device1);
  139. break;
  140. #ifndef CONFIG_MXC_IRDA
  141. case 2:
  142. mxc_uart_device2.dev.platform_data = pdata;
  143. platform_device_register(&mxc_uart_device2);
  144. break;
  145. #endif
  146. case 3:
  147. mxc_uart_device3.dev.platform_data = pdata;
  148. platform_device_register(&mxc_uart_device3);
  149. break;
  150. case 4:
  151. mxc_uart_device4.dev.platform_data = pdata;
  152. platform_device_register(&mxc_uart_device4);
  153. break;
  154. case 5:
  155. mxc_uart_device5.dev.platform_data = pdata;
  156. platform_device_register(&mxc_uart_device5);
  157. break;
  158. default:
  159. return -ENODEV;
  160. }
  161. return 0;
  162. }