Linux-ACPI Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH 00/11] Add support for software nodes to gpiolib
@ 2019-09-11  7:52 Dmitry Torokhov
  2019-09-11  7:52 ` [PATCH 09/11] gpiolib: of: tease apart acpi_find_gpio() Dmitry Torokhov
                   ` (3 more replies)
  0 siblings, 4 replies; 9+ messages in thread
From: Dmitry Torokhov @ 2019-09-11  7:52 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Andy Shevchenko, Mika Westerberg, linux-kernel, linux-gpio,
	Andrew Lunn, Andrzej Hajda, Bartosz Golaszewski, Daniel Vetter,
	David Airlie, David S. Miller, Florian Fainelli, Heiner Kallweit,
	Jernej Skrabec, Jonas Karlman, Laurent Pinchart, Neil Armstrong,
	Russell King, dri-devel, linux-acpi, netdev

This series attempts to add support for software nodes to gpiolib, using
software node references that were introduced recently. This allows us
to convert more drivers to the generic device properties and drop
support for custom platform data:

static const struct software_node gpio_bank_b_node = {
|-------.name = "B",
};

static const struct property_entry simone_key_enter_props[] = {
|-------PROPERTY_ENTRY_U32("linux,code", KEY_ENTER),
|-------PROPERTY_ENTRY_STRING("label", "enter"),
|-------PROPERTY_ENTRY_REF("gpios", &gpio_bank_b_node, 123, GPIO_ACTIVE_LOW),
|-------{ }
};

If we agree in principle, I would like to have the very first 3 patches
in an immutable branch off maybe -rc8 so that it can be pulled into
individual subsystems so that patches switching various drivers to
fwnode_gpiod_get_index() could be applied.

Thanks,
Dmitry

Dmitry Torokhov (11):
  gpiolib: of: add a fallback for wlf,reset GPIO name
  gpiolib: introduce devm_fwnode_gpiod_get_index()
  gpiolib: introduce fwnode_gpiod_get_index()
  net: phylink: switch to using fwnode_gpiod_get_index()
  net: mdio: switch to using fwnode_gpiod_get_index()
  drm/bridge: ti-tfp410: switch to using fwnode_gpiod_get_index()
  gpliolib: make fwnode_get_named_gpiod() static
  gpiolib: of: tease apart of_find_gpio()
  gpiolib: of: tease apart acpi_find_gpio()
  gpiolib: consolidate fwnode GPIO lookups
  gpiolib: add support for software nodes

 drivers/gpio/Makefile              |   1 +
 drivers/gpio/gpiolib-acpi.c        | 153 ++++++++++++++----------
 drivers/gpio/gpiolib-acpi.h        |  21 ++--
 drivers/gpio/gpiolib-devres.c      |  33 ++----
 drivers/gpio/gpiolib-of.c          | 159 ++++++++++++++-----------
 drivers/gpio/gpiolib-of.h          |  26 ++--
 drivers/gpio/gpiolib-swnode.c      |  92 +++++++++++++++
 drivers/gpio/gpiolib-swnode.h      |  13 ++
 drivers/gpio/gpiolib.c             | 184 ++++++++++++++++-------------
 drivers/gpu/drm/bridge/ti-tfp410.c |   4 +-
 drivers/net/phy/mdio_bus.c         |   4 +-
 drivers/net/phy/phylink.c          |   4 +-
 include/linux/gpio/consumer.h      |  53 ++++++---
 13 files changed, 471 insertions(+), 276 deletions(-)
 create mode 100644 drivers/gpio/gpiolib-swnode.c
 create mode 100644 drivers/gpio/gpiolib-swnode.h

-- 
2.23.0.162.g0b9fbb3734-goog


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

* [PATCH 09/11] gpiolib: of: tease apart acpi_find_gpio()
  2019-09-11  7:52 [PATCH 00/11] Add support for software nodes to gpiolib Dmitry Torokhov
@ 2019-09-11  7:52 ` Dmitry Torokhov
  2019-09-11 17:12   ` Andy Shevchenko
  2019-09-11  7:52 ` [PATCH 10/11] gpiolib: consolidate fwnode GPIO lookups Dmitry Torokhov
                   ` (2 subsequent siblings)
  3 siblings, 1 reply; 9+ messages in thread
From: Dmitry Torokhov @ 2019-09-11  7:52 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Andy Shevchenko, Mika Westerberg, linux-kernel, linux-gpio,
	Bartosz Golaszewski, linux-acpi

Tease apart acpi_find_gpio() into common function that works on the
firmware node, and a fallback handler that works on the ACPI device
structure, so that we can later use acpi_find_gpio() in
fwnode_gpiod_get_index().

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---

 drivers/gpio/gpiolib-acpi.c | 77 +++++++++++++++++++++++++------------
 drivers/gpio/gpiolib-acpi.h | 17 +++++++-
 drivers/gpio/gpiolib.c      |  8 +++-
 3 files changed, 74 insertions(+), 28 deletions(-)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 2b6fdc9947f7..8174db1bc02e 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -728,29 +728,35 @@ static struct gpio_desc *acpi_get_gpiod_by_index(struct acpi_device *adev,
 	return ret ? ERR_PTR(ret) : lookup.desc;
 }
 
-static bool acpi_can_fallback_to_crs(struct acpi_device *adev,
-				     const char *con_id)
+static int acpi_finalize_gpio_lookup(struct acpi_gpio_info *info,
+				     enum gpiod_flags *dflags,
+				     unsigned long *lookupflags)
 {
-	/* Never allow fallback if the device has properties */
-	if (acpi_dev_has_props(adev) || adev->driver_gpios)
-		return false;
+	if (info->gpioint &&
+	    (*dflags == GPIOD_OUT_LOW || *dflags == GPIOD_OUT_HIGH)) {
+		dev_dbg(&info->adev->dev,
+			"refusing GpioInt() entry when doing GPIOD_OUT_* lookup\n");
+		return -ENOENT;
+	}
 
-	return con_id == NULL;
+	acpi_gpio_update_gpiod_flags(dflags, info);
+	acpi_gpio_update_gpiod_lookup_flags(lookupflags, info);
+
+	return 0;
 }
 
-struct gpio_desc *acpi_find_gpio(struct device *dev,
-				 const char *con_id,
-				 unsigned int idx,
+struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode,
+				 const char *con_id, unsigned int idx,
 				 enum gpiod_flags *dflags,
 				 unsigned long *lookupflags)
 {
-	struct acpi_device *adev = ACPI_COMPANION(dev);
 	struct acpi_gpio_info info;
 	struct gpio_desc *desc;
 	char propname[32];
 	int i;
+	int error;
 
-	/* Try first from _DSD */
+	/* Try GPIOs from _DSD */
 	for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) {
 		if (con_id) {
 			snprintf(propname, sizeof(propname), "%s-%s",
@@ -760,31 +766,52 @@ struct gpio_desc *acpi_find_gpio(struct device *dev,
 				 gpio_suffixes[i]);
 		}
 
-		desc = acpi_get_gpiod_by_index(adev, propname, idx, &info);
+		desc = acpi_node_get_gpiod(fwnode, propname, idx, &info);
 		if (!IS_ERR(desc))
 			break;
 		if (PTR_ERR(desc) == -EPROBE_DEFER)
 			return ERR_CAST(desc);
 	}
 
-	/* Then from plain _CRS GPIOs */
-	if (IS_ERR(desc)) {
-		if (!acpi_can_fallback_to_crs(adev, con_id))
-			return ERR_PTR(-ENOENT);
-
-		desc = acpi_get_gpiod_by_index(adev, NULL, idx, &info);
-		if (IS_ERR(desc))
-			return desc;
+	if (!IS_ERR(desc)) {
+		error = acpi_finalize_gpio_lookup(&info, dflags, lookupflags);
+		if (error)
+			return ERR_PTR(error);
 	}
 
-	if (info.gpioint &&
-	    (*dflags == GPIOD_OUT_LOW || *dflags == GPIOD_OUT_HIGH)) {
-		dev_dbg(dev, "refusing GpioInt() entry when doing GPIOD_OUT_* lookup\n");
+	return desc;
+}
+
+static bool acpi_can_fallback_to_crs(struct acpi_device *adev,
+				     const char *con_id)
+{
+	/* Never allow fallback if the device has properties */
+	if (acpi_dev_has_props(adev) || adev->driver_gpios)
+		return false;
+
+	return con_id == NULL;
+}
+
+struct gpio_desc *acpi_find_gpio_fallback(struct acpi_device *adev,
+					  const char *con_id, unsigned int idx,
+					  enum gpiod_flags *dflags,
+					  unsigned long *lookupflags)
+{
+	struct acpi_gpio_info info;
+	struct gpio_desc *desc;
+	int error;
+
+	/* Then from plain _CRS GPIOs */
+	if (!acpi_can_fallback_to_crs(adev, con_id))
 		return ERR_PTR(-ENOENT);
+
+	desc = acpi_get_gpiod_by_index(adev, NULL, idx, &info);
+	if (!IS_ERR(desc)) {
+		error = acpi_finalize_gpio_lookup(&info, dflags, lookupflags);
+		if (error)
+			return ERR_PTR(error);
 	}
 
-	acpi_gpio_update_gpiod_flags(dflags, &info);
-	acpi_gpio_update_gpiod_lookup_flags(lookupflags, &info);
 	return desc;
 }
 
diff --git a/drivers/gpio/gpiolib-acpi.h b/drivers/gpio/gpiolib-acpi.h
index 1c6d65cf0629..ea97a3822116 100644
--- a/drivers/gpio/gpiolib-acpi.h
+++ b/drivers/gpio/gpiolib-acpi.h
@@ -9,6 +9,7 @@
 #define GPIOLIB_ACPI_H
 
 struct acpi_device;
+struct fwnode_handle;
 
 /**
  * struct acpi_gpio_info - ACPI GPIO specific information
@@ -42,11 +43,16 @@ int acpi_gpio_update_gpiod_flags(enum gpiod_flags *flags,
 int acpi_gpio_update_gpiod_lookup_flags(unsigned long *lookupflags,
 					struct acpi_gpio_info *info);
 
-struct gpio_desc *acpi_find_gpio(struct device *dev,
+struct gpio_desc *acpi_find_gpio(struct fwnode_handle *fwnode,
 				 const char *con_id,
 				 unsigned int idx,
 				 enum gpiod_flags *dflags,
 				 unsigned long *lookupflags);
+struct gpio_desc *acpi_find_gpio_fallback(struct acpi_device *adev,
+					  const char *con_id,
+					  unsigned int idx,
+					  enum gpiod_flags *dflags,
+					  unsigned long *lookupflags);
 struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode,
 				      const char *propname, int index,
 				      struct acpi_gpio_info *info);
@@ -75,13 +81,20 @@ acpi_gpio_update_gpiod_lookup_flags(unsigned long *lookupflags,
 }
 
 static inline struct gpio_desc *
-acpi_find_gpio(struct device *dev, const char *con_id,
+acpi_find_gpio(struct firmware_node *fwnode, const char *con_id,
 	       unsigned int idx, enum gpiod_flags *dflags,
 	       unsigned long *lookupflags)
 {
 	return ERR_PTR(-ENOENT);
 }
 static inline struct gpio_desc *
+acpi_find_gpio_fallback(struct acpi_device *adev, const char *con_id,
+			unsigned int idx, enum gpiod_flags *dflags,
+			unsigned long *lookupflags)
+{
+	return ERR_PTR(-ENOENT);
+}
+static inline struct gpio_desc *
 acpi_node_get_gpiod(struct fwnode_handle *fwnode, const char *propname,
 		    int index, struct acpi_gpio_info *info)
 {
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 1248e61f9a23..2d8dd67ab03d 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -4570,7 +4570,13 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
 
 		} else if (ACPI_COMPANION(dev)) {
 			dev_dbg(dev, "using ACPI for GPIO lookup\n");
-			desc = acpi_find_gpio(dev, con_id, idx, &flags, &lookupflags);
+			desc = acpi_find_gpio(dev_fwnode(dev), con_id, idx,
+					      &flags, &lookupflags);
+			if (desc == ERR_PTR(-ENOENT))
+				desc = acpi_find_gpio_fallback(
+						ACPI_COMPANION(dev),
+						con_id, idx,
+						&flags, &lookupflags);
 		}
 	}
 
-- 
2.23.0.162.g0b9fbb3734-goog


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

* [PATCH 10/11] gpiolib: consolidate fwnode GPIO lookups
  2019-09-11  7:52 [PATCH 00/11] Add support for software nodes to gpiolib Dmitry Torokhov
  2019-09-11  7:52 ` [PATCH 09/11] gpiolib: of: tease apart acpi_find_gpio() Dmitry Torokhov
@ 2019-09-11  7:52 ` Dmitry Torokhov
  2019-09-11 17:13 ` [PATCH 00/11] Add support for software nodes to gpiolib Andy Shevchenko
  2019-09-12  9:55 ` Linus Walleij
  3 siblings, 0 replies; 9+ messages in thread
From: Dmitry Torokhov @ 2019-09-11  7:52 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Andy Shevchenko, Mika Westerberg, linux-kernel, linux-gpio,
	Bartosz Golaszewski, linux-acpi

Ensure that all paths to obtain/look up GPIOD from generic
consumer-visible APIs go through the new fwnode_locate_gpiod(), so that
we can easily extend the support for new firmware mechanisms.

Signed-off-by: Dmitry Torokhov <dmitry.torokhov@gmail.com>
---

 drivers/gpio/gpiolib-acpi.c |  88 +++++++++++++++----------------
 drivers/gpio/gpiolib-acpi.h |  10 ----
 drivers/gpio/gpiolib.c      | 100 ++++++++++++------------------------
 3 files changed, 77 insertions(+), 121 deletions(-)

diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c
index 8174db1bc02e..13907add5027 100644
--- a/drivers/gpio/gpiolib-acpi.c
+++ b/drivers/gpio/gpiolib-acpi.c
@@ -728,6 +728,50 @@ static struct gpio_desc *acpi_get_gpiod_by_index(struct acpi_device *adev,
 	return ret ? ERR_PTR(ret) : lookup.desc;
 }
 
+/**
+ * acpi_node_get_gpiod() - get a GPIO descriptor from ACPI resources
+ * @fwnode: pointer to an ACPI firmware node to get the GPIO information from
+ * @propname: Property name of the GPIO
+ * @index: index of GpioIo/GpioInt resource (starting from %0)
+ * @info: info pointer to fill in (optional)
+ *
+ * If @fwnode is an ACPI device object, call acpi_get_gpiod_by_index() for it.
+ * Otherwise (i.e. it is a data-only non-device object), use the property-based
+ * GPIO lookup to get to the GPIO resource with the relevant information and use
+ * that to obtain the GPIO descriptor to return.
+ *
+ * If the GPIO cannot be translated or there is an error an ERR_PTR is
+ * returned.
+ */
+static struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode,
+					     const char *propname, int index,
+					     struct acpi_gpio_info *info)
+{
+	struct acpi_gpio_lookup lookup;
+	struct acpi_device *adev;
+	int ret;
+
+	adev = to_acpi_device_node(fwnode);
+	if (adev)
+		return acpi_get_gpiod_by_index(adev, propname, index, info);
+
+	if (!is_acpi_data_node(fwnode))
+		return ERR_PTR(-ENODEV);
+
+	if (!propname)
+		return ERR_PTR(-EINVAL);
+
+	memset(&lookup, 0, sizeof(lookup));
+	lookup.index = index;
+
+	ret = acpi_gpio_property_lookup(fwnode, propname, index, &lookup);
+	if (ret)
+		return ERR_PTR(ret);
+
+	ret = acpi_gpio_resource_lookup(&lookup, info);
+	return ret ? ERR_PTR(ret) : lookup.desc;
+}
+
 static int acpi_finalize_gpio_lookup(struct acpi_gpio_info *info,
 				     enum gpiod_flags *dflags,
 				     unsigned long *lookupflags)
@@ -815,50 +859,6 @@ struct gpio_desc *acpi_find_gpio_fallback(struct acpi_device *adev,
 	return desc;
 }
 
-/**
- * acpi_node_get_gpiod() - get a GPIO descriptor from ACPI resources
- * @fwnode: pointer to an ACPI firmware node to get the GPIO information from
- * @propname: Property name of the GPIO
- * @index: index of GpioIo/GpioInt resource (starting from %0)
- * @info: info pointer to fill in (optional)
- *
- * If @fwnode is an ACPI device object, call acpi_get_gpiod_by_index() for it.
- * Otherwise (i.e. it is a data-only non-device object), use the property-based
- * GPIO lookup to get to the GPIO resource with the relevant information and use
- * that to obtain the GPIO descriptor to return.
- *
- * If the GPIO cannot be translated or there is an error an ERR_PTR is
- * returned.
- */
-struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode,
-				      const char *propname, int index,
-				      struct acpi_gpio_info *info)
-{
-	struct acpi_gpio_lookup lookup;
-	struct acpi_device *adev;
-	int ret;
-
-	adev = to_acpi_device_node(fwnode);
-	if (adev)
-		return acpi_get_gpiod_by_index(adev, propname, index, info);
-
-	if (!is_acpi_data_node(fwnode))
-		return ERR_PTR(-ENODEV);
-
-	if (!propname)
-		return ERR_PTR(-EINVAL);
-
-	memset(&lookup, 0, sizeof(lookup));
-	lookup.index = index;
-
-	ret = acpi_gpio_property_lookup(fwnode, propname, index, &lookup);
-	if (ret)
-		return ERR_PTR(ret);
-
-	ret = acpi_gpio_resource_lookup(&lookup, info);
-	return ret ? ERR_PTR(ret) : lookup.desc;
-}
-
 /**
  * acpi_dev_gpio_irq_get() - Find GpioInt and translate it to Linux IRQ number
  * @adev: pointer to a ACPI device to get IRQ from
diff --git a/drivers/gpio/gpiolib-acpi.h b/drivers/gpio/gpiolib-acpi.h
index ea97a3822116..047df1d5c7fa 100644
--- a/drivers/gpio/gpiolib-acpi.h
+++ b/drivers/gpio/gpiolib-acpi.h
@@ -53,10 +53,6 @@ struct gpio_desc *acpi_find_gpio_fallback(struct acpi_device *adev,
 					  unsigned int idx,
 					  enum gpiod_flags *dflags,
 					  unsigned long *lookupflags);
-struct gpio_desc *acpi_node_get_gpiod(struct fwnode_handle *fwnode,
-				      const char *propname, int index,
-				      struct acpi_gpio_info *info);
-
 int acpi_gpio_count(struct device *dev, const char *con_id);
 #else
 static inline void acpi_gpiochip_add(struct gpio_chip *chip) { }
@@ -94,12 +90,6 @@ acpi_find_gpio_fallback(struct acpi_device *adev, const char *con_id,
 {
 	return ERR_PTR(-ENOENT);
 }
-static inline struct gpio_desc *
-acpi_node_get_gpiod(struct fwnode_handle *fwnode, const char *propname,
-		    int index, struct acpi_gpio_info *info)
-{
-	return ERR_PTR(-ENXIO);
-}
 static inline int acpi_gpio_count(struct device *dev, const char *con_id)
 {
 	return -ENODEV;
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index 2d8dd67ab03d..6534dcd6e406 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -4314,44 +4314,27 @@ static int platform_gpio_count(struct device *dev, const char *con_id)
 	return count;
 }
 
-static struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
-						const char *propname, int index,
-						enum gpiod_flags dflags,
-						const char *label)
+static struct gpio_desc *fwnode_locate_gpiod(struct fwnode_handle *fwnode,
+					     struct device *dev,
+					     const char *con_id, int idx,
+					     enum gpiod_flags *flags,
+					     unsigned long *lookupflags)
 {
-	unsigned long lflags = GPIO_LOOKUP_FLAGS_DEFAULT;
 	struct gpio_desc *desc = ERR_PTR(-ENODEV);
-	int ret;
-
-	if (!fwnode)
-		return ERR_PTR(-EINVAL);
 
 	if (is_of_node(fwnode)) {
-		desc = gpiod_get_from_of_node(to_of_node(fwnode),
-					      propname, index,
-					      dflags,
-					      label);
-		return desc;
+		dev_dbg(dev, "using device tree for GPIO lookup\n");
+		desc = of_find_gpio(fwnode, con_id, idx, lookupflags);
+		if (desc == ERR_PTR(-ENOENT) && dev)
+			desc = of_find_gpio_fallback(dev, con_id, idx,
+						     lookupflags);
 	} else if (is_acpi_node(fwnode)) {
-		struct acpi_gpio_info info;
-
-		desc = acpi_node_get_gpiod(fwnode, propname, index, &info);
-		if (IS_ERR(desc))
-			return desc;
-
-		acpi_gpio_update_gpiod_flags(&dflags, &info);
-		acpi_gpio_update_gpiod_lookup_flags(&lflags, &info);
-	}
-
-	/* Currently only ACPI takes this path */
-	ret = gpiod_request(desc, label);
-	if (ret)
-		return ERR_PTR(ret);
-
-	ret = gpiod_configure_flags(desc, propname, lflags, dflags);
-	if (ret < 0) {
-		gpiod_put(desc);
-		return ERR_PTR(ret);
+		dev_dbg(dev, "using ACPI for GPIO lookup\n");
+		desc = acpi_find_gpio(fwnode, con_id, idx, flags, lookupflags);
+		if (desc == ERR_PTR(-ENOENT) && dev)
+			desc = acpi_find_gpio_fallback(ACPI_COMPANION(dev),
+						       con_id, idx,
+						       flags, lookupflags);
 	}
 
 	return desc;
