Hi Jay, I've run into the same problem, so thank you much for your work. However it seems more natural to me to patch the cpsw driver to use the first MAC which is found rather than modifying the DT at runtime. Please see my suggestion (based on 3.12.30):
diff -Naur linux.orig/arch/arm/boot/dts/am335x-bone-common.dtsi linux/arch/ arm/boot/dts/am335x-bone-common.dtsi --- linux.orig/arch/arm/boot/dts/am335x-bone-common.dtsi 2014-10-09 15:46 :37.000000000 +0200 +++ linux/arch/arm/boot/dts/am335x-bone-common.dtsi 2015-04-23 23:38: 14.210206750 +0200 @@ -322,7 +322,7 @@ }; &cpsw_emac0 { - phy_id = <&davinci_mdio>, <0>; + phy_id = <&davinci_mdio>; phy-mode = "mii"; }; diff -Naur linux.orig/drivers/net/ethernet/ti/cpsw.c linux/drivers/net/ ethernet/ti/cpsw.c --- linux.orig/drivers/net/ethernet/ti/cpsw.c 2014-10-09 15:46: 37.000000000 +0200 +++ linux/drivers/net/ethernet/ti/cpsw.c 2015-04-24 08:16:54.401495090 + 0200 @@ -1810,6 +1810,20 @@ slave->port_vlan = data->dual_emac_res_vlan; } +static int match_first_phy(struct device *dev, void *data) +{ + const char *dn = dev_name(dev); + const char *mn = (const char *) data; + while (*mn) { + if (*dn != *mn) + return 0; + dn++; + mn++; + } + + return 1; +} + static int cpsw_probe_dt(struct cpsw_platform_data *data, struct platform_device *pdev) { @@ -1895,7 +1909,6 @@ for_each_child_of_node(node, slave_node) { struct cpsw_slave_data *slave_data = data->slave_data + i; const void *mac_addr = NULL; - u32 phyid; int lenp; const __be32 *parp; struct device_node *mdio_node; @@ -1906,19 +1919,31 @@ continue; parp = of_get_property(slave_node, "phy_id", &lenp); - if ((parp == NULL) || (lenp != (sizeof(void *) * 2))) { + if ((parp == NULL) || (lenp < sizeof(void *))) { pr_err("Missing slave[%d] phy_id property\n", i); return -EINVAL; } mdio_node = of_find_node_by_phandle(be32_to_cpup(parp)); - phyid = be32_to_cpup(parp+1); mdio = of_find_device_by_node(mdio_node); if (!mdio) { pr_err("Missing mdio platform device\n"); return -EINVAL; } - snprintf(slave_data->phy_id, sizeof(slave_data->phy_id), - PHY_ID_FMT, mdio->name, phyid); + if (lenp >= (sizeof(void *) * 2)) { + u32 phyid; + phyid = be32_to_cpup(parp+1); + snprintf(slave_data->phy_id, sizeof(slave_data->phy_id), + PHY_ID_FMT, mdio->name, phyid); + } else { + struct device *phy; + phy = bus_find_device( + &mdio_bus_type, NULL, (void *) mdio->name, match_first_phy ); + if (!phy) { + pr_err("No PHY found\n"); + return -EINVAL; + } + strncpy(slave_data->phy_id, dev_name(phy), sizeof(slave_data-> phy_id)); + } mac_addr = of_get_mac_address(slave_node); if (mac_addr) -- For more options, visit http://beagleboard.org/discuss --- You received this message because you are subscribed to the Google Groups "BeagleBoard" group. To unsubscribe from this group and stop receiving emails from it, send an email to beagleboard+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.