gpiolib: split of_mm_gpio_chip out of linux/of_gpio.h
authorArnd Bergmann <arnd@arndb.de>
Tue, 7 Feb 2023 14:29:47 +0000 (16:29 +0200)
committerAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Mon, 6 Mar 2023 10:33:01 +0000 (12:33 +0200)
This is a rarely used feature that has nothing to do with the
client-side of_gpio.h.

Split it out with a separate header file and Kconfig option
so it can be removed on its own timeline aside from removing
the of_gpio consumer interfaces.

Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
15 files changed:
arch/powerpc/platforms/44x/Kconfig
arch/powerpc/platforms/4xx/gpio.c
arch/powerpc/platforms/8xx/Kconfig
arch/powerpc/platforms/8xx/cpm1.c
arch/powerpc/platforms/Kconfig
arch/powerpc/sysdev/cpm_common.c
drivers/gpio/Kconfig
drivers/gpio/TODO
drivers/gpio/gpio-altera.c
drivers/gpio/gpio-mm-lantiq.c
drivers/gpio/gpio-mpc5200.c
drivers/gpio/gpiolib-of.c
drivers/soc/fsl/qe/gpio.c
include/linux/gpio/legacy-of-mm-gpiochip.h [new file with mode: 0644]
include/linux/of_gpio.h

index 25b80cd558f8d16c3f6bccd8a30ccdd0181e4c97..1624ebf95497ba77eb884b50e258ea7b401c08dd 100644 (file)
@@ -230,6 +230,7 @@ config PPC4xx_GPIO
        bool "PPC4xx GPIO support"
        depends on 44x
        select GPIOLIB
+       select OF_GPIO_MM_GPIOCHIP
        help
          Enable gpiolib support for ppc440 based boards
 
index 49ee8d365852b17da08494a0881c1aa2b5be7cb6..e5f2319e5cbe27d472b0c7421f88ce18848ea21f 100644 (file)
@@ -14,7 +14,7 @@
 #include <linux/spinlock.h>
 #include <linux/io.h>
 #include <linux/of.h>
-#include <linux/of_gpio.h>
+#include <linux/gpio/legacy-of-mm-gpiochip.h>
 #include <linux/gpio/driver.h>
 #include <linux/types.h>
 #include <linux/slab.h>
index 60cc5b537a9834c60883af2d5bd7f3e89c24e7bb..a14d9d8997a4f0eb91c6294f46891558ab125557 100644 (file)
@@ -101,6 +101,7 @@ comment "Generic MPC8xx Options"
 config 8xx_GPIO
        bool "GPIO API Support"
        select GPIOLIB
+       select OF_GPIO_MM_GPIOCHIP
        help
          Saying Y here will cause the ports on an MPC8xx processor to be used
          with the GPIO API.  If you say N here, the kernel needs less memory.
index bb38c8d8f8deac6f8a41f140fd75ace04add824a..56ca14f77543bbc5a5a6644fc3c48ca1d7100843 100644 (file)
@@ -44,7 +44,7 @@
 #include <asm/fs_pd.h>
 
 #ifdef CONFIG_8xx_GPIO
-#include <linux/of_gpio.h>
+#include <linux/gpio/legacy-of-mm-gpiochip.h>
 #endif
 
 #define CPM_MAP_SIZE    (0x4000)
index d41dad227de84c8aad20139101813acd7caab274..8e4bbd19dec5f641525770671774e307a16b51fa 100644 (file)
@@ -244,6 +244,7 @@ config QE_GPIO
        bool "QE GPIO support"
        depends on QUICC_ENGINE
        select GPIOLIB
+       select OF_GPIO_MM_GPIOCHIP
        help
          Say Y here if you're going to use hardware that connects to the
          QE GPIOs.
@@ -254,6 +255,7 @@ config CPM2
        select CPM
        select HAVE_PCI
        select GPIOLIB
+       select OF_GPIO_MM_GPIOCHIP
        help
          The CPM2 (Communications Processor Module) is a coprocessor on
          embedded CPUs made by Freescale.  Selecting this option means that
index 7dc1960f8bdb5e2267c85ac1ba7b9798a34a1b58..8234013a8772a3393cd682f2045422dfb7e843e1 100644 (file)
@@ -31,7 +31,7 @@
 #include <mm/mmu_decl.h>
 
 #if defined(CONFIG_CPM2) || defined(CONFIG_8xx_GPIO)
-#include <linux/of_gpio.h>
+#include <linux/gpio/legacy-of-mm-gpiochip.h>
 #endif
 
 static int __init cpm_init(void)
