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 @@ -589,6 +589,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 @@ -1259,8 +1304,7 @@ static int eth_open(struct net_device *d
68 - port->speed = 0; /* force "link up" message */
69 - phy_start(port->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 @@ -1381,7 +1425,7 @@ static int eth_close(struct net_device *
75 printk(KERN_CRIT "%s: unable to disable loopback\n",
78 - phy_stop(port->phydev);
79 + ixp4xx_phy_stop(dev);
82 qmgr_disable_irq(TXDONE_QUEUE);
83 @@ -1407,7 +1451,6 @@ static int eth_init_one(struct platform_
84 struct net_device *dev;
85 struct eth_plat_info *plat = dev_get_platdata(&pdev->dev);
87 - char phy_id[MII_BUS_ID_SIZE + 3];
90 if (!(dev = alloc_etherdev(sizeof(struct port))))
91 @@ -1465,20 +1508,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 - port->phydev = phy_connect(dev, phy_id, &ixp4xx_adjust_link,
98 - PHY_INTERFACE_MODE_MII);
99 - if (IS_ERR(port->phydev)) {
100 - err = PTR_ERR(port->phydev);
101 + err = ixp4xx_phy_connect(dev);
106 - /* mask with MAC supported features */
107 - port->phydev->supported &= PHY_BASIC_FEATURES;
108 - port->phydev->advertising = port->phydev->supported;
110 - port->phydev->irq = PHY_POLL;
112 if ((err = register_netdev(dev)))
114 @@ -1489,7 +1521,7 @@ static int eth_init_one(struct platform_
118 - phy_disconnect(port->phydev);
119 + ixp4xx_phy_disconnect(dev);
121 npe_port_tab[NPE_ID(port->id)] = NULL;
122 release_resource(port->mem_res);
123 @@ -1506,7 +1538,7 @@ static int eth_remove_one(struct platfor
124 struct port *port = netdev_priv(dev);
126 unregister_netdev(dev);
127 - phy_disconnect(port->phydev);
128 + ixp4xx_phy_disconnect(dev);
129 npe_port_tab[NPE_ID(port->id)] = NULL;
130 npe_release(port->npe);
131 release_resource(port->mem_res);