fdt: rework fdt_fixup_ethernet() to use env instead of bd_t
Move to using the environment variables 'ethaddr', 'eth1addr', etc.. instead of bd->bi_enetaddr, bi_enet1addr, etc. This makes the code a bit more flexible to the number of ethernet interfaces. Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
This commit is contained in:
parent
4cacf7c646
commit
ba37aa0328
|
@ -368,55 +368,41 @@ int fdt_fixup_memory(void *blob, u64 start, u64 size)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) ||\
|
void fdt_fixup_ethernet(void *fdt)
|
||||||
defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3)
|
|
||||||
|
|
||||||
void fdt_fixup_ethernet(void *fdt, bd_t *bd)
|
|
||||||
{
|
{
|
||||||
int node;
|
int node, i, j;
|
||||||
|
char enet[16], *tmp, *end;
|
||||||
|
char mac[16] = "ethaddr";
|
||||||
const char *path;
|
const char *path;
|
||||||
|
unsigned char mac_addr[6];
|
||||||
|
|
||||||
node = fdt_path_offset(fdt, "/aliases");
|
node = fdt_path_offset(fdt, "/aliases");
|
||||||
if (node >= 0) {
|
if (node < 0)
|
||||||
#if defined(CONFIG_HAS_ETH0)
|
return;
|
||||||
path = fdt_getprop(fdt, node, "ethernet0", NULL);
|
|
||||||
if (path) {
|
i = 0;
|
||||||
do_fixup_by_path(fdt, path, "mac-address",
|
while ((tmp = getenv(mac)) != NULL) {
|
||||||
bd->bi_enetaddr, 6, 0);
|
sprintf(enet, "ethernet%d", i);
|
||||||
do_fixup_by_path(fdt, path, "local-mac-address",
|
path = fdt_getprop(fdt, node, enet, NULL);
|
||||||
bd->bi_enetaddr, 6, 1);
|
if (!path) {
|
||||||
|
debug("No alias for %s\n", enet);
|
||||||
|
sprintf(mac, "eth%daddr", ++i);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_HAS_ETH1)
|
for (j = 0; j < 6; j++) {
|
||||||
path = fdt_getprop(fdt, node, "ethernet1", NULL);
|
mac_addr[j] = tmp ? simple_strtoul(tmp, &end, 16) : 0;
|
||||||
if (path) {
|
if (tmp)
|
||||||
do_fixup_by_path(fdt, path, "mac-address",
|
tmp = (*end) ? end+1 : end;
|
||||||
bd->bi_enet1addr, 6, 0);
|
|
||||||
do_fixup_by_path(fdt, path, "local-mac-address",
|
|
||||||
bd->bi_enet1addr, 6, 1);
|
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_HAS_ETH2)
|
do_fixup_by_path(fdt, path, "mac-address", &mac_addr, 6, 0);
|
||||||
path = fdt_getprop(fdt, node, "ethernet2", NULL);
|
do_fixup_by_path(fdt, path, "local-mac-address",
|
||||||
if (path) {
|
&mac_addr, 6, 1);
|
||||||
do_fixup_by_path(fdt, path, "mac-address",
|
|
||||||
bd->bi_enet2addr, 6, 0);
|
sprintf(mac, "eth%daddr", ++i);
|
||||||
do_fixup_by_path(fdt, path, "local-mac-address",
|
|
||||||
bd->bi_enet2addr, 6, 1);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#if defined(CONFIG_HAS_ETH3)
|
|
||||||
path = fdt_getprop(fdt, node, "ethernet3", NULL);
|
|
||||||
if (path) {
|
|
||||||
do_fixup_by_path(fdt, path, "mac-address",
|
|
||||||
bd->bi_enet3addr, 6, 0);
|
|
||||||
do_fixup_by_path(fdt, path, "local-mac-address",
|
|
||||||
bd->bi_enet3addr, 6, 1);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef CONFIG_HAS_FSL_DR_USB
|
#ifdef CONFIG_HAS_FSL_DR_USB
|
||||||
void fdt_fixup_dr_usb(void *blob, bd_t *bd)
|
void fdt_fixup_dr_usb(void *blob, bd_t *bd)
|
||||||
|
|
|
@ -314,7 +314,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)
|
||||||
|
|
||||||
fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
|
fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
|
||||||
|
|
||||||
fdt_fixup_ethernet(blob, bd);
|
fdt_fixup_ethernet(blob);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
/* ------------------------------------------------------------------------- */
|
/* ------------------------------------------------------------------------- */
|
||||||
|
|
|
@ -191,7 +191,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)
|
||||||
#endif
|
#endif
|
||||||
ft_clock_setup(blob, bd);
|
ft_clock_setup(blob, bd);
|
||||||
#ifdef CONFIG_HAS_ETH0
|
#ifdef CONFIG_HAS_ETH0
|
||||||
fdt_fixup_ethernet(blob, bd);
|
fdt_fixup_ethernet(blob);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -307,7 +307,7 @@ void ft_cpu_setup (void *blob, bd_t *bd)
|
||||||
|
|
||||||
#if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) ||\
|
#if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) ||\
|
||||||
defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3)
|
defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3)
|
||||||
fdt_fixup_ethernet(blob, bd);
|
fdt_fixup_ethernet(blob);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
do_fixup_by_path_u32(blob, cpu_path, "bus-frequency", bd->bi_busfreq, 1);
|
do_fixup_by_path_u32(blob, cpu_path, "bus-frequency", bd->bi_busfreq, 1);
|
||||||
|
|
|
@ -53,7 +53,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)
|
||||||
|
|
||||||
#if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) ||\
|
#if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) ||\
|
||||||
defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3)
|
defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3)
|
||||||
fdt_fixup_ethernet(blob, bd);
|
fdt_fixup_ethernet(blob);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
|
do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
|
||||||
|
|
|
@ -212,7 +212,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)
|
||||||
|
|
||||||
#if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) ||\
|
#if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) ||\
|
||||||
defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3)
|
defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3)
|
||||||
fdt_fixup_ethernet(blob, bd);
|
fdt_fixup_ethernet(blob);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
|
do_fixup_by_prop_u32(blob, "device_type", "cpu", 4,
|
||||||
|
|
|
@ -25,7 +25,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)
|
||||||
|
|
||||||
#if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) \
|
#if defined(CONFIG_HAS_ETH0) || defined(CONFIG_HAS_ETH1) \
|
||||||
|| defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3)
|
|| defined(CONFIG_HAS_ETH2) || defined(CONFIG_HAS_ETH3)
|
||||||
fdt_fixup_ethernet(blob, bd);
|
fdt_fixup_ethernet(blob);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef CFG_NS16550
|
#ifdef CFG_NS16550
|
||||||
|
|
|
@ -40,7 +40,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)
|
||||||
gd->brg_clk, 1);
|
gd->brg_clk, 1);
|
||||||
|
|
||||||
/* Fixup ethernet MAC addresses */
|
/* Fixup ethernet MAC addresses */
|
||||||
fdt_fixup_ethernet(blob, bd);
|
fdt_fixup_ethernet(blob);
|
||||||
|
|
||||||
fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
|
fdt_fixup_memory(blob, (u64)bd->bi_memstart, (u64)bd->bi_memsize);
|
||||||
}
|
}
|
||||||
|
|
|
@ -130,7 +130,7 @@ void ft_cpu_setup(void *blob, bd_t *bd)
|
||||||
* Fixup all ethernet nodes
|
* Fixup all ethernet nodes
|
||||||
* Note: aliases in the dts are required for this
|
* Note: aliases in the dts are required for this
|
||||||
*/
|
*/
|
||||||
fdt_fixup_ethernet(blob, bd);
|
fdt_fixup_ethernet(blob);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Fixup all available PCIe nodes by setting the device_type property
|
* Fixup all available PCIe nodes by setting the device_type property
|
||||||
|
|
|
@ -45,7 +45,7 @@ void do_fixup_by_compat(void *fdt, const char *compat,
|
||||||
void do_fixup_by_compat_u32(void *fdt, const char *compat,
|
void do_fixup_by_compat_u32(void *fdt, const char *compat,
|
||||||
const char *prop, u32 val, int create);
|
const char *prop, u32 val, int create);
|
||||||
int fdt_fixup_memory(void *blob, u64 start, u64 size);
|
int fdt_fixup_memory(void *blob, u64 start, u64 size);
|
||||||
void fdt_fixup_ethernet(void *fdt, bd_t *bd);
|
void fdt_fixup_ethernet(void *fdt);
|
||||||
int fdt_find_and_setprop(void *fdt, const char *node, const char *prop,
|
int fdt_find_and_setprop(void *fdt, const char *node, const char *prop,
|
||||||
const void *val, int len, int create);
|
const void *val, int len, int create);
|
||||||
void fdt_fixup_qe_firmware(void *fdt);
|
void fdt_fixup_qe_firmware(void *fdt);
|
||||||
|
|
Loading…
Reference in New Issue