bcma: register bcma as device tree driver
Subsystems (2)
PATCH v6 1/1 bcma: register bcma as device tree driver
This driver is used by the bcm53xx ARM SoC code. Now it is possible to give the address of the chipcommon core in device tree and bcma will search for all the other cores.
--- Documentation/devicetree/bindings/bus/bcma.txt | 20 +++++++ drivers/bcma/bcma_private.h | 14 +++++ drivers/bcma/host_soc.c | 81 ++++++++++++++++++++++++++ drivers/bcma/main.c | 52 ++++++++++++++++- include/linux/bcma/bcma.h | 2 + 5 files changed, 168 insertions(+), 1 deletion(-) create mode 100644 Documentation/devicetree/bindings/bus/bcma.txt
This is based on wireless-testing and should go into that tree.
changes since:
v5:
- send this patch without the other patch, I will still work on the other one.
v4:
- move the code adding the device tree to the child driver into this patch
- remove all references to irq from this patch
v3:
- remove .owner = THIS_MODULE,
v2:
- fix description
- use ranges dt in the example
- always define a empty implementation of bcma_host_soc_{un}register_driver() when it is build and remove some ifdefs
v1:
- renamed aix to axi
RFC:
- reworded the irq description
- improved the example
- hocked into bcma_modeinit() and bcma_modexit()
Documentation/devicetree/bindings/bus/bcma.txt new file +20 -0
@@ -0,0 +1,20 @@ +Driver for ARM AXI Bus with Broadcom Plugins (bcma) + +Required properties: + +- compatible : brcm,bus-axi + +- reg : iomem address range of chipcommon core + +The cores on the AXI bus are automatically detected by bcma with the +memory ranges they are using and they get registered afterwards. + +Example: + + axi at 18000000 { + compatible = "brcm,bus-axi"; + reg = <0x18000000 0x1000>; + ranges = <0x00000000 0x18000000 0x00100000>; + #address-cells = <1>; + #size-cells = <1>; + };
drivers/bcma/bcma_private.h +14 -0
@@ -88,6 +88,20 @@ extern int __init bcma_host_pci_init(void); extern void __exit bcma_host_pci_exit(void);#endif /* CONFIG_BCMA_HOST_PCI */ +/* host_soc.c */ +#if defined(CONFIG_BCMA_HOST_SOC ) && defined(CONFIG_OF ) +extern int __init bcma_host_soc_register_driver (void ); +extern void __exit bcma_host_soc_unregister_driver(void); +#else +static inline int __init bcma_host_soc_register_driver (void ) +{ +return 0 ; +} +static inline void __exit bcma_host_soc_unregister_driver(void) +{ +} +#endif /* CONFIG_BCMA_HOST_SOC && CONFIG_OF */ +/* driver_pci.c */ u32 bcma_pcie_read (struct bcma_drv_pci *pc,u32 address);
drivers/bcma/host_soc.c +81 -0
96 lines not on this page · raw message
drivers/bcma/main.c +51 -1
82 lines not on this page · raw message
include/linux/bcma/bcma.h +2 -0
@@ -323,6 +323,8 @@ struct bcma_bus {struct pci_dev *host_pci;/* Pointer to the SDIO device (only for BCMA_HOSTTYPE_SDIO) */ struct sdio_func *host_sdio; +/* Pointer to platform device (only for BCMA_HOSTTYPE_SOC) */ +struct platform_device *host_pdev; };struct bcma_chipinfo chipinfo;
Signature · 1 line
1.9.1
PATCH v6 1/1 bcma: register bcma as device tree driver
Quoted 5 lines · On Friday 26 September 2014 00:09:19 Hauke Mehrtens wrote:
This driver is used by the bcm53xx ARM SoC code. Now it is possible to give the address of the chipcommon core in device tree and bcma will search for all the other cores.
Signed-off-by Hauke Mehrtens <[email protected]>
I'm basically happy with this patch, so
A few details that I think are worth improving:
Quoted 16 lines
Documentation/devicetree/bindings/bus/bcma.txt new file +10
-0@@ -0,0 +1,20 @@ +Driver for ARM AXI Bus with Broadcom Plugins (bcma) + +Required properties: + +- compatible : brcm,bus-axi + +- reg : iomem address range of chipcommon core + +The cores on the AXI bus are automatically detected by bcma with the +memory ranges they are using and they get registered afterwards.
Documentation/devicetree/bindings/bus/bcma.txt line 20
Quoted 10 lines
Documentation/devicetree/bindings/bus/bcma.txt new file +10
-0+ +Example: + + axi at 18000000 { + compatible = "brcm,bus-axi"; + reg = <0x18000000 0x1000>; + ranges = <0x00000000 0x18000000 0x00100000>; + #address-cells = <1>; + #size-cells = <1>; + };
I think it would be good to document how you can specify child nodes here, and give one node as the example.
Documentation/devicetree/bindings/bus/bcma.txt
Quoted 4 lines
Documentation/devicetree/bindings/bus/bcma.txt new file +4
-0+ +#ifdef CONFIG_OF +static int bcma_host_soc_probe(struct platform_device *pdev) +{
We generally try to avoid #ifdef in device drivers, I think it would be trivial to avoid this one by moving the contents into a new file.
Quoted 4 lines
Documentation/devicetree/bindings/bus/bcma.txt new file +4
-0+ struct device *dev = &pdev->dev; + struct device_node *np = dev->of_node; + struct bcma_bus *bus; + int err;
Documentation/devicetree/bindings/bus/bcma.txt
Quoted 10 lines
Documentation/devicetree/bindings/bus/bcma.txt new file +10
-0+ + /* Alloc */ + bus = devm_kzalloc(dev, sizeof(*bus), GFP_KERNEL); + if (!bus) + return -ENOMEM; + + /* Map MMIO */ + bus->mmio = of_iomap(np, 0); + if (!bus->mmio) + return -ENOMEM;
this could use devm_ioremap_resource() to avoid the iounmap in the failu
Quoted 10 lines
Documentation/devicetree/bindings/bus/bcma.txt new file +10
-0+#ifdef CONFIG_OF +static struct device_node *bcma_of_find_child_device(struct platform_device *parent, + struct bcma_device *core) +{ + struct device_node *node; + u64 size; + const __be32 *reg; + + if (!parent || !parent->dev.of_node) + return NULL;
Documentation/devicetree/bindings/bus/bcma.txt
Quoted 10 lines
Documentation/devicetree/bindings/bus/bcma.txt new file +10
-0+ + for_each_child_of_node(parent->dev.of_node, node) { + reg = of_get_address(node, 0, &size, NULL); + if (!reg) + continue; + if (of_translate_address(node, reg) == core->addr) + return node; + } + return NULL; +}
I think this will compile into nothing if CONFIG_OF is disabled, so no need for the #ifdef.
Documentation/devicetree/bindings/bus/bcma.txt
Quoted 10 lines
Documentation/devicetree/bindings/bus/bcma.txt new file +10
-0+ +static void bcma_of_fill_device(struct platform_device *parent, + struct bcma_device *core) +{ + struct device_node *node; + + node = bcma_of_find_child_device(parent, core); + if (node) + core->dev.of_node = node; +}
and consequently, this function can be moved into the caller.
Arnd