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

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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. diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
  17. index 5e5c4d7..805c02a 100644
  18. --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
  19. +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
  20. @@ -55,6 +55,7 @@ struct bgx {
  21. struct pci_dev *pdev;
  22. bool is_dlm;
  23. bool is_rgx;
  24. + int phy_mode;
  25. };
  26. static struct bgx *bgx_vnic[MAX_BGX_THUNDER];
  27. @@ -841,12 +842,12 @@ static void bgx_poll_for_link(struct work_struct *work)
  28. queue_delayed_work(lmac->check_link, &lmac->dwork, HZ * 2);
  29. }
  30. -static int phy_interface_mode(u8 lmac_type)
  31. +static int phy_interface_mode(struct bgx *bgx, u8 lmac_type)
  32. {
  33. if (lmac_type == BGX_MODE_QSGMII)
  34. return PHY_INTERFACE_MODE_QSGMII;
  35. if (lmac_type == BGX_MODE_RGMII)
  36. - return PHY_INTERFACE_MODE_RGMII;
  37. + return bgx->phy_mode;
  38. return PHY_INTERFACE_MODE_SGMII;
  39. }
  40. @@ -912,7 +913,8 @@ static int bgx_lmac_enable(struct bgx *bgx, u8 lmacid)
  41. if (phy_connect_direct(&lmac->netdev, lmac->phydev,
  42. bgx_lmac_handler,
  43. - phy_interface_mode(lmac->lmac_type)))
  44. + phy_interface_mode(bgx,
  45. + lmac->lmac_type)))
  46. return -ENODEV;
  47. phy_start_aneg(lmac->phydev);
  48. @@ -1287,6 +1289,8 @@ static int bgx_init_of_phy(struct bgx *bgx)
  49. bgx->lmac[lmac].lmacid = lmac;
  50. phy_np = of_parse_phandle(node, "phy-handle", 0);
  51. + if (phy_np)
  52. + bgx->phy_mode = of_get_phy_mode(phy_np);
  53. /* If there is no phy or defective firmware presents
  54. * this cortina phy, for which there is no driver
  55. * support, ignore it.
  56. @@ -1390,7 +1394,6 @@ static int bgx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
  57. bgx->max_lmac = 1;
  58. bgx->bgx_id = MAX_BGX_PER_CN81XX - 1;
  59. bgx_vnic[bgx->bgx_id] = bgx;
  60. - xcv_init_hw();
  61. }
  62. /* On 81xx all are DLMs and on 83xx there are 3 BGX QLMs and one
  63. @@ -1407,6 +1410,8 @@ static int bgx_probe(struct pci_dev *pdev, const struct pci_device_id *ent)
  64. if (err)
  65. goto err_enable;
  66. + if (bgx->is_rgx)
  67. + xcv_init_hw(bgx->phy_mode);
  68. bgx_init_hw(bgx);
  69. /* Enable all LMACs */
  70. diff --git a/drivers/net/ethernet/cavium/thunder/thunder_bgx.h b/drivers/net/ethernet/cavium/thunder/thunder_bgx.h
  71. index 23acdc5..2bba9d1 100644
  72. --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.h
  73. +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.h
  74. @@ -226,7 +226,7 @@ void bgx_lmac_internal_loopback(int node, int bgx_idx,
  75. void bgx_lmac_get_pfc(int node, int bgx_idx, int lmacid, void *pause);
  76. void bgx_lmac_set_pfc(int node, int bgx_idx, int lmacid, void *pause);
  77. -void xcv_init_hw(void);
  78. +void xcv_init_hw(int phy_mode);
  79. void xcv_setup_link(bool link_up, int link_speed);
  80. u64 bgx_get_rx_stats(int node, int bgx_idx, int lmac, int idx);
  81. diff --git a/drivers/net/ethernet/cavium/thunder/thunder_xcv.c b/drivers/net/ethernet/cavium/thunder/thunder_xcv.c
  82. index 578c7f8..7e0c4cb 100644
  83. --- a/drivers/net/ethernet/cavium/thunder/thunder_xcv.c
  84. +++ b/drivers/net/ethernet/cavium/thunder/thunder_xcv.c
  85. @@ -65,7 +65,7 @@ MODULE_LICENSE("GPL v2");
  86. MODULE_VERSION(DRV_VERSION);
  87. MODULE_DEVICE_TABLE(pci, xcv_id_table);
  88. -void xcv_init_hw(void)
  89. +void xcv_init_hw(int phy_mode)
  90. {
  91. u64 cfg;
  92. @@ -81,12 +81,31 @@ void xcv_init_hw(void)
  93. /* Wait for DLL to lock */
  94. msleep(1);
  95. - /* Configure DLL - enable or bypass
  96. - * TX no bypass, RX bypass
  97. - */
  98. + /* enable/bypass DLL providing MAC based internal TX/RX delays */
  99. cfg = readq_relaxed(xcv->reg_base + XCV_DLL_CTL);
  100. - cfg &= ~0xFF03;
  101. - cfg |= CLKRX_BYP;
  102. + cfg &= ~0xffff00;
  103. + switch (phy_mode) {
  104. + /* RX and TX delays are added by the MAC */
  105. + case PHY_INTERFACE_MODE_RGMII:
  106. + break;
  107. + /* internal RX and TX delays provided by the PHY */
  108. + case PHY_INTERFACE_MODE_RGMII_ID:
  109. + cfg |= CLKRX_BYP;
  110. + cfg |= CLKTX_BYP;
  111. + break;
  112. + /* internal RX delay provided by the PHY, the MAC
  113. + * should not add an RX delay in this case
  114. + */
  115. + case PHY_INTERFACE_MODE_RGMII_RXID:
  116. + cfg |= CLKRX_BYP;
  117. + break;
  118. + /* internal TX delay provided by the PHY, the MAC
  119. + * should not add an TX delay in this case
  120. + */
  121. + case PHY_INTERFACE_MODE_RGMII_TXID:
  122. + cfg |= CLKRX_BYP;
  123. + break;
  124. + }
  125. writeq_relaxed(cfg, xcv->reg_base + XCV_DLL_CTL);
  126. /* Enable compensation controller and force the
  127. --
  128. 2.7.4