All of lore.kernel.org
 help / color / mirror / Atom feed
From: Joe Hershberger <joe.hershberger@gmail.com>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V1 1/3] phy: add phy_connect_by_mask
Date: Wed, 22 Aug 2012 15:50:11 -0500	[thread overview]
Message-ID: <CANr=Z=ZZBGpXHDkoZcTw=jR17e1gCX-Zm5SNxvnJd71xDG-NKQ@mail.gmail.com> (raw)
In-Reply-To: <CAKWjMd7T8LL=y8-anXup1Ch8y2d5xH7ivjeihOvaYu7AZ7fFsQ@mail.gmail.com>

Hi Andy,

On Wed, Aug 22, 2012 at 3:40 PM, Andy Fleming <afleming@gmail.com> wrote:
> On Wed, Aug 22, 2012 at 2:59 PM, Troy Kisky
> <troy.kisky@boundarydevices.com> wrote:
>> On 8/20/2012 5:35 PM, Andy Fleming wrote:
>> The same way it works currently. I removed no features.
>
>
> Agreed. But the way it works currently is bad. Many drivers do this:
>
> include/configs/board.h:
> #define MY_PHY_ADDR x
>
> drivers/net/myenet.c:
>
> ...
> phydev = phy_connect(blah, blah, MY_PHY_ADDR);
>
> This is a bad idea, because it encodes the implicit assumptions that:
>
> 1) There's only one PHY in the whole system
> 2) The PHY address can be known at compile time
>
> Later, when someone adds a second ethernet controller, a frequent
> solution is then to make a MY_PHY_ADDR1, MY_PHY_ADDR2, and then add
> some logic to the driver to pick which one to use. In general, this
> makes the driver brittle, as adding and rearranging controllers is
> fairly easy for logic designers, who don't have to care whether their
> new logic will continue to operate the old chip.
>
> Alternatively, when someone causes the PHY address to vary such that
> assumption #2 is violated, it's not uncommon to solve it by searching
> the bus. But this further entrenches assumption #1.
>
>

Just to underscore this, I'm currently working on a product with 2
MACs and 2 PHYs... both PHYs share the MDIO bus of the first MAC.
It's convenient for hardware since they only have to use up pins for
one MDIO bus.  I definitely want to get to a point where supporting
this sort of topology is cleaner and easier.

>> So, should I fix something before this patch?
>
> My thought is that your solution is quite elegant, but further
> entrenches the assumption that there will be only one ethernet
> controller. In my mind, the best way to solve this is:
>
> 1) Modify the driver so that the PHY address is passed in from board
> initialization code programmatically. As a nod to the effort of doing
> so for all boards, you can create a default value (ie - as it was),
> that can be overridden by board code.
> 2) Modify the search function to look for a valid PHY for a given
> mask, and return the address of that PHY
> 3) Add code to the board file which passes in the mask to the search
> function, and then passes the resulting PHY address to the driver.

I think this sounds good.

-Joe

  reply	other threads:[~2012-08-22 20:50 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-08-20 22:48 [U-Boot] [PATCH V1 1/3] phy: add phy_connect_by_mask Troy Kisky
2012-08-20 22:48 ` [U-Boot] [PATCH V1 2/3] fec_mxc: use phy_connect_by_mask Troy Kisky
2012-08-20 22:48 ` [U-Boot] [PATCH V1 3/3] mx6qsabrelite: set CONFIG_FEC_MXC_PHYMASK Troy Kisky
2012-08-20 23:07 ` [U-Boot] [PATCH V1 1/3] phy: add phy_connect_by_mask Troy Kisky
2012-08-21  0:35   ` Andy Fleming
2012-08-22 19:59     ` Troy Kisky
2012-08-22 20:40       ` Andy Fleming
2012-08-22 20:50         ` Joe Hershberger [this message]
2012-08-22 21:21         ` Troy Kisky
2012-09-26 17:26           ` Joe Hershberger
2012-09-26 17:47             ` Troy Kisky
2012-08-22 20:11     ` Eric Nelson
2012-08-22 20:50       ` Andy Fleming
2012-08-22 20:56         ` Eric Nelson
2012-10-23  2:40 ` [U-Boot] [PATCH V3 0/9] separate miiphy from ethernet Troy Kisky
2012-10-23  2:40   ` [U-Boot] [PATCH V3 1/9] doc/README.fec_mxc: add documentation Troy Kisky
2012-10-23  2:40   ` [U-Boot] [PATCH V3 2/9] net: fec_mxc: delete CONFIG_FEC_MXC_MULTI Troy Kisky
2012-10-23  2:40   ` [U-Boot] [PATCH V3 3/9] net: fec_mxc: change fec_mii_setspeed parameter Troy Kisky
2012-10-23  2:40   ` [U-Boot] [PATCH V3 4/9] net: fec_mxc: have fecmxc_initialize call fecmxc_initialize_multi Troy Kisky
2012-10-23  2:40   ` [U-Boot] [PATCH V3 5/9] phy: add phy_find_by_mask/phy_connect_dev Troy Kisky
2012-10-23  2:40   ` [U-Boot] [PATCH V3 6/9] net: fec_mxc: use fec_set_dev_name to set name Troy Kisky
2012-10-23  2:40   ` [U-Boot] [PATCH V3 7/9] net: fec_mxc: only call phy_connect in fec_probe Troy Kisky
2012-10-23  2:40   ` [U-Boot] [PATCH V3 8/9] net: fec_mxc: get phydev before fec_probe Troy Kisky
2012-10-23  2:40   ` [U-Boot] [PATCH V3 9/9] mx6qsabrelite: search mii phy address 4-7 Troy Kisky
2012-11-10  7:28   ` [U-Boot] [PATCH V3 0/9] separate miiphy from ethernet Stefano Babic
2013-01-22 23:48     ` Troy Kisky
2013-01-23  8:48       ` Stefano Babic
2013-01-23 19:06         ` Troy Kisky
2013-01-24  9:09           ` Stefano Babic
2013-01-23 22:35         ` Troy Kisky
2013-01-03 22:00   ` Troy Kisky
2013-01-28  6:00   ` Stefano Babic

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='CANr=Z=ZZBGpXHDkoZcTw=jR17e1gCX-Zm5SNxvnJd71xDG-NKQ@mail.gmail.com' \
    --to=joe.hershberger@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.