gpio15xx.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. };
  42. static struct __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = {
  43. .virtual_irq_start = IH_MPUIO_BASE,
  44. .bank_type = METHOD_MPUIO,
  45. .bank_width = 16,
  46. .bank_stride = 1,
  47. .regs = &omap15xx_mpuio_regs,
  48. };
  49. static struct platform_device omap15xx_mpu_gpio = {
  50. .name = "omap_gpio",
  51. .id = 0,
  52. .dev = {
  53. .platform_data = &omap15xx_mpu_gpio_config,
  54. },
  55. .num_resources = ARRAY_SIZE(omap15xx_mpu_gpio_resources),
  56. .resource = omap15xx_mpu_gpio_resources,
  57. };
  58. /* gpio2 */
  59. static struct __initdata resource omap15xx_gpio_resources[] = {
  60. {
  61. .start = OMAP1510_GPIO_BASE,
  62. .end = OMAP1510_GPIO_BASE + SZ_2K - 1,
  63. .flags = IORESOURCE_MEM,
  64. },
  65. {
  66. .start = INT_GPIO_BANK1,
  67. .flags = IORESOURCE_IRQ,
  68. },
  69. };
  70. static struct omap_gpio_reg_offs omap15xx_gpio_regs = {
  71. .revision = USHRT_MAX,
  72. .direction = OMAP1510_GPIO_DIR_CONTROL,
  73. .datain = OMAP1510_GPIO_DATA_INPUT,
  74. .dataout = OMAP1510_GPIO_DATA_OUTPUT,
  75. .irqstatus = OMAP1510_GPIO_INT_STATUS,
  76. .irqenable = OMAP1510_GPIO_INT_MASK,
  77. .irqenable_inv = true,
  78. };
  79. static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = {
  80. .virtual_irq_start = IH_GPIO_BASE,
  81. .bank_type = METHOD_GPIO_1510,
  82. .bank_width = 16,
  83. .regs = &omap15xx_gpio_regs,
  84. };
  85. static struct platform_device omap15xx_gpio = {
  86. .name = "omap_gpio",
  87. .id = 1,
  88. .dev = {
  89. .platform_data = &omap15xx_gpio_config,
  90. },
  91. .num_resources = ARRAY_SIZE(omap15xx_gpio_resources),
  92. .resource = omap15xx_gpio_resources,
  93. };
  94. /*
  95. * omap15xx_gpio_init needs to be done before
  96. * machine_init functions access gpio APIs.
  97. * Hence omap15xx_gpio_init is a postcore_initcall.
  98. */
  99. static int __init omap15xx_gpio_init(void)
  100. {
  101. if (!cpu_is_omap15xx())
  102. return -EINVAL;
  103. platform_device_register(&omap15xx_mpu_gpio);
  104. platform_device_register(&omap15xx_gpio);
  105. gpio_bank_count = 2;
  106. return 0;
  107. }
  108. postcore_initcall(omap15xx_gpio_init);