gpio15xx.c 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  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 __initdata omap_gpio_platform_data omap15xx_mpu_gpio_config = {
  34. .virtual_irq_start = IH_MPUIO_BASE,
  35. .bank_type = METHOD_MPUIO,
  36. .bank_width = 16,
  37. .bank_stride = 1,
  38. };
  39. static struct __initdata platform_device omap15xx_mpu_gpio = {
  40. .name = "omap_gpio",
  41. .id = 0,
  42. .dev = {
  43. .platform_data = &omap15xx_mpu_gpio_config,
  44. },
  45. .num_resources = ARRAY_SIZE(omap15xx_mpu_gpio_resources),
  46. .resource = omap15xx_mpu_gpio_resources,
  47. };
  48. /* gpio2 */
  49. static struct __initdata resource omap15xx_gpio_resources[] = {
  50. {
  51. .start = OMAP1510_GPIO_BASE,
  52. .end = OMAP1510_GPIO_BASE + SZ_2K - 1,
  53. .flags = IORESOURCE_MEM,
  54. },
  55. {
  56. .start = INT_GPIO_BANK1,
  57. .flags = IORESOURCE_IRQ,
  58. },
  59. };
  60. static struct __initdata omap_gpio_platform_data omap15xx_gpio_config = {
  61. .virtual_irq_start = IH_GPIO_BASE,
  62. .bank_type = METHOD_GPIO_1510,
  63. .bank_width = 16,
  64. };
  65. static struct __initdata platform_device omap15xx_gpio = {
  66. .name = "omap_gpio",
  67. .id = 1,
  68. .dev = {
  69. .platform_data = &omap15xx_gpio_config,
  70. },
  71. .num_resources = ARRAY_SIZE(omap15xx_gpio_resources),
  72. .resource = omap15xx_gpio_resources,
  73. };
  74. /*
  75. * omap15xx_gpio_init needs to be done before
  76. * machine_init functions access gpio APIs.
  77. * Hence omap15xx_gpio_init is a postcore_initcall.
  78. */
  79. static int __init omap15xx_gpio_init(void)
  80. {
  81. if (!cpu_is_omap15xx())
  82. return -EINVAL;
  83. platform_device_register(&omap15xx_mpu_gpio);
  84. platform_device_register(&omap15xx_gpio);
  85. gpio_bank_count = 2;
  86. return 0;
  87. }
  88. postcore_initcall(omap15xx_gpio_init);