On 22/04/16 12:45, Timur Tabi wrote: > Timur Tabi wrote: >>> >> >> So I've done some more research, and I believe that the internal phy is >> not a candidate for phylib, but the external phy (which is a real phy) >> might be. There's no MDIO bus to the internal phy. >> >> Does this mean that I will need to enable a PHY driver, and that driver >> will control the external phy? If so, then does that mean that I would >> delete all to code in my driver that calls emac_phy_read() and >> emac_phy_write()? For example, I wouldn't need emac_phy_link_check() >> any more? > > So I think I have it partially working, but I'm not sure if I'm doing > things correctly, and I'd like some help. > > The external phy is an Atheros 8031, so I load the at803x driver. I > added this code to my driver: > > mii_bus = devm_mdiobus_alloc(&pdev->dev); > mii_bus->phy_mask = ~(1 << adpt->hw.phy_addr); > mii_bus->read = emac_mdio_read; > mii_bus->write = emac_mdio_write; > mii_bus->reset = emac_mdio_reset; > mii_bus->parent = &pdev->dev; > mii_bus->priv = hw; > > mdiobus_register(mii_bus); > > When I call mdiobus_register, I can see that the at803x_probe() probe > function is called, so a connection is made. > > The problem is that after that point, it appears that the at803x driver > is never called again. I tried bring the interface up and down, and > connecting and disconnecting an Ethernet cable, but that didn't trigger > anything. I would expect the PHY driver to do more than just probe. Are you utilizing the PHYLIB APIs properly? You need at least a phy_start() to start the PHY state machine, and an adjust_link callback to be provided to phy_connect() (or of_phy_connect()) to manage link state changes. And that's the very basic minimum here, there could be additional APIs that you may end up using. There are tons of example in tree of drivers doing this, bcmgenet, bcmsysport, tg3 etc. -- Florian -- To unsubscribe from this list: send the line "unsubscribe linux-arm-msm" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html