Skip to contentSkip to conversation

bcma: use device from DT (brcm,bus-gpio) for SoC GPIO chip

PATCH New Rafał Miłecki 3 participants 15 messages Sep 26, 2014 – Sep 30, 2014

Subsystems (2)
lore
Share & tools
lore

Rafał Miłecki

author maintainer
#0 lore raw

PATCH 1/1 bcma: use device from DT (brcm,bus-gpio) for SoC GPIO chip

This will allow us to define GPIO-attached devices (LEDs, buttons) in the the device tree.

---
This is based on top of
[PATCH v6] bcma: register bcma as device tree driver that I hope will reach wireless-next git tree.

---
 Documentation/devicetree/bindings/bus/bcma.txt | 15 +++++++++++++++
 drivers/bcma/driver_gpio.c                     |  5 +++++
 2 files changed, 20 insertions(+)
Documentation/devicetree/bindings/bus/bcma.txt +15 -0
index e9070c1..f1b381e 100644
@@ -6,6 +6,15 @@ Required properties:
 
 - reg : iomem address range of chipcommon core
 
+The top-level axi bus may contain following children:
+
+- gpio: GPIO chip on the SoC
+
+  Required properties:
+  - compatible: "brcm,bus-gpio"
+  - gpio-controller : makes the node a GPIO controller
+  - #gpio-cells : size of the GPIO specifier, must be 2
+
 The cores on the AXI bus are automatically detected by bcma with the
 memory ranges they are using and they get registered afterwards.
 
@@ -17,4 +26,10 @@ Example:
 		ranges = <0x00000000 0x18000000 0x00100000>;
 		#address-cells = <1>;
 		#size-cells = <1>;
+
+		gpio at 0 {
+			compatible = "brcm,bus-gpio";
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
 	};
drivers/bcma/driver_gpio.c +5 -0
index 8ea497c..7ae39a8 100644
@@ -218,6 +218,11 @@ int bcma_gpio_init(struct bcma_drv_cc *cc)
 #if IS_BUILTIN(CONFIG_BCM47XX)
 	chip->to_irq		= bcma_gpio_to_irq;
 #endif
