206-npe_driver_add_update_link_function.patch 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
  2. +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
  3. @@ -177,7 +177,7 @@ struct port {
  4. struct desc *desc_tab; /* coherent */
  5. u32 desc_tab_phys;
  6. int id; /* logical port ID */
  7. - int speed, duplex;
  8. + int link, speed, duplex;
  9. u8 firmware[4];
  10. int hwts_tx_en;
  11. int hwts_rx_en;
  12. @@ -558,37 +558,52 @@ static void ixp4xx_mdio_remove(void)
  13. mdiobus_free(mdio_bus);
  14. }
  15. -
  16. -static void ixp4xx_adjust_link(struct net_device *dev)
  17. +static void ixp4xx_update_link(struct net_device *dev)
  18. {
  19. struct port *port = netdev_priv(dev);
  20. - struct phy_device *phydev = port->phydev;
  21. - if (!phydev->link) {
  22. - if (port->speed) {
  23. - port->speed = 0;
  24. - printk(KERN_INFO "%s: link down\n", dev->name);
  25. - }
  26. + if (!port->link) {
  27. + netif_carrier_off(dev);
  28. + printk(KERN_INFO "%s: link down\n", dev->name);
  29. return;
  30. }
  31. - if (port->speed == phydev->speed && port->duplex == phydev->duplex)
  32. - return;
  33. -
  34. - port->speed = phydev->speed;
  35. - port->duplex = phydev->duplex;
  36. -
  37. - if (port->duplex)
  38. + if (port->duplex == DUPLEX_FULL)
  39. __raw_writel(DEFAULT_TX_CNTRL0 & ~TX_CNTRL0_HALFDUPLEX,
  40. &port->regs->tx_control[0]);
  41. else
  42. __raw_writel(DEFAULT_TX_CNTRL0 | TX_CNTRL0_HALFDUPLEX,
  43. &port->regs->tx_control[0]);
  44. + netif_carrier_on(dev);
  45. printk(KERN_INFO "%s: link up, speed %u Mb/s, %s duplex\n",
  46. dev->name, port->speed, port->duplex ? "full" : "half");
  47. }
  48. +static void ixp4xx_adjust_link(struct net_device *dev)
  49. +{
  50. + struct port *port = netdev_priv(dev);
  51. + struct phy_device *phydev = port->phydev;
  52. + int status_change = 0;
  53. +
  54. + if (phydev->link) {
  55. + if (port->duplex != phydev->duplex
  56. + || port->speed != phydev->speed) {
  57. + status_change = 1;
  58. + }
  59. + }
  60. +
  61. + if (phydev->link != port->link)
  62. + status_change = 1;
  63. +
  64. + port->link = phydev->link;
  65. + port->speed = phydev->speed;
  66. + port->duplex = phydev->duplex;
  67. +
  68. + if (status_change)
  69. + ixp4xx_update_link(dev);
  70. +}
  71. +
  72. static int ixp4xx_phy_connect(struct net_device *dev)
  73. {
  74. struct port *port = netdev_priv(dev);
  75. @@ -624,7 +639,6 @@ static void ixp4xx_phy_start(struct net_
  76. {
  77. struct port *port = netdev_priv(dev);
  78. - port->speed = 0; /* force "link up" message */
  79. phy_start(port->phydev);
  80. }
  81. @@ -1515,6 +1529,10 @@ static int eth_init_one(struct platform_
  82. if ((err = register_netdev(dev)))
  83. goto err_phy_dis;
  84. + port->link = 0;
  85. + port->speed = 0;
  86. + port->duplex = -1;
  87. +
  88. printk(KERN_INFO "%s: MII PHY %i on %s\n", dev->name, plat->phy,
  89. npe_name(port->npe));