diff options
author | Grant Likely <grant.likely@secretlab.ca> | 2009-04-25 08:53:23 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2009-04-27 05:53:50 -0400 |
commit | 0b9da337dca972e7a4144e298ec3adb8f244d4a4 (patch) | |
tree | 0f200964ef90587ee21df0acfa4aae43449b52ac /drivers | |
parent | 1dd2d06c0459a2f1bffc56765e3cc57427818867 (diff) |
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: Grant Likely <grant.likely@secretlab.ca>
Acked-by: Andy Fleming <afleming@freescale.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/net/ucc_geth.c | 47 | ||||
-rw-r--r-- | drivers/net/ucc_geth.h | 2 |
2 files changed, 13 insertions, 36 deletions
diff --git a/drivers/net/ucc_geth.c b/drivers/net/ucc_geth.c index 811f97cb0a29..a53628466637 100644 --- a/drivers/net/ucc_geth.c +++ b/drivers/net/ucc_geth.c | |||
@@ -27,6 +27,7 @@ | |||
27 | #include <linux/mii.h> | 27 | #include <linux/mii.h> |
28 | #include <linux/phy.h> | 28 | #include <linux/phy.h> |
29 | #include <linux/workqueue.h> | 29 | #include <linux/workqueue.h> |
30 | #include <linux/of_mdio.h> | ||
30 | #include <linux/of_platform.h> | 31 | #include <linux/of_platform.h> |
31 | 32 | ||
32 | #include <asm/uaccess.h> | 33 | #include <asm/uaccess.h> |
@@ -1543,12 +1544,14 @@ static int init_phy(struct net_device *dev) | |||
1543 | priv->oldspeed = 0; | 1544 | priv->oldspeed = 0; |
1544 | priv->oldduplex = -1; | 1545 | priv->oldduplex = -1; |
1545 | 1546 | ||
1546 | phydev = phy_connect(dev, ug_info->phy_bus_id, &adjust_link, 0, | 1547 | if (!ug_info->phy_node) |
1547 | priv->phy_interface); | 1548 | return 0; |
1548 | 1549 | ||
1549 | if (IS_ERR(phydev)) { | 1550 | phydev = of_phy_connect(dev, ug_info->phy_node, &adjust_link, 0, |
1551 | priv->phy_interface); | ||
1552 | if (!phydev) { | ||
1550 | printk("%s: Could not attach to PHY\n", dev->name); | 1553 | printk("%s: Could not attach to PHY\n", dev->name); |
1551 | return PTR_ERR(phydev); | 1554 | return -ENODEV; |
1552 | } | 1555 | } |
1553 | 1556 | ||
1554 | phydev->supported &= (ADVERTISED_10baseT_Half | | 1557 | 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 | { | 3514 | { |
3512 | struct device *device = &ofdev->dev; | 3515 | struct device *device = &ofdev->dev; |
3513 | struct device_node *np = ofdev->node; | 3516 | struct device_node *np = ofdev->node; |
3514 | struct device_node *mdio; | ||
3515 | struct net_device *dev = NULL; | 3517 | struct net_device *dev = NULL; |
3516 | struct ucc_geth_private *ugeth = NULL; | 3518 | struct ucc_geth_private *ugeth = NULL; |
3517 | struct ucc_geth_info *ug_info; | 3519 | struct ucc_geth_info *ug_info; |
3518 | struct resource res; | 3520 | struct resource res; |
3519 | struct device_node *phy; | 3521 | struct device_node *phy; |
3520 | int err, ucc_num, max_speed = 0; | 3522 | int err, ucc_num, max_speed = 0; |
3521 | const phandle *ph; | ||
3522 | const u32 *fixed_link; | 3523 | const u32 *fixed_link; |
3523 | const unsigned int *prop; | 3524 | const unsigned int *prop; |
3524 | const char *sprop; | 3525 | const char *sprop; |
@@ -3618,45 +3619,21 @@ static int ucc_geth_probe(struct of_device* ofdev, const struct of_device_id *ma | |||
3618 | ug_info->uf_info.irq = irq_of_parse_and_map(np, 0); | 3619 | ug_info->uf_info.irq = irq_of_parse_and_map(np, 0); |
3619 | fixed_link = of_get_property(np, "fixed-link", NULL); | 3620 | fixed_link = of_get_property(np, "fixed-link", NULL); |
3620 | if (fixed_link) { | 3621 | if (fixed_link) { |
3621 | snprintf(ug_info->phy_bus_id, sizeof(ug_info->phy_bus_id), | ||
3622 | PHY_ID_FMT, "0", fixed_link[0]); | ||
3623 | phy = NULL; | 3622 | phy = NULL; |
3624 | } else { | 3623 | } else { |
3625 | char bus_name[MII_BUS_ID_SIZE]; | 3624 | phy = of_parse_phandle(np, "phy-handle", 0); |
3626 | |||
3627 | ph = of_get_property(np, "phy-handle", NULL); | ||
3628 | phy = of_find_node_by_phandle(*ph); | ||
3629 | |||
3630 | if (phy == NULL) | 3625 | if (phy == NULL) |
3631 | return -ENODEV; | 3626 | return -ENODEV; |
3632 | |||
3633 | /* set the PHY address */ | ||
3634 | prop = of_get_property(phy, "reg", NULL); | ||
3635 | if (prop == NULL) | ||
3636 | return -1; | ||
3637 | |||
3638 | /* Set the bus id */ | ||
3639 | mdio = of_get_parent(phy); | ||
3640 | |||
3641 | if (mdio == NULL) | ||
3642 | return -ENODEV; | ||
3643 | |||
3644 | err = of_address_to_resource(mdio, 0, &res); | ||
3645 | |||
3646 | if (err) { | ||
3647 | of_node_put(mdio); | ||
3648 | return err; | ||
3649 | } | ||
3650 | fsl_pq_mdio_bus_name(bus_name, mdio); | ||
3651 | of_node_put(mdio); | ||
3652 | snprintf(ug_info->phy_bus_id, sizeof(ug_info->phy_bus_id), | ||
3653 | "%s:%02x", bus_name, *prop); | ||
3654 | } | 3627 | } |
3628 | ug_info->phy_node = phy; | ||
3655 | 3629 | ||
3656 | /* get the phy interface type, or default to MII */ | 3630 | /* get the phy interface type, or default to MII */ |
3657 | prop = of_get_property(np, "phy-connection-type", NULL); | 3631 | prop = of_get_property(np, "phy-connection-type", NULL); |
3658 | if (!prop) { | 3632 | if (!prop) { |
3659 | /* handle interface property present in old trees */ | 3633 | /* handle interface property present in old trees */ |
3634 | if (!phy) | ||
3635 | return -ENODEV; | ||
3636 | |||
3660 | prop = of_get_property(phy, "interface", NULL); | 3637 | prop = of_get_property(phy, "interface", NULL); |
3661 | if (prop != NULL) { | 3638 | if (prop != NULL) { |
3662 | phy_interface = enet_to_phy_interface[*prop]; | 3639 | phy_interface = enet_to_phy_interface[*prop]; |
diff --git a/drivers/net/ucc_geth.h b/drivers/net/ucc_geth.h index 602764799df0..dca628a922ba 100644 --- a/drivers/net/ucc_geth.h +++ b/drivers/net/ucc_geth.h | |||
@@ -1099,7 +1099,7 @@ struct ucc_geth_info { | |||
1099 | u32 eventRegMask; | 1099 | u32 eventRegMask; |
1100 | u16 pausePeriod; | 1100 | u16 pausePeriod; |
1101 | u16 extensionField; | 1101 | u16 extensionField; |
1102 | char phy_bus_id[BUS_ID_SIZE]; | 1102 | struct device_node *phy_node; |
1103 | u8 weightfactor[NUM_TX_QUEUES]; | 1103 | u8 weightfactor[NUM_TX_QUEUES]; |
1104 | u8 interruptcoalescingmaxvalue[NUM_RX_QUEUES]; | 1104 | u8 interruptcoalescingmaxvalue[NUM_RX_QUEUES]; |
1105 | u8 l2qt[UCC_GETH_VLAN_PRIORITY_MAX]; | 1105 | u8 l2qt[UCC_GETH_VLAN_PRIORITY_MAX]; |