@@ -4383,22 +4366,23 @@ struct gpio_desc *fwnode_gpiod_get_index(struct fwnode_handle *fwnode,
 					 enum gpiod_flags flags,
 					 const char *label)
 {
+	unsigned long lookupflags = GPIO_LOOKUP_FLAGS_DEFAULT;
 	struct gpio_desc *desc;
-	char prop_name[32]; /* 32 is max size of property name */
-	unsigned int i;
+	int error;
 
-	for (i = 0; i < ARRAY_SIZE(gpio_suffixes); i++) {
-		if (con_id)
-			snprintf(prop_name, sizeof(prop_name), "%s-%s",
-					    con_id, gpio_suffixes[i]);
-		else
-			snprintf(prop_name, sizeof(prop_name), "%s",
-					    gpio_suffixes[i]);
+	desc = fwnode_locate_gpiod(fwnode, NULL, con_id, index,
+				   &flags, &lookupflags);
+	if (IS_ERR(desc))
+		return desc;
 
-		desc = fwnode_get_named_gpiod(fwnode, prop_name, index, flags,
-					      label);
-		if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT))
-			break;
+	error = gpiod_request(desc, label);
+	if (error)
+		return ERR_PTR(error);
+
+	error = gpiod_configure_flags(desc, con_id, lookupflags, flags);
+	if (error < 0) {
+		gpiod_put(desc);
+		return ERR_PTR(error);
 	}
 
 	return desc;