+#if IS_BUILTIN(CONFIG_OF)
+	if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
+		chip->of_node	= of_find_compatible_node(NULL, NULL,
+							  "brcm,bus-gpio");
+#endif
 	switch (cc->core->bus->chipinfo.id) {
 	case BCMA_CHIP_ID_BCM5357:
 	case BCMA_CHIP_ID_BCM53572:
Signature · 1 line
1.8.4.5
#1 lore raw

PATCH 1/1 bcma: use device from DT (brcm, bus-gpio) for SoC GPIO chip

Documentation/devicetree/bindings/bus/bcma.txt Required properties: · line 17

Quoted 10 lines · On Friday 26 September 2014 16:28:53 Rafa? Mi?ecki wrote:
Documentation/devicetree/bindings/bus/bcma.txt +9 -0
+The top-level axi bus may contain following children:
+
+- gpio: GPIO chip on the SoC
+
+  Required properties:
+  - compatible: "brcm,bus-gpio"
+  - gpio-controller : makes the node a GPIO controller
+  - #gpio-cells : size of the GPIO specifier, must be 2
+

I wonder if it would be better to avoid the subnode here and just make the parent itself the gpio controller.

Is the gpio controller part of the bus itself in reality, or is it a device that gets probed on the bus?

Arnd

author maintainer
#2 lore raw

PATCH 1/1 bcma: use device from DT (brcm, bus-gpio) for SoC GPIO chip

Quoted 15 lines · Arnd Bergmann

Documentation/devicetree/bindings/bus/bcma.txt Required properties: · line 17

Quoted 10 lines · On Friday 26 September 2014 16:28:53 Rafa? Mi?ecki wrote:
Documentation/devicetree/bindings/bus/bcma.txt +9 -0
+The top-level axi bus may contain following children:
+
+- gpio: GPIO chip on the SoC
+
+  Required properties:
+  - compatible: "brcm,bus-gpio"
+  - gpio-controller : makes the node a GPIO controller
+  - #gpio-cells : size of the GPIO specifier, must be 2
+

I wonder if it would be better to avoid the subnode here and just make the parent itself the gpio controller.

Quoted 2 lines

Is the gpio controller part of the bus itself in reality, or is it a device that gets probed on the bus?

I'm not sure how to treat this chip.
We control GPIOs using ChipCommon regs (and ChipCommon is one of cores/devices on the bus), so you could also consider GPIO chip a sub-device of ChipCommon.
I believe every Broadcom bus has a GPIO chip. In the ancient (MIPS) times, even if we didn't have ChipCommon, there was an EXTIF core that used to provide access to the GPIO chip.

What do you think? Should I make it separated device, even it if depends on the SoC and its ChipCommon core (device)?

Signature · 1 line
Rafa?
#3 lore raw

PATCH 1/1 bcma: use device from DT (brcm,bus-gpio) for SoC GPIO chip

Quoted 27 lines · Rafa? Mi?ecki
Quoted 15 lines · Arnd Bergmann

Documentation/devicetree/bindings/bus/bcma.txt Required properties: · line 17

Quoted 10 lines · On Friday 26 September 2014 16:28:53 Rafa? Mi?ecki wrote:
Documentation/devicetree/bindings/bus/bcma.txt +9 -0
+The top-level axi bus may contain following children:
+
+- gpio: GPIO chip on the SoC
+
+  Required properties:
+  - compatible: "brcm,bus-gpio"
+  - gpio-controller : makes the node a GPIO controller
+  - #gpio-cells : size of the GPIO specifier, must be 2
+

I wonder if it would be better to avoid the subnode here and just make the parent itself the gpio controller.

Quoted 2 lines

Is the gpio controller part of the bus itself in reality, or is it a device that gets probed on the bus?

I'm not sure how to treat this chip.
We control GPIOs using ChipCommon regs (and ChipCommon is one of cores/devices on the bus), so you could also consider GPIO chip a sub-device of ChipCommon.
I believe every Broadcom bus has a GPIO chip. In the ancient (MIPS) times, even if we didn't have ChipCommon, there was an EXTIF core that used to provide access to the GPIO chip.

Quoted 3 lines

What do you think? Should I make it separated device, even it if depends on the SoC and its ChipCommon core (device)?

I would make GPIO a subdevive of chipcommon. The chipcommon core has an own IRQ which is also used for GPIO.

Hauke

author maintainer
#4 lore raw

PATCH 1/1 bcma: use device from DT (brcm, bus-gpio) for SoC GPIO chip

Quoted 2 lines · Hauke Mehrtens

I would make GPIO a subdevive of chipcommon. The chipcommon core has an own IRQ which is also used for GPIO.

Which ChipCommon do yo mean?
1) chipcommonA (compatible = "simple-bus")
2) chipcommon at 0 (child of axi at 18000000 AKA brcm,bus-axi)

It seems that for some reason both of them use IRQ 85, while the IRQ for ChipCommon is 117 I believe.

Signature · 1 line
Rafa?
#5 lore raw

PATCH 1/1 bcma: use device from DT (brcm,bus-gpio) for SoC GPIO chip

Quoted 7 lines · Rafa? Mi?ecki
Quoted 2 lines · Hauke Mehrtens

I would make GPIO a subdevive of chipcommon. The chipcommon core has an own IRQ which is also used for GPIO.

Which ChipCommon do yo mean?
1) chipcommonA (compatible = "simple-bus")
2) chipcommon at 0 (child of axi at 18000000 AKA brcm,bus-axi)

We should combine this (both are describing the same core) I added chipcommonA to get some serial without adding bcma support first. When we have dts support added to bcma, I would like to remove chipcommonA from dtsi and add a chipcommon as a child of axi.

