Skip to contentSkip to conversation

dm: gpio: handle GPIO_ACTIVE_LOW flag in DT

PATCH New Eric Nelson 6 participants 67 messages Mar 25, 2016 – May 7, 2016

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 dm: gpio: handle GPIO_ACTIVE_LOW flag in DT

Device tree parsing of GPIO nodes is currently ignoring flags.

Add support for GPIO_ACTIVE_LOW by checking for the presence of the flag and setting the desc->flags field to the driver model constant GPIOD_ACTIVE_LOW.

---
 drivers/gpio/gpio-uclass.c | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpio/gpio-uclass.c +7 -2
index b58d4e6..6d30612 100644
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <dt-bindings/gpio/gpio.h>
 #include <errno.h>
 #include <fdtdec.h>
 #include <malloc.h>
@@ -118,12 +119,16 @@ static int gpio_find_and_xlate(struct gpio_desc *desc,
 {
 	struct dm_gpio_ops *ops = gpio_get_ops(desc->dev);
 
+	desc->flags = 0;
 	/* Use the first argument as the offset by default */
-	if (args->args_count > 0)
+	if (args->args_count > 0) {
 		desc->offset = args->args[0];
+		if ((args->args_count > 1) &&
+		    (args->args[1] & GPIO_ACTIVE_LOW))
+			desc->flags = GPIOD_ACTIVE_LOW;
+	}
 	else
 		desc->offset = -1;
-	desc->flags = 0;
 
 	return ops->xlate ? ops->xlate(desc->dev, desc, args) : 0;
 }
Signature · 1 line
2.6.2
#1 lore raw

PATCH 1/1 dm: gpio: handle GPIO_ACTIVE_LOW flag in DT

Hi Eric,

Quoted 5 lines · Eric Nelson

Device tree parsing of GPIO nodes is currently ignoring flags.

Add support for GPIO_ACTIVE_LOW by checking for the presence of the flag and setting the desc->flags field to the driver model constant GPIOD_ACTIVE_LOW.

You may need to try this: https://patchwork.ozlabs.org/patch/597363/

Regards,
Peng.

Quoted 44 lines

---
drivers/gpio/gpio-uclass.c | 9 +++++++--

1 file changed, 7 insertions(+), 2 deletions(-)
drivers/gpio/gpio-uclass.c +7 -2
index b58d4e6..6d30612 100644
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <dt-bindings/gpio/gpio.h>
 #include <errno.h>
 #include <fdtdec.h>
 #include <malloc.h>
@@ -118,12 +119,16 @@ static int gpio_find_and_xlate(struct gpio_desc *desc,
 {
 	struct dm_gpio_ops *ops = gpio_get_ops(desc->dev);
 
+	desc->flags = 0;
 	/* Use the first argument as the offset by default */
-	if (args->args_count > 0)
+	if (args->args_count > 0) {
 		desc->offset = args->args[0];
+		if ((args->args_count > 1) &&
+		    (args->args[1] & GPIO_ACTIVE_LOW))
+			desc->flags = GPIOD_ACTIVE_LOW;
+	}
 	else
 		desc->offset = -1;
-	desc->flags = 0;
 
 	return ops->xlate ? ops->xlate(desc->dev, desc, args) : 0;
 }
Signature · 6 lines
2.6.2

_______________________________________________
U-Boot mailing list
U-Boot at lists.denx.de
http://lists.denx.de/mailman/listinfo/u-boot
#2 lore raw

PATCH 1/1 dm: gpio: handle GPIO_ACTIVE_LOW flag in DT

Hi Peng,

Quoted 11 lines · Peng Fan

Hi Eric,

Quoted 5 lines · Eric Nelson

Device tree parsing of GPIO nodes is currently ignoring flags.

Add support for GPIO_ACTIVE_LOW by checking for the presence of the flag and setting the desc->flags field to the driver model constant GPIOD_ACTIVE_LOW.

You may need to try this: https://patchwork.ozlabs.org/patch/597363/

Thanks for pointing this out.

This patch also works, but it has me confused.

How/why is parsing the ACTIVE_LOW flag specific to MXC?

This is a general-purpose flag in the kernel, not something machine- specific.

It also appears that there are a bunch of other copies of this same bit of code in the various mach_xlate() routines:

desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;

If it's done in gpio-uclass, this isn't needed and xlate can be removed from mxc-gpio and quite a few other architectures.

Please advise,

Eric

#3 lore raw

cover Handle GPIO_ACTIVE_LOW in gpio-uclass

As Peng pointed out in [1], GPIO_ACTIVE_LOW is currently being parsed by driver-specific xlate routines, and an NXP/mxc-specific patch ([2]) to do the same on those processors is pending.

Upon further inspection, I found that many arch-specific xlate routines were present only to parse either or both offset and the GPIO_ACTIVE_LOW flag, both of which can be handled at a global level.

This series adds global support for GPIO_ACTIVE_LOW and removes the architecture-specific gpio xlate routine from five drivers.

It also removes the handling of flags in the tegra gpio driver, though a custom xlate is still needed.

[1] - http://lists.denx.de/pipermail/u-boot/2016-March/thread.html#249946
[2] - https://patchwork.ozlabs.org/patch/597363/

Eric Nelson (7):
dm: gpio: handle GPIO_ACTIVE_LOW flag in DT
gpio: intel_broadwell: remove gpio_xlate routine
gpio: omap: remove gpio_xlate routine
gpio: pic32: remove gpio_xlate routine
gpio: rk: remove gpio_xlate routine
gpio: exynos(s5p): remove gpio_xlate routine
gpio: tegra: remove flags parsing in xlate routine

 drivers/gpio/gpio-uclass.c          | 12 ++++++++----
 drivers/gpio/intel_broadwell_gpio.c | 10 ----------
 drivers/gpio/omap_gpio.c            | 10 ----------
 drivers/gpio/pic32_gpio.c           |  9 ---------
 drivers/gpio/rk_gpio.c              | 10 ----------
 drivers/gpio/s5p_gpio.c             | 10 ----------
 drivers/gpio/tegra_gpio.c           |  1 -
 7 files changed, 8 insertions(+), 54 deletions(-)
Signature · 1 line
2.6.2
#4 lore raw

PATCH 1/7 dm: gpio: handle GPIO_ACTIVE_LOW flag in DT

Device tree parsing of GPIO nodes is currently ignoring flags and architecture-specific xlate routines are handling the parsing of GPIO_ACTIVE_LOW.

Since GPIO_ACTIVE_LOW isn't specific to a particular device type, this patch adds support at a global level and removes the need for many of the driver-specific xlate routines.

---
 drivers/gpio/gpio-uclass.c | 12 ++++++++----
 1 file changed, 8 insertions(+), 4 deletions(-)
drivers/gpio/gpio-uclass.c +8 -4
index b58d4e6..a3cbb83 100644
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <dt-bindings/gpio/gpio.h>
 #include <errno.h>
 #include <fdtdec.h>
 #include <malloc.h>
@@ -118,12 +119,15 @@ static int gpio_find_and_xlate(struct gpio_desc *desc,
 {
 	struct dm_gpio_ops *ops = gpio_get_ops(desc->dev);
 
+	desc->offset = -1;
+	desc->flags = 0;
 	/* Use the first argument as the offset by default */
-	if (args->args_count > 0)
+	if (args->args_count > 0) {
 		desc->offset = args->args[0];
-	else
-		desc->offset = -1;
-	desc->flags = 0;
+		if ((args->args_count > 1) &&
+		    (args->args[1] & GPIO_ACTIVE_LOW))
+			desc->flags = GPIOD_ACTIVE_LOW;
+	}
 
 	return ops->xlate ? ops->xlate(desc->dev, desc, args) : 0;
 }
Signature · 1 line
2.6.2
#5 lore raw

PATCH 2/7 gpio: intel_broadwell: remove gpio_xlate routine

In reply to Eric Nelson

With the addition of GPIO_ACTIVE_LOW parsing in gpio-uclass, the intel_broadwell driver doesn't need a custom xlate routine.

---
 drivers/gpio/intel_broadwell_gpio.c | 10 ----------
 1 file changed, 10 deletions(-)
drivers/gpio/intel_broadwell_gpio.c +0 -10
index 8cf76f9..81ce446 100644
@@ -162,15 +162,6 @@ static int broadwell_gpio_ofdata_to_platdata(struct udevice *dev)
 	return 0;
 }
 
-static int broadwell_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
-				struct fdtdec_phandle_args *args)
-{
-	desc->offset = args->args[0];
-	desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;
-
-	return 0;
-}
-
 static const struct dm_gpio_ops gpio_broadwell_ops = {
 	.request		= broadwell_gpio_request,
 	.direction_input	= broadwell_gpio_direction_input,
@@ -178,7 +169,6 @@ static const struct dm_gpio_ops gpio_broadwell_ops = {
 	.get_value		= broadwell_gpio_get_value,
 	.set_value		= broadwell_gpio_set_value,
 	.get_function		= broadwell_gpio_get_function,
-	.xlate			= broadwell_gpio_xlate,
 };
 
 static const struct udevice_id intel_broadwell_gpio_ids[] = {
Signature · 1 line
2.6.2
#6 lore raw

PATCH 2/7 gpio: intel_broadwell: remove gpio_xlate routine

Quoted 7 lines · Eric Nelson

With the addition of GPIO_ACTIVE_LOW parsing in gpio-uclass, the intel_broadwell driver doesn't need a custom xlate routine.

---
 drivers/gpio/intel_broadwell_gpio.c | 10 ----------
 1 file changed, 10 deletions(-)
#7 lore raw

PATCH 3/7 gpio: omap: remove gpio_xlate routine

In reply to Eric Nelson

With the addition of GPIO_ACTIVE_LOW parsing in gpio-uclass, the omap gpio driver doesn't need a custom xlate routine.

---
 drivers/gpio/omap_gpio.c | 10 ----------
 1 file changed, 10 deletions(-)
drivers/gpio/omap_gpio.c +0 -10
index 93d18e4..5ab53bc 100644
@@ -277,22 +277,12 @@ static int omap_gpio_get_function(struct udevice *dev, unsigned offset)
 		return GPIOF_INPUT;
 }
 
-static int omap_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
-			   struct fdtdec_phandle_args *args)
-{
-	desc->offset = args->args[0];
-	desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;
-
-	return 0;
-}
-
 static const struct dm_gpio_ops gpio_omap_ops = {
 	.direction_input	= omap_gpio_direction_input,
 	.direction_output	= omap_gpio_direction_output,
 	.get_value		= omap_gpio_get_value,
 	.set_value		= omap_gpio_set_value,
 	.get_function		= omap_gpio_get_function,
-	.xlate			= omap_gpio_xlate,
 };
 
 static int omap_gpio_probe(struct udevice *dev)
Signature · 1 line
2.6.2
#9 lore raw

PATCH 4/7 gpio: pic32: remove gpio_xlate routine

In reply to Eric Nelson

With the addition of GPIO_ACTIVE_LOW parsing in gpio-uclass, the pic32 gpio driver doesn't need a custom xlate routine.

---
 drivers/gpio/pic32_gpio.c | 9 ---------
 1 file changed, 9 deletions(-)
drivers/gpio/pic32_gpio.c +0 -9
index 499b4fa..6999bc0 100644
@@ -99,14 +99,6 @@ static int pic32_gpio_direction_output(struct udevice *dev,
 	return 0;
 }
 
-static int pic32_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
-			    struct fdtdec_phandle_args *args)
-{
-	desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;
-
-	return 0;
-}
-
 static int pic32_gpio_get_function(struct udevice *dev, unsigned offset)
 {
 	int ret = GPIOF_UNUSED;
@@ -131,7 +123,6 @@ static const struct dm_gpio_ops gpio_pic32_ops = {
 	.get_value		= pic32_gpio_get_value,
 	.set_value		= pic32_gpio_set_value,
 	.get_function		= pic32_gpio_get_function,
-	.xlate			= pic32_gpio_xlate,
 };
 
 static int pic32_gpio_probe(struct udevice *dev)
Signature · 1 line
2.6.2
#11 lore raw

PATCH 5/7 gpio: rk: remove gpio_xlate routine

In reply to Eric Nelson

With the addition of GPIO_ACTIVE_LOW parsing in gpio-uclass, the Rockchip gpio driver doesn't need a custom xlate routine.

---
 drivers/gpio/rk_gpio.c | 10 ----------
 1 file changed, 10 deletions(-)
drivers/gpio/rk_gpio.c +0 -10
index 40e87bd..253ccec 100644
@@ -98,15 +98,6 @@ static int rockchip_gpio_get_function(struct udevice *dev, unsigned offset)
 #endif
 }
 
-static int rockchip_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
-			    struct fdtdec_phandle_args *args)
-{
-	desc->offset = args->args[0];
-	desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;
-
-	return 0;
-}
-
 static int rockchip_gpio_probe(struct udevice *dev)
 {
 	struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
@@ -135,7 +126,6 @@ static const struct dm_gpio_ops gpio_rockchip_ops = {
 	.get_value		= rockchip_gpio_get_value,
 	.set_value		= rockchip_gpio_set_value,
 	.get_function		= rockchip_gpio_get_function,
-	.xlate			= rockchip_gpio_xlate,
 };
 
 static const struct udevice_id rockchip_gpio_ids[] = {
Signature · 1 line
2.6.2
#13 lore raw

PATCH 6/7 gpio: exynos(s5p): remove gpio_xlate routine

In reply to Eric Nelson

With the addition of GPIO_ACTIVE_LOW parsing in gpio-uclass, the Exynos/S5P gpio driver doesn't need a custom xlate routine.

---
 drivers/gpio/s5p_gpio.c | 10 ----------
 1 file changed, 10 deletions(-)
drivers/gpio/s5p_gpio.c +0 -10
index 0f22b23..591c036 100644
@@ -276,22 +276,12 @@ static int exynos_gpio_get_function(struct udevice *dev, unsigned offset)
 		return GPIOF_FUNC;
 }
 
-static int exynos_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
-			     struct fdtdec_phandle_args *args)
-{
-	desc->offset = args->args[0];
-	desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;
-
-	return 0;
-}
-
 static const struct dm_gpio_ops gpio_exynos_ops = {
 	.direction_input	= exynos_gpio_direction_input,
 	.direction_output	= exynos_gpio_direction_output,
 	.get_value		= exynos_gpio_get_value,
 	.set_value		= exynos_gpio_set_value,
 	.get_function		= exynos_gpio_get_function,
-	.xlate			= exynos_gpio_xlate,
 };
 
 static int gpio_exynos_probe(struct udevice *dev)
Signature · 1 line
2.6.2
#15 lore raw

PATCH 7/7 gpio: tegra: remove flags parsing in xlate routine

In reply to Eric Nelson

With the addition of GPIO_ACTIVE_LOW parsing in gpio-uclass, it is no longer necessary for the tegra-specific xlate function to do this.

---
 drivers/gpio/tegra_gpio.c | 1 -
 1 file changed, 1 deletion(-)
