1 |
From f76bc05e184d3e04db3c508f6a454a65f4cba61c Mon Sep 17 00:00:00 2001 |
2 |
From: Justin Chen <justinpopo6@gmail.com> |
3 |
Date: Fri, 17 Aug 2018 16:47:39 -0700 |
4 |
Subject: [PATCH 076/145] gpio: brcmstb: allow 0 width GPIO banks |
5 |
|
6 |
[ Upstream commit bfba223dcc4548632d8f3bfd15690a86d4c68504 ] |
7 |
|
8 |
Sometimes we have empty banks within the GPIO block. This commit allows |
9 |
proper handling of 0 width GPIO banks. We handle 0 width GPIO banks by |
10 |
incrementing the bank and number of GPIOs, but not initializing them. |
11 |
This will mean a call into the non-existent GPIOs will return an error. |
12 |
|
13 |
Also remove "GPIO registered" dev print. This information is misleading |
14 |
since the incremented banks and gpio_base do not reflect the actual GPIOs |
15 |
that get initialized. We leave this information out since it is already |
16 |
printed with dev_dbg. |
17 |
|
18 |
Signed-off-by: Justin Chen <justinpopo6@gmail.com> |
19 |
Acked-by: Florian Fainelli <f.fainelli@gmail.com> |
20 |
Signed-off-by: Linus Walleij <linus.walleij@linaro.org> |
21 |
Signed-off-by: Sasha Levin <sashal@kernel.org> |
22 |
--- |
23 |
drivers/gpio/gpio-brcmstb.c | 15 ++++++++++++--- |
24 |
1 file changed, 12 insertions(+), 3 deletions(-) |
25 |
|
26 |
diff --git a/drivers/gpio/gpio-brcmstb.c b/drivers/gpio/gpio-brcmstb.c |
27 |
index 16c7f9f49416..af936dcca659 100644 |
28 |
--- a/drivers/gpio/gpio-brcmstb.c |
29 |
+++ b/drivers/gpio/gpio-brcmstb.c |
30 |
@@ -664,6 +664,18 @@ static int brcmstb_gpio_probe(struct platform_device *pdev) |
31 |
struct brcmstb_gpio_bank *bank; |
32 |
struct gpio_chip *gc; |
33 |
|
34 |
+ /* |
35 |
+ * If bank_width is 0, then there is an empty bank in the |
36 |
+ * register block. Special handling for this case. |
37 |
+ */ |
38 |
+ if (bank_width == 0) { |
39 |
+ dev_dbg(dev, "Width 0 found: Empty bank @ %d\n", |
40 |
+ num_banks); |
41 |
+ num_banks++; |
42 |
+ gpio_base += MAX_GPIO_PER_BANK; |
43 |
+ continue; |
44 |
+ } |
45 |
+ |
46 |
bank = devm_kzalloc(dev, sizeof(*bank), GFP_KERNEL); |
47 |
if (!bank) { |
48 |
err = -ENOMEM; |
49 |
@@ -740,9 +752,6 @@ static int brcmstb_gpio_probe(struct platform_device *pdev) |
50 |
goto fail; |
51 |
} |
52 |
|
53 |
- dev_info(dev, "Registered %d banks (GPIO(s): %d-%d)\n", |
54 |
- num_banks, priv->gpio_base, gpio_base - 1); |
55 |
- |
56 |
if (priv->parent_wake_irq && need_wakeup_event) |
57 |
pm_wakeup_event(dev, 0); |
58 |
|
59 |
-- |
60 |
2.19.1 |
61 |
|