summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README9
-rw-r--r--arch/arm/lib/bootm-fdt.c12
-rw-r--r--board/freescale/ls1046ardb/eth.c51
-rw-r--r--common/fdt_support.c25
-rw-r--r--include/configs/ls1046ardb.h2
-rw-r--r--include/fdt_support.h3
6 files changed, 98 insertions, 4 deletions
diff --git a/README b/README
index 7594f3caae..06f3ed057d 100644
--- 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
diff --git a/arch/arm/lib/bootm-fdt.c b/arch/arm/lib/bootm-fdt.c
index eaa817b9ac..fcc2a0e214 100644
--- a/arch/arm/lib/bootm-fdt.c
+++ b/arch/arm/lib/bootm-fdt.c
@@ -25,6 +25,13 @@
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;
}
diff --git a/board/freescale/ls1046ardb/eth.c b/board/freescale/ls1046ardb/eth.c
index ac8bbec9a3..9a07609820 100644
--- a/board/freescale/ls1046ardb/eth.c
+++ b/board/freescale/ls1046ardb/eth.c
@@ -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
diff --git a/common/fdt_support.c b/common/fdt_support.c
index 6896dcb285..724452d754 100644
--- a/common/fdt_support.c
+++ b/common/fdt_support.c
@@ -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;
diff --git a/include/configs/ls1046ardb.h b/include/configs/ls1046ardb.h
index 784894f0b7..793e67506d 100644
--- a/include/configs/ls1046ardb.h
+++ b/include/configs/ls1046ardb.h
@@ -195,6 +195,8 @@
#define FM1_10GEC1_PHY_ADDR 0x0
+#define FDT_SEQ_MACADDR_FROM_ENV
+
#define CONFIG_ETHPRIME "FM1@DTSEC3"
#endif
diff --git a/include/fdt_support.h b/include/fdt_support.h
index e0f908636c..f00fadcddb 100644
--- a/include/fdt_support.h
+++ b/include/fdt_support.h
@@ -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 */