There is a change in ranges property of PCIe node in device-tree, for which the driver needs support. This commit fix this.
Signed-off-by: Srikanth Thokala <sthokal@xilinx.com>
Signed-off-by: Michal Simek <michal.simek@xilinx.com>
reg: Should contain AXI PCIe registers location and length.
interrupts: Should contain AXI PCIe interrupts.
ranges: These are the parameters for each PCIe bar implemented within the IP
+ The ranges property is <<child address> <parent address> <size>>.
+ The parent address #address-cells is taken from the parent node.
xlnx, include-rc: Root Port (=1) or End Point(=0)
xlnx,axibar2pciebar-0: Translates address from AXI to PCIe
xlnx,pciebar2axibar-0: Translates address from PCIe to AXI
Example:
++++++++
- pci_express: axi-pcie@50000000 {
- compatible = "xlnx,axi-pcie-1.05.a";
- interrupts = < 0 52 4 >;
- ranges = < 0x00000002 0x00000000 0x60000000 0x60000000 0x00000000 0x00000000 0x10000000 >;
- reg = < 0x50000000 0x10000000 >;
- xlnx,include-rc = <0x1>;
- xlnx,axibar2pciebar-0 = <0x60000000>;
- xlnx,pciebar2axibar-0 = <0x0>;
- };
+ ps7_axi_interconnect_0: axi@0 {
+ #address-cells = <1>;
+ #size-cells = <1>;
+ pci_express: axi-pcie@50000000 {
+ #address-cells = <3>;
+ #size-cells = <2>;
+ compatible = "xlnx,axi-pcie-1.05.a";
+ interrupts = < 0 52 4 >;
+ ranges = < 0x02000000 0 0x60000000 0x60000000 0 0x10000000 >;
+ reg = < 0x50000000 0x10000000 >;
+ xlnx,include-rc = <0x1>;
+ xlnx,axibar2pciebar-0 = <0x60000000>;
+ xlnx,pciebar2axibar-0 = <0x0>;
+ };
+ };
u32 val = 0;
while ((rlen -= np * 4) >= 0) {
- pci_space = ranges[0];
+ pci_space = be32_to_cpup(ranges);
pci_addr = of_read_number(ranges + 1, 2);
size = of_read_number(ranges + port->pna + 3, 2);
pr_debug("Parsing ranges property...\n");
while ((rlen -= np * 4) >= 0) {
/* Read next ranges element */
- pci_space = ranges[0];
+ pci_space = be32_to_cpup(ranges);
pci_addr = of_read_number(ranges + 1, 2);
cpu_addr = of_translate_address(node, ranges + 3);
size = of_read_number(ranges + pna + 3, 2);
/* Now consume following elements while they are contiguous */
for (; rlen >= np * sizeof(u32);
ranges += np, rlen -= np * 4) {
- if (ranges[0] != pci_space)
+ if (be32_to_cpup(ranges) != pci_space)
break;
pci_next = of_read_number(ranges + 1, 2);
cpu_next = of_translate_address(node, ranges + 3);
return -ENODEV;
/* The address cells of PCIe node */
- value = (u32 *) of_get_property(node, "#address-cells", NULL);
- if (value)
- info->address_cells = be32_to_cpup(value);
- else
- return -ENODEV;
+ info->address_cells = of_n_addr_cells(node);
/* Get ranges property */
value = (u32 *) of_get_property(node, "ranges", &rlen);
{
const u32 *ranges;
int rlen;
-#ifdef CONFIG_XILINX_AXIPCIE
- /* The address cells of PCIe node */
- int pna = be32_to_cpup(of_get_property(dev, "#address-cells", NULL));
-#else
+ /* The address cells of PCIe parent node */
int pna = of_n_addr_cells(dev);
-#endif
int np = pna + 5;
int memno = 0, isa_hole = -1;
u32 pci_space;
pr_debug("Parsing ranges property...\n");
while ((rlen -= np * 4) >= 0) {
/* Read next ranges element */
- pci_space = ranges[0];
+ pci_space = be32_to_cpup(ranges);
pci_addr = of_read_number(ranges + 1, 2);
cpu_addr = of_translate_address(dev, ranges + 3);
size = of_read_number(ranges + pna + 3, 2);
/* Now consume following elements while they are contiguous */
for (; rlen >= np * sizeof(u32);
ranges += np, rlen -= np * 4) {
- if (ranges[0] != pci_space)
+ if (be32_to_cpup(ranges) != pci_space)
break;
pci_next = of_read_number(ranges + 1, 2);
cpu_next = of_translate_address(dev, ranges + 3);
{
const u32 *ranges;
int rlen;
- /* The address cells of PCIe node */
- int pna = be32_to_cpup(of_get_property(port->node,
- "#address-cells", NULL));
+ /* The address cells of PCIe parent node */
+ int pna = of_n_addr_cells(port->node);
int np = pna + 5;
u32 pci_space;
unsigned long long pci_addr, size;
}
while ((rlen -= np * 4) >= 0) {
- pci_space = ranges[0];
+ pci_space = be32_to_cpup(ranges);
pci_addr = of_read_number(ranges + 1, 2);
size = of_read_number(ranges + pna + 3, 2);