PCIe support for the Armada 370 and Armada XP SoCs
Subsystems (10)
PATCH v2 22/27 arm: mvebu: add PCIe Device Tree informations for Armada XP
In reply to Arnd BergmannDear Arnd Bergmann,
Quoted 21 lines · Arnd Bergmann
address-map {
/* this device translates 64 bit MMIO bus addresses into 32 bit CPU addresses */
compatible = "marvell,armada-addr-decoding-controller";
reg = <0xd0020000 0x258>;
#addres-cells = <2>;
#address-cells = <1>;
/* each remapped window has one entry here */
ranges = <0xa 0 0xc0000000 0x10000>, /* map window a to 0xc0000000 */
<0xb 0 0xc1000000 0x08000000>, /* map window b to 0xc1000000 */
<...>; /* more windows */
pciex {
#addres-cells = <3>;
#size-cells = <2>;
ranges = <0x81000000 0 0 0xa 0 0 0x00010000, /* I/O is window a */
0x82000000 0 0 0xb 0 0 0x08000000>; /* non-prefetchable memory */
...
};Quoted 6 lines
something-else {
...
reg = <0xc 0 0x10000>; /* window c */
};
};
};Unfortunately, this means the windows are statically defined in the DT, which is simply not possible for PCIe, as we have already explained several times in this thread.
Any solution where the PCIe windows are statically described is simply /not/ acceptable.
We have 10 PCIe interfaces, each requiring up to two windows, and we have on the system a *total* of 20 windows. Doing static assignments of windows is simply not an option.
Of course, you'll tell me that it's up to each board .dts to have a number of windows that matches the number of actually existing PCIe interface. But it means that each and every developer adding the support for a new board must understand this complex problem, which is something we do not want. We have a solution that makes all of this PCIe window assignment dynamic, so it surprises me that we have to continue to explain why a static solution is not appropriate.
Best regards,
Thomas
Signature · 4 lines
Thomas Petazzoni, Free Electrons Kernel, drivers, real-time and embedded Linux development, consulting, training and support. http://free-electrons.com
PATCH v2 22/27 arm: mvebu: add PCIe Device Tree informations for Armada XP
Quoted 11 lines · Thomas Petazzoni
Unfortunately, this means the windows are statically defined in the DT, which is simply not possible for PCIe, as we have already explained several times in this thread.
Any solution where the PCIe windows are statically described is simply not acceptable.
We have 10 PCIe interfaces, each requiring up to two windows, and we have on the system a total of 20 windows. Doing static assignments of windows is simply not an option.
Quoted 7 lines
Of course, you'll tell me that it's up to each board .dts to have a number of windows that matches the number of actually existing PCIe interface. But it means that each and every developer adding the support for a new board must understand this complex problem, which is something we do not want. We have a solution that makes all of this PCIe window assignment dynamic, so it surprises me that we have to continue to explain why a static solution is not appropriate.
No, the idea here was actually to leave out any of the dynamic mappings from the device tree and do the PCI bus probe for each port based on a local bus address starting at 0 for each port. After all BARs are assigned, you can then map each port to a convenient physical address and register it by passing the start offset so that the pci resources are adapted correctly.
Arnd
PATCH v2 22/27 arm: mvebu: add PCIe Device Tree informations for Armada XP
In reply to Arnd BergmannQuoted 5 lines · Arnd Bergmann
This would mean that rather than putting the mapped physical address (
0xc0000000,0xc1000000, ...) in here, you would actually have 64-bit address as the destination as well, in whatever format the address map hardware uses, I assume using a numbered 32 bit address space for each object that can be remapped.
Do you mean like:
mbus_matrix {
/* At this level addresses are
<32 bit MBUS target ID> <32 bit target address offset>
target_id is an internal MBUS specification
*/
#address-cells = <2>;
#size-cells = <1>;
pex0 {
ranges = <
// CPU window bridged to PCI MMIO
0x82000000 0x00000000 0x00000000 0x<target_id> 0x0 0x0 0x8000000
// CPU IO window bridged to PCI IO
0x81000000 0x00000000 0x00000000 0x<target_id> 0x0 0x0 0xa0000
...>;}
nand {
reg = <0x<target_id> 0 0x200>;
};
internal_regs {
ranges = <0 0x<target_id> 0 0x10000>; timer {
reg = <0x20300 0x20>;
}; };
}
?
I think the big issue would go back to how to pool all the link decoders together in a way that fits OF and Linux's PCI core will understand?
How does of_translate_address work in a world like this?
Quoted 5 lines
This would also let you do the PCI memory address assignment for each port separately, starting at bus address 0, followed by finding a location in the CPU address space and passing the start as the
sys->mem_offsetargument topci_add_resource_offset.
That goes back to the original problem - the goal is to have only one pci_sys_data, not one for every link.
The host driver would have to request a large region of physical address space and still dole it out on a link by link basis. Not sure how to model that in DT??
In any event, changing how all the dynamic windows are configured in DT is a big job (there was another thread about this) it seems orthogonal to the PCI host driver..
Quoted 12 lines
arch/arm/boot/dts/armada-xp-mv78230.dtsi line 115
Quoted 11 lines
arch/arm/boot/dts/armada-xp-mv78230.dtsi +11
-0+ pcie at 0,0 { + device_type = "pciex"; + reg = <0x0800 0 0xd0040000 0 0x2000>; + #address-cells = <3>; + #size-cells = <2>; + marvell,pcie-port = <0>; + marvell,pcie-lane = <0>; + interrupts = <1>; + clocks = <&gateclk 5>; + status = "disabled"; + };
Quoted 3 lines
I think you are missing a "ranges" property here, at least an empty one, which is required by the standard but not currently enforced in the code.
Maybe.. according to the standard the ranges in this stanza should reflect the bridge configuration, but that isn't known when the DT is written. An empty ranges means identity and that isn't really right either.
Also, what should 'reg' be so that the PCI core binds the OF nodes properly? The standard says reg should have the configuration space address of the bridge, and I noticed Thierry was using something that almost looked like a config space address in his driver..
But that seems overly tricky.. When using the link stanzas, shouldn't this scheme be more like this:
// The PCI-E host bridge
pex at 0 {
device_type = "pciex"; // <<-- Important!!
ranges = <
// Driver internal control registers in MMIO space
0x82000000 0x10000000 0xd0040000 0xd0040000 0x0 0x8000000
// CPU 0xe0000000 -> e8000000 bridged to PCI MMIO
0x82000000 0x00000000 0xe0000000 0xe0000000 0x0 0x8000000
// CPU IO bus 0x0000000 -> 0xa0000 bridged to PCI IO
0x81000000 0x00000000 0x00000000 0x00000000 0x0 0xa0000
// CPU 0xe8000000 -> f0000000 bridged to PCI MMIO, prefetchable
0xC2000000 0x00000000 0xe8000000 0xe8000000 0x0 0x8000000
>;//...
// PCI-PCI bridge to Physical link 0
pcie at 0,0 {
device_type = "pciex";
// The configuration space address of the PCI-PCI bridge required by OF
reg = <0x80 0 0 0 0>; // Bus 0, Dev 0x10, Fn 0 /* The 'bar' on the PCI-PCI bridge, maps to internal control
registers, required by the driver. */
assigned-addresses = <0x82000000 0x10000000 0xd0040000 0 0x2000>;
// .. }
}
Thierry, what do you think?
I struggled with this particular area of the OF system recently and Grant Likely was very helpful - the above is based on that discussion..
======
Thomas, here is one possible alternate idea, not sure on the merit, just including it because it is close to what I've got in my DT right now..:
// The entire multi-lane controller and PCI root bus pex at 0 {
device_type = "pciex";
/* This section configures the Linux PCI host driver. Each line is a
physical PCI-Link. (Erorrs included :) */
compatible = "marvell,armada-370-xp-pcie";
regs = <0xd0040000 0x00002000 // port 0.0
0xd0042000 0x00002000 // port 2.0
0xd0044000 0x00002000 // port 0.1
0xd0048000 0x00002000 // port 0.2
0xd004C000 0x00002000>; // port 0.3
io-cpu-window = <0xc0000000 0xa0000>;
interrupts = <58 59 60 61 99>;
clocks = <&gateclk 5
&gateclk 6
&gateclk 7
&gateclk 8
&gateclk 26>
marvell,port-lane <0 0
0 1
0 2
0 3
2 0>; /* Below here configures the aggregate PCI bus the PEX0 stanza
describes */
#address-cells = <3>; #size-cells = <2>;
// CPU resources allocated to this PCI host bridge bus-range = <0x00 0xff>;
ranges = <
// CPU 0xe0000000 -> e8000000 bridged to PCI MMIO
0x82000000 0x00000000 0xe0000000 0xe0000000 0x0 0x8000000
// CPU IO bus 0x0000000 -> 0xa0000 bridged to PCI IO
0x81000000 0x00000000 0x00000000 0x00000000 0x0 0xa0000
// CPU 0xe8000000 -> f0000000 bridged to PCI MMIO, prefetchable
0xC2000000 0x00000000 0xe8000000 0xe8000000 0x0 0x8000000
>; /* Any PCI devices associated with this bus go here, relative to
the above ranges. As example: */
link at 0 {
device_type = "pciex";
// Root port at bus 0, device 0x10, function 0
reg = <0x00000080 0 0 0 0>;
ep {
device_type = "pciex";
// End port on bus 1, device 0, function 0
reg = <0x00000100 0 0 0 0>;
} }
}
Thoughts:
- 'regs' in the main stanza, keep to CPU addresses instead of confusing translated fake ranges address
- each regs line is matches to an interrupt, clock and port-lane line to describe a link. The above describes 5 links.
- The CPU physical address window to use for the IO space is set via io-cpu-window, not much choice here, the PCI format ranges must be 0 based.
- It is not necessary to have per-root port stanzas at all with the above.
- There is only one PCI bus stanza, the top level.
Jason
PATCH v2 22/27 arm: mvebu: add PCIe Device Tree informations for Armada XP
On Wed, Feb 06, 2013 at 06:05:02PM -0700, Jason Gunthorpe wrote:
[...]
Quoted 11 lines
Also, what should 'reg' be so that the PCI core binds the OF nodes properly? The standard says reg should have the configuration space address of the bridge, and I noticed Thierry was using something that almost looked like a config space address in his driver..
But that seems overly tricky.. When using the link stanzas, shouldn't this scheme be more like this:
// The PCI-E host bridge
pex at 0 { device_type = "pciex"; // <<-- Important!!
That might actually work but is somewhat dangerous. I originally tried to trick the OF code into parsing the ranges properly by setting this to "pci". However that breaks horribly because of_bus_pci_match() in drivers/of/address.c will cause the parent bus of the pex@0 controller to be PCI, which will cause #address-cells == 3 and #size-cells == 2, and thus messing up the address translation because you actually have #address-cells == 1 and #size-cells == 1.
The code doesn't seem to match on "pciex", so you might get away with it, but I don't see why exactly it would be necessary. For one it is actually wrong as the device isn't a PCI device but a platform device. What I did to solve the ranges parsing problem is to use of_find_bus() instead of of_match_bus() in of_pci_process_ranges(), so that the cell count is correct.
Quoted 3 lines
ranges = <
// Driver internal control registers in MMIO space
0x82000000 0x10000000 0xd0040000 0xd0040000 0x0 0x8000000I'm not sure I understand what you're doing here. Where does the 0x10000000 in cell 2 come from?
I also just noticed that I used 0x00000800 in the first cell, maybe that should be 0x02000800, though I think that didn't quite work for some reason. I'll need to check that. The odd part about this is that the address is in fact not within PCI MMIO space at all, so I'm not sure this is even a correct way to represent it. However I find it quite intuitive to do so and it is really the only way to make the translation from the PCI-PCI bridge's reg property work while at the same time having a proper PCI address for the port.
Note that 0x82000800 would probably not be correct as it'd indicate that the address is relocatable, which it really isn't.
Quoted 7 lines
// CPU 0xe0000000 -> e8000000 bridged to PCI MMIO
0x82000000 0x00000000 0xe0000000 0xe0000000 0x0 0x8000000
// CPU IO bus 0x0000000 -> 0xa0000 bridged to PCI IO
0x81000000 0x00000000 0x00000000 0x00000000 0x0 0xa0000
// CPU 0xe8000000 -> f0000000 bridged to PCI MMIO, prefetchable
0xC2000000 0x00000000 0xe8000000 0xe8000000 0x0 0x8000000
>;These look good.
Quoted 5 lines
// PCI-PCI bridge to Physical link 0
pcie at 0,0 {
device_type = "pciex";
// The configuration space address of the PCI-PCI bridge required by OF
reg = <0x80 0 0 0 0>; // Bus 0, Dev 0x10, Fn 0I think the first cell should be 0x800.
Quoted 6 lines
/* The 'bar' on the PCI-PCI bridge, maps to internal control registers, required by the driver. */ assigned-addresses = <0x82000000 0x10000000 0xd0040000 0 0x2000>; // ..}
The PCI DT binding says that each entry in the assigned-addresses property is to correspond to one of the PCI device's base address registers. So unless this is actually the value that ends up being written to one of the BARs I don't think this is correct.
Thierry
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 836 bytes
Desc: not available
URL: <http://lists.infradead.org/pipermail/linux-arm-kernel/attachments/20130207/5e9430fb/attachment.sig>
PATCH v2 22/27 arm: mvebu: add PCIe Device Tree informations for Armada XP
Quoted 14 lines · Thierry Reding
On Wed, Feb 06, 2013 at 06:05:02PM -0700, Jason Gunthorpe wrote:
[...]Quoted 11 lines
Also, what should 'reg' be so that the PCI core binds the OF nodes properly? The standard says reg should have the configuration space address of the bridge, and I noticed Thierry was using something that almost looked like a config space address in his driver..
But that seems overly tricky.. When using the link stanzas, shouldn't this scheme be more like this:
// The PCI-E host bridge
pex at 0 { device_type = "pciex"; // <<-- Important!!
Quoted 7 lines
That might actually work but is somewhat dangerous. I originally tried to trick the OF code into parsing the ranges properly by setting this to "pci". However that breaks horribly because
of_bus_pci_match()indrivers/of/address.cwill cause the parent bus of the pex at 0 controller to be PCI, which will cause #address-cells == 3 and #size-cells == 2, and thus messing up the address translation because you actually have #address-cells == 1 and #size-cells == 1.
Oh right, yes, I ment it to be "pci", specifically to engage that code. Ditto for the other instance.
Not sure about the side effect you are talking about, I am using that pattern in my DT and it is OK, but the PEX node is off the root node directly.. It shouldn't affect the parent. Other DT examples using device_type = pci (ie in PPC) also put it on the top PCI node and have that node buried, so it should be correct, but all the stuff below has to be correct first..
Quoted 6 lines
Quoted 3 lines
ranges = < // Driver internal control registers in MMIO space 0x82000000 0x10000000 0xd0040000 0xd0040000 0x0 0x8000000I'm not sure I understand what you're doing here. Where does the
0x10000000in cell 2 come from?
It is just a marker to keep the internal regs distinct from the PCI MMIO window. I don't really like it, but something is necessary to pass the non-PCI items into the link stanza. It would probably be better to just place them outside the link as I did in my other example..
Quoted 3 lines
I also just noticed that I used
0x00000800in the first cell, maybe that should be0x02000800, though I think that didn't quite work for some reason. I'll need to check that. The odd part about this is that the
I think that is the trickyness you have, 0x00000800 is probably the correct config space address number for your root port bridge. You are overriding it to be both a config space address and something that translates back to a CPU MMIO address.
If you use 0x02000800 then it is no longer a config space address, it is an MMIO address and your 'reg' won't match anymore.
Quoted 5 lines
address is in fact not within PCI MMIO space at all, so I'm not sure this is even a correct way to represent it. However I find it quite intuitive to do so and it is really the only way to make the translation from the PCI-PCI bridge's reg property work while at the same time having a proper PCI address for the port.
Your problem is that in PCI devices 'reg' is not supposed to be translated to a CPU address. It is the config space address of the PCI device followed by the *sizes* of all the BARs.
assigned-addresses is the MMIO location (and size) of the 'BARs', and is intended to be translated to a CPU address.
When the bus is properly in PCI mode the OF address code automatically uses assigned-addresses instead of regs, that is why you need device_type = pci
Quoted 7 lines
Quoted 5 lines
// PCI-PCI bridge to Physical link 0 pcie at 0,0 { device_type = "pciex"; // The configuration space address of the PCI-PCI bridge required by OF reg = <0x80 0 0 0 0>; // Bus 0, Dev 0x10, Fn 0I think the first cell should be
0x800.
Right.
Quoted 10 lines
Quoted 5 lines
/* The 'bar' on the PCI-PCI bridge, maps to internal control registers, required by the driver. */ assigned-addresses = <0x82000000 0x10000000 0xd0040000 0 0x2000>; // ..}
The PCI DT binding says that each entry in the assigned-addresses property is to correspond to one of the PCI device's base address registers. So unless this is actually the value that ends up being written to one of the BARs I don't think this is correct.
Yes, but, it is a compromise, of sorts. DT has no way to pass a non-PCI described resource into this stanza. It would ideal if the driver didn't require that at all, but if it does I think it has to be through assigned-addresses...
Now, perhaps this is better:
assigned-addresses = <0 0 0 0 0 // BAR 0 of the bridge, unused
0 0 0 0 0 // BAR 1 of the bridge, unused 0x82000000 0x10000000 0xd0040000 0 0x2000>; // Extended
Mark the only two BARs in the bridge as unused and put your non-BAR registers after them.
Certainly, trying to use reg to convey that the link has an internal MMIO region at CPU address 0xd0040000 would be even worse..
Jason
PATCH v2 22/27 arm: mvebu: add PCIe Device Tree informations for Armada XP
In reply to Jason GunthorpeQuoted 40 lines · Jason Gunthorpe
Quoted 5 lines · Arnd Bergmann
This would mean that rather than putting the mapped physical address (
0xc0000000,0xc1000000, ...) in here, you would actually have 64-bit address as the destination as well, in whatever format the address map hardware uses, I assume using a numbered 32 bit address space for each object that can be remapped.Do you mean like:
mbus_matrix { /* At this level addresses are <32 bit MBUS target ID> <32 bit target address offset> target_id is an internal MBUS specification */ #address-cells = <2>; #size-cells = <1>; pex0 { ranges = < // CPU window bridged to PCI MMIO 0x82000000 0x00000000 0x00000000 0x<target_id> 0x0 0x0 0x8000000 // CPU IO window bridged to PCI IO 0x81000000 0x00000000 0x00000000 0x<target_id> 0x0 0x0 0xa0000 ...>; } nand { reg = <0x<target_id> 0 0x200>; }; internal_regs { ranges = <0 0x<target_id> 0 0x10000>; timer { reg = <0x20300 0x20>; }; }; }
Quoted 1 line
?
Yes, but the mbus-matrix node in the example would need a ranges property to map the addresses according to how the windows are set up.
Quoted 5 lines
I think the big issue would go back to how to pool all the link decoders together in a way that fits OF and Linux's PCI core will understand?
How does
of_translate_addresswork in a world like this?
The trick is that the root node must still be #address-cells=<1> and refer to the CPU's translated view of the world, rather the raw view with individul windows. When we set up the address map in Linux, we would initially read the windows from the ranges property, but if we make changes to the windows, that property has to be adapted on the fly. of_translate_address will then for any device go through the intermediate 64 bit address but end up with the correct physical address at the root node.
Quoted 9 lines
Quoted 5 lines
This would also let you do the PCI memory address assignment for each port separately, starting at bus address 0, followed by finding a location in the CPU address space and passing the start as the
sys->mem_offsetargument topci_add_resource_offset.That goes back to the original problem - the goal is to have only one
pci_sys_data, not one for every link.
Quoted 7 lines
The host driver would have to request a large region of physical address space and still dole it out on a link by link basis. Not sure how to model that in DT??
In any event, changing how all the dynamic windows are configured in DT is a big job (there was another thread about this) it seems orthogonal to the PCI host driver..
Yes, it is orthogonal, you are right, but I think it would make it easier to understand what we are trying to do here with the PCI node.
I'm not sure why you say "the goal is to have only one pci_sys_data", as far as I'm concerned, the goal is to have a working system that is both as sensible and as simple as possible. When in hardware you have a bunch of independent PCIe host bridges, each with their own address translation, that means to me that (if possible) we should in the device tree show multiple independent PCIe host bridges and how they are set up with address translation, and Linux should see multiple independent host bridges as well.
Having a single pci_sys_data is a hack to defeat some of the problems associated with getting bus probing to work in practice, but it's not necessarily the best solution.
Quoted 12 lines
Quoted 12 lines
Quoted 11 lines
arch/arm/boot/dts/armada-xp-mv78230.dtsi +11
-0+ pcie at 0,0 { + device_type = "pciex"; + reg = <0x0800 0 0xd0040000 0 0x2000>; + #address-cells = <3>; + #size-cells = <2>; + marvell,pcie-port = <0>; + marvell,pcie-lane = <0>; + interrupts = <1>; + clocks = <&gateclk 5>; + status = "disabled"; + };
Quoted 8 lines
Quoted 3 lines
I think you are missing a "ranges" property here, at least an empty one, which is required by the standard but not currently enforced in the code.
Maybe.. according to the standard the ranges in this stanza should reflect the bridge configuration, but that isn't known when the DT is written. An empty ranges means identity and that isn't really right either.
Ok, I thought it was an identity mapping here.
Quoted 4 lines
Also, what should 'reg' be so that the PCI core binds the OF nodes properly? The standard says reg should have the configuration space address of the bridge, and I noticed Thierry was using something that almost looked like a config space address in his driver..
Well, that assumes that a bridge is addressed using configuration space, which IIRC is normally the case but not here.
Quoted 31 lines
But that seems overly tricky.. When using the link stanzas, shouldn't this scheme be more like this:
// The PCI-E host bridge
pex at 0 { device_type = "pciex"; // <<-- Important!! ranges = < // Driver internal control registers in MMIO space 0x82000000 0x10000000 0xd0040000 0xd0040000 0x0 0x8000000 // CPU 0xe0000000 -> e8000000 bridged to PCI MMIO 0x82000000 0x00000000 0xe0000000 0xe0000000 0x0 0x8000000 // CPU IO bus 0x0000000 -> 0xa0000 bridged to PCI IO 0x81000000 0x00000000 0x00000000 0x00000000 0x0 0xa0000 // CPU 0xe8000000 -> f0000000 bridged to PCI MMIO, prefetchable 0xC2000000 0x00000000 0xe8000000 0xe8000000 0x0 0x8000000 >; //... // PCI-PCI bridge to Physical link 0 pcie at 0,0 { device_type = "pciex"; // The configuration space address of the PCI-PCI bridge required by OF reg = <0x80 0 0 0 0>; // Bus 0, Dev 0x10, Fn 0 /* The 'bar' on the PCI-PCI bridge, maps to internal control registers, required by the driver. */ assigned-addresses = <0x82000000 0x10000000 0xd0040000 0 0x2000>; // ..
Quoted 8 lines
}
}Thierry, what do you think?
I struggled with this particular area of the OF system recently and Grant Likely was very helpful - the above is based on that discussion..
I never really understood the 'assigned-addresses' property, but it looks sensible.
Quoted 63 lines
======
Thomas, here is one possible alternate idea, not sure on the merit, just including it because it is close to what I've got in my DT right now..:
// The entire multi-lane controller and PCI root bus
pex at 0 { device_type = "pciex"; /* This section configures the Linux PCI host driver. Each line is a physical PCI-Link. (Erorrs included :) */ compatible = "marvell,armada-370-xp-pcie"; regs = <0xd0040000 0x00002000 // port 0.0 0xd0042000 0x00002000 // port 2.0 0xd0044000 0x00002000 // port 0.1 0xd0048000 0x00002000 // port 0.2 0xd004C000 0x00002000>; // port 0.3 io-cpu-window = <0xc0000000 0xa0000>; interrupts = <58 59 60 61 99>; clocks = <&gateclk 5 &gateclk 6 &gateclk 7 &gateclk 8 &gateclk 26> marvell,port-lane <0 0 0 1 0 2 0 3 2 0>; /* Below here configures the aggregate PCI bus the PEX0 stanza describes */ #address-cells = <3>; #size-cells = <2>; // CPU resources allocated to this PCI host bridge bus-range = <0x00 0xff>; ranges = < // CPU 0xe0000000 -> e8000000 bridged to PCI MMIO 0x82000000 0x00000000 0xe0000000 0xe0000000 0x0 0x8000000 // CPU IO bus 0x0000000 -> 0xa0000 bridged to PCI IO 0x81000000 0x00000000 0x00000000 0x00000000 0x0 0xa0000 // CPU 0xe8000000 -> f0000000 bridged to PCI MMIO, prefetchable 0xC2000000 0x00000000 0xe8000000 0xe8000000 0x0 0x8000000 >; /* Any PCI devices associated with this bus go here, relative to the above ranges. As example: */ link at 0 { device_type = "pciex"; // Root port at bus 0, device 0x10, function 0 reg = <0x00000080 0 0 0 0>; ep { device_type = "pciex"; // End port on bus 1, device 0, function 0 reg = <0x00000100 0 0 0 0>; } } }
Quoted 3 lines
Thoughts:
- 'regs' in the main stanza, keep to CPU addresses instead of confusing translated fake ranges address
Yes, I like that. If we follow the address translation method I suggested, this would be a 64-bit address of course, but still easier to understand than what we have now.
Quoted 2 lines
- each regs line is matches to an interrupt, clock and port-lane line to describe a link. The above describes 5 links.
nice.
Quoted 3 lines
- The CPU physical address window to use for the IO space is set via io-cpu-window, not much choice here, the PCI format ranges must be 0 based.
I don't think I understand this part. Why can't you put this into ranges as before?
- 0x81000000 0x00000000 0x00000000 0x00000000 0x0 0xa0000
+ 0x81000000 0x00000000 0x00000000 0xc0000000 0x0 0xa0000
Quoted 3 lines
- It is not necessary to have per-root port stanzas at all with the above.
- There is only one PCI bus stanza, the top level.
Ok.
Arnd
PATCH v2 22/27 arm: mvebu: add PCIe Device Tree informations for Armada XP
Quoted 2 lines · Arnd Bergmann
Yes, but the mbus-matrix node in the example would need a ranges property to map the addresses according to how the windows are set up.
I'll hang on to this for next time the moving windows config to DT discussion comes up..
Quoted 7 lines
Quoted 4 lines
Maybe.. according to the standard the ranges in this stanza should reflect the bridge configuration, but that isn't known when the DT is written. An empty ranges means identity and that isn't really right either.
Ok, I thought it was an identity mapping here.
Quoted 7 lines
Quoted 4 lines
Also, what should 'reg' be so that the PCI core binds the OF nodes properly? The standard says reg should have the configuration space address of the bridge, and I noticed Thierry was using something that almost looked like a config space address in his driver..
Well, that assumes that a bridge is addressed using configuration space, which IIRC is normally the case but not here.
With Thomas's driver each link has a PCI-PCI bridge in config space, and 'configuration space address' is that wonky format OF defines for encoding the bus/device/function number into the 3 dword address. So the correct thing is to put the bus/device/function of the PCI-PCI bridge for the link in the reg value.
Quoted 2 lines
I never really understood the 'assigned-addresses' property, but it looks sensible.
assigned-addresses does the same thing as reg in simple bus, but handles all the wonky PCI address translation
Review
Quoted 9 lines
Quoted 3 lines
- The CPU physical address window to use for the IO space is set via io-cpu-window, not much choice here, the PCI format ranges must be 0 based.
I don't think I understand this part. Why can't you put this into ranges as before?
(quoted diff) +1
-1- 0x81000000 0x00000000 0x00000000 0x00000000 0x0 0xa0000 + 0x81000000 0x00000000 0x00000000 0xc0000000 0x0 0xa0000
The OF PCI core translates 0x81000000 IO space addresess into a 'struct resource' tagged with IORESOURCE_IO.
But 0xc0000000 is not an IORESOURCE_IO address, it is an IORESOURCE_MEM address..
So, I think with the current OF code this has to be 0, otherwise your IORESOURCE_IO's end up starting at 0xc000000 - but maybe there is some trickyness to work with in here? (Although none of this matters when Linux does resource assignment, the OF translation code is never enganged)
But I agree, 0xc0000000 seems much better...
To think about it from a different angle, what would you put in the 4th dword on x86? How do you describe the IO numberspace in DT on x86?
Jason
PATCH v2 22/27 arm: mvebu: add PCIe Device Tree informations for Armada XP
Quoted 14 lines · Jason Gunthorpe
Review
Quoted 9 lines · Arnd Bergmann
Quoted 3 lines
- The CPU physical address window to use for the IO space is set via io-cpu-window, not much choice here, the PCI format ranges must be 0 based.
I don't think I understand this part. Why can't you put this into ranges as before?
(quoted diff) +1
-1- 0x81000000 0x00000000 0x00000000 0x00000000 0x0 0xa0000 + 0x81000000 0x00000000 0x00000000 0xc0000000 0x0 0xa0000The OF PCI core translates
0x81000000IO space addresess into a 'struct resource' tagged withIORESOURCE_IO.
Quoted 8 lines
But
0xc0000000is not anIORESOURCE_IOaddress, it is anIORESOURCE_MEMaddress..So, I think with the current OF code this has to be 0, otherwise your IORESOURCE_IO's end up starting at
0xc000000- but maybe there is some trickyness to work with in here? (Although none of this matters when Linux does resource assignment, the OF translation code is never enganged)
Yes, I think this is for historic reasons: the PCI binding far predates the Linux implementation, and I'm sure on MacOS, AIX and Solaris the PCI drivers did not actually have the same kind of wrappers for PIO functions that we have on Linux because of the x86 legacy.
Quoted 4 lines
But I agree,
0xc0000000seems much better...To think about it from a different angle, what would you put in the 4th dword on x86? How do you describe the IO numberspace in DT on x86?
I think the best option is to have no translation at all on x86, leaving 0x81000000 out of the ranges property. I'm not sure if the authors of the binding actually considered that case though.
Arnd
PATCH v2 23/27 arm: mvebu: PCIe Device Tree informations for OpenBlocks AX3-4
In reply to Thomas PetazzoniThe PlatHome OpenBlocks AX3-4 has an internal mini-PCIe slot that can be used to plug mini-PCIe devices. We therefore enable the PCIe interface that corresponds to this slot.
--- arch/arm/boot/dts/armada-xp-openblocks-ax3-4.dts | 7 +++++++ 1 file changed, 7 insertions(+)
arch/arm/boot/dts/armada-xp-openblocks-ax3-4.dts +7 -0
@@ -121,5 +121,12 @@ nr-ports = <2>; status = "okay"; }; + pcie-controller { + status = "okay"; + /* Internal mini-PCIe connector */ + pcie at 0,0 { + status = "okay"; + }; + }; }; };
Signature · 1 line
1.7.9.5
PATCH v2 24/27 arm: mvebu: PCIe Device Tree informations for Armada XP DB
In reply to Thomas PetazzoniThe Marvell evaluation board (DB) for the Armada XP SoC has 6 physicals full-size PCIe slots, so we enable the corresponding PCIe interfaces in the Device Tree.
--- arch/arm/boot/dts/armada-xp-db.dts | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+)
arch/arm/boot/dts/armada-xp-db.dts +27 -0
@@ -90,5 +90,32 @@ phy = <&phy3>; phy-mode = "sgmii"; }; + + pcie-controller { + status = "okay"; + + /* + * All 6 slots are physically present as + * standard PCIe slots on the board. + */ + pcie at 0,0 { + status = "okay"; + }; + pcie at 0,1 { + status = "okay"; + }; + pcie at 0,2 { + status = "okay"; + }; + pcie at 0,3 { + status = "okay"; + }; + pcie at 2,0 { + status = "okay"; + }; + pcie at 3,0 { + status = "okay"; + }; + }; }; };
Signature · 1 line
1.7.9.5
PATCH v2 25/27 arm: mvebu: PCIe Device Tree informations for Armada 370 Mirabox
In reply to Thomas PetazzoniThe Globalscale Mirabox platform uses one PCIe interface for an available mini-PCIe slot, and the other PCIe interface for an internal USB 3.0 controller. We add the necessary Device Tree informations to enable those two interfaces.
--- arch/arm/boot/dts/armada-370-mirabox.dts | 14 ++++++++++++++ 1 file changed, 14 insertions(+)
arch/arm/boot/dts/armada-370-mirabox.dts +14 -0
@@ -52,5 +52,19 @@ phy = <&phy1>; phy-mode = "rgmii-id"; }; + + pcie-controller { + status = "okay"; + + /* Internal mini-PCIe connector */ + pcie at 0,0 { + status = "okay"; + }; + + /* Connected on the PCB to a USB 3.0 XHCI controller */ + pcie at 1,0 { + status = "okay"; + }; + }; }; };
Signature · 1 line
1.7.9.5
PATCH v2 26/27 arm: mvebu: PCIe Device Tree informations for Armada 370 DB
In reply to Thomas PetazzoniThe Marvell evaluation board (DB) for the Armada 370 SoC has 2 physical full-size PCIe slots, so we enable the corresponding PCIe interfaces in the Device Tree.
--- arch/arm/boot/dts/armada-370-db.dts | 15 +++++++++++++++ 1 file changed, 15 insertions(+)
arch/arm/boot/dts/armada-370-db.dts +15 -0
@@ -59,5 +59,20 @@ phy = <&phy1>; phy-mode = "rgmii-id"; }; + + pcie-controller { + status = "okay"; + /* + * The two PCIe units are accessible through + * both standard PCIe slots and mini-PCIe + * slots on the board. + */ + pcie at 0,0 { + status = "okay"; + }; + pcie at 1,0 { + status = "okay"; + }; + }; }; };
Signature · 1 line
1.7.9.5
PATCH v2 27/27 arm: mvebu: update defconfig with PCI and USB support
In reply to Thomas PetazzoniNow that we have the necessary drivers and Device Tree informations to support PCIe on Armada 370 and Armada XP, enable the CONFIG_PCI option.
Also, since the Armada 370 Mirabox has a built-in USB XHCI controller connected on the PCIe bus, enable the corresponding options as well.
--- arch/arm/configs/mvebu_defconfig | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
arch/arm/configs/mvebu_defconfig +3 -1
@@ -13,6 +13,7 @@ CONFIG_MACH_ARMADA_370=y CONFIG_MACH_ARMADA_XP=y # CONFIG_CACHE_L2X0 is not set # CONFIG_SWP_EMULATE is not set +CONFIG_PCI=y CONFIG_SMP=y # CONFIG_LOCAL_TIMERS is not set CONFIG_AEABI=y
@@ -36,7 +37,8 @@ CONFIG_SERIAL_8250_CONSOLE=y CONFIG_SERIAL_8250_DW=y CONFIG_GPIOLIB=y CONFIG_GPIO_SYSFS=y -# CONFIG_USB_SUPPORT is not set +CONFIG_USB=y +CONFIG_USB_XHCI_HCD=y CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_S35390A=y CONFIG_DMADEVICES=y
Signature · 1 line
1.7.9.5