Quoted 3 lines

It seems that for some reason both of them use IRQ 85, while the IRQ for ChipCommon is 117 I believe.

That's the same.

In the dtsi file it says:
interrupts = <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>;
this will result in the IRQ number 117, when it is GIC_SPI you have to add 32 to the irq number to get the actual number which will be given to request_irq().

Hauke

author maintainer
#6 lore raw

PATCH v2 1/1 bcma: use device from DT (brcm, bus-gpio) for SoC GPIO chip

In reply to Rafał Miłecki

This will allow us to define GPIO-attached devices (LEDs, buttons) in the the device tree.

---
This is based on top of
[PATCH v6] bcma: register bcma as device tree driver that I hope will reach wireless-next git tree.

V2: Describe axi chilren and make gpio a child of chipcommon core.

---
 Documentation/devicetree/bindings/bus/bcma.txt | 24 ++++++++++++++++++++++++
 drivers/bcma/driver_gpio.c                     |  5 +++++
 2 files changed, 29 insertions(+)
Documentation/devicetree/bindings/bus/bcma.txt +24 -0
index e9070c1..26ef4b7 100644
@@ -9,6 +9,22 @@ Required properties:
 The cores on the AXI bus are automatically detected by bcma with the
 memory ranges they are using and they get registered afterwards.
 
+The top-level axi bus may contain children representing attached cores
+(devices). This is needed since some hardware details can't be auto
+detected (e.g. IRQ numbers).
+
+There is also one special core called ChipCommon that may contain some
+extra sub-devices. This is because some devices (e.g. GPIO chip) are
+not standalone cores and can be access using ChipCommon regs only.
+Possible ChipCommon children:
+
+- gpio: GPIO chip on the SoC
+
+  Required properties:
+  - compatible: "brcm,bus-gpio"
+  - gpio-controller : makes the node a GPIO controller
+  - #gpio-cells : size of the GPIO specifier, must be 2
+
 Example:
 
 	axi at 18000000 {
@@ -17,4 +33,12 @@ Example:
 		ranges = <0x00000000 0x18000000 0x00100000>;
 		#address-cells = <1>;
 		#size-cells = <1>;
+
+		chipcommon at 0 {
+			gpio at 0 {
+				compatible = "brcm,bus-gpio";
+				gpio-controller;
+				#gpio-cells = <2>;
+			};
+		};
 	};
drivers/bcma/driver_gpio.c +5 -0
index 8ea497c..7ae39a8 100644
@@ -218,6 +218,11 @@ int bcma_gpio_init(struct bcma_drv_cc *cc)
 #if IS_BUILTIN(CONFIG_BCM47XX)
 	chip->to_irq		= bcma_gpio_to_irq;
 #endif