index df82fb7eb0eb268d477097c806a973e0a1fc75b3..2b72a7a7084ade5b92b0f79a0ea7bec54397c32e 100644 (file)
@@ -39,6 +39,14 @@ config GPIOLIB_IRQCHIP
        select IRQ_DOMAIN
        bool
 
+config OF_GPIO_MM_GPIOCHIP
+       bool
+       help
+         This adds support for the legacy 'struct of_mm_gpio_chip' interface
+         from PowerPC. Existing drivers using this interface need to select
+         this symbol, but new drivers should use the generic gpio-regmap
+         infrastructure instead.
+
 config DEBUG_GPIO
        bool "Debug GPIO calls"
        depends on DEBUG_KERNEL
@@ -131,6 +139,7 @@ config GPIO_ALTERA
        tristate "Altera GPIO"
        depends on OF_GPIO
        select GPIOLIB_IRQCHIP
+       select OF_GPIO_MM_GPIOCHIP
        help
          Say Y or M here to build support for the Altera PIO device.
 
@@ -403,6 +412,7 @@ config GPIO_MENZ127
 config GPIO_MM_LANTIQ
        bool "Lantiq Memory mapped GPIOs"
        depends on LANTIQ && SOC_XWAY
+       select OF_GPIO_MM_GPIOCHIP
        help
          This enables support for memory mapped GPIOs on the External Bus Unit
          (EBU) found on Lantiq SoCs. The GPIOs are output only as they are
@@ -411,6 +421,7 @@ config GPIO_MM_LANTIQ
 config GPIO_MPC5200
        def_bool y
        depends on PPC_MPC52xx
+       select OF_GPIO_MM_GPIOCHIP
 
 config GPIO_MPC8XXX
        bool "MPC512x/MPC8xxx/QorIQ GPIO support"
index 68ada1066941ececd868aa46753da883a713ac67..189c3abe7e79d4b99e18ccf3ef98750931b96d06 100644 (file)
@@ -59,11 +59,6 @@ the device tree back-end. It is legacy and should not be used in new code.
 
 Work items:
 
-- Get rid of struct of_mm_gpio_chip altogether: use the generic  MMIO
-  GPIO for all current users (see below). Delete struct of_mm_gpio_chip,
-  to_of_mm_gpio_chip(), of_mm_gpiochip_add_data(), of_mm_gpiochip_remove()
-  from the kernel.
-
 - Change all consumer drivers that #include <linux/of_gpio.h> to
   #include <linux/gpio/consumer.h> and stop doing custom parsing of the
   GPIO lines from the device tree. This can be tricky and often ivolves
@@ -81,6 +76,16 @@ Work items:
   uses <linux/gpio/consumer.h> or <linux/gpio/driver.h> instead.
 
 
+Get rid of <linux/gpio/legacy-of-mm-gpiochip.h>
+
+Work items:
+
+- Get rid of struct of_mm_gpio_chip altogether: use the generic  MMIO
+  GPIO for all current users (see below). Delete struct of_mm_gpio_chip,
+  to_of_mm_gpio_chip(), of_mm_gpiochip_add_data(), of_mm_gpiochip_remove(),
+  CONFIG_OF_GPIO_MM_GPIOCHIP from the kernel.
+
+
 Get rid of <linux/gpio.h>
 
 This legacy header is a one stop shop for anything GPIO is closely tied
index b59fae993626baa87459495498195e39f2c1dfdb..99e137f8097e07e51286355fc693c417d3976a50 100644 (file)
@@ -7,7 +7,7 @@
 #include <linux/io.h>
 #include <linux/module.h>
 #include <linux/gpio/driver.h>
-#include <linux/of_gpio.h> /* For of_mm_gpio_chip */
+#include <linux/gpio/legacy-of-mm-gpiochip.h>
 #include <linux/platform_device.h>
 
 #define ALTERA_GPIO_MAX_NGPIO          32
index 538e31fe890312a2840ff755068a2f6ddc3bdacb..27ff84c5d162612bd0359c11997a84ffd140859c 100644 (file)
@@ -10,8 +10,8 @@
 #include <linux/platform_device.h>
 #include <linux/mutex.h>
 #include <linux/gpio/driver.h>
+#include <linux/gpio/legacy-of-mm-gpiochip.h.h>
 #include <linux/of.h>
-#include <linux/of_gpio.h>
 #include <linux/io.h>
 #include <linux/slab.h>
 
index 000494e0c533b1f054b8a98f1226307a1a4b1864..3b0bfff8c77895cdc0c919121a79a27816ab4f84 100644 (file)
@@ -8,7 +8,7 @@
 #include <linux/of.h>
 #include <linux/kernel.h>
 #include <linux/slab.h>
