GPIO support for BRCMSTB
Subsystems (7)
v2 cover GPIO support for BRCMSTB
This patchset adds support for the GPIO controller (UPG GIO) used on Broadcom's various BRCMSTB SoCs (BCM7XXX and others). It uses the "basic-mmio-gpio" interface to try to reduce duplication of the base logic.
For all existing hardware, this block hooked up to the BCM7120 L2 IRQ controller and so will require CONFIG_BCM7120_L2_IRQ=y.
New in v2:
- fix license mismatch as pointed out by Paul Bolle
- move select ARCH_WANT_OPTIONAL_GPIOLIB to separate patch
- change to have 32 lines per bank per Linus Walleij's comments
- allow this controller to be used as a wakeup source
- add default GPIO number for BRCMSTB
The device tree bindings from v1 were merged to the GPIO tree, so this patchset only contains an addition to allow GPIOs to be used as a wakeup source (patch 3). The initial bindings from v1 can be found at
https://lkml.org/lkml/2015/5/6/200 .
Gregory Fong (6):
gpio: Add GPIO support for Broadcom STB SoCs
gpio: brcmstb: Add interrupt support
dt-bindings: brcmstb-gpio: document properties for wakeup
gpio: brcmstb: Allow GPIOs to be wakeup sources
ARM: brcmstb: Select ARCH_WANT_OPTIONAL_GPIOLIB
ARM: brcmstb: Add default gpio number
.../devicetree/bindings/gpio/brcm,brcmstb-gpio.txt | 26 +- MAINTAINERS | 7 + arch/arm/Kconfig | 3 +- arch/arm/mach-bcm/Kconfig | 1 + drivers/gpio/Kconfig | 9 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-brcmstb.c | 581 +++++++++++++++++++++ 7 files changed, 626 insertions(+), 2 deletions(-) create mode 100644 drivers/gpio/gpio-brcmstb.c
Signature · 1 line
1.9.1
PATCH v2 1/6 gpio: Add GPIO support for Broadcom STB SoCs
This adds support for the GPIO IP "UPG GIO" used on Broadcom STB SoCs (BCM7XXX and some others). Uses basic_mmio_gpio to instantiate a gpio_chip for each bank. The driver assumes that it handles the base set of GPIOs on the system and that it can start its numbering sequence from 0, so any GPIO expanders used with it must dynamically assign GPIO numbers after this driver has finished registering its GPIOs.
Does not implement the interrupt-controller portion yet, will be done in a future commit.
---
v2:
- change include to use <linux/gpio/driver.h> instead of <linux/gpio.h>
- get rid of unnecessary imask member in struct bank
- rename GPIO_PER_BANK -> MAX_GPIO_PER_BANK
- always have 32 GPIOs per bank and add 'width' member in struct bank to hold actual number of GPIOs in use
- mark of_match table as const
MAINTAINERS | 7 ++ drivers/gpio/Kconfig | 8 ++ drivers/gpio/Makefile | 1 + drivers/gpio/gpio-brcmstb.c | 252 ++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 268 insertions(+) create mode 100644 drivers/gpio/gpio-brcmstb.c
MAINTAINERS +7 -0
@@ -2290,6 +2290,13 @@ N: bcm9583* N: bcm583* N: bcm113* +BROADCOM BRCMSTB GPIO DRIVER +M: Gregory Fong <[email protected]> +L: bcm-kernel-feedback-list at broadcom.com> +S: Supported +F: drivers/gpio/gpio-brcmstb.c +F: Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt + BROADCOM KONA GPIO DRIVER M: Ray Jui <[email protected]> L: bcm-kernel-feedback-list at broadcom.com
drivers/gpio/Kconfig +8 -0
@@ -126,6 +126,14 @@ config GPIO_BCM_KONA help Turn on GPIO support for Broadcom "Kona" chips. +config GPIO_BRCMSTB + tristate "BRCMSTB GPIO support" + default y if ARCH_BRCMSTB + depends on OF_GPIO && (ARCH_BRCMSTB || COMPILE_TEST) + select GPIO_GENERIC + help + Say yes here to enable GPIO support for Broadcom STB (BCM7XXX) SoCs. + config GPIO_CLPS711X tristate "CLPS711X GPIO support" depends on ARCH_CLPS711X || COMPILE_TEST
drivers/gpio/Makefile +1 -0
@@ -21,6 +21,7 @@ obj-$(CONFIG_GPIO_ALTERA) += gpio-altera.o obj-$(CONFIG_GPIO_AMD8111) += gpio-amd8111.o obj-$(CONFIG_GPIO_ARIZONA) += gpio-arizona.o obj-$(CONFIG_GPIO_BCM_KONA) += gpio-bcm-kona.o +obj-$(CONFIG_GPIO_BRCMSTB) += gpio-brcmstb.o obj-$(CONFIG_GPIO_BT8XX) += gpio-bt8xx.o obj-$(CONFIG_GPIO_CLPS711X) += gpio-clps711x.o obj-$(CONFIG_GPIO_CS5535) += gpio-cs5535.o
drivers/gpio/gpio-brcmstb.c new file +252 -0
252 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH v2 1/6] gpio: Add GPIO support for Broadcom STB SoCs
Quoted 12 lines · Gregory Fong
This adds support for the GPIO IP "UPG GIO" used on Broadcom STB SoCs (BCM7XXX and some others). Uses
basic_mmio_gpioto instantiate agpio_chipfor each bank. The driver assumes that it handles the base set of GPIOs on the system and that it can start its numbering sequence from 0, so any GPIO expanders used with it must dynamically assign GPIO numbers after this driver has finished registering its GPIOs.Does not implement the interrupt-controller portion yet, will be done in a future commit.
List-usage-fixed-by Brian Norris <[email protected]>Signed-off-by Gregory Fong <[email protected]>
Quoted 8 lines
---
v2:
- change include to use <linux/gpio/driver.h> instead of <linux/gpio.h>
- get rid of unnecessary imask member in struct bank
- renameGPIO_PER_BANK->MAX_GPIO_PER_BANK
- always have 32 GPIOs per bank and add 'width' member in struct bank to hold actual number of GPIOs in use
- markof_matchtable as const
This v2 version of 1/5 applied.
I recognize that you need one driver for all banks. I'm still hesitant about the complexity it brings to e.g. the IRQ handling.
Another possibility would be to spawn one driver per bank anyways, then have the IRQ requested as IRQF_SHARED so the IRQ handler for the shared IRQ would walk all drivers IRQ handlers and eventually figure out what GPIO fired it. But this implementation is quicker I guess.
Yours,
Linus Walleij
PATCH v2 2/6 gpio: brcmstb: Add interrupt support
In reply to Gregory FongCreate an irq_chip for each GIO block. Uses chained IRQ handling since known uses of this block have a BCM7120 L2 interrupt controller as a parent. Supports interrupts for all GPIOs.
In the IRQ handler, we check for raised IRQs for invalid GPIOs and warn (ratelimited) if they're encountered.
---
v2:
- since imask member of bank struct was removed, just read and write from mask reg and don't maintain a shadow
- warn on invalid IRQs
- move some irq setup to a separate function since probe is getting unwieldy
drivers/gpio/Kconfig | 1 + drivers/gpio/gpio-brcmstb.c | 276 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 277 insertions(+)
drivers/gpio/Kconfig +1 -0
@@ -131,6 +131,7 @@ config GPIO_BRCMSTB default y if ARCH_BRCMSTB depends on OF_GPIO && (ARCH_BRCMSTB || COMPILE_TEST) select GPIO_GENERIC + select IRQ_DOMAIN help Say yes here to enable GPIO support for Broadcom STB (BCM7XXX) SoCs.
drivers/gpio/gpio-brcmstb.c +276 -0
319 lines not on this page · raw message
Signature · 1 line
1.9.1
Re: [PATCH v2 2/6] gpio: brcmstb: Add interrupt support
A few small comments:
Quoted 3 lines · Gregory Fong
v2:
- since imask member of bank struct was removed, just read and write from mask reg and don't maintain a shadow
^^ this comment may be addressing what I'm going to ask about below? Not sure why this was changed, actually.
Quoted 7 lines
- warn on invalid IRQs
- move some irq setup to a separate function since probe is getting unwieldydrivers/gpio/Kconfig | 1 + drivers/gpio/gpio-brcmstb.c | 276 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 277 insertions(+)
...
Quoted 4 lines
drivers/gpio/gpio-brcmstb.c +0
-0
...
Quoted 1 line
drivers/gpio/gpio-brcmstb.c +0
-0@@ -63,6 +69,231 @@ brcmstb_gpio_gc_to_priv(struct gpio_chip *gc)
...
drivers/gpio/gpio-brcmstb.c brcmstb_gpio_gc_to_priv(struct gpio_chip *gc) · line 196
Quoted 11 lines
drivers/gpio/gpio-brcmstb.c +11
-0+static void brcmstb_gpio_irq_bank_handler (int irq, +struct brcmstb_gpio_bank *bank) +{ +struct brcmstb_gpio_priv *priv = bank->parent_priv; +void __iomem *reg_base = priv->reg_base; +unsigned long status; +unsigned long flags; + +spin_lock_irqsave (&bank->bgc.lock, flags); +while ((status = bank->bgc.read_reg (reg_base +GIO_STAT (bank->id)) & + bank->bgc.read_reg (reg_base +GIO_MASK (bank->id)))) {
In case you do run this loop multiple times (multiple interrupts in progress?), wouldn't it make sense to stash the mask exactly once, outside the loop? It's probably not a real big deal in practice, I guess.
Quoted 20 lines
drivers/gpio/gpio-brcmstb.c +20
-0+int bit; +for_each_set_bit (bit, &status,32 ) { +int hwirq = bank->bgc.gc.base - + priv->gpio_base + bit; +int child_irq = +irq_find_mapping (priv->irq_domain, + hwirq); +u32 stat = bank->bgc.read_reg (reg_base + +GIO_STAT (bank->id)); +if (bit >= bank->width) +dev_warn (&priv->pdev->dev, +"IRQ for invalid GPIO (bank=%d, offset=%d)\n" , + bank->id, bit); + bank->bgc.write_reg (reg_base +GIO_STAT (bank->id), + stat |BIT (bit)); +generic_handle_irq (child_irq); + } + } +spin_unlock_irqrestore (&bank->bgc.lock, flags); +}
...
drivers/gpio/gpio-brcmstb.c static int brcmstb_gpio_probe(struct platform_device *pdev) · line 413
Quoted 5 lines
drivers/gpio/gpio-brcmstb.c +1
-0@@ -153,6 +410,16 @@ static int brcmstb_gpio_probe(struct platform_device *pdev) priv->reg_base = reg_base; priv->pdev = pdev; +if (of_find_property (np,"interrupt-controller" ,NULL )) {
of_property_read_bool()?
drivers/gpio/gpio-brcmstb.c static int brcmstb_gpio_probe(struct platform_device *pdev) · line 425
Quoted 12 lines
drivers/gpio/gpio-brcmstb.c +9
-0+ priv->parent_irq =platform_get_irq (pdev,0 ); +if (priv->parent_irq <0 ) { +dev_err (dev,"Couldn't get IRQ" ); +return -ENOENT ; + } + }else { + priv->parent_irq = -ENOENT ; + } +INIT_LIST_HEAD (&priv->bank_list);if (brcmstb_gpio_sanity_check_banks (dev, np, res))return -EINVAL ;
Otherwise, looks OK to my inexpert eyes.
Re: [PATCH v2 2/6] gpio: brcmstb: Add interrupt support
Quoted 9 lines · Brian Norris
A few small comments:
Quoted 3 lines · Gregory Fong
v2:
- since imask member of bank struct was removed, just read and write from mask reg and don't maintain a shadow^^ this comment may be addressing what I'm going to ask about below? Not sure why this was changed, actually.
Yes, see below...
Quoted 16 lines
Quoted 8 lines
- warn on invalid IRQs
- move some irq setup to a separate function since probe is getting unwieldydrivers/gpio/Kconfig | 1 + drivers/gpio/gpio-brcmstb.c | 276 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 277 insertions(+)...
Quoted 4 lines
drivers/gpio/gpio-brcmstb.c +0
-0...
Quoted 1 line
drivers/gpio/gpio-brcmstb.c +0
-0@@ -63,6 +69,231 @@ brcmstb_gpio_gc_to_priv(struct gpio_chip *gc)...
Quoted 16 lines
drivers/gpio/gpio-brcmstb.c brcmstb_gpio_gc_to_priv(struct gpio_chip *gc) · line 196
Quoted 11 lines
drivers/gpio/gpio-brcmstb.c +11
-0+static void brcmstb_gpio_irq_bank_handler (int irq, +struct brcmstb_gpio_bank *bank) +{ +struct brcmstb_gpio_priv *priv = bank->parent_priv; +void __iomem *reg_base = priv->reg_base; +unsigned long status; +unsigned long flags; + +spin_lock_irqsave (&bank->bgc.lock, flags); +while ((status = bank->bgc.read_reg (reg_base +GIO_STAT (bank->id)) & + bank->bgc.read_reg (reg_base +GIO_MASK (bank->id)))) {In case you do run this loop multiple times (multiple interrupts in progress?), wouldn't it make sense to stash the mask exactly once, outside the loop? It's probably not a real big deal in practice, I guess.
I made this change after Linus's remark at
https://lkml.org/lkml/2015/5/12/303 on v1, which I agree with mostly since it's a premature optimization---I haven't determined whether keeping a shadow mask actually helps performance at all in practice, and better to keep it simpler without actual data.
Quoted 21 lines
Quoted 11 lines
drivers/gpio/gpio-brcmstb.c +10
-0+int bit; +for_each_set_bit (bit, &status,32 ) { +int hwirq = bank->bgc.gc.base - + priv->gpio_base + bit; +int child_irq = +irq_find_mapping (priv->irq_domain, + hwirq); +u32 stat = bank->bgc.read_reg (reg_base + +GIO_STAT (bank->id)); +if (bit >= bank->width)drivers/gpio/gpio-brcmstb.c brcmstb_gpio_gc_to_priv(struct gpio_chip *gc) · line 216
Quoted 10 lines
drivers/gpio/gpio-brcmstb.c +10
-0+dev_warn (&priv->pdev->dev, +"IRQ for invalid GPIO (bank=%d, offset=%d)\n" , + bank->id, bit); + bank->bgc.write_reg (reg_base +GIO_STAT (bank->id), + stat |BIT (bit)); +generic_handle_irq (child_irq); + } + } +spin_unlock_irqrestore (&bank->bgc.lock, flags); +}
Quoted 8 lines
...
drivers/gpio/gpio-brcmstb.c static int brcmstb_gpio_probe(struct platform_device *pdev) · line 413
Quoted 5 lines
drivers/gpio/gpio-brcmstb.c +1
-0@@ -153,6 +410,16 @@ static int brcmstb_gpio_probe(struct platform_device *pdev) priv->reg_base = reg_base; priv->pdev = pdev; +if (of_find_property (np,"interrupt-controller" ,NULL )) {
of_property_read_bool()?
OK.
Quoted 17 lines
drivers/gpio/gpio-brcmstb.c static int brcmstb_gpio_probe(struct platform_device *pdev) · line 425
Quoted 13 lines
drivers/gpio/gpio-brcmstb.c +9
-0+ priv->parent_irq =platform_get_irq (pdev,0 ); +if (priv->parent_irq <0 ) { +dev_err (dev,"Couldn't get IRQ" ); +return -ENOENT ; + } + }else { + priv->parent_irq = -ENOENT ; + } +INIT_LIST_HEAD (&priv->bank_list);if (brcmstb_gpio_sanity_check_banks (dev, np, res))return -EINVAL ;Otherwise, looks OK to my inexpert eyes.
Reviewed-by Brian Norris <[email protected]>
Re: [PATCH v2 2/6] gpio: brcmstb: Add interrupt support
In reply to Gregory FongQuoted 7 lines · Gregory Fong
Create an
irq_chipfor each GIO block. Uses chained IRQ handling since known uses of this block have a BCM7120 L2 interrupt controller as a parent. Supports interrupts for all GPIOs.In the IRQ handler, we check for raised IRQs for invalid GPIOs and warn (ratelimited) if they're encountered.
Quoted 7 lines
Signed-off-by Gregory Fong <[email protected]>---
v2:
- since imask member of bank struct was removed, just read and write from mask reg and don't maintain a shadow
- warn on invalid IRQs
- move some irq setup to a separate function since probe is getting unwieldy
This patch basically painfully reimplements GPIOLIB_IRQCHIP.
Is there a reason for not using that generic mechanism?
drivers/gpio/gpio-brcmstb.c brcmstb_gpio_gc_to_priv(struct gpio_chip *gc) · line 99
Quoted 9 lines
drivers/gpio/gpio-brcmstb.c +9
-0+static int brcmstb_gpio_to_irq (struct gpio_chip *gc,unsigned gc_offset) +{ +struct brcmstb_gpio_priv *priv =brcmstb_gpio_gc_to_priv (gc); +/* gc_offset is relative to this gpio_chip; want real offset */ +int offset = gc_offset + (gc->base - priv->gpio_base); + +if (offset >= priv->num_gpios) +return -ENXIO ; +return irq_create_mapping (priv->irq_domain, offset);
It is a no-no to rely on .to_irq() to be called before using an IRQ from a GPIO chip.
The gpiochip and irq_chip APIs are orthogonal, and a user may request an interrupt from the irqchip without calling .to_irq() on any GPIO line first.
This should only use irq_find_mapping().
irq_create_mapping() needs to be called on all available offsets during probe.
If the module is removable or at error path it also needs to call irq_dispose_mapping() on all lines. Also this is handled by GPIOLIB_IRQCHIP, and that is why it should always be used, if possible.
Yours,
Linus Walleij
PATCH v2 3/6 dt-bindings: brcmstb-gpio: document properties for wakeup
In reply to Gregory FongSome brcmstb GPIO controllers can be used to wake from suspend, so use the de facto standard property 'wakeup-source' to mark the nodes of controllers with that capability.
Also document interrupts-extended, which will be used for wakeup handling because the interrupt parent for the wake IRQ is different from the regular IRQ.
---
New in v2.
.../devicetree/bindings/gpio/brcm,brcmstb-gpio.txt | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt +25 -1
@@ -33,6 +33,12 @@ Optional properties: - interrupt-parent: phandle of the parent interrupt controller +- interrupts-extended: + Alternate form of specifying interrupts and parents that allows for + multiple parents. This takes precedence over 'interrupts' and + 'interrupt-parent'. This probably must be used if the wakeup-source + property is provided because that may have a different interrupt parent. + - #interrupt-cells: Should be <2>. The first cell is the GPIO number, the second should specify flags. The following subset of flags is supported:
@@ -48,7 +54,10 @@ Optional properties: Marks the device node as an interrupt controller - interrupt-names: - The name of the IRQ resource used by this controller + The names of the IRQ resources used by this controller + +- wakeup-source: + GPIOs for this controller can be used as a wakeup source Example: upg_gio: gpio at f040a700 {
@@ -63,3 +72,18 @@ Example: interrupt-names = "upg_gio"; brcm,gpio-bank-widths = <0x20 0x20 0x20 0x18>; }; + + upg_gio_aon: gpio at f04172c0 { + #gpio-cells = <0x2>; + #interrupt-cells = <0x2>; + compatible = "brcm,bcm7445-gpio", "brcm,brcmstb-gpio"; + gpio-controller; + interrupt-controller; + reg = <0xf04172c0 0x40>; + interrupt-parent = <0xc>; + interrupts = <0x6>; + interrupts-extended = <0xc 0x6 0xa 0x5>; + interrupt-names = "upg_gio_aon", "upg_gio_aon_wakeup"; + wakeup-source; + brcm,gpio-bank-widths = <0x12 0x4>; + };
Signature · 1 line
1.9.1
Re: [PATCH v2 3/6] dt-bindings: brcmstb-gpio: document properties for wakeup
Quoted 20 lines · Gregory Fong
Some brcmstb GPIO controllers can be used to wake from suspend, so use the de facto standard property 'wakeup-source' to mark the nodes of controllers with that capability.
Also document interrupts-extended, which will be used for wakeup handling because the interrupt parent for the wake IRQ is different from the regular IRQ.
Signed-off-by Gregory Fong <[email protected]>---
New in v2..../devicetree/bindings/gpio/brcm,brcmstb-gpio.txt | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt +0
-0
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt Optional properties: · line 41
Quoted 9 lines
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt +6
-0@@ -33,6 +33,12 @@ Optional properties: - interrupt-parent: phandle of the parent interrupt controller +- interrupts-extended: + Alternate form of specifying interrupts and parents that allows for + multiple parents. This takes precedence over 'interrupts' and + 'interrupt-parent'. This probably must be used if the wakeup-source + property is provided because that may have a different interrupt parent. +
"This probably must be used" seems a little awkward, especially when you're just explaining an implementation detail of our SoCs, rather than something unique about this binding. Maybe:
"Wakeup-capable GPIO controllers often route their wakeup interrupt lines through a different interrupt controller than the primary interrupt line, making this property necessary."
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt Optional properties: · line 57
Quoted 9 lines
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt +1
-1- #interrupt-cells: Should be <2>. The first cell is the GPIO number, the second should specify flags. The following subset of flags is supported:@@ -48,7 +54,10 @@ Optional properties: Marks the device node as an interrupt controller - interrupt-names: - The name of the IRQ resource used by this controller + The names of the IRQ resources used by this controller
If you're specifying names, you should list them here.
Quoted 7 lines
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt +3
-0+ +- wakeup-source: + GPIOs for this controller can be used as a wakeup source Example: upg_gio: gpio at f040a700 {
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt Example: · line 78
Quoted 7 lines
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt +4
-0@@ -63,3 +72,18 @@ Example: interrupt-names = "upg_gio"; brcm,gpio-bank-widths = <0x20 0x20 0x20 0x18>; }; + + upg_gio_aon: gpio at f04172c0 { + #gpio-cells = <0x2>; + #interrupt-cells = <0x2>;
Might use decimal instead of hex for the above 2 lines?
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt Example: · line 83
Quoted 5 lines
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt +5
-0+ compatible = "brcm,bcm7445-gpio", "brcm,brcmstb-gpio"; + gpio-controller; + interrupt-controller; + reg = <0xf04172c0 0x40>; + interrupt-parent = <0xc>;
That should be a phandle, not an int (I realize phandles resolve down to an integer, but we're speaking DTS, not DTB).
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt Example: · line 85
Quoted 2 lines
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt +2
-0+ interrupts = <0x6>; + interrupts-extended = <0xc 0x6 0xa 0x5>;
Same here (phandles).
Also, even though the interrupt binding semantics specify precedence between interrupts and interrupts-extended, I'd think an example should stick to one or the other, no?
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt Example: · line 89
Quoted 4 lines
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt +4
-0+ interrupt-names = "upg_gio_aon", "upg_gio_aon_wakeup"; + wakeup-source; + brcm,gpio-bank-widths = <0x12 0x4>; + };
Re: [PATCH v2 3/6] dt-bindings: brcmstb-gpio: document properties for wakeup
Quoted 35 lines · Brian Norris
Quoted 20 lines · Gregory Fong
Some brcmstb GPIO controllers can be used to wake from suspend, so use the de facto standard property 'wakeup-source' to mark the nodes of controllers with that capability.
Also document interrupts-extended, which will be used for wakeup handling because the interrupt parent for the wake IRQ is different from the regular IRQ.
Signed-off-by Gregory Fong <[email protected]>---
New in v2..../devicetree/bindings/gpio/brcm,brcmstb-gpio.txt | 26 +++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-)Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt +0
-0Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt Optional properties: · line 41
Quoted 9 lines
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt +6
-0@@ -33,6 +33,12 @@ Optional properties: - interrupt-parent: phandle of the parent interrupt controller +- interrupts-extended: + Alternate form of specifying interrupts and parents that allows for + multiple parents. This takes precedence over 'interrupts' and + 'interrupt-parent'. This probably must be used if the wakeup-source + property is provided because that may have a different interrupt parent. +"This probably must be used" seems a little awkward, especially when you're just explaining an implementation detail of our SoCs, rather than something unique about this binding. Maybe:
Quoted 3 lines
"Wakeup-capable GPIO controllers often route their wakeup interrupt lines through a different interrupt controller than the primary interrupt line, making this property necessary."
That wording does seem better, will change.
Quoted 7 lines
Quoted 7 lines
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt +0
-0- #interrupt-cells: Should be <2>. The first cell is the GPIO number, the second should specify flags. The following subset of flags is supported:@@ -48,7 +54,10 @@ Optional properties: Marks the device node as an interrupt controller
Quoted 5 lines
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt Optional properties: · line 57
Quoted 3 lines
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt +1
-1- interrupt-names: - The name of the IRQ resource used by this controller + The names of the IRQ resources used by this controllerIf you're specifying names, you should list them here.
I was wondering about that. Some bindings have them listed, some don't. In this case I know what names currently exist but there could certainly be different ones in the future. How does that work? Or am I misunderstanding what this field is used for? Where are the documented rules for this?
Quoted 5 lines
Quoted 5 lines
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt +3
-0+ +- wakeup-source: + GPIOs for this controller can be used as a wakeup source
Quoted 12 lines
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt Example: · line 78
Quoted 10 lines
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt +4
-0Example: upg_gio: gpio at f040a700 {@@ -63,3 +72,18 @@ Example: interrupt-names = "upg_gio"; brcm,gpio-bank-widths = <0x20 0x20 0x20 0x18>; }; + + upg_gio_aon: gpio at f04172c0 { + #gpio-cells = <0x2>; + #interrupt-cells = <0x2>;Might use decimal instead of hex for the above 2 lines?
Sure.
Quoted 9 lines
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt Example: · line 83
Quoted 6 lines
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt +5
-0+ compatible = "brcm,bcm7445-gpio", "brcm,brcmstb-gpio"; + gpio-controller; + interrupt-controller; + reg = <0xf04172c0 0x40>; + interrupt-parent = <0xc>;That should be a phandle, not an int (I realize phandles resolve down to an integer, but we're speaking DTS, not DTB).
OK.
Quoted 9 lines
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt Example: · line 85
Quoted 3 lines
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt +2
-0+ interrupts = <0x6>; + interrupts-extended = <0xc 0x6 0xa 0x5>;Same here (phandles).
Also, even though the interrupt binding semantics specify precedence between interrupts and interrupts-extended, I'd think an example should stick to one or the other, no?
This is the output that we actually get from the bootloader. But regardless, IMO the example should have both cases: precedence is well-defined, both sets of information are valid, and the driver can handle the case where interrupts-extended is not an understood property.
Quoted 7 lines
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt Example: · line 89
Quoted 5 lines
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt +4
-0+ interrupt-names = "upg_gio_aon", "upg_gio_aon_wakeup"; + wakeup-source; + brcm,gpio-bank-widths = <0x12 0x4>; + };Reviewed-by Brian Norris <[email protected]>
Thanks for the review,
Gregory
Re: [PATCH v2 3/6] dt-bindings: brcmstb-gpio: document properties for wakeup
Quoted 6 lines · Gregory Fong
Quoted 4 lines · Brian Norris
Quoted 3 lines · Gregory Fong
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt +0
-0@@ -33,6 +33,12 @@ Optional properties:
...
Quoted 12 lines
Quoted 11 lines
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt Optional properties: · line 57
Quoted 9 lines
- #interrupt-cells:
Should be <2>. The first cell is the GPIO number, the second should specify flags. The following subset of flags is supported:Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt +1
-1@@ -48,7 +54,10 @@ Optional properties: Marks the device node as an interrupt controller - interrupt-names: - The name of the IRQ resource used by this controller + The names of the IRQ resources used by this controllerIf you're specifying names, you should list them here.
Quoted 5 lines
I was wondering about that. Some bindings have them listed, some don't. In this case I know what names currently exist but there could certainly be different ones in the future. How does that work? Or am I misunderstanding what this field is used for? Where are the documented rules for this?
The only documentation I see is:Documentation/devicetree/bindings/resource-names.txt
That documents the basics of the *-names properties, not their expected usage.
In practice, they're only useful if you have enough optional resources that fixed indexing isn't sufficient, and you need to use platform_get_resource_byname().
So IMO, their purposes seems to be one of these:
(1) functional (e.g., for get_resource_byname(), when you have more than one optional resource)
(2) self-documentation (which might run counter to #1, as you begin generating too many unique names)
(3) no purpose
So IMO, if you ever want (1), they shouldn't have instance-specific naming, but should use something generic to the device class. Otherwise, they are just self-documentation, and aren't functionally useful. So IMO, these sorts of names:
interrupt-names = "upg_gio_aon", "upg_gio_aon_wakeup";
work better as functional descriptions:
interrupt-names = "gio", "wakeup";
But in the end, I wouldn't foresee you needing to do (1), so you're left with (2) or (3), at which point I'm not sure if you should even mention the property.
Just my 2 cents (and those cents may not even be worth face value), Brian
Re: [PATCH v2 3/6] dt-bindings: brcmstb-gpio: document properties for wakeup
Quoted 50 lines · Brian Norris
Quoted 6 lines · Gregory Fong
Quoted 4 lines · Brian Norris
Quoted 3 lines · Gregory Fong
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt +0
-0@@ -33,6 +33,12 @@ Optional properties:...
Quoted 12 lines
Quoted 11 lines
Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt Optional properties: · line 57
Quoted 9 lines
- #interrupt-cells:
Should be <2>. The first cell is the GPIO number, the second should specify flags. The following subset of flags is supported:Documentation/devicetree/bindings/gpio/brcm,brcmstb-gpio.txt +1
-1@@ -48,7 +54,10 @@ Optional properties: Marks the device node as an interrupt controller - interrupt-names: - The name of the IRQ resource used by this controller + The names of the IRQ resources used by this controllerIf you're specifying names, you should list them here.
Quoted 5 lines
I was wondering about that. Some bindings have them listed, some don't. In this case I know what names currently exist but there could certainly be different ones in the future. How does that work? Or am I misunderstanding what this field is used for? Where are the documented rules for this?
The only documentation I see is:
Documentation/devicetree/bindings/resource-names.txtThat documents the basics of the *-names properties, not their expected usage.
In practice, they're only useful if you have enough optional resources that fixed indexing isn't sufficient, and you need to use
platform_get_resource_byname().So IMO, their purposes seems to be one of these:
(1) functional (e.g., forget_resource_byname(), when you have more than one optional resource)
(2) self-documentation (which might run counter to #1, as you begin generating too many unique names)
(3) no purposeSo IMO, if you ever want (1), they shouldn't have instance-specific naming, but should use something generic to the device class. Otherwise, they are just self-documentation, and aren't functionally useful. So IMO, these sorts of names:
interrupt-names = "upg_gio_aon", "upg_gio_aon_wakeup";
Quoted 7 lines
work better as functional descriptions:
interrupt-names = "gio", "wakeup";But in the end, I wouldn't foresee you needing to do (1), so you're left with (2) or (3), at which point I'm not sure if you should even mention the property.
I'm fine with leaving out the interrupt-names property, since we're not using it here anyway. Unless there are serious objections, I'll plan on remove it from the bindings doc next round.
Thanks,
Gregory
PATCH v2 4/6 gpio: brcmstb: Allow GPIOs to be wakeup sources
In reply to Gregory FongSeveral drivers (e.g. gpio-keys) allow for GPIOs to be configured as wakeup sources, and this GPIO controller supports that through a separate interrupt path.
The de-facto standard DT property "wakeup-source" is checked, since that indicates whether the GPIO controller hardware can wake. Uses the IRQCHIP_MASK_ON_SUSPEND irq_chip flag because UPG GIO doesn't have any of its own wakeup source configuration.
---
New in v2.
drivers/gpio/gpio-brcmstb.c | 53 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)
drivers/gpio/gpio-brcmstb.c +53 -0
@@ -19,6 +19,7 @@#include <linux/basic_mmio_gpio.h> #include <linux/irqdomain.h> #include <linux/irqchip/chained_irq.h> +#include <linux/interrupt.h> #define GIO_BANK_SIZE 0x20#define GIO_ODEN (bank) (((bank) * GIO_BANK_SIZE) + 0x00)
@@ -48,6 +49,7 @@ struct brcmstb_gpio_priv {struct irq_domain *irq_domain;int parent_irq;int gpio_base; +int parent_wake_irq; };#define MAX_GPIO_PER_BANK 32
@@ -183,6 +185,31 @@ static int brcmstb_gpio_irq_set_type(struct irq_data *d, unsigned int type)return 0 ; } +static int brcmstb_gpio_irq_set_wake (struct irq_data *d,unsigned int enable) +{ +struct brcmstb_gpio_bank *bank =irq_data_get_irq_chip_data (d); +struct brcmstb_gpio_priv *priv = bank->parent_priv; + +/* +* Only enable wake IRQ once for however many hwirqs can wake +* since they all use the same wake IRQ. Mask will be set +* up appropriately thanks to IRQCHIP_MASK_ON_SUSPEND flag. +*/ +if (enable) +enable_irq_wake (priv->parent_wake_irq); +else +disable_irq_wake (priv->parent_wake_irq); +return 0 ; +} + +static irqreturn_t brcmstb_gpio_wake_irq_handler (int irq,void *data) +{ +struct brcmstb_gpio_priv *priv = data; + +pm_wakeup_event (&priv->pdev->dev,0 ); +return IRQ_HANDLED ; +} +static void brcmstb_gpio_irq_bank_handler (int irq,struct brcmstb_gpio_bank *bank) {
@@ -369,6 +396,32 @@ static int brcmstb_gpio_irq_setup(struct platform_device *pdev, priv->irq_chip.irq_mask = brcmstb_gpio_irq_mask; priv->irq_chip.irq_unmask = brcmstb_gpio_irq_unmask; priv->irq_chip.irq_set_type = brcmstb_gpio_irq_set_type; + +/* Ensures that all non-wakeup IRQs are disabled at suspend */ + priv->irq_chip.flags =IRQCHIP_MASK_ON_SUSPEND ; + +if (IS_ENABLED (CONFIG_PM_SLEEP ) && +of_get_property (np,"wakeup-source" ,NULL )) { + priv->parent_wake_irq =platform_get_irq (pdev,1 ); +if (priv->parent_wake_irq <0 ) { +dev_warn (dev, +"Couldn't get wake IRQ - GPIOs will not be able to wake from sleep" ); + }else { +int err =devm_request_irq (dev, priv->parent_wake_irq, + brcmstb_gpio_wake_irq_handler,0 , +"brcmstb-gpio-wake" , priv); + +if (err <0 ) { +dev_err (dev,"Couldn't request wake IRQ" ); +return err; + } + +device_set_wakeup_capable (dev, true); +device_wakeup_enable (dev); + priv->irq_chip.irq_set_wake = brcmstb_gpio_irq_set_wake; + } + } + priv->irq_domain = irq_domain_add_linear(np, priv->num_gpios, &brcmstb_gpio_irq_domain_ops,
Signature · 1 line
1.9.1
Re: [PATCH v2 4/6] gpio: brcmstb: Allow GPIOs to be wakeup sources
Quoted 69 lines · Gregory Fong
Several drivers (e.g. gpio-keys) allow for GPIOs to be configured as wakeup sources, and this GPIO controller supports that through a separate interrupt path.
The de-facto standard DT property "wakeup-source" is checked, since that indicates whether the GPIO controller hardware can wake. Uses the
IRQCHIP_MASK_ON_SUSPENDirq_chipflag because UPG GIO doesn't have any of its own wakeup source configuration.Signed-off-by Gregory Fong <[email protected]>---
New in v2.drivers/gpio/gpio-brcmstb.c | 53 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)drivers/gpio/gpio-brcmstb.c +27
-0@@ -19,6 +19,7 @@#include <linux/basic_mmio_gpio.h> #include <linux/irqdomain.h> #include <linux/irqchip/chained_irq.h> +#include <linux/interrupt.h> #define GIO_BANK_SIZE 0x20#define GIO_ODEN (bank) (((bank) * GIO_BANK_SIZE) + 0x00)@@ -48,6 +49,7 @@ struct brcmstb_gpio_priv {struct irq_domain *irq_domain;int parent_irq;int gpio_base; +int parent_wake_irq; };#define MAX_GPIO_PER_BANK 32@@ -183,6 +185,31 @@ static int brcmstb_gpio_irq_set_type(struct irq_data *d, unsigned int type)return 0 ; } +static int brcmstb_gpio_irq_set_wake (struct irq_data *d,unsigned int enable) +{ +struct brcmstb_gpio_bank *bank =irq_data_get_irq_chip_data (d); +struct brcmstb_gpio_priv *priv = bank->parent_priv; + +/* +* Only enable wake IRQ once for however many hwirqs can wake +* since they all use the same wake IRQ. Mask will be set +* up appropriately thanks to IRQCHIP_MASK_ON_SUSPEND flag. +*/ +if (enable) +enable_irq_wake (priv->parent_wake_irq); +else +disable_irq_wake (priv->parent_wake_irq); +return 0 ; +} + +static irqreturn_t brcmstb_gpio_wake_irq_handler (int irq,void *data) +{ +struct brcmstb_gpio_priv *priv = data; + +pm_wakeup_event (&priv->pdev->dev,0 ); +return IRQ_HANDLED ; +} +static void brcmstb_gpio_irq_bank_handler (int irq,struct brcmstb_gpio_bank *bank) {
drivers/gpio/gpio-brcmstb.c static int brcmstb_gpio_irq_setup(struct platform_device *pdev, · line 404
Quoted 9 lines
drivers/gpio/gpio-brcmstb.c +6
-0@@ -369,6 +396,32 @@ static int brcmstb_gpio_irq_setup(struct platform_device *pdev, priv->irq_chip.irq_mask = brcmstb_gpio_irq_mask; priv->irq_chip.irq_unmask = brcmstb_gpio_irq_unmask; priv->irq_chip.irq_set_type = brcmstb_gpio_irq_set_type; + +/* Ensures that all non-wakeup IRQs are disabled at suspend */ + priv->irq_chip.flags =IRQCHIP_MASK_ON_SUSPEND ; + +if (IS_ENABLED (CONFIG_PM_SLEEP ) && +of_get_property (np,"wakeup-source" ,NULL )) {
of_property_read_bool()?
Quoted 6 lines
drivers/gpio/gpio-brcmstb.c +6
-0+ priv->parent_wake_irq =platform_get_irq (pdev,1 ); +if (priv->parent_wake_irq <0 ) { +dev_warn (dev, +"Couldn't get wake IRQ - GPIOs will not be able to wake from sleep" ); + }else { + int err = devm_request_irq(dev, priv->parent_wake_irq,
drivers/gpio/gpio-brcmstb.c static int brcmstb_gpio_irq_setup(struct platform_device *pdev, · line 420
Quoted 10 lines
drivers/gpio/gpio-brcmstb.c +10
-0+ brcmstb_gpio_wake_irq_handler,0 , + "brcmstb-gpio-wake", priv); + +if (err <0 ) { +dev_err (dev,"Couldn't request wake IRQ" ); +return err; + } + +device_set_wakeup_capable (dev, true); +device_wakeup_enable (dev);
Might want to move these two lines above the devm_request_irq(), so that you're ready to record PM events immediately at probe time. This is important when waking from S5 states, where we sometimes want to be able to check the /sys/devices/.../wakeup_count stats to see what woke us up.
drivers/gpio/gpio-brcmstb.c static int brcmstb_gpio_irq_setup(struct platform_device *pdev, · line 427
Quoted 7 lines
drivers/gpio/gpio-brcmstb.c +4
-0+ priv->irq_chip.irq_set_wake = brcmstb_gpio_irq_set_wake; + } + } + priv->irq_domain = irq_domain_add_linear(np, priv->num_gpios, &brcmstb_gpio_irq_domain_ops,
With that:
Re: [PATCH v2 4/6] gpio: brcmstb: Allow GPIOs to be wakeup sources
Quoted 26 lines · Brian Norris
Quoted 25 lines · Gregory Fong
Several drivers (e.g. gpio-keys) allow for GPIOs to be configured as wakeup sources, and this GPIO controller supports that through a separate interrupt path.
The de-facto standard DT property "wakeup-source" is checked, since that indicates whether the GPIO controller hardware can wake. Uses the
IRQCHIP_MASK_ON_SUSPENDirq_chipflag because UPG GIO doesn't have any of its own wakeup source configuration.Signed-off-by Gregory Fong <[email protected]>---
New in v2.drivers/gpio/gpio-brcmstb.c | 53 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+)drivers/gpio/gpio-brcmstb.c +0
-0@@ -369,6 +396,32 @@ static int brcmstb_gpio_irq_setup(struct platform_device *pdev, priv->irq_chip.irq_mask = brcmstb_gpio_irq_mask; priv->irq_chip.irq_unmask = brcmstb_gpio_irq_unmask; priv->irq_chip.irq_set_type = brcmstb_gpio_irq_set_type;
Quoted 8 lines
drivers/gpio/gpio-brcmstb.c static int brcmstb_gpio_irq_setup(struct platform_device *pdev, · line 404
Quoted 6 lines
drivers/gpio/gpio-brcmstb.c +6
-0+ +/* Ensures that all non-wakeup IRQs are disabled at suspend */ + priv->irq_chip.flags =IRQCHIP_MASK_ON_SUSPEND ; + +if (IS_ENABLED (CONFIG_PM_SLEEP ) && +of_get_property (np,"wakeup-source" ,NULL )) {
of_property_read_bool()?
Will change.
Quoted 14 lines
Quoted 14 lines
drivers/gpio/gpio-brcmstb.c +13
-0+ priv->parent_wake_irq =platform_get_irq (pdev,1 ); +if (priv->parent_wake_irq <0 ) { +dev_warn (dev, +"Couldn't get wake IRQ - GPIOs will not be able to wake from sleep" ); + }else { +int err =devm_request_irq (dev, priv->parent_wake_irq, + brcmstb_gpio_wake_irq_handler,0 , +"brcmstb-gpio-wake" , priv); + +if (err <0 ) { +dev_err (dev,"Couldn't request wake IRQ" ); +return err; + }
Quoted 8 lines
drivers/gpio/gpio-brcmstb.c static int brcmstb_gpio_irq_setup(struct platform_device *pdev, · line 420
Quoted 3 lines
drivers/gpio/gpio-brcmstb.c +3
-0+ +device_set_wakeup_capable (dev, true); +device_wakeup_enable (dev);Might want to move these two lines above the
devm_request_irq(), so that you're ready to record PM events immediately at probe time. This is important when waking from S5 states, where we sometimes want to be able to check the/sys/devices/.../wakeup_countstats to see what woke us up.
Makes sense. We'll also need a reboot notifier for S5 to work.
Quoted 9 lines
drivers/gpio/gpio-brcmstb.c static int brcmstb_gpio_irq_setup(struct platform_device *pdev, · line 427
Quoted 8 lines
drivers/gpio/gpio-brcmstb.c +4
-0+ priv->irq_chip.irq_set_wake = brcmstb_gpio_irq_set_wake; + } + } + priv->irq_domain = irq_domain_add_linear(np, priv->num_gpios, &brcmstb_gpio_irq_domain_ops,
Quoted 3 lines
With that:
Reviewed-by Brian Norris <[email protected]>
Thanks,
Gregory
Re: [PATCH v2 4/6] gpio: brcmstb: Allow GPIOs to be wakeup sources
In reply to Gregory FongQuoted 10 lines · Gregory Fong
Several drivers (e.g. gpio-keys) allow for GPIOs to be configured as wakeup sources, and this GPIO controller supports that through a separate interrupt path.
The de-facto standard DT property "wakeup-source" is checked, since that indicates whether the GPIO controller hardware can wake. Uses the
IRQCHIP_MASK_ON_SUSPENDirq_chipflag because UPG GIO doesn't have any of its own wakeup source configuration.Signed-off-by Gregory Fong <[email protected]>
(...)
drivers/gpio/gpio-brcmstb.c static int brcmstb_gpio_irq_set_type(struct irq_data *d, unsigned int type) · line 202
Quoted 5 lines
drivers/gpio/gpio-brcmstb.c +5
-0+if (enable) +enable_irq_wake (priv->parent_wake_irq); +else +disable_irq_wake (priv->parent_wake_irq); +return 0 ;
No error handling? If the code assumes these calls will always succeed, atleast write that in a comment.
Yours,
Linus Walleij
Re: [PATCH v2 4/6] gpio: brcmstb: Allow GPIOs to be wakeup sources
Quoted 14 lines · Linus Walleij
Quoted 10 lines · Gregory Fong
Several drivers (e.g. gpio-keys) allow for GPIOs to be configured as wakeup sources, and this GPIO controller supports that through a separate interrupt path.
The de-facto standard DT property "wakeup-source" is checked, since that indicates whether the GPIO controller hardware can wake. Uses the
IRQCHIP_MASK_ON_SUSPENDirq_chipflag because UPG GIO doesn't have any of its own wakeup source configuration.Signed-off-by Gregory Fong <[email protected]>(...)
Quoted 8 lines
drivers/gpio/gpio-brcmstb.c static int brcmstb_gpio_irq_set_type(struct irq_data *d, unsigned int type) · line 202
Quoted 5 lines
drivers/gpio/gpio-brcmstb.c +5
-0+if (enable) +enable_irq_wake (priv->parent_wake_irq); +else +disable_irq_wake (priv->parent_wake_irq); +return 0 ;No error handling? If the code assumes these calls will always succeed, atleast write that in a comment.
Will add error handling.
Thanks,
Gregory
PATCH v2 5/6 ARM: brcmstb: Select ARCH_WANT_OPTIONAL_GPIOLIB
In reply to Gregory FongSelect ARCH_WANT_OPTIONAL_GPIOLIB from BRCMSTB to allow GPIOLIB and GPIO_BRCMSTB to be enabled.
---
v2: this was split out so that it can go through the ARM SoC tree.
arch/arm/mach-bcm/Kconfig | 1 + 1 file changed, 1 insertion(+)
arch/arm/mach-bcm/Kconfig +1 -0
@@ -144,6 +144,7 @@ config ARCH_BRCMSTB select BRCMSTB_GISB_ARB select BRCMSTB_L2_IRQ select BCM7120_L2_IRQ + select ARCH_WANT_OPTIONAL_GPIOLIB help Say Y if you intend to run the kernel on a Broadcom ARM-based STB chipset.
Signature · 1 line
1.9.1
Florian Fainelli
AppliedRe: [PATCH v2 5/6] ARM: brcmstb: Select ARCH_WANT_OPTIONAL_GPIOLIB
Quoted 4 lines · Gregory Fong
Select
ARCH_WANT_OPTIONAL_GPIOLIBfrom BRCMSTB to allow GPIOLIB andGPIO_BRCMSTBto be enabled.Signed-off-by Gregory Fong <[email protected]>
Applied to soc/next, thanks!
Signature · 1 line
Florian
Re: [PATCH v2 5/6] ARM: brcmstb: Select ARCH_WANT_OPTIONAL_GPIOLIB
In reply to Gregory FongQuoted 4 lines · Gregory Fong
Select
ARCH_WANT_OPTIONAL_GPIOLIBfrom BRCMSTB to allow GPIOLIB andGPIO_BRCMSTBto be enabled.Signed-off-by Gregory Fong <[email protected]>
Yours,
Linus Walleij
PATCH v2 6/6 ARM: brcmstb: Add default gpio number
In reply to Gregory FongOut of the brcmstb SoCs that I know, BCM3390 has the largest numbers of GPIOs, with its
- 320 "peripheral" GPIOs
- 5*32 = 160 UPG GPIOs (counting unused lines, which do get counted)
- 2*32 = 64 UPG AON GPIOs (counting unused lines)
Total: 544
I suspect that the upper limit will only need to be higher in the future, so set it to 1024.
---
New in v2.
arch/arm/Kconfig | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/arm/Kconfig +2 -1
@@ -1509,7 +1509,8 @@ config ARM_PSCI # selected platforms. config ARCH_NR_GPIO int - default 1024 if ARCH_SHMOBILE || ARCH_TEGRA || ARCH_ZYNQ + default 1024 if ARCH_BRCMSTB || ARCH_SHMOBILE || ARCH_TEGRA || \ + ARCH_ZYNQ default 512 if ARCH_EXYNOS || ARCH_KEYSTONE || SOC_OMAP5 || \ SOC_DRA7XX || ARCH_S3C24XX || ARCH_S3C64XX || ARCH_S5PV210 default 416 if ARCH_SUNXI
Signature · 1 line
1.9.1
Florian Fainelli
AppliedRe: [PATCH v2 6/6] ARM: brcmstb: Add default gpio number
Quoted 11 lines · Gregory Fong
Out of the brcmstb SoCs that I know, BCM3390 has the largest numbers of GPIOs, with its
- 320 "peripheral" GPIOs
- 5*32 = 160 UPG GPIOs (counting unused lines, which do get counted)
- 2*32 = 64 UPG AON GPIOs (counting unused lines)
Total: 544I suspect that the upper limit will only need to be higher in the future, so set it to 1024.
Signed-off-by Gregory Fong <[email protected]>
Applied to soc/next, thanks!
Signature · 1 line
Florian
Re: [PATCH v2 6/6] ARM: brcmstb: Add default gpio number
In reply to Gregory FongQuoted 11 lines · Gregory Fong
Out of the brcmstb SoCs that I know, BCM3390 has the largest numbers of GPIOs, with its
- 320 "peripheral" GPIOs
- 5*32 = 160 UPG GPIOs (counting unused lines, which do get counted)
- 2*32 = 64 UPG AON GPIOs (counting unused lines)
Total: 544I suspect that the upper limit will only need to be higher in the future, so set it to 1024.
Signed-off-by Gregory Fong <[email protected]>
Yours,
Linus Walleij
Quoted 6 lines · Gregory Fong
This patchset adds support for the GPIO controller (UPG GIO) used on Broadcom's various BRCMSTB SoCs (BCM7XXX and others). It uses the "basic-mmio-gpio" interface to try to reduce duplication of the base logic.
For all existing hardware, this block hooked up to the BCM7120 L2 IRQ controller and so will require
CONFIG_BCM7120_L2_IRQ=y.
Unless there are objections, I will take patches 5 and 6 and apply them to soc/next.
Thanks!
Quoted 31 lines
New in v2:
- fix license mismatch as pointed out by Paul Bolle
- move selectARCH_WANT_OPTIONAL_GPIOLIBto separate patch
- change to have 32 lines per bank per Linus Walleij's comments
- allow this controller to be used as a wakeup source
- add default GPIO number for BRCMSTBThe device tree bindings from v1 were merged to the GPIO tree, so this patchset only contains an addition to allow GPIOs to be used as a wakeup source (patch 3). The initial bindings from v1 can be found at
https://lkml.org/lkml/2015/5/6/200 .Gregory Fong (6):
gpio: Add GPIO support for Broadcom STB SoCs
gpio: brcmstb: Add interrupt support
dt-bindings: brcmstb-gpio: document properties for wakeup
gpio: brcmstb: Allow GPIOs to be wakeup sources
ARM: brcmstb: SelectARCH_WANT_OPTIONAL_GPIOLIB
ARM: brcmstb: Add default gpio number.../devicetree/bindings/gpio/brcm,brcmstb-gpio.txt | 26 +- MAINTAINERS | 7 + arch/arm/Kconfig | 3 +- arch/arm/mach-bcm/Kconfig | 1 + drivers/gpio/Kconfig | 9 + drivers/gpio/Makefile | 1 + drivers/gpio/gpio-brcmstb.c | 581 +++++++++++++++++++++ 7 files changed, 626 insertions(+), 2 deletions(-) create mode 100644 drivers/gpio/gpio-brcmstb.c
Signature · 1 line
Florian