+#if IS_BUILTIN(CONFIG_OF)
+	if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
+		chip->of_node	= of_find_compatible_node(NULL, NULL,
+							  "brcm,bus-gpio");
+#endif
 	switch (cc->core->bus->chipinfo.id) {
 	case BCMA_CHIP_ID_BCM5357:
 	case BCMA_CHIP_ID_BCM53572:
Signature · 1 line
1.8.4.5
#7 lore raw

PATCH v2 1/1 bcma: use device from DT (brcm, bus-gpio) for SoC GPIO chip

Quoted 44 lines · On Sunday 28 September 2014 10:24:01 Rafa? Mi?ecki wrote:

This will allow us to define GPIO-attached devices (LEDs, buttons) in the the device tree.

---
This is based on top of
[PATCH v6] bcma: register bcma as device tree driver that I hope will reach wireless-next git tree.

V2: Describe axi chilren and make gpio a child of chipcommon core.

---
 Documentation/devicetree/bindings/bus/bcma.txt | 24 ++++++++++++++++++++++++
 drivers/bcma/driver_gpio.c                     |  5 +++++
 2 files changed, 29 insertions(+)
Documentation/devicetree/bindings/bus/bcma.txt +16 -0
index e9070c1..26ef4b7 100644
@@ -9,6 +9,22 @@ Required properties:
 The cores on the AXI bus are automatically detected by bcma with the
 memory ranges they are using and they get registered afterwards.
 
+The top-level axi bus may contain children representing attached cores
+(devices). This is needed since some hardware details can't be auto
+detected (e.g. IRQ numbers).
+
+There is also one special core called ChipCommon that may contain some
+extra sub-devices. This is because some devices (e.g. GPIO chip) are
+not standalone cores and can be access using ChipCommon regs only.
+Possible ChipCommon children:
+
+- gpio: GPIO chip on the SoC
+
+  Required properties:
+  - compatible: "brcm,bus-gpio"
+  - gpio-controller : makes the node a GPIO controller
+  - #gpio-cells : size of the GPIO specifier, must be 2
+
 Example:
 
 	axi at 18000000 {
@@ -17,4 +33,12 @@ Example:
 		ranges = <0x00000000 0x18000000 0x00100000>;

Documentation/devicetree/bindings/bus/bcma.txt Example: · line 43

Quoted 10 lines
Documentation/devicetree/bindings/bus/bcma.txt +8 -0
 		#address-cells = <1>;
 		#size-cells = <1>;
+
+		chipcommon at 0 {
+			gpio at 0 {
+				compatible = "brcm,bus-gpio";
+				gpio-controller;
+				#gpio-cells = <2>;
+			};
+		};

I think you should list the 'reg' property of the chipcommon area and make that match the unit address, rather than using '0', mostly for consistency.

Can you have multiple gpio areas in chipcommon? If not, I'd probably leave out the extra node and mark the chipcommon device itself as a 'gpio-controller'. It can also be other things at the same time, e.g. 'interrupt-controller' or provide things like pwms or pinctrl if that's what the hardware does. No need to have separate nodes for those if it's all the same register set.

Quoted 6 lines
Documentation/devicetree/bindings/bus/bcma.txt +0 -0
 	};
drivers/bcma/driver_gpio.c +0 -0
index 8ea497c..7ae39a8 100644

drivers/bcma/driver_gpio.c int bcma_gpio_init(struct bcma_drv_cc *cc) · line 225

Quoted 8 lines
drivers/bcma/driver_gpio.c +5 -0
@@ -218,6 +218,11 @@ int bcma_gpio_init(struct bcma_drv_cc *cc)
 #if IS_BUILTIN(CONFIG_BCM47XX)
 	chip->to_irq		= bcma_gpio_to_irq;
 #endif
+#if IS_BUILTIN(CONFIG_OF)
+	if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
+		chip->of_node	= of_find_compatible_node(NULL, NULL,
+							  "brcm,bus-gpio");
+#endif

Just commenting on the general style here, I think you can skip this step entirely, as mentioned above.

You should use C syntax here:

	if (IS_BUILTIN(CONFIG_OF) && cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC))
		chip->of_node = of_find_compatible_node(NULL, NULL, "brcm,bus-gpio");

If CONFIG_OF is not set, of_find_compatible_node() is turned into an inline function that returns NULL, so you probably don't even need that.

Finally, of_find_compatible_node() is a really slow operation, and "brcm,bus-gpio" is a much too generic name. If you need to look for something that is a child node, use something based on for_each_available_child_of_node().

Arnd

author maintainer
#8 lore raw

PATCH v2 1/1 bcma: use device from DT (brcm, bus-gpio) for SoC GPIO chip

Quoted 17 lines · Arnd Bergmann

Documentation/devicetree/bindings/bus/bcma.txt Example: · line 43

