All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Fleming <afleming@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] Question: Information regarding MII and PHY
Date: Tue, 27 Sep 2011 11:32:35 -0500	[thread overview]
Message-ID: <CAKWjMd52P2HA=kp+_+9DPMCMGC2nPG6+oQFAbm2rZ_L5SZkXiQ@mail.gmail.com> (raw)
In-Reply-To: <CALButC+UtA6MDh8fEED-iPab=Avh_RK1RxDyBn9bMek94cLHVw@mail.gmail.com>

On Thu, Sep 22, 2011 at 7:17 PM, Graeme Russ <graeme.russ@gmail.com> wrote:
> Hi Andy
>
> On Fri, Sep 23, 2011 at 9:36 AM, Andy Fleming <afleming@gmail.com> wrote:
>> On Thu, Sep 22, 2011 at 6:27 PM, Graeme Russ <graeme.russ@gmail.com> wrote:
>
> [snip]
>
>>> 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()
>
> Thanks for the explanation - I'll have a look tonight
>
> A couple of quick questions regarding network drivers...
>
> 1) Was it the case that the Linux phylib was 'tight' enough to bring
> ? straight into U-Boot, or was a new phylib written for U-Boot?


Much of the code was copied straight over. But the interface is
*slightly* different to account for the non-persistence of network
connections in u-boot. Basically, I merged "config_aneg" and
"config_init", and made "read_status" into "startup", and left out the
power saving and interrupt stuff. This was done for simplicity, but it
may make sense at this early stage to get closer to the Linux
interface.


> 2) The Linux network driver framework (at least now) is so
> ? massive that porting a network driver over is practically impossible.
> ? Is the U-Boot network driver framework similar in any way to the Linux
> ? framework such that I can take relevant portions of code straight from
> ? a Linux driver, or is it a case of carefully picking out the relevant
> ? bits and stitching together a entirely new beast?

It's very different. And most Linux ethernet drivers are going to be
filled with Linux-specific things (like sk_buffs). The U-Boot API is
very simple (open, close, tx, rx, no interrupts). Any driver can serve
as a simple example. As Mike said, just use the Linux driver to get a
sense of what registers to write, and how to set up your rings.

Andy

  parent reply	other threads:[~2011-09-27 16:32 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-09-22  1:20 [U-Boot] Question: Information regarding MII and PHY Graeme Russ
2011-09-22  3:12 ` Graeme Russ
2011-09-22 22:21   ` Mike Frysinger
2011-09-22 23:06     ` Graeme Russ
2011-09-22 23:27     ` Graeme Russ
2011-09-22 23:36       ` Andy Fleming
2011-09-23  0:17         ` Graeme Russ
2011-09-23  1:23           ` Mike Frysinger
2011-09-27 16:32           ` Andy Fleming [this message]
2011-09-22 23:30 ` Andy Fleming

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAKWjMd52P2HA=kp+_+9DPMCMGC2nPG6+oQFAbm2rZ_L5SZkXiQ@mail.gmail.com' \
    --to=afleming@gmail.com \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.