Merge git://git.denx.de/u-boot-dm
authorTom Rini <trini@konsulko.com>
Wed, 27 Dec 2017 13:17:05 +0000 (08:17 -0500)
committerTom Rini <trini@konsulko.com>
Wed, 27 Dec 2017 13:17:05 +0000 (08:17 -0500)
README
arch/arm/lib/bootm-fdt.c
board/freescale/ls1046ardb/eth.c
common/fdt_support.c
include/configs/ls1046ardb.h
include/fdt_support.h

diff --git a/README b/README
index 7594f3c..06f3ed0 100644 (file)
--- a/README
+++ b/README
@@ -1603,6 +1603,15 @@ The following options need to be configured:
 
                See doc/README.link-local for more information.
 
+ - MAC address from environment variables
+
+               FDT_SEQ_MACADDR_FROM_ENV
+
+               Fix-up device tree with MAC addresses fetched sequentially from
+               environment variables. This config work on assumption that
+               non-usable ethernet node of device-tree are either not present
+               or their status has been marked as "disabled".
+
  - CDP Options:
                CONFIG_CDP_DEVICE_ID
 
index eaa817b..fcc2a0e 100644 (file)
 
 DECLARE_GLOBAL_DATA_PTR;
 
+#ifdef CONFIG_FMAN_ENET
+__weak int fdt_update_ethernet_dt(void *blob)
+{
+       return 0;
+}
+#endif
+
 int arch_fixup_fdt(void *blob)
 {
        int ret = 0;
@@ -64,5 +71,10 @@ int arch_fixup_fdt(void *blob)
 #endif
 #endif
 
+#ifdef CONFIG_FMAN_ENET
+       ret = fdt_update_ethernet_dt(blob);
+       if (ret)
+               return ret;
+#endif
        return 0;
 }
index ac8bbec..9a07609 100644 (file)
@@ -75,3 +75,54 @@ int board_eth_init(bd_t *bis)
 
        return pci_eth_init(bis);
 }
+
+#ifdef CONFIG_FMAN_ENET
+int fdt_update_ethernet_dt(void *blob)
+{
+       u32 srds_s1;
+       int i, prop;
+       int offset, nodeoff;
+       const char *path;
+       struct ccsr_gur *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
+
+       srds_s1 = in_be32(&gur->rcwsr[4]) &
+                       FSL_CHASSIS2_RCWSR4_SRDS1_PRTCL_MASK;
+       srds_s1 >>= FSL_CHASSIS2_RCWSR4_SRDS1_PRTCL_SHIFT;
+
+       /* Cycle through all aliases */
+       for (prop = 0; ; prop++) {
+               const char *name;
+
+               /* FDT might have been edited, recompute the offset */
+               offset = fdt_first_property_offset(blob,
+                                                  fdt_path_offset(blob,
+                                                                  "/aliases")
+                                                  );
+               /* Select property number 'prop' */
+               for (i = 0; i < prop; i++)
+                       offset = fdt_next_property_offset(blob, offset);
+
+               if (offset < 0)
+                       break;
+
+               path = fdt_getprop_by_offset(blob, offset, &name, NULL);
+               nodeoff = fdt_path_offset(blob, path);
+
+               switch (srds_s1) {
+               case 0x1133:
+                       if (!strcmp(name, "ethernet0"))
+                               fdt_status_disabled(blob, nodeoff);
+
+                       if (!strcmp(name, "ethernet1"))
+                               fdt_status_disabled(blob, nodeoff);
+               break;
+               default:
+                       printf("%s: Invalid SerDes prtcl 0x%x for LS1046ARDB\n",
+                              __func__, srds_s1);
+               break;
+               }
+       }
+
+       return 0;
+}
+#endif
index 6896dcb..724452d 100644 (file)
@@ -508,12 +508,16 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size)
 
 void fdt_fixup_ethernet(void *fdt)
 {
-       int i, j, prop;
+       int i = 0, j, prop;
        char *tmp, *end;
        char mac[16];
        const char *path;
        unsigned char mac_addr[ARP_HLEN];
        int offset;
+#ifdef FDT_SEQ_MACADDR_FROM_ENV
+       int nodeoff;
+       const struct fdt_property *fdt_prop;
+#endif
 
        if (fdt_path_offset(fdt, "/aliases") < 0)
                return;
@@ -526,7 +530,7 @@ void fdt_fixup_ethernet(void *fdt)
                offset = fdt_first_property_offset(fdt,
                        fdt_path_offset(fdt, "/aliases"));
                /* Select property number 'prop' */
-               for (i = 0; i < prop; i++)
+               for (j = 0; j < prop; j++)
                        offset = fdt_next_property_offset(fdt, offset);
 
                if (offset < 0)
@@ -535,11 +539,16 @@ void fdt_fixup_ethernet(void *fdt)
                path = fdt_getprop_by_offset(fdt, offset, &name, NULL);
                if (!strncmp(name, "ethernet", 8)) {
                        /* Treat plain "ethernet" same as "ethernet0". */
-                       if (!strcmp(name, "ethernet"))
+                       if (!strcmp(name, "ethernet")
+#ifdef FDT_SEQ_MACADDR_FROM_ENV
+                        || !strcmp(name, "ethernet0")
+#endif
+                       )
                                i = 0;
+#ifndef FDT_SEQ_MACADDR_FROM_ENV
                        else
                                i = trailing_strtol(name);
-
+#endif
                        if (i != -1) {
                                if (i == 0)
                                        strcpy(mac, "ethaddr");
@@ -548,6 +557,14 @@ void fdt_fixup_ethernet(void *fdt)
                        } else {
                                continue;
                        }
+#ifdef FDT_SEQ_MACADDR_FROM_ENV
+                       nodeoff = fdt_path_offset(fdt, path);
+                       fdt_prop = fdt_get_property(fdt, nodeoff, "status",
+                                                   NULL);
+                       if (fdt_prop && !strcmp(fdt_prop->data, "disabled"))
+                               continue;
+                       i++;
+#endif
                        tmp = env_get(mac);
                        if (!tmp)
                                continue;
index 784894f..793e675 100644 (file)
 
 #define FM1_10GEC1_PHY_ADDR            0x0
 
+#define FDT_SEQ_MACADDR_FROM_ENV
+
 #define CONFIG_ETHPRIME                        "FM1@DTSEC3"
 #endif
 
index e0f9086..f00fadc 100644 (file)
@@ -290,4 +290,7 @@ int fdt_overlay_apply_verbose(void *fdt, void *fdto);
 int fdtdec_get_int(const void *blob, int node, const char *prop_name,
                int default_val);
 #endif
+#ifdef CONFIG_FMAN_ENET
+int fdt_update_ethernet_dt(void *blob);
+#endif
 #endif /* ifndef __FDT_SUPPORT_H */