Quoted 12 lines · On Sunday 28 September 2014 10:24:01 Rafa? Mi?ecki wrote:
Documentation/devicetree/bindings/bus/bcma.txt +8 -0
@@ -17,4 +33,12 @@ Example:
              ranges = <0x00000000 0x18000000 0x00100000>;
              #address-cells = <1>;
              #size-cells = <1>;
+
+             chipcommon at 0 {
+                     gpio at 0 {
+                             compatible = "brcm,bus-gpio";
+                             gpio-controller;
+                             #gpio-cells = <2>;
+                     };
+             };

I think you should list the 'reg' property of the chipcommon area and make that match the unit address, rather than using '0', mostly for consistency.

Do you mean this chipcommon at 0? We propose this foo at offset syntax since V1 which was posted 1,5 month ago, it's nothing new.

Quoted 6 lines

Can you have multiple gpio areas in chipcommon? If not, I'd probably leave out the extra node and mark the chipcommon device itself as a 'gpio-controller'. It can also be other things at the same time, e.g. 'interrupt-controller' or provide things like pwms or pinctrl if that's what the hardware does. No need to have separate nodes for those if it's all the same register set.

OK

Quoted 13 lines

drivers/bcma/driver_gpio.c int bcma_gpio_init(struct bcma_drv_cc *cc) · line 225

Quoted 9 lines
drivers/bcma/driver_gpio.c +5 -0
@@ -218,6 +218,11 @@ int bcma_gpio_init(struct bcma_drv_cc *cc)
 #if IS_BUILTIN(CONFIG_BCM47XX)
      chip->to_irq            = bcma_gpio_to_irq;
 #endif
+#if IS_BUILTIN(CONFIG_OF)
+     if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
+             chip->of_node   = of_find_compatible_node(NULL, NULL,
+                                                       "brcm,bus-gpio");
+#endif

Just commenting on the general style here, I think you can skip this step entirely, as mentioned above.

Quoted 4 lines

You should use C syntax here:

        if (IS_BUILTIN(CONFIG_OF) && cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC))
                chip->of_node = of_find_compatible_node(NULL, NULL, "brcm,bus-gpio");

OK

Quoted 2 lines

If CONFIG_OF is not set, of_find_compatible_node() is turned into an inline function that returns NULL, so you probably don't even need that.

But I need to have of_node defined. Please check out "struct gpio_chip".

Quoted 3 lines

Finally, of_find_compatible_node() is a really slow operation, and "brcm,bus-gpio" is a much too generic name. If you need to look for something that is a child node, use something based on for_each_available_child_of_node().

Will see what I can do.

Signature · 1 line
Rafa?
#9 lore raw

PATCH v2 1/1 bcma: use device from DT (brcm, bus-gpio) for SoC GPIO chip

Quoted 19 lines · On Tuesday 30 September 2014 11:56:20 Rafa? Mi?ecki wrote:
Quoted 17 lines · Arnd Bergmann

Documentation/devicetree/bindings/bus/bcma.txt Example: · line 43

Quoted 12 lines · On Sunday 28 September 2014 10:24:01 Rafa? Mi?ecki wrote:
Documentation/devicetree/bindings/bus/bcma.txt +8 -0
@@ -17,4 +33,12 @@ Example:
              ranges = <0x00000000 0x18000000 0x00100000>;
              #address-cells = <1>;
              #size-cells = <1>;
+
+             chipcommon at 0 {
+                     gpio at 0 {
+                             compatible = "brcm,bus-gpio";
+                             gpio-controller;
+                             #gpio-cells = <2>;
+                     };
+             };

I think you should list the 'reg' property of the chipcommon area and make that match the unit address, rather than using '0', mostly for consistency.

Quoted 2 lines

Do you mean this chipcommon at 0? We propose this foo at offset syntax since V1 which was posted 1,5 month ago, it's nothing new.

Is 'chipcommon' at the start of the 0x18000000 range? If so, that's great, but it would still be good to have the 'reg' property in there explicitly.

