2018-08-17 23:49:18

by Justin Chen

[permalink] [raw]
Subject: [PATCH v2] gpio: brcmstb: allow 0 width GPIO banks

From: Justin Chen <[email protected]>

Sometimes we have empty banks within the GPIO block. This commit allows
proper handling of 0 width GPIO banks. We handle 0 width GPIO banks by
incrementing the bank and number of GPIOs, but not initializing them.
This will mean a call into the non-existent GPIOs will return an error.

Also remove "GPIO registered" dev print. This information is misleading
since the incremented banks and gpio_base do not reflect the actual GPIOs
that get initialized. We leave this information out since it is already
printed with dev_dbg.

Signed-off-by: Justin Chen <[email protected]>
---
drivers/gpio/gpio-brcmstb.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)

diff --git a/drivers/gpio/gpio-brcmstb.c b/drivers/gpio/gpio-brcmstb.c
index 16c7f9f..af936dc 100644
--- a/drivers/gpio/gpio-brcmstb.c
+++ b/drivers/gpio/gpio-brcmstb.c
@@ -664,6 +664,18 @@ static int brcmstb_gpio_probe(struct platform_device *pdev)
struct brcmstb_gpio_bank *bank;
struct gpio_chip *gc;

+ /*
+ * If bank_width is 0, then there is an empty bank in the
+ * register block. Special handling for this case.
+ */
+ if (bank_width == 0) {
+ dev_dbg(dev, "Width 0 found: Empty bank @ %d\n",
+ num_banks);
+ num_banks++;
+ gpio_base += MAX_GPIO_PER_BANK;
+ continue;
+ }
+
bank = devm_kzalloc(dev, sizeof(*bank), GFP_KERNEL);
if (!bank) {
err = -ENOMEM;
@@ -740,9 +752,6 @@ static int brcmstb_gpio_probe(struct platform_device *pdev)
goto fail;
}

- dev_info(dev, "Registered %d banks (GPIO(s): %d-%d)\n",
- num_banks, priv->gpio_base, gpio_base - 1);
-
if (priv->parent_wake_irq && need_wakeup_event)
pm_wakeup_event(dev, 0);

--
2.7.4



2018-08-17 23:50:34

by Florian Fainelli

[permalink] [raw]
Subject: Re: [PATCH v2] gpio: brcmstb: allow 0 width GPIO banks

On 08/17/2018 04:47 PM, [email protected] wrote:
> From: Justin Chen <[email protected]>
>
> Sometimes we have empty banks within the GPIO block. This commit allows
> proper handling of 0 width GPIO banks. We handle 0 width GPIO banks by
> incrementing the bank and number of GPIOs, but not initializing them.
> This will mean a call into the non-existent GPIOs will return an error.
>
> Also remove "GPIO registered" dev print. This information is misleading
> since the incremented banks and gpio_base do not reflect the actual GPIOs
> that get initialized. We leave this information out since it is already
> printed with dev_dbg.
>
> Signed-off-by: Justin Chen <[email protected]>

Acked-by: Florian Fainelli <[email protected]>

Thanks Justin!
--
Florian

2018-08-18 00:53:40

by Andrew Lunn

[permalink] [raw]
Subject: Re: [PATCH v2] gpio: brcmstb: allow 0 width GPIO banks

On Fri, Aug 17, 2018 at 04:47:39PM -0700, [email protected] wrote:
> From: Justin Chen <[email protected]>
>
> Sometimes we have empty banks within the GPIO block. This commit allows
> proper handling of 0 width GPIO banks.

Hi Justin

This is coming from DT? Why do you put 0 width banks in DT in the
first place?

Andrew

2018-08-20 21:10:01

by Florian Fainelli

[permalink] [raw]
Subject: Re: [PATCH v2] gpio: brcmstb: allow 0 width GPIO banks

On 08/17/2018 05:52 PM, Andrew Lunn wrote:
> On Fri, Aug 17, 2018 at 04:47:39PM -0700, [email protected] wrote:
>> From: Justin Chen <[email protected]>
>>
>> Sometimes we have empty banks within the GPIO block. This commit allows
>> proper handling of 0 width GPIO banks.
>
> Hi Justin
>
> This is coming from DT? Why do you put 0 width banks in DT in the
> first place?

The way the binding is defined, the "reg" property must cover the entire
GPIO block. On our chips we typically have two blocks, one called GIO
and one called AON_GIO. One of our chips, BCM7429 unfortunately does not
have contiguous banks (groups of 32 GPIOs) within the GIO register
range, it has a first bank from 0 -> 0x20, then nothing, then another
one from 0x40 -> 0x60, which is why this change was proposed, since it
does not break any existing DT blob.
--
Florian

2018-08-30 09:07:20

by Linus Walleij

[permalink] [raw]
Subject: Re: [PATCH v2] gpio: brcmstb: allow 0 width GPIO banks

On Sat, Aug 18, 2018 at 1:47 AM <[email protected]> wrote:

> From: Justin Chen <[email protected]>
>
> Sometimes we have empty banks within the GPIO block. This commit allows
> proper handling of 0 width GPIO banks. We handle 0 width GPIO banks by
> incrementing the bank and number of GPIOs, but not initializing them.
> This will mean a call into the non-existent GPIOs will return an error.
>
> Also remove "GPIO registered" dev print. This information is misleading
> since the incremented banks and gpio_base do not reflect the actual GPIOs
> that get initialized. We leave this information out since it is already
> printed with dev_dbg.
>
> Signed-off-by: Justin Chen <[email protected]>

Patch applied with Florian's ACK.

Yours,
Linus Walleij

2018-08-31 21:27:50

by Gregory Fong

[permalink] [raw]
Subject: Re: [PATCH v2] gpio: brcmstb: allow 0 width GPIO banks

On Fri, Aug 17, 2018 at 4:48 PM <[email protected]> wrote:
>
> From: Justin Chen <[email protected]>
>
> Sometimes we have empty banks within the GPIO block. This commit allows
> proper handling of 0 width GPIO banks. We handle 0 width GPIO banks by
> incrementing the bank and number of GPIOs, but not initializing them.
> This will mean a call into the non-existent GPIOs will return an error.

This is clearer now; thanks for rewording!

>
> Also remove "GPIO registered" dev print. This information is misleading
> since the incremented banks and gpio_base do not reflect the actual GPIOs
> that get initialized. We leave this information out since it is already
> printed with dev_dbg.
>
> Signed-off-by: Justin Chen <[email protected]>

Looks like I'm a bit late on the response, but in case you feel like
adding it Linus:

Acked-by: Gregory Fong <[email protected]>