gpio: add gpio-hog support
Subsystems (2)
PATCH v2 1/1 gpio: add gpio-hog support
add gpio-hog support. GPIO hogging is a mechanism providing automatic GPIO request and configuration as part of the gpio-controller's driver probe function.
for more infos see:doc/device-tree-bindings/gpio/gpio.txt
---
not yet started clean travis build, see result:
https://travis-ci.org/hsdenx/u-boot-test/builds/537732421
Changes in v2:
- move gpio_hog() call from post_probe() to post_bind() call. Check if current gpio device has gpio-hog definitions, if so, probe it.
doc/device-tree-bindings/gpio/gpio.txt | 52 ++++++++ drivers/gpio/Kconfig | 10 ++ drivers/gpio/gpio-uclass.c | 162 +++++++++++++++++++++++-- include/asm-generic/gpio.h | 24 ++++ 4 files changed, 236 insertions(+), 12 deletions(-)
doc/device-tree-bindings/gpio/gpio.txt +52 -0
@@ -210,3 +210,55 @@ Example 2: Here, three GPIO ranges are defined wrt. two pin controllers. pinctrl1 GPIO ranges are defined using pin numbers whereas the GPIO ranges wrt. pinctrl2 are named "foo" and "bar". + +3) GPIO hog definitions +----------------------- + +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 represents a GPIO hog. +- gpios: Store the GPIO information (id, flags) for the GPIO to + affect. + + ! Not yet support more than one gpio ! + +Only one of the following properties scanned in the order shown below. +- input: A property specifying to set the GPIO direction as input. +- output-low A property specifying to set the GPIO direction as output with + the value low. +- output-high A property specifying to set the GPIO direction as output with + the value high. + +Example: + + tca6416 at 20 { + compatible = "ti,tca6416"; + reg = <0x20>; + #gpio-cells = <2>; + gpio-controller; + + env_reset { + gpio-hog; + input; + gpios = <6 GPIO_ACTIVE_LOW>; + }; + boot_rescue { + gpio-hog; + input; + gpios = <7 GPIO_ACTIVE_LOW>; + }; + }; + +For the above Example you can than access the gpio in your boardcode +with: + + desc = gpio_hog_lookup_name("boot_rescue.gpio-hog"); + if (desc) { + if (dm_gpio_get_value(desc)) + printf("\nBooting into Rescue System\n"); + else + printf("\nBoot normal\n");
drivers/gpio/Kconfig +10 -0
@@ -14,6 +14,16 @@ config DM_GPIO particular GPIOs that they provide. The uclass interface is defined in include/asm-generic/gpio.h. +config DM_GPIO_HOG + bool "Enable GPIO hog support" + depends on DM_GPIO + default n + help + Enable gpio hog support + The GPIO chip may contain GPIO hog definitions. GPIO hogging + is a mechanism providing automatic GPIO request and config- + uration as part of the gpio-controller's driver probe function. + config ALTERA_PIO bool "Altera PIO driver" depends on DM_GPIO
drivers/gpio/gpio-uclass.c +150 -12
222 lines not on this page · raw message
include/asm-generic/gpio.h +24 -0
@@ -348,6 +348,14 @@ const char *gpio_get_bank_info(struct udevice *dev, int *offset_count);*/ int dm_gpio_lookup_name (const char *name,struct gpio_desc *desc); +/** +* gpio_hog_lookup_name() - Look up a named GPIO and return the gpio descr. +* +* @name: Name to look up +* @return: Returns gpio_desc for gpio +*/ +struct gpio_desc *gpio_hog_lookup_name (const char *name); +/** * gpio_lookup_name - Look up a GPIO name and return its details *
@@ -503,6 +511,22 @@ int gpio_request_list_by_name_nodev(ofnode node, const char *list_name, struct gpio_desc *desc_list, int max_count, int flags); +/** +* gpio_dev_request_index() - request single GPIO from gpio device +* +* @dev: GPIO device +* @ofnode: of node wich requests the GPIO +* @list_name: Name of GPIO list (e.g. "board-id-gpios") +* @index: Index number of the GPIO in that list use request (0=first) +* @flags: GPIOD_* flags +* @dtflags: GPIO flags read from DT +* @desc: GPIO descriotor filled from this function +* @return: return value from gpio_request_tail() +*/ +int gpio_dev_request_index (struct udevice *dev,ofnode node,char *list_name, +int index,int flags,int dtflags, +struct gpio_desc *desc); +/** * dm_gpio_free() - Free a single GPIO *
Signature · 1 line
2.21.0
PATCH v2 1/1 gpio: add gpio-hog support
Quoted 9 lines · Heiko Schocher
add gpio-hog support. GPIO hogging is a mechanism providing automatic GPIO request and configuration as part of the gpio-controller's driver probe function.
for more infos see:
doc/device-tree-bindings/gpio/gpio.txtSigned-off-by Heiko Schocher <[email protected]>
Quoted 8 lines
---
not yet started clean travis build, see result:
https://travis-ci.org/hsdenx/u-boot-test/builds/537732421Changes in v2:
- movegpio_hog()call frompost_probe()topost_bind()call. Check if current gpio device has gpio-hog definitions, if so, probe it.
I am using i2c to gpio chip and with v2 this chip is not listed via dm completely. It means something is wrong for sure.
It looks like that parent is not probed that's why it is failing.
Thanks,
Michal
PATCH v2 1/1 gpio: add gpio-hog support
Hello Michal,
Am 27.05.2019 um 13:34 schrieb Michal Simek:
Quoted 14 lines · Heiko Schocher
Quoted 13 lines
add gpio-hog support. GPIO hogging is a mechanism providing automatic GPIO request and configuration as part of the gpio-controller's driver probe function.
for more infos see:
doc/device-tree-bindings/gpio/gpio.txtSigned-off-by Heiko Schocher <[email protected]>---
not yet started clean travis build, see result:
https://travis-ci.org/hsdenx/u-boot-test/builds/537732421
Quoted 7 lines
Quoted 4 lines
Changes in v2:
- movegpio_hog()call frompost_probe()topost_bind()call. Check if current gpio device has gpio-hog definitions, if so, probe it.I am using i2c to gpio chip and with v2 this chip is not listed via dm completely. It means something is wrong for sure.
What do you mean with "this chip is not listed via dm completely" ?
Quoted 1 line
It looks like that parent is not probed that's why it is failing.
I use this on the aristainetos board, work currently on rework for DM/DT usage in U-Boot, dts not yet in u-boot but in linux, see:
and added for u-boot now gpio hog definitons:
&i2c3 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c3>;
status = "okay";
expander: tca6416 at 20 {
compatible = "ti,tca6416";
reg = <0x20>;
#gpio-cells = <2>;
gpio-controller;
env_reset {
gpio-hog;
input;
gpios = <6 GPIO_ACTIVE_LOW>;
};
boot_rescue {
gpio-hog;
input;
gpios = <7 GPIO_ACTIVE_LOW>;
};
};
};works fine for me ...
=> dm tree
Class Index Probed Driver Name
-----------------------------------------------------------
root 0 [ + ] root_driver root_driver
[...]
i2c 2 [ + ] i2c_mxc | | |-- i2c at 21a8000 gpio 7 [ + ] pca953x | | | |-- tca6416 at 20
=> gpio status
[...]
Bank gpio at 20_:
gpio at 20_6: input: 0 [x] env_reset.gpio-hog
gpio at 20_7: input: 1 [x] boot_rescue.gpio-hog
=>
Hmm.. how can I reproduce your problem?
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
PATCH v2 1/1 gpio: add gpio-hog support
Hi,
Quoted 22 lines · Heiko Schocher
Hello Michal,
Am 27.05.2019 um 13:34 schrieb Michal Simek:
Quoted 19 lines · Heiko Schocher
Quoted 17 lines
add gpio-hog support. GPIO hogging is a mechanism providing automatic GPIO request and configuration as part of the gpio-controller's driver probe function.
for more infos see:
doc/device-tree-bindings/gpio/gpio.txtSigned-off-by Heiko Schocher <[email protected]>---
not yet started clean travis build, see result:
https://travis-ci.org/hsdenx/u-boot-test/builds/537732421Changes in v2:
- movegpio_hog()call frompost_probe()topost_bind()call. Check if current gpio device has gpio-hog definitions, if so, probe it.
Quoted 4 lines
Quoted 2 lines
I am using i2c to gpio chip and with v2 this chip is not listed via dm completely. It means something is wrong for sure.
What do you mean with "this chip is not listed via dm completely" ?
first of all I am using zcu102
http://git.denx.de/?p=u-boot.git;a=blob;f=arch/arm/dts/zynqmp-zcu102-revA.dts;h=6e22871713139517ad5f7f1d2e659690233bd946;hb=HEAD#l129
There are 2 i2c-gpio chips @20 and @21. @20 has hogs and it is not listed via dm tree when v2 is applied (v1 is without any issue). @21 is seen there.
Quoted 22 lines
Quoted 2 lines
It looks like that parent is not probed that's why it is failing.
I use this on the aristainetos board, work currently on rework for DM/DT usage in U-Boot, dts not yet in u-boot but in linux, see:
and added for u-boot now gpio hog definitons:
&i2c3 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c3>;
status = "okay";expander: tca6416 at 20 {
compatible = "ti,tca6416";
reg = <0x20>;
#gpio-cells = <2>;
gpio-controller;
Quoted 9 lines
env_reset{
gpio-hog;
input;
gpios = <6GPIO_ACTIVE_LOW>; };
boot_rescue{
gpio-hog;
input;
gpios = <7GPIO_ACTIVE_LOW>;
nit: there could be also line-name setup.
Quoted 3 lines
};
};
};
The setup looks the same as I have here.
Quoted 11 lines
works fine for me ...
=> dm tree
Class Index Probed Driver Name
-----------------------------------------------------------
root 0 [ + ] root_driverroot_driver
[...]
i2c 2 [ + ] i2c_mxc | | |-- i2c at 21a8000 gpio 7 [ + ] pca953x | | | |-- tca6416 at 20
Quoted 8 lines
=> gpio status
[...]
Bank gpio at 20_:
gpio at 20_6: input: 0 [x] env_reset.gpio-hog
gpio at 20_7: input: 1 [x] boot_rescue.gpio-hog
=>Hmm.. how can I reproduce your problem?
Take a look but IIRC you should have zcu102 around too.
Thanks,
Michal
PATCH v2 1/1 gpio: add gpio-hog support
Hello Michal,
Am 27.05.2019 um 14:31 schrieb Michal Simek:
Quoted 28 lines
Hi,
Quoted 25 lines · Heiko Schocher
Hello Michal,
Am 27.05.2019 um 13:34 schrieb Michal Simek:
Quoted 21 lines · Heiko Schocher
Quoted 9 lines
add gpio-hog support. GPIO hogging is a mechanism providing automatic GPIO request and configuration as part of the gpio-controller's driver probe function.
for more infos see:
doc/device-tree-bindings/gpio/gpio.txtSigned-off-by Heiko Schocher <[email protected]>Quoted 8 lines
---
not yet started clean travis build, see result:
https://travis-ci.org/hsdenx/u-boot-test/builds/537732421Changes in v2:
- movegpio_hog()call frompost_probe()topost_bind()call. Check if current gpio device has gpio-hog definitions, if so, probe it.I am using i2c to gpio chip and with v2 this chip is not listed via dm completely. It means something is wrong for sure.
Quoted 8 lines
Quoted 1 line
What do you mean with "this chip is not listed via dm completely" ?
first of all I am using zcu102
http://git.denx.de/?p=u-boot.git;a=blob;f=arch/arm/dts/zynqmp-zcu102-revA.dts;h=6e22871713139517ad5f7f1d2e659690233bd946;hb=HEAD#l129There are 2 i2c-gpio chips @20 and @21. @20 has hogs and it is not listed via dm tree when v2 is applied (v1 is without any issue). @21 is seen there.
Hmm... look like the same setup as mine ...
Quoted 31 lines
Quoted 21 lines
Quoted 1 line
It looks like that parent is not probed that's why it is failing.
I use this on the aristainetos board, work currently on rework for DM/DT usage in U-Boot, dts not yet in u-boot but in linux, see:
and added for u-boot now gpio hog definitons:
&i2c3 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c3>;
status = "okay";expander: tca6416 at 20 {
compatible = "ti,tca6416";
reg = <0x20>;
#gpio-cells = <2>;
gpio-controller;Quoted 9 lines
env_reset{
gpio-hog;
input;
gpios = <6GPIO_ACTIVE_LOW>; };
boot_rescue{
gpio-hog;
input;
gpios = <7GPIO_ACTIVE_LOW>;
Quoted 1 line
nit: there could be also line-name setup.
Ok, I add support for it.
Quoted 5 lines
Quoted 3 lines
};
};
};The setup looks the same as I have here.
Yes.
Quoted 18 lines
Quoted 18 lines
works fine for me ...
=> dm tree
Class Index Probed Driver Name
-----------------------------------------------------------
root 0 [ + ] root_driverroot_driver
[...]
i2c 2 [ + ] i2c_mxc | | |-- i2c at 21a8000 gpio 7 [ + ] pca953x | | | |-- tca6416 at 20=> gpio status
[...]
Bank gpio at 20_:
gpio at 20_6: input: 0 [x] env_reset.gpio-hog
gpio at 20_7: input: 1 [x] boot_rescue.gpio-hog
=>
Quoted 3 lines
Quoted 1 line
Hmm.. how can I reproduce your problem?
Take a look but IIRC you should have zcu102 around too.
Indeed we have one:
$ remote_power -l | grep zcu102 katmai3 off r360 off zcu102 off
I have to look, how I can test without breaking the board... Is there something like a bootmode switch, so I can restore the board if I broke it? (Sorry if dummy question, never worked on the board).
bye,
Heiko
Signature · 3 lines
DENX Software Engineering GmbH, Managing Director: Wolfgang Denk HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-52 Fax: +49-8142-66989-80 Email: hs at denx.de
PATCH v2 1/1 gpio: add gpio-hog support
Quoted 110 lines · Heiko Schocher
Hello Michal,
Am 27.05.2019 um 14:31 schrieb Michal Simek:
Quoted 30 lines
Hi,
Quoted 22 lines · Heiko Schocher
Hello Michal,
Am 27.05.2019 um 13:34 schrieb Michal Simek:
Quoted 19 lines · Heiko Schocher
Quoted 17 lines
add gpio-hog support. GPIO hogging is a mechanism providing automatic GPIO request and configuration as part of the gpio-controller's driver probe function.
for more infos see:
doc/device-tree-bindings/gpio/gpio.txtSigned-off-by Heiko Schocher <[email protected]>---
not yet started clean travis build, see result:
https://travis-ci.org/hsdenx/u-boot-test/builds/537732421Changes in v2:
- movegpio_hog()call frompost_probe()topost_bind()call. Check if current gpio device has gpio-hog definitions, if so, probe it.Quoted 4 lines
Quoted 2 lines
I am using i2c to gpio chip and with v2 this chip is not listed via dm completely. It means something is wrong for sure.
What do you mean with "this chip is not listed via dm completely" ?
Quoted 7 lines
first of all I am using zcu102
http://git.denx.de/?p=u-boot.git;a=blob;f=arch/arm/dts/zynqmp-zcu102-revA.dts;h=6e22871713139517ad5f7f1d2e659690233bd946;hb=HEAD#l129There are 2 i2c-gpio chips @20 and @21. @20 has hogs and it is not listed via dm tree when v2 is applied (v1 is without any issue). @21 is seen there.
Hmm... look like the same setup as mine ...
Quoted 32 lines
Quoted 22 lines
Quoted 1 line
It looks like that parent is not probed that's why it is failing.
I use this on the aristainetos board, work currently on rework for DM/DT usage in U-Boot, dts not yet in u-boot but in linux, see:
and added for u-boot now gpio hog definitons:
&i2c3 {
pinctrl-names = "default";
pinctrl-0 = <&pinctrl_i2c3>;
status = "okay";expander: tca6416 at 20 {
compatible = "ti,tca6416";
reg = <0x20>;
#gpio-cells = <2>;
gpio-controller;Quoted 9 lines
env_reset{
gpio-hog;
input;
gpios = <6GPIO_ACTIVE_LOW>; };
boot_rescue{
gpio-hog;
input;
gpios = <7GPIO_ACTIVE_LOW>;Quoted 1 line
nit: there could be also line-name setup.
Ok, I add support for it.
Quoted 5 lines
Quoted 3 lines
};
};
};The setup looks the same as I have here.
Yes.
Quoted 19 lines
Quoted 19 lines
works fine for me ...
=> dm tree
Class Index Probed Driver Name
-----------------------------------------------------------
root 0 [ + ] root_driverroot_driver[...]
i2c 2 [ + ] i2c_mxc | | |-- i2c at 21a8000 gpio 7 [ + ] pca953x | | | |-- tca6416 at 20=> gpio status
[...]
Bank gpio at 20_:
gpio at 20_6: input: 0 [x] env_reset.gpio-hog
gpio at 20_7: input: 1 [x] boot_rescue.gpio-hog
=>Quoted 3 lines
Quoted 1 line
Hmm.. how can I reproduce your problem?
Take a look but IIRC you should have zcu102 around too.
Quoted 8 lines
Indeed we have one:
$ remote_power -l | grep zcu102 katmai3 off r360 off zcu102 offI have to look, how I can test without breaking the board... Is there something like a bootmode switch, so I can restore the board if I broke it? (Sorry if dummy question, never worked on the board).
yes - there are easy way how to restore the board. Not sure if you use jtag, qspi or sd boot mode.
Thanks,
Michal