Some systems use a SoM (system on module) in such a way that the PHY addresses depend on the carrier board used, or even on the geographic position of the SoM on the carrier board. This patch adds support for runtime assignment of the PHY addresses for the TSEC ports through environment variables "tsec_1_phy_addr", "tsec_2_phy_addr", ...
Signed-off-by: Wolfgang Denk <[email protected]> Cc: Joe Hershberger <[email protected]> --- This is a RFC patch to have a base for discussing the approach. There are a few things I dislike - all comments welcome: - It would be nice if there was a generic approach that works for all types of network interfaces instead of only TSEC ports, but I could not find a good generic place for such a hook. - I'm not sure if "tsec_1_phy_addr" etc. is a good name ;-) - Maybe there is another way to address this issue? I can't believe we're the first to run into this type of problem? drivers/net/tsec.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/net/tsec.c b/drivers/net/tsec.c index f5e314b..e86e48c 100644 --- a/drivers/net/tsec.c +++ b/drivers/net/tsec.c @@ -567,6 +567,26 @@ static phy_interface_t tsec_get_interface(struct tsec_private *priv) return PHY_INTERFACE_MODE_MII; } +static void update_phy_addr(int phy_nr) +{ + char *str, buf[32]; + + sprintf(buf, "tsec_%d_phy_addr", phy_nr); + + str = getenv(buf); + + if (str) { + ulong val = simple_strtoul(str, NULL, 16); + + debug("FIX TSEC%d_PHY_ADDR : %d => %ld\n", + phy_nr, tsec_info[phy_nr].phyaddr, val); + + tsec_info[phy_nr].phyaddr = val; + } else { + debug("FIX TSEC%d_PHY_ADDR : %s not set\n", + phy_nr, buf); + } +} /* Discover which PHY is attached to the device, and configure it * properly. If the PHY is not recognized, then return 0 @@ -671,7 +691,10 @@ int tsec_eth_init(bd_t *bis, struct tsec_info_struct *tsecs, int num) int i; int ret, count = 0; + debug ("tsec_eth_init()\n"); for (i = 0; i < num; i++) { + update_phy_addr(i); + ret = tsec_initialize(bis, &tsecs[i]); if (ret > 0) count += ret; -- 1.7.11.7 _______________________________________________ U-Boot mailing list [email protected] http://lists.denx.de/mailman/listinfo/u-boot

