Skip to contentSkip to conversation

bcma: populate bus DT subnodes as platform_device-s

PATCH New Rafał Miłecki 4 participants 10 messages Jun 28, 2015 – Aug 2, 2015 Broadcom specific amba driver (bcma)

lore
Share & tools
lore

Rafał Miłecki

author maintainer
#0 lore raw

PATCH 1/1 bcma: populate bus DT subnodes as platform_device-s

Our bus should allow defining children nodes as we may want to specify devices attached to the bus. This is required e.g. to specify NAND or ChipCommon cores and use bus's address and IRQ mappings.

---
 drivers/bcma/main.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/bcma/main.c +8 -0
index 9635f10..5912847 100644
@@ -12,6 +12,7 @@
 #include <linux/slab.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
+#include <linux/of_platform.h>
 
 MODULE_DESCRIPTION("Broadcom's specific AMBA driver");
 MODULE_LICENSE("GPL");
@@ -409,6 +410,13 @@ int bcma_bus_register(struct bcma_bus *bus)
 		bcma_core_pci_early_init(&bus->drv_pci[0]);
 	}
 
+	if (bus->host_pdev) {
+		struct device *dev = &bus->host_pdev->dev;
+
+		of_platform_populate(dev->of_node, of_default_bus_match_table,
+				     NULL, dev);
+	}
+
 	/* Cores providing flash access go before SPROM init */
 	list_for_each_entry(core, &bus->cores, list) {
 		if (bcma_is_core_needed_early(core->id.id))
Signature · 1 line
1.8.4.5
#1 lore raw

PATCH 1/1 bcma: populate bus DT subnodes as platform_device-s

Quoted 8 lines · Rafa? Mi?ecki

Our bus should allow defining children nodes as we may want to specify devices attached to the bus. This is required e.g. to specify NAND or ChipCommon cores and use bus's address and IRQ mappings.

---
 drivers/bcma/main.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Rafa? have you solved the IRQ problem? Is it possible to assign all the sub devices the same IRQ number as the chipcommon core?

author maintainer
#2 lore raw

PATCH 1/1 bcma: populate bus DT subnodes as platform_device-s

Quoted 5 lines · Hauke Mehrtens
Quoted 4 lines · Rafa? Mi?ecki

Our bus should allow defining children nodes as we may want to specify devices attached to the bus. This is required e.g. to specify NAND or ChipCommon cores and use bus's address and IRQ mappings.

Quoted 7 lines
Quoted 4 lines
---
 drivers/bcma/main.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Rafa? have you solved the IRQ problem? Is it possible to assign all the sub devices the same IRQ number as the chipcommon core?

Not yet. The only working solution I have so far is:

serial0: serial at 0300 {
        compatible = "ns16550";
        reg = <0x0300 0x100>;
        interrupt-parent = <&gic>;
        interrupts = <GIC_SPI 85 IRQ_TYPE_LEVEL_HIGH>;
        clock-frequency = <100000000>;
};

(plus adding compatible = "simple-bus" to the chipcommon).

Signature · 1 line
Rafa?
#3 lore raw

PATCH 1/1 bcma: populate bus DT subnodes as platform_device-s

In reply to Rafał Miłecki
Quoted 5 lines · Rafa? Mi?ecki

Our bus should allow defining children nodes as we may want to specify devices attached to the bus. This is required e.g. to specify NAND or ChipCommon cores and use bus's address and IRQ mappings.

Thanks, manually applied to wireless-drivers-next.git.

Signature · 1 line
Kalle Valo
author maintainer
#4 lore raw

PATCH 1/1 bcma: populate bus DT subnodes as platform_device-s

In reply to Rafał Miłecki
Quoted 22 lines · Rafa? Mi?ecki

Our bus should allow defining children nodes as we may want to specify devices attached to the bus. This is required e.g. to specify NAND or ChipCommon cores and use bus's address and IRQ mappings.

---
 drivers/bcma/main.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/bcma/main.c +1 -0
index 9635f10..5912847 100644
@@ -12,6 +12,7 @@
 #include <linux/slab.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
+#include <linux/of_platform.h>
 
 MODULE_DESCRIPTION("Broadcom's specific AMBA driver");
 MODULE_LICENSE("GPL");

drivers/bcma/main.c int bcma_bus_register(struct bcma_bus *bus) · line 419

Quoted 10 lines
drivers/bcma/main.c +7 -0
@@ -409,6 +410,13 @@ int bcma_bus_register(struct bcma_bus *bus)
                bcma_core_pci_early_init(&bus->drv_pci[0]);
        }
 
