summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2026-06-16 07:30:52 +0530
committerLinus Torvalds <torvalds@linux-foundation.org>2026-06-16 07:30:52 +0530
commit77d084d66b7694e2a912abdd8b9e5a0e7a32d28e (patch)
tree1b21610ec0bfccc6fd4254c66b8ee0641c2c4333 /include/linux
parent6b617c82580599994c8dd078ab0dcb0375b42eda (diff)
parentf953585dafd71ecb0897f9def9c0a3702afc1bf8 (diff)
downloadlinux-77d084d66b7694e2a912abdd8b9e5a0e7a32d28e.tar.gz
linux-77d084d66b7694e2a912abdd8b9e5a0e7a32d28e.zip
Merge tag 'gpio-updates-for-v7.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux
Pull gpio updates from Bartosz Golaszewski: "There's one new driver, one legacy driver removed, a kunit test-suite for the GPIO core, support for new models in existing drivers and a slew of various changes in many places though I can't think of anything controversial that would stand out - it's been a relatively calm cycle. GPIO core: - Add an initial set of kunit test cases for the GPIO subsystem - Use the devres owner as the GPIO chip's parent in absence of any other parent - Fix const-correctness of GPIO chip SRCU guards - Provide new GPIO consumer interfaces: gpiod_is_single_ended() and fwnode_gpiod_get() - Quarantine all legacy GPIO APIs in linux/gpio/legacy.h - Use __ro_after_init where applicable New drivers: - Add driver for the GPIO controller on Waveshare DSI TOUCH panels Removed drivers: - Remove the obsolete ts5500 GPIO driver Driver updates: - Modernize gpio-timberdale: remove platform data support and use generic device property accessors - Extend test build coverage by enabling COMPILE_TEST for more GPIO drivers - Add some missing dependencies in Kconfig - Add support for sparse fixed direction to gpio-regmap - Remove dead code from gpio-nomadik - use BIT() in gpio-mxc - use bitmap_complement() in gpio-xilinx and gpio-pca953x - Use more appropriate printing functions where applicable - Use named initializers for platform_device_id and i2c_device_id arrays - Convert gpio-altera to using the generic GPIO chip helper library - Add support for new models to gpio-dwapb, gpio-zynq, gpio-usbio and gpio-tegra186 - Unify the naming convention for Qualcomm in GPIO drivers - Fix interrupt bank mapping to GPIO chips in gpio-mt7621 - Add support for the lines-initial-states property to gpio-74x164 - Switch to using dynamic GPIO base in gpio-ixp4xx - Move the handling of an OF quirk from ASoC to gpiolib-of.c where other such quirks live - Use handle_bad_irq() in gpio-ep93xx - Some other minor tweaks and refactorings Devicetree bindings: - Document the Waveshare GPIO controller for DSI TOUCH panels - Document new models: Tegra238 in gpio-tegra186 and EIO GPIO in gpio-zynq - Add new properties for gpio-dwapb and fairchild,74hc595 - Fix whitespace issues - Sort compatibles alphabetically in gpio-zynq Documentation: - Fix kerneldoc warnings in gpio-realtek-otto Misc: - Attach software nodes representing GPIO chips to the actual struct device objects associated with them in some legacy platforms enabling real firmware node lookup instead of string matching - Drop unneeded dependencies on OF_GPIO from bus and staging drivers" * tag 'gpio-updates-for-v7.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/brgl/linux: (62 commits) gpio: nomadik: remove dead DB8540 code from <gpio/gpio-nomadik.h> gpio: mt7621: fix interrupt banks mapping on gpio chips bus: ts-nbus: drop unneeded dependency on OF_GPIO staging: media: max96712: drop unneeded dependency on OF_GPIO gpiolib: Replace strcpy() with memcpy() gpio: remove obsolete UAF FIXMEs from lookup paths gpio: core: fix const-correctness of gpio_chip_guard gpio: mxc: use BIT() macro gpio: realtek-otto: fix kernel-doc warnings gpio: max77620: Unify usage of space and comma in platform_device_id array gpio: Use named initializers for platform_device_id arrays gpio: cros-ec: Drop unused assignment of platform_device_id driver data ARM: omap1: enable real software node lookup of GPIOs on Nokia 770 ARM: omap1: use platform_device_register_full() for GPIO devices on OMAP 16xx ARM: omap1: drop unused variable from omap16xx_gpio_init() gpio: gpiolib: use seq_puts() for plain strings gpio: ts5500: remove obsolete driver gpio: add kunit test cases for the GPIO subsystem kunit: provide kunit_platform_device_unregister() kunit: provide kunit_platform_device_register_full() ...
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/gpio.h162
-rw-r--r--include/linux/gpio/consumer.h14
-rw-r--r--include/linux/gpio/gpio-nomadik.h16
-rw-r--r--include/linux/gpio/legacy.h173
-rw-r--r--include/linux/gpio/regmap.h7
-rw-r--r--include/linux/timb_gpio.h25
6 files changed, 198 insertions, 199 deletions
diff --git a/include/linux/gpio.h b/include/linux/gpio.h
index 8f85ddb26429..b0d4942a65de 100644
--- a/include/linux/gpio.h
+++ b/include/linux/gpio.h
@@ -2,13 +2,11 @@
/*
* NOTE: This header *must not* be included.
*
- * This is the LEGACY GPIO bulk include file, including legacy APIs. It is
- * used for GPIO drivers still referencing the global GPIO numberspace,
- * and should not be included in new code.
- *
* If you're implementing a GPIO driver, only include <linux/gpio/driver.h>
* If you're implementing a GPIO consumer, only include <linux/gpio/consumer.h>
+ * If you're using the legacy interfaces, include <linux/gpio/legacy.h>
*/
+
#ifndef __LINUX_GPIO_H
#define __LINUX_GPIO_H
@@ -18,159 +16,7 @@
#endif
#ifdef CONFIG_GPIOLIB_LEGACY
-
-struct device;
-
-/* make these flag values available regardless of GPIO kconfig options */
-#define GPIOF_IN ((1 << 0))
-#define GPIOF_OUT_INIT_LOW ((0 << 0) | (0 << 1))
-#define GPIOF_OUT_INIT_HIGH ((0 << 0) | (1 << 1))
-
-#ifdef CONFIG_GPIOLIB
-/*
- * "valid" GPIO numbers are nonnegative and may be passed to
- * setup routines like gpio_request(). Only some valid numbers
- * can successfully be requested and used.
- *
- * Invalid GPIO numbers are useful for indicating no-such-GPIO in
- * platform data and other tables.
- */
-static inline bool gpio_is_valid(int number)
-{
- /* only non-negative numbers are valid */
- return number >= 0;
-}
-
-/*
- * Platforms may implement their GPIO interface with library code,
- * at a small performance cost for non-inlined operations and some
- * extra memory (for code and for per-GPIO table entries).
- */
-
-/* Always use the library code for GPIO management calls,
- * or when sleeping may be involved.
- */
-int gpio_request(unsigned gpio, const char *label);
-void gpio_free(unsigned gpio);
-
-static inline int gpio_direction_input(unsigned gpio)
-{
- return gpiod_direction_input(gpio_to_desc(gpio));
-}
-static inline int gpio_direction_output(unsigned gpio, int value)
-{
- return gpiod_direction_output_raw(gpio_to_desc(gpio), value);
-}
-
-static inline int gpio_get_value_cansleep(unsigned gpio)
-{
- return gpiod_get_raw_value_cansleep(gpio_to_desc(gpio));
-}
-static inline void gpio_set_value_cansleep(unsigned gpio, int value)
-{
- gpiod_set_raw_value_cansleep(gpio_to_desc(gpio), value);
-}
-
-static inline int gpio_get_value(unsigned gpio)
-{
- return gpiod_get_raw_value(gpio_to_desc(gpio));
-}
-static inline void gpio_set_value(unsigned gpio, int value)
-{
- gpiod_set_raw_value(gpio_to_desc(gpio), value);
-}
-
-static inline int gpio_to_irq(unsigned gpio)
-{
- return gpiod_to_irq(gpio_to_desc(gpio));
-}
-
-int gpio_request_one(unsigned gpio, unsigned long flags, const char *label);
-
-int devm_gpio_request_one(struct device *dev, unsigned gpio,
- unsigned long flags, const char *label);
-
-#else /* ! CONFIG_GPIOLIB */
-
-#include <linux/kernel.h>
-
-#include <asm/bug.h>
-#include <asm/errno.h>
-
-static inline bool gpio_is_valid(int number)
-{
- return false;
-}
-
-static inline int gpio_request(unsigned gpio, const char *label)
-{
- return -ENOSYS;
-}
-
-static inline int gpio_request_one(unsigned gpio,
- unsigned long flags, const char *label)
-{
- return -ENOSYS;
-}
-
-static inline void gpio_free(unsigned gpio)
-{
- might_sleep();
-
- /* GPIO can never have been requested */
- WARN_ON(1);
-}
-
-static inline int gpio_direction_input(unsigned gpio)
-{
- return -ENOSYS;
-}
-
-static inline int gpio_direction_output(unsigned gpio, int value)
-{
- return -ENOSYS;
-}
-
-static inline int gpio_get_value(unsigned gpio)
-{
- /* GPIO can never have been requested or set as {in,out}put */
- WARN_ON(1);
- return 0;
-}
-
-static inline void gpio_set_value(unsigned gpio, int value)
-{
- /* GPIO can never have been requested or set as output */
- WARN_ON(1);
-}
-
-static inline int gpio_get_value_cansleep(unsigned gpio)
-{
- /* GPIO can never have been requested or set as {in,out}put */
- WARN_ON(1);
- return 0;
-}
-
-static inline void gpio_set_value_cansleep(unsigned gpio, int value)
-{
- /* GPIO can never have been requested or set as output */
- WARN_ON(1);
-}
-
-static inline int gpio_to_irq(unsigned gpio)
-{
- /* GPIO can never have been requested or set as input */
- WARN_ON(1);
- return -EINVAL;
-}
-
-static inline int devm_gpio_request_one(struct device *dev, unsigned gpio,
- unsigned long flags, const char *label)
-{
- WARN_ON(1);
- return -EINVAL;
-}
-
-#endif /* ! CONFIG_GPIOLIB */
+#include <linux/gpio/legacy.h>
#endif /* CONFIG_GPIOLIB_LEGACY */
+
#endif /* __LINUX_GPIO_H */
diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
index 3efb5cb1e1d1..fceeefd5f893 100644
--- a/include/linux/gpio/consumer.h
+++ b/include/linux/gpio/consumer.h
@@ -111,6 +111,7 @@ void devm_gpiod_unhinge(struct device *dev, struct gpio_desc *desc);
void devm_gpiod_put_array(struct device *dev, struct gpio_descs *descs);
int gpiod_get_direction(struct gpio_desc *desc);
+bool gpiod_is_single_ended(struct gpio_desc *desc);
int gpiod_direction_input(struct gpio_desc *desc);
int gpiod_direction_output(struct gpio_desc *desc, int value);
int gpiod_direction_output_raw(struct gpio_desc *desc, int value);
@@ -337,6 +338,10 @@ static inline int gpiod_get_direction(const struct gpio_desc *desc)
WARN_ON(desc);
return -ENOSYS;
}
+static inline bool gpiod_is_single_ended(struct gpio_desc *desc)
+{
+ return false;
+}
static inline int gpiod_direction_input(struct gpio_desc *desc)
{
/* GPIO can never have been requested */
@@ -599,6 +604,15 @@ static inline int gpiod_disable_hw_timestamp_ns(struct gpio_desc *desc,
#endif /* CONFIG_GPIOLIB && CONFIG_HTE */
static inline
+struct gpio_desc *fwnode_gpiod_get(struct fwnode_handle *fwnode,
+ const char *con_id,
+ enum gpiod_flags flags,
+ const char *label)
+{
+ return fwnode_gpiod_get_index(fwnode, con_id, 0, flags, label);
+}
+
+static inline
struct gpio_desc *devm_fwnode_gpiod_get(struct device *dev,
struct fwnode_handle *fwnode,
const char *con_id,
diff --git a/include/linux/gpio/gpio-nomadik.h b/include/linux/gpio/gpio-nomadik.h
index 8061b9826361..44c47645649c 100644
--- a/include/linux/gpio/gpio-nomadik.h
+++ b/include/linux/gpio/gpio-nomadik.h
@@ -32,9 +32,6 @@ struct fwnode_handle;
#define NMK_GPIO_RWIMSC 0x50
#define NMK_GPIO_FWIMSC 0x54
#define NMK_GPIO_WKS 0x58
-/* These appear in DB8540 and later ASICs */
-#define NMK_GPIO_EDGELEVEL 0x5C
-#define NMK_GPIO_LEVEL 0x60
/* Pull up/down values */
enum nmk_gpio_pull {
@@ -236,19 +233,6 @@ nmk_pinctrl_db8500_init(const struct nmk_pinctrl_soc_data **soc)
#endif
-#ifdef CONFIG_PINCTRL_DB8540
-
-void nmk_pinctrl_db8540_init(const struct nmk_pinctrl_soc_data **soc);
-
-#else
-
-static inline void
-nmk_pinctrl_db8540_init(const struct nmk_pinctrl_soc_data **soc)
-{
-}
-
-#endif
-
struct platform_device;
#ifdef CONFIG_DEBUG_FS
diff --git a/include/linux/gpio/legacy.h b/include/linux/gpio/legacy.h
new file mode 100644
index 000000000000..557ef635935e
--- /dev/null
+++ b/include/linux/gpio/legacy.h
@@ -0,0 +1,173 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+/*
+ * This is the LEGACY GPIO include file, used only for legacy APIs.
+ *
+ * No new code should use this, but instead use the linux/gpio/consumer.h
+ * interfaces directly.
+ */
+
+#ifndef __LINUX_GPIO_LEGACY_H
+#define __LINUX_GPIO_LEGACY_H
+
+#include <linux/types.h>
+
+#ifdef CONFIG_GPIOLIB_LEGACY
+
+struct device;
+
+/* make these flag values available regardless of GPIO kconfig options */
+#define GPIOF_IN ((1 << 0))
+#define GPIOF_OUT_INIT_LOW ((0 << 0) | (0 << 1))
+#define GPIOF_OUT_INIT_HIGH ((0 << 0) | (1 << 1))
+
+#ifdef CONFIG_GPIOLIB
+
+#include <linux/gpio/consumer.h>
+
+/*
+ * "valid" GPIO numbers are nonnegative and may be passed to
+ * setup routines like gpio_request(). Only some valid numbers
+ * can successfully be requested and used.
+ *
+ * Invalid GPIO numbers are useful for indicating no-such-GPIO in
+ * platform data and other tables.
+ */
+static inline bool gpio_is_valid(int number)
+{
+ /* only non-negative numbers are valid */
+ return number >= 0;
+}
+
+/*
+ * Platforms may implement their GPIO interface with library code,
+ * at a small performance cost for non-inlined operations and some
+ * extra memory (for code and for per-GPIO table entries).
+ */
+
+/* Always use the library code for GPIO management calls,
+ * or when sleeping may be involved.
+ */
+int gpio_request(unsigned gpio, const char *label);
+void gpio_free(unsigned gpio);
+
+static inline int gpio_direction_input(unsigned gpio)
+{
+ return gpiod_direction_input(gpio_to_desc(gpio));
+}
+static inline int gpio_direction_output(unsigned gpio, int value)
+{
+ return gpiod_direction_output_raw(gpio_to_desc(gpio), value);
+}
+
+static inline int gpio_get_value_cansleep(unsigned gpio)
+{
+ return gpiod_get_raw_value_cansleep(gpio_to_desc(gpio));
+}
+static inline void gpio_set_value_cansleep(unsigned gpio, int value)
+{
+ gpiod_set_raw_value_cansleep(gpio_to_desc(gpio), value);
+}
+
+static inline int gpio_get_value(unsigned gpio)
+{
+ return gpiod_get_raw_value(gpio_to_desc(gpio));
+}
+static inline void gpio_set_value(unsigned gpio, int value)
+{
+ gpiod_set_raw_value(gpio_to_desc(gpio), value);
+}
+
+static inline int gpio_to_irq(unsigned gpio)
+{
+ return gpiod_to_irq(gpio_to_desc(gpio));
+}
+
+int gpio_request_one(unsigned gpio, unsigned long flags, const char *label);
+
+int devm_gpio_request_one(struct device *dev, unsigned gpio,
+ unsigned long flags, const char *label);
+
+#else /* ! CONFIG_GPIOLIB */
+
+#include <linux/kernel.h>
+
+#include <asm/bug.h>
+#include <asm/errno.h>
+
+static inline bool gpio_is_valid(int number)
+{
+ return false;
+}
+
+static inline int gpio_request(unsigned gpio, const char *label)
+{
+ return -ENOSYS;
+}
+
+static inline int gpio_request_one(unsigned gpio,
+ unsigned long flags, const char *label)
+{
+ return -ENOSYS;
+}
+
+static inline void gpio_free(unsigned gpio)
+{
+ might_sleep();
+
+ /* GPIO can never have been requested */
+ WARN_ON(1);
+}
+
+static inline int gpio_direction_input(unsigned gpio)
+{
+ return -ENOSYS;
+}
+
+static inline int gpio_direction_output(unsigned gpio, int value)
+{
+ return -ENOSYS;
+}
+
+static inline int gpio_get_value(unsigned gpio)
+{
+ /* GPIO can never have been requested or set as {in,out}put */
+ WARN_ON(1);
+ return 0;
+}
+
+static inline void gpio_set_value(unsigned gpio, int value)
+{
+ /* GPIO can never have been requested or set as output */
+ WARN_ON(1);
+}
+
+static inline int gpio_get_value_cansleep(unsigned gpio)
+{
+ /* GPIO can never have been requested or set as {in,out}put */
+ WARN_ON(1);
+ return 0;
+}
+
+static inline void gpio_set_value_cansleep(unsigned gpio, int value)
+{
+ /* GPIO can never have been requested or set as output */
+ WARN_ON(1);
+}
+
+static inline int gpio_to_irq(unsigned gpio)
+{
+ /* GPIO can never have been requested or set as input */
+ WARN_ON(1);
+ return -EINVAL;
+}
+
+static inline int devm_gpio_request_one(struct device *dev, unsigned gpio,
+ unsigned long flags, const char *label)
+{
+ WARN_ON(1);
+ return -EINVAL;
+}
+
+#endif /* ! CONFIG_GPIOLIB */
+#endif /* CONFIG_GPIOLIB_LEGACY */
+#endif /* __LINUX_GPIO_LEGAGY_H */
diff --git a/include/linux/gpio/regmap.h b/include/linux/gpio/regmap.h
index 12d154732ca9..06255756710d 100644
--- a/include/linux/gpio/regmap.h
+++ b/include/linux/gpio/regmap.h
@@ -38,6 +38,12 @@ struct regmap;
* offset to a register/bitmask pair. If not
* given the default gpio_regmap_simple_xlate()
* is used.
+ * @fixed_direction_mask:
+ * (Optional) Bitmap representing the GPIO lines that
+ * make use of the @fixed_direction_output list to
+ * enforce direction of the GPIO. If this is NULL
+ * and @fixed_direction_output is defined, ALL GPIOs
+ * are assumed to be fixed direction (out or in).
* @fixed_direction_output:
* (Optional) Bitmap representing the fixed direction of
* the GPIO lines. Useful when there are GPIO lines with a
@@ -89,6 +95,7 @@ struct gpio_regmap_config {
int reg_stride;
int ngpio_per_reg;
struct irq_domain *irq_domain;
+ unsigned long *fixed_direction_mask;
unsigned long *fixed_direction_output;
#ifdef CONFIG_REGMAP_IRQ
diff --git a/include/linux/timb_gpio.h b/include/linux/timb_gpio.h
deleted file mode 100644
index 74f5e73bf6db..000000000000
--- a/include/linux/timb_gpio.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/* SPDX-License-Identifier: GPL-2.0-only */
-/*
- * timb_gpio.h timberdale FPGA GPIO driver, platform data definition
- * Copyright (c) 2009 Intel Corporation
- */
-
-#ifndef _LINUX_TIMB_GPIO_H
-#define _LINUX_TIMB_GPIO_H
-
-/**
- * struct timbgpio_platform_data - Platform data of the Timberdale GPIO driver
- * @gpio_base: The number of the first GPIO pin, set to -1 for
- * dynamic number allocation.
- * @nr_pins: Number of pins that is supported by the hardware (1-32)
- * @irq_base: If IRQ is supported by the hardware, this is the base
- * number of IRQ:s. One IRQ per pin will be used. Set to
- * -1 if IRQ:s is not supported.
- */
-struct timbgpio_platform_data {
- int gpio_base;
- int nr_pins;
- int irq_base;
-};
-
-#endif