Skip to content

Commit

Permalink
ucc_geth: Change uec phy id to the same format as gianfar's
Browse files Browse the repository at this point in the history
The commit b31a1d8 ("gianfar: Convert
gianfar to an of_platform_driver") changes the gianfar's phy id to the
format like "mdio@xxxx:xx", but uec still uses the old format like
"xxxxxxxx:xx".  For the board whose UEC uses gianfar-mdio like
MPC8568MDS, the phy can not be attached because of the incompatible
phy id format. This patch changes uec's phy id to the same format as
gianfar's.

Signed-off-by: Haiying Wang <Haiying.Wang@freescale.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Haiying Wang authored and David S. Miller committed Jan 30, 2009
1 parent 1af7ad5 commit b1c4a9d
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 3 deletions.
20 changes: 18 additions & 2 deletions drivers/net/ucc_geth.c
Original file line number Diff line number Diff line change
Expand Up @@ -1536,15 +1536,30 @@ static void adjust_link(struct net_device *dev)
static int init_phy(struct net_device *dev)
{
struct ucc_geth_private *priv = netdev_priv(dev);
struct device_node *np = priv->node;
struct device_node *phy, *mdio;
const phandle *ph;
char bus_name[MII_BUS_ID_SIZE];
const unsigned int *id;
struct phy_device *phydev;
char phy_id[BUS_ID_SIZE];

priv->oldlink = 0;
priv->oldspeed = 0;
priv->oldduplex = -1;

snprintf(phy_id, sizeof(phy_id), PHY_ID_FMT, priv->ug_info->mdio_bus,
priv->ug_info->phy_address);
ph = of_get_property(np, "phy-handle", NULL);
phy = of_find_node_by_phandle(*ph);
mdio = of_get_parent(phy);

id = of_get_property(phy, "reg", NULL);

of_node_put(phy);
of_node_put(mdio);

uec_mdio_bus_name(bus_name, mdio);
snprintf(phy_id, sizeof(phy_id), "%s:%02x",
bus_name, *id);

phydev = phy_connect(dev, phy_id, &adjust_link, 0, priv->phy_interface);

Expand Down Expand Up @@ -3748,6 +3763,7 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma

ugeth->ug_info = ug_info;
ugeth->dev = dev;
ugeth->node = np;

return 0;
}
Expand Down
2 changes: 2 additions & 0 deletions drivers/net/ucc_geth.h
Original file line number Diff line number Diff line change
Expand Up @@ -1186,6 +1186,8 @@ struct ucc_geth_private {
int oldspeed;
int oldduplex;
int oldlink;

struct device_node *node;
};

void uec_set_ethtool_ops(struct net_device *netdev);
Expand Down
12 changes: 11 additions & 1 deletion drivers/net/ucc_geth_mii.c
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ static int uec_mdio_probe(struct of_device *ofdev, const struct of_device_id *ma
if (err)
goto reg_map_fail;

snprintf(new_bus->id, MII_BUS_ID_SIZE, "%x", res.start);
uec_mdio_bus_name(new_bus->id, np);

new_bus->irq = kmalloc(32 * sizeof(int), GFP_KERNEL);

Expand Down Expand Up @@ -283,3 +283,13 @@ void uec_mdio_exit(void)
{
of_unregister_platform_driver(&uec_mdio_driver);
}

void uec_mdio_bus_name(char *name, struct device_node *np)
{
const u32 *reg;

reg = of_get_property(np, "reg", NULL);

snprintf(name, MII_BUS_ID_SIZE, "%s@%x", np->name, reg ? *reg : 0);
}

1 change: 1 addition & 0 deletions drivers/net/ucc_geth_mii.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,5 @@ int uec_mdio_read(struct mii_bus *bus, int mii_id, int regnum);
int uec_mdio_write(struct mii_bus *bus, int mii_id, int regnum, u16 value);
int __init uec_mdio_init(void);
void uec_mdio_exit(void);
void uec_mdio_bus_name(char *name, struct device_node *np);
#endif /* __UEC_MII_H */

0 comments on commit b1c4a9d

Please sign in to comment.