diff --git a/drivers/gpio/devres.c b/drivers/gpio/devres.c
index e82cc763633c..48464eafc670 100644
--- a/drivers/gpio/devres.c
+++ b/drivers/gpio/devres.c
@@ -206,8 +206,8 @@ struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev,
 			snprintf(prop_name, sizeof(prop_name), "%s",
 					    gpio_suffixes[i]);
 
-		desc = fwnode_get_named_gpiod(child, prop_name, index, flags,
-					      label);
+		desc = fwnode_get_named_gpiod_dev(dev, child, prop_name, index,
+					      flags, label);
 		if (!IS_ERR(desc) || (PTR_ERR(desc) != -ENOENT))
 			break;
 	}
diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
index e8f8a1999393..501ddcd9c86f 100644
--- a/drivers/gpio/gpiolib.c
+++ b/drivers/gpio/gpiolib.c
@@ -3994,7 +3994,8 @@ struct gpio_desc *gpiod_get_from_of_node(struct device_node *node,
 EXPORT_SYMBOL(gpiod_get_from_of_node);
 
 /**
- * fwnode_get_named_gpiod - obtain a GPIO from firmware node
+ * fwnode_get_named_gpiod_dev - obtain a GPIO from firmware node
+ * @dev:	corresponding device, may be NULL for DT and ACPI
  * @fwnode:	handle of the firmware node
  * @propname:	name of the firmware property representing the GPIO
  * @index:	index of the GPIO to obtain for the consumer
@@ -4002,7 +4003,7 @@ EXPORT_SYMBOL(gpiod_get_from_of_node);
  * @label:	label to attach to the requested GPIO
  *
  * This function can be used for drivers that get their configuration
- * from opaque firmware.
+ * from opaque firmware or machine descriptors in board files.
  *
  * The function properly finds the corresponding GPIO using whatever is the
  * underlying firmware interface and then makes sure that the GPIO
@@ -4012,20 +4013,19 @@ EXPORT_SYMBOL(gpiod_get_from_of_node);
  * On successful request the GPIO pin is configured in accordance with
  * provided @dflags.
  *
- * In case of error an ERR_PTR() is returned.
+ * In case of error an ERR_PTR() is returned. -ENOENT is returned if
+ * no GPIO descriptor can be located in DT, ACPI or board file tables.
  */
-struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
-					 const char *propname, int index,
-					 enum gpiod_flags dflags,
-					 const char *label)
+struct gpio_desc *fwnode_get_named_gpiod_dev(struct device *dev,
+					     struct fwnode_handle *fwnode,
+					     const char *propname, int index,
+					     enum gpiod_flags dflags,
+					     const char *label)
 {
 	struct gpio_desc *desc = ERR_PTR(-ENODEV);
-	unsigned long lflags = 0;
+	enum gpio_lookup_flags lflags = 0;
 	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,
@@ -4043,9 +4043,30 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
 
 		if (info.polarity == GPIO_ACTIVE_LOW)
 			lflags |= GPIO_ACTIVE_LOW;
+	} else {
+		desc = gpiod_find(dev, propname, index, &lflags);
+		if (IS_ERR(desc))
+			return desc;
+		/*
+		 * This is a special case. This happens when you try
+		 * to look up more than one child node from
+		 * fwnode_get_*_from_child(): the boardfile tables
+		 * do not have hierarchy or children, they are flat.
+		 * To get out of this without having to reinvent a
+		 * complex datastructure for board files, we convert
+		 * the child to an index by simply trying the next
+		 * descriptor index until we get something not busy
+		 * (already requested) or -ENOENT.
+		 */
+		while (test_bit(FLAG_REQUESTED, &desc->flags)) {
+			index++;
+			desc = gpiod_find(dev, propname, index,
+					  &lflags);
+			if (IS_ERR(desc))
+				return desc;
+		}
 	}
 
-	/* Currently only ACPI takes this path */
 	ret = gpiod_request(desc, label);
 	if (ret)
 		return ERR_PTR(ret);
@@ -4058,7 +4079,7 @@ struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
 
 	return desc;
 }
-EXPORT_SYMBOL_GPL(fwnode_get_named_gpiod);
+EXPORT_SYMBOL_GPL(fwnode_get_named_gpiod_dev);
 
 /**
  * gpiod_get_index_optional - obtain an optional GPIO from a multi-index GPIO
diff --git a/include/linux/gpio/consumer.h b/include/linux/gpio/consumer.h
index 21ddbe440030..6ddb62a70f4a 100644
--- a/include/linux/gpio/consumer.h
+++ b/include/linux/gpio/consumer.h
@@ -157,10 +157,21 @@ struct gpio_desc *devm_gpiod_get_from_of_node(struct device *dev,
 					      const char *propname, int index,
 					      enum gpiod_flags dflags,
 					      const char *label);
-struct gpio_desc *fwnode_get_named_gpiod(struct fwnode_handle *fwnode,
-					 const char *propname, int index,
-					 enum gpiod_flags dflags,
-					 const char *label);
+struct gpio_desc *fwnode_get_named_gpiod_dev(struct device *dev,
+					     struct fwnode_handle *fwnode,
+					     const char *propname, int index,
+					     enum gpiod_flags dflags,
+					     const char *label);
+static inline struct gpio_desc *fwnode_get_named_gpiod(
+	struct fwnode_handle *fwnode,
+	const char *propname, int index,
+	enum gpiod_flags dflags,
+	const char *label)
+{
+	/* Just a wrapper calling the former for device NULL */
+	return fwnode_get_named_gpiod_dev(NULL, fwnode, propname, index,
+					  dflags, label);
+}
 struct gpio_desc *devm_fwnode_get_index_gpiod_from_child(struct device *dev,
 						const char *con_id, int index,
 						struct fwnode_handle *child,
