gpio-tangier.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Intel Tangier GPIO functions
  4. *
  5. * Copyright (c) 2016, 2021, 2023 Intel Corporation.
  6. *
  7. * Authors: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
  8. * Pandith N <pandith.n@intel.com>
  9. * Raag Jadav <raag.jadav@intel.com>
  10. */
  11. #ifndef _GPIO_TANGIER_H_
  12. #define _GPIO_TANGIER_H_
  13. #include <linux/gpio/driver.h>
  14. #include <linux/pm.h>
  15. #include <linux/spinlock_types.h>
  16. #include <linux/types.h>
  17. struct device;
  18. struct tng_gpio_context;
  19. /* Elkhart Lake specific wake registers */
  20. #define GWMR_EHL 0x100 /* Wake mask */
  21. #define GWSR_EHL 0x118 /* Wake source */
  22. #define GSIR_EHL 0x130 /* Secure input */
  23. /* Merrifield specific wake registers */
  24. #define GWMR_MRFLD 0x400 /* Wake mask */
  25. #define GWSR_MRFLD 0x418 /* Wake source */
  26. #define GSIR_MRFLD 0xc00 /* Secure input */
  27. /**
  28. * struct tng_wake_regs - Platform specific wake registers
  29. * @gwmr: Wake mask
  30. * @gwsr: Wake source
  31. * @gsir: Secure input
  32. */
  33. struct tng_wake_regs {
  34. u32 gwmr;
  35. u32 gwsr;
  36. u32 gsir;
  37. };
  38. /**
  39. * struct tng_gpio_pinrange - Map pin numbers to gpio numbers
  40. * @gpio_base: Starting GPIO number of this range
  41. * @pin_base: Starting pin number of this range
  42. * @npins: Number of pins in this range
  43. */
  44. struct tng_gpio_pinrange {
  45. unsigned int gpio_base;
  46. unsigned int pin_base;
  47. unsigned int npins;
  48. };
  49. #define GPIO_PINRANGE(gstart, gend, pstart) \
  50. (struct tng_gpio_pinrange) { \
  51. .gpio_base = (gstart), \
  52. .pin_base = (pstart), \
  53. .npins = (gend) - (gstart) + 1, \
  54. }
  55. /**
  56. * struct tng_gpio_pin_info - Platform specific pinout information
  57. * @pin_ranges: Pin to GPIO mapping
  58. * @nranges: Number of pin ranges
  59. * @name: Respective pinctrl device name
  60. */
  61. struct tng_gpio_pin_info {
  62. const struct tng_gpio_pinrange *pin_ranges;
  63. unsigned int nranges;
  64. const char *name;
  65. };
  66. /**
  67. * struct tng_gpio_info - Platform specific GPIO and IRQ information
  68. * @base: GPIO base to start numbering with
  69. * @ngpio: Amount of GPIOs supported by the controller
  70. * @first: First IRQ to start numbering with
  71. */
  72. struct tng_gpio_info {
  73. int base;
  74. u16 ngpio;
  75. unsigned int first;
  76. };
  77. /**
  78. * struct tng_gpio - Platform specific private data
  79. * @chip: Instance of the struct gpio_chip
  80. * @reg_base: Base address of MMIO registers
  81. * @irq: Interrupt for the GPIO device
  82. * @lock: Synchronization lock to prevent I/O race conditions
  83. * @dev: The GPIO device
  84. * @ctx: Context to be saved during suspend-resume
  85. * @wake_regs: Platform specific wake registers
  86. * @pin_info: Platform specific pinout information
  87. * @info: Platform specific GPIO and IRQ information
  88. */
  89. struct tng_gpio {
  90. struct gpio_chip chip;
  91. void __iomem *reg_base;
  92. int irq;
  93. raw_spinlock_t lock;
  94. struct device *dev;
  95. struct tng_gpio_context *ctx;
  96. struct tng_wake_regs wake_regs;
  97. struct tng_gpio_pin_info pin_info;
  98. struct tng_gpio_info info;
  99. };
  100. int devm_tng_gpio_probe(struct device *dev, struct tng_gpio *gpio);
  101. extern const struct dev_pm_ops tng_gpio_pm_ops;
  102. #endif /* _GPIO_TANGIER_H_ */