gpio15xx.c 2.7 KB

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