Quoted 18 lines
Quoted 13 lines

drivers/bcma/driver_gpio.c int bcma_gpio_init(struct bcma_drv_cc *cc) · line 225

Quoted 9 lines
drivers/bcma/driver_gpio.c +5 -0
@@ -218,6 +218,11 @@ int bcma_gpio_init(struct bcma_drv_cc *cc)
 #if IS_BUILTIN(CONFIG_BCM47XX)
      chip->to_irq            = bcma_gpio_to_irq;
 #endif
+#if IS_BUILTIN(CONFIG_OF)
+     if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
+             chip->of_node   = of_find_compatible_node(NULL, NULL,
+                                                       "brcm,bus-gpio");
+#endif

Just commenting on the general style here, I think you can skip this step entirely, as mentioned above.

Quoted 4 lines

You should use C syntax here:

        if (IS_BUILTIN(CONFIG_OF) && cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC))
                chip->of_node = of_find_compatible_node(NULL, NULL, "brcm,bus-gpio");
Quoted 7 lines

OK

Quoted 2 lines

If CONFIG_OF is not set, of_find_compatible_node() is turned into an inline function that returns NULL, so you probably don't even need that.

But I need to have of_node defined. Please check out "struct gpio_chip".

I see. This is something we might want to change, but you don't need to bother with it now, so just leave this part as it is.

Quoted 5 lines
Quoted 3 lines

Finally, of_find_compatible_node() is a really slow operation, and "brcm,bus-gpio" is a much too generic name. If you need to look for something that is a child node, use something based on for_each_available_child_of_node().

Will see what I can do.

ok, thanks.

Arnd

author maintainer
#10 lore raw

PATCH v3 1/1 bcma: use device from DT (brcm, bus-chipcommon) for SoC GPIO chip

In reply to Rafał Miłecki

This will allow us to define GPIO-attached devices (LEDs, buttons) in the the device tree.

---
This is based on top of
[PATCH v6] bcma: register bcma as device tree driver that I hope will reach wireless-next git tree.

V2: Describe axi chilren and make gpio a child of chipcommon core.
V3: Make chipcommon a GPIO controller (avoid extra sub-child)
Speed up finding OF node in driver_gpio.c

---
 Documentation/devicetree/bindings/bus/bcma.txt | 13 +++++++++++++
 drivers/bcma/driver_gpio.c                     |  6 ++++++
 2 files changed, 19 insertions(+)
Documentation/devicetree/bindings/bus/bcma.txt +13 -0
index e9070c1..0538692 100644
@@ -9,6 +9,11 @@ Required properties:
 The cores on the AXI bus are automatically detected by bcma with the
 memory ranges they are using and they get registered afterwards.
 
