gpio15xx.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. #include <linux/platform_data/gpio-omap.h>
  20. #include <mach/irqs.h>
  21. #define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE
  22. #define OMAP1510_GPIO_BASE 0xFFFCE000
  23. /* gpio1 */
  24. static struct resource omap15xx_mpu_gpio_resources[] = {
  25. {
  26. .start = OMAP1_MPUIO_VBASE,
  27. .end = OMAP1_MPUIO_VBASE + SZ_2K - 1,
  28. .flags = IORESOURCE_MEM,
  29. },
  30. {
  31. .start = INT_MPUIO,
  32. .flags = IORESOURCE_IRQ,
  33. },
  34. };
  35. static struct omap_gpio_reg_offs omap15xx_mpuio_regs = {
  36. .revision = USHRT_MAX,
  37. .direction = OMAP_MPUIO_IO_CNTL,
  38. .datain = OMAP_MPUIO_INPUT_LATCH,
  39. .dataout = OMAP_MPUIO_OUTPUT,
  40. .irqstatus = OMAP_MPUIO_GPIO_INT,
  41. .irqenable = OMAP_MPUIO_GPIO_MASKIT,
  42. .irqenable_inv = true,
  43. .irqctrl = OMAP_MPUIO_GPIO_INT_EDGE,
  44. };
  45. static struct omap_gpio_platform_data omap15xx_mpu_gpio_config = {
  46. .is_mpuio = true,
  47. .bank_width = 16,
  48. .bank_stride = 1,
  49. .regs = &omap15xx_mpuio_regs,
  50. };
  51. static struct platform_device omap15xx_mpu_gpio = {
  52. .name = "omap_gpio",
  53. .id = 0,
  54. .dev = {
  55. .platform_data = &omap15xx_mpu_gpio_config,
  56. },
  57. .num_resources = ARRAY_SIZE(omap15xx_mpu_gpio_resources),
  58. .resource = omap15xx_mpu_gpio_resources,
  59. };
  60. /* gpio2 */
  61. static struct resource omap15xx_gpio_resources[] = {
  62. {
  63. .start = OMAP1510_GPIO_BASE,
  64. .end = OMAP1510_GPIO_BASE + SZ_2K - 1,
  65. .flags = IORESOURCE_MEM,
  66. },
  67. {
  68. .start = INT_GPIO_BANK1,
  69. .flags = IORESOURCE_IRQ,
  70. },
  71. };
  72. static struct omap_gpio_reg_offs omap15xx_gpio_regs = {
  73. .revision = USHRT_MAX,
  74. .direction = OMAP1510_GPIO_DIR_CONTROL,
  75. .datain = OMAP1510_GPIO_DATA_INPUT,
  76. .dataout = OMAP1510_GPIO_DATA_OUTPUT,
  77. .irqstatus = OMAP1510_GPIO_INT_STATUS,
  78. .irqenable = OMAP1510_GPIO_INT_MASK,
  79. .irqenable_inv = true,
  80. .irqctrl = OMAP1510_GPIO_INT_CONTROL,
  81. .pinctrl = OMAP1510_GPIO_PIN_CONTROL,
  82. };
  83. static struct omap_gpio_platform_data omap15xx_gpio_config = {
  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);