]> git.sur5r.net Git - u-boot/blobdiff - arch/powerpc/cpu/mpc85xx/liodn.c
Merge branch 'master' of git://www.denx.de/git/u-boot-imx
[u-boot] / arch / powerpc / cpu / mpc85xx / liodn.c
index 2e533672f397e496464045c5751cf9100b9010e3..19e130e87f1986f01e46c4609997def84da433b1 100644 (file)
@@ -1,23 +1,7 @@
 /*
  * Copyright 2008-2011 Freescale Semiconductor, Inc.
  *
- * See file CREDITS for list of people who contributed to this
- * project.
- *
- * This program is free software; you can redistribute it and/or
- * modify it under the terms of the GNU General Public License as
- * published by the Free Software Foundation; either version 2 of
- * the License, or (at your option) any later version.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
- * MA 02111-1307 USA
+ * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
@@ -255,9 +239,9 @@ static void fdt_fixup_srio_liodn(void *blob, struct srio_liodn_id_table *tbl)
 #endif
 
 #define CONFIG_SYS_MAX_PCI_EPS         8
-#define CONFIG_SYS_PCI_EP_LIODN_START  256
 
-static void fdt_fixup_pci_liodn_offsets(void *fdt, const char *compat)
+static void fdt_fixup_pci_liodn_offsets(void *fdt, const char *compat,
+                                       int ep_liodn_start)
 {
        int off, pci_idx = 0, pci_cnt = 0, i, rc;
        const uint32_t *base_liodn;
@@ -287,7 +271,7 @@ static void fdt_fixup_pci_liodn_offsets(void *fdt, const char *compat)
                        continue;
                }
                for (i = 0; i < CONFIG_SYS_MAX_PCI_EPS; i++)
-                       liodn_offs[i + 1] = CONFIG_SYS_PCI_EP_LIODN_START +
+                       liodn_offs[i + 1] = ep_liodn_start +
                                        i * pci_cnt + pci_idx - *base_liodn;
                rc = fdt_setprop(fdt, off, "fsl,liodn-offset-list",
                                 liodn_offs, sizeof(liodn_offs));
@@ -354,5 +338,22 @@ void fdt_fixup_liodn(void *blob)
        fdt_fixup_liodn_tbl(blob, rman_liodn_tbl, rman_liodn_tbl_sz);
 #endif
 
-       fdt_fixup_pci_liodn_offsets(blob, "fsl,qoriq-pcie-v2.4");
+       ccsr_pcix_t *pcix = (ccsr_pcix_t *)CONFIG_SYS_PCIE1_ADDR;
+       int pci_ver = pcix->ipver1 & 0xffff, liodn_base = 0;
+
+       if (pci_ver >= 0x0204) {
+               if (pci_ver >= 0x0300)
+                       liodn_base = 1024;
+               else
+                       liodn_base = 256;
+       }
+
+       if (liodn_base) {
+               char compat[32];
+
+               sprintf(compat, "fsl,qoriq-pcie-v%d.%d",
+                       (pci_ver & 0xff00) >> 8, pci_ver & 0xff);
+               fdt_fixup_pci_liodn_offsets(blob, compat, liodn_base);
+               fdt_fixup_pci_liodn_offsets(blob, "fsl,qoriq-pcie", liodn_base);
+       }
 }