Advertisement
Guest User

Untitled

a guest
Mar 19th, 2017
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 2.15 KB | None | 0 0
  1. commit c673ce2ce358f473e81292af6b59d6fdc62f5ade
  2. Author: Andre Przywara <andre.przywara@arm.com>
  3. Date:   Tue Feb 28 22:23:35 2017 +0000
  4.  
  5.     PHY: faulty 8211E workaround
  6.  
  7. diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c
  8. index 9cbe645..331183f 100644
  9. --- a/drivers/net/phy/realtek.c
  10. +++ b/drivers/net/phy/realtek.c
  11. @@ -15,6 +15,7 @@
  12.   */
  13.  #include <linux/phy.h>
  14.  #include <linux/module.h>
  15. +#include <linux/of.h>
  16.  
  17.  #define RTL821x_PHYSR      0x11
  18.  #define RTL821x_PHYSR_DUPLEX   0x2000
  19. @@ -23,6 +24,8 @@
  20.  #define RTL821x_INER_INIT  0x6400
  21.  #define RTL821x_INSR       0x13
  22.  #define RTL8211E_INER_LINK_STATUS 0x400
  23. +#define RTL8211E_EXTENSION_PAGE    0x7
  24. +#define RTL8211E_EXT_PAGE_SEL  0x1e
  25.  
  26.  #define RTL8211F_INER_LINK_STATUS 0x0010
  27.  #define RTL8211F_INSR      0x1d
  28. @@ -67,6 +70,33 @@ static int rtl8211b_config_intr(struct phy_device *phydev)
  29.     return err;
  30.  }
  31.  
  32. +static int rtl8211e_config_init(struct phy_device *phydev)
  33. +{
  34. +   struct device_node *of_node = phydev->mdio.dev.of_node;
  35. +
  36. +   if (!of_node)
  37. +       return 0;
  38. +
  39. +   if (!of_property_read_bool(of_node, "disable-rx-delay")) {
  40. +       pr_info("8211E PHY, but no DT property\n");
  41. +       return 0;
  42. +   }
  43. +
  44. +   /* This is a workaround for a batch of faulty PHY chips, found
  45. +    * on a range of Pine64 boards. The RX delay needs to be disabled
  46. +    * completely (the normal rx_delay of 0 programmable by the driver
  47. +    * is not "short enough").
  48. +    */
  49. +   phy_write(phydev, RTL8211F_PAGE_SELECT, RTL8211E_EXTENSION_PAGE);
  50. +   phy_write(phydev, RTL8211E_EXT_PAGE_SEL, 0x00a4);
  51. +   /* Recommended by Realtek engineers, without further explanation. */
  52. +   phy_write(phydev, 0x1c, 0xb591);
  53. +   phy_write(phydev, RTL8211F_PAGE_SELECT, 0x0);
  54. +   pr_info("Applied RTL8211E PHY fix to disable RX delay.\n");
  55. +
  56. +   return 0;
  57. +}
  58. +
  59.  static int rtl8211e_config_intr(struct phy_device *phydev)
  60.  {
  61.     int err;
  62. @@ -156,6 +186,7 @@ static struct phy_driver realtek_drvs[] = {
  63.         .phy_id_mask    = 0x001fffff,
  64.         .features   = PHY_GBIT_FEATURES,
  65.         .flags      = PHY_HAS_INTERRUPT,
  66. +       .config_init    = rtl8211e_config_init,
  67.         .config_aneg    = &genphy_config_aneg,
  68.         .read_status    = &genphy_read_status,
  69.         .ack_interrupt  = &rtl821x_ack_interrupt,
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement