0001-net-thunderx-add-support-for-rgmii-internal-delay-mo.patch 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. From 69a99101748bb1bdb2730393ef48bc152c4d244a Mon Sep 17 00:00:00 2001
  2. From: Tim Harvey <[email protected]>
  3. Date: Tue, 12 Dec 2017 12:49:55 -0800
  4. Subject: [PATCH] net: thunderx: add support for rgmii internal delay modes
  5. The XCV_DLL_CTL is being configured with the assumption that
  6. phy-mode is rgmii-txid (PHY_INTERFACE_MODE_RGMII_TXID) which is not always
  7. the case.
  8. This patch parses the phy-mode property and uses it to configure CXV_DLL_CTL
  9. properly.
  10. Signed-off-by: Tim Harvey <[email protected]>
  11. ---
  12. drivers/net/ethernet/cavium/thunder/thunder_bgx.c | 13 +++++++---
  13. drivers/net/ethernet/cavium/thunder/thunder_bgx.h | 2 +-
  14. drivers/net/ethernet/cavium/thunder/thunder_xcv.c | 31 ++++++++++++++++++-----
  15. 3 files changed, 35 insertions(+), 11 deletions(-)
  16. --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
  17. +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
  18. @@ -55,6 +55,7 @@ struct bgx {
  19. struct pci_dev *pdev;
  20. bool is_dlm;
  21. bool is_rgx;
  22. + int phy_mode;
  23. };
  24. static struct bgx *bgx_vnic[MAX_BGX_THUNDER];
  25. @@ -841,12 +842,12 @@ static void bgx_poll_for_link(struct wor
  26. queue_delayed_work(lmac->check_link, &lmac->dwork, HZ * 2);
  27. }
  28. -static int phy_interface_mode(u8 lmac_type)
  29. +static int phy_interface_mode(struct bgx *bgx, u8 lmac_type)
  30. {
  31. if (lmac_type == BGX_MODE_QSGMII)
  32. return PHY_INTERFACE_MODE_QSGMII;
  33. if (lmac_type == BGX_MODE_RGMII)
  34. - return PHY_INTERFACE_MODE_RGMII;
  35. + return bgx->phy_mode;
  36. return PHY_INTERFACE_MODE_SGMII;
  37. }
  38. @@ -912,7 +913,8 @@ static int bgx_lmac_enable(struct bgx *b
  39. if (phy_connect_direct(&lmac->netdev, lmac->phydev,
  40. bgx_lmac_handler,
  41. - phy_interface_mode(lmac->lmac_type)))
  42. + phy_interface_mode(bgx,
  43. + lmac->lmac_type)))
  44. return -ENODEV;
  45. phy_start_aneg(lmac->phydev);
  46. @@ -1287,6 +1289,8 @@ static int bgx_init_of_phy(struct bgx *b
  47. bgx->lmac[lmac].lmacid = lmac;
  48. phy_np = of_parse_phandle(node, "phy-handle", 0);
  49. + if (phy_np)
  50. + bgx->phy_mode = of_get_phy_mode(phy_np);
  51. /* If there is no phy or defective firmware presents
  52. * this cortina phy, for which there is no driver
  53. * support, ignore it.
  54. @@ -1390,7 +1394,6 @@ static int bgx_probe(struct pci_dev *pde
  55. bgx->max_lmac = 1;
  56. bgx->bgx_id = MAX_BGX_PER_CN81XX - 1;
  57. bgx_vnic[bgx->bgx_id] = bgx;
  58. - xcv_init_hw();
  59. }
  60. /* On 81xx all are DLMs and on 83xx there are 3 BGX QLMs and one
  61. @@ -1407,6 +1410,8 @@ static int bgx_probe(struct pci_dev *pde
  62. if (err)
  63. goto err_enable;
  64. + if (bgx->is_rgx)
  65. + xcv_init_hw(bgx->phy_mode);
  66. bgx_init_hw(bgx);
  67. /* Enable all LMACs */
  68. --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.h
  69. +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.h
  70. @@ -226,7 +226,7 @@ void bgx_lmac_internal_loopback(int node
  71. void bgx_lmac_get_pfc(int node, int bgx_idx, int lmacid, void *pause);
  72. void bgx_lmac_set_pfc(int node, int bgx_idx, int lmacid, void *pause);
  73. -void xcv_init_hw(void);
  74. +void xcv_init_hw(int phy_mode);
  75. void xcv_setup_link(bool link_up, int link_speed);
  76. u64 bgx_get_rx_stats(int node, int bgx_idx, int lmac, int idx);
  77. --- a/drivers/net/ethernet/cavium/thunder/thunder_xcv.c
  78. +++ b/drivers/net/ethernet/cavium/thunder/thunder_xcv.c
  79. @@ -65,7 +65,7 @@ MODULE_LICENSE("GPL v2");
  80. MODULE_VERSION(DRV_VERSION);
  81. MODULE_DEVICE_TABLE(pci, xcv_id_table);
  82. -void xcv_init_hw(void)
  83. +void xcv_init_hw(int phy_mode)
  84. {
  85. u64 cfg;
  86. @@ -81,12 +81,31 @@ void xcv_init_hw(void)
  87. /* Wait for DLL to lock */
  88. msleep(1);
  89. - /* Configure DLL - enable or bypass
  90. - * TX no bypass, RX bypass
  91. - */
  92. + /* enable/bypass DLL providing MAC based internal TX/RX delays */
  93. cfg = readq_relaxed(xcv->reg_base + XCV_DLL_CTL);
  94. - cfg &= ~0xFF03;
  95. - cfg |= CLKRX_BYP;
  96. + cfg &= ~0xffff00;
  97. + switch (phy_mode) {
  98. + /* RX and TX delays are added by the MAC */
  99. + case PHY_INTERFACE_MODE_RGMII:
  100. + break;
  101. + /* internal RX and TX delays provided by the PHY */
  102. + case PHY_INTERFACE_MODE_RGMII_ID:
  103. + cfg |= CLKRX_BYP;
  104. + cfg |= CLKTX_BYP;
  105. + break;
  106. + /* internal RX delay provided by the PHY, the MAC
  107. + * should not add an RX delay in this case
  108. + */
  109. + case PHY_INTERFACE_MODE_RGMII_RXID:
  110. + cfg |= CLKRX_BYP;
  111. + break;
  112. + /* internal TX delay provided by the PHY, the MAC
  113. + * should not add an TX delay in this case
  114. + */
  115. + case PHY_INTERFACE_MODE_RGMII_TXID:
  116. + cfg |= CLKRX_BYP;
  117. + break;
  118. + }
  119. writeq_relaxed(cfg, xcv->reg_base + XCV_DLL_CTL);
  120. /* Enable compensation controller and force the