Commit 0b9da337 authored by Grant Likely's avatar Grant Likely Committed by David S. Miller

net: Rework ucc_geth driver to use of_mdio infrastructure

This patch simplifies the driver by making use of more common code.
Signed-off-by: default avatarGrant Likely <grant.likely@secretlab.ca>
Acked-by: default avatarAndy Fleming <afleming@freescale.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 1dd2d06c
...@@ -27,6 +27,7 @@ ...@@ -27,6 +27,7 @@
#include <linux/mii.h> #include <linux/mii.h>
#include <linux/phy.h> #include <linux/phy.h>
#include <linux/workqueue.h> #include <linux/workqueue.h>
#include <linux/of_mdio.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <asm/uaccess.h> #include <asm/uaccess.h>
...@@ -1543,12 +1544,14 @@ static int init_phy(struct net_device *dev) ...@@ -1543,12 +1544,14 @@ static int init_phy(struct net_device *dev)
priv->oldspeed = 0; priv->oldspeed = 0;
priv->oldduplex = -1; priv->oldduplex = -1;
phydev = phy_connect(dev, ug_info->phy_bus_id, &adjust_link, 0, if (!ug_info->phy_node)
priv->phy_interface); return 0;
if (IS_ERR(phydev)) { phydev = of_phy_connect(dev, ug_info->phy_node, &adjust_link, 0,
priv->phy_interface);
if (!phydev) {
printk("%s: Could not attach to PHY\n", dev->name); printk("%s: Could not attach to PHY\n", dev->name);
return PTR_ERR(phydev); return -ENODEV;
} }
phydev->supported &= (ADVERTISED_10baseT_Half | phydev->supported &= (ADVERTISED_10baseT_Half |
...@@ -3511,14 +3514,12 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma ...@@ -3511,14 +3514,12 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
{ {
struct device *device = &ofdev->dev; struct device *device = &ofdev->dev;
struct device_node *np = ofdev->node; struct device_node *np = ofdev->node;
struct device_node *mdio;
struct net_device *dev = NULL; struct net_device *dev = NULL;
struct ucc_geth_private *ugeth = NULL; struct ucc_geth_private *ugeth = NULL;
struct ucc_geth_info *ug_info; struct ucc_geth_info *ug_info;
struct resource res; struct resource res;
struct device_node *phy; struct device_node *phy;
int err, ucc_num, max_speed = 0; int err, ucc_num, max_speed = 0;
const phandle *ph;
const u32 *fixed_link; const u32 *fixed_link;
const unsigned int *prop; const unsigned int *prop;
const char *sprop; const char *sprop;
...@@ -3618,45 +3619,21 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma ...@@ -3618,45 +3619,21 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma
ug_info->uf_info.irq = irq_of_parse_and_map(np, 0); ug_info->uf_info.irq = irq_of_parse_and_map(np, 0);
fixed_link = of_get_property(np, "fixed-link", NULL); fixed_link = of_get_property(np, "fixed-link", NULL);
if (fixed_link) { if (fixed_link) {
snprintf(ug_info->phy_bus_id, sizeof(ug_info->phy_bus_id),
PHY_ID_FMT, "0", fixed_link[0]);
phy = NULL; phy = NULL;
} else { } else {
char bus_name[MII_BUS_ID_SIZE]; phy = of_parse_phandle(np, "phy-handle", 0);
ph = of_get_property(np, "phy-handle", NULL);
phy = of_find_node_by_phandle(*ph);
if (phy == NULL) if (phy == NULL)
return -ENODEV; return -ENODEV;
/* set the PHY address */
prop = of_get_property(phy, "reg", NULL);
if (prop == NULL)
return -1;
/* Set the bus id */
mdio = of_get_parent(phy);
if (mdio == NULL)
return -ENODEV;
err = of_address_to_resource(mdio, 0, &res);
if (err) {
of_node_put(mdio);
return err;
}
fsl_pq_mdio_bus_name(bus_name, mdio);
of_node_put(mdio);
snprintf(ug_info->phy_bus_id, sizeof(ug_info->phy_bus_id),
"%s:%02x", bus_name, *prop);
} }
ug_info->phy_node = phy;
/* get the phy interface type, or default to MII */ /* get the phy interface type, or default to MII */
prop = of_get_property(np, "phy-connection-type", NULL); prop = of_get_property(np, "phy-connection-type", NULL);
if (!prop) { if (!prop) {
/* handle interface property present in old trees */ /* handle interface property present in old trees */
if (!phy)
return -ENODEV;
prop = of_get_property(phy, "interface", NULL); prop = of_get_property(phy, "interface", NULL);
if (prop != NULL) { if (prop != NULL) {
phy_interface = enet_to_phy_interface[*prop]; phy_interface = enet_to_phy_interface[*prop];
......
...@@ -1099,7 +1099,7 @@ struct ucc_geth_info { ...@@ -1099,7 +1099,7 @@ struct ucc_geth_info {
u32 eventRegMask; u32 eventRegMask;
u16 pausePeriod; u16 pausePeriod;
u16 extensionField; u16 extensionField;
char phy_bus_id[BUS_ID_SIZE]; struct device_node *phy_node;
u8 weightfactor[NUM_TX_QUEUES]; u8 weightfactor[NUM_TX_QUEUES];
u8 interruptcoalescingmaxvalue[NUM_RX_QUEUES]; u8 interruptcoalescingmaxvalue[NUM_RX_QUEUES];
u8 l2qt[UCC_GETH_VLAN_PRIORITY_MAX]; u8 l2qt[UCC_GETH_VLAN_PRIORITY_MAX];
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment