1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Intel Tangier GPIO functions
5 * Copyright (c) 2016, 2021, 2023 Intel Corporation.
7 * Authors: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
8 * Pandith N <pandith.n@intel.com>
9 * Raag Jadav <raag.jadav@intel.com>
12 #ifndef _GPIO_TANGIER_H_
13 #define _GPIO_TANGIER_H_
15 #include <linux/gpio/driver.h>
16 #include <linux/spinlock_types.h>
17 #include <linux/types.h>
21 struct tng_gpio_context;
23 /* Elkhart Lake specific wake registers */
24 #define GWMR_EHL 0x100 /* Wake mask */
25 #define GWSR_EHL 0x118 /* Wake source */
26 #define GSIR_EHL 0x130 /* Secure input */
28 /* Merrifield specific wake registers */
29 #define GWMR_MRFLD 0x400 /* Wake mask */
30 #define GWSR_MRFLD 0x418 /* Wake source */
31 #define GSIR_MRFLD 0xc00 /* Secure input */
34 * struct tng_wake_regs - Platform specific wake registers
39 struct tng_wake_regs {
46 * struct tng_gpio_pinrange - Map pin numbers to gpio numbers
47 * @gpio_base: Starting GPIO number of this range
48 * @pin_base: Starting pin number of this range
49 * @npins: Number of pins in this range
51 struct tng_gpio_pinrange {
52 unsigned int gpio_base;
53 unsigned int pin_base;
57 #define GPIO_PINRANGE(gstart, gend, pstart) \
58 (struct tng_gpio_pinrange) { \
59 .gpio_base = (gstart), \
60 .pin_base = (pstart), \
61 .npins = (gend) - (gstart) + 1, \
65 * struct tng_gpio_pin_info - Platform specific pinout information
66 * @pin_ranges: Pin to GPIO mapping
67 * @nranges: Number of pin ranges
68 * @name: Respective pinctrl device name
70 struct tng_gpio_pin_info {
71 const struct tng_gpio_pinrange *pin_ranges;
77 * struct tng_gpio_info - Platform specific GPIO and IRQ information
78 * @base: GPIO base to start numbering with
79 * @ngpio: Amount of GPIOs supported by the controller
80 * @first: First IRQ to start numbering with
82 struct tng_gpio_info {
89 * struct tng_gpio - Platform specific private data
90 * @chip: Instance of the struct gpio_chip
91 * @reg_base: Base address of MMIO registers
92 * @irq: Interrupt for the GPIO device
93 * @lock: Synchronization lock to prevent I/O race conditions
94 * @dev: The GPIO device
95 * @ctx: Context to be saved during suspend-resume
96 * @wake_regs: Platform specific wake registers
97 * @pin_info: Platform specific pinout information
98 * @info: Platform specific GPIO and IRQ information
101 struct gpio_chip chip;
102 void __iomem *reg_base;
106 struct tng_gpio_context *ctx;
107 struct tng_wake_regs wake_regs;
108 struct tng_gpio_pin_info pin_info;
109 struct tng_gpio_info info;
112 int devm_tng_gpio_probe(struct device *dev, struct tng_gpio *gpio);
114 int tng_gpio_suspend(struct device *dev);
115 int tng_gpio_resume(struct device *dev);
117 #endif /* _GPIO_TANGIER_H_ */