7029-fmd-SGMII-PCS-needs-to-be-reprogrammed-after-sleep.patch 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. From afcfdda960da9d9ad4c4d21c7dd0cc7791cf36c7 Mon Sep 17 00:00:00 2001
  2. From: Madalin Bucur <madalin.bucur@freescale.com>
  3. Date: Wed, 4 May 2016 19:24:53 +0300
  4. Subject: [PATCH 29/70] fmd: SGMII PCS needs to be reprogrammed after sleep
  5. Signed-off-by: Madalin Bucur <madalin.bucur@freescale.com>
  6. ---
  7. drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.c | 6 ++
  8. .../freescale/sdk_fman/Peripherals/FM/MAC/dtsec.c | 1 +
  9. .../freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.c | 12 ++++
  10. .../freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.h | 1 +
  11. .../freescale/sdk_fman/Peripherals/FM/MAC/memac.c | 58 +++++++++++---------
  12. .../freescale/sdk_fman/Peripherals/FM/MAC/tgec.c | 1 +
  13. .../sdk_fman/inc/Peripherals/fm_mac_ext.h | 13 +++++
  14. .../sdk_fman/src/inc/wrapper/lnxwrp_fsl_fman.h | 2 +
  15. .../freescale/sdk_fman/src/wrapper/lnxwrp_fm.c | 14 +++++
  16. 9 files changed, 83 insertions(+), 25 deletions(-)
  17. --- a/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.c
  18. +++ b/drivers/net/ethernet/freescale/sdk_dpaa/dpaa_eth.c
  19. @@ -175,6 +175,12 @@ static int dpaa_resume(struct device *de
  20. priv = netdev_priv(net_dev);
  21. mac_dev = priv->mac_dev;
  22. + err = fm_mac_resume(mac_dev->get_mac_handle(mac_dev));
  23. + if (err) {
  24. + netdev_err(net_dev, "fm_mac_resume = %d\n", err);
  25. + goto resume_failed;
  26. + }
  27. +
  28. err = fm_port_resume(mac_dev->port_dev[TX]);
  29. if (err) {
  30. netdev_err(net_dev, "fm_port_resume(TX) = %d\n", err);
  31. --- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/dtsec.c
  32. +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/dtsec.c
  33. @@ -1371,6 +1371,7 @@ static void InitFmMacControllerDriver(t_
  34. p_FmMacControllerDriver->f_FM_MAC_Enable = DtsecEnable;
  35. p_FmMacControllerDriver->f_FM_MAC_Disable = DtsecDisable;
  36. + p_FmMacControllerDriver->f_FM_MAC_Resume = NULL;
  37. p_FmMacControllerDriver->f_FM_MAC_SetException = DtsecSetException;
  38. --- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.c
  39. +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.c
  40. @@ -299,6 +299,18 @@ t_Error FM_MAC_Disable (t_Handle h_FmMac
  41. RETURN_ERROR(MINOR, E_NOT_SUPPORTED, NO_MSG);
  42. }
  43. +t_Error FM_MAC_Resume (t_Handle h_FmMac)
  44. +{
  45. + t_FmMacControllerDriver *p_FmMacControllerDriver = (t_FmMacControllerDriver *)h_FmMac;
  46. +
  47. + SANITY_CHECK_RETURN_ERROR(p_FmMacControllerDriver, E_INVALID_HANDLE);
  48. +
  49. + if (p_FmMacControllerDriver->f_FM_MAC_Resume)
  50. + return p_FmMacControllerDriver->f_FM_MAC_Resume(h_FmMac);
  51. +
  52. + return E_OK;
  53. +}
  54. +
  55. /* ......................................................................... */
  56. t_Error FM_MAC_Enable1588TimeStamp (t_Handle h_FmMac)
  57. --- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.h
  58. +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/fm_mac.h
  59. @@ -91,6 +91,7 @@ typedef struct {
  60. t_Error (*f_FM_MAC_Enable) (t_Handle h_FmMac, e_CommMode mode);
  61. t_Error (*f_FM_MAC_Disable) (t_Handle h_FmMac, e_CommMode mode);
  62. + t_Error (*f_FM_MAC_Resume) (t_Handle h_FmMac);
  63. t_Error (*f_FM_MAC_Enable1588TimeStamp) (t_Handle h_FmMac);
  64. t_Error (*f_FM_MAC_Disable1588TimeStamp) (t_Handle h_FmMac);
  65. t_Error (*f_FM_MAC_Reset) (t_Handle h_FmMac, bool wait);
  66. --- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/memac.c
  67. +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/memac.c
  68. @@ -812,6 +812,37 @@ static uint16_t MemacGetMaxFrameLength(t
  69. return fman_memac_get_max_frame_len(p_Memac->p_MemMap);
  70. }
  71. +static t_Error MemacInitInternalPhy(t_Handle h_Memac)
  72. +{
  73. + t_Memac *p_Memac = (t_Memac *)h_Memac;
  74. + uint8_t i, phyAddr;
  75. +
  76. + if (ENET_INTERFACE_FROM_MODE(p_Memac->enetMode) == e_ENET_IF_SGMII)
  77. + {
  78. + /* Configure internal SGMII PHY */
  79. + if (p_Memac->enetMode & ENET_IF_SGMII_BASEX)
  80. + SetupSgmiiInternalPhyBaseX(p_Memac, PHY_MDIO_ADDR);
  81. + else
  82. + SetupSgmiiInternalPhy(p_Memac, PHY_MDIO_ADDR);
  83. + }
  84. + else if (ENET_INTERFACE_FROM_MODE(p_Memac->enetMode) == e_ENET_IF_QSGMII)
  85. + {
  86. + /* Configure 4 internal SGMII PHYs */
  87. + for (i = 0; i < 4; i++)
  88. + {
  89. + /* QSGMII PHY address occupies 3 upper bits of 5-bit
  90. + phyAddress; the lower 2 bits are used to extend
  91. + register address space and access each one of 4
  92. + ports inside QSGMII. */
  93. + phyAddr = (uint8_t)((PHY_MDIO_ADDR << 2) | i);
  94. + if (p_Memac->enetMode & ENET_IF_SGMII_BASEX)
  95. + SetupSgmiiInternalPhyBaseX(p_Memac, phyAddr);
  96. + else
  97. + SetupSgmiiInternalPhy(p_Memac, phyAddr);
  98. + }
  99. + }
  100. + return E_OK;
  101. +}
  102. /*****************************************************************************/
  103. /* mEMAC Init & Free API */
  104. @@ -825,7 +856,6 @@ static t_Error MemacInit(t_Handle h_Mema
  105. struct memac_cfg *p_MemacDriverParam;
  106. enum enet_interface enet_interface;
  107. enum enet_speed enet_speed;
  108. - uint8_t i, phyAddr;
  109. t_EnetAddr ethAddr;
  110. e_FmMacType portType;
  111. t_Error err;
  112. @@ -887,30 +917,7 @@ static t_Error MemacInit(t_Handle h_Mema
  113. }
  114. #endif /* FM_RX_FIFO_CORRUPT_ERRATA_10GMAC_A006320 */
  115. - if (ENET_INTERFACE_FROM_MODE(p_Memac->enetMode) == e_ENET_IF_SGMII)
  116. - {
  117. - /* Configure internal SGMII PHY */
  118. - if (p_Memac->enetMode & ENET_IF_SGMII_BASEX)
  119. - SetupSgmiiInternalPhyBaseX(p_Memac, PHY_MDIO_ADDR);
  120. - else
  121. - SetupSgmiiInternalPhy(p_Memac, PHY_MDIO_ADDR);
  122. - }
  123. - else if (ENET_INTERFACE_FROM_MODE(p_Memac->enetMode) == e_ENET_IF_QSGMII)
  124. - {
  125. - /* Configure 4 internal SGMII PHYs */
  126. - for (i = 0; i < 4; i++)
  127. - {
  128. - /* QSGMII PHY address occupies 3 upper bits of 5-bit
  129. - phyAddress; the lower 2 bits are used to extend
  130. - register address space and access each one of 4
  131. - ports inside QSGMII. */
  132. - phyAddr = (uint8_t)((PHY_MDIO_ADDR << 2) | i);
  133. - if (p_Memac->enetMode & ENET_IF_SGMII_BASEX)
  134. - SetupSgmiiInternalPhyBaseX(p_Memac, phyAddr);
  135. - else
  136. - SetupSgmiiInternalPhy(p_Memac, phyAddr);
  137. - }
  138. - }
  139. + MemacInitInternalPhy(h_Memac);
  140. /* Max Frame Length */
  141. err = FmSetMacMaxFrame(p_Memac->fmMacControllerDriver.h_Fm,
  142. @@ -1008,6 +1015,7 @@ static void InitFmMacControllerDriver(t_
  143. p_FmMacControllerDriver->f_FM_MAC_Enable = MemacEnable;
  144. p_FmMacControllerDriver->f_FM_MAC_Disable = MemacDisable;
  145. + p_FmMacControllerDriver->f_FM_MAC_Resume = MemacInitInternalPhy;
  146. p_FmMacControllerDriver->f_FM_MAC_SetTxAutoPauseFrames = MemacSetTxAutoPauseFrames;
  147. p_FmMacControllerDriver->f_FM_MAC_SetTxPauseFrames = MemacSetTxPauseFrames;
  148. --- a/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/tgec.c
  149. +++ b/drivers/net/ethernet/freescale/sdk_fman/Peripherals/FM/MAC/tgec.c
  150. @@ -897,6 +897,7 @@ static void InitFmMacControllerDriver(t_
  151. p_FmMacControllerDriver->f_FM_MAC_Enable = TgecEnable;
  152. p_FmMacControllerDriver->f_FM_MAC_Disable = TgecDisable;
  153. + p_FmMacControllerDriver->f_FM_MAC_Resume = NULL;
  154. p_FmMacControllerDriver->f_FM_MAC_SetTxAutoPauseFrames = TgecTxMacPause;
  155. p_FmMacControllerDriver->f_FM_MAC_SetTxPauseFrames = TgecSetTxPauseFrames;
  156. --- a/drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_mac_ext.h
  157. +++ b/drivers/net/ethernet/freescale/sdk_fman/inc/Peripherals/fm_mac_ext.h
  158. @@ -467,6 +467,19 @@ t_Error FM_MAC_Enable(t_Handle h_FmMac,
  159. t_Error FM_MAC_Disable(t_Handle h_FmMac, e_CommMode mode);
  160. /**************************************************************************//**
  161. + @Function FM_MAC_Resume
  162. +
  163. + @Description Re-init the MAC after suspend
  164. +
  165. + @Param[in] h_FmMac A handle to a FM MAC Module.
  166. +
  167. + @Return E_OK on success; Error code otherwise.
  168. +
  169. + @Cautions Allowed only following FM_MAC_Init().
  170. +*//***************************************************************************/
  171. +t_Error FM_MAC_Resume(t_Handle h_FmMac);
  172. +
  173. +/**************************************************************************//**
  174. @Function FM_MAC_Enable1588TimeStamp
  175. @Description Enables the TSU operation.
  176. --- a/drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/lnxwrp_fsl_fman.h
  177. +++ b/drivers/net/ethernet/freescale/sdk_fman/src/inc/wrapper/lnxwrp_fsl_fman.h
  178. @@ -765,6 +765,8 @@ int fm_mac_enable(struct fm_mac_dev *fm_
  179. int fm_mac_disable(struct fm_mac_dev *fm_mac_dev);
  180. +int fm_mac_resume(struct fm_mac_dev *fm_mac_dev);
  181. +
  182. int fm_mac_set_promiscuous(struct fm_mac_dev *fm_mac_dev,
  183. bool enable);
  184. --- a/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_fm.c
  185. +++ b/drivers/net/ethernet/freescale/sdk_fman/src/wrapper/lnxwrp_fm.c
  186. @@ -1733,6 +1733,20 @@ int fm_mac_disable(struct fm_mac_dev *fm
  187. }
  188. EXPORT_SYMBOL(fm_mac_disable);
  189. +int fm_mac_resume(struct fm_mac_dev *fm_mac_dev)
  190. +{
  191. + int _errno;
  192. + t_Error err;
  193. +
  194. + err = FM_MAC_Resume(fm_mac_dev);
  195. + _errno = -GET_ERROR_TYPE(err);
  196. + if (unlikely(_errno < 0))
  197. + pr_err("FM_MAC_Resume() = 0x%08x\n", err);
  198. +
  199. + return _errno;
  200. +}
  201. +EXPORT_SYMBOL(fm_mac_resume);
  202. +
  203. int fm_mac_set_promiscuous(struct fm_mac_dev *fm_mac_dev,
  204. bool enable)
  205. {