206-npe_driver_add_update_link_function.patch 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. -static void ixp4xx_adjust_link(struct net_device *dev)
  21. +static void ixp4xx_update_link(struct net_device *dev)
  22. {
  23. struct port *port = netdev_priv(dev);
  24. - struct phy_device *phydev = dev->phydev;
  25. -
  26. - if (!phydev->link) {
  27. - if (port->speed) {
  28. - port->speed = 0;
  29. - printk(KERN_INFO "%s: link down\n", dev->name);
  30. - }
  31. - return;
  32. - }
  33. -
  34. - if (port->speed == phydev->speed && port->duplex == phydev->duplex)
  35. - return;
  36. -
  37. - port->speed = phydev->speed;
  38. - port->duplex = phydev->duplex;
  39. - if (port->duplex)
  40. + if (port->duplex == DUPLEX_FULL)
  41. __raw_writel(DEFAULT_TX_CNTRL0 & ~TX_CNTRL0_HALFDUPLEX,
  42. &port->regs->tx_control[0]);
  43. else
  44. __raw_writel(DEFAULT_TX_CNTRL0 | TX_CNTRL0_HALFDUPLEX,
  45. &port->regs->tx_control[0]);
  46. + netif_carrier_on(dev);
  47. printk(KERN_INFO "%s: link up, speed %u Mb/s, %s duplex\n",
  48. dev->name, port->speed, port->duplex ? "full" : "half");
  49. }
  50. +static void ixp4xx_adjust_link(struct net_device *dev)
  51. +{
  52. + struct port *port = netdev_priv(dev);
  53. + struct phy_device *phydev = port->phydev;
  54. + int status_change = 0;
  55. +
  56. + if (phydev->link) {
  57. + if (port->duplex != phydev->duplex
  58. + || port->speed != phydev->speed) {
  59. + status_change = 1;
  60. + }
  61. + }
  62. +
  63. + if (phydev->link != port->link)
  64. + status_change = 1;
  65. +
  66. + port->link = phydev->link;
  67. + port->speed = phydev->speed;
  68. + port->duplex = phydev->duplex;
  69. +
  70. + if (status_change)
  71. + ixp4xx_update_link(dev);
  72. +}
  73. +
  74. static int ixp4xx_phy_connect(struct net_device *dev)
  75. {
  76. struct port *port = netdev_priv(dev);
  77. @@ -623,7 +634,6 @@ static void ixp4xx_phy_start(struct net_
  78. {
  79. struct port *port = netdev_priv(dev);
  80. - port->speed = 0; /* force "link up" message */
  81. phy_start(port->phydev);
  82. }
  83. @@ -1499,6 +1509,10 @@ static int eth_init_one(struct platform_
  84. if ((err = register_netdev(dev)))
  85. goto err_phy_dis;
  86. + port->link = 0;
  87. + port->speed = 0;
  88. + port->duplex = -1;
  89. +
  90. printk(KERN_INFO "%s: MII PHY %i on %s\n", dev->name, plat->phy,
  91. npe_name(port->npe));