205-npe_driver_separate_phy_functions.patch 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  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. drivers/net/ethernet/xscale/ixp4xx_eth.c | 70 ++++++++++++++++++++++--------
  7. 1 file changed, 51 insertions(+), 19 deletions(-)
  8. --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
  9. +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
  10. @@ -589,6 +589,51 @@ static void ixp4xx_adjust_link(struct ne
  11. dev->name, port->speed, port->duplex ? "full" : "half");
  12. }
  13. +static int ixp4xx_phy_connect(struct net_device *dev)
  14. +{
  15. + struct port *port = netdev_priv(dev);
  16. + struct eth_plat_info *plat = port->plat;
  17. + char phy_id[MII_BUS_ID_SIZE + 3];
  18. +
  19. + snprintf(phy_id, MII_BUS_ID_SIZE + 3, PHY_ID_FMT,
  20. + mdio_bus->id, plat->phy);
  21. + port->phydev = phy_connect(dev, phy_id, &ixp4xx_adjust_link,
  22. + PHY_INTERFACE_MODE_MII);
  23. + if (IS_ERR(port->phydev)) {
  24. + printk(KERN_ERR "%s: Could not attach to PHY\n", dev->name);
  25. + return PTR_ERR(port->phydev);
  26. + }
  27. +
  28. + /* mask with MAC supported features */
  29. + port->phydev->supported &= PHY_BASIC_FEATURES;
  30. + port->phydev->advertising = port->phydev->supported;
  31. +
  32. + port->phydev->irq = PHY_POLL;
  33. +
  34. + return 0;
  35. +}
  36. +
  37. +static void ixp4xx_phy_disconnect(struct net_device *dev)
  38. +{
  39. + struct port *port = netdev_priv(dev);
  40. +
  41. + phy_disconnect(port->phydev);
  42. +}
  43. +
  44. +static void ixp4xx_phy_start(struct net_device *dev)
  45. +{
  46. + struct port *port = netdev_priv(dev);
  47. +
  48. + port->speed = 0; /* force "link up" message */
  49. + phy_start(port->phydev);
  50. +}
  51. +
  52. +static void ixp4xx_phy_stop(struct net_device *dev)
  53. +{
  54. + struct port *port = netdev_priv(dev);
  55. +
  56. + phy_stop(port->phydev);
  57. +}
  58. static inline void debug_pkt(struct net_device *dev, const char *func,
  59. u8 *data, int len)
  60. @@ -1259,8 +1304,7 @@ static int eth_open(struct net_device *d
  61. return err;
  62. }
  63. - port->speed = 0; /* force "link up" message */
  64. - phy_start(port->phydev);
  65. + ixp4xx_phy_start(dev);
  66. for (i = 0; i < ETH_ALEN; i++)
  67. __raw_writel(dev->dev_addr[i], &port->regs->hw_addr[i]);
  68. @@ -1381,7 +1425,7 @@ static int eth_close(struct net_device *
  69. printk(KERN_CRIT "%s: unable to disable loopback\n",
  70. dev->name);
  71. - phy_stop(port->phydev);
  72. + ixp4xx_phy_stop(dev);
  73. if (!ports_open)
  74. qmgr_disable_irq(TXDONE_QUEUE);
  75. @@ -1407,7 +1451,6 @@ static int eth_init_one(struct platform_
  76. struct net_device *dev;
  77. struct eth_plat_info *plat = dev_get_platdata(&pdev->dev);
  78. u32 regs_phys;
  79. - char phy_id[MII_BUS_ID_SIZE + 3];
  80. int err;
  81. if (!(dev = alloc_etherdev(sizeof(struct port))))
  82. @@ -1465,20 +1508,9 @@ static int eth_init_one(struct platform_
  83. __raw_writel(DEFAULT_CORE_CNTRL, &port->regs->core_control);
  84. udelay(50);
  85. - snprintf(phy_id, MII_BUS_ID_SIZE + 3, PHY_ID_FMT,
  86. - mdio_bus->id, plat->phy);
  87. - port->phydev = phy_connect(dev, phy_id, &ixp4xx_adjust_link,
  88. - PHY_INTERFACE_MODE_MII);
  89. - if (IS_ERR(port->phydev)) {
  90. - err = PTR_ERR(port->phydev);
  91. + err = ixp4xx_phy_connect(dev);
  92. + if (err)
  93. goto err_free_mem;
  94. - }
  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. if ((err = register_netdev(dev)))
  102. goto err_phy_dis;
  103. @@ -1489,7 +1521,7 @@ static int eth_init_one(struct platform_
  104. return 0;
  105. err_phy_dis:
  106. - phy_disconnect(port->phydev);
  107. + ixp4xx_phy_disconnect(dev);
  108. err_free_mem:
  109. npe_port_tab[NPE_ID(port->id)] = NULL;
  110. release_resource(port->mem_res);
  111. @@ -1506,7 +1538,7 @@ static int eth_remove_one(struct platfor
  112. struct port *port = netdev_priv(dev);
  113. unregister_netdev(dev);
  114. - phy_disconnect(port->phydev);
  115. + ixp4xx_phy_disconnect(dev);
  116. npe_port_tab[NPE_ID(port->id)] = NULL;
  117. npe_release(port->npe);
  118. release_resource(port->mem_res);