@@ -4558,27 +4542,9 @@ struct gpio_desc *__must_check gpiod_get_index(struct device *dev,
 
 	dev_dbg(dev, "GPIO lookup for consumer %s\n", con_id);
 
-	if (dev) {
-		/* Using device tree? */
-		if (IS_ENABLED(CONFIG_OF) && dev->of_node) {
-			dev_dbg(dev, "using device tree for GPIO lookup\n");
-			desc = of_find_gpio(dev_fwnode(dev),
-					    con_id, idx, &lookupflags);
-			if (desc == ERR_PTR(-ENOENT))
-				desc = of_find_gpio_fallback(dev, con_id, idx,
-							     &lookupflags);
-
-		} else if (ACPI_COMPANION(dev)) {
-			dev_dbg(dev, "using ACPI for GPIO lookup\n");
-			desc = acpi_find_gpio(dev_fwnode(dev), con_id, idx,
-					      &flags, &lookupflags);
-			if (desc == ERR_PTR(-ENOENT))
-				desc = acpi_find_gpio_fallback(
-						ACPI_COMPANION(dev),
-						con_id, idx,
-						&flags, &lookupflags);
-		}
-	}
+	if (dev)
+		desc = fwnode_locate_gpiod(dev_fwnode(dev), dev, con_id, idx,
+					   &flags, &lookupflags);
 
 	/*
 	 * Either we are not using DT or ACPI, or their lookup did not return
-- 
2.23.0.162.g0b9fbb3734-goog


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

* Re: [PATCH 09/11] gpiolib: of: tease apart acpi_find_gpio()
  2019-09-11  7:52 ` [PATCH 09/11] gpiolib: of: tease apart acpi_find_gpio() Dmitry Torokhov
@ 2019-09-11 17:12   ` Andy Shevchenko
  0 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2019-09-11 17:12 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Linus Walleij, Mika Westerberg, linux-kernel, linux-gpio,
	Bartosz Golaszewski, linux-acpi

On Wed, Sep 11, 2019 at 12:52:13AM -0700, Dmitry Torokhov wrote:
> Tease apart acpi_find_gpio() into common function that works on the
> firmware node, and a fallback handler that works on the ACPI device
> structure, so that we can later use acpi_find_gpio() in
> fwnode_gpiod_get_index().

Title should start with "gpiolib: acpi:"


I review from this one later on.

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 00/11] Add support for software nodes to gpiolib
  2019-09-11  7:52 [PATCH 00/11] Add support for software nodes to gpiolib Dmitry Torokhov
  2019-09-11  7:52 ` [PATCH 09/11] gpiolib: of: tease apart acpi_find_gpio() Dmitry Torokhov
  2019-09-11  7:52 ` [PATCH 10/11] gpiolib: consolidate fwnode GPIO lookups Dmitry Torokhov
@ 2019-09-11 17:13 ` Andy Shevchenko
  2019-09-12  9:55 ` Linus Walleij
  3 siblings, 0 replies; 9+ messages in thread
From: Andy Shevchenko @ 2019-09-11 17:13 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Linus Walleij, Mika Westerberg, linux-kernel, linux-gpio,
	Andrew Lunn, Andrzej Hajda, Bartosz Golaszewski, Daniel Vetter,
	David Airlie, David S. Miller, Florian Fainelli, Heiner Kallweit,
	Jernej Skrabec, Jonas Karlman, Laurent Pinchart, Neil Armstrong,
	Russell King, dri-devel, linux-acpi, netdev

On Wed, Sep 11, 2019 at 12:52:04AM -0700, Dmitry Torokhov wrote:
> This series attempts to add support for software nodes to gpiolib, using
> software node references that were introduced recently. This allows us
> to convert more drivers to the generic device properties and drop
> support for custom platform data:
> 
> static const struct software_node gpio_bank_b_node = {
> |-------.name = "B",
> };
> 
> static const struct property_entry simone_key_enter_props[] = {
> |-------PROPERTY_ENTRY_U32("linux,code", KEY_ENTER),
> |-------PROPERTY_ENTRY_STRING("label", "enter"),
> |-------PROPERTY_ENTRY_REF("gpios", &gpio_bank_b_node, 123, GPIO_ACTIVE_LOW),
> |-------{ }
> };
> 
> If we agree in principle, I would like to have the very first 3 patches
> in an immutable branch off maybe -rc8 so that it can be pulled into
> individual subsystems so that patches switching various drivers to
> fwnode_gpiod_get_index() could be applied.

FWIW,
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>

for patches 1-8 after addressing minor issues.
I'll review the rest later on.

> 
> Thanks,
> Dmitry
> 
> Dmitry Torokhov (11):
>   gpiolib: of: add a fallback for wlf,reset GPIO name
>   gpiolib: introduce devm_fwnode_gpiod_get_index()
>   gpiolib: introduce fwnode_gpiod_get_index()
>   net: phylink: switch to using fwnode_gpiod_get_index()
>   net: mdio: switch to using fwnode_gpiod_get_index()
>   drm/bridge: ti-tfp410: switch to using fwnode_gpiod_get_index()
>   gpliolib: make fwnode_get_named_gpiod() static
>   gpiolib: of: tease apart of_find_gpio()
>   gpiolib: of: tease apart acpi_find_gpio()
>   gpiolib: consolidate fwnode GPIO lookups
>   gpiolib: add support for software nodes
> 
>  drivers/gpio/Makefile              |   1 +
>  drivers/gpio/gpiolib-acpi.c        | 153 ++++++++++++++----------
>  drivers/gpio/gpiolib-acpi.h        |  21 ++--
>  drivers/gpio/gpiolib-devres.c      |  33 ++----
>  drivers/gpio/gpiolib-of.c          | 159 ++++++++++++++-----------
>  drivers/gpio/gpiolib-of.h          |  26 ++--
>  drivers/gpio/gpiolib-swnode.c      |  92 +++++++++++++++
>  drivers/gpio/gpiolib-swnode.h      |  13 ++
>  drivers/gpio/gpiolib.c             | 184 ++++++++++++++++-------------
>  drivers/gpu/drm/bridge/ti-tfp410.c |   4 +-
>  drivers/net/phy/mdio_bus.c         |   4 +-
>  drivers/net/phy/phylink.c          |   4 +-
>  include/linux/gpio/consumer.h      |  53 ++++++---
>  13 files changed, 471 insertions(+), 276 deletions(-)
>  create mode 100644 drivers/gpio/gpiolib-swnode.c
>  create mode 100644 drivers/gpio/gpiolib-swnode.h
> 
> -- 
> 2.23.0.162.g0b9fbb3734-goog
> 

-- 
With Best Regards,
Andy Shevchenko



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

* Re: [PATCH 00/11] Add support for software nodes to gpiolib
  2019-09-11  7:52 [PATCH 00/11] Add support for software nodes to gpiolib Dmitry Torokhov
                   ` (2 preceding siblings ...)
  2019-09-11 17:13 ` [PATCH 00/11] Add support for software nodes to gpiolib Andy Shevchenko
@ 2019-09-12  9:55 ` Linus Walleij
  2019-09-17  0:22   ` Dmitry Torokhov
  3 siblings, 1 reply; 9+ messages in thread
From: Linus Walleij @ 2019-09-12  9:55 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Andy Shevchenko, Mika Westerberg, linux-kernel,
	open list:GPIO SUBSYSTEM, Andrew Lunn, Andrzej Hajda,
	Bartosz Golaszewski, Daniel Vetter, David Airlie,
	David S. Miller, Florian Fainelli, Heiner Kallweit,
	Jernej Skrabec, Jonas Karlman, Laurent Pinchart, Neil Armstrong,
	Russell King, open list:DRM PANEL DRIVERS,
	ACPI Devel Maling List, netdev

On Wed, Sep 11, 2019 at 8:52 AM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:

> If we agree in principle, I would like to have the very first 3 patches
> in an immutable branch off maybe -rc8 so that it can be pulled into
> individual subsystems so that patches switching various drivers to
> fwnode_gpiod_get_index() could be applied.

I think it seems a bit enthusiastic to have non-GPIO subsystems
pick up these changes this close to the merge window so my plan
is to merge patches 1.2.3 (1 already merged) and then you could
massage the other subsystems in v5.4-rc1.

But if other subsystems say "hey we want do fix this in like 3 days"
then I'm game for an immutable branch as well.

Yours,
Linus Walleij

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

* Re: [PATCH 00/11] Add support for software nodes to gpiolib
  2019-09-12  9:55 ` Linus Walleij
@ 2019-09-17  0:22   ` Dmitry Torokhov
  2019-09-30 22:44     ` Dmitry Torokhov
  0 siblings, 1 reply; 9+ messages in thread
From: Dmitry Torokhov @ 2019-09-17  0:22 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Andy Shevchenko, Mika Westerberg, linux-kernel,
	open list:GPIO SUBSYSTEM, Andrew Lunn, Andrzej Hajda,
	Bartosz Golaszewski, Daniel Vetter, David Airlie,
	David S. Miller, Florian Fainelli, Heiner Kallweit,
	Jernej Skrabec, Jonas Karlman, Laurent Pinchart, Neil Armstrong,
	Russell King, open list:DRM PANEL DRIVERS,
	ACPI Devel Maling List, netdev

On Thu, Sep 12, 2019 at 10:55:47AM +0100, Linus Walleij wrote:
> On Wed, Sep 11, 2019 at 8:52 AM Dmitry Torokhov
> <dmitry.torokhov@gmail.com> wrote:
> 
> > If we agree in principle, I would like to have the very first 3 patches
> > in an immutable branch off maybe -rc8 so that it can be pulled into
> > individual subsystems so that patches switching various drivers to
> > fwnode_gpiod_get_index() could be applied.
> 
> I think it seems a bit enthusiastic to have non-GPIO subsystems
> pick up these changes this close to the merge window so my plan
> is to merge patches 1.2.3 (1 already merged) and then you could
> massage the other subsystems in v5.4-rc1.
> 
> But if other subsystems say "hey we want do fix this in like 3 days"
> then I'm game for an immutable branch as well.

No, if it is still has a chance for -rc1 then I'm good. I was thinking
if it does not go into -rc1 I could convince some of them merge a
targeted immutable branch off -rc8 or 5.3 final and then apply patches
relevant to their subsystems so we do not have to wait till 5.6 to land
everything.

Thanks.

-- 
Dmitry

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

* Re: [PATCH 00/11] Add support for software nodes to gpiolib
  2019-09-17  0:22   ` Dmitry Torokhov
@ 2019-09-30 22:44     ` Dmitry Torokhov
  2019-10-04 21:44       ` Linus Walleij
  0 siblings, 1 reply; 9+ messages in thread
From: Dmitry Torokhov @ 2019-09-30 22:44 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Andy Shevchenko, Mika Westerberg, linux-kernel,
	open list:GPIO SUBSYSTEM, Andrew Lunn, Andrzej Hajda,
	Bartosz Golaszewski, Daniel Vetter, David Airlie,
	David S. Miller, Florian Fainelli, Heiner Kallweit,
	Jernej Skrabec, Jonas Karlman, Laurent Pinchart, Neil Armstrong,
	Russell King, open list:DRM PANEL DRIVERS,
	ACPI Devel Maling List, netdev

Hi Linus,

On Mon, Sep 16, 2019 at 05:22:07PM -0700, Dmitry Torokhov wrote:
> On Thu, Sep 12, 2019 at 10:55:47AM +0100, Linus Walleij wrote:
> > On Wed, Sep 11, 2019 at 8:52 AM Dmitry Torokhov
> > <dmitry.torokhov@gmail.com> wrote:
> > 
> > > If we agree in principle, I would like to have the very first 3 patches
> > > in an immutable branch off maybe -rc8 so that it can be pulled into
> > > individual subsystems so that patches switching various drivers to
> > > fwnode_gpiod_get_index() could be applied.
> > 
> > I think it seems a bit enthusiastic to have non-GPIO subsystems
> > pick up these changes this close to the merge window so my plan
> > is to merge patches 1.2.3 (1 already merged) and then you could
> > massage the other subsystems in v5.4-rc1.
> > 
> > But if other subsystems say "hey we want do fix this in like 3 days"
> > then I'm game for an immutable branch as well.
> 
> No, if it is still has a chance for -rc1 then I'm good. I was thinking
> if it does not go into -rc1 I could convince some of them merge a
> targeted immutable branch off -rc8 or 5.3 final and then apply patches
> relevant to their subsystems so we do not have to wait till 5.6 to land
> everything.

So I guess we missed -rc1. Any chance we could get an immutable branch
off -rc1 that you will pull into your main branch and I hopefully can
persuade other maintainers to pull as well so we do not need to drag it
over 2+ merge windows?

Thanks.

-- 
Dmitry

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

* Re: [PATCH 00/11] Add support for software nodes to gpiolib
  2019-09-30 22:44     ` Dmitry Torokhov
@ 2019-10-04 21:44       ` Linus Walleij
  0 siblings, 0 replies; 9+ messages in thread
From: Linus Walleij @ 2019-10-04 21:44 UTC (permalink / raw)
  To: Dmitry Torokhov
  Cc: Andy Shevchenko, Mika Westerberg, linux-kernel,
	open list:GPIO SUBSYSTEM, Andrew Lunn, Andrzej Hajda,
	Bartosz Golaszewski, Daniel Vetter, David Airlie,
	David S. Miller, Florian Fainelli, Heiner Kallweit,
	Jernej Skrabec, Jonas Karlman, Laurent Pinchart, Neil Armstrong,
	Russell King, open list:DRM PANEL DRIVERS,
	ACPI Devel Maling List, netdev

On Tue, Oct 1, 2019 at 12:45 AM Dmitry Torokhov
<dmitry.torokhov@gmail.com> wrote:

> So I guess we missed -rc1. Any chance we could get an immutable branch
> off -rc1 that you will pull into your main branch and I hopefully can
> persuade other maintainers to pull as well so we do not need to drag it
> over 2+ merge windows?

Yes I'm sorry. I was swamped with stabilizing the kernel.
I made an immutable branch and tried to use zeroday for testing
but it timed out so I folded it in for-next anyways after som basic
tests.

Yours,
Linus Walleij

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

end of thread, back to index

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-11  7:52 [PATCH 00/11] Add support for software nodes to gpiolib Dmitry Torokhov
2019-09-11  7:52 ` [PATCH 09/11] gpiolib: of: tease apart acpi_find_gpio() Dmitry Torokhov
2019-09-11 17:12   ` Andy Shevchenko
2019-09-11  7:52 ` [PATCH 10/11] gpiolib: consolidate fwnode GPIO lookups Dmitry Torokhov
2019-09-11 17:13 ` [PATCH 00/11] Add support for software nodes to gpiolib Andy Shevchenko
2019-09-12  9:55 ` Linus Walleij
2019-09-17  0:22   ` Dmitry Torokhov
2019-09-30 22:44     ` Dmitry Torokhov
2019-10-04 21:44       ` Linus Walleij

Linux-ACPI Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-acpi/0 linux-acpi/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-acpi linux-acpi/ https://lore.kernel.org/linux-acpi \
		linux-acpi@vger.kernel.org linux-acpi@archiver.kernel.org
	public-inbox-index linux-acpi

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-acpi


AGPL code for this site: git clone https://public-inbox.org/ public-inbox