linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/10] gpiolib: more quirks to handle legacy names
@ 2022-10-18  5:41 Dmitry Torokhov
  2022-10-18  5:41 ` [PATCH v3 01/10] gpiolib: of: add a quirk for legacy names in Mediatek mt2701-cs42448 Dmitry Torokhov
                   ` (11 more replies)
  0 siblings, 12 replies; 16+ messages in thread
From: Dmitry Torokhov @ 2022-10-18  5:41 UTC (permalink / raw)
  To: Bartosz Golaszewski, Linus Walleij
  Cc: Alexander Stein, linux-arm-kernel, linux-gpio, Andy Shevchenko,
	Daniel Thompson, linux-kernel, linux-mediatek

In preparation to converting several drivers to gpiod API, and to keep
existing DTS working, this series adds additional quirks to locate
gpio lines with legacy names.

Additionally the quirk handling has been reworked (once again) to pull
all simple renames (ones that do not involve change of indices or other
complex manipulations) into a single quirk with a table containing
transformations. This should make adding new quirks easier.
When using legacy names gpiolib will emit a message to nudge users to
update DTSes (when possible).

Note that the last patch requires the following change from the OF tree:

        88269151be67 ("of: base: make of_device_compatible_match() accept const device node")

The change is also available in mainline - it has been merged in 6.1
merge window.

Thanks.

To: Linus Walleij <linus.walleij@linaro.org>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Cc: Alexander Stein <alexander.stein@ew.tq-group.com>
Cc: Daniel Thompson <daniel.thompson@linaro.org>
Cc: linux-gpio@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-mediatek@lists.infradead.org

---
Changes in v3:
- added missed legacy compatible for UART variant of Marvell NFC controller
- added naming quirk for MOXA ART RTC
- Link to v2: https://lore.kernel.org/r/20221011-gpiolib-quirks-v2-0-73cb7176fd94@gmail.com

Changes in v2:
- fixed 'fsl,imx8mq-fec' & 'fsl,imx8qm-fec' compatibles issue noticed
  by Alexander Stein
- implemented Daniel Thompson's suggestion on tightening configs
  selecting renaming quirks and added a comment to discourage adding
  rename quirks without checks for specific compatible(s) 
- added a polarity quirk for Himax LCDs
- collected reviewed-by tags
- Link to v1: https://lore.kernel.org/r/20221011-gpiolib-quirks-v1-0-e01d9d3e7b29@gmail.com

---
Dmitry Torokhov (10):
      gpiolib: of: add a quirk for legacy names in Mediatek mt2701-cs42448
      gpiolib: of: consolidate simple renames into a single quirk
      gpiolib: of: tighten selection of gpio renaming quirks
      gpiolib: of: add quirk for locating reset lines with legacy bindings
      gpiolib: of: add a quirk for reset line for Marvell NFC controller
      gpiolib: of: add a quirk for reset line for Cirrus CS42L56 codec
      gpiolib: of: add a quirk for legacy names in MOXA ART RTC
      gpiolib: of: factor out code overriding gpio line polarity
      gpiolib: of: add quirk for phy reset polarity for Freescale Ethernet
      gpiolib: of: add a quirk for reset line polarity for Himax LCDs

 drivers/gpio/gpiolib-of.c | 349 ++++++++++++++++++++++++++++++----------------
 1 file changed, 227 insertions(+), 122 deletions(-)
---
base-commit: dca0a0385a4963145593ba417e1417af88a7c18d
change-id: 20221011-gpiolib-quirks-d452ed31d24e

-- 
Dmitry


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH v3 01/10] gpiolib: of: add a quirk for legacy names in Mediatek mt2701-cs42448
  2022-10-18  5:41 [PATCH v3 00/10] gpiolib: more quirks to handle legacy names Dmitry Torokhov
@ 2022-10-18  5:41 ` Dmitry Torokhov
  2022-10-18  5:41 ` [PATCH v3 02/10] gpiolib: of: consolidate simple renames into a single quirk Dmitry Torokhov
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Dmitry Torokhov @ 2022-10-18  5:41 UTC (permalink / raw)
  To: Bartosz Golaszewski, Linus Walleij
  Cc: Alexander Stein, linux-arm-kernel, linux-gpio, Andy Shevchenko,
	Daniel Thompson, linux-kernel, linux-mediatek

The driver is using non-standard "i2s1-in-sel-gpio1" and
"i2s1-in-sel-gpio2" names to describe its gpios. In preparation to
converting to the standard naming (i2s1-in-sel-gpios) and switching the
driver to gpiod API add a quirk to gpiolib to keep compatibility with
existing DTSes.

Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/gpio/gpiolib-of.c | 33 +++++++++++++++++++++++++++++++++
 1 file changed, 33 insertions(+)

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 0e4e1291604d..cef4f6634125 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -488,6 +488,38 @@ static struct gpio_desc *of_find_usb_gpio(struct device_node *np,
 	return of_get_named_gpiod_flags(np, con_id, idx, of_flags);
 }
 
