gpio15xx.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. // SPDX-License-Identifier: GPL-2.0-only
  2. /*
  3. * OMAP15xx specific gpio init
  4. *
  5. * Copyright (C) 2010 Texas Instruments Incorporated - https://www.ti.com/
  6. *
  7. * Author:
  8. * Charulatha V <[email protected]>
  9. */
  10. #include <linux/gpio.h>
  11. #include <linux/platform_data/gpio-omap.h>
  12. #include <linux/soc/ti/omap1-soc.h>
  13. #include <asm/irq.h>
  14. #include "irqs.h"
  15. #define OMAP1_MPUIO_VBASE OMAP1_MPUIO_BASE
  16. #define OMAP1510_GPIO_BASE 0xFFFCE000
  17. /* gpio1 */
  18. static struct resource omap15xx_mpu_gpio_resources[] = {
  19. {
  20. .start = OMAP1_MPUIO_VBASE,
  21. .end = OMAP1_MPUIO_VBASE + SZ_2K - 1,
  22. .flags = IORESOURCE_MEM,
  23. },
  24. {
  25. .start = INT_MPUIO,
  26. .flags = IORESOURCE_IRQ,
  27. },
  28. };
  29. static struct omap_gpio_reg_offs omap15xx_mpuio_regs = {
  30. .revision = USHRT_MAX,
  31. .direction = OMAP_MPUIO_IO_CNTL,
  32. .datain = OMAP_MPUIO_INPUT_LATCH,
  33. .dataout = OMAP_MPUIO_OUTPUT,
  34. .irqstatus = OMAP_MPUIO_GPIO_INT,
  35. .irqenable = OMAP_MPUIO_GPIO_MASKIT,
  36. .irqenable_inv = true,
  37. .irqctrl = OMAP_MPUIO_GPIO_INT_EDGE,
  38. };
  39. static struct omap_gpio_platform_data omap15xx_mpu_gpio_config = {
  40. .is_mpuio = true,
  41. .bank_width = 16,
  42. .bank_stride = 1,
  43. .regs = &omap15xx_mpuio_regs,
  44. };
  45. static struct platform_device omap15xx_mpu_gpio = {
  46. .name = "omap_gpio",
  47. .id = 0,
  48. .dev = {
  49. .platform_data = &omap15xx_mpu_gpio_config,
  50. },
  51. .num_resources = ARRAY_SIZE(omap15xx_mpu_gpio_resources),
  52. .resource = omap15xx_mpu_gpio_resources,
  53. };
  54. /* gpio2 */
  55. static struct resource omap15xx_gpio_resources[] = {
  56. {
  57. .start = OMAP1510_GPIO_BASE,
  58. .end = OMAP1510_GPIO_BASE + SZ_2K - 1,
  59. .flags = IORESOURCE_MEM,
  60. },
  61. {
  62. .start = INT_GPIO_BANK1,
  63. .flags = IORESOURCE_IRQ,
  64. },
  65. };
  66. static struct omap_gpio_reg_offs omap15xx_gpio_regs = {
  67. .revision = USHRT_MAX,
  68. .direction = OMAP1510_GPIO_DIR_CONTROL,
  69. .datain = OMAP1510_GPIO_DATA_INPUT,
  70. .dataout = OMAP1510_GPIO_DATA_OUTPUT,
  71. .irqstatus = OMAP1510_GPIO_INT_STATUS,
  72. .irqenable = OMAP1510_GPIO_INT_MASK,
  73. .irqenable_inv = true,
  74. .irqctrl = OMAP1510_GPIO_INT_CONTROL,
  75. .pinctrl = OMAP1510_GPIO_PIN_CONTROL,
  76. };
  77. static struct omap_gpio_platform_data omap15xx_gpio_config = {
  78. .bank_width = 16,
  79. .regs = &omap15xx_gpio_regs,
  80. };
  81. static struct platform_device omap15xx_gpio = {
  82. .name = "omap_gpio",
  83. .id = 1,
  84. .dev = {
  85. .platform_data = &omap15xx_gpio_config,
  86. },
  87. .num_resources = ARRAY_SIZE(omap15xx_gpio_resources),
  88. .resource = omap15xx_gpio_resources,
  89. };
  90. /*
  91. * omap15xx_gpio_init needs to be done before
  92. * machine_init functions access gpio APIs.
  93. * Hence omap15xx_gpio_init is a postcore_initcall.
  94. */
  95. static int __init omap15xx_gpio_init(void)
  96. {
  97. if (!cpu_is_omap15xx())
  98. return -EINVAL;
  99. platform_device_register(&omap15xx_mpu_gpio);
  100. platform_device_register(&omap15xx_gpio);
  101. return 0;
  102. }
  103. postcore_initcall(omap15xx_gpio_init);