Commit 8e5f0497c8a8ab9bd7314737f2edb4711733b6fe

Authored by Tom Rini

Merge git://git.denx.de/u-boot-dm

Showing 6 changed files Side-by-side Diff

... ... @@ -1603,6 +1603,15 @@
1603 1603  
1604 1604 See doc/README.link-local for more information.
1605 1605  
  1606 + - MAC address from environment variables
  1607 +
  1608 + FDT_SEQ_MACADDR_FROM_ENV
  1609 +
  1610 + Fix-up device tree with MAC addresses fetched sequentially from
  1611 + environment variables. This config work on assumption that
  1612 + non-usable ethernet node of device-tree are either not present
  1613 + or their status has been marked as "disabled".
  1614 +
1606 1615 - CDP Options:
1607 1616 CONFIG_CDP_DEVICE_ID
1608 1617  
arch/arm/lib/bootm-fdt.c
... ... @@ -25,6 +25,13 @@
25 25  
26 26 DECLARE_GLOBAL_DATA_PTR;
27 27  
  28 +#ifdef CONFIG_FMAN_ENET
  29 +__weak int fdt_update_ethernet_dt(void *blob)
  30 +{
  31 + return 0;
  32 +}
  33 +#endif
  34 +
28 35 int arch_fixup_fdt(void *blob)
29 36 {
30 37 int ret = 0;
... ... @@ -64,6 +71,11 @@
64 71 #endif
65 72 #endif
66 73  
  74 +#ifdef CONFIG_FMAN_ENET
  75 + ret = fdt_update_ethernet_dt(blob);
  76 + if (ret)
  77 + return ret;
  78 +#endif
67 79 return 0;
68 80 }
board/freescale/ls1046ardb/eth.c
... ... @@ -75,4 +75,55 @@
75 75  
76 76 return pci_eth_init(bis);
77 77 }
  78 +
  79 +#ifdef CONFIG_FMAN_ENET
  80 +int fdt_update_ethernet_dt(void *blob)
  81 +{
  82 + u32 srds_s1;
  83 + int i, prop;
  84 + int offset, nodeoff;
  85 + const char *path;
  86 + struct ccsr_gur *gur = (void *)(CONFIG_SYS_FSL_GUTS_ADDR);
  87 +
  88 + srds_s1 = in_be32(&gur->rcwsr[4]) &
  89 + FSL_CHASSIS2_RCWSR4_SRDS1_PRTCL_MASK;
  90 + srds_s1 >>= FSL_CHASSIS2_RCWSR4_SRDS1_PRTCL_SHIFT;
  91 +
  92 + /* Cycle through all aliases */
  93 + for (prop = 0; ; prop++) {
  94 + const char *name;
  95 +
  96 + /* FDT might have been edited, recompute the offset */
  97 + offset = fdt_first_property_offset(blob,
  98 + fdt_path_offset(blob,
  99 + "/aliases")
  100 + );
  101 + /* Select property number 'prop' */
  102 + for (i = 0; i < prop; i++)
  103 + offset = fdt_next_property_offset(blob, offset);
  104 +
  105 + if (offset < 0)
  106 + break;
  107 +
  108 + path = fdt_getprop_by_offset(blob, offset, &name, NULL);
  109 + nodeoff = fdt_path_offset(blob, path);
  110 +
  111 + switch (srds_s1) {
  112 + case 0x1133:
  113 + if (!strcmp(name, "ethernet0"))
  114 + fdt_status_disabled(blob, nodeoff);
  115 +
  116 + if (!strcmp(name, "ethernet1"))
  117 + fdt_status_disabled(blob, nodeoff);
  118 + break;
  119 + default:
  120 + printf("%s: Invalid SerDes prtcl 0x%x for LS1046ARDB\n",
  121 + __func__, srds_s1);
  122 + break;
  123 + }
  124 + }
  125 +
  126 + return 0;
  127 +}
  128 +#endif
common/fdt_support.c
... ... @@ -508,12 +508,16 @@
508 508  
509 509 void fdt_fixup_ethernet(void *fdt)
510 510 {
511   - int i, j, prop;
  511 + int i = 0, j, prop;
512 512 char *tmp, *end;
513 513 char mac[16];
514 514 const char *path;
515 515 unsigned char mac_addr[ARP_HLEN];
516 516 int offset;
  517 +#ifdef FDT_SEQ_MACADDR_FROM_ENV
  518 + int nodeoff;
  519 + const struct fdt_property *fdt_prop;
  520 +#endif
517 521  
518 522 if (fdt_path_offset(fdt, "/aliases") < 0)
519 523 return;
... ... @@ -526,7 +530,7 @@
526 530 offset = fdt_first_property_offset(fdt,
527 531 fdt_path_offset(fdt, "/aliases"));
528 532 /* Select property number 'prop' */
529   - for (i = 0; i < prop; i++)
  533 + for (j = 0; j < prop; j++)
530 534 offset = fdt_next_property_offset(fdt, offset);
531 535  
532 536 if (offset < 0)
533 537  
534 538  
... ... @@ -535,11 +539,16 @@
535 539 path = fdt_getprop_by_offset(fdt, offset, &name, NULL);
536 540 if (!strncmp(name, "ethernet", 8)) {
537 541 /* Treat plain "ethernet" same as "ethernet0". */
538   - if (!strcmp(name, "ethernet"))
  542 + if (!strcmp(name, "ethernet")
  543 +#ifdef FDT_SEQ_MACADDR_FROM_ENV
  544 + || !strcmp(name, "ethernet0")
  545 +#endif
  546 + )
539 547 i = 0;
  548 +#ifndef FDT_SEQ_MACADDR_FROM_ENV
540 549 else
541 550 i = trailing_strtol(name);
542   -
  551 +#endif
543 552 if (i != -1) {
544 553 if (i == 0)
545 554 strcpy(mac, "ethaddr");
... ... @@ -548,6 +557,14 @@
548 557 } else {
549 558 continue;
550 559 }
  560 +#ifdef FDT_SEQ_MACADDR_FROM_ENV
  561 + nodeoff = fdt_path_offset(fdt, path);
  562 + fdt_prop = fdt_get_property(fdt, nodeoff, "status",
  563 + NULL);
  564 + if (fdt_prop && !strcmp(fdt_prop->data, "disabled"))
  565 + continue;
  566 + i++;
  567 +#endif
551 568 tmp = env_get(mac);
552 569 if (!tmp)
553 570 continue;
include/configs/ls1046ardb.h
... ... @@ -195,6 +195,8 @@
195 195  
196 196 #define FM1_10GEC1_PHY_ADDR 0x0
197 197  
  198 +#define FDT_SEQ_MACADDR_FROM_ENV
  199 +
198 200 #define CONFIG_ETHPRIME "FM1@DTSEC3"
199 201 #endif
200 202  
include/fdt_support.h
... ... @@ -290,5 +290,8 @@
290 290 int fdtdec_get_int(const void *blob, int node, const char *prop_name,
291 291 int default_val);
292 292 #endif
  293 +#ifdef CONFIG_FMAN_ENET
  294 +int fdt_update_ethernet_dt(void *blob);
  295 +#endif
293 296 #endif /* ifndef __FDT_SUPPORT_H */