+static struct gpio_desc *of_find_mt2701_gpio(struct device_node *np,
+					     const char *con_id,
+					     unsigned int idx,
+					     enum of_gpio_flags *of_flags)
+{
+	struct gpio_desc *desc;
+	const char *legacy_id;
+
+	if (!IS_ENABLED(CONFIG_SND_SOC_MT2701_CS42448))
+		return ERR_PTR(-ENOENT);
+
+	if (!of_device_is_compatible(np, "mediatek,mt2701-cs42448-machine"))
+		return ERR_PTR(-ENOENT);
+
+	if (!con_id || strcmp(con_id, "i2s1-in-sel"))
+		return ERR_PTR(-ENOENT);
+
+	if (idx == 0)
+		legacy_id = "i2s1-in-sel-gpio1";
+	else if (idx == 1)
+		legacy_id = "i2s1-in-sel-gpio2";
+	else
+		return ERR_PTR(-ENOENT);
+
+	desc = of_get_named_gpiod_flags(np, legacy_id, 0, of_flags);
+	if (!gpiod_not_found(desc))
+		pr_info("%s is using legacy gpio name '%s' instead of '%s-gpios'\n",
+			of_node_full_name(np), legacy_id, con_id);
+
+	return desc;
+}
+
 typedef struct gpio_desc *(*of_find_gpio_quirk)(struct device_node *np,
 						const char *con_id,
 						unsigned int idx,
@@ -498,6 +530,7 @@ static const of_find_gpio_quirk of_find_gpio_quirks[] = {
 	of_find_regulator_gpio,
 	of_find_arizona_gpio,
 	of_find_usb_gpio,
+	of_find_mt2701_gpio,
 	NULL
 };
 

-- 
b4 0.11.0-dev-5166b

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v3 02/10] gpiolib: of: consolidate simple renames into a single quirk
  2022-10-18  5:41 [PATCH v3 00/10] gpiolib: more quirks to handle legacy names Dmitry Torokhov
  2022-10-18  5:41 ` [PATCH v3 01/10] gpiolib: of: add a quirk for legacy names in Mediatek mt2701-cs42448 Dmitry Torokhov
@ 2022-10-18  5:41 ` Dmitry Torokhov
  2022-10-18  5:41 ` [PATCH v3 03/10] gpiolib: of: tighten selection of gpio renaming quirks Dmitry Torokhov
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Dmitry Torokhov @ 2022-10-18  5:41 UTC (permalink / raw)
  To: Bartosz Golaszewski, Linus Walleij
  Cc: Alexander Stein, linux-arm-kernel, linux-gpio, Andy Shevchenko,
	Daniel Thompson, linux-kernel, linux-mediatek

This consolidates all quirks doing simple renames (either allowing
suffix-less names or trivial renames, when index changes are not
required) into a single quirk.

Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/gpio/gpiolib-of.c | 183 ++++++++++++++++++----------------------------
 1 file changed, 71 insertions(+), 112 deletions(-)

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index cef4f6634125..63c6fa3086f3 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -365,127 +365,90 @@ struct gpio_desc *gpiod_get_from_of_node(const struct device_node *node,
 }
 EXPORT_SYMBOL_GPL(gpiod_get_from_of_node);
 
-/*
- * The SPI GPIO bindings happened before we managed to establish that GPIO
- * properties should be named "foo-gpios" so we have this special kludge for
- * them.
- */
-static struct gpio_desc *of_find_spi_gpio(struct device_node *np,
-					  const char *con_id,
-					  unsigned int idx,
-					  enum of_gpio_flags *of_flags)
-{
-	char prop_name[32]; /* 32 is max size of property name */
-
-	/*
-	 * Hopefully the compiler stubs the rest of the function if this
-	 * is false.
-	 */
-	if (!IS_ENABLED(CONFIG_SPI_MASTER))
-		return ERR_PTR(-ENOENT);
-
-	/* Allow this specifically for "spi-gpio" devices */
-	if (!of_device_is_compatible(np, "spi-gpio") || !con_id)
-		return ERR_PTR(-ENOENT);
-
-	/* Will be "gpio-sck", "gpio-mosi" or "gpio-miso" */
-	snprintf(prop_name, sizeof(prop_name), "%s-%s", "gpio", con_id);
-
-	return of_get_named_gpiod_flags(np, prop_name, idx, of_flags);
-}
-
-/*
- * The old Freescale bindings use simply "gpios" as name for the chip select
- * lines rather than "cs-gpios" like all other SPI hardware. Account for this
- * with a special quirk.
- */
-static struct gpio_desc *of_find_spi_cs_gpio(struct device_node *np,
+static struct gpio_desc *of_find_gpio_rename(struct device_node *np,
 					     const char *con_id,
 					     unsigned int idx,
 					     enum of_gpio_flags *of_flags)
 {
-	if (!IS_ENABLED(CONFIG_SPI_MASTER))
-		return ERR_PTR(-ENOENT);
-
-	/* Allow this specifically for Freescale and PPC devices */
-	if (!of_device_is_compatible(np, "fsl,spi") &&
-	    !of_device_is_compatible(np, "aeroflexgaisler,spictrl") &&
-	    !of_device_is_compatible(np, "ibm,ppc4xx-spi"))
-		return ERR_PTR(-ENOENT);
-	/* Allow only if asking for "cs-gpios" */
-	if (!con_id || strcmp(con_id, "cs"))
-		return ERR_PTR(-ENOENT);
+	static const struct of_rename_gpio {
+		const char *con_id;
+		const char *legacy_id;	/* NULL - same as con_id */
+		/*
+		 * Compatible string can be set to NULL in case where
+		 * matching to a particular compatible is not practical,
+		 * but it should only be done for gpio names that have
+		 * vendor prefix to reduce risk of false positives.
+		 * Addition of such entries is strongly discouraged.
+		 */
+		const char *compatible;
+	} gpios[] = {
+#if IS_ENABLED(CONFIG_MFD_ARIZONA)
+		{ "wlf,reset",	NULL,		NULL },
+#endif
+#if IS_ENABLED(CONFIG_REGULATOR)
+		/*
+		 * Some regulator bindings happened before we managed to
+		 * establish that GPIO properties should be named
+		 * "foo-gpios" so we have this special kludge for them.
+		 */
+		{ "wlf,ldoena",  NULL,		NULL }, /* Arizona */
+		{ "wlf,ldo1ena", NULL,		NULL }, /* WM8994 */
+		{ "wlf,ldo2ena", NULL,		NULL }, /* WM8994 */
+#endif
+#if IS_ENABLED(CONFIG_SPI_MASTER)
 
-	/*
-	 * While all other SPI controllers use "cs-gpios" the Freescale
-	 * uses just "gpios" so translate to that when "cs-gpios" is
-	 * requested.
-	 */
-	return of_get_named_gpiod_flags(np, "gpios", idx, of_flags);
-}
+		/*
+		 * The SPI GPIO bindings happened before we managed to
+		 * establish that GPIO properties should be named
+		 * "foo-gpios" so we have this special kludge for them.
+		 */
+		{ "miso",	"gpio-miso",	"spi-gpio" },
+		{ "mosi",	"gpio-mosi",	"spi-gpio" },
+		{ "sck",	"gpio-sck",	"spi-gpio" },
 
-/*
- * Some regulator bindings happened before we managed to establish that GPIO
- * properties should be named "foo-gpios" so we have this special kludge for
- * them.
- */
-static struct gpio_desc *of_find_regulator_gpio(struct device_node *np,
-						const char *con_id,
-						unsigned int idx,
-						enum of_gpio_flags *of_flags)
-{
-	/* These are the connection IDs we accept as legacy GPIO phandles */
-	const char *whitelist[] = {
-		"wlf,ldoena", /* Arizona */
-		"wlf,ldo1ena", /* WM8994 */
-		"wlf,ldo2ena", /* WM8994 */
+		/*
+		 * The old Freescale bindings use simply "gpios" as name
+		 * for the chip select lines rather than "cs-gpios" like
+		 * all other SPI hardware. Allow this specifically for
+		 * Freescale and PPC devices.
+		 */
+		{ "cs",		"gpios",	"fsl,spi" },
+		{ "cs",		"gpios",	"aeroflexgaisler,spictrl" },
+		{ "cs",		"gpios",	"ibm,ppc4xx-spi" },
+#endif
+#if IS_ENABLED(CONFIG_TYPEC_FUSB302)
+		/*
+		 * Fairchild FUSB302 host is using undocumented "fcs,int_n"
+		 * property without the compulsory "-gpios" suffix.
+		 */
+		{ "fcs,int_n",	NULL,		"fcs,fusb302" },
+#endif
 	};
-	int i;
-
-	if (!IS_ENABLED(CONFIG_REGULATOR))
-		return ERR_PTR(-ENOENT);
+	struct gpio_desc *desc;
+	const char *legacy_id;
+	unsigned int i;
 
 	if (!con_id)
 		return ERR_PTR(-ENOENT);
 
-	i = match_string(whitelist, ARRAY_SIZE(whitelist), con_id);
-	if (i < 0)
-		return ERR_PTR(-ENOENT);
-
-	return of_get_named_gpiod_flags(np, con_id, idx, of_flags);
-}
-
-static struct gpio_desc *of_find_arizona_gpio(struct device_node *np,
-					      const char *con_id,
-					      unsigned int idx,
-					      enum of_gpio_flags *of_flags)
-{
-	if (!IS_ENABLED(CONFIG_MFD_ARIZONA))
-		return ERR_PTR(-ENOENT);
-
-	if (!con_id || strcmp(con_id, "wlf,reset"))
-		return ERR_PTR(-ENOENT);
-
-	return of_get_named_gpiod_flags(np, con_id, idx, of_flags);
-}
+	for (i = 0; i < ARRAY_SIZE(gpios); i++) {
+		if (strcmp(con_id, gpios[i].con_id))
+			continue;
 
-static struct gpio_desc *of_find_usb_gpio(struct device_node *np,
-					  const char *con_id,
-					  unsigned int idx,
-					  enum of_gpio_flags *of_flags)
-{
-	/*
-	 * Currently this USB quirk is only for the Fairchild FUSB302 host
-	 * which is using an undocumented DT GPIO line named "fcs,int_n"
-	 * without the compulsory "-gpios" suffix.
-	 */
-	if (!IS_ENABLED(CONFIG_TYPEC_FUSB302))
-		return ERR_PTR(-ENOENT);
+		if (gpios[i].compatible &&
+		    !of_device_is_compatible(np, gpios[i].compatible))
+			continue;
 
-	if (!con_id || strcmp(con_id, "fcs,int_n"))
-		return ERR_PTR(-ENOENT);
+		legacy_id = gpios[i].legacy_id ?: gpios[i].con_id;
+		desc = of_get_named_gpiod_flags(np, legacy_id, idx, of_flags);
+		if (!gpiod_not_found(desc)) {
+			pr_info("%s uses legacy gpio name '%s' instead of '%s-gpios'\n",
+				of_node_full_name(np), legacy_id, con_id);
+			return desc;
+		}
+	}
 
-	return of_get_named_gpiod_flags(np, con_id, idx, of_flags);
+	return ERR_PTR(-ENOENT);
 }
 
 static struct gpio_desc *of_find_mt2701_gpio(struct device_node *np,
@@ -525,11 +488,7 @@ typedef struct gpio_desc *(*of_find_gpio_quirk)(struct device_node *np,
 						unsigned int idx,
 						enum of_gpio_flags *of_flags);
 static const of_find_gpio_quirk of_find_gpio_quirks[] = {
-	of_find_spi_gpio,
-	of_find_spi_cs_gpio,
-	of_find_regulator_gpio,
-	of_find_arizona_gpio,
-	of_find_usb_gpio,
+	of_find_gpio_rename,
 	of_find_mt2701_gpio,
 	NULL
 };

-- 
b4 0.11.0-dev-5166b

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v3 03/10] gpiolib: of: tighten selection of gpio renaming quirks
  2022-10-18  5:41 [PATCH v3 00/10] gpiolib: more quirks to handle legacy names Dmitry Torokhov
  2022-10-18  5:41 ` [PATCH v3 01/10] gpiolib: of: add a quirk for legacy names in Mediatek mt2701-cs42448 Dmitry Torokhov
  2022-10-18  5:41 ` [PATCH v3 02/10] gpiolib: of: consolidate simple renames into a single quirk Dmitry Torokhov
@ 2022-10-18  5:41 ` Dmitry Torokhov
  2022-10-18  5:41 ` [PATCH v3 04/10] gpiolib: of: add quirk for locating reset lines with legacy bindings Dmitry Torokhov
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Dmitry Torokhov @ 2022-10-18  5:41 UTC (permalink / raw)
  To: Bartosz Golaszewski, Linus Walleij
  Cc: Alexander Stein, linux-arm-kernel, linux-gpio, Andy Shevchenko,
	Daniel Thompson, linux-kernel, linux-mediatek

Tighten selection of legacy gpio renaming quirks so that they only
considered on more relevant configurations.

Suggested-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/gpio/gpiolib-of.c | 12 ++++++++++--
 1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 63c6fa3086f3..7d4bbf6484bc 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -385,18 +385,21 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np,
 #if IS_ENABLED(CONFIG_MFD_ARIZONA)
 		{ "wlf,reset",	NULL,		NULL },
 #endif
-#if IS_ENABLED(CONFIG_REGULATOR)
+
 		/*
 		 * Some regulator bindings happened before we managed to
 		 * establish that GPIO properties should be named
 		 * "foo-gpios" so we have this special kludge for them.
 		 */
+#if IS_ENABLED(CONFIG_REGULATOR_ARIZONA_LDO1)
 		{ "wlf,ldoena",  NULL,		NULL }, /* Arizona */
+#endif
+#if IS_ENABLED(CONFIG_REGULATOR_WM8994)
 		{ "wlf,ldo1ena", NULL,		NULL }, /* WM8994 */
 		{ "wlf,ldo2ena", NULL,		NULL }, /* WM8994 */
 #endif
-#if IS_ENABLED(CONFIG_SPI_MASTER)
 
+#if IS_ENABLED(CONFIG_SPI_GPIO)
 		/*
 		 * The SPI GPIO bindings happened before we managed to
 		 * establish that GPIO properties should be named
@@ -405,6 +408,7 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np,
 		{ "miso",	"gpio-miso",	"spi-gpio" },
 		{ "mosi",	"gpio-mosi",	"spi-gpio" },
 		{ "sck",	"gpio-sck",	"spi-gpio" },
+#endif
 
 		/*
 		 * The old Freescale bindings use simply "gpios" as name
@@ -412,10 +416,14 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np,
 		 * all other SPI hardware. Allow this specifically for
 		 * Freescale and PPC devices.
 		 */
+#if IS_ENABLED(CONFIG_SPI_FSL_SPI)
 		{ "cs",		"gpios",	"fsl,spi" },
 		{ "cs",		"gpios",	"aeroflexgaisler,spictrl" },
+#endif
+#if IS_ENABLED(CONFIG_SPI_PPC4xx)
 		{ "cs",		"gpios",	"ibm,ppc4xx-spi" },
 #endif
+
 #if IS_ENABLED(CONFIG_TYPEC_FUSB302)
 		/*
 		 * Fairchild FUSB302 host is using undocumented "fcs,int_n"

-- 
b4 0.11.0-dev-5166b

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v3 04/10] gpiolib: of: add quirk for locating reset lines with legacy bindings
  2022-10-18  5:41 [PATCH v3 00/10] gpiolib: more quirks to handle legacy names Dmitry Torokhov
                   ` (2 preceding siblings ...)
  2022-10-18  5:41 ` [PATCH v3 03/10] gpiolib: of: tighten selection of gpio renaming quirks Dmitry Torokhov
@ 2022-10-18  5:41 ` Dmitry Torokhov
  2022-10-18  5:41 ` [PATCH v3 05/10] gpiolib: of: add a quirk for reset line for Marvell NFC controller Dmitry Torokhov
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Dmitry Torokhov @ 2022-10-18  5:41 UTC (permalink / raw)
  To: Bartosz Golaszewski, Linus Walleij
  Cc: Alexander Stein, linux-arm-kernel, linux-gpio, Andy Shevchenko,
	Daniel Thompson, linux-kernel, linux-mediatek

Some legacy mappings used "gpio[s]-reset" instead of "reset-gpios",
add a quirk so that gpiod API will still work on unmodified DTSes.

Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/gpio/gpiolib-of.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 7d4bbf6484bc..2b5d1b3095c7 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -382,9 +382,18 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np,
 		 */
 		const char *compatible;
 	} gpios[] = {
+#if !IS_ENABLED(CONFIG_LCD_HX8357)
+		/* Himax LCD controllers used "gpios-reset" */
+		{ "reset",	"gpios-reset",	"himax,hx8357" },
+		{ "reset",	"gpios-reset",	"himax,hx8369" },
+#endif
 #if IS_ENABLED(CONFIG_MFD_ARIZONA)
 		{ "wlf,reset",	NULL,		NULL },
 #endif
+#if !IS_ENABLED(CONFIG_PCI_LANTIQ)
+		/* MIPS Lantiq PCI */
+		{ "reset",	"gpios-reset",	"lantiq,pci-xway" },
+#endif
 
 		/*
 		 * Some regulator bindings happened before we managed to
@@ -399,6 +408,13 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np,
 		{ "wlf,ldo2ena", NULL,		NULL }, /* WM8994 */
 #endif
 
+#if IS_ENABLED(CONFIG_SND_SOC_TLV320AIC3X)
+		{ "reset",	"gpio-reset",	"ti,tlv320aic3x" },
+		{ "reset",	"gpio-reset",	"ti,tlv320aic33" },
+		{ "reset",	"gpio-reset",	"ti,tlv320aic3007" },
+		{ "reset",	"gpio-reset",	"ti,tlv320aic3104" },
+		{ "reset",	"gpio-reset",	"ti,tlv320aic3106" },
+#endif
 #if IS_ENABLED(CONFIG_SPI_GPIO)
 		/*
 		 * The SPI GPIO bindings happened before we managed to

-- 
b4 0.11.0-dev-5166b

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v3 05/10] gpiolib: of: add a quirk for reset line for Marvell NFC controller
  2022-10-18  5:41 [PATCH v3 00/10] gpiolib: more quirks to handle legacy names Dmitry Torokhov
                   ` (3 preceding siblings ...)
  2022-10-18  5:41 ` [PATCH v3 04/10] gpiolib: of: add quirk for locating reset lines with legacy bindings Dmitry Torokhov
@ 2022-10-18  5:41 ` Dmitry Torokhov
  2022-10-18  5:41 ` [PATCH v3 06/10] gpiolib: of: add a quirk for reset line for Cirrus CS42L56 codec Dmitry Torokhov
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Dmitry Torokhov @ 2022-10-18  5:41 UTC (permalink / raw)
  To: Bartosz Golaszewski, Linus Walleij
  Cc: Alexander Stein, linux-arm-kernel, linux-gpio, Andy Shevchenko,
	Daniel Thompson, linux-kernel, linux-mediatek

The controller is using non-standard "reset-n-io" name for its reset
gpio property, whereas gpiod API expects "<name>-gpios". Add a quirk
so that gpiod API will still work on unmodified DTSes.

Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/gpio/gpiolib-of.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 2b5d1b3095c7..a9cedc39a245 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -390,6 +390,16 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np,
 #if IS_ENABLED(CONFIG_MFD_ARIZONA)
 		{ "wlf,reset",	NULL,		NULL },
 #endif
+#if IS_ENABLED(CONFIG_NFC_MRVL_I2C)
+		{ "reset",	"reset-n-io",	"marvell,nfc-i2c" },
+#endif
+#if IS_ENABLED(CONFIG_NFC_MRVL_SPI)
+		{ "reset",	"reset-n-io",	"marvell,nfc-spi" },
+#endif
+#if IS_ENABLED(CONFIG_NFC_MRVL_UART)
+		{ "reset",	"reset-n-io",	"marvell,nfc-uart" },
+		{ "reset",	"reset-n-io",	"mrvl,nfc-uart" },
+#endif
 #if !IS_ENABLED(CONFIG_PCI_LANTIQ)
 		/* MIPS Lantiq PCI */
 		{ "reset",	"gpios-reset",	"lantiq,pci-xway" },

-- 
b4 0.11.0-dev-5166b

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v3 06/10] gpiolib: of: add a quirk for reset line for Cirrus CS42L56 codec
  2022-10-18  5:41 [PATCH v3 00/10] gpiolib: more quirks to handle legacy names Dmitry Torokhov
                   ` (4 preceding siblings ...)
  2022-10-18  5:41 ` [PATCH v3 05/10] gpiolib: of: add a quirk for reset line for Marvell NFC controller Dmitry Torokhov
@ 2022-10-18  5:41 ` Dmitry Torokhov
  2022-10-18  5:41 ` [PATCH v3 07/10] gpiolib: of: add a quirk for legacy names in MOXA ART RTC Dmitry Torokhov
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Dmitry Torokhov @ 2022-10-18  5:41 UTC (permalink / raw)
  To: Bartosz Golaszewski, Linus Walleij
  Cc: Alexander Stein, linux-arm-kernel, linux-gpio, Andy Shevchenko,
	Daniel Thompson, linux-kernel, linux-mediatek

The controller is using non-standard "cirrus,gpio-nreset" name for its
reset gpio property, whereas gpiod API expects "<name>-gpios".
Add a quirk so that gpiod API will still work on unmodified DTSes.

Reviewed-by: Daniel Thompson <daniel.thompson@linaro.org>
Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/gpio/gpiolib-of.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index a9cedc39a245..ffdbac2eeaa6 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -418,6 +418,9 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np,
 		{ "wlf,ldo2ena", NULL,		NULL }, /* WM8994 */
 #endif
 
+#if IS_ENABLED(CONFIG_SND_SOC_CS42L56)
+		{ "reset",	"cirrus,gpio-nreset",	"cirrus,cs42l56" },
+#endif
 #if IS_ENABLED(CONFIG_SND_SOC_TLV320AIC3X)
 		{ "reset",	"gpio-reset",	"ti,tlv320aic3x" },
 		{ "reset",	"gpio-reset",	"ti,tlv320aic33" },

-- 
b4 0.11.0-dev-5166b

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v3 07/10] gpiolib: of: add a quirk for legacy names in MOXA ART RTC
  2022-10-18  5:41 [PATCH v3 00/10] gpiolib: more quirks to handle legacy names Dmitry Torokhov
                   ` (5 preceding siblings ...)
  2022-10-18  5:41 ` [PATCH v3 06/10] gpiolib: of: add a quirk for reset line for Cirrus CS42L56 codec Dmitry Torokhov
@ 2022-10-18  5:41 ` Dmitry Torokhov
  2022-10-18  5:41 ` [PATCH v3 08/10] gpiolib: of: factor out code overriding gpio line polarity Dmitry Torokhov
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Dmitry Torokhov @ 2022-10-18  5:41 UTC (permalink / raw)
  To: Bartosz Golaszewski, Linus Walleij
  Cc: Alexander Stein, linux-arm-kernel, linux-gpio, Andy Shevchenko,
	Daniel Thompson, linux-kernel, linux-mediatek

The driver is using non-standard "gpio-rtc-data", "gpio-rtc-sclk", and
"gpio-rtc-reset" names for properties describing its gpios. In
preparation to converting to the standard naming ("rtc-*-gpios") and
switching the driver to gpiod API add a quirk to gpiolib to keep
compatibility with existing DTSes.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/gpio/gpiolib-of.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index ffdbac2eeaa6..d22498c72a67 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -390,6 +390,11 @@ static struct gpio_desc *of_find_gpio_rename(struct device_node *np,
 #if IS_ENABLED(CONFIG_MFD_ARIZONA)
 		{ "wlf,reset",	NULL,		NULL },
 #endif
+#if IS_ENABLED(CONFIG_RTC_DRV_MOXART)
+		{ "rtc-data",	"gpio-rtc-data",	"moxa,moxart-rtc" },
+		{ "rtc-sclk",	"gpio-rtc-sclk",	"moxa,moxart-rtc" },
+		{ "rtc-reset",	"gpio-rtc-reset",	"moxa,moxart-rtc" },
+#endif
 #if IS_ENABLED(CONFIG_NFC_MRVL_I2C)
 		{ "reset",	"reset-n-io",	"marvell,nfc-i2c" },
 #endif

-- 
b4 0.11.0-dev-5166b

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v3 08/10] gpiolib: of: factor out code overriding gpio line polarity
  2022-10-18  5:41 [PATCH v3 00/10] gpiolib: more quirks to handle legacy names Dmitry Torokhov
                   ` (6 preceding siblings ...)
  2022-10-18  5:41 ` [PATCH v3 07/10] gpiolib: of: add a quirk for legacy names in MOXA ART RTC Dmitry Torokhov
@ 2022-10-18  5:41 ` Dmitry Torokhov
  2022-10-18  5:41 ` [PATCH v3 09/10] gpiolib: of: add quirk for phy reset polarity for Freescale Ethernet Dmitry Torokhov
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Dmitry Torokhov @ 2022-10-18  5:41 UTC (permalink / raw)
  To: Bartosz Golaszewski, Linus Walleij
  Cc: Alexander Stein, linux-arm-kernel, linux-gpio, Andy Shevchenko,
	Daniel Thompson, linux-kernel, linux-mediatek

There are several instances where we use a separate property to
override polarity specified in gpio property. Factor it out into
a separate function.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/gpio/gpiolib-of.c | 48 +++++++++++++++++++++++++++--------------------
 1 file changed, 28 insertions(+), 20 deletions(-)

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index d22498c72a67..6faf0dc7bc31 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -130,6 +130,28 @@ bool of_gpio_need_valid_mask(const struct gpio_chip *gc)
 	return false;
 }
 
+/*
+ * Overrides stated polarity of a gpio line and warns when there is a
+ * discrepancy.
+ */
+static void of_gpio_quirk_polarity(const struct device_node *np,
+				   bool active_high,
+				   enum of_gpio_flags *flags)
+{
+	if (active_high) {
+		if (*flags & OF_GPIO_ACTIVE_LOW) {
+			pr_warn("%s GPIO handle specifies active low - ignored\n",
+				of_node_full_name(np));
+			*flags &= ~OF_GPIO_ACTIVE_LOW;
+		}
+	} else {
+		if (!(*flags & OF_GPIO_ACTIVE_LOW))
+			pr_info("%s enforce active low on GPIO handle\n",
+				of_node_full_name(np));
+		*flags |= OF_GPIO_ACTIVE_LOW;
+	}
+}
+
 static void of_gpio_flags_quirks(const struct device_node *np,
 				 const char *propname,
 				 enum of_gpio_flags *flags,
@@ -145,7 +167,7 @@ static void of_gpio_flags_quirks(const struct device_node *np,
 	     (!(strcmp(propname, "enable-gpio") &&
 		strcmp(propname, "enable-gpios")) &&
 	      of_device_is_compatible(np, "regulator-gpio")))) {
-		bool active_low = !of_property_read_bool(np,
+		bool active_high = of_property_read_bool(np,
 							 "enable-active-high");
 		/*
 		 * The regulator GPIO handles are specified such that the
@@ -153,13 +175,7 @@ static void of_gpio_flags_quirks(const struct device_node *np,
 		 * the polarity of the GPIO line. Any phandle flags must
 		 * be actively ignored.
 		 */
-		if ((*flags & OF_GPIO_ACTIVE_LOW) && !active_low) {
-			pr_warn("%s GPIO handle specifies active low - ignored\n",
-				of_node_full_name(np));
-			*flags &= ~OF_GPIO_ACTIVE_LOW;
-		}
-		if (active_low)
-			*flags |= OF_GPIO_ACTIVE_LOW;
+		of_gpio_quirk_polarity(np, active_high, flags);
 	}
 	/*
 	 * Legacy open drain handling for fixed voltage regulators.
@@ -200,18 +216,10 @@ static void of_gpio_flags_quirks(const struct device_node *np,
 				 * conflict and the "spi-cs-high" flag will
 				 * take precedence.
 				 */
-				if (of_property_read_bool(child, "spi-cs-high")) {
-					if (*flags & OF_GPIO_ACTIVE_LOW) {
-						pr_warn("%s GPIO handle specifies active low - ignored\n",
-							of_node_full_name(child));
-						*flags &= ~OF_GPIO_ACTIVE_LOW;
-					}
-				} else {
-					if (!(*flags & OF_GPIO_ACTIVE_LOW))
-						pr_info("%s enforce active low on chipselect handle\n",
-							of_node_full_name(child));
-					*flags |= OF_GPIO_ACTIVE_LOW;
-				}
+				bool active_high = of_property_read_bool(child,
+								"spi-cs-high");
+				of_gpio_quirk_polarity(child, active_high,
+						       flags);
 				of_node_put(child);
 				break;
 			}

-- 
b4 0.11.0-dev-5166b

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v3 09/10] gpiolib: of: add quirk for phy reset polarity for Freescale Ethernet
  2022-10-18  5:41 [PATCH v3 00/10] gpiolib: more quirks to handle legacy names Dmitry Torokhov
                   ` (7 preceding siblings ...)
  2022-10-18  5:41 ` [PATCH v3 08/10] gpiolib: of: factor out code overriding gpio line polarity Dmitry Torokhov
@ 2022-10-18  5:41 ` Dmitry Torokhov
  2022-10-18  5:41 ` [PATCH v3 10/10] gpiolib: of: add a quirk for reset line polarity for Himax LCDs Dmitry Torokhov
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 16+ messages in thread
From: Dmitry Torokhov @ 2022-10-18  5:41 UTC (permalink / raw)
  To: Bartosz Golaszewski, Linus Walleij
  Cc: Alexander Stein, linux-arm-kernel, linux-gpio, Andy Shevchenko,
	Daniel Thompson, linux-kernel, linux-mediatek

Bindings for Freescale Fast Ethernet Controller use a separate
property "phy-reset-active-high" to specify polarity of its phy
gpio line. To allow converting the driver to gpiod API we need
to add this quirk to gpiolib.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/gpio/gpiolib-of.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index 6faf0dc7bc31..c2a55ffb2b20 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -231,6 +231,33 @@ static void of_gpio_flags_quirks(const struct device_node *np,
 	    !strcmp(propname, "snps,reset-gpio") &&
 	    of_property_read_bool(np, "snps,reset-active-low"))
 		*flags |= OF_GPIO_ACTIVE_LOW;
+
+	/*
+	 * Freescale Fast Ethernet Controller uses a separate property to
+	 * describe polarity of the phy reset line.
+	 */
+	if (IS_ENABLED(CONFIG_FEC)) {
+		static const char * const fec_devices[] = {
+			"fsl,imx25-fec",
+			"fsl,imx27-fec",
+			"fsl,imx28-fec",
+			"fsl,imx6q-fec",
+			"fsl,mvf600-fec",
+			"fsl,imx6sx-fec",
+			"fsl,imx6ul-fec",
+			"fsl,imx8mq-fec",
+			"fsl,imx8qm-fec",
+			"fsl,s32v234-fec",
+			NULL
+		};
+
+		if (!strcmp(propname, "phy-reset-gpios") &&
+		    of_device_compatible_match(np, fec_devices)) {
+			bool active_high = of_property_read_bool(np,
+						"phy-reset-active-high");
+			of_gpio_quirk_polarity(np, active_high, flags);
+		}
+	}
 }
 
 /**

-- 
b4 0.11.0-dev-5166b

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH v3 10/10] gpiolib: of: add a quirk for reset line polarity for Himax LCDs
  2022-10-18  5:41 [PATCH v3 00/10] gpiolib: more quirks to handle legacy names Dmitry Torokhov
                   ` (8 preceding siblings ...)
  2022-10-18  5:41 ` [PATCH v3 09/10] gpiolib: of: add quirk for phy reset polarity for Freescale Ethernet Dmitry Torokhov
@ 2022-10-18  5:41 ` Dmitry Torokhov
  2022-10-18 12:31 ` [PATCH v3 00/10] gpiolib: more quirks to handle legacy names Andy Shevchenko
  2022-10-20 11:58 ` Bartosz Golaszewski
  11 siblings, 0 replies; 16+ messages in thread
