devices.c 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. /*
  2. * Author: MontaVista Software, Inc.
  3. * <source@mvista.com>
  4. *
  5. * Based on the OMAP devices.c
  6. *
  7. * 2005 (c) MontaVista Software, Inc. This file is licensed under the
  8. * terms of the GNU General Public License version 2. This program is
  9. * licensed "as is" without any warranty of any kind, whether express
  10. * or implied.
  11. *
  12. * Copyright 2006-2007 Freescale Semiconductor, Inc. All Rights Reserved.
  13. * Copyright 2008 Juergen Beisert, kernel@pengutronix.de
  14. * Copyright 2008 Sascha Hauer, kernel@pengutronix.de
  15. * Copyright (c) 2008 Paulius Zaleckas <paulius.zaleckas@teltonika.lt>
  16. * Copyright (c) 2008 Darius Augulis <darius.augulis@teltonika.lt>
  17. *
  18. * This program is free software; you can redistribute it and/or
  19. * modify it under the terms of the GNU General Public License
  20. * as published by the Free Software Foundation; either version 2
  21. * of the License, or (at your option) any later version.
  22. * This program is distributed in the hope that it will be useful,
  23. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  24. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  25. * GNU General Public License for more details.
  26. *
  27. * You should have received a copy of the GNU General Public License
  28. * along with this program; if not, write to the Free Software
  29. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
  30. * MA 02110-1301, USA.
  31. */
  32. #include <linux/module.h>
  33. #include <linux/kernel.h>
  34. #include <linux/init.h>
  35. #include <linux/platform_device.h>
  36. #include <linux/gpio.h>
  37. #include <linux/dma-mapping.h>
  38. #include <linux/serial.h>
  39. #include <mach/irqs.h>
  40. #include <mach/hardware.h>
  41. #include <mach/common.h>
  42. #include <mach/mmc.h>
  43. #if defined(CONFIG_ARCH_MX1)
  44. /* GPIO port description */
  45. static struct mxc_gpio_port imx_gpio_ports[] = {
  46. {
  47. .chip.label = "gpio-0",
  48. .base = MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR),
  49. .irq = MX1_GPIO_INT_PORTA,
  50. .virtual_irq_start = MXC_GPIO_IRQ_START,
  51. }, {
  52. .chip.label = "gpio-1",
  53. .base = MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR + 0x100),
  54. .irq = MX1_GPIO_INT_PORTB,
  55. .virtual_irq_start = MXC_GPIO_IRQ_START + 32,
  56. }, {
  57. .chip.label = "gpio-2",
  58. .base = MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR + 0x200),
  59. .irq = MX1_GPIO_INT_PORTC,
  60. .virtual_irq_start = MXC_GPIO_IRQ_START + 64,
  61. }, {
  62. .chip.label = "gpio-3",
  63. .base = MX1_IO_ADDRESS(MX1_GPIO_BASE_ADDR + 0x300),
  64. .irq = MX1_GPIO_INT_PORTD,
  65. .virtual_irq_start = MXC_GPIO_IRQ_START + 96,
  66. }
  67. };
  68. int __init imx1_register_gpios(void)
  69. {
  70. return mxc_gpio_init(imx_gpio_ports, ARRAY_SIZE(imx_gpio_ports));
  71. }
  72. #endif
  73. #if defined(CONFIG_MACH_MX21) || defined(CONFIG_MACH_MX27)
  74. /* GPIO port description */
  75. #define DEFINE_MXC_GPIO_PORT_IRQ(SOC, n, _irq) \
  76. { \
  77. .chip.label = "gpio-" #n, \
  78. .irq = _irq, \
  79. .base = SOC ## _IO_ADDRESS(MX2x_GPIO_BASE_ADDR + \
  80. n * 0x100), \
  81. .virtual_irq_start = MXC_GPIO_IRQ_START + n * 32, \
  82. }
  83. #define DEFINE_MXC_GPIO_PORT(SOC, n) \
  84. { \
  85. .chip.label = "gpio-" #n, \
  86. .base = SOC ## _IO_ADDRESS(MX2x_GPIO_BASE_ADDR + \
  87. n * 0x100), \
  88. .virtual_irq_start = MXC_GPIO_IRQ_START + n * 32, \
  89. }
  90. #define DEFINE_MXC_GPIO_PORTS(SOC, pfx) \
  91. static struct mxc_gpio_port pfx ## _gpio_ports[] = { \
  92. DEFINE_MXC_GPIO_PORT_IRQ(SOC, 0, SOC ## _INT_GPIO), \
  93. DEFINE_MXC_GPIO_PORT(SOC, 1), \
  94. DEFINE_MXC_GPIO_PORT(SOC, 2), \
  95. DEFINE_MXC_GPIO_PORT(SOC, 3), \
  96. DEFINE_MXC_GPIO_PORT(SOC, 4), \
  97. DEFINE_MXC_GPIO_PORT(SOC, 5), \
  98. }
  99. #ifdef CONFIG_MACH_MX21
  100. DEFINE_MXC_GPIO_PORTS(MX21, imx21);
  101. int __init imx21_register_gpios(void)
  102. {
  103. return mxc_gpio_init(imx21_gpio_ports, ARRAY_SIZE(imx21_gpio_ports));
  104. }
  105. #endif
  106. #ifdef CONFIG_MACH_MX27
  107. DEFINE_MXC_GPIO_PORTS(MX27, imx27);
  108. int __init imx27_register_gpios(void)
  109. {
  110. return mxc_gpio_init(imx27_gpio_ports, ARRAY_SIZE(imx27_gpio_ports));
  111. }
  112. #endif
  113. #endif