Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
16 years ago

OpenCore MAC + ethoc driver + PHY

Hi all.

I noticed some people have troubles with ethoc driver for Opencore MAC getting

errors like "no PHY found" and/or "failed to register MDIO bus".

I had this problem and I have tracked it down.

It happened that our hardware guys wired all the PHY's address lines to ground

so PHY address become 0x0. And this is the root of problem since the ethoc driver

rejects zero addresses.

This file: drivers/net/ethoc.c in the function ethoc_mdio_probe(),

check out this block of original code:

if (phy) {

if (priv->phy_id != -1) {

/* attach to specified phy */

if (priv->phy_id == phy->addr)

break;

} else {

/* autoselect phy if none was specified */

if (phy->addr != 0)

break;

}

}

Note the close `if (phy->addr != 0)' which prevents PHY with zero address to be attached.

I have rearranged this code in the following way:

if( phy ) {

/* autoselect this phy if none was specified */

if( priv->phy_id < 0 )

break;

/* attach to the specified phy if found a matching one */

if( priv->phy_id == phy->addr )

break;

}

Now it works perfectly, either generic or my own PHY driver gets correctly attached.

But I don't think it's a proper solution. The bug is not in the driver itself but rather a

hardware designer's mistake. Rejecting zero addresses is technically correct,

since the 0x0 is reserved for broadcast, i.e. any PHY connected to a given MDIO

should respond regardless of its actual address.

So, IMHO the problem should be fixed at kernel configuration level, just we need to add

a menu option to enter expected PHY address and then propagate the user's choice

to `.phy_id' instead of assigning -1 unconditionally.

In the file arch/nios2/kernel/config.c skip down to the structure:

static struct ethoc_platform_data ethoc_pdata = {

.hwaddr = { 0, },

.phy_id = -1,

};

I guess it should be something like this:

static struct ethoc_platform_data ethoc_pdata = {

.hwaddr = { 0, },

# if defined(CONFIG_ETHOC_PHY_EXPECTED_ID)

.phy_id = (s8)(CONFIG_ETHOC_PHY_EXPECTED_ID),

# else

.phy_id = -1,

# endif

};

Just I don't know how to do it :confused:

Is there someone skillful with all this Kconfig/Makefile stuff? :)
No RepliesBe the first to reply