+       if (bus->host_pdev) {
+               struct device *dev = &bus->host_pdev->dev;
+
+               of_platform_populate(dev->of_node, of_default_bus_match_table,
+                                    NULL, dev);
+       }
+

This caused a compile error when using bcma as module:
ERROR: "of_default_bus_match_table" [drivers/bcma/bcma.ko] undefined!

There are two options I guess:
1) Export of_default_bus_match_table
2) Use some better condition like
if (IS_BUILTIN(CONFIG_BCMA) && bus->host_pdev)

Unfortunately I'm on my long holidays right now.

Hauke: do you think you can find a moment to handle this?

Sorry for the problem :|

Signature · 1 line
Rafa?
#5 lore raw

PATCH 1/1 bcma: populate bus DT subnodes as platform_device-s

Quoted 11 lines · Rafa? Mi?ecki

drivers/bcma/main.c int bcma_bus_register(struct bcma_bus *bus) · line 419

Quoted 7 lines
drivers/bcma/main.c +7 -0
+       if (bus->host_pdev) {
+               struct device *dev = &bus->host_pdev->dev;
+
+               of_platform_populate(dev->of_node, of_default_bus_match_table,
+                                    NULL, dev);
+       }
+

This caused a compile error when using bcma as module:
ERROR: "of_default_bus_match_table" [drivers/bcma/bcma.ko] undefined!

Quoted 8 lines

There are two options I guess:
1) Export of_default_bus_match_table
2) Use some better condition like
if (IS_BUILTIN(CONFIG_BCMA) && bus->host_pdev)

Unfortunately I'm on my long holidays right now.

Hauke: do you think you can find a moment to handle this?

I can cook up a patch which uses IS_BUILTIN() so that we get the build working again. You can fix this better once you come back.

Quoted 1 line

Sorry for the problem :|

No worries, enjoy your vacation :)

Signature · 1 line
Kalle Valo
#6 lore raw

PATCH 1/1 bcma: populate bus DT subnodes as platform_device-s

Quoted 12 lines · Kalle Valo
Quoted 10 lines · Rafa? Mi?ecki

drivers/bcma/main.c int bcma_bus_register(struct bcma_bus *bus) · line 419

Quoted 7 lines
drivers/bcma/main.c +7 -0
+       if (bus->host_pdev) {
+               struct device *dev = &bus->host_pdev->dev;
+
+               of_platform_populate(dev->of_node, of_default_bus_match_table,
+                                    NULL, dev);
+       }
+

This caused a compile error when using bcma as module:
ERROR: "of_default_bus_match_table" [drivers/bcma/bcma.ko] undefined!

I encountered the same problem with my modular memory controller driver.

Quoted 2 lines
Quoted 2 lines

There are two options I guess:
1) Export of_default_bus_match_table

See link below for Rob Herring's take on that.
http://marc.info/?l=linaro-kernel&m=143766694414121&w=2

regards,
Joachim Eastwood

#7 lore raw

PATCH 1/1 bcma: populate bus DT subnodes as platform_device-s

Quoted 19 lines · Joachim Eastwood
Quoted 12 lines · Kalle Valo
Quoted 10 lines · Rafa? Mi?ecki

drivers/bcma/main.c int bcma_bus_register(struct bcma_bus *bus) · line 419

Quoted 7 lines
drivers/bcma/main.c +7 -0
+       if (bus->host_pdev) {
+               struct device *dev = &bus->host_pdev->dev;
+
+               of_platform_populate(dev->of_node, of_default_bus_match_table,
+                                    NULL, dev);
+       }
+

