[U-Boot] Question: Information regarding MII and PHY

Andy Fleming afleming at gmail.com
Fri Sep 23 01:36:11 CEST 2011


On Thu, Sep 22, 2011 at 6:27 PM, Graeme Russ <graeme.russ at gmail.com> wrote:
> Hi Mike,
>
> On Fri, Sep 23, 2011 at 8:21 AM, Mike Frysinger <vapier at gentoo.org> wrote:
>> On Wednesday, September 21, 2011 23:12:44 Graeme Russ wrote:
>>> On Thu, Sep 22, 2011 at 11:20 AM, Graeme Russ wrote:
>
> [snip]
>
>> i believe this is correct.  the intention is to be like Linux where you've got
>> a driver for the MAC, and you've got drivers for the PHYs, and the MAC driver
>> provides the hooks for the PHY layer to access what it needs.
>>
>> not all drivers have been converted to the PHY abstraction, and we don't have
>> a requirement atm for that.
>>
>> there's also a bit of a mess as we try to move to the Linux phylib code ...
>> another area that needs a bit of TLC.
>
> OK, I just saw another thread (phylib: reset mii bus only if reset handler
> is registered) which raises a question in my head as to how I should
> provide PHY support for a brand-spakin' new driver
>
> Is there any documentation on how I should build a new MAC and PHY driver
> from scratch (i.e. what is the official network driver API)

There's not really any documentation for phylib at the moment, except
the header files. There aren't a lot of examples for mdio buses at the
moment, but it's straightforward:

1) Call mdio_alloc() to create a new bus object
2) Fill in the name, then read, write, and reset functions, and set
bus->priv to whatever context structure you want
3) Call mdio_register(bus)

For an example, see drivers/net/fsl_mdio.c

A PHY driver is not much more complicated, and there are many examples.

Then, in the ethernet driver, you will need to call:

phy_connect() to declare the connection between your MAC and the PHY
phy_config() to initialize the PHY

When the MAC is ready to deal with traffic, you call phy_startup()

When the MAC is being shut down (the close function), you call phy_shutdown()

Andy


More information about the U-Boot mailing list