> On a good phy boot I see the following:
> [    2.810749] davinci_mdio 4a101000.mdio: davinci mdio revision 1.6
> [    2.817206] davinci_mdio 4a101000.mdio: detected phy mask fffffffe
> [    2.833517] libphy: 4a101000.mdio: probed
> [    2.837871] davinci_mdio 4a101000.mdio: phy[0]: device 
> 4a101000.mdio:00, driver unknown
>  
>
On a 'bad phy' boot I see the following (differences highlighted):
> [    2.806763] davinci_mdio 4a101000.mdio: davinci mdio revision 1.6
> [    2.813213] davinci_mdio 4a101000.mdio: detected phy mask *fffffffb*
> [    2.829512] libphy: 4a101000.mdio: probed
> [    2.833875] davinci_mdio 4a101000.mdio: phy[2]: device 
> 4a101000.mdio:02, driver unknown
>
>
I've experienced the same issue and found your patch 
https://github.com/RobertCNelson/linux-dev/blob/master/patches/beaglebone/phy/0003-cpsw-search-for-phy.patch
 
to fix it.

However it seems to be more natural to me to patch the cpsw driver to use 
the first phy that it will found. Please see my suggestion for that (it's 
based on kernel 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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to