Versatile PCI DT support
cover Versatile PCI DT support
From: Rob Herring <[email protected]>
This series adds a platform driver for Versatile PB's PCI host using Liviu's recent patch series[1] for DT parsing and setup.
The first patch is a hack to get Liviu's current patches to work on ARM. It at least shows we are not that far off from being able to use the series on ARM.
I've tested PCI under QEMU, but need someone with actual h/w to test. A branch with this series and which includes full conversion of Versatile to DT is available here[2].
Rob
[1] https://lkml.org/lkml/2014/3/14/279
[2] git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git versatile
Rob Herring (3):
ARM: hackup pcibios support for commmon bridge code dt/bindings: add versatile PCI binding
pci: add DT based ARM Versatile PCI host driver
.../devicetree/bindings/pci/versatile.txt | 59 +++++ arch/arm/kernel/bios32.c | 63 +++++ drivers/pci/host/Kconfig | 4 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pci-versatile.c | 275 +++++++++++++++++++++ 5 files changed, 402 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/versatile.txt create mode 100644 drivers/pci/host/pci-versatile.c
Signature · 1 line
1.8.3.2
PATCH 1/3 ARM: hackup pcibios support for commmon bridge code
From: Rob Herring <[email protected]>
--- arch/arm/kernel/bios32.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+)
arch/arm/kernel/bios32.c +63 -0
@@ -11,6 +11,7 @@#include <linux/slab.h> #include <linux/init.h> #include <linux/io.h> +#include <linux/of_pci.h> #include <asm/mach-types.h> #include <asm/mach/map.h>
@@ -337,6 +338,15 @@ void pcibios_fixup_bus(struct pci_bus *bus)list_for_each_entry (dev, &bus->devices, bus_list) {u16 cmd; +/* Ignore fully discovered devices */ +if (dev->is_added) +continue ; + +set_dev_node (&dev->dev,pcibus_to_node (dev->bus)); + +/* Read default IRQs and fixup if necessary */ + dev->irq =of_irq_parse_and_map_pci (dev,0 ,0 ); +pci_read_config_word (dev,PCI_COMMAND , &cmd); cmd |= features;pci_write_config_word (dev,PCI_COMMAND , cmd);
@@ -681,3 +691,56 @@ void __init pci_map_io_early(unsigned long pfn) pci_io_desc.pfn = pfn;iotable_init (&pci_io_desc,1 ); } + +struct ioresource { +struct list_head list; +phys_addr_t start; +resource_size_t size; +}; + +static LIST_HEAD (io_list); + +int pci_register_io_range (phys_addr_t address,resource_size_t size) +{ +struct ioresource *res; +resource_size_t allocated_size =0 ; + +/* find if the range has not been already allocated */ +list_for_each_entry (res, &io_list, list) { +if (address >= res->start && + address + size <= res->start + size) +return 0 ; + allocated_size += res->size; + } + +/* range not already registered, check for space */ +if (allocated_size + size >IO_SPACE_LIMIT ) +return -E2BIG ; + +/* add the range in the list */ + res =kzalloc (sizeof (*res),GFP_KERNEL ); +if (!res) +return -ENOMEM ; + res->start = address; + res->size = size; + +list_add_tail (&res->list, &io_list); + +return 0 ; +} +EXPORT_SYMBOL_GPL (pci_register_io_range); + +unsigned long pci_address_to_pio (phys_addr_t address) +{ +struct ioresource *res; + +list_for_each_entry (res, &io_list, list) { +if (address >= res->start && + address < res->start + res->size) { +return res->start - address; + } + } + +return (unsigned long )-1 ; +} +EXPORT_SYMBOL_GPL (pci_address_to_pio);
Signature · 1 line
1.8.3.2
Bjorn Helgaas
maintainerPATCH 1/3 ARM: hackup pcibios support for commmon bridge code
Quoted 20 lines · Rob Herring
From: Rob Herring <[email protected]>
Signed-off-by Rob Herring <[email protected]>--- arch/arm/kernel/bios32.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+)arch/arm/kernel/bios32.c +1
-0@@ -11,6 +11,7 @@#include <linux/slab.h> #include <linux/init.h> #include <linux/io.h> +#include <linux/of_pci.h> #include <asm/mach-types.h> #include <asm/mach/map.h>
arch/arm/kernel/bios32.c void pcibios_fixup_bus(struct pci_bus *bus) · line 345
Quoted 8 lines
arch/arm/kernel/bios32.c +5
-0@@ -337,6 +338,15 @@ void pcibios_fixup_bus(struct pci_bus *bus)list_for_each_entry (dev, &bus->devices, bus_list) {u16 cmd; +/* Ignore fully discovered devices */ +if (dev->is_added) +continue ; + +set_dev_node (&dev->dev,pcibus_to_node (dev->bus));
We already do this in pci_device_add(); why do we need it here, too?
arch/arm/kernel/bios32.c void pcibios_fixup_bus(struct pci_bus *bus) · line 348
Quoted 2 lines
arch/arm/kernel/bios32.c +2
-0+/* Read default IRQs and fixup if necessary */ + dev->irq =of_irq_parse_and_map_pci (dev,0 ,0 );
Could this be done in pcibios_enable_device() or some other per-device interface()? I'd like to get rid of pcibios_fixup_bus() eventually.
Quoted 50 lines
arch/arm/kernel/bios32.c +43
-0pci_read_config_word (dev,PCI_COMMAND , &cmd); cmd |= features;pci_write_config_word (dev,PCI_COMMAND , cmd);@@ -681,3 +691,56 @@ void __init pci_map_io_early(unsigned long pfn) pci_io_desc.pfn = pfn;iotable_init (&pci_io_desc,1 ); } + +struct ioresource { +struct list_head list; +phys_addr_t start; +resource_size_t size; +}; + +static LIST_HEAD (io_list); + +int pci_register_io_range (phys_addr_t address,resource_size_t size) +{ +struct ioresource *res; +resource_size_t allocated_size =0 ; + +/* find if the range has not been already allocated */ +list_for_each_entry (res, &io_list, list) { +if (address >= res->start && + address + size <= res->start + size) +return 0 ; + allocated_size += res->size; + } + +/* range not already registered, check for space */ +if (allocated_size + size >IO_SPACE_LIMIT ) +return -E2BIG ; + +/* add the range in the list */ + res =kzalloc (sizeof (*res),GFP_KERNEL ); +if (!res) +return -ENOMEM ; + res->start = address; + res->size = size; + +list_add_tail (&res->list, &io_list); + +return 0 ; +} +EXPORT_SYMBOL_GPL (pci_register_io_range); + +unsigned long pci_address_to_pio (phys_addr_t address) +{ +struct ioresource *res; +
arch/arm/kernel/bios32.c void __init pci_map_io_early(unsigned long pfn) · line 746
Quoted 10 lines
arch/arm/kernel/bios32.c +10
-0+list_for_each_entry (res, &io_list, list) { +if (address >= res->start && + address < res->start + res->size) { +return res->start - address; + } + } + +return (unsigned long )-1 ; +} +EXPORT_SYMBOL_GPL (pci_address_to_pio);
ISTR some discussion about this, so maybe this has already been addressed, but it doesn't seem right to export generically-named symbols like these from the ARM arch code. And they don't look very ARM-specific.
Bjorn
PATCH 1/3 ARM: hackup pcibios support for commmon bridge code
Quoted 24 lines · Bjorn Helgaas
Quoted 23 lines · Rob Herring
From: Rob Herring <[email protected]>
Signed-off-by Rob Herring <[email protected]>--- arch/arm/kernel/bios32.c | 63 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+)arch/arm/kernel/bios32.c +1
-0@@ -11,6 +11,7 @@#include <linux/slab.h> #include <linux/init.h> #include <linux/io.h> +#include <linux/of_pci.h> #include <asm/mach-types.h> #include <asm/mach/map.h> @@ -337,6 +338,15 @@ void pcibios_fixup_bus(struct pci_bus *bus)list_for_each_entry (dev, &bus->devices, bus_list) {u16 cmd;
Quoted 7 lines
arch/arm/kernel/bios32.c void pcibios_fixup_bus(struct pci_bus *bus) · line 345
Quoted 5 lines
arch/arm/kernel/bios32.c +5
-0+/* Ignore fully discovered devices */ +if (dev->is_added) +continue ; + +set_dev_node (&dev->dev,pcibus_to_node (dev->bus));We already do this in
pci_device_add(); why do we need it here, too?
Because it was in the arm64 code. I'm not really sure.
Quoted 5 lines
arch/arm/kernel/bios32.c void pcibios_fixup_bus(struct pci_bus *bus) · line 348
Quoted 2 lines
arch/arm/kernel/bios32.c +2
-0+/* Read default IRQs and fixup if necessary */ + dev->irq =of_irq_parse_and_map_pci (dev,0 ,0 );Could this be done in
pcibios_enable_device()or some other per-deviceinterface()? I'd like to get rid ofpcibios_fixup_bus()eventually.
Probably. This should return NO_IRQ in the !OF case. We'd need to make sure that works.
I had a loop at pcibios_fixup_bus across architectures and could make no sense of why things were done in here. It all seemed a bit random and left me with questions like shouldn't something always be needed. Probably a lot of pieces are redundant now that didn't use to be. It needs someone that knows more about PCI than me to look at.
Quoted 56 lines
Quoted 56 lines
arch/arm/kernel/bios32.c +49
-0pci_read_config_word (dev,PCI_COMMAND , &cmd); cmd |= features;pci_write_config_word (dev,PCI_COMMAND , cmd);@@ -681,3 +691,56 @@ void __init pci_map_io_early(unsigned long pfn) pci_io_desc.pfn = pfn;iotable_init (&pci_io_desc,1 ); } + +struct ioresource { +struct list_head list; +phys_addr_t start; +resource_size_t size; +}; + +static LIST_HEAD (io_list); + +int pci_register_io_range (phys_addr_t address,resource_size_t size) +{ +struct ioresource *res; +resource_size_t allocated_size =0 ; + +/* find if the range has not been already allocated */ +list_for_each_entry (res, &io_list, list) { +if (address >= res->start && + address + size <= res->start + size) +return 0 ; + allocated_size += res->size; + } + +/* range not already registered, check for space */ +if (allocated_size + size >IO_SPACE_LIMIT ) +return -E2BIG ; + +/* add the range in the list */ + res =kzalloc (sizeof (*res),GFP_KERNEL ); +if (!res) +return -ENOMEM ; + res->start = address; + res->size = size; + +list_add_tail (&res->list, &io_list); + +return 0 ; +} +EXPORT_SYMBOL_GPL (pci_register_io_range); + +unsigned long pci_address_to_pio (phys_addr_t address) +{ +struct ioresource *res; + +list_for_each_entry (res, &io_list, list) { +if (address >= res->start && + address < res->start + res->size) { +return res->start - address; + } + }
Quoted 8 lines
arch/arm/kernel/bios32.c void __init pci_map_io_early(unsigned long pfn) · line 746
Quoted 4 lines
arch/arm/kernel/bios32.c +4
-0+ +return (unsigned long )-1 ; +} +EXPORT_SYMBOL_GPL (pci_address_to_pio);ISTR some discussion about this, so maybe this has already been addressed, but it doesn't seem right to export generically-named symbols like these from the ARM arch code. And they don't look very ARM-specific.
Right, I expect these to go away with Liviu's the next version.
Rob
PATCH 2/3 dt/bindings: add versatile PCI binding
In reply to Rob HerringFrom: Rob Herring <[email protected]>
Add binding documentation for the PCI controller found on Versatile PB boards.
--- .../devicetree/bindings/pci/versatile.txt | 59 ++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/versatile.txt
Documentation/devicetree/bindings/pci/versatile.txt new file +59 -0
@@ -0,0 +1,59 @@ +* ARM Versatile Platform Baseboard PCI interface + +PCI host controller found on the ARM Versatile PB board's FPGA. + +Required properties: +- compatible: should contain "arm,versatile-pci" to identify the Versatile PCI + controller. +- reg: base addresses and lengths of the pci controller. There must be 3 + entries: + - Versatile specific registers + - Self Config space + - Config space +- #address-cells: set to <3> +- #size-cells: set to <2> +- device_type: set to "pci" +- bus-range: set to <0 0xff> +- ranges: ranges for the PCI memory and I/O regions +- #interrupt-cells: set to <1> +- interrupt-map-mask and interrupt-map: standard PCI properties to define + the mapping of the PCI interface to interrupt numbers. + +Example: + +pci-controller at 10001000 { + compatible = "arm,versatile-pci"; + device_type = "pci"; + reg = <0x10001000 0x1000 + 0x41000000 0x10000 + 0x42000000 0x100000>; + bus-range = <0 0xff>; + #address-cells = <3>; + #size-cells = <2>; + #interrupt-cells = <1>; + + ranges = <0x01000000 0 0x00000000 0x43000000 0 0x00010000 /* downstream I/O */ + 0x02000000 0 0x50000000 0x50000000 0 0x10000000 /* non-prefetchable memory */ + 0x42000000 0 0x60000000 0x60000000 0 0x10000000>; /* prefetchable memory */ + + interrupt-map-mask = <0x1800 0 0 7>; + interrupt-map = <0x1800 0 0 1 &sic 28 + 0x1800 0 0 2 &sic 29 + 0x1800 0 0 3 &sic 30 + 0x1800 0 0 4 &sic 27 + + 0x1000 0 0 1 &sic 27 + 0x1000 0 0 2 &sic 28 + 0x1000 0 0 3 &sic 29 + 0x1000 0 0 4 &sic 30 + + 0x0800 0 0 1 &sic 30 + 0x0800 0 0 2 &sic 27 + 0x0800 0 0 3 &sic 28 + 0x0800 0 0 4 &sic 29 + + 0x0000 0 0 1 &sic 29 + 0x0000 0 0 2 &sic 30 + 0x0000 0 0 3 &sic 27 + 0x0000 0 0 4 &sic 28>; +};
Signature · 1 line
1.8.3.2
PATCH 3/3 pci: add DT based ARM Versatile PCI host driver
In reply to Rob HerringFrom: Rob Herring <[email protected]>
This converts the Versatile PCI host code to a platform driver using of_create_pci_host_bridge for parsing DT and setup.
I think more of this setup could be done by the core code. There are accesses to the host's config space (accesses using local_pci_cfg_base) which seem like they could be done by the core code or using standard config space accessors. The problem is bridge->bus->self is needed, but it does not get setup. I'm not exactly sure how that should work.
--- drivers/pci/host/Kconfig | 4 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pci-versatile.c | 275 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 280 insertions(+) create mode 100644 drivers/pci/host/pci-versatile.c
drivers/pci/host/Kconfig +4 -0
@@ -33,4 +33,8 @@ config PCI_RCAR_GEN2 There are 3 internal PCI controllers available with a single built-in EHCI/OHCI host controller present on each one. +config PCI_VERSATILE + bool "ARM Versatile PB PCI controller" + depends on ARCH_VERSATILE + endmenu
drivers/pci/host/Makefile +1 -0
@@ -4,3 +4,4 @@ obj-$(CONFIG_PCI_IMX6) += pci-imx6.o obj-$(CONFIG_PCI_MVEBU) += pci-mvebu.o obj-$(CONFIG_PCI_TEGRA) += pci-tegra.o obj-$(CONFIG_PCI_RCAR_GEN2) += pci-rcar-gen2.o +obj-$(CONFIG_PCI_VERSATILE) += pci-versatile.o
drivers/pci/host/pci-versatile.c new file +275 -0
275 lines not on this page · raw message
Signature · 1 line
1.8.3.2
Bjorn Helgaas
maintainerPATCH 3/3 pci: add DT based ARM Versatile PCI host driver
Quoted 30 lines · Rob Herring
From: Rob Herring <[email protected]>
This converts the Versatile PCI host code to a platform driver using
of_create_pci_host_bridgefor parsing DT and setup.I think more of this setup could be done by the core code. There are accesses to the host's config space (accesses using
local_pci_cfg_base) which seem like they could be done by the core code or using standard config space accessors. The problem isbridge->bus->selfis needed, but it does not get setup. I'm not exactly sure how that should work.Signed-off-by Rob Herring <[email protected]>Cc Bjorn Helgaas <[email protected]>...
drivers/pci/host/pci-versatile.c new file +15
-0+static int versatile_pci_probe (struct platform_device *pdev) +{ +struct resource *res; +int ret, i, mem =1 , myslot =-1 ; +unsigned int lastbus; +u32 val; +struct pci_host_bridge *bridge; +void __iomem *local_pci_cfg_base; + + res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); +if (!res) +return -ENODEV ; + versatile_pci_base =devm_ioremap_resource (&pdev->dev, res); + + res =platform_get_resource (pdev,IORESOURCE_MEM ,1 );
drivers/pci/host/pci-versatile.c line 178
Quoted 10 lines
drivers/pci/host/pci-versatile.c new file +10
-0+if (!res) +return -ENODEV ; + versatile_cfg_base[0 ] =devm_ioremap_resource (&pdev->dev, res); + + res =platform_get_resource (pdev,IORESOURCE_MEM ,2 ); +if (!res) +return -ENODEV ; + versatile_cfg_base[1 ] =devm_ioremap_resource (&pdev->dev, res); + + bridge =of_create_pci_host_bridge (&pdev->dev, &pci_versatile_ops, &sys);
Are we still relying on the PCI core to default to a bus number range of 00-ff? Can we not do that?
Bjorn
PATCH 3/3 pci: add DT based ARM Versatile PCI host driver
Quoted 12 lines · Bjorn Helgaas
Quoted 11 lines · Rob Herring
From: Rob Herring <[email protected]>
This converts the Versatile PCI host code to a platform driver using
of_create_pci_host_bridgefor parsing DT and setup.I think more of this setup could be done by the core code. There are accesses to the host's config space (accesses using
local_pci_cfg_base) which seem like they could be done by the core code or using standard config space accessors. The problem isbridge->bus->selfis needed, but it does not get setup. I'm not exactly sure how that should work.
Quoted 8 lines
Quoted 5 lines
Signed-off-by Rob Herring <[email protected]>Cc Bjorn Helgaas <[email protected]>...
+ bridge =
of_create_pci_host_bridge(&pdev->dev, &pci_versatile_ops, &sys);Are we still relying on the PCI core to default to a bus number range of 00-ff? Can we not do that?
No, that comes from DT.
Rob
Bjorn Helgaas
maintainerPATCH 3/3 pci: add DT based ARM Versatile PCI host driver
Quoted 17 lines · Rob Herring
Quoted 15 lines · Bjorn Helgaas
Quoted 14 lines · Rob Herring
From: Rob Herring <[email protected]>
This converts the Versatile PCI host code to a platform driver using
of_create_pci_host_bridgefor parsing DT and setup.I think more of this setup could be done by the core code. There are accesses to the host's config space (accesses using
local_pci_cfg_base) which seem like they could be done by the core code or using standard config space accessors. The problem isbridge->bus->selfis needed, but it does not get setup. I'm not exactly sure how that should work.Signed-off-by Rob Herring <[email protected]>Cc Bjorn Helgaas <[email protected]>...
Quoted 6 lines
Quoted 4 lines
Quoted 1 line
+ bridge =
of_create_pci_host_bridge(&pdev->dev, &pci_versatile_ops, &sys);Are we still relying on the PCI core to default to a bus number range of 00-ff? Can we not do that?
No, that comes from DT.
Oh, good. That's done inside of_create_pci_host_bridge(), then? (I haven't looked at that code.)
Bjorn
cover Versatile PCI DT support
In reply to Rob HerringQuoted 5 lines · Rob Herring
From: Rob Herring <[email protected]>
This series adds a platform driver for Versatile PB's PCI host using Liviu's recent patch series[1] for DT parsing and setup.
Quoted 7 lines
The first patch is a hack to get Liviu's current patches to work on ARM. It at least shows we are not that far off from being able to use the series on ARM.
I've tested PCI under QEMU, but need someone with actual h/w to test. A branch with this series and which includes full conversion of Versatile to DT is available here[2].
Hi Rob,
Thanks for doing this. Hopefully others will take inspiration and start to convert their host bridge controllers as well.
I will post an updated series soon. (Un)fortunately it will look slightly different than the last one I've posted as I am trying to get more code that I've currently placed in arch/arm64/kernel/pci.c into drivers/pci, so you will need to revisit your series.
Regarding your comment about bridge->bus->self being needed: root busses are supposed to have bus->self == NULL, and the bridge->bus *is* the root bus. Where would you need to use bridge->bus->self?
Best regards,
Liviu
Quoted 24 lines
Rob
[1] https://lkml.org/lkml/2014/3/14/279
[2]git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.gitversatileRob Herring (3):
ARM: hackup pcibios support for commmon bridge code dt/bindings: add versatile PCI binding
pci: add DT based ARM Versatile PCI host driver.../devicetree/bindings/pci/versatile.txt | 59 +++++ arch/arm/kernel/bios32.c | 63 +++++ drivers/pci/host/Kconfig | 4 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pci-versatile.c | 275 +++++++++++++++++++++ 5 files changed, 402 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/versatile.txt create mode 100644 drivers/pci/host/pci-versatile.cSignature · 1 line
1.8.3.2
Signature · 8 lines
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
?\_(?)_/?Quoted 19 lines · Liviu Dudau
Quoted 5 lines · Rob Herring
From: Rob Herring <[email protected]>
This series adds a platform driver for Versatile PB's PCI host using Liviu's recent patch series[1] for DT parsing and setup.
Quoted 7 lines
The first patch is a hack to get Liviu's current patches to work on ARM. It at least shows we are not that far off from being able to use the series on ARM.
I've tested PCI under QEMU, but need someone with actual h/w to test. A branch with this series and which includes full conversion of Versatile to DT is available here[2].
Hi Rob,
Thanks for doing this. Hopefully others will take inspiration and start to convert their host bridge controllers as well.
Quoted 8 lines
I will post an updated series soon. (Un)fortunately it will look slightly different than the last one I've posted as I am trying to get more code that I've currently placed in
arch/arm64/kernel/pci.cintodrivers/pci, so you will need to revisit your series.Regarding your comment about
bridge->bus->selfbeing needed: root busses are supposed to havebus->self== NULL, and thebridge->bus*is* the root bus. Where would you need to usebridge->bus->self?
If I want to use pci_write_config_* accesses, then I need a struct pci_dev pointer for the host. I can get this since I know the slot of the host, but only after pci_bus_add_devices which is perhaps too late. Historically, the Versatile PCI driver has blocked config accesses to the host's config space. I'm just wondering if this is really correct behavior and whether the core code should do the setup. This is setup that is done which doesn't seem like it is very specific to Versatile.
local_pci_cfg_base = versatile_cfg_base[1] + (myslot << 11);
val = readl(local_pci_cfg_base + CSR_OFFSET);
val |= PCI_COMMAND_MEMORY | PCI_COMMAND_MASTER | PCI_COMMAND_INVALIDATE; writel(val, local_pci_cfg_base + CSR_OFFSET);
/*
* Configure the PCI inbound memory windows to be 1:1 mapped to SDRAM */writel(PHYS_OFFSET, local_pci_cfg_base + PCI_BASE_ADDRESS_0); writel(PHYS_OFFSET, local_pci_cfg_base + PCI_BASE_ADDRESS_1); writel(PHYS_OFFSET, local_pci_cfg_base + PCI_BASE_ADDRESS_2);
Rob
Quoted 29 lines · Rob Herring
Quoted 19 lines · Liviu Dudau
Quoted 5 lines · Rob Herring
From: Rob Herring <[email protected]>
This series adds a platform driver for Versatile PB's PCI host using Liviu's recent patch series[1] for DT parsing and setup.
Quoted 7 lines
The first patch is a hack to get Liviu's current patches to work on ARM. It at least shows we are not that far off from being able to use the series on ARM.
I've tested PCI under QEMU, but need someone with actual h/w to test. A branch with this series and which includes full conversion of Versatile to DT is available here[2].
Hi Rob,
Thanks for doing this. Hopefully others will take inspiration and start to convert their host bridge controllers as well.
Quoted 8 lines
I will post an updated series soon. (Un)fortunately it will look slightly different than the last one I've posted as I am trying to get more code that I've currently placed in
arch/arm64/kernel/pci.cintodrivers/pci, so you will need to revisit your series.Regarding your comment about
bridge->bus->selfbeing needed: root busses are supposed to havebus->self== NULL, and thebridge->bus*is* the root bus. Where would you need to usebridge->bus->self?
Quoted 6 lines
If I want to use pci_write_config_* accesses, then I need a struct
pci_devpointer for the host. I can get this since I know the slot of the host, but only afterpci_bus_add_deviceswhich is perhaps too late. Historically, the Versatile PCI driver has blocked config accesses to the host's config space. I'm just wondering if this is really correct behavior and whether the core code should do the setup.
PCI core? It knows nothing of the Versatile registers. Versatile core code? Maybe.
Quoted 8 lines
This is setup that is done which doesn't seem like it is very specific to Versatile.
local_pci_cfg_base= versatile_cfg_base[1] + (myslot << 11);val =
readl(local_pci_cfg_base + CSR_OFFSET);
val |=PCI_COMMAND_MEMORY|PCI_COMMAND_MASTER|PCI_COMMAND_INVALIDATE;writel(val, local_pci_cfg_base + CSR_OFFSET);
Why don't you do this in a versatile_fixup_bridge() call, like pci-tegra.c does?
Quoted 7 lines
/*
* Configure the PCI inbound memory windows to be 1:1 mapped to SDRAM */writel(PHYS_OFFSET, local_pci_cfg_base + PCI_BASE_ADDRESS_0);writel(PHYS_OFFSET, local_pci_cfg_base + PCI_BASE_ADDRESS_1);writel(PHYS_OFFSET, local_pci_cfg_base + PCI_BASE_ADDRESS_2);
My guess is that this has to be done at probe time. It just happens that for Versatile PCI they live in the host config space, but they are not really PCI config space writes.
Best regards,
Liviu
Quoted 8 lines
Rob
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 8 lines
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯Quoted 30 lines · Liviu Dudau
Quoted 29 lines · Rob Herring
Quoted 27 lines · Liviu Dudau
Quoted 5 lines · Rob Herring
From: Rob Herring <[email protected]>
This series adds a platform driver for Versatile PB's PCI host using Liviu's recent patch series[1] for DT parsing and setup.
Quoted 7 lines
The first patch is a hack to get Liviu's current patches to work on ARM. It at least shows we are not that far off from being able to use the series on ARM.
I've tested PCI under QEMU, but need someone with actual h/w to test. A branch with this series and which includes full conversion of Versatile to DT is available here[2].
Hi Rob,
Thanks for doing this. Hopefully others will take inspiration and start to convert their host bridge controllers as well.
I will post an updated series soon. (Un)fortunately it will look slightly different than the last one I've posted as I am trying to get more code that I've currently placed in
arch/arm64/kernel/pci.cintodrivers/pci, so you will need to revisit your series.Regarding your comment about
bridge->bus->selfbeing needed: root busses are supposed to havebus->self== NULL, and thebridge->bus*is* the root bus. Where would you need to usebridge->bus->self?
Quoted 8 lines
Quoted 6 lines
If I want to use pci_write_config_* accesses, then I need a struct
pci_devpointer for the host. I can get this since I know the slot of the host, but only afterpci_bus_add_deviceswhich is perhaps too late. Historically, the Versatile PCI driver has blocked config accesses to the host's config space. I'm just wondering if this is really correct behavior and whether the core code should do the setup.PCI core? It knows nothing of the Versatile registers. Versatile core code? Maybe.
These are all standard config space registers based on the offsets and documentation. The only thing that I think might make this Versatile specific is a host bridge having its own config space at all is optional.
Quoted 11 lines
Quoted 8 lines
This is setup that is done which doesn't seem like it is very specific to Versatile.
local_pci_cfg_base= versatile_cfg_base[1] + (myslot << 11);val =
readl(local_pci_cfg_base + CSR_OFFSET);
val |=PCI_COMMAND_MEMORY|PCI_COMMAND_MASTER|PCI_COMMAND_INVALIDATE;writel(val, local_pci_cfg_base + CSR_OFFSET);Why don't you do this in a
versatile_fixup_bridge()call, likepci-tegra.cdoes?
I could, but doesn't any host need these bits set (assuming the host has a config space)?
As it stands now, the PCI core would never call a fixup because the host's config space is masked out (with pci_slot_ignore). So is that wrong?
Quoted 11 lines
Quoted 7 lines
/*
* Configure the PCI inbound memory windows to be 1:1 mapped to SDRAM */writel(PHYS_OFFSET, local_pci_cfg_base + PCI_BASE_ADDRESS_0);writel(PHYS_OFFSET, local_pci_cfg_base + PCI_BASE_ADDRESS_1);writel(PHYS_OFFSET, local_pci_cfg_base + PCI_BASE_ADDRESS_2);My guess is that this has to be done at probe time. It just happens that for Versatile PCI they live in the host config space, but they are not really PCI config space writes.
It is not completely obvious since they use private defines, but PCI_BASE_ADDRESS_x registers are BAR registers AFAICT.
Rob
Quoted 38 lines · Rob Herring
Quoted 37 lines · Liviu Dudau
Quoted 35 lines · Rob Herring
Quoted 19 lines · Liviu Dudau
Quoted 5 lines · Rob Herring
From: Rob Herring <[email protected]>
This series adds a platform driver for Versatile PB's PCI host using Liviu's recent patch series[1] for DT parsing and setup.
Quoted 7 lines
The first patch is a hack to get Liviu's current patches to work on ARM. It at least shows we are not that far off from being able to use the series on ARM.
I've tested PCI under QEMU, but need someone with actual h/w to test. A branch with this series and which includes full conversion of Versatile to DT is available here[2].
Hi Rob,
Thanks for doing this. Hopefully others will take inspiration and start to convert their host bridge controllers as well.
Quoted 8 lines
I will post an updated series soon. (Un)fortunately it will look slightly different than the last one I've posted as I am trying to get more code that I've currently placed in
arch/arm64/kernel/pci.cintodrivers/pci, so you will need to revisit your series.Regarding your comment about
bridge->bus->selfbeing needed: root busses are supposed to havebus->self== NULL, and thebridge->bus*is* the root bus. Where would you need to usebridge->bus->self?If I want to use pci_write_config_* accesses, then I need a struct
pci_devpointer for the host. I can get this since I know the slot of the host, but only afterpci_bus_add_deviceswhich is perhaps too late. Historically, the Versatile PCI driver has blocked config accesses to the host's config space. I'm just wondering if this is really correct behavior and whether the core code should do the setup.
Quoted 6 lines
Quoted 1 line
PCI core? It knows nothing of the Versatile registers. Versatile core code? Maybe.
These are all standard config space registers based on the offsets and documentation. The only thing that I think might make this Versatile specific is a host bridge having its own config space at all is optional.
Sorry, got confused by your CSR_OFFSET macro into thinking it's Versatile specific (I still cannot get hold of the SP810 manual, sigh). Why don't you use PCI_COMMAND ?
Quoted 13 lines
Quoted 4 lines
Quoted 4 lines
This is setup that is done which doesn't seem like it is very specific to Versatile.
Quoted 8 lines
Quoted 5 lines
local_pci_cfg_base= versatile_cfg_base[1] + (myslot << 11);val =
readl(local_pci_cfg_base + CSR_OFFSET);
val |=PCI_COMMAND_MEMORY|PCI_COMMAND_MASTER|PCI_COMMAND_INVALIDATE;writel(val, local_pci_cfg_base + CSR_OFFSET);Why don't you do this in a
versatile_fixup_bridge()call, likepci-tegra.cdoes?
Quoted 6 lines
I could, but doesn't any host need these bits set (assuming the host has a config space)?
As it stands now, the PCI core would never call a fixup because the host's config space is masked out (with
pci_slot_ignore). So is that wrong?
No, it is right. Host bridge config space should not be visible if it is a PCI host bridge. And I'm guessing that this is the reason why everyone and their dog does the PCI_COMMAND register setup for the host brige manually.
For PCIe the spec is a bit more forgiving is you use ECAM, although it doesn't explicitly allow writes to the config space of the host bridge. From PCI Express Base spec, rev 3.0:
7.2.2.1. Host Bridge Requirements
For those systems that implement the ECAM, the PCI Express Host Bridge is required to translate the memory-mapped PCI Express Configuration Space accesses from the host processor to PCI Express configuration transactions. The use of Host Bridge PCI class code is Reserved for backwards compatibility; host Bridge Configuration Space is opaque to standard PCI Express software and may be implemented in an implementation specific manner that is compatible with PCI Host Bridge Type 0 Configuration Space. A PCI Express Host Bridge is not required to signal errors through a Root Complex Event Collector. This support is optional for PCI Express Host Bridges.
So it looks like you need to do those in the host bridge probe function, rather than in a generic way.
Best regards,
Liviu
Quoted 22 lines
Quoted 9 lines
Quoted 8 lines
/*
* Configure the PCI inbound memory windows to be 1:1 mapped to SDRAM */writel(PHYS_OFFSET, local_pci_cfg_base + PCI_BASE_ADDRESS_0);writel(PHYS_OFFSET, local_pci_cfg_base + PCI_BASE_ADDRESS_1);writel(PHYS_OFFSET, local_pci_cfg_base + PCI_BASE_ADDRESS_2);Quoted 3 lines
My guess is that this has to be done at probe time. It just happens that for Versatile PCI they live in the host config space, but they are not really PCI config space writes.
It is not completely obvious since they use private defines, but
PCI_BASE_ADDRESS_xregisters are BAR registers AFAICT.Rob
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Signature · 8 lines
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯Quoted 11 lines · On Friday 28 March 2014 16:21:38 Liviu Dudau wrote:
Quoted 7 lines · Rob Herring
Quoted 1 line · Liviu Dudau
PCI core? It knows nothing of the Versatile registers. Versatile core code? Maybe.
These are all standard config space registers based on the offsets and documentation. The only thing that I think might make this Versatile specific is a host bridge having its own config space at all is optional.
Sorry, got confused by your
CSR_OFFSETmacro into thinking it's Versatile specific (I still cannot get hold of the SP810 manual, sigh). Why don't you usePCI_COMMAND?
While it's not uncommon to have PCI host controllers use a similar layout for their own registers as the normal config space, I believe this is not standardized anywhere. It may be better not to pretend that this is a standard register.
Quoted 15 lines
For PCIe the spec is a bit more forgiving is you use ECAM, although it doesn't explicitly allow writes to the config space of the host bridge. From PCI Express Base spec, rev 3.0:
7.2.2.1. Host Bridge Requirements
For those systems that implement the ECAM, the PCI Express Host Bridge is required to translate the memory-mapped PCI Express Configuration Space accesses from the host processor to PCI Express configuration transactions. The use of Host Bridge PCI class code is Reserved for backwards compatibility; host Bridge Configuration Space is opaque to standard PCI Express software and may be implemented in an implementation specific manner that is compatible with PCI Host Bridge Type 0 Configuration Space. A PCI Express Host Bridge is not required to signal errors through a Root Complex Event Collector. This support is optional for PCI Express Host Bridges.
Quoted 2 lines
So it looks like you need to do those in the host bridge probe function, rather than in a generic way.
Right. FWIW, the reason why these have a normal register layout seems to be that the same hardware is used for host controller and endpoint devices.
Arnd
Bjorn Helgaas
maintainercover Versatile PCI DT support
In reply to Rob HerringQuoted 8 lines · Rob Herring
From: Rob Herring <[email protected]>
This series adds a platform driver for Versatile PB's PCI host using Liviu's recent patch series[1] for DT parsing and setup.
The first patch is a hack to get Liviu's current patches to work on ARM. It at least shows we are not that far off from being able to use the series on ARM.
Since this depends on Liviu's work that is not yet upstream, I guess I can't do anything with this yet, right? Poke me again when I can.
I assume you would want a MAINTAINERS update, too (at least, *I* do :))
Quoted 26 lines
I've tested PCI under QEMU, but need someone with actual h/w to test. A branch with this series and which includes full conversion of Versatile to DT is available here[2].
Rob
[1] https://lkml.org/lkml/2014/3/14/279
[2]git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.gitversatileRob Herring (3):
ARM: hackup pcibios support for commmon bridge code dt/bindings: add versatile PCI binding
pci: add DT based ARM Versatile PCI host driver.../devicetree/bindings/pci/versatile.txt | 59 +++++ arch/arm/kernel/bios32.c | 63 +++++ drivers/pci/host/Kconfig | 4 + drivers/pci/host/Makefile | 1 + drivers/pci/host/pci-versatile.c | 275 +++++++++++++++++++++ 5 files changed, 402 insertions(+) create mode 100644 Documentation/devicetree/bindings/pci/versatile.txt create mode 100644 drivers/pci/host/pci-versatile.cSignature · 1 line
1.8.3.2