From: Dmitry Torokhov @ 2022-10-18  5:41 UTC (permalink / raw)
  To: Bartosz Golaszewski, Linus Walleij
  Cc: Alexander Stein, linux-arm-kernel, linux-gpio, Andy Shevchenko,
	Daniel Thompson, linux-kernel, linux-mediatek

Existing DTS that use legacy (non-standard) property name for the reset
line "gpios-reset" also specify incorrect polarity (0 which maps to
"active high"). Add a quirk to force polarity to "active low" so that
once driver is converted to gpiod API that pays attention to line
polarity it will work properly.

Reviewed-by: Linus Walleij <linus.walleij@linaro.org>
Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---
 drivers/gpio/gpiolib-of.c | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/drivers/gpio/gpiolib-of.c b/drivers/gpio/gpiolib-of.c
index c2a55ffb2b20..52616848a37c 100644
--- a/drivers/gpio/gpiolib-of.c
+++ b/drivers/gpio/gpiolib-of.c
@@ -152,11 +152,47 @@ static void of_gpio_quirk_polarity(const struct device_node *np,
 	}
 }
 
+/*
+ * This quirk does static polarity overrides in cases where existing
+ * DTS specified incorrect polarity.
+ */
+static void of_gpio_try_fixup_polarity(const struct device_node *np,
+				       const char *propname,
+				       enum of_gpio_flags *flags)
+{
+	static const struct {
+		const char *compatible;
+		const char *propname;
+		bool active_high;
+	} gpios[] = {
+#if !IS_ENABLED(CONFIG_LCD_HX8357)
+		/*
+		 * Himax LCD controllers used incorrectly named
+		 * "gpios-reset" property and also specified wrong
+		 * polarity.
+		 */
+		{ "himax,hx8357",	"gpios-reset",	false },
+		{ "himax,hx8369",	"gpios-reset",	false },
+#endif
+	};
+	unsigned int i;
+
+	for (i = 0; i < ARRAY_SIZE(gpios); i++) {
+		if (of_device_is_compatible(np, gpios[i].compatible) &&
+		    !strcmp(propname, gpios[i].propname)) {
+			of_gpio_quirk_polarity(np, gpios[i].active_high, flags);
+			break;
+		}
+	}
+}
+
 static void of_gpio_flags_quirks(const struct device_node *np,
 				 const char *propname,
 				 enum of_gpio_flags *flags,
 				 int index)
 {
+	of_gpio_try_fixup_polarity(np, propname, flags);
+
 	/*
 	 * Some GPIO fixed regulator quirks.
 	 * Note that active low is the default.

-- 
b4 0.11.0-dev-5166b

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH v3 00/10] gpiolib: more quirks to handle legacy names
  2022-10-18  5:41 [PATCH v3 00/10] gpiolib: more quirks to handle legacy names Dmitry Torokhov
                   ` (9 preceding siblings ...)
  2022-10-18  5:41 ` [PATCH v3 10/10] gpiolib: of: add a quirk for reset line polarity for Himax LCDs Dmitry Torokhov
@ 2022-10-18 12:31 ` Andy Shevchenko
  2022-10-19 10:56   ` Linus Walleij
  2022-10-20 11:58 ` Bartosz Golaszewski
  11 siblings, 1 reply; 16+ messages in thread
From: Andy Shevchenko @ 2022-10-18 12:31 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Bartosz Golaszewski, Linus Walleij, Alexander Stein,
	linux-arm-kernel, linux-gpio, Daniel Thompson, linux-kernel,
	linux-mediatek

On Mon, Oct 17, 2022 at 10:41:01PM -0700, Dmitry Torokhov wrote:
> In preparation to converting several drivers to gpiod API, and to keep
> existing DTS working, this series adds additional quirks to locate
> gpio lines with legacy names.
> 
> Additionally the quirk handling has been reworked (once again) to pull
> all simple renames (ones that do not involve change of indices or other
> complex manipulations) into a single quirk with a table containing
> transformations. This should make adding new quirks easier.
> When using legacy names gpiolib will emit a message to nudge users to
> update DTSes (when possible).
> 
> Note that the last patch requires the following change from the OF tree:
> 
>         88269151be67 ("of: base: make of_device_compatible_match() accept const device node")
> 
> The change is also available in mainline - it has been merged in 6.1
> merge window.

I was wondering if we can use the approach that ACPI chose for itself,
i.e.  the separate data that can be filled by the corresponding driver
and then GPIO OF common code may use it. In that case each driver knows
the exact list of compatible strings and associated quirks.

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v3 00/10] gpiolib: more quirks to handle legacy names
  2022-10-18 12:31 ` [PATCH v3 00/10] gpiolib: more quirks to handle legacy names Andy Shevchenko
@ 2022-10-19 10:56   ` Linus Walleij
  2022-10-19 11:16     ` Andy Shevchenko
  0 siblings, 1 reply; 16+ messages in thread
From: Linus Walleij @ 2022-10-19 10:56 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Dmitry Torokhov, Bartosz Golaszewski, Alexander Stein,
	linux-arm-kernel, linux-gpio, Daniel Thompson, linux-kernel,
	linux-mediatek

On Tue, Oct 18, 2022 at 2:32 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> On Mon, Oct 17, 2022 at 10:41:01PM -0700, Dmitry Torokhov wrote:
> > In preparation to converting several drivers to gpiod API, and to keep
> > existing DTS working, this series adds additional quirks to locate
> > gpio lines with legacy names.
> >
> > Additionally the quirk handling has been reworked (once again) to pull
> > all simple renames (ones that do not involve change of indices or other
> > complex manipulations) into a single quirk with a table containing
> > transformations. This should make adding new quirks easier.
> > When using legacy names gpiolib will emit a message to nudge users to
> > update DTSes (when possible).
> >
> > Note that the last patch requires the following change from the OF tree:
> >
> >         88269151be67 ("of: base: make of_device_compatible_match() accept const device node")
> >
> > The change is also available in mainline - it has been merged in 6.1
> > merge window.
>
> I was wondering if we can use the approach that ACPI chose for itself,
> i.e.  the separate data that can be filled by the corresponding driver
> and then GPIO OF common code may use it. In that case each driver knows
> the exact list of compatible strings and associated quirks.

I actually deliverately chose the other way around, to centralize all quirks,
so that drivers look nice and simple and the ugly historical errors of the
device tree be hidden away in gpiolib-of.c.

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v3 00/10] gpiolib: more quirks to handle legacy names
  2022-10-19 10:56   ` Linus Walleij
@ 2022-10-19 11:16     ` Andy Shevchenko
  2022-10-20  8:00       ` Linus Walleij
  0 siblings, 1 reply; 16+ messages in thread
From: Andy Shevchenko @ 2022-10-19 11:16 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Dmitry Torokhov, Bartosz Golaszewski, Alexander Stein,
	linux-arm-kernel, linux-gpio, Daniel Thompson, linux-kernel,
	linux-mediatek

On Wed, Oct 19, 2022 at 12:56:31PM +0200, Linus Walleij wrote:
> On Tue, Oct 18, 2022 at 2:32 PM Andy Shevchenko
> <andriy.shevchenko@linux.intel.com> wrote:
> > On Mon, Oct 17, 2022 at 10:41:01PM -0700, Dmitry Torokhov wrote:
> > > In preparation to converting several drivers to gpiod API, and to keep
> > > existing DTS working, this series adds additional quirks to locate
> > > gpio lines with legacy names.
> > >
> > > Additionally the quirk handling has been reworked (once again) to pull
> > > all simple renames (ones that do not involve change of indices or other
> > > complex manipulations) into a single quirk with a table containing
> > > transformations. This should make adding new quirks easier.
> > > When using legacy names gpiolib will emit a message to nudge users to
> > > update DTSes (when possible).
> > >
> > > Note that the last patch requires the following change from the OF tree:
> > >
> > >         88269151be67 ("of: base: make of_device_compatible_match() accept const device node")
> > >
> > > The change is also available in mainline - it has been merged in 6.1
> > > merge window.
> >
> > I was wondering if we can use the approach that ACPI chose for itself,
> > i.e.  the separate data that can be filled by the corresponding driver
> > and then GPIO OF common code may use it. In that case each driver knows
> > the exact list of compatible strings and associated quirks.
> 
> I actually deliverately chose the other way around, to centralize all quirks,
> so that drivers look nice and simple and the ugly historical errors of the
> device tree be hidden away in gpiolib-of.c.

This makes sense if and only if we may guarantee no quirks will appear in the
future. So, it may be true for DT, but I'm quite skeptical about ACPI...

-- 
With Best Regards,
Andy Shevchenko



^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v3 00/10] gpiolib: more quirks to handle legacy names
  2022-10-19 11:16     ` Andy Shevchenko
@ 2022-10-20  8:00       ` Linus Walleij
  0 siblings, 0 replies; 16+ messages in thread
From: Linus Walleij @ 2022-10-20  8:00 UTC (permalink / raw)
  To: Andy Shevchenko
  Cc: Dmitry Torokhov, Bartosz Golaszewski, Alexander Stein,
	linux-arm-kernel, linux-gpio, Daniel Thompson, linux-kernel,
	linux-mediatek

On Wed, Oct 19, 2022 at 1:16 PM Andy Shevchenko
<andriy.shevchenko@linux.intel.com> wrote:
> On Wed, Oct 19, 2022 at 12:56:31PM +0200, Linus Walleij wrote:
> > On Tue, Oct 18, 2022 at 2:32 PM Andy Shevchenko

> > > I was wondering if we can use the approach that ACPI chose for itself,
> > > i.e.  the separate data that can be filled by the corresponding driver
> > > and then GPIO OF common code may use it. In that case each driver knows
> > > the exact list of compatible strings and associated quirks.
> >
> > I actually deliverately chose the other way around, to centralize all quirks,
> > so that drivers look nice and simple and the ugly historical errors of the
> > device tree be hidden away in gpiolib-of.c.
>
> This makes sense if and only if we may guarantee no quirks will appear in the
> future. So, it may be true for DT, but I'm quite skeptical about ACPI...

Right, the idea is to stop more idiomatic DT bindings from coming into existance
by review and formal verification of the reviewed bindings by using
YAML schemas.

ACPI is somewhat lacking public review of "bindings" and DSDT tables, and I
don't know if there is some counterpart to the schema validation, so that
makes for more new bugs. But maybe ACPI has some tricks up its sleeve that I
don't know about. To me it seems like bugs in ACPI are discovered by developers
after the devices are already produced :/

There are bindings and device trees which lack public review too, most notably
Apple Mac, so especially for them we are redefining new bindings and
who knows, maybe Apple will pick them up eventually!

Yours,
Linus Walleij

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH v3 00/10] gpiolib: more quirks to handle legacy names
  2022-10-18  5:41 [PATCH v3 00/10] gpiolib: more quirks to handle legacy names Dmitry Torokhov
                   ` (10 preceding siblings ...)
  2022-10-18 12:31 ` [PATCH v3 00/10] gpiolib: more quirks to handle legacy names Andy Shevchenko
@ 2022-10-20 11:58 ` Bartosz Golaszewski
  11 siblings, 0 replies; 16+ messages in thread
From: Bartosz Golaszewski @ 2022-10-20 11:58 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Linus Walleij, Alexander Stein, linux-arm-kernel, linux-gpio,
	Andy Shevchenko, Daniel Thompson, linux-kernel, linux-mediatek

On Tue, Oct 18, 2022 at 7:41 AM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:
>
> In preparation to converting several drivers to gpiod API, and to keep
> existing DTS working, this series adds additional quirks to locate
> gpio lines with legacy names.
>
> Additionally the quirk handling has been reworked (once again) to pull
> all simple renames (ones that do not involve change of indices or other
> complex manipulations) into a single quirk with a table containing
> transformations. This should make adding new quirks easier.
> When using legacy names gpiolib will emit a message to nudge users to
> update DTSes (when possible).
>
> Note that the last patch requires the following change from the OF tree:
>
>         88269151be67 ("of: base: make of_device_compatible_match() accept const device node")
>
> The change is also available in mainline - it has been merged in 6.1
> merge window.
>
> Thanks.
>
> To: Linus Walleij <linus.walleij@linaro.org>
> To: Bartosz Golaszewski <brgl@bgdev.pl>
> Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> Cc: Alexander Stein <alexander.stein@ew.tq-group.com>
> Cc: Daniel Thompson <daniel.thompson@linaro.org>
> Cc: linux-gpio@vger.kernel.org
> Cc: linux-kernel@vger.kernel.org
> Cc: linux-arm-kernel@lists.infradead.org
> Cc: linux-mediatek@lists.infradead.org
>

I applied the entire series.

Bartosz

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2022-10-20 11:59 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-10-18  5:41 [PATCH v3 00/10] gpiolib: more quirks to handle legacy names Dmitry Torokhov
2022-10-18  5:41 ` [PATCH v3 01/10] gpiolib: of: add a quirk for legacy names in Mediatek mt2701-cs42448 Dmitry Torokhov
2022-10-18  5:41 ` [PATCH v3 02/10] gpiolib: of: consolidate simple renames into a single quirk Dmitry Torokhov
2022-10-18  5:41 ` [PATCH v3 03/10] gpiolib: of: tighten selection of gpio renaming quirks Dmitry Torokhov
2022-10-18  5:41 ` [PATCH v3 04/10] gpiolib: of: add quirk for locating reset lines with legacy bindings Dmitry Torokhov
2022-10-18  5:41 ` [PATCH v3 05/10] gpiolib: of: add a quirk for reset line for Marvell NFC controller Dmitry Torokhov
2022-10-18  5:41 ` [PATCH v3 06/10] gpiolib: of: add a quirk for reset line for Cirrus CS42L56 codec Dmitry Torokhov
2022-10-18  5:41 ` [PATCH v3 07/10] gpiolib: of: add a quirk for legacy names in MOXA ART RTC Dmitry Torokhov
2022-10-18  5:41 ` [PATCH v3 08/10] gpiolib: of: factor out code overriding gpio line polarity Dmitry Torokhov
2022-10-18  5:41 ` [PATCH v3 09/10] gpiolib: of: add quirk for phy reset polarity for Freescale Ethernet Dmitry Torokhov
2022-10-18  5:41 ` [PATCH v3 10/10] gpiolib: of: add a quirk for reset line polarity for Himax LCDs Dmitry Torokhov
2022-10-18 12:31 ` [PATCH v3 00/10] gpiolib: more quirks to handle legacy names Andy Shevchenko
2022-10-19 10:56   ` Linus Walleij
2022-10-19 11:16     ` Andy Shevchenko
2022-10-20  8:00       ` Linus Walleij
2022-10-20 11:58 ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).