+The top-level axi bus may contain children representing attached cores
+(devices). This is needed since some hardware details can't be auto
+detected (e.g. IRQ numbers). Also some of the cores may be responsible
+for extra things, e.g. ChipCommon providing access to the GPIO chip.
+
 Example:
 
 	axi at 18000000 {
@@ -17,4 +22,12 @@ Example:
 		ranges = <0x00000000 0x18000000 0x00100000>;
 		#address-cells = <1>;
 		#size-cells = <1>;
+
+		chipcommon {
+			compatible = "brcm,bus-chipcommon";
+			reg = <0x00000000 0x1000>;
+
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
 	};
drivers/bcma/driver_gpio.c +6 -0
index 8ea497c..28bdbe5 100644
@@ -218,6 +218,12 @@ int bcma_gpio_init(struct bcma_drv_cc *cc)
 #if IS_BUILTIN(CONFIG_BCM47XX)
 	chip->to_irq		= bcma_gpio_to_irq;
 #endif
+#if IS_BUILTIN(CONFIG_OF)
+	if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
+		chip->of_node	= of_find_compatible_node(
+					bus->host_pdev->dev.of_node, NULL,
+					"brcm,bus-chipcommon");
+#endif
 	switch (cc->core->bus->chipinfo.id) {
 	case BCMA_CHIP_ID_BCM5357:
 	case BCMA_CHIP_ID_BCM53572:
Signature · 1 line
1.8.4.5
#11 lore raw

PATCH v3 1/1 bcma: use device from DT (brcm, bus-chipcommon) for SoC GPIO chip

Quoted 12 lines · On Tuesday 30 September 2014 12:22:26 Rafa? Mi?ecki wrote:
Documentation/devicetree/bindings/bus/bcma.txt +5 -0
+The top-level axi bus may contain children representing attached cores
+(devices). This is needed since some hardware details can't be auto
+detected (e.g. IRQ numbers). Also some of the cores may be responsible
+for extra things, e.g. ChipCommon providing access to the GPIO chip.
+
 Example:
 
        axi at 18000000 {
@@ -17,4 +22,12 @@ Example:
                ranges = <0x00000000 0x18000000 0x00100000>;
                #address-cells = <1>;

Documentation/devicetree/bindings/bus/bcma.txt Example: · line 33

Quoted 10 lines
Documentation/devicetree/bindings/bus/bcma.txt +8 -0
                #size-cells = <1>;
+
+               chipcommon {
+                       compatible = "brcm,bus-chipcommon";
+                       reg = <0x00000000 0x1000>;
+
+                       gpio-controller;
+                       #gpio-cells = <2>;
+               };
        };

Looks good.

Quoted 5 lines
drivers/bcma/driver_gpio.c +0 -0
index 8ea497c..28bdbe5 100644

drivers/bcma/driver_gpio.c int bcma_gpio_init(struct bcma_drv_cc *cc) · line 227

Quoted 10 lines
drivers/bcma/driver_gpio.c +6 -0
@@ -218,6 +218,12 @@ int bcma_gpio_init(struct bcma_drv_cc *cc)
 #if IS_BUILTIN(CONFIG_BCM47XX)
        chip->to_irq            = bcma_gpio_to_irq;
 #endif
+#if IS_BUILTIN(CONFIG_OF)
+       if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
+               chip->of_node   = of_find_compatible_node(
+                                       bus->host_pdev->dev.of_node, NULL,
+                                       "brcm,bus-chipcommon");
+#endif
        switch (cc->core->bus->chipinfo.id) {

This doesn't: you are now searching through all nodes starting at the axi node rather than searching just through the children.

I think it would be better with the first change in place to set chip->of_node to cc->core->dev.of_node, and set that pointer in bcma_bus_scan by matching the 'reg' number. I think that is what an earlier version of the bcma DT support did in order to find the IRQs. We no longer need it for that purpose, but it seems like a good idea anyway, as I expect other bcma_devices to have similar requirements to add additional properties.

Arnd

author maintainer
#12 lore raw

PATCH v3 1/1 bcma: use device from DT (brcm, bus-chipcommon) for SoC GPIO chip

Quoted 16 lines · Arnd Bergmann

drivers/bcma/driver_gpio.c int bcma_gpio_init(struct bcma_drv_cc *cc) · line 227

Quoted 11 lines · On Tuesday 30 September 2014 12:22:26 Rafa? Mi?ecki wrote:
drivers/bcma/driver_gpio.c +6 -0
@@ -218,6 +218,12 @@ int bcma_gpio_init(struct bcma_drv_cc *cc)
 #if IS_BUILTIN(CONFIG_BCM47XX)
        chip->to_irq            = bcma_gpio_to_irq;
 #endif
+#if IS_BUILTIN(CONFIG_OF)
+       if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
+               chip->of_node   = of_find_compatible_node(
+                                       bus->host_pdev->dev.of_node, NULL,
+                                       "brcm,bus-chipcommon");
+#endif
        switch (cc->core->bus->chipinfo.id) {

This doesn't: you are now searching through all nodes starting at the axi node rather than searching just through the children.

Quoted 7 lines

I think it would be better with the first change in place to set chip->of_node to cc->core->dev.of_node, and set that pointer in bcma_bus_scan by matching the 'reg' number. I think that is what an earlier version of the bcma DT support did in order to find the IRQs. We no longer need it for that purpose, but it seems like a good idea anyway, as I expect other bcma_devices to have similar requirements to add additional properties.

Ohh, of course, I didn't notice that
[PATCH v6] bcma: register bcma as device tree driver
already contains bcma_of_fill_device. This will simplify my search a lot!

Signature · 1 line
Rafa?
author maintainer
#13 lore raw

PATCH v4 1/1 bcma: use chipcommon node from DT for SoC GPIO chip

In reply to Rafał Miłecki

This will allow us to define GPIO-attached devices (LEDs, buttons) in the the device tree.

---
This is based on top of
[PATCH v6] bcma: register bcma as device tree driver that I hope will reach wireless-next git tree.

V2: Describe axi chilren and make gpio a child of chipcommon core.
V3: Make chipcommon a GPIO controller (avoid extra sub-child)
Speed up finding OF node in driver_gpio.c
V4: Simplify setting of_node in driver_gpio.c

---
 Documentation/devicetree/bindings/bus/bcma.txt | 12 ++++++++++++
 drivers/bcma/driver_gpio.c                     |  4 ++++
 2 files changed, 16 insertions(+)
Documentation/devicetree/bindings/bus/bcma.txt +12 -0
index e9070c1..62a4834 100644
@@ -9,6 +9,11 @@ Required properties:
 The cores on the AXI bus are automatically detected by bcma with the
 memory ranges they are using and they get registered afterwards.
 
+The top-level axi bus may contain children representing attached cores
+(devices). This is needed since some hardware details can't be auto
+detected (e.g. IRQ numbers). Also some of the cores may be responsible
+for extra things, e.g. ChipCommon providing access to the GPIO chip.
+
 Example:
 
 	axi at 18000000 {
@@ -17,4 +22,11 @@ Example:
 		ranges = <0x00000000 0x18000000 0x00100000>;
 		#address-cells = <1>;
 		#size-cells = <1>;
+
+		chipcommon {
+			reg = <0x00000000 0x1000>;
+
+			gpio-controller;
+			#gpio-cells = <2>;
+		};
 	};
drivers/bcma/driver_gpio.c +4 -0
index 8ea497c..57ce5fe 100644
@@ -218,6 +218,10 @@ int bcma_gpio_init(struct bcma_drv_cc *cc)
 #if IS_BUILTIN(CONFIG_BCM47XX)
 	chip->to_irq		= bcma_gpio_to_irq;
 #endif
+#if IS_BUILTIN(CONFIG_OF)
+	if (cc->core->bus->hosttype == BCMA_HOSTTYPE_SOC)
+		chip->of_node	= cc->core->dev.of_node;
+#endif
 	switch (cc->core->bus->chipinfo.id) {
 	case BCMA_CHIP_ID_BCM5357:
 	case BCMA_CHIP_ID_BCM53572:
Signature · 1 line
1.8.4.5
#14 lore raw

PATCH v4 1/1 bcma: use chipcommon node from DT for SoC GPIO chip

Quoted 9 lines · On Tuesday 30 September 2014 12:55:48 Rafa? Mi?ecki wrote:

This will allow us to define GPIO-attached devices (LEDs, buttons) in the the device tree.

---
This is based on top of
[PATCH v6] bcma: register bcma as device tree driver that I hope will reach wireless-next git tree.

Quoted 5 lines

V2: Describe axi chilren and make gpio a child of chipcommon core.
V3: Make chipcommon a GPIO controller (avoid extra sub-child)
Speed up finding OF node in driver_gpio.c
V4: Simplify setting of_node in driver_gpio.c