diff mbox series

[U-Boot,v2019.04-aspeed-openbmc,4/6] gpio: Enable hogging support in SPL

Message ID 20220124191503.88452-5-eajames@linux.ibm.com
State New
Headers show
Series Add GPIO hog support | expand

Commit Message

Eddie James Jan. 24, 2022, 7:15 p.m. UTC
Use the CONFIG macros to conditionally build the GPIO hogging support in
either the SPL or U-Boot, or both, depending on the configuration. Also
call the GPIO hog probe function in the common SPL board initialization
as an equivalent to adding it to the U-Boot init sequence functions.

Signed-off-by: Eddie James <eajames@linux.ibm.com>
---
 common/spl/spl.c           |  7 +++++++
 drivers/gpio/Kconfig       | 10 ++++++++++
 drivers/gpio/gpio-uclass.c | 12 +++++++-----
 3 files changed, 24 insertions(+), 5 deletions(-)

Comments

Andrew Jeffery Feb. 3, 2022, 2:11 a.m. UTC | #1
On Tue, 25 Jan 2022, at 05:45, Eddie James wrote:
> Use the CONFIG macros to conditionally build the GPIO hogging support in
> either the SPL or U-Boot, or both, depending on the configuration. Also
> call the GPIO hog probe function in the common SPL board initialization
> as an equivalent to adding it to the U-Boot init sequence functions.
>
> Signed-off-by: Eddie James <eajames@linux.ibm.com>
> ---
>  common/spl/spl.c           |  7 +++++++
>  drivers/gpio/Kconfig       | 10 ++++++++++
>  drivers/gpio/gpio-uclass.c | 12 +++++++-----
>  3 files changed, 24 insertions(+), 5 deletions(-)
>
> diff --git a/common/spl/spl.c b/common/spl/spl.c
> index a1d4514fd3..bbb7578463 100644
> --- a/common/spl/spl.c
> +++ b/common/spl/spl.c
> @@ -12,6 +12,9 @@
>  #include <dm.h>
>  #include <handoff.h>
>  #include <spl.h>
> +#if defined(CONFIG_SPL_GPIO_HOG)
> +#include <asm/gpio.h>
> +#endif
>  #include <asm/sections.h>
>  #include <asm/u-boot.h>
>  #include <nand.h>
> @@ -652,6 +655,10 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
>  	timer_init();
>  #endif
> 
> +#if defined(CONFIG_SPL_GPIO_HOG)
> +	gpio_hog_probe_all();
> +#endif
> +
>  #if CONFIG_IS_ENABLED(BOARD_INIT)
>  	spl_board_init();
>  #endif
> diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
> index a8dc16ca0e..8b8bf6822f 100644
> --- a/drivers/gpio/Kconfig
> +++ b/drivers/gpio/Kconfig
> @@ -24,6 +24,16 @@ config GPIO_HOG
>  	  is a mechanism providing automatic GPIO request and config-
>  	  uration as part of the gpio-controller's driver probe function.
> 
> +config SPL_GPIO_HOG
> +	bool "Enable GPIO hog support in SPL"
> +	depends on SPL_GPIO_SUPPORT
> +	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
> diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
> index 01cfa2f788..219caa651b 100644
> --- a/drivers/gpio/gpio-uclass.c
> +++ b/drivers/gpio/gpio-uclass.c
> @@ -144,7 +144,7 @@ static int gpio_find_and_xlate(struct gpio_desc *desc,
>  		return gpio_xlate_offs_flags(desc->dev, desc, args);
>  }
> 
> -#if defined(CONFIG_GPIO_HOG)
> +#if CONFIG_IS_ENABLED(GPIO_HOG)
> 
>  struct gpio_hog_priv {
>  	struct gpio_desc gpiod;
> @@ -1033,9 +1033,6 @@ int gpio_dev_request_index(struct udevice *dev, 
> const char *nodename,
> 
>  static int gpio_post_bind(struct udevice *dev)
>  {
> -	struct udevice *child;
> -	ofnode node;
> -
>  #if defined(CONFIG_NEEDS_MANUAL_RELOC)
>  	struct dm_gpio_ops *ops = (struct dm_gpio_ops *)device_get_ops(dev);
>  	static int reloc_done;
> @@ -1066,7 +1063,11 @@ static int gpio_post_bind(struct udevice *dev)
>  	}
>  #endif
> 
> -	if (IS_ENABLED(CONFIG_GPIO_HOG)) {
> +#if CONFIG_IS_ENABLED(GPIO_HOG)

Why switch to a CPP conditional here?

I mean, it's not clear why there was a choice for a C conditional 
originally, so I'm curious either way.

Otherwise:

Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
Eddie James Feb. 3, 2022, 3:47 p.m. UTC | #2
On 2/2/22 20:11, Andrew Jeffery wrote:
>
> On Tue, 25 Jan 2022, at 05:45, Eddie James wrote:
>> Use the CONFIG macros to conditionally build the GPIO hogging support in
>> either the SPL or U-Boot, or both, depending on the configuration. Also
>> call the GPIO hog probe function in the common SPL board initialization
>> as an equivalent to adding it to the U-Boot init sequence functions.
>>
>> Signed-off-by: Eddie James <eajames@linux.ibm.com>
>> ---
>>   common/spl/spl.c           |  7 +++++++
>>   drivers/gpio/Kconfig       | 10 ++++++++++
>>   drivers/gpio/gpio-uclass.c | 12 +++++++-----
>>   3 files changed, 24 insertions(+), 5 deletions(-)
>>
>> diff --git a/common/spl/spl.c b/common/spl/spl.c
>> index a1d4514fd3..bbb7578463 100644
>> --- a/common/spl/spl.c
>> +++ b/common/spl/spl.c
>> @@ -12,6 +12,9 @@
>>   #include <dm.h>
>>   #include <handoff.h>
>>   #include <spl.h>
>> +#if defined(CONFIG_SPL_GPIO_HOG)
>> +#include <asm/gpio.h>
>> +#endif
>>   #include <asm/sections.h>
>>   #include <asm/u-boot.h>
>>   #include <nand.h>
>> @@ -652,6 +655,10 @@ void board_init_r(gd_t *dummy1, ulong dummy2)
>>   	timer_init();
>>   #endif
>>
>> +#if defined(CONFIG_SPL_GPIO_HOG)
>> +	gpio_hog_probe_all();
>> +#endif
>> +
>>   #if CONFIG_IS_ENABLED(BOARD_INIT)
>>   	spl_board_init();
>>   #endif
>> diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
>> index a8dc16ca0e..8b8bf6822f 100644
>> --- a/drivers/gpio/Kconfig
>> +++ b/drivers/gpio/Kconfig
>> @@ -24,6 +24,16 @@ config GPIO_HOG
>>   	  is a mechanism providing automatic GPIO request and config-
>>   	  uration as part of the gpio-controller's driver probe function.
>>
>> +config SPL_GPIO_HOG
>> +	bool "Enable GPIO hog support in SPL"
>> +	depends on SPL_GPIO_SUPPORT
>> +	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
>> diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
>> index 01cfa2f788..219caa651b 100644
>> --- a/drivers/gpio/gpio-uclass.c
>> +++ b/drivers/gpio/gpio-uclass.c
>> @@ -144,7 +144,7 @@ static int gpio_find_and_xlate(struct gpio_desc *desc,
>>   		return gpio_xlate_offs_flags(desc->dev, desc, args);
>>   }
>>
>> -#if defined(CONFIG_GPIO_HOG)
>> +#if CONFIG_IS_ENABLED(GPIO_HOG)
>>
>>   struct gpio_hog_priv {
>>   	struct gpio_desc gpiod;
>> @@ -1033,9 +1033,6 @@ int gpio_dev_request_index(struct udevice *dev,
>> const char *nodename,
>>
>>   static int gpio_post_bind(struct udevice *dev)
>>   {
>> -	struct udevice *child;
>> -	ofnode node;
>> -
>>   #if defined(CONFIG_NEEDS_MANUAL_RELOC)
>>   	struct dm_gpio_ops *ops = (struct dm_gpio_ops *)device_get_ops(dev);
>>   	static int reloc_done;
>> @@ -1066,7 +1063,11 @@ static int gpio_post_bind(struct udevice *dev)
>>   	}
>>   #endif
>>
>> -	if (IS_ENABLED(CONFIG_GPIO_HOG)) {
>> +#if CONFIG_IS_ENABLED(GPIO_HOG)
> Why switch to a CPP conditional here?
>
> I mean, it's not clear why there was a choice for a C conditional
> originally, so I'm curious either way.


Well I just thought it should match the other conditionals for GPIO_HOG, 
and it's obviously more efficient at runtime. Other than that, no reason 
really.


Thanks!

Eddie


>
> Otherwise:
>
> Reviewed-by: Andrew Jeffery <andrew@aj.id.au>
Andrew Jeffery Feb. 3, 2022, 9:43 p.m. UTC | #3
On Fri, 4 Feb 2022, at 02:17, Eddie James wrote:
> On 2/2/22 20:11, Andrew Jeffery wrote:
>>
>> On Tue, 25 Jan 2022, at 05:45, Eddie James wrote:
>>> -	if (IS_ENABLED(CONFIG_GPIO_HOG)) {
>>> +#if CONFIG_IS_ENABLED(GPIO_HOG)
>> Why switch to a CPP conditional here?
>>
>> I mean, it's not clear why there was a choice for a C conditional
>> originally, so I'm curious either way.
>
>
> Well I just thought it should match the other conditionals for GPIO_HOG, 
> and it's obviously more efficient at runtime. Other than that, no reason 
> really.

Well, I expect it will be optimised out in the C case anyway.

Doesn't matter too much.

Andrew
diff mbox series

Patch

diff --git a/common/spl/spl.c b/common/spl/spl.c
index a1d4514fd3..bbb7578463 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -12,6 +12,9 @@ 
 #include <dm.h>
 #include <handoff.h>
 #include <spl.h>
+#if defined(CONFIG_SPL_GPIO_HOG)
+#include <asm/gpio.h>
+#endif
 #include <asm/sections.h>
 #include <asm/u-boot.h>
 #include <nand.h>
@@ -652,6 +655,10 @@  void board_init_r(gd_t *dummy1, ulong dummy2)
 	timer_init();
 #endif
 
+#if defined(CONFIG_SPL_GPIO_HOG)
+	gpio_hog_probe_all();
+#endif
+
 #if CONFIG_IS_ENABLED(BOARD_INIT)
 	spl_board_init();
 #endif
diff --git a/drivers/gpio/Kconfig b/drivers/gpio/Kconfig
index a8dc16ca0e..8b8bf6822f 100644
--- a/drivers/gpio/Kconfig
+++ b/drivers/gpio/Kconfig
@@ -24,6 +24,16 @@  config GPIO_HOG
 	  is a mechanism providing automatic GPIO request and config-
 	  uration as part of the gpio-controller's driver probe function.
 
+config SPL_GPIO_HOG
+	bool "Enable GPIO hog support in SPL"
+	depends on SPL_GPIO_SUPPORT
+	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
diff --git a/drivers/gpio/gpio-uclass.c b/drivers/gpio/gpio-uclass.c
index 01cfa2f788..219caa651b 100644
--- a/drivers/gpio/gpio-uclass.c
+++ b/drivers/gpio/gpio-uclass.c
@@ -144,7 +144,7 @@  static int gpio_find_and_xlate(struct gpio_desc *desc,
 		return gpio_xlate_offs_flags(desc->dev, desc, args);
 }
 
-#if defined(CONFIG_GPIO_HOG)
+#if CONFIG_IS_ENABLED(GPIO_HOG)
 
 struct gpio_hog_priv {
 	struct gpio_desc gpiod;
@@ -1033,9 +1033,6 @@  int gpio_dev_request_index(struct udevice *dev, const char *nodename,
 
 static int gpio_post_bind(struct udevice *dev)
 {
-	struct udevice *child;
-	ofnode node;
-
 #if defined(CONFIG_NEEDS_MANUAL_RELOC)
 	struct dm_gpio_ops *ops = (struct dm_gpio_ops *)device_get_ops(dev);
 	static int reloc_done;
@@ -1066,7 +1063,11 @@  static int gpio_post_bind(struct udevice *dev)
 	}
 #endif
 
-	if (IS_ENABLED(CONFIG_GPIO_HOG)) {
+#if CONFIG_IS_ENABLED(GPIO_HOG)
+	{
+		struct udevice *child;
+		ofnode node;
+
 		dev_for_each_subnode(node, dev) {
 			if (ofnode_read_bool(node, "gpio-hog")) {
 				const char *name = ofnode_get_name(node);
@@ -1081,6 +1082,7 @@  static int gpio_post_bind(struct udevice *dev)
 			}
 		}
 	}
+#endif
 	return 0;
 }