207-npe_driver_multiphy_support.patch 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. TODO: take care of additional PHYs through the PHY abstraction layer
  2. --- a/arch/arm/mach-ixp4xx/include/mach/platform.h
  3. +++ b/arch/arm/mach-ixp4xx/include/mach/platform.h
  4. @@ -95,12 +95,23 @@ struct ixp4xx_pata_data {
  5. #define IXP4XX_ETH_NPEB 0x10
  6. #define IXP4XX_ETH_NPEC 0x20
  7. +#define IXP4XX_ETH_PHY_MAX_ADDR 32
  8. +
  9. /* Information about built-in Ethernet MAC interfaces */
  10. struct eth_plat_info {
  11. u8 phy; /* MII PHY ID, 0 - 31 */
  12. u8 rxq; /* configurable, currently 0 - 31 only */
  13. u8 txreadyq;
  14. u8 hwaddr[6];
  15. +
  16. + u32 phy_mask;
  17. +#if 0
  18. + int speed;
  19. + int duplex;
  20. +#else
  21. + int speed_10;
  22. + int half_duplex;
  23. +#endif
  24. };
  25. /* Information about built-in HSS (synchronous serial) interfaces */
  26. --- a/drivers/net/ethernet/xscale/ixp4xx_eth.c
  27. +++ b/drivers/net/ethernet/xscale/ixp4xx_eth.c
  28. @@ -610,6 +610,37 @@ static int ixp4xx_phy_connect(struct net
  29. struct eth_plat_info *plat = port->plat;
  30. char phy_id[MII_BUS_ID_SIZE + 3];
  31. + if (plat->phy == IXP4XX_ETH_PHY_MAX_ADDR) {
  32. +#if 0
  33. + switch (plat->speed) {
  34. + case SPEED_10:
  35. + case SPEED_100:
  36. + break;
  37. + default:
  38. + printk(KERN_ERR "%s: invalid speed (%d)\n",
  39. + dev->name, plat->speed);
  40. + return -EINVAL;
  41. + }
  42. +
  43. + switch (plat->duplex) {
  44. + case DUPLEX_HALF:
  45. + case DUPLEX_FULL:
  46. + break;
  47. + default:
  48. + printk(KERN_ERR "%s: invalid duplex mode (%d)\n",
  49. + dev->name, plat->duplex);
  50. + return -EINVAL;
  51. + }
  52. + port->speed = plat->speed;
  53. + port->duplex = plat->duplex;
  54. +#else
  55. + port->speed = plat->speed_10 ? SPEED_10 : SPEED_100;
  56. + port->duplex = plat->half_duplex ? DUPLEX_HALF : DUPLEX_FULL;
  57. +#endif
  58. +
  59. + return 0;
  60. + }
  61. +
  62. snprintf(phy_id, MII_BUS_ID_SIZE + 3, PHY_ID_FMT,
  63. mdio_bus->id, plat->phy);
  64. port->phydev = phy_connect(dev, phy_id, &ixp4xx_adjust_link,
  65. @@ -632,21 +663,32 @@ static void ixp4xx_phy_disconnect(struct
  66. {
  67. struct port *port = netdev_priv(dev);
  68. - phy_disconnect(port->phydev);
  69. + if (port->phydev)
  70. + phy_disconnect(port->phydev);
  71. }
  72. static void ixp4xx_phy_start(struct net_device *dev)
  73. {
  74. struct port *port = netdev_priv(dev);
  75. - phy_start(port->phydev);
  76. + if (port->phydev) {
  77. + phy_start(port->phydev);
  78. + } else {
  79. + port->link = 1;
  80. + ixp4xx_update_link(dev);
  81. + }
  82. }
  83. static void ixp4xx_phy_stop(struct net_device *dev)
  84. {
  85. struct port *port = netdev_priv(dev);
  86. - phy_stop(port->phydev);
  87. + if (port->phydev) {
  88. + phy_stop(port->phydev);
  89. + } else {
  90. + port->link = 0;
  91. + ixp4xx_update_link(dev);
  92. + }
  93. }
  94. static inline void debug_pkt(struct net_device *dev, const char *func,
  95. @@ -1048,6 +1090,9 @@ static int eth_ioctl(struct net_device *
  96. return hwtstamp_get(dev, req);
  97. }
  98. + if (!port->phydev)
  99. + return -EOPNOTSUPP;
  100. +
  101. return phy_mii_ioctl(port->phydev, req, cmd);
  102. }
  103. @@ -1068,18 +1113,30 @@ static void ixp4xx_get_drvinfo(struct ne
  104. static int ixp4xx_get_settings(struct net_device *dev, struct ethtool_cmd *cmd)
  105. {
  106. struct port *port = netdev_priv(dev);
  107. +
  108. + if (!port->phydev)
  109. + return -EOPNOTSUPP;
  110. +
  111. return phy_ethtool_gset(port->phydev, cmd);
  112. }
  113. static int ixp4xx_set_settings(struct net_device *dev, struct ethtool_cmd *cmd)
  114. {
  115. struct port *port = netdev_priv(dev);
  116. +
  117. + if (!port->phydev)
  118. + return -EOPNOTSUPP;
  119. +
  120. return phy_ethtool_sset(port->phydev, cmd);
  121. }
  122. static int ixp4xx_nway_reset(struct net_device *dev)
  123. {
  124. struct port *port = netdev_priv(dev);
  125. +
  126. + if (!port->phydev)
  127. + return -EOPNOTSUPP;
  128. +
  129. return phy_start_aneg(port->phydev);
  130. }