gpio: add GPIO hogging mechanism
Subsystems (2)
v2 cover gpio: add GPIO hogging mechanism
This patch set re-introduces the gpio hogging concept first presented by Boris Brezillion.
This patch set provides a way to initally configure specific GPIO when the gpio controller is probed.
The actual DT scanning to collect the GPIO specific data is performed as part of the gpiochip_add().
The purpose of this is to allows specific GPIOs to be configured without any driver specific code.
This particularly useful because board design are getting increasingly complex and given SoC pins can now have upward of 10 mux values a lot of connections are now dependent on external IO muxes to switch various modes and combination.
Specific drivers should not necessarily need to be aware of what accounts to a specific board implementation. This board level "description" should be best kept as part of the dts file.
Changes since v1:
* Split the devicetree bindings documentation in its own patch.
* Refactor the gpio-hog mechanism as private functions meant to be to invoked from of_gpiochip_add().
Benoit Parrot (2):
gpio: add GPIO hogging mechanism
gpio: Document GPIO hogging mechanism
Documentation/devicetree/bindings/gpio/gpio.txt | 25 ++++ drivers/gpio/gpiolib-of.c | 188 ++++++++++++++++++++++++ 2 files changed, 213 insertions(+)
Signature · 1 line
1.8.5.1
PATCH v2 1/2 gpio: add GPIO hogging mechanism
Based on Boris Brezillion's work this is a reworked patch of his initial GPIO hogging mechanism.
This patch provides a way to initally configure specific GPIO when the gpio controller is probed.
The actual DT scanning to collect the GPIO specific data is performed as part of the gpiochip_add().
The purpose of this is to allows specific GPIOs to be configured without any driver specific code.
This particularly useful because board design are getting increasingly complex and given SoC pins can now have upward of 10 mux values a lot of connections are now dependent on external IO muxes to switch various modes and combination.
Specific drivers should not necessarily need to be aware of what accounts to a specific board implementation. This board level "description" should be best kept as part of the dts file.
---
Changes since v1:
* Refactor the gpio-hog mechanism as private functions meant to be to invoked from of_gpiochip_add().
drivers/gpio/gpiolib-of.c | 188 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 188 insertions(+)
drivers/gpio/gpiolib-of.c +188 -0
@@ -22,6 +22,7 @@#include <linux/of_gpio.h> #include <linux/pinctrl/pinctrl.h> #include <linux/slab.h> +#include <linux/gpio/machine.h> #include "gpiolib.h"
@@ -111,6 +112,184 @@ int of_get_named_gpio_flags(struct device_node *np, const char *list_name,EXPORT_SYMBOL (of_get_named_gpio_flags);/** +* of_get_gpio_hog() - Get a GPIO hog descriptor, names and flags for GPIO API +* @np: device node to get GPIO from +* @name: GPIO line name +* @flags: a flags pointer to fill in +* +* Returns GPIO descriptor to use with Linux GPIO API, or one of the errno +* value on the error condition. +*/ + +static struct gpio_desc *of_get_gpio_hog (struct device_node *np, +const char **name, +enum gpio_lookup_flags *lflags, +enum gpiod_flags *dflags) +{ +struct device_node *chip_np; +enum of_gpio_flags xlate_flags; +struct gpio_desc *desc; +struct gg_data gg_data = { + .flags = &xlate_flags, + .out_gpio =NULL , + }; +u32 tmp; +int i, in, outlo, outhi; +int ret; + +if (!np) +return ERR_PTR (-EINVAL ); + + chip_np = np->parent; +if (!chip_np) { + desc =ERR_PTR (-EINVAL ); + goto out; + } + +if (!lflags || !dflags) { + desc =ERR_PTR (-EINVAL ); + goto out; + } + + *lflags =0 ; + *dflags =0 ; + in =0 ; + outlo =0 ; + outhi =0 ; + + ret =of_property_read_u32 (chip_np,"#gpio-cells" , &tmp); +if (ret) { + desc =ERR_PTR (ret); + goto out; + } + +if (tmp >MAX_PHANDLE_ARGS ) { + desc =ERR_PTR (-EINVAL ); + goto out; + } + + gg_data.gpiospec.args_count = tmp; + gg_data.gpiospec.np = chip_np; +for (i =0 ; i < tmp; i++) { + ret =of_property_read_u32 (np,"gpios" , + &gg_data.gpiospec.args[i]); +if (ret) { + desc =ERR_PTR (ret); + goto out; + } + } + +gpiochip_find (&gg_data, of_gpiochip_find_and_xlate); +if (!gg_data.out_gpio) { +if (np->parent == np) + desc =ERR_PTR (-ENXIO ); +else + desc =ERR_PTR (-EPROBE_DEFER ); + goto out; + } + +if (xlate_flags &OF_GPIO_ACTIVE_LOW ) + *lflags |=GPIOF_ACTIVE_LOW ; + +if (of_property_read_bool (np,"input" )) { + *dflags |=GPIOD_IN ; + in =1 ; + } +if (of_property_read_bool (np,"output-low" )) { + *dflags |=GPIOD_OUT_LOW ; + outlo =1 ; + } +if (of_property_read_bool (np,"output-high" )) { + *dflags |=GPIOD_OUT_HIGH ; + outhi =1 ; + } +if ((in + outlo + outhi) >1 ) { +pr_warn ("%s: GPIO %s: more than one direction/value selected, assuming: %s.\n" , + __func__, np->name, + (outhi)?"output-high" :(outlo)?"output-low" :"input" ); + } + +if (of_property_read_bool (np,"open-drain-line" )) + *lflags |=GPIO_OPEN_DRAIN ; +if (of_property_read_bool (np,"open-source-line" )) + *lflags |=GPIO_OPEN_SOURCE ; +if (name &&of_property_read_string (np,"line-name" , name)) + *name = np->name; + + desc = gg_data.out_gpio; + +out: +return desc; +} + + +/** +* do_gpio_hog - Given node is a GPIO hog configuration, handle it +* @np: device node to get GPIO from +* +* This is only used by of_gpiochip_add to request/set GPIO initial +* configuration. +*/ +static int do_gpio_hog (struct device_node *np) +{ +struct gpio_desc *desc =NULL ; +int err; +const char *name; +enum gpio_lookup_flags lflags; +enum gpiod_flags dflags; + + desc =of_get_gpio_hog (np, &name, &lflags, &dflags); +if (!desc) +return -ENOTSUPP ; +else if (IS_ERR (desc)) +return PTR_ERR (desc); + + err =gpiod_request (desc, name); +if (err <0 ) +return err; + +if (lflags &GPIO_ACTIVE_LOW ) +set_bit (FLAG_ACTIVE_LOW , &desc->flags); +if (lflags &GPIO_OPEN_DRAIN ) +set_bit (FLAG_OPEN_DRAIN , &desc->flags); +if (lflags &GPIO_OPEN_SOURCE ) +set_bit (FLAG_OPEN_SOURCE , &desc->flags); + +/* No particular flag request, not really hogging then... */ +if (!(dflags &GPIOD_FLAGS_BIT_DIR_SET )) { +pr_warn ("%s: GPIO %s: no hogging direction specified, bailing out\n" , + __func__, name); + err = -EINVAL ; + goto free_gpio; + } + +/* Process flags */ +if (dflags &GPIOD_FLAGS_BIT_DIR_OUT ) + err =gpiod_direction_output (desc, + dflags &GPIOD_FLAGS_BIT_DIR_VAL ); +else + err =gpiod_direction_input (desc); + +if (err <0 ) { +pr_warn ("%s: GPIO %s setting direction/value failed\n" , + __func__, name); + goto free_gpio; + } + +pr_debug ("%s: gpio-hog: GPIO:%d (%s) as %s%s\n" , __func__, +desc_to_gpio (desc), name, + (dflags&GPIOD_FLAGS_BIT_DIR_OUT ) ?"output" :"input" , + (dflags&GPIOD_FLAGS_BIT_DIR_OUT ) ? + (dflags&GPIOD_FLAGS_BIT_DIR_VAL ) ?"/high" :"/low" :"" ); + +return 0 ; + +free_gpio: +gpiod_put (desc); +return err; +} + +/** * of_gpio_simple_xlate - translate gpio_spec to the GPIO number and flags * @gc: pointer to the gpio_chip structure * @np: device node of the GPIO chip
@@ -289,6 +468,8 @@ static void of_gpiochip_add_pin_range(struct gpio_chip *chip) {}void of_gpiochip_add (struct gpio_chip *chip) { +struct device_node *np; +if ((!chip->of_node) && (chip->dev)) chip->of_node = chip->dev->of_node;
@@ -302,6 +483,13 @@ void of_gpiochip_add(struct gpio_chip *chip)of_gpiochip_add_pin_range (chip);of_node_get (chip->of_node); + +for_each_child_of_node (chip->dev->of_node, np) { +if (!of_property_read_bool (np,"gpio-hog" )) +continue ; +/* Hog this GPIO */ +do_gpio_hog (np); + } }void of_gpiochip_remove (struct gpio_chip *chip)
Signature · 1 line
1.8.5.1
Quoted 61 lines · Benoit Parrot
Based on Boris Brezillion's work this is a reworked patch of his initial GPIO hogging mechanism.
This patch provides a way to initally configure specific GPIO when the gpio controller is probed.The actual DT scanning to collect the GPIO specific data is performed as part of the
gpiochip_add().The purpose of this is to allows specific GPIOs to be configured without any driver specific code.
This particularly useful because board design are getting increasingly complex and given SoC pins can now have upward of 10 mux values a lot of connections are now dependent on external IO muxes to switch various modes and combination.Specific drivers should not necessarily need to be aware of what accounts to a specific board implementation. This board level "description" should be best kept as part of the dts file.
Signed-off-by Benoit Parrot <[email protected]>---
Changes since v1:
* Refactor the gpio-hog mechanism as private functions meant to be to invoked fromof_gpiochip_add().drivers/gpio/gpiolib-of.c | 188 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 188 insertions(+)drivers/gpio/gpiolib-of.c +18
-0@@ -22,6 +22,7 @@#include <linux/of_gpio.h> #include <linux/pinctrl/pinctrl.h> #include <linux/slab.h> +#include <linux/gpio/machine.h> #include "gpiolib.h" @@ -111,6 +112,184 @@ int of_get_named_gpio_flags(struct device_node *np, const char *list_name,EXPORT_SYMBOL (of_get_named_gpio_flags);/** +* of_get_gpio_hog() - Get a GPIO hog descriptor, names and flags for GPIO API +* @np: device node to get GPIO from +* @name: GPIO line name +* @flags: a flags pointer to fill in +* +* Returns GPIO descriptor to use with Linux GPIO API, or one of the errno +* value on the error condition. +*/ + +static struct gpio_desc *of_get_gpio_hog (struct device_node *np, +const char **name, +enum gpio_lookup_flags *lflags, +enum gpiod_flags *dflags) +{ +struct device_node *chip_np; +enum of_gpio_flags xlate_flags; +struct gpio_desc *desc;
drivers/gpio/gpiolib-of.c int of_get_named_gpio_flags(struct device_node *np, const char *list_name, · line 141
Quoted 10 lines
drivers/gpio/gpiolib-of.c +10
-0+struct gg_data gg_data = { + .flags = &xlate_flags, + .out_gpio =NULL , + }; +u32 tmp; +int i, in, outlo, outhi; +int ret; + +if (!np) +return ERR_PTR (-EINVAL );
This function is being called from a perfectly mastered context in this file, so maybe we can avoid this check.
drivers/gpio/gpiolib-of.c int of_get_named_gpio_flags(struct device_node *np, const char *list_name, · line 152
Quoted 11 lines
drivers/gpio/gpiolib-of.c +11
-0+ + chip_np = np->parent; +if (!chip_np) { + desc =ERR_PTR (-EINVAL ); + goto out; + } + +if (!lflags || !dflags) { + desc =ERR_PTR (-EINVAL ); + goto out; + }
Same for this one.
drivers/gpio/gpiolib-of.c int of_get_named_gpio_flags(struct device_node *np, const char *list_name, · line 163
Quoted 11 lines
drivers/gpio/gpiolib-of.c +11
-0+ + *lflags =0 ; + *dflags =0 ; + in =0 ; + outlo =0 ; + outhi =0 ; + + ret =of_property_read_u32 (chip_np,"#gpio-cells" , &tmp); +if (ret) { + desc =ERR_PTR (ret); + goto out;
Please use "return ERR_PTR(ret);" directly, since you do absolutely no cleanup in out:. Same remark everywhere it applies.
Quoted 9 lines
drivers/gpio/gpiolib-of.c +9
-0+ } + +if (tmp >MAX_PHANDLE_ARGS ) { + desc =ERR_PTR (-EINVAL ); + goto out; + } + + gg_data.gpiospec.args_count = tmp; + gg_data.gpiospec.np = chip_np;
drivers/gpio/gpiolib-of.c int of_get_named_gpio_flags(struct device_node *np, const char *list_name, · line 182
Quoted 10 lines
drivers/gpio/gpiolib-of.c +10
-0+for (i =0 ; i < tmp; i++) { + ret =of_property_read_u32 (np,"gpios" , + &gg_data.gpiospec.args[i]); +if (ret) { + desc =ERR_PTR (ret); + goto out; + } + } + +gpiochip_find (&gg_data, of_gpiochip_find_and_xlate);
This seems to work but only supports one GPIO per hog node. It would be nice to be able to specify several GPIOs to which the same settings need to be applied.
Quoted 13 lines
drivers/gpio/gpiolib-of.c +13
-0+if (!gg_data.out_gpio) { +if (np->parent == np) + desc =ERR_PTR (-ENXIO ); +else + desc =ERR_PTR (-EPROBE_DEFER ); + goto out; + } + +if (xlate_flags &OF_GPIO_ACTIVE_LOW ) + *lflags |=GPIOF_ACTIVE_LOW ; + +if (of_property_read_bool (np,"input" )) { + *dflags |=GPIOD_IN ;
drivers/gpio/gpiolib-of.c int of_get_named_gpio_flags(struct device_node *np, const char *list_name, · line 205
Quoted 10 lines
drivers/gpio/gpiolib-of.c +10
-0+ in =1 ; + } +if (of_property_read_bool (np,"output-low" )) { + *dflags |=GPIOD_OUT_LOW ; + outlo =1 ; + } +if (of_property_read_bool (np,"output-high" )) { + *dflags |=GPIOD_OUT_HIGH ; + outhi =1 ; + }
I thought we agreed that this should be a "direction = input|output-low|output-high" property?
drivers/gpio/gpiolib-of.c int of_get_named_gpio_flags(struct device_node *np, const char *list_name, · line 215
Quoted 10 lines
drivers/gpio/gpiolib-of.c +10
-0+if ((in + outlo + outhi) >1 ) { +pr_warn ("%s: GPIO %s: more than one direction/value selected, assuming: %s.\n" , + __func__, np->name, + (outhi)?"output-high" :(outlo)?"output-low" :"input" ); + } + +if (of_property_read_bool (np,"open-drain-line" )) + *lflags |=GPIO_OPEN_DRAIN ; +if (of_property_read_bool (np,"open-source-line" )) + *lflags |=GPIO_OPEN_SOURCE ;
These properties are not documented in your DT bindings.
Quoted 22 lines
drivers/gpio/gpiolib-of.c +22
-0+if (name &&of_property_read_string (np,"line-name" , name)) + *name = np->name; + + desc = gg_data.out_gpio; + +out: +return desc; +} + + +/** +* do_gpio_hog - Given node is a GPIO hog configuration, handle it +* @np: device node to get GPIO from +* +* This is only used by of_gpiochip_add to request/set GPIO initial +* configuration. +*/ +static int do_gpio_hog (struct device_node *np) +{ +struct gpio_desc *desc =NULL ; +int err; +const char *name;
drivers/gpio/gpiolib-of.c int of_get_named_gpio_flags(struct device_node *np, const char *list_name, · line 247
Quoted 10 lines
drivers/gpio/gpiolib-of.c +10
-0+enum gpio_lookup_flags lflags; +enum gpiod_flags dflags; + + desc =of_get_gpio_hog (np, &name, &lflags, &dflags); +if (!desc) +return -ENOTSUPP ; +else if (IS_ERR (desc)) +return PTR_ERR (desc); + + err =gpiod_request (desc, name);
Using this function means that a GPIO chip module cannot be unloaded if it uses GPIO hogs. Is it the intended behavior? If not, please use gpiochip_request_own_desc() instead, and make sure to call gpiochip_free_own_desc() for each hog when the driver is unloaded.
Quoted 20 lines
drivers/gpio/gpiolib-of.c +20
-0+if (err <0 ) +return err; + +if (lflags &GPIO_ACTIVE_LOW ) +set_bit (FLAG_ACTIVE_LOW , &desc->flags); +if (lflags &GPIO_OPEN_DRAIN ) +set_bit (FLAG_OPEN_DRAIN , &desc->flags); +if (lflags &GPIO_OPEN_SOURCE ) +set_bit (FLAG_OPEN_SOURCE , &desc->flags); + +/* No particular flag request, not really hogging then... */ +if (!(dflags &GPIOD_FLAGS_BIT_DIR_SET )) { +pr_warn ("%s: GPIO %s: no hogging direction specified, bailing out\n" , + __func__, name); + err = -EINVAL ; + goto free_gpio; + } + +/* Process flags */ +if (dflags &GPIOD_FLAGS_BIT_DIR_OUT )
drivers/gpio/gpiolib-of.c int of_get_named_gpio_flags(struct device_node *np, const char *list_name, · line 277
Quoted 10 lines
drivers/gpio/gpiolib-of.c +10
-0+ err =gpiod_direction_output (desc, + dflags &GPIOD_FLAGS_BIT_DIR_VAL ); + else + err =gpiod_direction_input (desc); + +if (err <0 ) { +pr_warn ("%s: GPIO %s setting direction/value failed\n" , + __func__, name); + goto free_gpio; + }
I would suggest to factorize this code that is similar to the one found in __gpiod_get_index(). Do all the DT parsing in a function that just returns a descriptor and the
drivers/gpio/gpiolib-of.c int of_get_named_gpio_flags(struct device_node *np, const char *list_name, · line 290
Quoted 13 lines
drivers/gpio/gpiolib-of.c +13
-0+ +pr_debug ("%s: gpio-hog: GPIO:%d (%s) as %s%s\n" , __func__, +desc_to_gpio (desc), name, + (dflags&GPIOD_FLAGS_BIT_DIR_OUT ) ?"output" :"input" , + (dflags&GPIOD_FLAGS_BIT_DIR_OUT ) ? + (dflags&GPIOD_FLAGS_BIT_DIR_VAL ) ?"/high" :"/low" :"" ); + +return 0 ; + +free_gpio: +gpiod_put (desc); +return err; +}
I think most of this function should be moved into gpiolib.c. Add a function there that takes the descriptor, lflags and dflags and that sets the GPIO up, possibly adding it to a list of hogs so we can unset the hogs when unloading the module. That way we have a hogging mechanism that is not dependent on device tree and can be used by other GPIO binders, such as ACPI.
There is still some work needed but it looks much better than the first version. Please make sure to also keep Maxime, Pantelis and Jiri in the loop since they expressed interest in your first version.
Hi,
Quoted 19 lines · Alexandre Courbot
Quoted 19 lines
drivers/gpio/gpiolib-of.c +19
-0+/** +* do_gpio_hog - Given node is a GPIO hog configuration, handle it +* @np: device node to get GPIO from +* +* This is only used by of_gpiochip_add to request/set GPIO initial +* configuration. +*/ +static int do_gpio_hog (struct device_node *np) +{ +struct gpio_desc *desc =NULL ; +int err; +const char *name; +enum gpio_lookup_flags lflags; +enum gpiod_flags dflags; + + desc =of_get_gpio_hog (np, &name, &lflags, &dflags); +if (!desc) +return -ENOTSUPP ; +else if (IS_ERR (desc))
Quoted 8 lines
drivers/gpio/gpiolib-of.c int of_get_named_gpio_flags(struct device_node *np, const char *list_name, · line 247
Quoted 3 lines
drivers/gpio/gpiolib-of.c +3
-0+return PTR_ERR (desc); + + err =gpiod_request (desc, name);Using this function means that a GPIO chip module cannot be unloaded if it uses GPIO hogs. Is it the intended behavior? If not, please use
gpiochip_request_own_desc()instead, and make sure to callgpiochip_free_own_desc()for each hog when the driver is unloaded.
The only thing I'd like to have would be that the request here would be non-exclusive, so that a later driver would still be allowed later on to request that GPIO later on and manage it itself (ideally using the usual gpiod_request function).
Maxime
Signature · 3 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
Maxime Ripard <[email protected]> wrote on Mon [2014-Dec-01 17:36:39 +0100]:
Quoted 31 lines
Hi,
Quoted 19 lines · Alexandre Courbot
Quoted 19 lines
drivers/gpio/gpiolib-of.c +19
-0+/** +* do_gpio_hog - Given node is a GPIO hog configuration, handle it +* @np: device node to get GPIO from +* +* This is only used by of_gpiochip_add to request/set GPIO initial +* configuration. +*/ +static int do_gpio_hog (struct device_node *np) +{ +struct gpio_desc *desc =NULL ; +int err; +const char *name; +enum gpio_lookup_flags lflags; +enum gpiod_flags dflags; + + desc =of_get_gpio_hog (np, &name, &lflags, &dflags); +if (!desc) +return -ENOTSUPP ; +else if (IS_ERR (desc))Quoted 8 lines
drivers/gpio/gpiolib-of.c int of_get_named_gpio_flags(struct device_node *np, const char *list_name, · line 247
Quoted 3 lines
drivers/gpio/gpiolib-of.c +3
-0+return PTR_ERR (desc); + + err =gpiod_request (desc, name);Using this function means that a GPIO chip module cannot be unloaded if it uses GPIO hogs. Is it the intended behavior? If not, please use
gpiochip_request_own_desc()instead, and make sure to callgpiochip_free_own_desc()for each hog when the driver is unloaded.
Quoted 4 lines
The only thing I'd like to have would be that the request here would be non-exclusive, so that a later driver would still be allowed later on to request that GPIO later on and manage it itself (ideally using the usual
gpiod_requestfunction).
I'll let Linus chime in on this.
But the premise for the hogging mechanism is to have a mechanism to set GPIOs which do not need to be requested by any other entity.
If a driver needs access to a specific GPIO then it should use the existing gpiolib API to request it and set it up.
Quoted 7 lines
Maxime
Signature · 3 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
Regards,
Benoit
Quoted 31 lines · Maxime Ripard
Hi,
Quoted 19 lines · Alexandre Courbot
Quoted 19 lines
drivers/gpio/gpiolib-of.c +19
-0+/** +* do_gpio_hog - Given node is a GPIO hog configuration, handle it +* @np: device node to get GPIO from +* +* This is only used by of_gpiochip_add to request/set GPIO initial +* configuration. +*/ +static int do_gpio_hog (struct device_node *np) +{ +struct gpio_desc *desc =NULL ; +int err; +const char *name; +enum gpio_lookup_flags lflags; +enum gpiod_flags dflags; + + desc =of_get_gpio_hog (np, &name, &lflags, &dflags); +if (!desc) +return -ENOTSUPP ; +else if (IS_ERR (desc))Quoted 8 lines
drivers/gpio/gpiolib-of.c int of_get_named_gpio_flags(struct device_node *np, const char *list_name, · line 247
Quoted 3 lines
drivers/gpio/gpiolib-of.c +3
-0+return PTR_ERR (desc); + + err =gpiod_request (desc, name);Using this function means that a GPIO chip module cannot be unloaded if it uses GPIO hogs. Is it the intended behavior? If not, please use
gpiochip_request_own_desc()instead, and make sure to callgpiochip_free_own_desc()for each hog when the driver is unloaded.
Quoted 4 lines
The only thing I'd like to have would be that the request here would be non-exclusive, so that a later driver would still be allowed later on to request that GPIO later on and manage it itself (ideally using the usual
gpiod_requestfunction).
Actually we have a plan (and I have some code too) to allow multiple consumers per GPIO. Although like Benoit I wonder why you would want to hog a GPIO and then request it properly later. Also, that probably means we should abandon the hog since it actively drives the line and would interfere with the late requested. How to do that correctly is not really clear to me.
Quoted 8 lines · Alexandre Courbot
Quoted 4 lines · Maxime Ripard
The only thing I'd like to have would be that the request here would be non-exclusive, so that a later driver would still be allowed later on to request that GPIO later on and manage it itself (ideally using the usual
gpiod_requestfunction).
Quoted 6 lines
Actually we have a plan (and I have some code too) to allow multiple consumers per GPIO. Although like Benoit I wonder why you would want to hog a GPIO and then request it properly later. Also, that probably means we should abandon the hog since it actively drives the line and would interfere with the late requested. How to do that correctly is not really clear to me.
I don't get the usecase. A hogged GPIO is per definition hogged. This sounds more like "initial settings" or something, which is another usecase altogether.
Yours,
Linus Walleij
Quoted 16 lines · Linus Walleij
Quoted 8 lines · Alexandre Courbot
Quoted 4 lines · Maxime Ripard
The only thing I'd like to have would be that the request here would be non-exclusive, so that a later driver would still be allowed later on to request that GPIO later on and manage it itself (ideally using the usual
gpiod_requestfunction).Quoted 6 lines
Actually we have a plan (and I have some code too) to allow multiple consumers per GPIO. Although like Benoit I wonder why you would want to hog a GPIO and then request it properly later. Also, that probably means we should abandon the hog since it actively drives the line and would interfere with the late requested. How to do that correctly is not really clear to me.
Quoted 3 lines
I don't get the usecase. A hogged GPIO is per definition hogged. This sounds more like "initial settings" or something, which is another usecase altogether.
We do have one board where we have a pin (let's say GPIO14 of the bank
A) that enables a regulator that will provide VCC the bank B.
Now, both banks are handled by the same driver, but in order to have a working output on the bank B, we do need to set GPIO14 as soon as we're probed.
Just relying on the usual deferred probing introduces a circular dependency between the gpio-regulator that needs to grab its GPIO from a driver not there yet, and the gpio driver that needs to enable its gpio-regulator.
GPIO hogging needs to be the ideal solution for that, since we can just enforce the GPIO14 value as the driver is probed, which provides the guarantee that any driver using the bank B will actually drive the GPIO it might use.
However, an exclusive request will prevent any representation of this as a regulator, which sounds a bit weird, since it really is just that.
Maxime
Signature · 3 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
Quoted 24 lines · Maxime Ripard
Quoted 16 lines · Linus Walleij
Quoted 8 lines · Alexandre Courbot
Quoted 4 lines · Maxime Ripard
The only thing I'd like to have would be that the request here would be non-exclusive, so that a later driver would still be allowed later on to request that GPIO later on and manage it itself (ideally using the usual
gpiod_requestfunction).Quoted 6 lines
Actually we have a plan (and I have some code too) to allow multiple consumers per GPIO. Although like Benoit I wonder why you would want to hog a GPIO and then request it properly later. Also, that probably means we should abandon the hog since it actively drives the line and would interfere with the late requested. How to do that correctly is not really clear to me.
Quoted 3 lines
I don't get the usecase. A hogged GPIO is per definition hogged. This sounds more like "initial settings" or something, which is another usecase altogether.
We do have one board where we have a pin (let's say GPIO14 of the bank
A) that enables a regulator that will provide VCC the bank B.
Quoted 8 lines
Now, both banks are handled by the same driver, but in order to have a working output on the bank B, we do need to set GPIO14 as soon as we're probed.
Just relying on the usual deferred probing introduces a circular dependency between the gpio-regulator that needs to grab its GPIO from a driver not there yet, and the gpio driver that needs to enable its gpio-regulator.
I don't get it. According to what you said, the following order should go through IIUC:
1) bank A is probed, gpio 14 is available
2) gpio-regulator is probed, acquires GPIO 14, regulator for Bank B is available
3) bank B is probed, grabs its regulator and turn it on, probes.
What am I missing?
Quoted 5 lines
GPIO hogging needs to be the ideal solution for that, since we can just enforce the GPIO14 value as the driver is probed, which provides the guarantee that any driver using the bank B will actually drive the GPIO it might use.
At this point I start wondering if such initial setup should not be the job of the bootloader? GPIO hogging ought to be simple and definitive, adding the possibility to have it just as an initial value would considerably complexify it. E.g. when is the gpio chip driver supposed to release the hogged descriptor in such a case?
Note that if the multiple GPIO consumer feature we are planning goes through, you should be able to use both hogging *and* a regulator on the same GPIO and achieve what you want. The expectation of multiple consumers is that the board designers know what they are doing, and this case would certainly fit (chip hogs the line and doesn't touch the value after that, letting the regulator control it without any conflict afterwards), although it would of course be better to solve the issue through regular probing...
Hi Alexandre,
I tried to stay away while things are being fleshed out but…
Quoted 52 lines · Alexandre Courbot
Quoted 24 lines · Maxime Ripard
Quoted 16 lines · Linus Walleij
Quoted 8 lines · Alexandre Courbot
Quoted 4 lines · Maxime Ripard
The only thing I'd like to have would be that the request here would be non-exclusive, so that a later driver would still be allowed later on to request that GPIO later on and manage it itself (ideally using the usual
gpiod_requestfunction).Quoted 6 lines
Actually we have a plan (and I have some code too) to allow multiple consumers per GPIO. Although like Benoit I wonder why you would want to hog a GPIO and then request it properly later. Also, that probably means we should abandon the hog since it actively drives the line and would interfere with the late requested. How to do that correctly is not really clear to me.
Quoted 3 lines
I don't get the usecase. A hogged GPIO is per definition hogged. This sounds more like "initial settings" or something, which is another usecase altogether.
We do have one board where we have a pin (let's say GPIO14 of the bank
A) that enables a regulator that will provide VCC the bank B.Quoted 8 lines
Now, both banks are handled by the same driver, but in order to have a working output on the bank B, we do need to set GPIO14 as soon as we're probed.
Just relying on the usual deferred probing introduces a circular dependency between the gpio-regulator that needs to grab its GPIO from a driver not there yet, and the gpio driver that needs to enable its gpio-regulator.
I don't get it. According to what you said, the following order should go through IIUC:
1) bank A is probed, gpio 14 is available
2) gpio-regulator is probed, acquires GPIO 14, regulator for Bank B is available
3) bank B is probed, grabs its regulator and turn it on, probes.What am I missing?
Quoted 5 lines
GPIO hogging needs to be the ideal solution for that, since we can just enforce the GPIO14 value as the driver is probed, which provides the guarantee that any driver using the bank B will actually drive the GPIO it might use.
Quoted 6 lines
At this point I start wondering if such initial setup should not be the job of the bootloader? GPIO hogging ought to be simple and definitive, adding the possibility to have it just as an initial value would considerably complexify it. E.g. when is the gpio chip driver supposed to release the hogged descriptor in such a case?
Do not count on the bootloader setting up anything. The trend is for the bootloader to setup the minimal environment to load your kernel and jump to it.
http://www.denx.de/wiki/pub/U-Boot/MiniSummitELCE2013/2013-ELCE-U-Boot-Falcon-Boot.pdf
Quoted 8 lines
Note that if the multiple GPIO consumer feature we are planning goes through, you should be able to use both hogging *and* a regulator on the same GPIO and achieve what you want. The expectation of multiple consumers is that the board designers know what they are doing, and this case would certainly fit (chip hogs the line and doesn't touch the value after that, letting the regulator control it without any conflict afterwards), although it would of course be better to solve the issue through regular probing...
That’s why I was advocating a simple probing driver for all this. Figure out a way for this driver to be probed first would be an easier solution that what’s going on here.
Regards
— Pantelis
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 63 lines · Pantelis Antoniou
Hi Alexandre,
I tried to stay away while things are being fleshed out but…
Quoted 52 lines · Alexandre Courbot
Quoted 24 lines · Maxime Ripard
Quoted 16 lines · Linus Walleij
Quoted 8 lines · Alexandre Courbot
Quoted 4 lines · Maxime Ripard
The only thing I'd like to have would be that the request here would be non-exclusive, so that a later driver would still be allowed later on to request that GPIO later on and manage it itself (ideally using the usual
gpiod_requestfunction).Quoted 6 lines
Actually we have a plan (and I have some code too) to allow multiple consumers per GPIO. Although like Benoit I wonder why you would want to hog a GPIO and then request it properly later. Also, that probably means we should abandon the hog since it actively drives the line and would interfere with the late requested. How to do that correctly is not really clear to me.
Quoted 3 lines
I don't get the usecase. A hogged GPIO is per definition hogged. This sounds more like "initial settings" or something, which is another usecase altogether.
We do have one board where we have a pin (let's say GPIO14 of the bank
A) that enables a regulator that will provide VCC the bank B.Quoted 8 lines
Now, both banks are handled by the same driver, but in order to have a working output on the bank B, we do need to set GPIO14 as soon as we're probed.
Just relying on the usual deferred probing introduces a circular dependency between the gpio-regulator that needs to grab its GPIO from a driver not there yet, and the gpio driver that needs to enable its gpio-regulator.
I don't get it. According to what you said, the following order should go through IIUC:
1) bank A is probed, gpio 14 is available
2) gpio-regulator is probed, acquires GPIO 14, regulator for Bank B is available
3) bank B is probed, grabs its regulator and turn it on, probes.What am I missing?
Quoted 5 lines
GPIO hogging needs to be the ideal solution for that, since we can just enforce the GPIO14 value as the driver is probed, which provides the guarantee that any driver using the bank B will actually drive the GPIO it might use.
Quoted 6 lines
At this point I start wondering if such initial setup should not be the job of the bootloader? GPIO hogging ought to be simple and definitive, adding the possibility to have it just as an initial value would considerably complexify it. E.g. when is the gpio chip driver supposed to release the hogged descriptor in such a case?
Quoted 5 lines
Do not count on the bootloader setting up anything. The trend is for the bootloader to setup the minimal environment to load your kernel and jump to it.
http://www.denx.de/wiki/pub/U-Boot/MiniSummitELCE2013/2013-ELCE-U-Boot-Falcon-Boot.pdf
Just wondering. :)
But yeah, there are some use-cases (such as this one or Linux-as-a-bootloader) for which this would not play nicely.
Quoted 12 lines
Quoted 10 lines
Note that if the multiple GPIO consumer feature we are planning goes through, you should be able to use both hogging *and* a regulator on the same GPIO and achieve what you want. The expectation of multiple consumers is that the board designers know what they are doing, and this case would certainly fit (chip hogs the line and doesn't touch the value after that, letting the regulator control it without any conflict afterwards), although it would of course be better to solve the issue through regular probing...
Quoted 3 lines
That’s why I was advocating a simple probing driver for all this. Figure out a way for this driver to be probed first would be an easier solution that what’s going on here.
Do you mean, a driver whose sole job is to probe other drivers in the right order? :/
Hi Alexandre,
Quoted 90 lines · Alexandre Courbot
Quoted 63 lines · Pantelis Antoniou
Hi Alexandre,
I tried to stay away while things are being fleshed out but…
Quoted 52 lines · Alexandre Courbot
Quoted 24 lines · Maxime Ripard
Quoted 16 lines · Linus Walleij
Quoted 8 lines · Alexandre Courbot
Quoted 4 lines · Maxime Ripard
The only thing I'd like to have would be that the request here would be non-exclusive, so that a later driver would still be allowed later on to request that GPIO later on and manage it itself (ideally using the usual
gpiod_requestfunction).Quoted 6 lines
Actually we have a plan (and I have some code too) to allow multiple consumers per GPIO. Although like Benoit I wonder why you would want to hog a GPIO and then request it properly later. Also, that probably means we should abandon the hog since it actively drives the line and would interfere with the late requested. How to do that correctly is not really clear to me.
Quoted 3 lines
I don't get the usecase. A hogged GPIO is per definition hogged. This sounds more like "initial settings" or something, which is another usecase altogether.
We do have one board where we have a pin (let's say GPIO14 of the bank
A) that enables a regulator that will provide VCC the bank B.Quoted 8 lines
Now, both banks are handled by the same driver, but in order to have a working output on the bank B, we do need to set GPIO14 as soon as we're probed.
Just relying on the usual deferred probing introduces a circular dependency between the gpio-regulator that needs to grab its GPIO from a driver not there yet, and the gpio driver that needs to enable its gpio-regulator.
I don't get it. According to what you said, the following order should go through IIUC:
1) bank A is probed, gpio 14 is available
2) gpio-regulator is probed, acquires GPIO 14, regulator for Bank B is available
3) bank B is probed, grabs its regulator and turn it on, probes.What am I missing?
Quoted 5 lines
GPIO hogging needs to be the ideal solution for that, since we can just enforce the GPIO14 value as the driver is probed, which provides the guarantee that any driver using the bank B will actually drive the GPIO it might use.
Quoted 6 lines
At this point I start wondering if such initial setup should not be the job of the bootloader? GPIO hogging ought to be simple and definitive, adding the possibility to have it just as an initial value would considerably complexify it. E.g. when is the gpio chip driver supposed to release the hogged descriptor in such a case?
Quoted 5 lines
Do not count on the bootloader setting up anything. The trend is for the bootloader to setup the minimal environment to load your kernel and jump to it.
http://www.denx.de/wiki/pub/U-Boot/MiniSummitELCE2013/2013-ELCE-U-Boot-Falcon-Boot.pdf
Just wondering. :)
But yeah, there are some use-cases (such as this one or Linux-as-a-bootloader) for which this would not play nicely.
Quoted 12 lines
Quoted 10 lines
Note that if the multiple GPIO consumer feature we are planning goes through, you should be able to use both hogging *and* a regulator on the same GPIO and achieve what you want. The expectation of multiple consumers is that the board designers know what they are doing, and this case would certainly fit (chip hogs the line and doesn't touch the value after that, letting the regulator control it without any conflict afterwards), although it would of course be better to solve the issue through regular probing...
Quoted 6 lines
Quoted 3 lines
That’s why I was advocating a simple probing driver for all this. Figure out a way for this driver to be probed first would be an easier solution that what’s going on here.
Do you mean, a driver whose sole job is to probe other drivers in the right order? :/
$DEITY no :)
I mean instead of having the gpio hog in the gpio adapter driver, have a gpio-hog driver, that’s using an undisclosed method to make sure that it’s the first one to be probed afterwards.
We can probably do it using DT.
Or maybe using the proposed gpio hog method doesn’t cover every case.
I don’t know, that’s why we’re spending time talking about this :)
Regards
— pantelis
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 96 lines · Pantelis Antoniou
Hi Alexandre,
Quoted 94 lines · Alexandre Courbot
Quoted 63 lines · Pantelis Antoniou
Hi Alexandre,
I tried to stay away while things are being fleshed out but…
Quoted 52 lines · Alexandre Courbot
Quoted 24 lines · Maxime Ripard
Quoted 16 lines · Linus Walleij
Quoted 8 lines · Alexandre Courbot
Quoted 4 lines · Maxime Ripard
The only thing I'd like to have would be that the request here would be non-exclusive, so that a later driver would still be allowed later on to request that GPIO later on and manage it itself (ideally using the usual
gpiod_requestfunction).Quoted 6 lines
Actually we have a plan (and I have some code too) to allow multiple consumers per GPIO. Although like Benoit I wonder why you would want to hog a GPIO and then request it properly later. Also, that probably means we should abandon the hog since it actively drives the line and would interfere with the late requested. How to do that correctly is not really clear to me.
Quoted 3 lines
I don't get the usecase. A hogged GPIO is per definition hogged. This sounds more like "initial settings" or something, which is another usecase altogether.
We do have one board where we have a pin (let's say GPIO14 of the bank
A) that enables a regulator that will provide VCC the bank B.Quoted 8 lines
Now, both banks are handled by the same driver, but in order to have a working output on the bank B, we do need to set GPIO14 as soon as we're probed.
Just relying on the usual deferred probing introduces a circular dependency between the gpio-regulator that needs to grab its GPIO from a driver not there yet, and the gpio driver that needs to enable its gpio-regulator.
I don't get it. According to what you said, the following order should go through IIUC:
1) bank A is probed, gpio 14 is available
2) gpio-regulator is probed, acquires GPIO 14, regulator for Bank B is available
3) bank B is probed, grabs its regulator and turn it on, probes.What am I missing?
Quoted 5 lines
GPIO hogging needs to be the ideal solution for that, since we can just enforce the GPIO14 value as the driver is probed, which provides the guarantee that any driver using the bank B will actually drive the GPIO it might use.
Quoted 6 lines
At this point I start wondering if such initial setup should not be the job of the bootloader? GPIO hogging ought to be simple and definitive, adding the possibility to have it just as an initial value would considerably complexify it. E.g. when is the gpio chip driver supposed to release the hogged descriptor in such a case?
Quoted 5 lines
Do not count on the bootloader setting up anything. The trend is for the bootloader to setup the minimal environment to load your kernel and jump to it.
http://www.denx.de/wiki/pub/U-Boot/MiniSummitELCE2013/2013-ELCE-U-Boot-Falcon-Boot.pdf
Just wondering. :)
But yeah, there are some use-cases (such as this one or Linux-as-a-bootloader) for which this would not play nicely.
Quoted 15 lines
Quoted 10 lines
Note that if the multiple GPIO consumer feature we are planning goes through, you should be able to use both hogging *and* a regulator on the same GPIO and achieve what you want. The expectation of multiple consumers is that the board designers know what they are doing, and this case would certainly fit (chip hogs the line and doesn't touch the value after that, letting the regulator control it without any conflict afterwards), although it would of course be better to solve the issue through regular probing...
That’s why I was advocating a simple probing driver for all this. Figure out a way for this driver to be probed first would be an easier solution that what’s going on here.
Quoted 8 lines
Quoted 2 lines
Do you mean, a driver whose sole job is to probe other drivers in the right order? :/
$DEITY no :)
I mean instead of having the gpio hog in the gpio adapter driver, have a gpio-hog driver, that’s using an undisclosed method to make sure that it’s the first one to be probed afterwards.
IIUC that would not solve this particular issue - here the GPIO controller is both a provider and (indirect) consumer of a GPIO for itself. If the hog is in a separate node, if would have to be probed from inside the probe() function of the GPIO controller to do the job, which would be the same effect as having the hogs directly under the controller node, only with more hassle.
Again, IIUC. >_<
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi Alexandre,
Quoted 109 lines · Alexandre Courbot
Quoted 96 lines · Pantelis Antoniou
Hi Alexandre,
Quoted 94 lines · Alexandre Courbot
Quoted 63 lines · Pantelis Antoniou
Hi Alexandre,
I tried to stay away while things are being fleshed out but…
Quoted 52 lines · Alexandre Courbot
Quoted 24 lines · Maxime Ripard
Quoted 16 lines · Linus Walleij
Quoted 8 lines · Alexandre Courbot
Quoted 4 lines · Maxime Ripard
The only thing I'd like to have would be that the request here would be non-exclusive, so that a later driver would still be allowed later on to request that GPIO later on and manage it itself (ideally using the usual
gpiod_requestfunction).Quoted 6 lines
Actually we have a plan (and I have some code too) to allow multiple consumers per GPIO. Although like Benoit I wonder why you would want to hog a GPIO and then request it properly later. Also, that probably means we should abandon the hog since it actively drives the line and would interfere with the late requested. How to do that correctly is not really clear to me.
Quoted 3 lines
I don't get the usecase. A hogged GPIO is per definition hogged. This sounds more like "initial settings" or something, which is another usecase altogether.
We do have one board where we have a pin (let's say GPIO14 of the bank
A) that enables a regulator that will provide VCC the bank B.Quoted 8 lines
Now, both banks are handled by the same driver, but in order to have a working output on the bank B, we do need to set GPIO14 as soon as we're probed.
Just relying on the usual deferred probing introduces a circular dependency between the gpio-regulator that needs to grab its GPIO from a driver not there yet, and the gpio driver that needs to enable its gpio-regulator.
I don't get it. According to what you said, the following order should go through IIUC:
1) bank A is probed, gpio 14 is available
2) gpio-regulator is probed, acquires GPIO 14, regulator for Bank B is available
3) bank B is probed, grabs its regulator and turn it on, probes.What am I missing?
Quoted 5 lines
GPIO hogging needs to be the ideal solution for that, since we can just enforce the GPIO14 value as the driver is probed, which provides the guarantee that any driver using the bank B will actually drive the GPIO it might use.
Quoted 6 lines
At this point I start wondering if such initial setup should not be the job of the bootloader? GPIO hogging ought to be simple and definitive, adding the possibility to have it just as an initial value would considerably complexify it. E.g. when is the gpio chip driver supposed to release the hogged descriptor in such a case?
Quoted 5 lines
Do not count on the bootloader setting up anything. The trend is for the bootloader to setup the minimal environment to load your kernel and jump to it.
http://www.denx.de/wiki/pub/U-Boot/MiniSummitELCE2013/2013-ELCE-U-Boot-Falcon-Boot.pdf
Just wondering. :)
But yeah, there are some use-cases (such as this one or Linux-as-a-bootloader) for which this would not play nicely.
Quoted 15 lines
Quoted 10 lines
Note that if the multiple GPIO consumer feature we are planning goes through, you should be able to use both hogging *and* a regulator on the same GPIO and achieve what you want. The expectation of multiple consumers is that the board designers know what they are doing, and this case would certainly fit (chip hogs the line and doesn't touch the value after that, letting the regulator control it without any conflict afterwards), although it would of course be better to solve the issue through regular probing...
That’s why I was advocating a simple probing driver for all this. Figure out a way for this driver to be probed first would be an easier solution that what’s going on here.
Quoted 8 lines
Quoted 2 lines
Do you mean, a driver whose sole job is to probe other drivers in the right order? :/
$DEITY no :)
I mean instead of having the gpio hog in the gpio adapter driver, have a gpio-hog driver, that’s using an undisclosed method to make sure that it’s the first one to be probed afterwards.
Quoted 8 lines
IIUC that would not solve this particular issue - here the GPIO controller is both a provider and (indirect) consumer of a GPIO for itself. If the hog is in a separate node, if would have to be probed from inside the
probe()function of the GPIO controller to do the job, which would be the same effect as having the hogs directly under the controller node, only with more hassle.Again, IIUC. >_<
If you had a way to specify the order of probing that would work no? You don’t have to do it in the gpio-controller, you can do it in the platform bus probe.
Regards
— Pantelis
--
To unsubscribe from this list: send the line "unsubscribe linux-gpio" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 118 lines · Pantelis Antoniou
Hi Alexandre,
Quoted 116 lines · Alexandre Courbot
Quoted 96 lines · Pantelis Antoniou
Hi Alexandre,
Quoted 94 lines · Alexandre Courbot
Quoted 63 lines · Pantelis Antoniou
Hi Alexandre,
I tried to stay away while things are being fleshed out but…
Quoted 52 lines · Alexandre Courbot
Quoted 24 lines · Maxime Ripard
Quoted 16 lines · Linus Walleij
Quoted 8 lines · Alexandre Courbot
Quoted 4 lines · Maxime Ripard
The only thing I'd like to have would be that the request here would be non-exclusive, so that a later driver would still be allowed later on to request that GPIO later on and manage it itself (ideally using the usual
gpiod_requestfunction).Quoted 6 lines
Actually we have a plan (and I have some code too) to allow multiple consumers per GPIO. Although like Benoit I wonder why you would want to hog a GPIO and then request it properly later. Also, that probably means we should abandon the hog since it actively drives the line and would interfere with the late requested. How to do that correctly is not really clear to me.
Quoted 3 lines
I don't get the usecase. A hogged GPIO is per definition hogged. This sounds more like "initial settings" or something, which is another usecase altogether.
We do have one board where we have a pin (let's say GPIO14 of the bank
A) that enables a regulator that will provide VCC the bank B.Quoted 8 lines
Now, both banks are handled by the same driver, but in order to have a working output on the bank B, we do need to set GPIO14 as soon as we're probed.
Just relying on the usual deferred probing introduces a circular dependency between the gpio-regulator that needs to grab its GPIO from a driver not there yet, and the gpio driver that needs to enable its gpio-regulator.
I don't get it. According to what you said, the following order should go through IIUC:
1) bank A is probed, gpio 14 is available
2) gpio-regulator is probed, acquires GPIO 14, regulator for Bank B is available
3) bank B is probed, grabs its regulator and turn it on, probes.What am I missing?
Quoted 5 lines
GPIO hogging needs to be the ideal solution for that, since we can just enforce the GPIO14 value as the driver is probed, which provides the guarantee that any driver using the bank B will actually drive the GPIO it might use.
Quoted 6 lines
At this point I start wondering if such initial setup should not be the job of the bootloader? GPIO hogging ought to be simple and definitive, adding the possibility to have it just as an initial value would considerably complexify it. E.g. when is the gpio chip driver supposed to release the hogged descriptor in such a case?
Quoted 5 lines
Do not count on the bootloader setting up anything. The trend is for the bootloader to setup the minimal environment to load your kernel and jump to it.
http://www.denx.de/wiki/pub/U-Boot/MiniSummitELCE2013/2013-ELCE-U-Boot-Falcon-Boot.pdf
Just wondering. :)
But yeah, there are some use-cases (such as this one or Linux-as-a-bootloader) for which this would not play nicely.
Quoted 15 lines
Quoted 10 lines
Note that if the multiple GPIO consumer feature we are planning goes through, you should be able to use both hogging *and* a regulator on the same GPIO and achieve what you want. The expectation of multiple consumers is that the board designers know what they are doing, and this case would certainly fit (chip hogs the line and doesn't touch the value after that, letting the regulator control it without any conflict afterwards), although it would of course be better to solve the issue through regular probing...
That’s why I was advocating a simple probing driver for all this. Figure out a way for this driver to be probed first would be an easier solution that what’s going on here.
Quoted 8 lines
Quoted 2 lines
Do you mean, a driver whose sole job is to probe other drivers in the right order? :/
$DEITY no :)
I mean instead of having the gpio hog in the gpio adapter driver, have a gpio-hog driver, that’s using an undisclosed method to make sure that it’s the first one to be probed afterwards.
IIUC that would not solve this particular issue - here the GPIO controller is both a provider and (indirect) consumer of a GPIO for itself. If the hog is in a separate node, if would have to be probed from inside the
probe()function of the GPIO controller to do the job, which would be the same effect as having the hogs directly under the controller node, only with more hassle.
Quoted 5 lines
Quoted 1 line
Again, IIUC. >_<
If you had a way to specify the order of probing that would work no? You don’t have to do it in the gpio-controller, you can do it in the platform bus probe.
A probe order that works would be the following:
1) bank A is probed, gpio 14 is available
2) gpio-regulator is probed, acquires GPIO 14, regulator for Bank B is available
3) bank B is probed, grabs its regulator and turn it on, probes.
The problem is that in the present case, 1) and 3) are the same operation because both banks are the same device.
You could probably solve this by making bank A and bank B separate devices, then even EPROBE_DEFER would allow you to probe everything in the right order. But since the DT bindings are (supposedly) already published this is likely not an option (?). And logically speaking, these banks form one device anyway.
Hi Alexandre,
Quoted 134 lines · Alexandre Courbot
Quoted 118 lines · Pantelis Antoniou
Hi Alexandre,
Quoted 116 lines · Alexandre Courbot
Quoted 96 lines · Pantelis Antoniou
Hi Alexandre,
Quoted 94 lines · Alexandre Courbot
Quoted 63 lines · Pantelis Antoniou
Hi Alexandre,
I tried to stay away while things are being fleshed out but…
Quoted 52 lines · Alexandre Courbot
Quoted 24 lines · Maxime Ripard
Quoted 16 lines · Linus Walleij
Quoted 8 lines · Alexandre Courbot
Quoted 4 lines · Maxime Ripard
The only thing I'd like to have would be that the request here would be non-exclusive, so that a later driver would still be allowed later on to request that GPIO later on and manage it itself (ideally using the usual
gpiod_requestfunction).Quoted 6 lines
Actually we have a plan (and I have some code too) to allow multiple consumers per GPIO. Although like Benoit I wonder why you would want to hog a GPIO and then request it properly later. Also, that probably means we should abandon the hog since it actively drives the line and would interfere with the late requested. How to do that correctly is not really clear to me.
Quoted 3 lines
I don't get the usecase. A hogged GPIO is per definition hogged. This sounds more like "initial settings" or something, which is another usecase altogether.
We do have one board where we have a pin (let's say GPIO14 of the bank
A) that enables a regulator that will provide VCC the bank B.Quoted 8 lines
Now, both banks are handled by the same driver, but in order to have a working output on the bank B, we do need to set GPIO14 as soon as we're probed.
Just relying on the usual deferred probing introduces a circular dependency between the gpio-regulator that needs to grab its GPIO from a driver not there yet, and the gpio driver that needs to enable its gpio-regulator.
I don't get it. According to what you said, the following order should go through IIUC:
1) bank A is probed, gpio 14 is available
2) gpio-regulator is probed, acquires GPIO 14, regulator for Bank B is available
3) bank B is probed, grabs its regulator and turn it on, probes.What am I missing?
Quoted 5 lines
GPIO hogging needs to be the ideal solution for that, since we can just enforce the GPIO14 value as the driver is probed, which provides the guarantee that any driver using the bank B will actually drive the GPIO it might use.
Quoted 6 lines
At this point I start wondering if such initial setup should not be the job of the bootloader? GPIO hogging ought to be simple and definitive, adding the possibility to have it just as an initial value would considerably complexify it. E.g. when is the gpio chip driver supposed to release the hogged descriptor in such a case?
Quoted 5 lines
Do not count on the bootloader setting up anything. The trend is for the bootloader to setup the minimal environment to load your kernel and jump to it.
http://www.denx.de/wiki/pub/U-Boot/MiniSummitELCE2013/2013-ELCE-U-Boot-Falcon-Boot.pdf
Just wondering. :)
But yeah, there are some use-cases (such as this one or Linux-as-a-bootloader) for which this would not play nicely.
Quoted 15 lines
Quoted 10 lines
Note that if the multiple GPIO consumer feature we are planning goes through, you should be able to use both hogging *and* a regulator on the same GPIO and achieve what you want. The expectation of multiple consumers is that the board designers know what they are doing, and this case would certainly fit (chip hogs the line and doesn't touch the value after that, letting the regulator control it without any conflict afterwards), although it would of course be better to solve the issue through regular probing...
That’s why I was advocating a simple probing driver for all this. Figure out a way for this driver to be probed first would be an easier solution that what’s going on here.
Quoted 8 lines
Quoted 2 lines
Do you mean, a driver whose sole job is to probe other drivers in the right order? :/
$DEITY no :)
I mean instead of having the gpio hog in the gpio adapter driver, have a gpio-hog driver, that’s using an undisclosed method to make sure that it’s the first one to be probed afterwards.
IIUC that would not solve this particular issue - here the GPIO controller is both a provider and (indirect) consumer of a GPIO for itself. If the hog is in a separate node, if would have to be probed from inside the
probe()function of the GPIO controller to do the job, which would be the same effect as having the hogs directly under the controller node, only with more hassle.Quoted 5 lines
Quoted 1 line
Again, IIUC. >_<
If you had a way to specify the order of probing that would work no? You don’t have to do it in the gpio-controller, you can do it in the platform bus probe.
A probe order that works would be the following:
1) bank A is probed, gpio 14 is available
2) gpio-regulator is probed, acquires GPIO 14, regulator for Bank B is available
3) bank B is probed, grabs its regulator and turn it on, probes.
Quoted 8 lines
The problem is that in the present case, 1) and 3) are the same operation because both banks are the same device.
You could probably solve this by making bank A and bank B separate devices, then even
EPROBE_DEFERwould allow you to probe everything in the right order. But since the DT bindings are (supposedly) already published this is likely not an option (?). And logically speaking, these banks form one device anyway.
Let’s put that in a pseudo DT definition.
BANK_A: bank_a {
compatible = “banka,gpio-controller”;
};GPIO_REGULATOR: gpio-regulator {
compatible = “gpio-regulator”;
gpio = <&BANK_A 14>;
};BANK_B: bank_b {
compatible = “bankb,gpio-controller”;
power-supply = <&GPIO_REGULATOR>;
};The correct probe order is bank_a, gpio-regulator, bank_b correct?
It is possible to modify DTC to follow phandle references and spit out a depends node that the platform bus probe can use.
For instance,
__depends__ {
gpio-regulator = <&BANK_A>;
bank_b = <&GPIO_REGULATOR>;
};Would that work for your case?
Regards
— Pantelis
Quoted 156 lines · Pantelis Antoniou
Hi Alexandre,
Quoted 134 lines · Alexandre Courbot
Quoted 118 lines · Pantelis Antoniou
Hi Alexandre,
Quoted 116 lines · Alexandre Courbot
Quoted 96 lines · Pantelis Antoniou
Hi Alexandre,
Quoted 94 lines · Alexandre Courbot
Quoted 63 lines · Pantelis Antoniou
Hi Alexandre,
I tried to stay away while things are being fleshed out but…
Quoted 52 lines · Alexandre Courbot
Quoted 24 lines · Maxime Ripard
Quoted 16 lines · Linus Walleij
Quoted 8 lines · Alexandre Courbot
Quoted 4 lines · Maxime Ripard
The only thing I'd like to have would be that the request here would be non-exclusive, so that a later driver would still be allowed later on to request that GPIO later on and manage it itself (ideally using the usual
gpiod_requestfunction).Quoted 6 lines
Actually we have a plan (and I have some code too) to allow multiple consumers per GPIO. Although like Benoit I wonder why you would want to hog a GPIO and then request it properly later. Also, that probably means we should abandon the hog since it actively drives the line and would interfere with the late requested. How to do that correctly is not really clear to me.
Quoted 3 lines
I don't get the usecase. A hogged GPIO is per definition hogged. This sounds more like "initial settings" or something, which is another usecase altogether.
We do have one board where we have a pin (let's say GPIO14 of the bank
A) that enables a regulator that will provide VCC the bank B.Quoted 8 lines
Now, both banks are handled by the same driver, but in order to have a working output on the bank B, we do need to set GPIO14 as soon as we're probed.
Just relying on the usual deferred probing introduces a circular dependency between the gpio-regulator that needs to grab its GPIO from a driver not there yet, and the gpio driver that needs to enable its gpio-regulator.
I don't get it. According to what you said, the following order should go through IIUC:
1) bank A is probed, gpio 14 is available
2) gpio-regulator is probed, acquires GPIO 14, regulator for Bank B is available
3) bank B is probed, grabs its regulator and turn it on, probes.What am I missing?
Quoted 5 lines
GPIO hogging needs to be the ideal solution for that, since we can just enforce the GPIO14 value as the driver is probed, which provides the guarantee that any driver using the bank B will actually drive the GPIO it might use.
Quoted 6 lines
At this point I start wondering if such initial setup should not be the job of the bootloader? GPIO hogging ought to be simple and definitive, adding the possibility to have it just as an initial value would considerably complexify it. E.g. when is the gpio chip driver supposed to release the hogged descriptor in such a case?
Quoted 5 lines
Do not count on the bootloader setting up anything. The trend is for the bootloader to setup the minimal environment to load your kernel and jump to it.
http://www.denx.de/wiki/pub/U-Boot/MiniSummitELCE2013/2013-ELCE-U-Boot-Falcon-Boot.pdf
Just wondering. :)
But yeah, there are some use-cases (such as this one or Linux-as-a-bootloader) for which this would not play nicely.
Quoted 15 lines
Quoted 10 lines
Note that if the multiple GPIO consumer feature we are planning goes through, you should be able to use both hogging *and* a regulator on the same GPIO and achieve what you want. The expectation of multiple consumers is that the board designers know what they are doing, and this case would certainly fit (chip hogs the line and doesn't touch the value after that, letting the regulator control it without any conflict afterwards), although it would of course be better to solve the issue through regular probing...
That’s why I was advocating a simple probing driver for all this. Figure out a way for this driver to be probed first would be an easier solution that what’s going on here.
Quoted 8 lines
Quoted 2 lines
Do you mean, a driver whose sole job is to probe other drivers in the right order? :/
$DEITY no :)
I mean instead of having the gpio hog in the gpio adapter driver, have a gpio-hog driver, that’s using an undisclosed method to make sure that it’s the first one to be probed afterwards.
IIUC that would not solve this particular issue - here the GPIO controller is both a provider and (indirect) consumer of a GPIO for itself. If the hog is in a separate node, if would have to be probed from inside the
probe()function of the GPIO controller to do the job, which would be the same effect as having the hogs directly under the controller node, only with more hassle.Quoted 5 lines
Quoted 1 line
Again, IIUC. >_<
If you had a way to specify the order of probing that would work no? You don’t have to do it in the gpio-controller, you can do it in the platform bus probe.
A probe order that works would be the following:
1) bank A is probed, gpio 14 is available
2) gpio-regulator is probed, acquires GPIO 14, regulator for Bank B is available
3) bank B is probed, grabs its regulator and turn it on, probes.Quoted 8 lines
The problem is that in the present case, 1) and 3) are the same operation because both banks are the same device.
You could probably solve this by making bank A and bank B separate devices, then even
EPROBE_DEFERwould allow you to probe everything in the right order. But since the DT bindings are (supposedly) already published this is likely not an option (?). And logically speaking, these banks form one device anyway.Let’s put that in a pseudo DT definition.
BANK_A: bank_a { compatible = “banka,gpio-controller”; };GPIO_REGULATOR: gpio-regulator { compatible = “gpio-regulator”; gpio = <&BANK_A 14>; };
Quoted 6 lines
BANK_B: bank_b { compatible = “bankb,gpio-controller”; power-supply = <&GPIO_REGULATOR>; };The correct probe order is
bank_a, gpio-regulator,bank_bcorrect?
Right. And actually this would work without any DT annotation, altough it might take a few more loops to get to the right order.
But as Maxime confirmed later, his device is more like this:
/* Contains both banks A and B */
gpio: gpio {
compatible = "foo,gpio-controller";
bankb-supply = <&GPIO_REGULATOR>'
};
GPIO_REGULATOR: gpio-regulator {
compatible = “gpio-regulator”;
gpio = <&gpio 14>;
};And here there is nothing we can do, I'm afraid, without splitting the banks into their own nodes first.
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Hi,
Quoted 35 lines · Alexandre Courbot
Quoted 24 lines · Maxime Ripard
Quoted 16 lines · Linus Walleij
Quoted 8 lines · Alexandre Courbot
Quoted 4 lines · Maxime Ripard
The only thing I'd like to have would be that the request here would be non-exclusive, so that a later driver would still be allowed later on to request that GPIO later on and manage it itself (ideally using the usual
gpiod_requestfunction).Quoted 6 lines
Actually we have a plan (and I have some code too) to allow multiple consumers per GPIO. Although like Benoit I wonder why you would want to hog a GPIO and then request it properly later. Also, that probably means we should abandon the hog since it actively drives the line and would interfere with the late requested. How to do that correctly is not really clear to me.
Quoted 3 lines
I don't get the usecase. A hogged GPIO is per definition hogged. This sounds more like "initial settings" or something, which is another usecase altogether.
We do have one board where we have a pin (let's say GPIO14 of the bank
A) that enables a regulator that will provide VCC the bank B.Quoted 8 lines
Now, both banks are handled by the same driver, but in order to have a working output on the bank B, we do need to set GPIO14 as soon as we're probed.
Just relying on the usual deferred probing introduces a circular dependency between the gpio-regulator that needs to grab its GPIO from a driver not there yet, and the gpio driver that needs to enable its gpio-regulator.
Quoted 8 lines
I don't get it. According to what you said, the following order should go through IIUC:
1) bank A is probed, gpio 14 is available
2) gpio-regulator is probed, acquires GPIO 14, regulator for Bank B is available
3) bank B is probed, grabs its regulator and turn it on, probes.What am I missing?
It would be true if bank A and B were exposed through different drivers (or at least different instances of the same driver), which is not the case.
In our case, banks A and B are handled by the same instance.
Maxime
Signature · 3 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
Quoted 45 lines · Maxime Ripard
Hi,
Quoted 42 lines · Alexandre Courbot
Quoted 24 lines · Maxime Ripard
Quoted 16 lines · Linus Walleij
Quoted 8 lines · Alexandre Courbot
Quoted 4 lines · Maxime Ripard
The only thing I'd like to have would be that the request here would be non-exclusive, so that a later driver would still be allowed later on to request that GPIO later on and manage it itself (ideally using the usual
gpiod_requestfunction).Quoted 6 lines
Actually we have a plan (and I have some code too) to allow multiple consumers per GPIO. Although like Benoit I wonder why you would want to hog a GPIO and then request it properly later. Also, that probably means we should abandon the hog since it actively drives the line and would interfere with the late requested. How to do that correctly is not really clear to me.
Quoted 3 lines
I don't get the usecase. A hogged GPIO is per definition hogged. This sounds more like "initial settings" or something, which is another usecase altogether.
We do have one board where we have a pin (let's say GPIO14 of the bank
A) that enables a regulator that will provide VCC the bank B.Quoted 8 lines
Now, both banks are handled by the same driver, but in order to have a working output on the bank B, we do need to set GPIO14 as soon as we're probed.
Just relying on the usual deferred probing introduces a circular dependency between the gpio-regulator that needs to grab its GPIO from a driver not there yet, and the gpio driver that needs to enable its gpio-regulator.
I don't get it. According to what you said, the following order should go through IIUC:
1) bank A is probed, gpio 14 is available
2) gpio-regulator is probed, acquires GPIO 14, regulator for Bank B is available
3) bank B is probed, grabs its regulator and turn it on, probes.
Quoted 7 lines
Quoted 1 line
What am I missing?
It would be true if bank A and B were exposed through different drivers (or at least different instances of the same driver), which is not the case.
In our case, banks A and B are handled by the same instance.
Ok, so both banks A and B are part of the same device/DT node. Now I think I understand the issue. You need to hog the pin so that bank B will work right after the device is probed.
But you will still have the problem that the regulator device will *not* be available when your device is probed, so you cannot call regulator_get() for bank B anyway. I guess your only choice is to hog that pin and leave it active ad vitam eternam.
Quoted 53 lines · Alexandre Courbot
Quoted 51 lines · Maxime Ripard
Hi,
Quoted 35 lines · Alexandre Courbot
Quoted 24 lines · Maxime Ripard
Quoted 16 lines · Linus Walleij
Quoted 8 lines · Alexandre Courbot
Quoted 4 lines · Maxime Ripard
The only thing I'd like to have would be that the request here would be non-exclusive, so that a later driver would still be allowed later on to request that GPIO later on and manage it itself (ideally using the usual
gpiod_requestfunction).Quoted 6 lines
Actually we have a plan (and I have some code too) to allow multiple consumers per GPIO. Although like Benoit I wonder why you would want to hog a GPIO and then request it properly later. Also, that probably means we should abandon the hog since it actively drives the line and would interfere with the late requested. How to do that correctly is not really clear to me.
Quoted 3 lines
I don't get the usecase. A hogged GPIO is per definition hogged. This sounds more like "initial settings" or something, which is another usecase altogether.
We do have one board where we have a pin (let's say GPIO14 of the bank
A) that enables a regulator that will provide VCC the bank B.Quoted 8 lines
Now, both banks are handled by the same driver, but in order to have a working output on the bank B, we do need to set GPIO14 as soon as we're probed.
Just relying on the usual deferred probing introduces a circular dependency between the gpio-regulator that needs to grab its GPIO from a driver not there yet, and the gpio driver that needs to enable its gpio-regulator.
Quoted 8 lines
I don't get it. According to what you said, the following order should go through IIUC:
1) bank A is probed, gpio 14 is available
2) gpio-regulator is probed, acquires GPIO 14, regulator for Bank B is available
3) bank B is probed, grabs its regulator and turn it on, probes.What am I missing?
It would be true if bank A and B were exposed through different drivers (or at least different instances of the same driver), which is not the case.
Quoted 5 lines
Quoted 1 line
In our case, banks A and B are handled by the same instance.
Ok, so both banks A and B are part of the same device/DT node. Now I think I understand the issue. You need to hog the pin so that bank B will work right after the device is probed.
Exactly.
Quoted 4 lines
But you will still have the problem that the regulator device will *not* be available when your device is probed, so you cannot call
regulator_get()for bank B anyway. I guess your only choice is to hog that pin and leave it active ad vitam eternam.
Hmmm, indeed.
I'll stop boring you with this then :)
Maxime
Signature · 3 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
Quoted 62 lines · Maxime Ripard
Quoted 53 lines · Alexandre Courbot
Quoted 51 lines · Maxime Ripard
Hi,
Quoted 35 lines · Alexandre Courbot
Quoted 24 lines · Maxime Ripard
Quoted 16 lines · Linus Walleij
Quoted 8 lines · Alexandre Courbot
Quoted 4 lines · Maxime Ripard
The only thing I'd like to have would be that the request here would be non-exclusive, so that a later driver would still be allowed later on to request that GPIO later on and manage it itself (ideally using the usual
gpiod_requestfunction).Quoted 6 lines
Actually we have a plan (and I have some code too) to allow multiple consumers per GPIO. Although like Benoit I wonder why you would want to hog a GPIO and then request it properly later. Also, that probably means we should abandon the hog since it actively drives the line and would interfere with the late requested. How to do that correctly is not really clear to me.
Quoted 3 lines
I don't get the usecase. A hogged GPIO is per definition hogged. This sounds more like "initial settings" or something, which is another usecase altogether.
We do have one board where we have a pin (let's say GPIO14 of the bank
A) that enables a regulator that will provide VCC the bank B.Quoted 8 lines
Now, both banks are handled by the same driver, but in order to have a working output on the bank B, we do need to set GPIO14 as soon as we're probed.
Just relying on the usual deferred probing introduces a circular dependency between the gpio-regulator that needs to grab its GPIO from a driver not there yet, and the gpio driver that needs to enable its gpio-regulator.
Quoted 8 lines
I don't get it. According to what you said, the following order should go through IIUC:
1) bank A is probed, gpio 14 is available
2) gpio-regulator is probed, acquires GPIO 14, regulator for Bank B is available
3) bank B is probed, grabs its regulator and turn it on, probes.What am I missing?
It would be true if bank A and B were exposed through different drivers (or at least different instances of the same driver), which is not the case.
Quoted 5 lines
Quoted 1 line
In our case, banks A and B are handled by the same instance.
Ok, so both banks A and B are part of the same device/DT node. Now I think I understand the issue. You need to hog the pin so that bank B will work right after the device is probed.
Exactly.
Quoted 8 lines
Quoted 4 lines
But you will still have the problem that the regulator device will *not* be available when your device is probed, so you cannot call
regulator_get()for bank B anyway. I guess your only choice is to hog that pin and leave it active ad vitam eternam.Hmmm, indeed.
I'll stop boring you with this then :)
Please *keep* bothering us with any doubt you may have until they are all cleared and you are sure this feature will be useful to you. Especially since we are designing DT bindings that will have to be carried over forever. We really want to get them right, and need input of potential users for that.
Having a few design arguments is a small thing compared to the hassle of having to work with unadapted features and bindings.
Quoted 73 lines · Alexandre Courbot
Quoted 62 lines · Maxime Ripard
Quoted 53 lines · Alexandre Courbot
Quoted 51 lines · Maxime Ripard
Hi,
Quoted 35 lines · Alexandre Courbot
Quoted 24 lines · Maxime Ripard
Quoted 16 lines · Linus Walleij
Quoted 8 lines · Alexandre Courbot
Quoted 4 lines · Maxime Ripard
The only thing I'd like to have would be that the request here would be non-exclusive, so that a later driver would still be allowed later on to request that GPIO later on and manage it itself (ideally using the usual
gpiod_requestfunction).Quoted 6 lines
Actually we have a plan (and I have some code too) to allow multiple consumers per GPIO. Although like Benoit I wonder why you would want to hog a GPIO and then request it properly later. Also, that probably means we should abandon the hog since it actively drives the line and would interfere with the late requested. How to do that correctly is not really clear to me.
Quoted 3 lines
I don't get the usecase. A hogged GPIO is per definition hogged. This sounds more like "initial settings" or something, which is another usecase altogether.
We do have one board where we have a pin (let's say GPIO14 of the bank
A) that enables a regulator that will provide VCC the bank B.Quoted 8 lines
Now, both banks are handled by the same driver, but in order to have a working output on the bank B, we do need to set GPIO14 as soon as we're probed.
Just relying on the usual deferred probing introduces a circular dependency between the gpio-regulator that needs to grab its GPIO from a driver not there yet, and the gpio driver that needs to enable its gpio-regulator.
Quoted 8 lines
I don't get it. According to what you said, the following order should go through IIUC:
1) bank A is probed, gpio 14 is available
2) gpio-regulator is probed, acquires GPIO 14, regulator for Bank B is available
3) bank B is probed, grabs its regulator and turn it on, probes.What am I missing?
It would be true if bank A and B were exposed through different drivers (or at least different instances of the same driver), which is not the case.
Quoted 5 lines
Quoted 1 line
In our case, banks A and B are handled by the same instance.
Ok, so both banks A and B are part of the same device/DT node. Now I think I understand the issue. You need to hog the pin so that bank B will work right after the device is probed.
Exactly.
Quoted 8 lines
Quoted 4 lines
But you will still have the problem that the regulator device will *not* be available when your device is probed, so you cannot call
regulator_get()for bank B anyway. I guess your only choice is to hog that pin and leave it active ad vitam eternam.Hmmm, indeed.
I'll stop boring you with this then :)
Quoted 8 lines
Please *keep* bothering us with any doubt you may have until they are all cleared and you are sure this feature will be useful to you. Especially since we are designing DT bindings that will have to be carried over forever. We really want to get them right, and need input of potential users for that.
Having a few design arguments is a small thing compared to the hassle of having to work with unadapted features and bindings.
Ok. What I had in mind when I first thought about it was to set GPIO as hogged through the GPIO flags, and then have a dumb GPIO driver like Pantelis was suggesting.
I don't know if hogged would still be the right term, but we could have that flag that would just allow the value to be set through gpio_request init value, and deny/cache any subsequent change through gpio_set_value.
gpio_request with this flag would never return EPROBE_DEFER, and just cache the value to be set for when the driver comes in.
We could enforce driver-less GPIOs through that dumb driver, and we would still be able to break weird dependency chains that end up in circle.
That's just a thought though.
Maxime
Signature · 3 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
Hi again,
It looks like I missed some part of it.
Quoted 10 lines · Alexandre Courbot
Quoted 4 lines
GPIO hogging needs to be the ideal solution for that, since we can just enforce the GPIO14 value as the driver is probed, which provides the guarantee that any driver using the bank B will actually drive the GPIO it might use.
At this point I start wondering if such initial setup should not be the job of the bootloader? GPIO hogging ought to be simple and definitive, adding the possibility to have it just as an initial value would considerably complexify it. E.g. when is the gpio chip driver supposed to release the hogged descriptor in such a case?
Relying on the bootloader for such trivial (and critical) things may not work at all. You don't always have the option to replace it, either because you physically can't, or just because you don't have any alternative.
I agree that in general this is something that should go in the bootloader, but we should have a way to deal with the case where it's not done.
Quoted 8 lines
Note that if the multiple GPIO consumer feature we are planning goes through, you should be able to use both hogging *and* a regulator on the same GPIO and achieve what you want. The expectation of multiple consumers is that the board designers know what they are doing, and this case would certainly fit (chip hogs the line and doesn't touch the value after that, letting the regulator control it without any conflict afterwards), although it would of course be better to solve the issue through regular probing...
If such an effort is on-going, then I'm totally fine waiting for it and leaving that outside the hogging mechanism. As long as it works, I'm happy.
Maxime
Signature · 3 lines
Maxime Ripard, Free Electrons Embedded Linux, Kernel and Android engineering http://free-electrons.com
Quoted 34 lines · Maxime Ripard
Hi again,
It looks like I missed some part of it.
Quoted 10 lines · Alexandre Courbot
Quoted 4 lines
GPIO hogging needs to be the ideal solution for that, since we can just enforce the GPIO14 value as the driver is probed, which provides the guarantee that any driver using the bank B will actually drive the GPIO it might use.
At this point I start wondering if such initial setup should not be the job of the bootloader? GPIO hogging ought to be simple and definitive, adding the possibility to have it just as an initial value would considerably complexify it. E.g. when is the gpio chip driver supposed to release the hogged descriptor in such a case?
Relying on the bootloader for such trivial (and critical) things may not work at all. You don't always have the option to replace it, either because you physically can't, or just because you don't have any alternative.
I agree that in general this is something that should go in the bootloader, but we should have a way to deal with the case where it's not done.
Quoted 8 lines
Note that if the multiple GPIO consumer feature we are planning goes through, you should be able to use both hogging *and* a regulator on the same GPIO and achieve what you want. The expectation of multiple consumers is that the board designers know what they are doing, and this case would certainly fit (chip hogs the line and doesn't touch the value after that, letting the regulator control it without any conflict afterwards), although it would of course be better to solve the issue through regular probing...
Quoted 3 lines
If such an effort is on-going, then I'm totally fine waiting for it and leaving that outside the hogging mechanism. As long as it works, I'm happy.
Ok. I just want to wait until the next -rc1 to make sure that the large GPIO array removal patch (on which the multiple consumers feature depend) did not break anything important, then I will submit it.
Quoted 33 lines · Maxime Ripard
Quoted 16 lines · Linus Walleij
Quoted 8 lines · Alexandre Courbot
Quoted 4 lines · Maxime Ripard
The only thing I'd like to have would be that the request here would be non-exclusive, so that a later driver would still be allowed later on to request that GPIO later on and manage it itself (ideally using the usual
gpiod_requestfunction).Quoted 6 lines
Actually we have a plan (and I have some code too) to allow multiple consumers per GPIO. Although like Benoit I wonder why you would want to hog a GPIO and then request it properly later. Also, that probably means we should abandon the hog since it actively drives the line and would interfere with the late requested. How to do that correctly is not really clear to me.
Quoted 3 lines
I don't get the usecase. A hogged GPIO is per definition hogged. This sounds more like "initial settings" or something, which is another usecase altogether.
We do have one board where we have a pin (let's say GPIO14 of the bank
A) that enables a regulator that will provide VCC the bank B.Now, both banks are handled by the same driver, but in order to have a working output on the bank B, we do need to set GPIO14 as soon as we're probed.
Just relying on the usual deferred probing introduces a circular dependency between the gpio-regulator that needs to grab its GPIO from a driver not there yet, and the gpio driver that needs to enable its gpio-regulator.
Quoted 8 lines
GPIO hogging needs to be the ideal solution for that, since we can just enforce the GPIO14 value as the driver is probed, which provides the guarantee that any driver using the bank B will actually drive the GPIO it might use.
However, an exclusive request will prevent any representation of this as a regulator, which sounds a bit weird, since it really is just that.
Well that's elegant...
I think it's a hog in this case though, not a GPIO regulator, definately not both. But let's check Mark's opinion on this.
Yours,
Linus Walleij
Quoted 7 lines · Linus Walleij
On Tue, Dec 2, 2014 at 5:12 PM, Maxime Ripard
Quoted 2 lines
We do have one board where we have a pin (let's say GPIO14 of the bank
A) that enables a regulator that will provide VCC the bank B.I think it's a hog in this case though, not a GPIO regulator, definately not both. But let's check Mark's opinion on this.
I'm lacking some context here but my first thought is that if VCC might be supplied by some other thing we need to use a regulator since otherwise we can't substitute in the other regulator.
Alexandre Courbot <[email protected]> wrote on Fri [2014-Nov-28 16:30:01 +0900]:
Quoted 67 lines · Benoit Parrot
Quoted 66 lines
Based on Boris Brezillion's work this is a reworked patch of his initial GPIO hogging mechanism.
This patch provides a way to initally configure specific GPIO when the gpio controller is probed.The actual DT scanning to collect the GPIO specific data is performed as part of the
gpiochip_add().The purpose of this is to allows specific GPIOs to be configured without any driver specific code.
This particularly useful because board design are getting increasingly complex and given SoC pins can now have upward of 10 mux values a lot of connections are now dependent on external IO muxes to switch various modes and combination.Specific drivers should not necessarily need to be aware of what accounts to a specific board implementation. This board level "description" should be best kept as part of the dts file.
Signed-off-by Benoit Parrot <[email protected]>---
Changes since v1:
* Refactor the gpio-hog mechanism as private functions meant to be to invoked fromof_gpiochip_add().drivers/gpio/gpiolib-of.c | 188 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 188 insertions(+)drivers/gpio/gpiolib-of.c +23
-0@@ -22,6 +22,7 @@#include <linux/of_gpio.h> #include <linux/pinctrl/pinctrl.h> #include <linux/slab.h> +#include <linux/gpio/machine.h> #include "gpiolib.h" @@ -111,6 +112,184 @@ int of_get_named_gpio_flags(struct device_node *np, const char *list_name,EXPORT_SYMBOL (of_get_named_gpio_flags);/** +* of_get_gpio_hog() - Get a GPIO hog descriptor, names and flags for GPIO API +* @np: device node to get GPIO from +* @name: GPIO line name +* @flags: a flags pointer to fill in +* +* Returns GPIO descriptor to use with Linux GPIO API, or one of the errno +* value on the error condition. +*/ + +static struct gpio_desc *of_get_gpio_hog (struct device_node *np, +const char **name, +enum gpio_lookup_flags *lflags, +enum gpiod_flags *dflags) +{ +struct device_node *chip_np; +enum of_gpio_flags xlate_flags; +struct gpio_desc *desc; +struct gg_data gg_data = { + .flags = &xlate_flags, + .out_gpio =NULL , + }; +u32 tmp;
Quoted 8 lines
drivers/gpio/gpiolib-of.c int of_get_named_gpio_flags(struct device_node *np, const char *list_name, · line 141
Quoted 5 lines
drivers/gpio/gpiolib-of.c +5
-0+int i, in, outlo, outhi; +int ret; + +if (!np) +return ERR_PTR (-EINVAL );This function is being called from a perfectly mastered context in this file, so maybe we can avoid this check.
You are correct, I will change this.
Quoted 14 lines
drivers/gpio/gpiolib-of.c int of_get_named_gpio_flags(struct device_node *np, const char *list_name, · line 152
Quoted 12 lines
drivers/gpio/gpiolib-of.c +11
-0+ + chip_np = np->parent; +if (!chip_np) { + desc =ERR_PTR (-EINVAL ); + goto out; + } + +if (!lflags || !dflags) { + desc =ERR_PTR (-EINVAL ); + goto out; + }Same for this one.
Agreed.
Quoted 15 lines
drivers/gpio/gpiolib-of.c int of_get_named_gpio_flags(struct device_node *np, const char *list_name, · line 163
Quoted 12 lines
drivers/gpio/gpiolib-of.c +11
-0+ + *lflags =0 ; + *dflags =0 ; + in =0 ; + outlo =0 ; + outhi =0 ; + + ret =of_property_read_u32 (chip_np,"#gpio-cells" , &tmp); +if (ret) { + desc =ERR_PTR (ret); + goto out;Please use "return
ERR_PTR(ret);" directly, since you do absolutely no cleanup in out:. Same remark everywhere it applies.
Agreed.
Quoted 16 lines
Quoted 16 lines
drivers/gpio/gpiolib-of.c +15
-0+ } + +if (tmp >MAX_PHANDLE_ARGS ) { + desc =ERR_PTR (-EINVAL ); + goto out; + } + + gg_data.gpiospec.args_count = tmp; + gg_data.gpiospec.np = chip_np; +for (i =0 ; i < tmp; i++) { + ret =of_property_read_u32 (np,"gpios" , + &gg_data.gpiospec.args[i]); +if (ret) { + desc =ERR_PTR (ret); + goto out;
Quoted 8 lines
drivers/gpio/gpiolib-of.c int of_get_named_gpio_flags(struct device_node *np, const char *list_name, · line 182
Quoted 4 lines
drivers/gpio/gpiolib-of.c +4
-0+ } + } + +gpiochip_find (&gg_data, of_gpiochip_find_and_xlate);This seems to work but only supports one GPIO per hog node. It would be nice to be able to specify several GPIOs to which the same settings need to be applied.
This is on purpose following Linus Walleij's comment.
Quoted 19 lines
Quoted 19 lines
drivers/gpio/gpiolib-of.c +18
-0+if (!gg_data.out_gpio) { +if (np->parent == np) + desc =ERR_PTR (-ENXIO ); +else + desc =ERR_PTR (-EPROBE_DEFER ); + goto out; + } + +if (xlate_flags &OF_GPIO_ACTIVE_LOW ) + *lflags |=GPIOF_ACTIVE_LOW ; + +if (of_property_read_bool (np,"input" )) { + *dflags |=GPIOD_IN ; + in =1 ; + } +if (of_property_read_bool (np,"output-low" )) { + *dflags |=GPIOD_OUT_LOW ; + outlo =1 ;
Quoted 8 lines
drivers/gpio/gpiolib-of.c int of_get_named_gpio_flags(struct device_node *np, const char *list_name, · line 205
Quoted 5 lines
drivers/gpio/gpiolib-of.c +5
-0+ } +if (of_property_read_bool (np,"output-high" )) { + *dflags |=GPIOD_OUT_HIGH ; + outhi =1 ; + }I thought we agreed that this should be a "direction = input|output-low|output-high" property?
Yes, miss that my bad.
I'll change it, so it will only look for a single "direction" node, and hopefully simplify this mess.
Quoted 12 lines
drivers/gpio/gpiolib-of.c int of_get_named_gpio_flags(struct device_node *np, const char *list_name, · line 215
Quoted 11 lines
drivers/gpio/gpiolib-of.c +10
-0+if ((in + outlo + outhi) >1 ) { +pr_warn ("%s: GPIO %s: more than one direction/value selected, assuming: %s.\n" , + __func__, np->name, + (outhi)?"output-high" :(outlo)?"output-low" :"input" ); + } + +if (of_property_read_bool (np,"open-drain-line" )) + *lflags |=GPIO_OPEN_DRAIN ; +if (of_property_read_bool (np,"open-source-line" )) + *lflags |=GPIO_OPEN_SOURCE ;
Quoted 1 line
These properties are not documented in your DT bindings.
Yeah I'll remove those as they might as well be covered under the "xlate_flags" instead similar to GPIO_ACTIVE_LOW or whenever it gets propagated.
Quoted 30 lines
Quoted 30 lines
drivers/gpio/gpiolib-of.c +29
-0+if (name &&of_property_read_string (np,"line-name" , name)) + *name = np->name; + + desc = gg_data.out_gpio; + +out: +return desc; +} + + +/** +* do_gpio_hog - Given node is a GPIO hog configuration, handle it +* @np: device node to get GPIO from +* +* This is only used by of_gpiochip_add to request/set GPIO initial +* configuration. +*/ +static int do_gpio_hog (struct device_node *np) +{ +struct gpio_desc *desc =NULL ; +int err; +const char *name; +enum gpio_lookup_flags lflags; +enum gpiod_flags dflags; + + desc =of_get_gpio_hog (np, &name, &lflags, &dflags); +if (!desc) +return -ENOTSUPP ; +else if (IS_ERR (desc))
Quoted 8 lines
drivers/gpio/gpiolib-of.c int of_get_named_gpio_flags(struct device_node *np, const char *list_name, · line 247
Quoted 3 lines
drivers/gpio/gpiolib-of.c +3
-0+return PTR_ERR (desc); + + err =gpiod_request (desc, name);Using this function means that a GPIO chip module cannot be unloaded if it uses GPIO hogs. Is it the intended behavior? If not, please use
gpiochip_request_own_desc()instead, and make sure to callgpiochip_free_own_desc()for each hog when the driver is unloaded.
So I guess we could add a undo_gpio_hog() function and hook it up under of_gpiochip_remove(). Now instead of maintaining a seperate structure just to keep track of hogged descriptor, would it be acceptable to add a new "gpio_desc.flags" value in gpiolib.h says:
#define FLAG_GPIO_IS_HOGGED 10
And key on that at removal time instead of creating a list and having to maintain that?
Quoted 27 lines
Quoted 27 lines
drivers/gpio/gpiolib-of.c +26
-0+if (err <0 ) +return err; + +if (lflags &GPIO_ACTIVE_LOW ) +set_bit (FLAG_ACTIVE_LOW , &desc->flags); +if (lflags &GPIO_OPEN_DRAIN ) +set_bit (FLAG_OPEN_DRAIN , &desc->flags); +if (lflags &GPIO_OPEN_SOURCE ) +set_bit (FLAG_OPEN_SOURCE , &desc->flags); + +/* No particular flag request, not really hogging then... */ +if (!(dflags &GPIOD_FLAGS_BIT_DIR_SET )) { +pr_warn ("%s: GPIO %s: no hogging direction specified, bailing out\n" , + __func__, name); + err = -EINVAL ; + goto free_gpio; + } + +/* Process flags */ +if (dflags &GPIOD_FLAGS_BIT_DIR_OUT ) + err =gpiod_direction_output (desc, + dflags &GPIOD_FLAGS_BIT_DIR_VAL ); +else + err =gpiod_direction_input (desc); + +if (err <0 ) {
Quoted 8 lines
drivers/gpio/gpiolib-of.c int of_get_named_gpio_flags(struct device_node *np, const char *list_name, · line 277
Quoted 4 lines
drivers/gpio/gpiolib-of.c +4
-0+pr_warn ("%s: GPIO %s setting direction/value failed\n" , + __func__, name); + goto free_gpio; + }I would suggest to factorize this code that is similar to the one found in
__gpiod_get_index(). Do all the DT parsing in a function that just returns a descriptor and the
I would tend to agree.
But as Linus suggested I was trying to contain the changes to gpiolib_of.c only.
Quoted 13 lines
Quoted 13 lines
drivers/gpio/gpiolib-of.c +12
-0+ +pr_debug ("%s: gpio-hog: GPIO:%d (%s) as %s%s\n" , __func__, +desc_to_gpio (desc), name, + (dflags&GPIOD_FLAGS_BIT_DIR_OUT ) ?"output" :"input" , + (dflags&GPIOD_FLAGS_BIT_DIR_OUT ) ? + (dflags&GPIOD_FLAGS_BIT_DIR_VAL ) ?"/high" :"/low" :"" ); + +return 0 ; + +free_gpio: +gpiod_put (desc); +return err;
Quoted 9 lines
drivers/gpio/gpiolib-of.c int of_get_named_gpio_flags(struct device_node *np, const char *list_name, · line 290
Quoted 1 line
drivers/gpio/gpiolib-of.c +1
-0+}I think most of this function should be moved into
gpiolib.c. Add a function there that takes the descriptor, lflags and dflags and that sets the GPIO up, possibly adding it to a list of hogs so we can unset the hogs when unloading the module. That way we have a hogging mechanism that is not dependent on device tree and can be used by other GPIO binders, such as ACPI.
That's fine with as long as everyone agrees.
Quoted 3 lines
There is still some work needed but it looks much better than the first version. Please make sure to also keep Maxime, Pantelis and Jiri in the loop since they expressed interest in your first version.
Regards,
Benoit
Quoted 24 lines · Benoit Parrot
Quoted 15 lines
Quoted 15 lines
drivers/gpio/gpiolib-of.c +15
-0+ } + +if (tmp >MAX_PHANDLE_ARGS ) { + desc =ERR_PTR (-EINVAL ); + goto out; + } + + gg_data.gpiospec.args_count = tmp; + gg_data.gpiospec.np = chip_np; +for (i =0 ; i < tmp; i++) { + ret =of_property_read_u32 (np,"gpios" , + &gg_data.gpiospec.args[i]); +if (ret) { + desc =ERR_PTR (ret); + goto out;Quoted 8 lines
drivers/gpio/gpiolib-of.c int of_get_named_gpio_flags(struct device_node *np, const char *list_name, · line 182
Quoted 4 lines
drivers/gpio/gpiolib-of.c +4
-0+ } + } + +gpiochip_find (&gg_data, of_gpiochip_find_and_xlate);This seems to work but only supports one GPIO per hog node. It would be nice to be able to specify several GPIOs to which the same settings need to be applied.
Quoted 1 line
This is on purpose following Linus Walleij's comment.
Could you point me to his comment? My bad for not remembering what he said, but I'd like to understand why.
Quoted 5 lines
Quoted 4 lines
Using this function means that a GPIO chip module cannot be unloaded if it uses GPIO hogs. Is it the intended behavior? If not, please use
gpiochip_request_own_desc()instead, and make sure to callgpiochip_free_own_desc()for each hog when the driver is unloaded.
Quoted 7 lines
So I guess we could add a
undo_gpio_hog()function and hook it up underof_gpiochip_remove(). Now instead of maintaining a seperate structure just to keep track of hogged descriptor, would it be acceptable to add a new "gpio_desc.flags" value ingpiolib.hsays:#define FLAG_GPIO_IS_HOGGED 10And key on that at removal time instead of creating a list and having to maintain that?
Definitely, that would be even better I think.
Quoted 6 lines
Quoted 3 lines
I would suggest to factorize this code that is similar to the one found in
__gpiod_get_index(). Do all the DT parsing in a function that just returns a descriptor and theI would tend to agree.
But as Linus suggested I was trying to contain the changes togpiolib_of.conly.
If we add a FLAG_GPIO_IS_HOGGED and undo the hogs when the chip is unloaded, I would say that this becomes a gpiolib feature. Moving it here would also allow non-DT GPIO providers to implement hogs (it should be particularly easy to implement for platform data). Linus, do you agree?
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 25 lines · Alexandre Courbot
Quoted 24 lines · Benoit Parrot
Quoted 23 lines
Quoted 9 lines
drivers/gpio/gpiolib-of.c +9
-0+ } + +if (tmp >MAX_PHANDLE_ARGS ) { + desc =ERR_PTR (-EINVAL ); + goto out; + } + + gg_data.gpiospec.args_count = tmp; + gg_data.gpiospec.np = chip_np;drivers/gpio/gpiolib-of.c int of_get_named_gpio_flags(struct device_node *np, const char *list_name, · line 182
Quoted 10 lines
drivers/gpio/gpiolib-of.c +10
-0+for (i =0 ; i < tmp; i++) { + ret =of_property_read_u32 (np,"gpios" , + &gg_data.gpiospec.args[i]); +if (ret) { + desc =ERR_PTR (ret); + goto out; + } + } + +gpiochip_find (&gg_data, of_gpiochip_find_and_xlate);This seems to work but only supports one GPIO per hog node. It would be nice to be able to specify several GPIOs to which the same settings need to be applied.
Quoted 4 lines
Quoted 1 line
This is on purpose following Linus Walleij's comment.
Could you point me to his comment? My bad for not remembering what he said, but I'd like to understand why.
Said in previous message I think: either one-per-node or lists directly in the gpiochip node.
Quoted 9 lines
Quoted 9 lines
Quoted 4 lines
Using this function means that a GPIO chip module cannot be unloaded if it uses GPIO hogs. Is it the intended behavior? If not, please use
gpiochip_request_own_desc()instead, and make sure to callgpiochip_free_own_desc()for each hog when the driver is unloaded.So I guess we could add a
undo_gpio_hog()function and hook it up underof_gpiochip_remove(). Now instead of maintaining a seperate structure just to keep track of hogged descriptor, would it be acceptable to add a new "gpio_desc.flags" value ingpiolib.hsays:
Quoted 5 lines
Quoted 3 lines
#define FLAG_GPIO_IS_HOGGED 10And key on that at removal time instead of creating a list and having to maintain that?
Definitely, that would be even better I think.
Clever. Go for this.
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines
I would suggest to factorize this code that is similar to the one found in
__gpiod_get_index(). Do all the DT parsing in a function that just returns a descriptor and the
Quoted 8 lines
Quoted 2 lines
I would tend to agree.
But as Linus suggested I was trying to contain the changes togpiolib_of.conly.If we add a
FLAG_GPIO_IS_HOGGEDand undo the hogs when the chip is unloaded, I would say that this becomes a gpiolib feature. Moving it here would also allow non-DT GPIO providers to implement hogs (it should be particularly easy to implement for platform data). Linus, do you agree?
Yes, this is better and leaves the door open for other users.
Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Quoted 27 lines · Benoit Parrot
Alexandre Courbot <[email protected]> wrote on Fri [2014-Nov-28 16:30:01 +0900]:
Quoted 17 lines · Benoit Parrot
Quoted 16 lines
drivers/gpio/gpiolib-of.c +15
-0+ } + +if (tmp >MAX_PHANDLE_ARGS ) { + desc =ERR_PTR (-EINVAL ); + goto out; + } + + gg_data.gpiospec.args_count = tmp; + gg_data.gpiospec.np = chip_np; +for (i =0 ; i < tmp; i++) { + ret =of_property_read_u32 (np,"gpios" , + &gg_data.gpiospec.args[i]); +if (ret) { + desc =ERR_PTR (ret); + goto out;Quoted 8 lines
drivers/gpio/gpiolib-of.c int of_get_named_gpio_flags(struct device_node *np, const char *list_name, · line 182
Quoted 4 lines
drivers/gpio/gpiolib-of.c +4
-0+ } + } + +gpiochip_find (&gg_data, of_gpiochip_find_and_xlate);This seems to work but only supports one GPIO per hog node. It would be nice to be able to specify several GPIOs to which the same settings need to be applied.
Quoted 1 line
This is on purpose following Linus Walleij's comment.
Yes, I think either we have separate nodes for each hogged line *OR* we just put a list of hogs under the gpiochip, no special node at all.
The one-node-per-hog pattern has the upside of being usable to also name the hogs. (Exporting them is dubious however! I would add a special type of node for that.)
Quoted 35 lines
Quoted 26 lines
Quoted 26 lines
drivers/gpio/gpiolib-of.c +26
-0+if (err <0 ) +return err; + +if (lflags &GPIO_ACTIVE_LOW ) +set_bit (FLAG_ACTIVE_LOW , &desc->flags); +if (lflags &GPIO_OPEN_DRAIN ) +set_bit (FLAG_OPEN_DRAIN , &desc->flags); +if (lflags &GPIO_OPEN_SOURCE ) +set_bit (FLAG_OPEN_SOURCE , &desc->flags); + +/* No particular flag request, not really hogging then... */ +if (!(dflags &GPIOD_FLAGS_BIT_DIR_SET )) { +pr_warn ("%s: GPIO %s: no hogging direction specified, bailing out\n" , + __func__, name); + err = -EINVAL ; + goto free_gpio; + } + +/* Process flags */ +if (dflags &GPIOD_FLAGS_BIT_DIR_OUT ) + err =gpiod_direction_output (desc, + dflags &GPIOD_FLAGS_BIT_DIR_VAL ); +else + err =gpiod_direction_input (desc); + +if (err <0 ) {Quoted 8 lines
drivers/gpio/gpiolib-of.c int of_get_named_gpio_flags(struct device_node *np, const char *list_name, · line 277
Quoted 4 lines
drivers/gpio/gpiolib-of.c +4
-0+pr_warn ("%s: GPIO %s setting direction/value failed\n" , + __func__, name); + goto free_gpio; + }I would suggest to factorize this code that is similar to the one found in
__gpiod_get_index(). Do all the DT parsing in a function that just returns a descriptor and the
Quoted 2 lines
I would tend to agree.
But as Linus suggested I was trying to contain the changes togpiolib_of.conly.
Yes I prefer we begin by supporting it in OF and then generalize it later if more users (board files, ACPI) appear.
Not a big deal but I want to avoid big design up front unless it's easy and a few alterations.
http://c2.com/cgi/wiki?BigDesignUpFront
Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
PATCH v2 2/2 gpio: Document GPIO hogging mechanism
In reply to Benoit ParrotAdd GPIO hogging documentation to gpio.txt
---
Changes since v1:
* Split the devicetree bindings documentation in its own patch.
Documentation/devicetree/bindings/gpio/gpio.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
Documentation/devicetree/bindings/gpio/gpio.txt +25 -0
@@ -103,6 +103,24 @@ Every GPIO controller node must contain both an empty "gpio-controller" property, and a #gpio-cells integer property, which indicates the number of cells in a gpio-specifier. +The GPIO chip may contain GPIO hog definitions. GPIO hogging is a mechanism +providing automatic GPIO request and configuration as part of the +gpio-controller's driver probe function. + +Each GPIO hog definition is represented as a child node of the GPIO controller. +Required properties: +- gpio-hog: a property specifying that this child node represent a gpio-hog. +- gpios: store the gpio information (id, flags, ...). Shall contain the + number of cells specified in its parent node (GPIO controller node). +- input: a property specifying to set the GPIO direction as input. +- output-high: a property specifying to set the GPIO direction to output with + the value high. +- output-low: a property specifying to set the GPIO direction to output with + the value low. + +Optional properties: +- line-name: the GPIO label name. If not present the node name is used. + Example of two SOC GPIO banks defined as gpio-controller nodes: qe_pio_a: gpio-controller@1400 {
@@ -110,6 +128,13 @@ Example of two SOC GPIO banks defined as gpio-controller nodes: reg = <0x1400 0x18>; gpio-controller; #gpio-cells = <2>; + + line_b: line_b { + gpio-hog; + gpios = <6 0>; + output-low; + line-name = "foo-bar-gpio"; + }; }; qe_pio_e: gpio-controller@1460 {
Signature · 1 line
1.8.5.1
Re: [Patch v2 2/2] gpio: Document GPIO hogging mechanism
Quoted 40 lines · Benoit Parrot
Add GPIO hogging documentation to gpio.txt
Signed-off-by Benoit Parrot <[email protected]>---
Changes since v1:
* Split the devicetree bindings documentation in its own patch.Documentation/devicetree/bindings/gpio/gpio.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)Documentation/devicetree/bindings/gpio/gpio.txt +18
-0@@ -103,6 +103,24 @@ Every GPIO controller node must contain both an empty "gpio-controller" property, and a #gpio-cells integer property, which indicates the number of cells in a gpio-specifier. +The GPIO chip may contain GPIO hog definitions. GPIO hogging is a mechanism +providing automatic GPIO request and configuration as part of the +gpio-controller's driver probe function. + +Each GPIO hog definition is represented as a child node of the GPIO controller. +Required properties: +- gpio-hog: a property specifying that this child node represent a gpio-hog. +- gpios: store the gpio information (id, flags, ...). Shall contain the + number of cells specified in its parent node (GPIO controller node). +- input: a property specifying to set the GPIO direction as input. +- output-high: a property specifying to set the GPIO direction to output with + the value high. +- output-low: a property specifying to set the GPIO direction to output with + the value low. + +Optional properties: +- line-name: the GPIO label name. If not present the node name is used. + Example of two SOC GPIO banks defined as gpio-controller nodes: qe_pio_a: gpio-controller@1400 {
Documentation/devicetree/bindings/gpio/gpio.txt Example of two SOC GPIO banks defined as gpio-controller nodes: · line 132
Quoted 5 lines
Documentation/devicetree/bindings/gpio/gpio.txt +2
-0@@ -110,6 +128,13 @@ Example of two SOC GPIO banks defined as gpio-controller nodes: reg = <0x1400 0x18>; gpio-controller; #gpio-cells = <2>; + + line_b: line_b {
Mmm what is the label used for? Can this node ever be referenced from somewhere else?
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in the body of a message to [email protected] More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [Patch v2 2/2] gpio: Document GPIO hogging mechanism
Alexandre Courbot <[email protected]> wrote on Fri [2014-Nov-28 16:31:19 +0900]:
Quoted 39 lines · Benoit Parrot
Quoted 38 lines
Add GPIO hogging documentation to gpio.txt
Signed-off-by Benoit Parrot <[email protected]>---
Changes since v1:
* Split the devicetree bindings documentation in its own patch.Documentation/devicetree/bindings/gpio/gpio.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)Documentation/devicetree/bindings/gpio/gpio.txt +18
-0@@ -103,6 +103,24 @@ Every GPIO controller node must contain both an empty "gpio-controller" property, and a #gpio-cells integer property, which indicates the number of cells in a gpio-specifier. +The GPIO chip may contain GPIO hog definitions. GPIO hogging is a mechanism +providing automatic GPIO request and configuration as part of the +gpio-controller's driver probe function. + +Each GPIO hog definition is represented as a child node of the GPIO controller. +Required properties: +- gpio-hog: a property specifying that this child node represent a gpio-hog. +- gpios: store the gpio information (id, flags, ...). Shall contain the + number of cells specified in its parent node (GPIO controller node). +- input: a property specifying to set the GPIO direction as input. +- output-high: a property specifying to set the GPIO direction to output with + the value high. +- output-low: a property specifying to set the GPIO direction to output with + the value low. + +Optional properties: +- line-name: the GPIO label name. If not present the node name is used. + Example of two SOC GPIO banks defined as gpio-controller nodes:
Quoted 10 lines
Documentation/devicetree/bindings/gpio/gpio.txt Example of two SOC GPIO banks defined as gpio-controller nodes: · line 132
Quoted 7 lines
Documentation/devicetree/bindings/gpio/gpio.txt +2
-0qe_pio_a: gpio-controller@1400 {@@ -110,6 +128,13 @@ Example of two SOC GPIO banks defined as gpio-controller nodes: reg = <0x1400 0x18>; gpio-controller; #gpio-cells = <2>; + + line_b: line_b {Mmm what is the label used for? Can this node ever be referenced from somewhere else?
It's not used for anything else as far as I know other than as the line-name to be assigned to the gpio being hogged. I guess you agree with Linus and should make the line-name mandatory and remove the label altogether?
I was trying to keep the verbosity to a minimum so as to have the possibilty to keep everything on a single line when possible.
Benoit
Re: [Patch v2 2/2] gpio: Document GPIO hogging mechanism
Quoted 51 lines · Benoit Parrot
Alexandre Courbot <[email protected]> wrote on Fri [2014-Nov-28 16:31:19 +0900]:
Quoted 39 lines · Benoit Parrot
Quoted 38 lines
Add GPIO hogging documentation to gpio.txt
Signed-off-by Benoit Parrot <[email protected]>---
Changes since v1:
* Split the devicetree bindings documentation in its own patch.Documentation/devicetree/bindings/gpio/gpio.txt | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)Documentation/devicetree/bindings/gpio/gpio.txt +18
-0@@ -103,6 +103,24 @@ Every GPIO controller node must contain both an empty "gpio-controller" property, and a #gpio-cells integer property, which indicates the number of cells in a gpio-specifier. +The GPIO chip may contain GPIO hog definitions. GPIO hogging is a mechanism +providing automatic GPIO request and configuration as part of the +gpio-controller's driver probe function. + +Each GPIO hog definition is represented as a child node of the GPIO controller. +Required properties: +- gpio-hog: a property specifying that this child node represent a gpio-hog. +- gpios: store the gpio information (id, flags, ...). Shall contain the + number of cells specified in its parent node (GPIO controller node). +- input: a property specifying to set the GPIO direction as input. +- output-high: a property specifying to set the GPIO direction to output with + the value high. +- output-low: a property specifying to set the GPIO direction to output with + the value low. + +Optional properties: +- line-name: the GPIO label name. If not present the node name is used. + Example of two SOC GPIO banks defined as gpio-controller nodes:Quoted 10 lines
Documentation/devicetree/bindings/gpio/gpio.txt Example of two SOC GPIO banks defined as gpio-controller nodes: · line 132
Quoted 7 lines
Documentation/devicetree/bindings/gpio/gpio.txt +2
-0qe_pio_a: gpio-controller@1400 {@@ -110,6 +128,13 @@ Example of two SOC GPIO banks defined as gpio-controller nodes: reg = <0x1400 0x18>; gpio-controller; #gpio-cells = <2>; + + line_b: line_b {Mmm what is the label used for? Can this node ever be referenced from somewhere else?
Quoted 4 lines
It's not used for anything else as far as I know other than as the line-name to be assigned to the gpio being hogged. I guess you agree with Linus and should make the line-name mandatory and remove the label altogether?
I was trying to keep the verbosity to a minimum so as to have the possibilty to keep everything on a single line when possible.
It's just that when you see a label, you expect it to be referenced somewhere, which is obviously not the case here. Just having
line_b {
would work just as well, wouldn't it?