drivers/gpio/tegra_gpio.c +0 -1
index 5a03115..7ae1509 100644
@@ -246,7 +246,6 @@ static int tegra_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
 	if (ret)
 		return ret;
 	desc->offset = gpio % TEGRA_GPIOS_PER_PORT;
-	desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;
 
 	return 0;
 }
Signature · 1 line
2.6.2
#16 lore raw

PATCH 7/7 gpio: tegra: remove flags parsing in xlate routine

drivers/gpio/tegra_gpio.c static int tegra_gpio_xlate(struct udevice *dev, struct gpio_desc *desc, · line 249

Quoted 10 lines · Eric Nelson

With the addition of GPIO_ACTIVE_LOW parsing in gpio-uclass, it is no longer necessary for the tegra-specific xlate function to do this.

drivers/gpio/tegra_gpio.c +0 -1
@@ -246,7 +246,6 @@ static int tegra_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
  	if (ret)
  		return ret;
  	desc->offset = gpio % TEGRA_GPIOS_PER_PORT;
-	desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;

I expect that after that, you can also remove the following at the top of the file:

#include <dt-bindings/gpio/gpio.h>

I expect that's true of other GPIO drivers too.

#17 lore raw

PATCH 7/7 gpio: tegra: remove flags parsing in xlate routine

Hi Stephen,

Quoted 21 lines · Stephen Warren
Quoted 9 lines · Eric Nelson

With the addition of GPIO_ACTIVE_LOW parsing in gpio-uclass, it is no longer necessary for the tegra-specific xlate function to do this.

drivers/gpio/tegra_gpio.c static int tegra_gpio_xlate(struct udevice *dev, · line 250

Quoted 6 lines
drivers/gpio/tegra_gpio.c +0 -1
@@ -246,7 +246,6 @@ static int tegra_gpio_xlate(struct udevice *dev,
 struct gpio_desc *desc,
        if (ret)
                return ret;
        desc->offset = gpio % TEGRA_GPIOS_PER_PORT;
-       desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW :
 0;

I expect that after that, you can also remove the following at the top of the file:

Quoted 3 lines

#include <dt-bindings/gpio/gpio.h>

I expect that's true of other GPIO drivers too.

But I don't think we want this patch for Tegra since we need to keep the xlate() method, and with your suggested approach earlier, we won't call the default xlate() method in the uclass for Tegra.

Regards,
Simon

#18 lore raw

PATCH 7/7 gpio: tegra: remove flags parsing in xlate routine

Thanks for the feedback Simon.

Quoted 22 lines · Simon Glass
Quoted 21 lines · Stephen Warren
Quoted 9 lines · Eric Nelson

With the addition of GPIO_ACTIVE_LOW parsing in gpio-uclass, it is no longer necessary for the tegra-specific xlate function to do this.

drivers/gpio/tegra_gpio.c static int tegra_gpio_xlate(struct udevice *dev, · line 250

Quoted 6 lines
drivers/gpio/tegra_gpio.c +0 -1
@@ -246,7 +246,6 @@ static int tegra_gpio_xlate(struct udevice *dev,
 struct gpio_desc *desc,
        if (ret)
                return ret;
        desc->offset = gpio % TEGRA_GPIOS_PER_PORT;
-       desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW :
 0;

I expect that after that, you can also remove the following at the top of the file:

Quoted 8 lines
Quoted 3 lines

#include <dt-bindings/gpio/gpio.h>

I expect that's true of other GPIO drivers too.

But I don't think we want this patch for Tegra since we need to keep the xlate() method, and with your suggested approach earlier, we won't call the default xlate() method in the uclass for Tegra.

Based on your comments and Stephens, I can re-work this to have a __maybe_unused xlate function for the common case of handling offset+active low, but I think the handling of offset inside of gpio_find_and_xlate() should be removed at the same time.

It seems weird to have processing for one argument in the common code when it may not be used (as is the case with tegra).

I see that you've sent some updates, so I'm not sure whether I should send an update on top of your patch set or without it.

Regards,

Eric

#19 lore raw

PATCH 7/7 gpio: tegra: remove flags parsing in xlate routine

Quoted 30 lines · Eric Nelson
Quoted 20 lines · Simon Glass
Quoted 19 lines · Stephen Warren

drivers/gpio/tegra_gpio.c static int tegra_gpio_xlate(struct udevice *dev, · line 250

Quoted 13 lines · Eric Nelson

With the addition of GPIO_ACTIVE_LOW parsing in gpio-uclass, it is no longer necessary for the tegra-specific xlate function to do this.

drivers/gpio/tegra_gpio.c +0 -1
@@ -246,7 +246,6 @@ static int tegra_gpio_xlate(struct udevice *dev,
 struct gpio_desc *desc,
        if (ret)
                return ret;
        desc->offset = gpio % TEGRA_GPIOS_PER_PORT;
-       desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW :
 0;

I expect that after that, you can also remove the following at the top of the file:

Quoted 8 lines
Quoted 3 lines

#include <dt-bindings/gpio/gpio.h>

I expect that's true of other GPIO drivers too.

But I don't think we want this patch for Tegra since we need to keep the xlate() method, and with your suggested approach earlier, we won't call the default xlate() method in the uclass for Tegra.

Quoted 8 lines

Based on your comments and Stephens, I can re-work this to have a __maybe_unused xlate function for the common case of handling offset+active low, but I think the handling of offset inside of gpio_find_and_xlate() should be removed at the same time.

It seems weird to have processing for one argument in the common code when it may not be used (as is the case with tegra).

While reviewing this, I think I found that the sunxi gpio driver is broken.

The device trees have #gpio-cells=<3>, and gpio declaration like this:

	<&pio 1 8 GPIO_ACTIVE_HIGH>

but there's no custom xlate routine, the offset is currently going to have what I presume is the bank number.

Hans, can you confirm this?

Please advise,

Eric

#20 lore raw

v2 cover Handle GPIO_ACTIVE_LOW in gpio-uclass

In reply to Eric Nelson

As Peng pointed out in [1], GPIO_ACTIVE_LOW is currently being parsed by driver-specific xlate routines, and an NXP/mxc-specific patch ([2]) to do the same on those processors is pending.

This patch series takes a different approach and provides a default routine for xlate that handles the most common case of GPIO device tree node parsing:

	<&gpio1 2 GPIO_ACTIVE_LOW>

The first routine adds the default gpio_xlate_offs_flags() routine, and the remainder of the patches remove the driver-specific versions from the intel_broadwell, omap, pic32, rk, and s5p drivers.

V2 of this patch set removes parsing of offset from the gpio_find_and_xlate routine, and only parses the offset and GPIO_ACTIVE_LOW flag when a driver-specific xlate is unavailable.

V2 also drops the update to the tegra_gpio driver.

Eric Nelson (6):
dm: gpio: add a default gpio xlate routine
gpio: intel_broadwell: remove gpio_xlate routine
gpio: omap: remove gpio_xlate routine
gpio: pic32: remove gpio_xlate routine
gpio: rk: remove gpio_xlate routine
gpio: exynos(s5p): remove gpio_xlate routine

 drivers/gpio/gpio-uclass.c          | 26 +++++++++++++++++++-------
 drivers/gpio/intel_broadwell_gpio.c | 10 ----------
 drivers/gpio/omap_gpio.c            | 11 -----------
 drivers/gpio/pic32_gpio.c           | 10 ----------
 drivers/gpio/rk_gpio.c              | 11 -----------
 drivers/gpio/s5p_gpio.c             | 11 -----------
 include/asm-generic/gpio.h          | 19 ++++++++++++++-----
 7 files changed, 33 insertions(+), 65 deletions(-)
Signature · 1 line
2.6.2
#21 lore raw

PATCH v2 1/6 dm: gpio: add a default gpio xlate routine

Many drivers use a common form of offset + flags for device tree nodes. e.g.:

	<&gpio1 2 GPIO_ACTIVE_LOW>

This patch adds a common implementation of this type of parsing and calls it when a gpio driver doesn't supply its' own xlate routine.

This will allow removal of the driver-specific versions in a handful of drivers and simplify the addition of new drivers.

---
 drivers/gpio/gpio-uclass.c | 26 +++++++++++++++++++-------
 include/asm-generic/gpio.h | 19 ++++++++++++++-----
 2 files changed, 33 insertions(+), 12 deletions(-)
drivers/gpio/gpio-uclass.c +19 -7
index b58d4e6..6c24e65 100644
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <dt-bindings/gpio/gpio.h>
 #include <errno.h>
 #include <fdtdec.h>
 #include <malloc.h>
@@ -113,19 +114,29 @@ int gpio_lookup_name(const char *name, struct udevice **devp,
 	return 0;
 }
 
+int gpio_xlate_offs_flags(struct udevice *dev,
+					 struct gpio_desc *desc,
+					 struct fdtdec_phandle_args *args)
+{
+	int ret = -EINVAL;
+	if (args->args_count > 1) {
+		desc->offset = args->args[0];
+		if (args->args[1] & GPIO_ACTIVE_LOW)
+			desc->flags = GPIOD_ACTIVE_LOW;
+		ret = 0;
+	}
+	return ret;
+}
+
 static int gpio_find_and_xlate(struct gpio_desc *desc,
 			       struct fdtdec_phandle_args *args)
 {
 	struct dm_gpio_ops *ops = gpio_get_ops(desc->dev);
 
-	/* Use the first argument as the offset by default */
-	if (args->args_count > 0)
-		desc->offset = args->args[0];
+	if (ops->xlate)
+		return ops->xlate(desc->dev, desc, args);
 	else
-		desc->offset = -1;
-	desc->flags = 0;
-
-	return ops->xlate ? ops->xlate(desc->dev, desc, args) : 0;
+		return gpio_xlate_offs_flags(desc->dev, desc, args);
 }
 
 int dm_gpio_request(struct gpio_desc *desc, const char *label)
@@ -605,6 +616,7 @@ static int _gpio_request_by_name_nodev(const void *blob, int node,
 
 	desc->dev = NULL;
 	desc->offset = 0;
+	desc->flags = 0;
 	ret = fdtdec_parse_phandle_with_args(blob, node, list_name,
 					     "#gpio-cells", 0, index, &args);
 	if (ret) {
include/asm-generic/gpio.h +14 -5
index 68b5f0b..2500c10 100644
@@ -207,6 +207,16 @@ int gpio_requestf(unsigned gpio, const char *fmt, ...)
 struct fdtdec_phandle_args;
 
 /**
+ * gpio_xlate_offs_flags() - implementation for common use of dm_gpio_ops.xlate
+ *
+ * This routine sets the offset field to args[0] and the flags field to
+ * GPIOD_ACTIVE_LOW if the GPIO_ACTIVE_LOW flag is present in args[1].
+ *
+ */
+int gpio_xlate_offs_flags(struct udevice *dev, struct gpio_desc *desc,
+			  struct fdtdec_phandle_args *args);
+
+/**
  * struct struct dm_gpio_ops - Driver model GPIO operations
  *
  * Refer to functions above for description. These function largely copy
@@ -258,12 +268,11 @@ struct dm_gpio_ops {
 	 *
 	 *   @desc->dev to @dev
 	 *   @desc->flags to 0
-	 *   @desc->offset to the value of the first argument in args, if any,
-	 *		otherwise -1 (which is invalid)
+	 *   @desc->offset to 0
 	 *
-	 * This method is optional so if the above defaults suit it can be
-	 * omitted. Typical behaviour is to set up the GPIOD_ACTIVE_LOW flag
-	 * in desc->flags.
+	 * This method is optional and defaults to gpio_xlate_offs_flags,
+	 * which will parse offset and the GPIO_ACTIVE_LOW flag in the first
+	 * two arguments.
 	 *
 	 * Note that @dev is passed in as a parameter to follow driver model
 	 * uclass conventions, even though it is already available as
Signature · 1 line
2.6.2
#22 lore raw

PATCH v2 1/6 dm: gpio: add a default gpio xlate routine

Quoted 10 lines · Eric Nelson

Many drivers use a common form of offset + flags for device tree nodes. e.g.:

	<&gpio1 2 GPIO_ACTIVE_LOW>

This patch adds a common implementation of this type of parsing and calls it when a gpio driver doesn't supply its' own xlate routine.

This will allow removal of the driver-specific versions in a handful of drivers and simplify the addition of new drivers.

The series,

Although one nit below.

Quoted 5 lines
drivers/gpio/gpio-uclass.c +3 -0
 
+int gpio_xlate_offs_flags(struct udevice *dev,
+					 struct gpio_desc *desc,
+					 struct fdtdec_phandle_args *args)

drivers/gpio/gpio-uclass.c int gpio_lookup_name(const char *name, struct udevice **devp, · line 129

Quoted 10 lines
drivers/gpio/gpio-uclass.c +10 -0
+{
+	int ret = -EINVAL;
+	if (args->args_count > 1) {
+		desc->offset = args->args[0];
+		if (args->args[1] & GPIO_ACTIVE_LOW)
+			desc->flags = GPIOD_ACTIVE_LOW;
+		ret = 0;
+	}
+	return ret;
+}

Why not return the error first, and avoid the need for an extra indentation level for the rest of the function, and make it quite a bit more readable in my opinion. The default could also be made to cover more situations (e.g. bindings that define a single cell for the GPIO but not cell at all for any flags):

if (args->args_count < 1)

     return -EINVAL;

desc->offset = args->args[0];

if (args->args_count < 2)

     return 0;

if (args->args[1] & GPIO_ACTIVE_LOW)

     desc->flags = GPIOD_ACTIVE_LOW;

return 0;

#23 lore raw

PATCH v2 1/6 dm: gpio: add a default gpio xlate routine

Hi Stephen,

Quoted 44 lines · Stephen Warren
Quoted 10 lines · Eric Nelson

Many drivers use a common form of offset + flags for device tree nodes. e.g.:

    <&gpio1 2 GPIO_ACTIVE_LOW>

This patch adds a common implementation of this type of parsing and calls it when a gpio driver doesn't supply its' own xlate routine.

This will allow removal of the driver-specific versions in a handful of drivers and simplify the addition of new drivers.

The series,

Although one nit below.

Quoted 5 lines
drivers/gpio/gpio-uclass.c +3 -0
 
+int gpio_xlate_offs_flags(struct udevice *dev,
+                     struct gpio_desc *desc,
+                     struct fdtdec_phandle_args *args)

drivers/gpio/gpio-uclass.c int gpio_lookup_name(const char *name, struct udevice **devp, · line 129

Quoted 10 lines
drivers/gpio/gpio-uclass.c +10 -0
+{
+    int ret = -EINVAL;
+    if (args->args_count > 1) {
+        desc->offset = args->args[0];
+        if (args->args[1] & GPIO_ACTIVE_LOW)
+            desc->flags = GPIOD_ACTIVE_LOW;
+        ret = 0;
+    }
+    return ret;
+}

Why not return the error first, and avoid the need for an extra indentation level for the rest of the function, and make it quite a bit more readable in my opinion. The default could also be made to cover more situations (e.g. bindings that define a single cell for the GPIO but not cell at all for any flags):

if (args->args_count < 1)

    return -EINVAL;

desc->offset = args->args[0];

Quoted 7 lines

if (args->args_count < 2)

    return 0;

if (args->args[1] & GPIO_ACTIVE_LOW)

    desc->flags = GPIOD_ACTIVE_LOW;

return 0;

I like it. V3 of that one patch forthcoming.

#24 lore raw

PATCH v3 1/6 dm: gpio: add a default gpio xlate routine

In reply to Stephen Warren

Many drivers use a common form of offset + flags for device tree nodes. e.g.:

	<&gpio1 2 GPIO_ACTIVE_LOW>

This patch adds a common implementation of this type of parsing and calls it when a gpio driver doesn't supply its' own xlate routine.

This will allow removal of the driver-specific versions in a handful of drivers and simplify the addition of new drivers.

---
V2 removes parsing of offset from the gpio_find_and_xlate routine, and only parses the offset and GPIO_ACTIVE_LOW flag when a driver-specific xlate is unavailable.

V3 re-works tests of the argument count as suggested by Stephen Warren and will allow parsing of nodes with no flags field:

	<&gpio1 2>
 drivers/gpio/gpio-uclass.c | 30 +++++++++++++++++++++++-------
 include/asm-generic/gpio.h | 19 ++++++++++++++-----
 2 files changed, 37 insertions(+), 12 deletions(-)
drivers/gpio/gpio-uclass.c +23 -7
index b58d4e6..3e83cec 100644
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <dt-bindings/gpio/gpio.h>
 #include <errno.h>
 #include <fdtdec.h>
 #include <malloc.h>
@@ -113,19 +114,33 @@ int gpio_lookup_name(const char *name, struct udevice **devp,
 	return 0;
 }
 
+int gpio_xlate_offs_flags(struct udevice *dev,
+					 struct gpio_desc *desc,
+					 struct fdtdec_phandle_args *args)
+{
+	if (args->args_count < 1)
+		return -EINVAL;
+
+	desc->offset = args->args[0];
+
+	if (args->args_count < 2)
+		return 0;
+
+	if (args->args[1] & GPIO_ACTIVE_LOW)
+		desc->flags = GPIOD_ACTIVE_LOW;
+
+	return 0;
+}
+
 static int gpio_find_and_xlate(struct gpio_desc *desc,
 			       struct fdtdec_phandle_args *args)
 {
 	struct dm_gpio_ops *ops = gpio_get_ops(desc->dev);
 
-	/* Use the first argument as the offset by default */
-	if (args->args_count > 0)
-		desc->offset = args->args[0];
+	if (ops->xlate)
+		return ops->xlate(desc->dev, desc, args);
 	else
-		desc->offset = -1;
-	desc->flags = 0;
-
-	return ops->xlate ? ops->xlate(desc->dev, desc, args) : 0;
+		return gpio_xlate_offs_flags(desc->dev, desc, args);
 }
 
 int dm_gpio_request(struct gpio_desc *desc, const char *label)
@@ -605,6 +620,7 @@ static int _gpio_request_by_name_nodev(const void *blob, int node,
 
 	desc->dev = NULL;
 	desc->offset = 0;
+	desc->flags = 0;
 	ret = fdtdec_parse_phandle_with_args(blob, node, list_name,
 					     "#gpio-cells", 0, index, &args);
 	if (ret) {
include/asm-generic/gpio.h +14 -5
index 68b5f0b..2500c10 100644
@@ -207,6 +207,16 @@ int gpio_requestf(unsigned gpio, const char *fmt, ...)
 struct fdtdec_phandle_args;
 
 /**
+ * gpio_xlate_offs_flags() - implementation for common use of dm_gpio_ops.xlate
+ *
+ * This routine sets the offset field to args[0] and the flags field to
+ * GPIOD_ACTIVE_LOW if the GPIO_ACTIVE_LOW flag is present in args[1].
+ *
+ */
+int gpio_xlate_offs_flags(struct udevice *dev, struct gpio_desc *desc,
+			  struct fdtdec_phandle_args *args);
+
+/**
  * struct struct dm_gpio_ops - Driver model GPIO operations
  *
  * Refer to functions above for description. These function largely copy
@@ -258,12 +268,11 @@ struct dm_gpio_ops {
 	 *
 	 *   @desc->dev to @dev
 	 *   @desc->flags to 0
-	 *   @desc->offset to the value of the first argument in args, if any,
-	 *		otherwise -1 (which is invalid)
+	 *   @desc->offset to 0
 	 *
-	 * This method is optional so if the above defaults suit it can be
-	 * omitted. Typical behaviour is to set up the GPIOD_ACTIVE_LOW flag
-	 * in desc->flags.
+	 * This method is optional and defaults to gpio_xlate_offs_flags,
+	 * which will parse offset and the GPIO_ACTIVE_LOW flag in the first
+	 * two arguments.
 	 *
 	 * Note that @dev is passed in as a parameter to follow driver model
 	 * uclass conventions, even though it is already available as
Signature · 1 line
2.6.2
#25 lore raw

PATCH v3 1/6 dm: gpio: add a default gpio xlate routine

Quoted 8 lines · Eric Nelson

Many drivers use a common form of offset + flags for device tree nodes. e.g.:

	<&gpio1 2 GPIO_ACTIVE_LOW>

This patch adds a common implementation of this type of parsing and calls it when a gpio driver doesn't supply its' own xlate routine.

Quoted 5 lines

This will allow removal of the driver-specific versions in a handful of drivers and simplify the addition of new drivers.

#26 lore raw

PATCH v2 2/6 gpio: intel_broadwell: remove gpio_xlate routine

In reply to Eric Nelson

With the addition of GPIO_ACTIVE_LOW parsing in gpio-uclass, the intel_broadwell driver doesn't need a custom xlate routine.

---
Nothing changed in V2.

 drivers/gpio/intel_broadwell_gpio.c | 10 ----------
 1 file changed, 10 deletions(-)
drivers/gpio/intel_broadwell_gpio.c +0 -10
index 8cf76f9..81ce446 100644
@@ -162,15 +162,6 @@ static int broadwell_gpio_ofdata_to_platdata(struct udevice *dev)
 	return 0;
 }
 
-static int broadwell_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
-				struct fdtdec_phandle_args *args)
-{
-	desc->offset = args->args[0];
-	desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;
-
-	return 0;
-}
-
 static const struct dm_gpio_ops gpio_broadwell_ops = {
 	.request		= broadwell_gpio_request,
 	.direction_input	= broadwell_gpio_direction_input,
@@ -178,7 +169,6 @@ static const struct dm_gpio_ops gpio_broadwell_ops = {
 	.get_value		= broadwell_gpio_get_value,
 	.set_value		= broadwell_gpio_set_value,
 	.get_function		= broadwell_gpio_get_function,
-	.xlate			= broadwell_gpio_xlate,
 };
 
 static const struct udevice_id intel_broadwell_gpio_ids[] = {
Signature · 1 line
2.6.2
#27 lore raw

PATCH v2 3/6 gpio: omap: remove gpio_xlate routine

In reply to Eric Nelson

With the addition of GPIO_ACTIVE_LOW parsing in gpio-uclass, the omap gpio driver doesn't need a custom xlate routine.

---
V2 removes the include of <dt-bindings/gpio/gpio.h>

 drivers/gpio/omap_gpio.c | 11 -----------
 1 file changed, 11 deletions(-)
drivers/gpio/omap_gpio.c +0 -11
index 93d18e4..cd960dc 100644
@@ -25,7 +25,6 @@
 #include <asm/io.h>
 #include <asm/errno.h>
 #include <malloc.h>
-#include <dt-bindings/gpio/gpio.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -277,22 +276,12 @@ static int omap_gpio_get_function(struct udevice *dev, unsigned offset)
 		return GPIOF_INPUT;
 }
 
-static int omap_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
-			   struct fdtdec_phandle_args *args)
-{
-	desc->offset = args->args[0];
-	desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;
-
-	return 0;
-}
-
 static const struct dm_gpio_ops gpio_omap_ops = {
 	.direction_input	= omap_gpio_direction_input,
 	.direction_output	= omap_gpio_direction_output,
 	.get_value		= omap_gpio_get_value,
 	.set_value		= omap_gpio_set_value,
 	.get_function		= omap_gpio_get_function,
-	.xlate			= omap_gpio_xlate,
 };
 
 static int omap_gpio_probe(struct udevice *dev)
Signature · 1 line
2.6.2
#28 lore raw

PATCH v2 4/6 gpio: pic32: remove gpio_xlate routine

In reply to Eric Nelson

With the addition of GPIO_ACTIVE_LOW parsing in gpio-uclass, the pic32 gpio driver doesn't need a custom xlate routine.

---
V2 removes the include of <dt-bindings/gpio/gpio.h>

 drivers/gpio/pic32_gpio.c | 10 ----------
 1 file changed, 10 deletions(-)
drivers/gpio/pic32_gpio.c +0 -10
index 499b4fa..7a037f3 100644
@@ -12,7 +12,6 @@
 #include <asm/io.h>
 #include <asm/gpio.h>
 #include <linux/compat.h>
-#include <dt-bindings/gpio/gpio.h>
 #include <mach/pic32.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -99,14 +98,6 @@ static int pic32_gpio_direction_output(struct udevice *dev,
 	return 0;
 }
 
-static int pic32_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
-			    struct fdtdec_phandle_args *args)
-{
-	desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;
-
-	return 0;
-}
-
 static int pic32_gpio_get_function(struct udevice *dev, unsigned offset)
 {
 	int ret = GPIOF_UNUSED;
@@ -131,7 +122,6 @@ static const struct dm_gpio_ops gpio_pic32_ops = {
 	.get_value		= pic32_gpio_get_value,
 	.set_value		= pic32_gpio_set_value,
 	.get_function		= pic32_gpio_get_function,
-	.xlate			= pic32_gpio_xlate,
 };
 
 static int pic32_gpio_probe(struct udevice *dev)
Signature · 1 line
2.6.2
#30 lore raw

PATCH v2 5/6 gpio: rk: remove gpio_xlate routine

In reply to Eric Nelson

With the addition of GPIO_ACTIVE_LOW parsing in gpio-uclass, the Rockchip gpio driver doesn't need a custom xlate routine.

---
V2 removes the include of <dt-bindings/gpio/gpio.h>

 drivers/gpio/rk_gpio.c | 11 -----------
 1 file changed, 11 deletions(-)
drivers/gpio/rk_gpio.c +0 -11
index 40e87bd..fefe3ca 100644
@@ -16,7 +16,6 @@
 #include <asm/io.h>
 #include <asm/arch/clock.h>
 #include <dm/pinctrl.h>
-#include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/clock/rk3288-cru.h>
 
 enum {
@@ -98,15 +97,6 @@ static int rockchip_gpio_get_function(struct udevice *dev, unsigned offset)
 #endif
 }
 
-static int rockchip_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
-			    struct fdtdec_phandle_args *args)
-{
-	desc->offset = args->args[0];
-	desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;
-
-	return 0;
-}
-
 static int rockchip_gpio_probe(struct udevice *dev)
 {
 	struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
@@ -135,7 +125,6 @@ static const struct dm_gpio_ops gpio_rockchip_ops = {
 	.get_value		= rockchip_gpio_get_value,
 	.set_value		= rockchip_gpio_set_value,
 	.get_function		= rockchip_gpio_get_function,
-	.xlate			= rockchip_gpio_xlate,
 };
 
 static const struct udevice_id rockchip_gpio_ids[] = {
Signature · 1 line
2.6.2
#31 lore raw

PATCH v2 6/6 gpio: exynos(s5p): remove gpio_xlate routine

In reply to Eric Nelson

With the addition of GPIO_ACTIVE_LOW parsing in gpio-uclass, the Exynos/S5P gpio driver doesn't need a custom xlate routine.

---
V2 removes the include of <dt-bindings/gpio/gpio.h>

 drivers/gpio/s5p_gpio.c | 11 -----------
 1 file changed, 11 deletions(-)
drivers/gpio/s5p_gpio.c +0 -11
index 0f22b23..377fed4 100644
@@ -13,7 +13,6 @@
 #include <asm/io.h>
 #include <asm/gpio.h>
 #include <dm/device-internal.h>
-#include <dt-bindings/gpio/gpio.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -276,22 +275,12 @@ static int exynos_gpio_get_function(struct udevice *dev, unsigned offset)
 		return GPIOF_FUNC;
 }
 
-static int exynos_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
-			     struct fdtdec_phandle_args *args)
-{
-	desc->offset = args->args[0];
-	desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;
-
-	return 0;
-}
-
 static const struct dm_gpio_ops gpio_exynos_ops = {
 	.direction_input	= exynos_gpio_direction_input,
 	.direction_output	= exynos_gpio_direction_output,
 	.get_value		= exynos_gpio_get_value,
 	.set_value		= exynos_gpio_set_value,
 	.get_function		= exynos_gpio_get_function,
-	.xlate			= exynos_gpio_xlate,
 };
 
 static int gpio_exynos_probe(struct udevice *dev)
Signature · 1 line
2.6.2
#32 lore raw

PATCH v2 6/6 gpio: exynos(s5p): remove gpio_xlate routine

Quoted 36 lines · Eric Nelson

With the addition of GPIO_ACTIVE_LOW parsing in gpio-uclass, the Exynos/S5P gpio driver doesn't need a custom xlate routine.

---
V2 removes the include of <dt-bindings/gpio/gpio.h>

 drivers/gpio/s5p_gpio.c | 11 -----------
 1 file changed, 11 deletions(-)
drivers/gpio/s5p_gpio.c +0 -10
index 0f22b23..377fed4 100644
@@ -13,7 +13,6 @@
 #include <asm/io.h>
 #include <asm/gpio.h>
 #include <dm/device-internal.h>
-#include <dt-bindings/gpio/gpio.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -276,22 +275,12 @@ static int exynos_gpio_get_function(struct udevice *dev, unsigned offset)
 		return GPIOF_FUNC;
 }
 
-static int exynos_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
-			     struct fdtdec_phandle_args *args)
-{
-	desc->offset = args->args[0];
-	desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;
-
-	return 0;
-}
-

drivers/gpio/s5p_gpio.c static int exynos_gpio_get_function(struct udevice *dev, unsigned offset) · line 286

Quoted 10 lines
drivers/gpio/s5p_gpio.c +0 -1
 static const struct dm_gpio_ops gpio_exynos_ops = {
 	.direction_input	= exynos_gpio_direction_input,
 	.direction_output	= exynos_gpio_direction_output,
 	.get_value		= exynos_gpio_get_value,
 	.set_value		= exynos_gpio_set_value,
 	.get_function		= exynos_gpio_get_function,
-	.xlate			= exynos_gpio_xlate,
 };
 
 static int gpio_exynos_probe(struct udevice *dev)

Thanks,
Minkyu Kang.

#33 lore raw

PATCH 1/1 dm: gpio: handle GPIO_ACTIVE_LOW flag in DT

In reply to Eric Nelson

Hi Eric,

Quoted 26 lines · Eric Nelson

Hi Peng,

Quoted 11 lines · Peng Fan

Hi Eric,

Quoted 5 lines · Eric Nelson

Device tree parsing of GPIO nodes is currently ignoring flags.

Add support for GPIO_ACTIVE_LOW by checking for the presence of the flag and setting the desc->flags field to the driver model constant GPIOD_ACTIVE_LOW.

You may need to try this: https://patchwork.ozlabs.org/patch/597363/

Thanks for pointing this out.

This patch also works, but it has me confused.

How/why is parsing the ACTIVE_LOW flag specific to MXC?

This is a general-purpose flag in the kernel, not something machine- specific.

It also appears that there are a bunch of other copies of this same bit of code in the various mach_xlate() routines:

Quoted 6 lines

desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;

If it's done in gpio-uclass, this isn't needed and xlate can be removed from mxc-gpio and quite a few other architectures.

Please advise,

I saw you have posted a patch set to convert other gpio drivers. But actually the translation of gpio property should be done by each gpio driver. Alought we have gpio-cells=<2> for most gpio drivers, but if there is one case that gpio-cells=<3>, and it have different meaning for each cell from other most drivers?

So I suggest we follow the linux way,

434 if (!chip->of_xlate) {
435 chip->of_gpio_n_cells = 2;
436 chip->of_xlate = of_gpio_simple_xlate;
437 }

If gpio drivers does not provide xlate function, then use a simple xlate function. If gpio drivers have their own xlate function, then use their own way. Also I do no think delete the xlate implementation is not a good idea.

Simon may give more comments on this.

Regards,
Peng.

Quoted 3 lines

Eric

#34 lore raw

PATCH 1/1 dm: gpio: handle GPIO_ACTIVE_LOW flag in DT

Hi Peng,

Quoted 28 lines · Peng Fan
Quoted 27 lines · Eric Nelson
Quoted 9 lines · Peng Fan
Quoted 5 lines · Eric Nelson

Device tree parsing of GPIO nodes is currently ignoring flags.

Add support for GPIO_ACTIVE_LOW by checking for the presence of the flag and setting the desc->flags field to the driver model constant GPIOD_ACTIVE_LOW.

You may need to try this: https://patchwork.ozlabs.org/patch/597363/

Thanks for pointing this out.

This patch also works, but it has me confused.

How/why is parsing the ACTIVE_LOW flag specific to MXC?

This is a general-purpose flag in the kernel, not something machine- specific.

It also appears that there are a bunch of other copies of this same bit of code in the various mach_xlate() routines:

desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;

If it's done in gpio-uclass, this isn't needed and xlate can be removed from mxc-gpio and quite a few other architectures.

Quoted 8 lines
Quoted 1 line

Please advise,

I saw you have posted a patch set to convert other gpio drivers. But actually the translation of gpio property should be done by each gpio driver. Alought we have gpio-cells=<2> for most gpio drivers, but if there is one case that gpio-cells=<3>, and it have different meaning for each cell from other most drivers?

Which case has gpio-cells=<3>?

As far as I can tell, only tegra and sandbox have something other than parsing of offset and the GPIO_ACTIVE_LOW flag.

Tegra seems to have gpio-cells=<2> and sandbox has either 0 or 1.

Quoted 11 lines

So I suggest we follow the linux way,

434 if (!chip->of_xlate) {
435 chip->of_gpio_n_cells = 2;
436 chip->of_xlate = of_gpio_simple_xlate;
437 }

If gpio drivers does not provide xlate function, then use a simple xlate function. If gpio drivers have their own xlate function, then use their own way.

The recommendation in device-tree-bindings/gpio/gpio.txt is to have the GPIO_ACTIVE_LOW/HIGH flag in the second cell, so parsing that directly in gpio_find_and_xlate() seems right.

That way, driver-specific parsing only needs to handle additional flags or needs as is the case with tegra.

Quoted 2 lines

Also I do no think delete the xlate implementation is not a good idea.

Which xlate routine? All of those that my patch set removes?

Since none of them do anything besides parsing the offset and GPIO_ACTIVE_LOW flag, this seems like code bloat.

Please advise,

Eric

#35 lore raw

PATCH 1/1 dm: gpio: handle GPIO_ACTIVE_LOW flag in DT

Quoted 53 lines · Eric Nelson

Hi Peng,

Quoted 28 lines · Peng Fan
Quoted 27 lines · Eric Nelson
Quoted 9 lines · Peng Fan
Quoted 5 lines · Eric Nelson

Device tree parsing of GPIO nodes is currently ignoring flags.

Add support for GPIO_ACTIVE_LOW by checking for the presence of the flag and setting the desc->flags field to the driver model constant GPIOD_ACTIVE_LOW.

You may need to try this: https://patchwork.ozlabs.org/patch/597363/

Thanks for pointing this out.

This patch also works, but it has me confused.

How/why is parsing the ACTIVE_LOW flag specific to MXC?

This is a general-purpose flag in the kernel, not something machine- specific.

It also appears that there are a bunch of other copies of this same bit of code in the various mach_xlate() routines:

desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;

If it's done in gpio-uclass, this isn't needed and xlate can be removed from mxc-gpio and quite a few other architectures.

Quoted 7 lines
Quoted 1 line

Please advise,

I saw you have posted a patch set to convert other gpio drivers. But actually the translation of gpio property should be done by each gpio driver. Alought we have gpio-cells=<2> for most gpio drivers, but if there is one case that gpio-cells=<3>, and it have different meaning for each cell from other most drivers?

Which case has gpio-cells=<3>?

As far as I can tell, only tegra and sandbox have something other than parsing of offset and the GPIO_ACTIVE_LOW flag.

Tegra seems to have gpio-cells=<2> and sandbox has either 0 or 1.

Quoted 7 lines

So I suggest we follow the linux way,

434 if (!chip->of_xlate) {
435 chip->of_gpio_n_cells = 2;
436 chip->of_xlate = of_gpio_simple_xlate;
437 }

Quoted 7 lines
Quoted 3 lines

If gpio drivers does not provide xlate function, then use a simple xlate function. If gpio drivers have their own xlate function, then use their own way.

The recommendation in device-tree-bindings/gpio/gpio.txt is to have the GPIO_ACTIVE_LOW/HIGH flag in the second cell, so parsing that directly in gpio_find_and_xlate() seems right.

That's a recommendation when designing GPIO controller bindings, not a definition of something that is categorically true for all bindings. Each binding is free to represent its flags (if any) in whatever way it wants, and so as Peng says, each driver has be in full control over its own of_xlate functionality. Now, for drivers that happen to use a common flag representation, we can plug in a common implementation of the xlate function.

#36 lore raw

PATCH 1/1 dm: gpio: handle GPIO_ACTIVE_LOW flag in DT

Hi Stephen and Peng,

Quoted 60 lines · Stephen Warren
Quoted 51 lines · Eric Nelson
Quoted 28 lines · Peng Fan
Quoted 27 lines · Eric Nelson
Quoted 9 lines · Peng Fan
Quoted 5 lines · Eric Nelson

Device tree parsing of GPIO nodes is currently ignoring flags.

Add support for GPIO_ACTIVE_LOW by checking for the presence of the flag and setting the desc->flags field to the driver model constant GPIOD_ACTIVE_LOW.

You may need to try this: https://patchwork.ozlabs.org/patch/597363/

Thanks for pointing this out.

This patch also works, but it has me confused.

How/why is parsing the ACTIVE_LOW flag specific to MXC?

This is a general-purpose flag in the kernel, not something machine- specific.

It also appears that there are a bunch of other copies of this same bit of code in the various mach_xlate() routines:

desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;

If it's done in gpio-uclass, this isn't needed and xlate can be removed from mxc-gpio and quite a few other architectures.

Quoted 7 lines
Quoted 1 line

Please advise,

I saw you have posted a patch set to convert other gpio drivers. But actually the translation of gpio property should be done by each gpio driver. Alought we have gpio-cells=<2> for most gpio drivers, but if there is one case that gpio-cells=<3>, and it have different meaning for each cell from other most drivers?

Which case has gpio-cells=<3>?

As far as I can tell, only tegra and sandbox have something other than parsing of offset and the GPIO_ACTIVE_LOW flag.

Tegra seems to have gpio-cells=<2> and sandbox has either 0 or 1.

Quoted 7 lines

So I suggest we follow the linux way,

434 if (!chip->of_xlate) {
435 chip->of_gpio_n_cells = 2;
436 chip->of_xlate = of_gpio_simple_xlate;
437 }

Quoted 7 lines
Quoted 3 lines

If gpio drivers does not provide xlate function, then use a simple xlate function. If gpio drivers have their own xlate function, then use their own way.

The recommendation in device-tree-bindings/gpio/gpio.txt is to have the GPIO_ACTIVE_LOW/HIGH flag in the second cell, so parsing that directly in gpio_find_and_xlate() seems right.

Quoted 7 lines

That's a recommendation when designing GPIO controller bindings, not a definition of something that is categorically true for all bindings. Each binding is free to represent its flags (if any) in whatever way it wants, and so as Peng says, each driver has be in full control over its own of_xlate functionality. Now, for drivers that happen to use a common flag representation, we can plug in a common implementation of the xlate function.

Isn't that what this patch-set does?

	http://lists.denx.de/pipermail/u-boot/2016-April/250228.html

For the cost of a couple of lines of code in gpio-uclass, we remove ~50 lines from existing implementations, essentially allowing them to use the common (or default) implementation. Nothing in the patch prevents completely custom handling by a driver.

If we want to be pedantic about requiring each driver to have function xlate, then we should get rid of gpio_find_and_xlate entirely from gpio-uclass.c.

Regards,

Eric

#37 lore raw

PATCH 1/1 dm: gpio: handle GPIO_ACTIVE_LOW flag in DT

Quoted 71 lines · Eric Nelson

Hi Stephen and Peng,

Quoted 60 lines · Stephen Warren
Quoted 51 lines · Eric Nelson
Quoted 28 lines · Peng Fan
Quoted 27 lines · Eric Nelson
Quoted 9 lines · Peng Fan
Quoted 5 lines · Eric Nelson

Device tree parsing of GPIO nodes is currently ignoring flags.

Add support for GPIO_ACTIVE_LOW by checking for the presence of the flag and setting the desc->flags field to the driver model constant GPIOD_ACTIVE_LOW.

You may need to try this: https://patchwork.ozlabs.org/patch/597363/

Thanks for pointing this out.

This patch also works, but it has me confused.

How/why is parsing the ACTIVE_LOW flag specific to MXC?

This is a general-purpose flag in the kernel, not something machine- specific.

It also appears that there are a bunch of other copies of this same bit of code in the various mach_xlate() routines:

desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;

If it's done in gpio-uclass, this isn't needed and xlate can be removed from mxc-gpio and quite a few other architectures.

Quoted 7 lines
Quoted 1 line

Please advise,

I saw you have posted a patch set to convert other gpio drivers. But actually the translation of gpio property should be done by each gpio driver. Alought we have gpio-cells=<2> for most gpio drivers, but if there is one case that gpio-cells=<3>, and it have different meaning for each cell from other most drivers?

Which case has gpio-cells=<3>?

As far as I can tell, only tegra and sandbox have something other than parsing of offset and the GPIO_ACTIVE_LOW flag.

Tegra seems to have gpio-cells=<2> and sandbox has either 0 or 1.

Quoted 7 lines

So I suggest we follow the linux way,

434 if (!chip->of_xlate) {
435 chip->of_gpio_n_cells = 2;
436 chip->of_xlate = of_gpio_simple_xlate;
437 }

Quoted 7 lines
Quoted 3 lines

If gpio drivers does not provide xlate function, then use a simple xlate function. If gpio drivers have their own xlate function, then use their own way.

The recommendation in device-tree-bindings/gpio/gpio.txt is to have the GPIO_ACTIVE_LOW/HIGH flag in the second cell, so parsing that directly in gpio_find_and_xlate() seems right.

Quoted 7 lines

That's a recommendation when designing GPIO controller bindings, not a definition of something that is categorically true for all bindings. Each binding is free to represent its flags (if any) in whatever way it wants, and so as Peng says, each driver has be in full control over its own of_xlate functionality. Now, for drivers that happen to use a common flag representation, we can plug in a common implementation of the xlate function.

Quoted 2 lines

Isn't that what this patch-set does?

	http://lists.denx.de/pipermail/u-boot/2016-April/250228.html

No, I don't believe so. Rather, it forcibly decodes the common layout in the common code, in such a way that it's always used. Then, the driver-specific of_xlate is called, which could fix up (i.e. undo) the incorrect results if they weren't appropriate, and then apply the correct translation.

Better would be to never decode the results incorrectly in the first place, yet allow each driver to use the common decoder function if it's appropriate.

gpio_find_and_xlate() should do either exactly:

a)

return ops->xlate(desc->dev, desc, args);

In this case, .xlate could never be NULL, and all drivers would need to provide some implementation. We could provide a common implementation gpio_xlate_common() that all drivers (that use the common DT specifier layout) can plug into their .xlate pointer.

b)

if (ops->xlate)

     return ops->xlate(desc->dev, desc, args);
else
     return gpio_xlate_common(desc->dev, desc, args);

Making that else clause call a separate function allows any custom ops->xlate implementation to call it too, assuming the code there is valid but simply needs extension rather than completely custom replacement.

Quoted 8 lines

For the cost of a couple of lines of code in gpio-uclass, we remove ~50 lines from existing implementations, essentially allowing them to use the common (or default) implementation. Nothing in the patch prevents completely custom handling by a driver.

If we want to be pedantic about requiring each driver to have function xlate, then we should get rid of gpio_find_and_xlate entirely from gpio-uclass.c.

The intent of the change is good.

I'm not sure why we need to remove gpio_find_and_xlate(); it provides an API for clients so they don't need to know how to access driver functionality through the ops pointer, which I think is an internal/private implementation detail. Is that detail exposed to clients in other places? If so, removing the wrapper seems fine. If not, I suspect it's a deliberate abstraction.

#38 lore raw

PATCH 1/1 dm: gpio: handle GPIO_ACTIVE_LOW flag in DT

Hi,

Quoted 131 lines · Stephen Warren
Quoted 85 lines · Eric Nelson

Hi Stephen and Peng,

Quoted 72 lines · Stephen Warren
Quoted 65 lines · Eric Nelson
Quoted 33 lines · Peng Fan
Quoted 31 lines · Eric Nelson
Quoted 12 lines · Peng Fan
Quoted 6 lines · Eric Nelson

Device tree parsing of GPIO nodes is currently ignoring flags.

Add support for GPIO_ACTIVE_LOW by checking for the presence of the flag and setting the desc->flags field to the driver model constant GPIOD_ACTIVE_LOW.

You may need to try this: https://patchwork.ozlabs.org/patch/597363/

Thanks for pointing this out.

This patch also works, but it has me confused.

How/why is parsing the ACTIVE_LOW flag specific to MXC?

This is a general-purpose flag in the kernel, not something machine- specific.

It also appears that there are a bunch of other copies of this same bit of code in the various mach_xlate() routines:

desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;

If it's done in gpio-uclass, this isn't needed and xlate can be removed from mxc-gpio and quite a few other architectures.

Quoted 8 lines
Quoted 1 line

Please advise,

I saw you have posted a patch set to convert other gpio drivers. But actually the translation of gpio property should be done by each gpio driver. Alought we have gpio-cells=<2> for most gpio drivers, but if there is one case that gpio-cells=<3>, and it have different meaning for each cell from other most drivers?

Which case has gpio-cells=<3>?

As far as I can tell, only tegra and sandbox have something other than parsing of offset and the GPIO_ACTIVE_LOW flag.

Tegra seems to have gpio-cells=<2> and sandbox has either 0 or 1.

Quoted 11 lines

So I suggest we follow the linux way,

434 if (!chip->of_xlate) {
435 chip->of_gpio_n_cells = 2;
436 chip->of_xlate = of_gpio_simple_xlate;
437 }

If gpio drivers does not provide xlate function, then use a simple xlate
function. If gpio drivers have their own xlate function, then use their own way.

Quoted 3 lines

The recommendation in device-tree-bindings/gpio/gpio.txt is to have the GPIO_ACTIVE_LOW/HIGH flag in the second cell, so parsing that directly in gpio_find_and_xlate() seems right.

Quoted 7 lines

That's a recommendation when designing GPIO controller bindings, not a definition of something that is categorically true for all bindings. Each binding is free to represent its flags (if any) in whatever way it wants, and so as Peng says, each driver has be in full control over its own of_xlate functionality. Now, for drivers that happen to use a common flag representation, we can plug in a common implementation of the xlate function.

Quoted 2 lines

Isn't that what this patch-set does?

        http://lists.denx.de/pipermail/u-boot/2016-April/250228.html

No, I don't believe so. Rather, it forcibly decodes the common layout in the common code, in such a way that it's always used. Then, the driver-specific of_xlate is called, which could fix up (i.e. undo) the incorrect results if they weren't appropriate, and then apply the correct translation.

Better would be to never decode the results incorrectly in the first place, yet allow each driver to use the common decoder function if it's appropriate.

gpio_find_and_xlate() should do either exactly:

a)

return ops->xlate(desc->dev, desc, args);

In this case, .xlate could never be NULL, and all drivers would need to provide some implementation. We could provide a common implementation gpio_xlate_common() that all drivers (that use the common DT specifier layout) can plug into their .xlate pointer.

b)

if (ops->xlate)

    return ops->xlate(desc->dev, desc, args);
else
    return gpio_xlate_common(desc->dev, desc, args);

Making that else clause call a separate function allows any custom ops->xlate implementation to call it too, assuming the code there is valid but simply needs extension rather than completely custom replacement.

Quoted 8 lines

For the cost of a couple of lines of code in gpio-uclass, we remove ~50 lines from existing implementations, essentially allowing them to use the common (or default) implementation. Nothing in the patch prevents completely custom handling by a driver.

If we want to be pedantic about requiring each driver to have function xlate, then we should get rid of gpio_find_and_xlate entirely from gpio-uclass.c.

Quoted 7 lines

The intent of the change is good.

I'm not sure why we need to remove gpio_find_and_xlate(); it provides an API for clients so they don't need to know how to access driver functionality through the ops pointer, which I think is an internal/private implementation detail. Is that detail exposed to clients in other places? If so, removing the wrapper seems fine. If not, I suspect it's a deliberate abstraction.

This seems a bit pedantic, but since Linux does it this way I think we should follow along.

Eric you still get to remove the code from all the GPIO drivers - the difference is just creating a common function to call when no xlate() method is available.

Can you please take a look at what Stephen suggests?

Regards,
Simon

#39 lore raw

PATCH 1/1 dm: gpio: handle GPIO_ACTIVE_LOW flag in DT

Hi Simon,

Quoted 15 lines · Simon Glass
Quoted 14 lines · Stephen Warren
Quoted 13 lines · Eric Nelson
Quoted 12 lines · Stephen Warren
Quoted 11 lines · Eric Nelson
Quoted 10 lines · Peng Fan
Quoted 9 lines · Eric Nelson
Quoted 8 lines · Peng Fan
Quoted 6 lines · Eric Nelson

Device tree parsing of GPIO nodes is currently ignoring flags.

Add support for GPIO_ACTIVE_LOW by checking for the presence of the flag and setting the desc->flags field to the driver model constant GPIOD_ACTIVE_LOW.

<snip>

Quoted 9 lines
Quoted 8 lines

The intent of the change is good.

I'm not sure why we need to remove gpio_find_and_xlate(); it provides an API for clients so they don't need to know how to access driver functionality through the ops pointer, which I think is an internal/private implementation detail. Is that detail exposed to clients in other places? If so, removing the wrapper seems fine. If not, I suspect it's a deliberate abstraction.

Quoted 9 lines

This seems a bit pedantic, but since Linux does it this way I think we should follow along.

Eric you still get to remove the code from all the GPIO drivers - the difference is just creating a common function to call when no xlate() method is available.

Can you please take a look at what Stephen suggests?

Got it. I'm just not sure about where to start (before or after the patch set you sent) and whether to also remove offset parsing from gpio_find_and_xlate().

#40 lore raw

PATCH 1/1 dm: gpio: handle GPIO_ACTIVE_LOW flag in DT

Hi Eric,

Quoted 37 lines · Eric Nelson

Hi Simon,

Quoted 15 lines · Simon Glass
Quoted 14 lines · Stephen Warren
Quoted 13 lines · Eric Nelson
Quoted 12 lines · Stephen Warren
Quoted 11 lines · Eric Nelson
Quoted 10 lines · Peng Fan
Quoted 9 lines · Eric Nelson
Quoted 8 lines · Peng Fan
Quoted 6 lines · Eric Nelson

Device tree parsing of GPIO nodes is currently ignoring flags.

Add support for GPIO_ACTIVE_LOW by checking for the presence of the flag and setting the desc->flags field to the driver model constant GPIOD_ACTIVE_LOW.

<snip>

Quoted 16 lines
Quoted 8 lines

The intent of the change is good.

I'm not sure why we need to remove gpio_find_and_xlate(); it provides an API for clients so they don't need to know how to access driver functionality through the ops pointer, which I think is an internal/private implementation detail. Is that detail exposed to clients in other places? If so, removing the wrapper seems fine. If not, I suspect it's a deliberate abstraction.

This seems a bit pedantic, but since Linux does it this way I think we should follow along.

Eric you still get to remove the code from all the GPIO drivers - the difference is just creating a common function to call when no xlate() method is available.

Quoted 7 lines
Quoted 2 lines

Can you please take a look at what Stephen suggests?

Got it. I'm just not sure about where to start (before or after the patch set you sent) and whether to also remove offset parsing from gpio_find_and_xlate().

Which patch did I send? My understanding is:

- Add my review/ack tag to the patches as necessary
- Drop the tegra patch
- Update gpio_find_and_xlate() to call a default function if there is no xlate() method
- Resend the series

I'm not sure about removing the existing functionality from gpio_find_and_xlate(), but my guess is that it is best to move it to your default function, so that gpio_find_and_xlate() doesn't include any default behaviour in the case where there is a xlate() method.

Regards,
Simon

#41 lore raw

PATCH 1/1 dm: gpio: handle GPIO_ACTIVE_LOW flag in DT

Hi Simon,

Quoted 43 lines · Simon Glass

Hi Eric,

Quoted 40 lines · Eric Nelson

Hi Simon,

Quoted 15 lines · Simon Glass
Quoted 14 lines · Stephen Warren
Quoted 13 lines · Eric Nelson
Quoted 12 lines · Stephen Warren
Quoted 11 lines · Eric Nelson
Quoted 10 lines · Peng Fan
Quoted 9 lines · Eric Nelson
Quoted 8 lines · Peng Fan
Quoted 6 lines · Eric Nelson

Device tree parsing of GPIO nodes is currently ignoring flags.

Add support for GPIO_ACTIVE_LOW by checking for the presence of the flag and setting the desc->flags field to the driver model constant GPIOD_ACTIVE_LOW.

<snip>

Quoted 18 lines
Quoted 8 lines

The intent of the change is good.

I'm not sure why we need to remove gpio_find_and_xlate(); it provides an API for clients so they don't need to know how to access driver functionality through the ops pointer, which I think is an internal/private implementation detail. Is that detail exposed to clients in other places? If so, removing the wrapper seems fine. If not, I suspect it's a deliberate abstraction.

This seems a bit pedantic, but since Linux does it this way I think we should follow along.

Eric you still get to remove the code from all the GPIO drivers - the difference is just creating a common function to call when no xlate() method is available.

Can you please take a look at what Stephen suggests?

Quoted 7 lines
Quoted 4 lines

Got it. I'm just not sure about where to start (before or after the patch set you sent) and whether to also remove offset parsing from gpio_find_and_xlate().

Which patch did I send? My understanding is:

At the time I sent this, you had just submitted the patch set adding more driver-model support for block devices.

	http://lists.denx.de/pipermail/u-boot/2016-April/251095.html
Quoted 11 lines

- Add my review/ack tag to the patches as necessary
- Drop the tegra patch
- Update gpio_find_and_xlate() to call a default function if there is no xlate() method
- Resend the series

I'm not sure about removing the existing functionality from gpio_find_and_xlate(), but my guess is that it is best to move it to your default function, so that gpio_find_and_xlate() doesn't include any default behaviour in the case where there is a xlate() method.

Reviewing the use of the offset field did yield some information about the broken sunxi support and also that Vybrid was also missing the xlate routine.

Since reviewing your patch sets (driver model updates for blk and also driver model updates for mmc) will take some time, so I'll base an updated patch set on master. My guess is that any merge issues will be trivial.

I'll remove your acks in the updated patch set, since the updates to the drivers won't drop the xlate field, but will connect them to the common (__maybe_unused) routine. This will prevent the code from leaking into machines like Tegra that don't need the common code.

Regards,

Eric

#42 lore raw

PATCH 1/1 dm: gpio: handle GPIO_ACTIVE_LOW flag in DT

Hi Eric,

Quoted 71 lines · Eric Nelson

Hi Simon,

Quoted 43 lines · Simon Glass

Hi Eric,

Quoted 40 lines · Eric Nelson

Hi Simon,

Quoted 15 lines · Simon Glass
Quoted 14 lines · Stephen Warren
Quoted 13 lines · Eric Nelson
Quoted 12 lines · Stephen Warren
Quoted 11 lines · Eric Nelson
Quoted 10 lines · Peng Fan
Quoted 9 lines · Eric Nelson
Quoted 8 lines · Peng Fan
Quoted 6 lines · Eric Nelson

Device tree parsing of GPIO nodes is currently ignoring flags.

Add support for GPIO_ACTIVE_LOW by checking for the presence of the flag and setting the desc->flags field to the driver model constant GPIOD_ACTIVE_LOW.

<snip>

Quoted 18 lines
Quoted 8 lines

The intent of the change is good.

I'm not sure why we need to remove gpio_find_and_xlate(); it provides an API for clients so they don't need to know how to access driver functionality through the ops pointer, which I think is an internal/private implementation detail. Is that detail exposed to clients in other places? If so, removing the wrapper seems fine. If not, I suspect it's a deliberate abstraction.

This seems a bit pedantic, but since Linux does it this way I think we should follow along.

Eric you still get to remove the code from all the GPIO drivers - the difference is just creating a common function to call when no xlate() method is available.

Can you please take a look at what Stephen suggests?

Quoted 7 lines
Quoted 4 lines

Got it. I'm just not sure about where to start (before or after the patch set you sent) and whether to also remove offset parsing from gpio_find_and_xlate().

Which patch did I send? My understanding is:

At the time I sent this, you had just submitted the patch set adding more driver-model support for block devices.

        http://lists.denx.de/pipermail/u-boot/2016-April/251095.html
Quoted 11 lines

- Add my review/ack tag to the patches as necessary
- Drop the tegra patch
- Update gpio_find_and_xlate() to call a default function if there is no xlate() method
- Resend the series

I'm not sure about removing the existing functionality from gpio_find_and_xlate(), but my guess is that it is best to move it to your default function, so that gpio_find_and_xlate() doesn't include any default behaviour in the case where there is a xlate() method.

Quoted 8 lines

Reviewing the use of the offset field did yield some information about the broken sunxi support and also that Vybrid was also missing the xlate routine.

Since reviewing your patch sets (driver model updates for blk and also driver model updates for mmc) will take some time, so I'll base an updated patch set on master. My guess is that any merge issues will be trivial.

Yes, that's right.

Quoted 5 lines

I'll remove your acks in the updated patch set, since the updates to the drivers won't drop the xlate field, but will connect them to the common (__maybe_unused) routine. This will prevent the code from leaking into machines like Tegra that don't need the common code.

I'm pretty sure you can drop the xlate() implementations from the functions, though, and those at the patches I acked.

I don't think you need __maybe_unused

static int gpio_find_and_xlate(...)
{
get ops...

if (ops->xlate)

      return ops->xlate(....)

else
return gpio_default_xlate()...
}

gpio_default_xlate() (or whatever name you use) should be exported so drivers can use it.

Regards,
Simon

#43 lore raw

PATCH 1/1 dm: gpio: handle GPIO_ACTIVE_LOW flag in DT

Hi Simon,

Quoted 97 lines · Simon Glass
Quoted 65 lines · Eric Nelson
Quoted 39 lines · Simon Glass
Quoted 38 lines · Eric Nelson
Quoted 15 lines · Simon Glass
Quoted 14 lines · Stephen Warren
Quoted 13 lines · Eric Nelson
Quoted 12 lines · Stephen Warren
Quoted 11 lines · Eric Nelson
Quoted 10 lines · Peng Fan
Quoted 9 lines · Eric Nelson
Quoted 8 lines · Peng Fan
Quoted 6 lines · Eric Nelson

Device tree parsing of GPIO nodes is currently ignoring flags.

Add support for GPIO_ACTIVE_LOW by checking for the presence
of the flag and setting the desc->flags field to the driver
model constant GPIOD_ACTIVE_LOW.

<snip>

Quoted 18 lines
Quoted 8 lines

The intent of the change is good.

I'm not sure why we need to remove gpio_find_and_xlate(); it provides an API for clients so they don't need to know how to access driver functionality through the ops pointer, which I think is an internal/private implementation detail. Is that detail exposed to clients in other places? If so, removing the wrapper seems fine. If not, I suspect it's a deliberate abstraction.

This seems a bit pedantic, but since Linux does it this way I think we should follow along.

Eric you still get to remove the code from all the GPIO drivers - the difference is just creating a common function to call when no xlate() method is available.

Can you please take a look at what Stephen suggests?

Quoted 7 lines
Quoted 4 lines

Got it. I'm just not sure about where to start (before or after the patch set you sent) and whether to also remove offset parsing from gpio_find_and_xlate().

Which patch did I send? My understanding is:

At the time I sent this, you had just submitted the patch set adding more driver-model support for block devices.

        http://lists.denx.de/pipermail/u-boot/2016-April/251095.html
Quoted 11 lines

- Add my review/ack tag to the patches as necessary
- Drop the tegra patch
- Update gpio_find_and_xlate() to call a default function if there is no xlate() method
- Resend the series

I'm not sure about removing the existing functionality from gpio_find_and_xlate(), but my guess is that it is best to move it to your default function, so that gpio_find_and_xlate() doesn't include any default behaviour in the case where there is a xlate() method.

Quoted 8 lines

Reviewing the use of the offset field did yield some information about the broken sunxi support and also that Vybrid was also missing the xlate routine.

Since reviewing your patch sets (driver model updates for blk and also driver model updates for mmc) will take some time, so I'll base an updated patch set on master. My guess is that any merge issues will be trivial.

Yes, that's right.

Quoted 5 lines

I'll remove your acks in the updated patch set, since the updates to the drivers won't drop the xlate field, but will connect them to the common (__maybe_unused) routine. This will prevent the code from leaking into machines like Tegra that don't need the common code.

I'm pretty sure you can drop the xlate() implementations from the functions, though, and those at the patches I acked.

I don't think you need __maybe_unused

static int gpio_find_and_xlate(...)

{
   get ops...

   if (ops->xlate)
      return ops->xlate(....)
   else
      return gpio_default_xlate()...
}
Quoted 3 lines

gpio_default_xlate() (or whatever name you use) should be exported so drivers can use it.

This will leak gpio_default_xlate (locally named gpio_xlate_offs_flags) into machines that don't need it.

I can go the route you suggest above, but it will cost the tegra and sandbox builds ~64 bytes ;)

#44 lore raw

PATCH 1/1 dm: gpio: handle GPIO_ACTIVE_LOW flag in DT

Hi Eric,

Quoted 104 lines · Eric Nelson

Hi Simon,

Quoted 97 lines · Simon Glass
Quoted 65 lines · Eric Nelson
Quoted 39 lines · Simon Glass
Quoted 38 lines · Eric Nelson
Quoted 15 lines · Simon Glass
Quoted 14 lines · Stephen Warren
Quoted 13 lines · Eric Nelson
Quoted 12 lines · Stephen Warren
Quoted 11 lines · Eric Nelson
Quoted 10 lines · Peng Fan
Quoted 9 lines · Eric Nelson
Quoted 8 lines · Peng Fan

On Fri, Mar 25, 2016 at 01:12:11PM -0700, Eric Nelson wrote:

Device tree parsing of GPIO nodes is currently ignoring flags.

Add support for GPIO_ACTIVE_LOW by checking for the presence
of the flag and setting the desc->flags field to the driver
model constant GPIOD_ACTIVE_LOW.

<snip>

Quoted 18 lines
Quoted 8 lines

The intent of the change is good.

I'm not sure why we need to remove gpio_find_and_xlate(); it provides an API for clients so they don't need to know how to access driver functionality through the ops pointer, which I think is an internal/private implementation detail. Is that detail exposed to clients in other places? If so, removing the wrapper seems fine. If not, I suspect it's a deliberate abstraction.

This seems a bit pedantic, but since Linux does it this way I think we should follow along.

Eric you still get to remove the code from all the GPIO drivers - the difference is just creating a common function to call when no xlate() method is available.

Can you please take a look at what Stephen suggests?

Quoted 7 lines
Quoted 4 lines

Got it. I'm just not sure about where to start (before or after the patch set you sent) and whether to also remove offset parsing from gpio_find_and_xlate().

Which patch did I send? My understanding is:

At the time I sent this, you had just submitted the patch set adding more driver-model support for block devices.

        http://lists.denx.de/pipermail/u-boot/2016-April/251095.html
Quoted 11 lines

- Add my review/ack tag to the patches as necessary
- Drop the tegra patch
- Update gpio_find_and_xlate() to call a default function if there is no xlate() method
- Resend the series

I'm not sure about removing the existing functionality from gpio_find_and_xlate(), but my guess is that it is best to move it to your default function, so that gpio_find_and_xlate() doesn't include any default behaviour in the case where there is a xlate() method.

Quoted 8 lines

Reviewing the use of the offset field did yield some information about the broken sunxi support and also that Vybrid was also missing the xlate routine.

Since reviewing your patch sets (driver model updates for blk and also driver model updates for mmc) will take some time, so I'll base an updated patch set on master. My guess is that any merge issues will be trivial.

Yes, that's right.

Quoted 5 lines

I'll remove your acks in the updated patch set, since the updates to the drivers won't drop the xlate field, but will connect them to the common (__maybe_unused) routine. This will prevent the code from leaking into machines like Tegra that don't need the common code.

I'm pretty sure you can drop the xlate() implementations from the functions, though, and those at the patches I acked.

I don't think you need __maybe_unused

static int gpio_find_and_xlate(...)

{
   get ops...

   if (ops->xlate)
      return ops->xlate(....)
   else
      return gpio_default_xlate()...
}
Quoted 3 lines

gpio_default_xlate() (or whatever name you use) should be exported so drivers can use it.

Quoted 6 lines

This will leak gpio_default_xlate (locally named gpio_xlate_offs_flags) into machines that don't need it.

I can go the route you suggest above, but it will cost the tegra and sandbox builds ~64 bytes ;)

Sure, but we can live with that.

Regards,
Simon

#45 lore raw

PATCH 1/1 dm: gpio: handle GPIO_ACTIVE_LOW flag in DT

Quoted 107 lines · Simon Glass

Hi Eric,

Quoted 104 lines · Eric Nelson

Hi Simon,

Quoted 100 lines · Simon Glass
Quoted 65 lines · Eric Nelson
Quoted 39 lines · Simon Glass
Quoted 38 lines · Eric Nelson
Quoted 15 lines · Simon Glass
Quoted 14 lines · Stephen Warren
Quoted 13 lines · Eric Nelson
Quoted 12 lines · Stephen Warren
Quoted 11 lines · Eric Nelson
Quoted 10 lines · Peng Fan
Quoted 9 lines · Eric Nelson

On 03/28/2016 09:57 PM, Peng Fan wrote:
On Fri, Mar 25, 2016 at 01:12:11PM -0700, Eric Nelson wrote:

Device tree parsing of GPIO nodes is currently ignoring flags.

Add support for GPIO_ACTIVE_LOW by checking for the presence
of the flag and setting the desc->flags field to the driver
model constant GPIOD_ACTIVE_LOW.

<snip>

Quoted 18 lines
Quoted 8 lines

The intent of the change is good.

I'm not sure why we need to remove gpio_find_and_xlate(); it provides an API for clients so they don't need to know how to access driver functionality through the ops pointer, which I think is an internal/private implementation detail. Is that detail exposed to clients in other places? If so, removing the wrapper seems fine. If not, I suspect it's a deliberate abstraction.

This seems a bit pedantic, but since Linux does it this way I think we should follow along.

Eric you still get to remove the code from all the GPIO drivers - the difference is just creating a common function to call when no xlate() method is available.

Can you please take a look at what Stephen suggests?

Quoted 7 lines
Quoted 4 lines

Got it. I'm just not sure about where to start (before or after the patch set you sent) and whether to also remove offset parsing from gpio_find_and_xlate().

Which patch did I send? My understanding is:

At the time I sent this, you had just submitted the patch set adding more driver-model support for block devices.

         http://lists.denx.de/pipermail/u-boot/2016-April/251095.html
Quoted 11 lines

- Add my review/ack tag to the patches as necessary
- Drop the tegra patch
- Update gpio_find_and_xlate() to call a default function if there is no xlate() method
- Resend the series

I'm not sure about removing the existing functionality from gpio_find_and_xlate(), but my guess is that it is best to move it to your default function, so that gpio_find_and_xlate() doesn't include any default behaviour in the case where there is a xlate() method.

Quoted 8 lines

Reviewing the use of the offset field did yield some information about the broken sunxi support and also that Vybrid was also missing the xlate routine.

Since reviewing your patch sets (driver model updates for blk and also driver model updates for mmc) will take some time, so I'll base an updated patch set on master. My guess is that any merge issues will be trivial.

Yes, that's right.

Quoted 5 lines

I'll remove your acks in the updated patch set, since the updates to the drivers won't drop the xlate field, but will connect them to the common (__maybe_unused) routine. This will prevent the code from leaking into machines like Tegra that don't need the common code.

I'm pretty sure you can drop the xlate() implementations from the functions, though, and those at the patches I acked.

I don't think you need __maybe_unused

static int gpio_find_and_xlate(...)

{
    get ops...

    if (ops->xlate)
       return ops->xlate(....)
    else
       return gpio_default_xlate()...
}

gpio_default_xlate() (or whatever name you use) should be exported so drivers can use it.

Quoted 8 lines
Quoted 6 lines

This will leak gpio_default_xlate (locally named gpio_xlate_offs_flags) into machines that don't need it.

I can go the route you suggest above, but it will cost the tegra and sandbox builds ~64 bytes ;)

Sure, but we can live with that.

You can avoid that by requiring that ops->xlate always be non-NULL, and simply referencing the default function from drivers that want to use it. Not a big deal either way though.

#46 lore raw

PATCH 1/1 dm: gpio: handle GPIO_ACTIVE_LOW flag in DT

Hi,

Quoted 145 lines · Stephen Warren
Quoted 144 lines · Simon Glass

Hi Eric,

Quoted 139 lines · Eric Nelson

Hi Simon,

Quoted 125 lines · Simon Glass
Quoted 89 lines · Eric Nelson
Quoted 62 lines · Simon Glass
Quoted 60 lines · Eric Nelson
Quoted 27 lines · Simon Glass
Quoted 24 lines · Stephen Warren
Quoted 22 lines · Eric Nelson
Quoted 20 lines · Stephen Warren
Quoted 18 lines · Eric Nelson
Quoted 16 lines · Peng Fan

On Thu, Mar 31, 2016 at 01:41:04PM -0700, Eric Nelson wrote:

On 03/28/2016 09:57 PM, Peng Fan wrote:

On Fri, Mar 25, 2016 at 01:12:11PM -0700, Eric Nelson wrote:

Device tree parsing of GPIO nodes is currently ignoring
flags.

Add support for GPIO_ACTIVE_LOW by checking for the presence
of the flag and setting the desc->flags field to the driver
model constant GPIOD_ACTIVE_LOW.

<snip>

Quoted 27 lines
Quoted 13 lines

The intent of the change is good.

I'm not sure why we need to remove gpio_find_and_xlate(); it provides an API
for clients so they don't need to know how to access driver functionality
through the ops pointer, which I think is an internal/private implementation
detail. Is that detail exposed to clients in other places? If so, removing
the wrapper seems fine. If not, I suspect it's a deliberate abstraction.

This seems a bit pedantic, but since Linux does it this way I think we
should follow along.

Eric you still get to remove the code from all the GPIO drivers - the
difference is just creating a common function to call when no xlate()
method is available.

Can you please take a look at what Stephen suggests?

Quoted 7 lines
Quoted 4 lines

Got it. I'm just not sure about where to start (before or after the patch set you sent) and whether to also remove offset parsing from gpio_find_and_xlate().

Which patch did I send? My understanding is:

At the time I sent this, you had just submitted the patch set adding more driver-model support for block devices.

         http://lists.denx.de/pipermail/u-boot/2016-April/251095.html
Quoted 11 lines

- Add my review/ack tag to the patches as necessary
- Drop the tegra patch
- Update gpio_find_and_xlate() to call a default function if there is no xlate() method
- Resend the series

I'm not sure about removing the existing functionality from gpio_find_and_xlate(), but my guess is that it is best to move it to your default function, so that gpio_find_and_xlate() doesn't include any default behaviour in the case where there is a xlate() method.

Quoted 8 lines

Reviewing the use of the offset field did yield some information about the broken sunxi support and also that Vybrid was also missing the xlate routine.

Since reviewing your patch sets (driver model updates for blk and also driver model updates for mmc) will take some time, so I'll base an updated patch set on master. My guess is that any merge issues will be trivial.

Yes, that's right.

Quoted 6 lines

I'll remove your acks in the updated patch set, since the updates to the drivers won't drop the xlate field, but will connect them to the common (__maybe_unused) routine. This will prevent the code from leaking into machines like Tegra that don't need the common code.

I'm pretty sure you can drop the xlate() implementations from the functions, though, and those at the patches I acked.

I don't think you need __maybe_unused

static int gpio_find_and_xlate(...)

{
    get ops...

    if (ops->xlate)
       return ops->xlate(....)
    else
       return gpio_default_xlate()...
}
Quoted 3 lines

gpio_default_xlate() (or whatever name you use) should be exported so drivers can use it.

This will leak gpio_default_xlate (locally named gpio_xlate_offs_flags) into machines that don't need it.

I can go the route you suggest above, but it will cost the tegra and sandbox builds ~64 bytes ;)

Quoted 6 lines
Quoted 1 line

Sure, but we can live with that.

You can avoid that by requiring that ops->xlate always be non-NULL, and simply referencing the default function from drivers that want to use it. Not a big deal either way though.

I'd prefer not to do that. It just adds cruft, the removal of which is the purpose of Eric's series.

Regards,
Simon

#47 lore raw

PATCH 1/1 dm: gpio: handle GPIO_ACTIVE_LOW flag in DT

Quoted 9 lines · Simon Glass

Hi,

Quoted 6 lines · Stephen Warren
Quoted 5 lines · Simon Glass

Hi Eric,

Quoted 1 line · Eric Nelson

<snip>

Quoted 26 lines
Quoted 26 lines
Quoted 24 lines
Quoted 16 lines
Quoted 12 lines

I don't think you need __maybe_unused

static int gpio_find_and_xlate(...)

{
    get ops...

    if (ops->xlate)
       return ops->xlate(....)
    else
       return gpio_default_xlate()...
}
Quoted 3 lines

gpio_default_xlate() (or whatever name you use) should be exported so drivers can use it.

Quoted 6 lines

This will leak gpio_default_xlate (locally named gpio_xlate_offs_flags) into machines that don't need it.

I can go the route you suggest above, but it will cost the tegra and sandbox builds ~64 bytes ;)

Sure, but we can live with that.

Quoted 7 lines
Quoted 3 lines

You can avoid that by requiring that ops->xlate always be non-NULL, and simply referencing the default function from drivers that want to use it. Not a big deal either way though.

I'd prefer not to do that. It just adds cruft, the removal of which is the purpose of Eric's series.

We must be close to the goal now, since we're picking apart stuff like this!

Since I've done it both ways locally, I'll try to recap.

Requiring an xlate puts a greater demand on the drivers, and requires an extra patch to get Vybrid working (adding xlate to vybrid_gpio.c) but does make it clearer which drivers need updates to handle DT parsing.

There are a lot of them:

	altera_pio
	at91_gpio
	atmel_pio4
	axp_gpio
	bcm2835_gpio
	dwapb_gpio
	gpio-uniphier
	hi6220_gpio
	intel_ich6_gpio
	lpc32xx_gpio
	msm_gpio
	mvebu_gpio
	pm8916_gpio

None of these have dts files in either U-Boot or the kernel, so this doesn't appear to be a problem.

Calling gpio_xlate_offs_flags as done in the V2 I just sent adds 64 bytes of code to the output for all machines, but transparently adds support for machines like vybrid and mxc.

Regards,

Eric

#48 lore raw

PATCH 1/1 dm: gpio: handle GPIO_ACTIVE_LOW flag in DT

Hi Eric,

Quoted 72 lines · Eric Nelson
Quoted 9 lines · Simon Glass

Hi,

Quoted 6 lines · Stephen Warren
Quoted 5 lines · Simon Glass

Hi Eric,

Quoted 1 line · Eric Nelson

<snip>

Quoted 26 lines
Quoted 26 lines
Quoted 24 lines
Quoted 16 lines
Quoted 12 lines

I don't think you need __maybe_unused

static int gpio_find_and_xlate(...)

{
    get ops...

    if (ops->xlate)
       return ops->xlate(....)
    else
       return gpio_default_xlate()...
}
Quoted 3 lines

gpio_default_xlate() (or whatever name you use) should be exported so drivers can use it.

Quoted 6 lines

This will leak gpio_default_xlate (locally named gpio_xlate_offs_flags) into machines that don't need it.

I can go the route you suggest above, but it will cost the tegra and sandbox builds ~64 bytes ;)

Sure, but we can live with that.

Quoted 7 lines
Quoted 3 lines

You can avoid that by requiring that ops->xlate always be non-NULL, and simply referencing the default function from drivers that want to use it. Not a big deal either way though.

I'd prefer not to do that. It just adds cruft, the removal of which is the purpose of Eric's series.

We must be close to the goal now, since we're picking apart stuff like this!

Since I've done it both ways locally, I'll try to recap.

Requiring an xlate puts a greater demand on the drivers, and requires an extra patch to get Vybrid working (adding xlate to vybrid_gpio.c) but does make it clearer which drivers need updates to handle DT parsing.

There are a lot of them:

        altera_pio
        at91_gpio
        atmel_pio4
        axp_gpio
        bcm2835_gpio
        dwapb_gpio
        gpio-uniphier
        hi6220_gpio
        intel_ich6_gpio
        lpc32xx_gpio
        msm_gpio
        mvebu_gpio
        pm8916_gpio
Quoted 6 lines

None of these have dts files in either U-Boot or the kernel, so this doesn't appear to be a problem.

Calling gpio_xlate_offs_flags as done in the V2 I just sent adds 64 bytes of code to the output for all machines, but transparently adds support for machines like vybrid and mxc.

Yes that seems OK to me. Can you please send a new version of the series?

Regards,
Simon

#49 lore raw

PATCH 1/1 dm: gpio: handle GPIO_ACTIVE_LOW flag in DT

Hi Simon,

Quoted 9 lines · Simon Glass

Hi Eric,

Quoted 6 lines · Eric Nelson
Quoted 4 lines · Simon Glass
Quoted 3 lines · Stephen Warren
Quoted 2 lines · Simon Glass
Quoted 1 line · Eric Nelson

<snip>

Quoted 9 lines
Quoted 6 lines

None of these have dts files in either U-Boot or the kernel, so this doesn't appear to be a problem.

Calling gpio_xlate_offs_flags as done in the V2 I just sent adds 64 bytes of code to the output for all machines, but transparently adds support for machines like vybrid and mxc.

Yes that seems OK to me. Can you please send a new version of the series?

Sure. I'll re-send shortly.

#50 lore raw

cover Handle GPIO_ACTIVE_LOW in gpio-uclass

In reply to Simon Glass

As Peng pointed out in [1], GPIO_ACTIVE_LOW is currently being parsed by driver-specific xlate routines, and an NXP/mxc-specific patch ([2]) to do the same on those processors is pending.

Upon further inspection, I found that many arch-specific xlate routines were present only to parse either or both offset and the GPIO_ACTIVE_LOW flag, both of which can be handled at a global level.

This series adds global support for GPIO_ACTIVE_LOW and removes the architecture-specific gpio xlate routine from five drivers.

It also removes the handling of flags in the tegra gpio driver, though a custom xlate is still needed.

[1] - http://lists.denx.de/pipermail/u-boot/2016-March/thread.html#249946
[2] - https://patchwork.ozlabs.org/patch/597363/

Eric Nelson (7):
dm: gpio: handle GPIO_ACTIVE_LOW flag in DT
gpio: intel_broadwell: remove gpio_xlate routine
gpio: omap: remove gpio_xlate routine
gpio: pic32: remove gpio_xlate routine
gpio: rk: remove gpio_xlate routine
gpio: exynos(s5p): remove gpio_xlate routine
gpio: tegra: remove flags parsing in xlate routine

 drivers/gpio/gpio-uclass.c          | 12 ++++++++----
 drivers/gpio/intel_broadwell_gpio.c | 10 ----------
 drivers/gpio/omap_gpio.c            | 10 ----------
 drivers/gpio/pic32_gpio.c           |  9 ---------
 drivers/gpio/rk_gpio.c              | 10 ----------
 drivers/gpio/s5p_gpio.c             | 10 ----------
 drivers/gpio/tegra_gpio.c           |  1 -
 7 files changed, 8 insertions(+), 54 deletions(-)
Signature · 1 line
2.6.2
#51 lore raw

PATCH RESEND v3 1/6 dm: gpio: add a default gpio xlate routine

Many drivers use a common form of offset + flags for device tree nodes. e.g.:

	<&gpio1 2 GPIO_ACTIVE_LOW>

This patch adds a common implementation of this type of parsing and calls it when a gpio driver doesn't supply its' own xlate routine.

This will allow removal of the driver-specific versions in a handful of drivers and simplify the addition of new drivers.

---
V2 removes parsing of offset from the gpio_find_and_xlate routine, and only parses the offset and GPIO_ACTIVE_LOW flag when a driver-specific xlate is unavailable.

V3 re-works tests of the argument count as suggested by Stephen Warren and will allow parsing of nodes with no flags field:

	<&gpio1 2>
 drivers/gpio/gpio-uclass.c | 30 +++++++++++++++++++++++-------
 include/asm-generic/gpio.h | 19 ++++++++++++++-----
 2 files changed, 37 insertions(+), 12 deletions(-)
drivers/gpio/gpio-uclass.c +23 -7
index b58d4e6..3e83cec 100644
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <dt-bindings/gpio/gpio.h>
 #include <errno.h>
 #include <fdtdec.h>
 #include <malloc.h>
@@ -113,19 +114,33 @@ int gpio_lookup_name(const char *name, struct udevice **devp,
 	return 0;
 }
 
+int gpio_xlate_offs_flags(struct udevice *dev,
+					 struct gpio_desc *desc,
+					 struct fdtdec_phandle_args *args)
+{
+	if (args->args_count < 1)
+		return -EINVAL;
+
+	desc->offset = args->args[0];
+
+        if (args->args_count < 2)
+		return 0;
+
+	if (args->args[1] & GPIO_ACTIVE_LOW)
+		desc->flags = GPIOD_ACTIVE_LOW;
+
+	return 0;
+}
+
 static int gpio_find_and_xlate(struct gpio_desc *desc,
 			       struct fdtdec_phandle_args *args)
 {
 	struct dm_gpio_ops *ops = gpio_get_ops(desc->dev);
 
-	/* Use the first argument as the offset by default */
-	if (args->args_count > 0)
-		desc->offset = args->args[0];
+	if (ops->xlate)
+		return ops->xlate(desc->dev, desc, args);
 	else
-		desc->offset = -1;
-	desc->flags = 0;
-
-	return ops->xlate ? ops->xlate(desc->dev, desc, args) : 0;
+		return gpio_xlate_offs_flags(desc->dev, desc, args);
 }
 
 int dm_gpio_request(struct gpio_desc *desc, const char *label)
@@ -605,6 +620,7 @@ static int _gpio_request_by_name_nodev(const void *blob, int node,
 
 	desc->dev = NULL;
 	desc->offset = 0;
+	desc->flags = 0;
 	ret = fdtdec_parse_phandle_with_args(blob, node, list_name,
 					     "#gpio-cells", 0, index, &args);
 	if (ret) {
include/asm-generic/gpio.h +14 -5
index 68b5f0b..2500c10 100644
@@ -207,6 +207,16 @@ int gpio_requestf(unsigned gpio, const char *fmt, ...)
 struct fdtdec_phandle_args;
 
 /**
+ * gpio_xlate_offs_flags() - implementation for common use of dm_gpio_ops.xlate
+ *
+ * This routine sets the offset field to args[0] and the flags field to
+ * GPIOD_ACTIVE_LOW if the GPIO_ACTIVE_LOW flag is present in args[1].
+ *
+ */
+int gpio_xlate_offs_flags(struct udevice *dev, struct gpio_desc *desc,
+			  struct fdtdec_phandle_args *args);
+
+/**
  * struct struct dm_gpio_ops - Driver model GPIO operations
  *
  * Refer to functions above for description. These function largely copy
@@ -258,12 +268,11 @@ struct dm_gpio_ops {
 	 *
 	 *   @desc->dev to @dev
 	 *   @desc->flags to 0
-	 *   @desc->offset to the value of the first argument in args, if any,
-	 *		otherwise -1 (which is invalid)
+	 *   @desc->offset to 0
 	 *
-	 * This method is optional so if the above defaults suit it can be
-	 * omitted. Typical behaviour is to set up the GPIOD_ACTIVE_LOW flag
-	 * in desc->flags.
+	 * This method is optional and defaults to gpio_xlate_offs_flags,
+	 * which will parse offset and the GPIO_ACTIVE_LOW flag in the first
+	 * two arguments.
 	 *
 	 * Note that @dev is passed in as a parameter to follow driver model
 	 * uclass conventions, even though it is already available as
Signature · 1 line
2.6.2
#52 lore raw

PATCH RESEND v3 1/6 dm: gpio: add a default gpio xlate routine

Quoted 14 lines · Eric Nelson

Many drivers use a common form of offset + flags for device tree nodes. e.g.:

	<&gpio1 2 GPIO_ACTIVE_LOW>

This patch adds a common implementation of this type of parsing and calls it when a gpio driver doesn't supply its' own xlate routine.

This will allow removal of the driver-specific versions in a handful of drivers and simplify the addition of new drivers.

drivers/gpio/gpio-uclass.c +1 -0
 
+int gpio_xlate_offs_flags(struct udevice *dev,

drivers/gpio/gpio-uclass.c int gpio_lookup_name(const char *name, struct udevice **devp, · line 127

Quoted 10 lines
drivers/gpio/gpio-uclass.c +10 -0
+					 struct gpio_desc *desc,
+					 struct fdtdec_phandle_args *args)
+{
+	if (args->args_count < 1)
+		return -EINVAL;
+
+	desc->offset = args->args[0];
+
+        if (args->args_count < 2)
+		return 0;

Nit: There's an indentation inconsistency there.

Aside from that, the series,

#53 lore raw

PATCH RESEND v3 1/6 dm: gpio: add a default gpio xlate routine

Thanks Stephen,

Quoted 14 lines · Stephen Warren
Quoted 12 lines · Eric Nelson

Many drivers use a common form of offset + flags for device tree nodes. e.g.:

    <&gpio1 2 GPIO_ACTIVE_LOW>

This patch adds a common implementation of this type of parsing and calls it when a gpio driver doesn't supply its' own xlate routine.

This will allow removal of the driver-specific versions in a handful of drivers and simplify the addition of new drivers.

drivers/gpio/gpio-uclass.c +0 -0
Quoted 14 lines

drivers/gpio/gpio-uclass.c int gpio_lookup_name(const char *name, struct udevice **devp, · line 127

Quoted 11 lines
drivers/gpio/gpio-uclass.c +11 -0
+int gpio_xlate_offs_flags(struct udevice *dev,
+                     struct gpio_desc *desc,
+                     struct fdtdec_phandle_args *args)
+{
+    if (args->args_count < 1)
+        return -EINVAL;
+
+    desc->offset = args->args[0];
+
+        if (args->args_count < 2)
+        return 0;

Nit: There's an indentation inconsistency there.

I seem to have fat fingered this.

V4 on its way.

#54 lore raw

PATCH v4 1/6 dm: gpio: add a default gpio xlate routine

In reply to Stephen Warren

Many drivers use a common form of offset + flags for device tree nodes. e.g.:

	<&gpio1 2 GPIO_ACTIVE_LOW>

This patch adds a common implementation of this type of parsing and calls it when a gpio driver doesn't supply its' own xlate routine.

This will allow removal of the driver-specific versions in a handful of drivers and simplify the addition of new drivers.

---
V2 removes parsing of offset from the gpio_find_and_xlate routine, and only parses the offset and GPIO_ACTIVE_LOW flag when a driver-specific xlate is unavailable.

V3 re-works tests of the argument count as suggested by Stephen Warren and will allow parsing of nodes with no flags field:

	<&gpio1 2>

V4 fixes an indent with spaces instead of tabs

 drivers/gpio/gpio-uclass.c | 30 +++++++++++++++++++++++-------
 include/asm-generic/gpio.h | 19 ++++++++++++++-----
 2 files changed, 37 insertions(+), 12 deletions(-)
drivers/gpio/gpio-uclass.c +23 -7
index b58d4e6..732b6c2 100644
@@ -6,6 +6,7 @@
 
 #include <common.h>
 #include <dm.h>
+#include <dt-bindings/gpio/gpio.h>
 #include <errno.h>
 #include <fdtdec.h>
 #include <malloc.h>
@@ -113,19 +114,33 @@ int gpio_lookup_name(const char *name, struct udevice **devp,
 	return 0;
 }
 
+int gpio_xlate_offs_flags(struct udevice *dev,
+					 struct gpio_desc *desc,
+					 struct fdtdec_phandle_args *args)
+{
+	if (args->args_count < 1)
+		return -EINVAL;
+
+	desc->offset = args->args[0];
+
+	if (args->args_count < 2)
+		return 0;
+
+	if (args->args[1] & GPIO_ACTIVE_LOW)
+		desc->flags = GPIOD_ACTIVE_LOW;
+
+	return 0;
+}
+
 static int gpio_find_and_xlate(struct gpio_desc *desc,
 			       struct fdtdec_phandle_args *args)
 {
 	struct dm_gpio_ops *ops = gpio_get_ops(desc->dev);
 
-	/* Use the first argument as the offset by default */
-	if (args->args_count > 0)
-		desc->offset = args->args[0];
+	if (ops->xlate)
+		return ops->xlate(desc->dev, desc, args);
 	else
-		desc->offset = -1;
-	desc->flags = 0;
-
-	return ops->xlate ? ops->xlate(desc->dev, desc, args) : 0;
+		return gpio_xlate_offs_flags(desc->dev, desc, args);
 }
 
 int dm_gpio_request(struct gpio_desc *desc, const char *label)
@@ -605,6 +620,7 @@ static int _gpio_request_by_name_nodev(const void *blob, int node,
 
 	desc->dev = NULL;
 	desc->offset = 0;
+	desc->flags = 0;
 	ret = fdtdec_parse_phandle_with_args(blob, node, list_name,
 					     "#gpio-cells", 0, index, &args);
 	if (ret) {
include/asm-generic/gpio.h +14 -5
index 68b5f0b..2500c10 100644
@@ -207,6 +207,16 @@ int gpio_requestf(unsigned gpio, const char *fmt, ...)
 struct fdtdec_phandle_args;
 
 /**
+ * gpio_xlate_offs_flags() - implementation for common use of dm_gpio_ops.xlate
+ *
+ * This routine sets the offset field to args[0] and the flags field to
+ * GPIOD_ACTIVE_LOW if the GPIO_ACTIVE_LOW flag is present in args[1].
+ *
+ */
+int gpio_xlate_offs_flags(struct udevice *dev, struct gpio_desc *desc,
+			  struct fdtdec_phandle_args *args);
+
+/**
  * struct struct dm_gpio_ops - Driver model GPIO operations
  *
  * Refer to functions above for description. These function largely copy
@@ -258,12 +268,11 @@ struct dm_gpio_ops {
 	 *
 	 *   @desc->dev to @dev
 	 *   @desc->flags to 0
-	 *   @desc->offset to the value of the first argument in args, if any,
-	 *		otherwise -1 (which is invalid)
+	 *   @desc->offset to 0
 	 *
-	 * This method is optional so if the above defaults suit it can be
-	 * omitted. Typical behaviour is to set up the GPIOD_ACTIVE_LOW flag
-	 * in desc->flags.
+	 * This method is optional and defaults to gpio_xlate_offs_flags,
+	 * which will parse offset and the GPIO_ACTIVE_LOW flag in the first
+	 * two arguments.
 	 *
 	 * Note that @dev is passed in as a parameter to follow driver model
 	 * uclass conventions, even though it is already available as
Signature · 1 line
2.6.2
#55 lore raw

PATCH v4 1/6 dm: gpio: add a default gpio xlate routine

Quoted 20 lines · Eric Nelson

Many drivers use a common form of offset + flags for device tree nodes. e.g.:

        <&gpio1 2 GPIO_ACTIVE_LOW>

This patch adds a common implementation of this type of parsing and calls it when a gpio driver doesn't supply its' own xlate routine.

This will allow removal of the driver-specific versions in a handful of drivers and simplify the addition of new drivers.

---
V2 removes parsing of offset from the gpio_find_and_xlate routine, and only parses the offset and GPIO_ACTIVE_LOW flag when a driver-specific xlate is unavailable.

V3 re-works tests of the argument count as suggested by Stephen Warren and will allow parsing of nodes with no flags field:

Quoted 7 lines
        <&gpio1 2>

V4 fixes an indent with spaces instead of tabs

 drivers/gpio/gpio-uclass.c | 30 +++++++++++++++++++++++-------
 include/asm-generic/gpio.h | 19 ++++++++++++++-----
 2 files changed, 37 insertions(+), 12 deletions(-)
#56 lore raw

PATCH v4 1/6 dm: gpio: add a default gpio xlate routine

Quoted 23 lines · Simon Glass
Quoted 22 lines · Eric Nelson

Many drivers use a common form of offset + flags for device tree nodes. e.g.:

        <&gpio1 2 GPIO_ACTIVE_LOW>

This patch adds a common implementation of this type of parsing and calls it when a gpio driver doesn't supply its' own xlate routine.

This will allow removal of the driver-specific versions in a handful of drivers and simplify the addition of new drivers.

---
V2 removes parsing of offset from the gpio_find_and_xlate routine, and only parses the offset and GPIO_ACTIVE_LOW flag when a driver-specific xlate is unavailable.

V3 re-works tests of the argument count as suggested by Stephen Warren and will allow parsing of nodes with no flags field:

        <&gpio1 2>
Quoted 7 lines
Quoted 5 lines

V4 fixes an indent with spaces instead of tabs

 drivers/gpio/gpio-uclass.c | 30 +++++++++++++++++++++++-------
 include/asm-generic/gpio.h | 19 ++++++++++++++-----
 2 files changed, 37 insertions(+), 12 deletions(-)

Applied to u-boot-dm, thanks!

#57 lore raw

PATCH RESEND v2 2/6 gpio: intel_broadwell: remove gpio_xlate routine

In reply to Eric Nelson

With the addition of GPIO_ACTIVE_LOW parsing in gpio-uclass, the intel_broadwell driver doesn't need a custom xlate routine.

---
Nothing changed in V2.

 drivers/gpio/intel_broadwell_gpio.c | 10 ----------
 1 file changed, 10 deletions(-)
drivers/gpio/intel_broadwell_gpio.c +0 -10
index 8cf76f9..81ce446 100644
@@ -162,15 +162,6 @@ static int broadwell_gpio_ofdata_to_platdata(struct udevice *dev)
 	return 0;
 }
 
-static int broadwell_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
-				struct fdtdec_phandle_args *args)
-{
-	desc->offset = args->args[0];
-	desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;
-
-	return 0;
-}
-
 static const struct dm_gpio_ops gpio_broadwell_ops = {
 	.request		= broadwell_gpio_request,
 	.direction_input	= broadwell_gpio_direction_input,
@@ -178,7 +169,6 @@ static const struct dm_gpio_ops gpio_broadwell_ops = {
 	.get_value		= broadwell_gpio_get_value,
 	.set_value		= broadwell_gpio_set_value,
 	.get_function		= broadwell_gpio_get_function,
-	.xlate			= broadwell_gpio_xlate,
 };
 
 static const struct udevice_id intel_broadwell_gpio_ids[] = {
Signature · 1 line
2.6.2
#58 lore raw

PATCH RESEND v2 2/6 gpio: intel_broadwell: remove gpio_xlate routine

Quoted 9 lines · Eric Nelson

With the addition of GPIO_ACTIVE_LOW parsing in gpio-uclass, the intel_broadwell driver doesn't need a custom xlate routine.

---
Nothing changed in V2.

 drivers/gpio/intel_broadwell_gpio.c | 10 ----------
 1 file changed, 10 deletions(-)

Applied to u-boot-dm, thanks!

#59 lore raw

PATCH RESEND v2 3/6 gpio: omap: remove gpio_xlate routine

In reply to Eric Nelson

With the addition of GPIO_ACTIVE_LOW parsing in gpio-uclass, the omap gpio driver doesn't need a custom xlate routine.

---
V2 removes the include of <dt-bindings/gpio/gpio.h>

 drivers/gpio/omap_gpio.c | 11 -----------
 1 file changed, 11 deletions(-)
drivers/gpio/omap_gpio.c +0 -11
index 93d18e4..cd960dc 100644
@@ -25,7 +25,6 @@
 #include <asm/io.h>
 #include <asm/errno.h>
 #include <malloc.h>
-#include <dt-bindings/gpio/gpio.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -277,22 +276,12 @@ static int omap_gpio_get_function(struct udevice *dev, unsigned offset)
 		return GPIOF_INPUT;
 }
 
-static int omap_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
-			   struct fdtdec_phandle_args *args)
-{
-	desc->offset = args->args[0];
-	desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;
-
-	return 0;
-}
-
 static const struct dm_gpio_ops gpio_omap_ops = {
 	.direction_input	= omap_gpio_direction_input,
 	.direction_output	= omap_gpio_direction_output,
 	.get_value		= omap_gpio_get_value,
 	.set_value		= omap_gpio_set_value,
 	.get_function		= omap_gpio_get_function,
-	.xlate			= omap_gpio_xlate,
 };
 
 static int omap_gpio_probe(struct udevice *dev)
Signature · 1 line
2.6.2
#60 lore raw

PATCH RESEND v2 3/6 gpio: omap: remove gpio_xlate routine

Quoted 9 lines · Eric Nelson

With the addition of GPIO_ACTIVE_LOW parsing in gpio-uclass, the omap gpio driver doesn't need a custom xlate routine.

---
V2 removes the include of <dt-bindings/gpio/gpio.h>

 drivers/gpio/omap_gpio.c | 11 -----------
 1 file changed, 11 deletions(-)

Applied to u-boot-dm, thanks!

#61 lore raw

PATCH RESEND v2 4/6 gpio: pic32: remove gpio_xlate routine

In reply to Eric Nelson

With the addition of GPIO_ACTIVE_LOW parsing in gpio-uclass, the pic32 gpio driver doesn't need a custom xlate routine.

---
V2 removes the include of <dt-bindings/gpio/gpio.h>

 drivers/gpio/pic32_gpio.c | 10 ----------
 1 file changed, 10 deletions(-)
drivers/gpio/pic32_gpio.c +0 -10
index 499b4fa..7a037f3 100644
@@ -12,7 +12,6 @@
 #include <asm/io.h>
 #include <asm/gpio.h>
 #include <linux/compat.h>
-#include <dt-bindings/gpio/gpio.h>
 #include <mach/pic32.h>
 
 DECLARE_GLOBAL_DATA_PTR;
@@ -99,14 +98,6 @@ static int pic32_gpio_direction_output(struct udevice *dev,
 	return 0;
 }
 
-static int pic32_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
-			    struct fdtdec_phandle_args *args)
-{
-	desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;
-
-	return 0;
-}
-
 static int pic32_gpio_get_function(struct udevice *dev, unsigned offset)
 {
 	int ret = GPIOF_UNUSED;
@@ -131,7 +122,6 @@ static const struct dm_gpio_ops gpio_pic32_ops = {
 	.get_value		= pic32_gpio_get_value,
 	.set_value		= pic32_gpio_set_value,
 	.get_function		= pic32_gpio_get_function,
-	.xlate			= pic32_gpio_xlate,
 };
 
 static int pic32_gpio_probe(struct udevice *dev)
Signature · 1 line
2.6.2
#62 lore raw

PATCH RESEND v2 4/6 gpio: pic32: remove gpio_xlate routine

Quoted 10 lines · Eric Nelson

With the addition of GPIO_ACTIVE_LOW parsing in gpio-uclass, the pic32 gpio driver doesn't need a custom xlate routine.

---
V2 removes the include of <dt-bindings/gpio/gpio.h>

 drivers/gpio/pic32_gpio.c | 10 ----------
 1 file changed, 10 deletions(-)

Applied to u-boot-dm, thanks!

#63 lore raw

PATCH RESEND v2 5/6 gpio: rk: remove gpio_xlate routine

In reply to Eric Nelson

With the addition of GPIO_ACTIVE_LOW parsing in gpio-uclass, the Rockchip gpio driver doesn't need a custom xlate routine.

---
V2 removes the include of <dt-bindings/gpio/gpio.h>

 drivers/gpio/rk_gpio.c | 11 -----------
 1 file changed, 11 deletions(-)
drivers/gpio/rk_gpio.c +0 -11
index 40e87bd..fefe3ca 100644
@@ -16,7 +16,6 @@
 #include <asm/io.h>
 #include <asm/arch/clock.h>
 #include <dm/pinctrl.h>
-#include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/clock/rk3288-cru.h>
 
 enum {
@@ -98,15 +97,6 @@ static int rockchip_gpio_get_function(struct udevice *dev, unsigned offset)
 #endif
 }
 
-static int rockchip_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
-			    struct fdtdec_phandle_args *args)
-{
-	desc->offset = args->args[0];
-	desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;
-
-	return 0;
-}
-
 static int rockchip_gpio_probe(struct udevice *dev)
 {
 	struct gpio_dev_priv *uc_priv = dev_get_uclass_priv(dev);
@@ -135,7 +125,6 @@ static const struct dm_gpio_ops gpio_rockchip_ops = {
 	.get_value		= rockchip_gpio_get_value,
 	.set_value		= rockchip_gpio_set_value,
 	.get_function		= rockchip_gpio_get_function,
-	.xlate			= rockchip_gpio_xlate,
 };
 
 static const struct udevice_id rockchip_gpio_ids[] = {
Signature · 1 line
2.6.2
#64 lore raw

PATCH RESEND v2 5/6 gpio: rk: remove gpio_xlate routine

Quoted 9 lines · Eric Nelson

With the addition of GPIO_ACTIVE_LOW parsing in gpio-uclass, the Rockchip gpio driver doesn't need a custom xlate routine.

---
V2 removes the include of <dt-bindings/gpio/gpio.h>

 drivers/gpio/rk_gpio.c | 11 -----------
 1 file changed, 11 deletions(-)

Applied to u-boot-dm, thanks!

#65 lore raw

PATCH RESEND v2 6/6 gpio: exynos(s5p): remove gpio_xlate routine

In reply to Eric Nelson

With the addition of GPIO_ACTIVE_LOW parsing in gpio-uclass, the Exynos/S5P gpio driver doesn't need a custom xlate routine.

---
V2 removes the include of <dt-bindings/gpio/gpio.h>

 drivers/gpio/s5p_gpio.c | 11 -----------
 1 file changed, 11 deletions(-)
drivers/gpio/s5p_gpio.c +0 -11
index 0f22b23..377fed4 100644
@@ -13,7 +13,6 @@
 #include <asm/io.h>
 #include <asm/gpio.h>
 #include <dm/device-internal.h>
-#include <dt-bindings/gpio/gpio.h>
 
 DECLARE_GLOBAL_DATA_PTR;
 
@@ -276,22 +275,12 @@ static int exynos_gpio_get_function(struct udevice *dev, unsigned offset)
 		return GPIOF_FUNC;
 }
 
-static int exynos_gpio_xlate(struct udevice *dev, struct gpio_desc *desc,
-			     struct fdtdec_phandle_args *args)
-{
-	desc->offset = args->args[0];
-	desc->flags = args->args[1] & GPIO_ACTIVE_LOW ? GPIOD_ACTIVE_LOW : 0;
-
-	return 0;
-}
-
 static const struct dm_gpio_ops gpio_exynos_ops = {
 	.direction_input	= exynos_gpio_direction_input,
 	.direction_output	= exynos_gpio_direction_output,
 	.get_value		= exynos_gpio_get_value,
 	.set_value		= exynos_gpio_set_value,
 	.get_function		= exynos_gpio_get_function,
-	.xlate			= exynos_gpio_xlate,
 };
 
 static int gpio_exynos_probe(struct udevice *dev)
Signature · 1 line
2.6.2
#66 lore raw

PATCH RESEND v2 6/6 gpio: exynos(s5p): remove gpio_xlate routine

Quoted 10 lines · Eric Nelson

With the addition of GPIO_ACTIVE_LOW parsing in gpio-uclass, the Exynos/S5P gpio driver doesn't need a custom xlate routine.

---
V2 removes the include of <dt-bindings/gpio/gpio.h>

 drivers/gpio/s5p_gpio.c | 11 -----------
 1 file changed, 11 deletions(-)

Applied to u-boot-dm, thanks!