1 From e3eab80fb5d0a7d7fdb0f2f231b27161d5ec3804 Mon Sep 17 00:00:00 2001
2 From: Jonas Gorski <jogo@openwrt.org>
3 Date: Sun, 30 Jun 2013 15:52:53 +0200
4 Subject: [PATCH 23/36] 205-npe_driver_separate_phy_functions.patch
7 drivers/net/ethernet/xscale/ixp4xx_eth.c | 70 ++++++++++++++++++++++--------
8 1 file changed, 51 insertions(+), 19 deletions(-)
10 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
11 +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
12 @@ -588,6 +588,51 @@ static void ixp4xx_adjust_link(struct ne
13 dev->name, port->speed, port->duplex ? "full" : "half");
16 +static int ixp4xx_phy_connect(struct net_device *dev)
18 + struct port *port = netdev_priv(dev);
19 + struct eth_plat_info *plat = port->plat;
20 + char phy_id[MII_BUS_ID_SIZE + 3];
22 + snprintf(phy_id, MII_BUS_ID_SIZE + 3, PHY_ID_FMT,
23 + mdio_bus->id, plat->phy);
24 + port->phydev = phy_connect(dev, phy_id, &ixp4xx_adjust_link,
25 + PHY_INTERFACE_MODE_MII);
26 + if (IS_ERR(port->phydev)) {
27 + printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
28 + return PTR_ERR(port->phydev);
31 + /* mask with MAC supported features */
32 + port->phydev->supported &= PHY_BASIC_FEATURES;
33 + port->phydev->advertising = port->phydev->supported;
35 + port->phydev->irq = PHY_POLL;
40 +static void ixp4xx_phy_disconnect(struct net_device *dev)
42 + struct port *port = netdev_priv(dev);
44 + phy_disconnect(port->phydev);
47 +static void ixp4xx_phy_start(struct net_device *dev)
49 + struct port *port = netdev_priv(dev);
51 + port->speed = 0; /* force "link up" message */
52 + phy_start(port->phydev);
55 +static void ixp4xx_phy_stop(struct net_device *dev)
57 + struct port *port = netdev_priv(dev);
59 + phy_stop(port->phydev);
62 static inline void debug_pkt(struct net_device *dev, const char *func,
64 @@ -1242,8 +1287,7 @@ static int eth_open(struct net_device *d
68 - port->speed = 0; /* force "link up" message */
69 - phy_start(dev->phydev);
70 + ixp4xx_phy_start(dev);
72 for (i = 0; i < ETH_ALEN; i++)
73 __raw_writel(dev->dev_addr[i], &port->regs->hw_addr[i]);
74 @@ -1364,7 +1408,7 @@ static int eth_close(struct net_device *
75 printk(KERN_CRIT "%s: unable to disable loopback\n",
78 - phy_stop(dev->phydev);
79 + ixp4xx_phy_stop(dev);
82 qmgr_disable_irq(TXDONE_QUEUE);
83 @@ -1391,7 +1435,6 @@ static int eth_init_one(struct platform_
84 struct eth_plat_info *plat = dev_get_platdata(&pdev->dev);
85 struct phy_device *phydev = NULL;
87 - char phy_id[MII_BUS_ID_SIZE + 3];
90 if (!(dev = alloc_etherdev(sizeof(struct port))))
91 @@ -1449,16 +1492,9 @@ static int eth_init_one(struct platform_
92 __raw_writel(DEFAULT_CORE_CNTRL, &port->regs->core_control);
95 - snprintf(phy_id, MII_BUS_ID_SIZE + 3, PHY_ID_FMT,
96 - mdio_bus->id, plat->phy);
97 - phydev = phy_connect(dev, phy_id, &ixp4xx_adjust_link,
98 - PHY_INTERFACE_MODE_MII);
99 - if (IS_ERR(phydev)) {
100 - err = PTR_ERR(phydev);
101 + err = ixp4xx_phy_connect(dev);
106 - phydev->irq = PHY_POLL;
108 if ((err = register_netdev(dev)))
110 @@ -1469,7 +1505,7 @@ static int eth_init_one(struct platform_
114 - phy_disconnect(phydev);
115 + ixp4xx_phy_disconnect(phydev);
117 npe_port_tab[NPE_ID(port->id)] = NULL;
118 release_resource(port->mem_res);
119 @@ -1487,7 +1523,7 @@ static int eth_remove_one(struct platfor
120 struct port *port = netdev_priv(dev);
122 unregister_netdev(dev);
123 - phy_disconnect(phydev);
124 + ixp4xx_phy_disconnect(phydev);
125 npe_port_tab[NPE_ID(port->id)] = NULL;
126 npe_release(port->npe);
127 release_resource(port->mem_res);