-#include <linux/of_gpio.h>
+#include <linux/gpio/legacy-of-mm-gpiochip.h>
 #include <linux/io.h>
 #include <linux/of_platform.h>
 #include <linux/module.h>
index 266352b1a966bc7079be3418e92633f08d5bbf0d..0f699af438b0030cf7508bbd31009c4564dda1c6 100644 (file)
@@ -892,6 +892,8 @@ static int of_gpio_simple_xlate(struct gpio_chip *gc,
        return gpiospec->args[0];
 }
 
+#if IS_ENABLED(CONFIG_OF_GPIO_MM_GPIOCHIP)
+#include <linux/gpio/legacy-of-mm-gpiochip.h>
 /**
  * of_mm_gpiochip_add_data - Add memory mapped GPIO chip (bank)
  * @np:                device node of the GPIO chip
@@ -964,6 +966,7 @@ void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc)
        kfree(gc->label);
 }
 EXPORT_SYMBOL_GPL(of_mm_gpiochip_remove);
+#endif
 
 #ifdef CONFIG_PINCTRL
 static int of_gpiochip_add_pin_range(struct gpio_chip *chip)
index 1c41eb49d5a77f9e8eb537c46302566a8ef86385..3ef24ba0245b75471ffa10f579bb744c0c3b7e43 100644 (file)
@@ -13,7 +13,7 @@
 #include <linux/err.h>
 #include <linux/io.h>
 #include <linux/of.h>
-#include <linux/of_gpio.h>     /* for of_mm_gpio_chip */
+#include <linux/gpio/legacy-of-mm-gpiochip.h>
 #include <linux/gpio/consumer.h>
 #include <linux/gpio/driver.h>
 #include <linux/slab.h>
diff --git a/include/linux/gpio/legacy-of-mm-gpiochip.h b/include/linux/gpio/legacy-of-mm-gpiochip.h
new file mode 100644 (file)
index 0000000..2e2bd3b
--- /dev/null
@@ -0,0 +1,36 @@
+/* SPDX-License-Identifier: GPL-2.0+ */
+/*
+ * OF helpers for the old of_mm_gpio_chip, used on ppc32 and nios2,
+ * do not use in new code.
+ *
+ * Copyright (c) 2007-2008  MontaVista Software, Inc.
+ *
+ * Author: Anton Vorontsov <avorontsov@ru.mvista.com>
+ */
+
+#ifndef __LINUX_GPIO_LEGACY_OF_MM_GPIO_CHIP_H
+#define __LINUX_GPIO_LEGACY_OF_MM_GPIO_CHIP_H
+
+#include <linux/gpio/driver.h>
+#include <linux/of.h>
+
+/*
+ * OF GPIO chip for memory mapped banks
+ */
+struct of_mm_gpio_chip {
+       struct gpio_chip gc;
+       void (*save_regs)(struct of_mm_gpio_chip *mm_gc);
+       void __iomem *regs;
+};
+
+static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc)
+{
+       return container_of(gc, struct of_mm_gpio_chip, gc);
+}
+
+extern int of_mm_gpiochip_add_data(struct device_node *np,
+                                  struct of_mm_gpio_chip *mm_gc,
+                                  void *data);
+extern void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc);
+
+#endif /* __LINUX_GPIO_LEGACY_OF_MM_GPIO_CHIP_H */
index 5d58b3b0a97e1dfa5181f3f3bac75b16a8070aa7..d0f66a5e1b2a7254df8beab0a14807249fd92dfc 100644 (file)
@@ -19,30 +19,9 @@ struct device_node;
 
 #ifdef CONFIG_OF_GPIO
 
-#include <linux/container_of.h>
-
-/*
- * OF GPIO chip for memory mapped banks
- */
-struct of_mm_gpio_chip {
-       struct gpio_chip gc;
-       void (*save_regs)(struct of_mm_gpio_chip *mm_gc);
-       void __iomem *regs;
-};
-
-static inline struct of_mm_gpio_chip *to_of_mm_gpio_chip(struct gpio_chip *gc)
-{
-       return container_of(gc, struct of_mm_gpio_chip, gc);
-}
-
 extern int of_get_named_gpio(const struct device_node *np,
                             const char *list_name, int index);
 
-extern int of_mm_gpiochip_add_data(struct device_node *np,
-                                  struct of_mm_gpio_chip *mm_gc,
-                                  void *data);
-extern void of_mm_gpiochip_remove(struct of_mm_gpio_chip *mm_gc);
-
 #else /* CONFIG_OF_GPIO */
 
 #include <linux/errno.h>