]> git.karo-electronics.de Git - karo-tx-uboot.git/blobdiff - arch/powerpc/cpu/mpc85xx/portals.c
Merge branch 'master' of git://www.denx.de/git/u-boot-mpc85xx
[karo-tx-uboot.git] / arch / powerpc / cpu / mpc85xx / portals.c
index 418dd9d9ead246e53918a0f3108362f6803a8391..672edde455ef030cce21e95884b5a71661f8240c 100644 (file)
 #include <asm/fsl_portals.h>
 #include <asm/fsl_liodn.h>
 
-static ccsr_qman_t *qman = (void *)CONFIG_SYS_FSL_QMAN_ADDR;
-static ccsr_bman_t *bman = (void *)CONFIG_SYS_FSL_BMAN_ADDR;
-
 void setup_portals(void)
 {
+       ccsr_qman_t *qman = (void *)CONFIG_SYS_FSL_QMAN_ADDR;
 #ifdef CONFIG_FSL_CORENET
        int i;
 
@@ -130,24 +128,32 @@ static int fdt_qportal(void *blob, int off, int id, char *name,
 
        childoff = fdt_subnode_offset(blob, off, name);
        if (create) {
-               if (childoff <= 0)
-                       childoff = fdt_add_subnode(blob, off, name);
+               char handle[64], *p;
 
-               if (childoff > 0) {
-                       char handle[64], *p;
+               strncpy(handle, name, sizeof(handle));
+               p = strchr(handle, '@');
+               if (!strncmp(name, "fman", 4)) {
+                       *p = *(p + 1);
+                       p++;
+               }
+               *p = '\0';
 
-                       strncpy(handle, name, sizeof(handle));
-                       p = strchr(handle, '@');
-                       if (!strncmp(name, "fman", 4)) {
-                               *p = *(p + 1);
-                               p++;
-                       }
-                       *p = '\0';
+               dev_off = fdt_path_offset(blob, handle);
+               /* skip this node if alias is not found */
+               if (dev_off == -FDT_ERR_BADPATH)
+                       return 0;
+               if (dev_off < 0)
+                       return dev_off;
+
+               if (childoff <= 0)
+                       childoff = fdt_add_subnode(blob, off, name);
 
-                       dev_off = fdt_path_offset(blob, handle);
-                       if (dev_off < 0)
-                               return dev_off;
+               /* need to update the dev_off after adding a subnode */
+               dev_off = fdt_path_offset(blob, handle);
+               if (dev_off < 0)
+                       return dev_off;
 
+               if (childoff > 0) {
                        dev_handle = fdt_get_phandle(blob, dev_off);
                        if (dev_handle <= 0) {
                                dev_handle = fdt_alloc_phandle(blob);
@@ -166,6 +172,20 @@ static int fdt_qportal(void *blob, int off, int id, char *name,
                        num = get_dpaa_liodn(dev, &liodns[0], id);
                        ret = fdt_setprop(blob, childoff, "fsl,liodn",
                                          &liodns[0], sizeof(u32) * num);
+                       if (!strncmp(name, "pme", 3)) {
+                               u32 pme_rev1, pme_rev2;
+                               ccsr_pme_t *pme_regs =
+                                       (void *)CONFIG_SYS_FSL_CORENET_PME_ADDR;
+
+                               pme_rev1 = in_be32(&pme_regs->pm_ip_rev_1);
+                               pme_rev2 = in_be32(&pme_regs->pm_ip_rev_2);
+                               ret = fdt_setprop(blob, childoff,
+                                       "fsl,pme-rev1", &pme_rev1, sizeof(u32));
+                               if (ret < 0)
+                                       return ret;
+                               ret = fdt_setprop(blob, childoff,
+                                       "fsl,pme-rev2", &pme_rev2, sizeof(u32));
+                       }
 #endif
                } else {
                        return childoff;
@@ -182,14 +202,19 @@ void fdt_fixup_qportals(void *blob)
 {
        int off, err;
        unsigned int maj, min;
+       unsigned int ip_cfg;
+       ccsr_qman_t *qman = (void *)CONFIG_SYS_FSL_QMAN_ADDR;
        u32 rev_1 = in_be32(&qman->ip_rev_1);
+       u32 rev_2 = in_be32(&qman->ip_rev_2);
        char compat[64];
        int compat_len;
 
        maj = (rev_1 >> 8) & 0xff;
        min = rev_1 & 0xff;
+       ip_cfg = rev_2 & 0xff;
 
-       compat_len = sprintf(compat, "fsl,qman-portal-%u.%u", maj, min) + 1;
+       compat_len = sprintf(compat, "fsl,qman-portal-%u.%u.%u",
+                                       maj, min, ip_cfg) + 1;
        compat_len += sprintf(compat + compat_len, "fsl,qman-portal") + 1;
 
        off = fdt_node_offset_by_compatible(blob, -1, "fsl,qman-portal");
@@ -245,6 +270,12 @@ void fdt_fixup_qportals(void *blob)
                                goto err;
                }
 #endif
+#ifdef CONFIG_SYS_DPAA_RMAN
+               err = fdt_qportal(blob, off, i, "rman@0",
+                                 FSL_HW_PORTAL_RMAN, 1);
+               if (err < 0)
+                       goto err;
+#endif
 
 err:
                if (err < 0) {
@@ -261,14 +292,20 @@ void fdt_fixup_bportals(void *blob)
 {
        int off, err;
        unsigned int maj, min;
+       unsigned int ip_cfg;
+       ccsr_bman_t *bman = (void *)CONFIG_SYS_FSL_BMAN_ADDR;
        u32 rev_1 = in_be32(&bman->ip_rev_1);
+       u32 rev_2 = in_be32(&bman->ip_rev_2);
        char compat[64];
        int compat_len;
 
        maj = (rev_1 >> 8) & 0xff;
        min = rev_1 & 0xff;
 
-       compat_len = sprintf(compat, "fsl,bman-portal-%u.%u", maj, min) + 1;
+       ip_cfg = rev_2 & 0xff;
+
+       compat_len = sprintf(compat, "fsl,bman-portal-%u.%u.%u",
+                                maj, min, ip_cfg) + 1;
        compat_len += sprintf(compat + compat_len, "fsl,bman-portal") + 1;
 
        off = fdt_node_offset_by_compatible(blob, -1, "fsl,bman-portal");