diff options
author | Tom Rini <trini@konsulko.com> | 2017-02-04 01:33:42 (GMT) |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2017-02-04 01:33:42 (GMT) |
commit | c83a824e62277162ad35f52879b2316902c0eff5 (patch) | |
tree | fa91cdcda24b8822d0f1e52786b2657e4d68be27 /drivers | |
parent | 0ff27d4a94637d4b1937c625d33212375bd118d9 (diff) | |
parent | add63f94a9c3bbe1af3fdf3f4c56a5185a4c0504 (diff) | |
download | u-boot-fsl-qoriq-c83a824e62277162ad35f52879b2316902c0eff5.tar.xz |
Merge git://git.denx.de/u-boot-fsl-qoriq
Signed-off-by: Tom Rini <trini@konsulko.com>
Conflicts:
configs/ls1046aqds_defconfig
configs/ls1046aqds_nand_defconfig
configs/ls1046aqds_qspi_defconfig
configs/ls1046aqds_sdcard_ifc_defconfig
configs/ls1046aqds_sdcard_qspi_defconfig
configs/ls1046ardb_emmc_defconfig
configs/ls1046ardb_qspi_defconfig
configs/ls1046ardb_sdcard_defconfig
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/fsl-mc/mc.c | 103 |
1 files changed, 101 insertions, 2 deletions
diff --git a/drivers/net/fsl-mc/mc.c b/drivers/net/fsl-mc/mc.c index 46b8a6b..079082a 100644 --- a/drivers/net/fsl-mc/mc.c +++ b/drivers/net/fsl-mc/mc.c @@ -8,6 +8,7 @@ #include <linux/bug.h> #include <asm/io.h> #include <libfdt.h> +#include <net.h> #include <fdt_support.h> #include <fsl-mc/fsl_mc.h> #include <fsl-mc/fsl_mc_sys.h> @@ -195,10 +196,81 @@ static int calculate_mc_private_ram_params(u64 mc_private_ram_start_addr, return 0; } +static int mc_fixup_dpc_mac_addr(void *blob, int noff, int dpmac_id, + struct eth_device *eth_dev) +{ + int nodeoffset, err = 0; + char mac_name[10]; + const char link_type_mode[] = "FIXED_LINK"; + unsigned char env_enetaddr[6]; + + sprintf(mac_name, "mac@%d", dpmac_id); + + /* node not found - create it */ + nodeoffset = fdt_subnode_offset(blob, noff, (const char *) mac_name); + if (nodeoffset < 0) { + err = fdt_increase_size(blob, 200); + if (err) { + printf("fdt_increase_size: err=%s\n", + fdt_strerror(err)); + return err; + } + + nodeoffset = fdt_add_subnode(blob, noff, mac_name); + + /* add default property of fixed link */ + err = fdt_appendprop_string(blob, nodeoffset, + "link_type", link_type_mode); + if (err) { + printf("fdt_appendprop_string: err=%s\n", + fdt_strerror(err)); + return err; + } + } + + /* port_mac_address property present in DPC */ + if (fdt_get_property(blob, nodeoffset, "port_mac_address", NULL)) { + /* MAC addr randomly assigned - leave the one in DPC */ + eth_getenv_enetaddr_by_index("eth", eth_dev->index, + env_enetaddr); + if (is_zero_ethaddr(env_enetaddr)) + return err; + + /* replace DPC MAC address with u-boot env one */ + err = fdt_setprop(blob, nodeoffset, "port_mac_address", + eth_dev->enetaddr, 6); + if (err) { + printf("fdt_setprop mac: err=%s\n", fdt_strerror(err)); + return err; + } + + return 0; + } + + /* append port_mac_address property to mac node in DPC */ + err = fdt_increase_size(blob, 80); + if (err) { + printf("fdt_increase_size: err=%s\n", fdt_strerror(err)); + return err; + } + + err = fdt_appendprop(blob, nodeoffset, + "port_mac_address", eth_dev->enetaddr, 6); + if (err) { + printf("fdt_appendprop: err=%s\n", fdt_strerror(err)); + return err; + } + + return err; +} + static int mc_fixup_dpc(u64 dpc_addr) { void *blob = (void *)dpc_addr; - int nodeoffset; + int nodeoffset, err = 0; + char ethname[10]; + struct eth_device *eth_dev; + int i; /* delete any existing ICID pools */ nodeoffset = fdt_path_offset(blob, "/resources/icid_pools"); @@ -220,9 +292,36 @@ static int mc_fixup_dpc(u64 dpc_addr) FSL_DPAA2_STREAM_ID_END - FSL_DPAA2_STREAM_ID_START + 1, 1); + /* fixup MAC addresses for dpmac ports */ + nodeoffset = fdt_path_offset(blob, "/board_info/ports"); + if (nodeoffset < 0) + goto out; + + for (i = WRIOP1_DPMAC1; i < NUM_WRIOP_PORTS; i++) { + /* port not enabled */ + if ((wriop_is_enabled_dpmac(i) != 1) || + (wriop_get_phy_address(i) == -1)) + continue; + + sprintf(ethname, "DPMAC%d@%s", i, + phy_interface_strings[wriop_get_enet_if(i)]); + + eth_dev = eth_get_dev_by_name(ethname); + if (eth_dev == NULL) + continue; + + err = mc_fixup_dpc_mac_addr(blob, nodeoffset, i, eth_dev); + if (err) { + printf("mc_fixup_dpc_mac_addr failed: err=%s\n", + fdt_strerror(err)); + goto out; + } + } + +out: flush_dcache_range(dpc_addr, dpc_addr + fdt_totalsize(blob)); - return 0; + return err; } static int load_mc_dpc(u64 mc_ram_addr, size_t mc_ram_size, u64 mc_dpc_addr) |