2.6.30: add lzma support to squashfs through pcomp
[openwrt/openwrt.git] / target / linux / ixp4xx / patches-2.6.30 / 205-npe_driver_separate_phy_functions.patch
1 --- a/drivers/net/arm/ixp4xx_eth.c
2 +++ b/drivers/net/arm/ixp4xx_eth.c
3 @@ -396,6 +396,53 @@ 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[BUS_ID_SIZE];
12 +
13 + snprintf(phy_id, BUS_ID_SIZE, PHY_ID_FMT, "0", plat->phy);
14 + port->phydev = phy_connect(dev, phy_id, &ixp4xx_adjust_link, 0,
15 + PHY_INTERFACE_MODE_MII);
16 + if (IS_ERR(port->phydev)) {
17 + printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
18 + return PTR_ERR(port->phydev);
19 + }
20 +
21 + /* mask with MAC supported features */
22 + port->phydev->supported &= PHY_BASIC_FEATURES;
23 + port->phydev->advertising = port->phydev->supported;
24 +
25 + port->phydev->irq = PHY_POLL;
26 +
27 + printk(KERN_INFO "%s: MII PHY %i on %s\n", dev->name, plat->phy,
28 + npe_name(port->npe));
29 +
30 + return 0;
31 +}
32 +
33 +static void ixp4xx_phy_disconnect(struct net_device *dev)
34 +{
35 + struct port *port = netdev_priv(dev);
36 +
37 + phy_disconnect(port->phydev);
38 +}
39 +
40 +static void ixp4xx_phy_start(struct net_device *dev)
41 +{
42 + struct port *port = netdev_priv(dev);
43 +
44 + port->speed = 0; /* force "link up" message */
45 + phy_start(port->phydev);
46 +}
47 +
48 +static void ixp4xx_phy_stop(struct net_device *dev)
49 +{
50 + struct port *port = netdev_priv(dev);
51 +
52 + phy_stop(port->phydev);
53 +}
54
55 static inline void debug_pkt(struct net_device *dev, const char *func,
56 u8 *data, int len)
57 @@ -1003,8 +1050,7 @@ static int eth_open(struct net_device *d
58 return err;
59 }
60
61 - port->speed = 0; /* force "link up" message */
62 - phy_start(port->phydev);
63 + ixp4xx_phy_start(dev);
64
65 for (i = 0; i < ETH_ALEN; i++)
66 __raw_writel(dev->dev_addr[i], &port->regs->hw_addr[i]);
67 @@ -1125,7 +1171,7 @@ static int eth_close(struct net_device *
68 printk(KERN_CRIT "%s: unable to disable loopback\n",
69 dev->name);
70
71 - phy_stop(port->phydev);
72 + ixp4xx_phy_stop(dev);
73
74 if (!ports_open)
75 qmgr_disable_irq(TXDONE_QUEUE);
76 @@ -1149,7 +1195,6 @@ static int __devinit eth_init_one(struct
77 struct net_device *dev;
78 struct eth_plat_info *plat = pdev->dev.platform_data;
79 u32 regs_phys;
80 - char phy_id[BUS_ID_SIZE];
81 int err;
82
83 if (!(dev = alloc_etherdev(sizeof(struct port))))
84 @@ -1207,18 +1252,10 @@ static int __devinit eth_init_one(struct
85 __raw_writel(DEFAULT_CORE_CNTRL, &port->regs->core_control);
86 udelay(50);
87
88 - snprintf(phy_id, BUS_ID_SIZE, PHY_ID_FMT, "0", plat->phy);
89 - port->phydev = phy_connect(dev, phy_id, &ixp4xx_adjust_link, 0,
90 - PHY_INTERFACE_MODE_MII);
91 - if ((err = IS_ERR(port->phydev)))
92 + err = ixp4xx_phy_connect(dev);
93 + if (err)
94 goto err_free_mem;
95
96 - /* mask with MAC supported features */
97 - port->phydev->supported &= PHY_BASIC_FEATURES;
98 - port->phydev->advertising = port->phydev->supported;
99 -
100 - port->phydev->irq = PHY_POLL;
101 -
102 if ((err = register_netdev(dev)))
103 goto err_phy_dis;
104
105 @@ -1245,7 +1282,7 @@ static int __devexit eth_remove_one(stru
106 struct net_device *dev = platform_get_drvdata(pdev);
107 struct port *port = netdev_priv(dev);
108
109 - phy_disconnect(port->phydev);
110 + ixp4xx_phy_disconnect(dev);
111 unregister_netdev(dev);
112 phy_disconnect(port->phydev);
113 npe_port_tab[NPE_ID(port->id)] = NULL;