uboot-sunxi: disable AXP209 on Olimex A13 Olinuxino
[oweals/openwrt.git] / target / linux / ixp4xx / patches-4.9 / 206-npe_driver_add_update_link_function.patch
1 --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
2 +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
3 @@ -171,12 +171,13 @@ struct port {
4         struct npe *npe;
5         struct net_device *netdev;
6         struct napi_struct napi;
7 +       struct phy_device *phydev;
8         struct eth_plat_info *plat;
9         buffer_t *rx_buff_tab[RX_DESCS], *tx_buff_tab[TX_DESCS];
10         struct desc *desc_tab;  /* coherent */
11         u32 desc_tab_phys;
12         int id;                 /* logical port ID */
13 -       int speed, duplex;
14 +       int link, speed, duplex;
15         u8 firmware[4];
16         int hwts_tx_en;
17         int hwts_rx_en;
18 @@ -558,36 +559,46 @@ static void ixp4xx_mdio_remove(void)
19  }
20  
21  
22 -static void ixp4xx_adjust_link(struct net_device *dev)
23 +static void ixp4xx_update_link(struct net_device *dev)
24  {
25         struct port *port = netdev_priv(dev);
26 -       struct phy_device *phydev = dev->phydev;
27 -
28 -       if (!phydev->link) {
29 -               if (port->speed) {
30 -                       port->speed = 0;
31 -                       printk(KERN_INFO "%s: link down\n", dev->name);
32 -               }
33 -               return;
34 -       }
35 -
36 -       if (port->speed == phydev->speed && port->duplex == phydev->duplex)
37 -               return;
38 -
39 -       port->speed = phydev->speed;
40 -       port->duplex = phydev->duplex;
41  
42 -       if (port->duplex)
43 +       if (port->duplex == DUPLEX_FULL)
44                 __raw_writel(DEFAULT_TX_CNTRL0 & ~TX_CNTRL0_HALFDUPLEX,
45                              &port->regs->tx_control[0]);
46         else
47                 __raw_writel(DEFAULT_TX_CNTRL0 | TX_CNTRL0_HALFDUPLEX,
48                              &port->regs->tx_control[0]);
49  
50 +       netif_carrier_on(dev);
51         printk(KERN_INFO "%s: link up, speed %u Mb/s, %s duplex\n",
52                dev->name, port->speed, port->duplex ? "full" : "half");
53  }
54  
55 +static void ixp4xx_adjust_link(struct net_device *dev)
56 +{
57 +       struct port *port = netdev_priv(dev);
58 +       struct phy_device *phydev = port->phydev;
59 +       int status_change = 0;
60 +
61 +       if (phydev->link) {
62 +               if (port->duplex != phydev->duplex
63 +                   || port->speed != phydev->speed) {
64 +                       status_change = 1;
65 +               }
66 +       }
67 +
68 +       if (phydev->link != port->link)
69 +               status_change = 1;
70 +
71 +       port->link = phydev->link;
72 +       port->speed = phydev->speed;
73 +       port->duplex = phydev->duplex;
74 +
75 +       if (status_change)
76 +               ixp4xx_update_link(dev);
77 +}
78 +
79  static int ixp4xx_phy_connect(struct net_device *dev)
80  {
81         struct port *port = netdev_priv(dev);
82 @@ -623,7 +634,6 @@ static void ixp4xx_phy_start(struct net_
83  {
84         struct port *port = netdev_priv(dev);
85  
86 -       port->speed = 0;        /* force "link up" message */
87         phy_start(port->phydev);
88  }
89  
90 @@ -1499,6 +1509,10 @@ static int eth_init_one(struct platform_
91         if ((err = register_netdev(dev)))
92                 goto err_phy_dis;
93  
94 +       port->link = 0;
95 +       port->speed = 0;
96 +       port->duplex = -1;
97 +
98         printk(KERN_INFO "%s: MII PHY %i on %s\n", dev->name, plat->phy,
99                npe_name(port->npe));
100