gpio15xx.c 2.5 KB

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