Root/target/linux/ixp4xx/patches-3.3/205-npe_driver_separate_phy_functions.patch

1--- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
2+++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
3@@ -573,6 +573,51 @@ static void ixp4xx_adjust_link(struct ne
4            dev->name, port->speed, port->duplex ? "full" : "half");
5 }
6 
7+static int ixp4xx_phy_connect(struct net_device *dev)
8+{
9+ struct port *port = netdev_priv(dev);
10+ struct eth_plat_info *plat = port->plat;
11+ char phy_id[MII_BUS_ID_SIZE + 3];
12+
13+ snprintf(phy_id, MII_BUS_ID_SIZE + 3, PHY_ID_FMT,
14+ mdio_bus->id, plat->phy);
15+ port->phydev = phy_connect(dev, phy_id, &ixp4xx_adjust_link, 0,
16+ PHY_INTERFACE_MODE_MII);
17+ if (IS_ERR(port->phydev)) {
18+ printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
19+ return PTR_ERR(port->phydev);
20+ }
21+
22+ /* mask with MAC supported features */
23+ port->phydev->supported &= PHY_BASIC_FEATURES;
24+ port->phydev->advertising = port->phydev->supported;
25+
26+ port->phydev->irq = PHY_POLL;
27+
28+ return 0;
29+}
30+
31+static void ixp4xx_phy_disconnect(struct net_device *dev)
32+{
33+ struct port *port = netdev_priv(dev);
34+
35+ phy_disconnect(port->phydev);
36+}
37+
38+static void ixp4xx_phy_start(struct net_device *dev)
39+{
40+ struct port *port = netdev_priv(dev);
41+
42+ port->speed = 0; /* force "link up" message */
43+ phy_start(port->phydev);
44+}
45+
46+static void ixp4xx_phy_stop(struct net_device *dev)
47+{
48+ struct port *port = netdev_priv(dev);
49+
50+ phy_stop(port->phydev);
51+}
52 
53 static inline void debug_pkt(struct net_device *dev, const char *func,
54                  u8 *data, int len)
55@@ -1205,8 +1250,7 @@ static int eth_open(struct net_device *d
56         return err;
57     }
58 
59- port->speed = 0; /* force "link up" message */
60- phy_start(port->phydev);
61+ ixp4xx_phy_start(dev);
62 
63     for (i = 0; i < ETH_ALEN; i++)
64         __raw_writel(dev->dev_addr[i], &port->regs->hw_addr[i]);
65@@ -1327,7 +1371,7 @@ static int eth_close(struct net_device *
66         printk(KERN_CRIT "%s: unable to disable loopback\n",
67                dev->name);
68 
69- phy_stop(port->phydev);
70+ ixp4xx_phy_stop(dev);
71 
72     if (!ports_open)
73         qmgr_disable_irq(TXDONE_QUEUE);
74@@ -1353,7 +1397,6 @@ static int __devinit eth_init_one(struct
75     struct net_device *dev;
76     struct eth_plat_info *plat = pdev->dev.platform_data;
77     u32 regs_phys;
78- char phy_id[MII_BUS_ID_SIZE + 3];
79     int err;
80 
81     if (ptp_filter_init(ptp_filter, ARRAY_SIZE(ptp_filter))) {
82@@ -1416,20 +1459,9 @@ static int __devinit eth_init_one(struct
83     __raw_writel(DEFAULT_CORE_CNTRL, &port->regs->core_control);
84     udelay(50);
85 
86- snprintf(phy_id, MII_BUS_ID_SIZE + 3, PHY_ID_FMT,
87- mdio_bus->id, plat->phy);
88- port->phydev = phy_connect(dev, phy_id, &ixp4xx_adjust_link, 0,
89- PHY_INTERFACE_MODE_MII);
90- if (IS_ERR(port->phydev)) {
91- err = PTR_ERR(port->phydev);
92+ err = ixp4xx_phy_connect(dev);
93+ if (err)
94         goto err_free_mem;
95- }
96-
97- /* mask with MAC supported features */
98- port->phydev->supported &= PHY_BASIC_FEATURES;
99- port->phydev->advertising = port->phydev->supported;
100-
101- port->phydev->irq = PHY_POLL;
102 
103     if ((err = register_netdev(dev)))
104         goto err_phy_dis;
105@@ -1440,7 +1472,7 @@ static int __devinit eth_init_one(struct
106     return 0;
107 
108 err_phy_dis:
109- phy_disconnect(port->phydev);
110+ ixp4xx_phy_disconnect(dev);
111 err_free_mem:
112     npe_port_tab[NPE_ID(port->id)] = NULL;
113     platform_set_drvdata(pdev, NULL);
114@@ -1458,7 +1490,7 @@ static int __devexit eth_remove_one(stru
115     struct port *port = netdev_priv(dev);
116 
117     unregister_netdev(dev);
118- phy_disconnect(port->phydev);
119+ ixp4xx_phy_disconnect(dev);
120     npe_port_tab[NPE_ID(port->id)] = NULL;
121     platform_set_drvdata(pdev, NULL);
122     npe_release(port->npe);
123

Archive Download this file



interactive