gpio15xx.c 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /*
  2. * OMAP15xx specific gpio init
  3. *
  4. * Copyright (C) 2010 Texas Instruments Incorporated - http://www.ti.com/
  5. *
  6. * Author:
  7. * Charulatha V <charu@ti.com>
  8. *
  9. * This program is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU General Public License as
  11. * published by the Free Software Foundation version 2.
  12. *
  13. * This program is distributed "as is" WITHOUT ANY WARRANTY of any
  14. * kind, whether express or implied; without even the implied warranty
  15. * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. */
  18. #include <linux/gpio.h>
  19. #define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE
  20. #define OMAP1510_GPIO_BASE 0xFFFCE000
  21. /* gpio1 */
  22. static struct __initdata resource omap15xx_mpu_gpio_resources[] = {
  23. {
  24. .start = OMAP1_MPUIO_VBASE,
  25. .end = OMAP1_MPUIO_VBASE + SZ_2K - 1,
  26. .flags = IORESOURCE_MEM,
  27. },
  28. {
  29. .start = INT_MPUIO,
  30. .flags = IORESOURCE_IRQ,
  31. },
  32. };
  33. static struct omap_gpio_reg_offs omap15xx_mpuio_regs = {
  34. .revision = USHRT_MAX,
  35. .direction = OMAP_MPUIO_IO_CNTL,
  36. .datain = OMAP_MPUIO_INPUT_LATCH,
  37. .dataout = OMAP_MPUIO_OUTPUT,
  38. .irqstatus = OMAP_MPUIO_GPIO_INT,
  39. .irqenable = OMAP_MPUIO_GPIO_MASKIT,
  40. .irqenable_inv = true,
  41. .irqctrl = OMAP_MPUIO_GPIO_INT_EDGE,
  42. };
  43. static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = {
  44. .virtual_irq_start = IH_MPUIO_BASE,
  45. .is_mpuio = true,
  46. .bank_width = 16,
  47. .bank_stride = 1,
  48. .regs = &omap15xx_mpuio_regs,
  49. };
  50. static struct platform_device omap15xx_mpu_gpio = {
  51. .name = "omap_gpio",
  52. .id = 0,
  53. .dev = {
  54. .platform_data = &omap15xx_mpu_gpio_config,
  55. },
  56. .num_resources = ARRAY_SIZE(omap15xx_mpu_gpio_resources),
  57. .resource = omap15xx_mpu_gpio_resources,
  58. };
  59. /* gpio2 */
  60. static struct __initdata resource omap15xx_gpio_resources[] = {
  61. {
  62. .start = OMAP1510_GPIO_BASE,
  63. .end = OMAP1510_GPIO_BASE + SZ_2K - 1,
  64. .flags = IORESOURCE_MEM,
  65. },
  66. {
  67. .start = INT_GPIO_BANK1,
  68. .flags = IORESOURCE_IRQ,
  69. },
  70. };
  71. static struct omap_gpio_reg_offs omap15xx_gpio_regs = {
  72. .revision = USHRT_MAX,
  73. .direction = OMAP1510_GPIO_DIR_CONTROL,
  74. .datain = OMAP1510_GPIO_DATA_INPUT,
  75. .dataout = OMAP1510_GPIO_DATA_OUTPUT,
  76. .irqstatus = OMAP1510_GPIO_INT_STATUS,
  77. .irqenable = OMAP1510_GPIO_INT_MASK,
  78. .irqenable_inv = true,
  79. .irqctrl = OMAP1510_GPIO_INT_CONTROL,
  80. .pinctrl = OMAP1510_GPIO_PIN_CONTROL,
  81. };
  82. static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = {
  83. .virtual_irq_start = IH_GPIO_BASE,
  84. .bank_width = 16,
  85. .regs = &omap15xx_gpio_regs,
  86. };
  87. static struct platform_device omap15xx_gpio = {
  88. .name = "omap_gpio",
  89. .id = 1,
  90. .dev = {
  91. .platform_data = &omap15xx_gpio_config,
  92. },
  93. .num_resources = ARRAY_SIZE(omap15xx_gpio_resources),
  94. .resource = omap15xx_gpio_resources,
  95. };
  96. /*
  97. * omap15xx_gpio_init needs to be done before
  98. * machine_init functions access gpio APIs.
  99. * Hence omap15xx_gpio_init is a postcore_initcall.
  100. */
  101. static int __init omap15xx_gpio_init(void)
  102. {
  103. if (!cpu_is_omap15xx())
  104. return -EINVAL;
  105. platform_device_register(&omap15xx_mpu_gpio);
  106. platform_device_register(&omap15xx_gpio);
  107. return 0;
  108. }
  109. postcore_initcall(omap15xx_gpio_init);