devices.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. /*
  2. * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved.
  3. * Copyright 2008 Sascha Hauer, 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,
  17. * Boston, MA 02110-1301, USA.
  18. */
  19. #include <linux/module.h>
  20. #include <linux/platform_device.h>
  21. #include <linux/serial.h>
  22. #include <linux/gpio.h>
  23. #include <mach/hardware.h>
  24. #include <mach/imx-uart.h>
  25. static struct resource uart0[] = {
  26. {
  27. .start = UART1_BASE_ADDR,
  28. .end = UART1_BASE_ADDR + 0x0B5,
  29. .flags = IORESOURCE_MEM,
  30. }, {
  31. .start = MXC_INT_UART1,
  32. .end = MXC_INT_UART1,
  33. .flags = IORESOURCE_IRQ,
  34. },
  35. };
  36. struct platform_device mxc_uart_device0 = {
  37. .name = "imx-uart",
  38. .id = 0,
  39. .resource = uart0,
  40. .num_resources = ARRAY_SIZE(uart0),
  41. };
  42. static struct resource uart1[] = {
  43. {
  44. .start = UART2_BASE_ADDR,
  45. .end = UART2_BASE_ADDR + 0x0B5,
  46. .flags = IORESOURCE_MEM,
  47. }, {
  48. .start = MXC_INT_UART2,
  49. .end = MXC_INT_UART2,
  50. .flags = IORESOURCE_IRQ,
  51. },
  52. };
  53. struct platform_device mxc_uart_device1 = {
  54. .name = "imx-uart",
  55. .id = 1,
  56. .resource = uart1,
  57. .num_resources = ARRAY_SIZE(uart1),
  58. };
  59. static struct resource uart2[] = {
  60. {
  61. .start = UART3_BASE_ADDR,
  62. .end = UART3_BASE_ADDR + 0x0B5,
  63. .flags = IORESOURCE_MEM,
  64. }, {
  65. .start = MXC_INT_UART3,
  66. .end = MXC_INT_UART3,
  67. .flags = IORESOURCE_IRQ,
  68. },
  69. };
  70. struct platform_device mxc_uart_device2 = {
  71. .name = "imx-uart",
  72. .id = 2,
  73. .resource = uart2,
  74. .num_resources = ARRAY_SIZE(uart2),
  75. };
  76. static struct resource uart3[] = {
  77. {
  78. .start = UART4_BASE_ADDR,
  79. .end = UART4_BASE_ADDR + 0x0B5,
  80. .flags = IORESOURCE_MEM,
  81. }, {
  82. .start = MXC_INT_UART4,
  83. .end = MXC_INT_UART4,
  84. .flags = IORESOURCE_IRQ,
  85. },
  86. };
  87. struct platform_device mxc_uart_device3 = {
  88. .name = "imx-uart",
  89. .id = 3,
  90. .resource = uart3,
  91. .num_resources = ARRAY_SIZE(uart3),
  92. };
  93. static struct resource uart4[] = {
  94. {
  95. .start = UART5_BASE_ADDR,
  96. .end = UART5_BASE_ADDR + 0x0B5,
  97. .flags = IORESOURCE_MEM,
  98. }, {
  99. .start = MXC_INT_UART5,
  100. .end = MXC_INT_UART5,
  101. .flags = IORESOURCE_IRQ,
  102. },
  103. };
  104. struct platform_device mxc_uart_device4 = {
  105. .name = "imx-uart",
  106. .id = 4,
  107. .resource = uart4,
  108. .num_resources = ARRAY_SIZE(uart4),
  109. };
  110. /* GPIO port description */
  111. static struct mxc_gpio_port imx_gpio_ports[] = {
  112. [0] = {
  113. .chip.label = "gpio-0",
  114. .base = IO_ADDRESS(GPIO1_BASE_ADDR),
  115. .irq = MXC_INT_GPIO1,
  116. .virtual_irq_start = MXC_GPIO_INT_BASE
  117. },
  118. [1] = {
  119. .chip.label = "gpio-1",
  120. .base = IO_ADDRESS(GPIO2_BASE_ADDR),
  121. .irq = MXC_INT_GPIO2,
  122. .virtual_irq_start = MXC_GPIO_INT_BASE + GPIO_NUM_PIN
  123. },
  124. [2] = {
  125. .chip.label = "gpio-2",
  126. .base = IO_ADDRESS(GPIO3_BASE_ADDR),
  127. .irq = MXC_INT_GPIO3,
  128. .virtual_irq_start = MXC_GPIO_INT_BASE + GPIO_NUM_PIN * 2
  129. }
  130. };
  131. int __init mxc_register_gpios(void)
  132. {
  133. return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));
  134. }