OpenWrt – Blame information for rev 4
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
4 | office | 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 |
||
5 | |||
6 | --- |
||
7 | drivers/net/ethernet/xscale/ixp4xx_eth.c | 70 ++++++++++++++++++++++-------- |
||
8 | 1 file changed, 51 insertions(+), 19 deletions(-) |
||
9 | |||
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"); |
||
14 | } |
||
15 | |||
16 | +static int ixp4xx_phy_connect(struct net_device *dev) |
||
17 | +{ |
||
18 | + struct port *port = netdev_priv(dev); |
||
19 | + struct eth_plat_info *plat = port->plat; |
||
20 | + char phy_id[MII_BUS_ID_SIZE + 3]; |
||
21 | + |
||
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); |
||
29 | + } |
||
30 | + |
||
31 | + /* mask with MAC supported features */ |
||
32 | + port->phydev->supported &= PHY_BASIC_FEATURES; |
||
33 | + port->phydev->advertising = port->phydev->supported; |
||
34 | + |
||
35 | + port->phydev->irq = PHY_POLL; |
||
36 | + |
||
37 | + return 0; |
||
38 | +} |
||
39 | + |
||
40 | +static void ixp4xx_phy_disconnect(struct net_device *dev) |
||
41 | +{ |
||
42 | + struct port *port = netdev_priv(dev); |
||
43 | + |
||
44 | + phy_disconnect(port->phydev); |
||
45 | +} |
||
46 | + |
||
47 | +static void ixp4xx_phy_start(struct net_device *dev) |
||
48 | +{ |
||
49 | + struct port *port = netdev_priv(dev); |
||
50 | + |
||
51 | + port->speed = 0; /* force "link up" message */ |
||
52 | + phy_start(port->phydev); |
||
53 | +} |
||
54 | + |
||
55 | +static void ixp4xx_phy_stop(struct net_device *dev) |
||
56 | +{ |
||
57 | + struct port *port = netdev_priv(dev); |
||
58 | + |
||
59 | + phy_stop(port->phydev); |
||
60 | +} |
||
61 | |||
62 | static inline void debug_pkt(struct net_device *dev, const char *func, |
||
63 | u8 *data, int len) |
||
64 | @@ -1242,8 +1287,7 @@ static int eth_open(struct net_device *d |
||
65 | return err; |
||
66 | } |
||
67 | |||
68 | - port->speed = 0; /* force "link up" message */ |
||
69 | - phy_start(dev->phydev); |
||
70 | + ixp4xx_phy_start(dev); |
||
71 | |||
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", |
||
76 | dev->name); |
||
77 | |||
78 | - phy_stop(dev->phydev); |
||
79 | + ixp4xx_phy_stop(dev); |
||
80 | |||
81 | if (!ports_open) |
||
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; |
||
86 | u32 regs_phys; |
||
87 | - char phy_id[MII_BUS_ID_SIZE + 3]; |
||
88 | int err; |
||
89 | |||
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); |
||
93 | udelay(50); |
||
94 | |||
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); |
||
102 | + if (err) |
||
103 | goto err_free_mem; |
||
104 | - } |
||
105 | - |
||
106 | - phydev->irq = PHY_POLL; |
||
107 | |||
108 | if ((err = register_netdev(dev))) |
||
109 | goto err_phy_dis; |
||
110 | @@ -1469,7 +1505,7 @@ static int eth_init_one(struct platform_ |
||
111 | return 0; |
||
112 | |||
113 | err_phy_dis: |
||
114 | - phy_disconnect(phydev); |
||
115 | + ixp4xx_phy_disconnect(phydev); |
||
116 | err_free_mem: |
||
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); |
||
121 | |||
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); |