This caused a compile error when using bcma as module:
ERROR: "of_default_bus_match_table" [drivers/bcma/bcma.ko] undefined!

I encountered the same problem with my modular memory controller driver.

Quoted 2 lines
Quoted 2 lines

There are two options I guess:
1) Export of_default_bus_match_table

Quoted 7 lines

See link below for Rob Herring's take on that.
http://marc.info/?l=linaro-kernel&m=143766694414121&w=2

regards,
Joachim Eastwood

Hi Joachim,

are you working on a patch which exports "of_default_bus_match_table" or provides a wrapper function? If not then I will look into this. My current plan for bcma is just to deactivate this when it is build as a module as a temporary workaround

Hauke

#8 lore raw

PATCH 1/1 bcma: populate bus DT subnodes as platform_device-s

Quoted 24 lines · Hauke Mehrtens
Quoted 23 lines · Joachim Eastwood
Quoted 12 lines · Kalle Valo
Quoted 10 lines · Rafa? Mi?ecki

drivers/bcma/main.c int bcma_bus_register(struct bcma_bus *bus) · line 419

Quoted 7 lines
drivers/bcma/main.c +7 -0
+       if (bus->host_pdev) {
+               struct device *dev = &bus->host_pdev->dev;
+
+               of_platform_populate(dev->of_node, of_default_bus_match_table,
+                                    NULL, dev);
+       }
+

This caused a compile error when using bcma as module:
ERROR: "of_default_bus_match_table" [drivers/bcma/bcma.ko] undefined!

I encountered the same problem with my modular memory controller driver.

Quoted 2 lines
Quoted 2 lines

There are two options I guess:
1) Export of_default_bus_match_table

See link below for Rob Herring's take on that.
http://marc.info/?l=linaro-kernel&m=143766694414121&w=2

Quoted 7 lines
Quoted 3 lines

regards,
Joachim Eastwood

Hi Joachim,

are you working on a patch which exports "of_default_bus_match_table" or provides a wrapper function? If not then I will look into this.

Not really, so if you could take it that would be great. Thanks.

regards,
Joachim Eastwood

#9 lore raw

PATCH 1/1 bcma: populate bus DT subnodes as platform_device-s

In reply to Rafał Miłecki
Quoted 22 lines · Rafa? Mi?ecki

Our bus should allow defining children nodes as we may want to specify devices attached to the bus. This is required e.g. to specify NAND or ChipCommon cores and use bus's address and IRQ mappings.

---
 drivers/bcma/main.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/bcma/main.c +1 -0
index 9635f10..5912847 100644
@@ -12,6 +12,7 @@
 #include <linux/slab.h>
 #include <linux/of_address.h>
 #include <linux/of_irq.h>
+#include <linux/of_platform.h>
 
 MODULE_DESCRIPTION("Broadcom's specific AMBA driver");
 MODULE_LICENSE("GPL");

drivers/bcma/main.c int bcma_bus_register(struct bcma_bus *bus) · line 413

Quoted 4 lines
drivers/bcma/main.c +1 -0
@@ -409,6 +410,13 @@ int bcma_bus_register(struct bcma_bus *bus)
 		bcma_core_pci_early_init(&bus->drv_pci[0]);
 	}
 
+	if (bus->host_pdev) {

Here is an other problem. So many bugs in this line. ;-) host_pdev is in a union so this is also true for PCIe devices, but then the offset of the dev structure probably is wrong. You should check for the hosttype. I will send a patch.

Quoted 10 lines
drivers/bcma/main.c +6 -0
+		struct device *dev = &bus->host_pdev->dev;
+
+		of_platform_populate(dev->of_node, of_default_bus_match_table,
+				     NULL, dev);
+	}
+
 	/* Cores providing flash access go before SPROM init */
 	list_for_each_entry(core, &bus->cores, list) {
 		if (bcma_is_core_needed_early(core->id.id))