Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

phy: lynx-28g: restructure protocol configuration register accesses

Eliminate the need to calculate a lane_offset manually, and generate
some macros which access the protocol converter corresponding to the
correct lane in the PCC* registers.

Signed-off-by: Vladimir Oltean <vladimir.oltean@nxp.com>
Link: https://patch.msgid.link/20251125114847.804961-10-vladimir.oltean@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Vladimir Oltean and committed by
Vinod Koul
6af3b6d3 90d985a0

+32 -21
+32 -21
drivers/phy/freescale/phy-fsl-lynx-28g.c
··· 12 12 #define LYNX_28G_NUM_LANE 8 13 13 #define LYNX_28G_NUM_PLL 2 14 14 15 + #define LNa_PCC_OFFSET(lane) (4 * (LYNX_28G_NUM_LANE - (lane->id) - 1)) 16 + 15 17 /* General registers per SerDes block */ 16 18 #define PCC8 0x10a0 17 - #define PCC8_SGMII 0x1 18 - #define PCC8_SGMII_DIS 0x0 19 + #define PCC8_SGMIInCFG(lane, x) (((x) & GENMASK(2, 0)) << LNa_PCC_OFFSET(lane)) 20 + #define PCC8_SGMIInCFG_EN(lane) PCC8_SGMIInCFG(lane, 1) 21 + #define PCC8_SGMIInCFG_MSK(lane) PCC8_SGMIInCFG(lane, GENMASK(2, 0)) 22 + #define PCC8_SGMIIn_KX(lane, x) ((((x) << 3) & BIT(3)) << LNa_PCC_OFFSET(lane)) 23 + #define PCC8_SGMIIn_KX_MSK(lane) PCC8_SGMIIn_KX(lane, 1) 24 + #define PCC8_MSK(lane) PCC8_SGMIInCFG_MSK(lane) | \ 25 + PCC8_SGMIIn_KX_MSK(lane) 19 26 20 27 #define PCCC 0x10b0 21 - #define PCCC_10GBASER 0x9 22 - #define PCCC_USXGMII 0x1 23 - #define PCCC_SXGMII_DIS 0x0 28 + #define PCCC_SXGMIInCFG(lane, x) (((x) & GENMASK(2, 0)) << LNa_PCC_OFFSET(lane)) 29 + #define PCCC_SXGMIInCFG_EN(lane) PCCC_SXGMIInCFG(lane, 1) 30 + #define PCCC_SXGMIInCFG_MSK(lane) PCCC_SXGMIInCFG(lane, GENMASK(2, 0)) 31 + #define PCCC_SXGMIInCFG_XFI(lane, x) ((((x) << 3) & BIT(3)) << LNa_PCC_OFFSET(lane)) 32 + #define PCCC_SXGMIInCFG_XFI_MSK(lane) PCCC_SXGMIInCFG_XFI(lane, 1) 33 + #define PCCC_MSK(lane) PCCC_SXGMIInCFG_MSK(lane) | \ 34 + PCCC_SXGMIInCFG_XFI_MSK(lane) 24 35 25 - #define LNa_PCC_OFFSET(lane) (4 * (LYNX_28G_NUM_LANE - (lane->id) - 1)) 36 + #define PCCD 0x10b4 37 + #define PCCD_E25GnCFG(lane, x) (((x) & GENMASK(2, 0)) << LNa_PCCD_OFFSET(lane)) 38 + #define PCCD_E25GnCFG_EN(lane) PCCD_E25GnCFG(lane, 1) 39 + #define PCCD_E25GnCFG_MSK(lane) PCCD_E25GnCFG(lane, GENMASK(2, 0)) 40 + #define PCCD_MSK(lane) PCCD_E25GnCFG_MSK(lane) 26 41 27 42 /* Per PLL registers */ 28 43 #define PLLnRSTCTL(pll) (0x400 + (pll) * 0x100 + 0x0) ··· 329 314 static void lynx_28g_cleanup_lane(struct lynx_28g_lane *lane) 330 315 { 331 316 struct lynx_28g_priv *priv = lane->priv; 332 - u32 lane_offset = LNa_PCC_OFFSET(lane); 333 317 334 318 /* Cleanup the protocol configuration registers of the current protocol */ 335 319 switch (lane->interface) { 336 320 case PHY_INTERFACE_MODE_10GBASER: 337 - lynx_28g_rmw(priv, PCCC, 338 - PCCC_SXGMII_DIS << lane_offset, 339 - GENMASK(3, 0) << lane_offset); 321 + /* Cleanup the protocol configuration registers */ 322 + lynx_28g_rmw(priv, PCCC, 0, PCCC_MSK(lane)); 340 323 break; 341 324 case PHY_INTERFACE_MODE_SGMII: 342 325 case PHY_INTERFACE_MODE_1000BASEX: 343 - lynx_28g_rmw(priv, PCC8, 344 - PCC8_SGMII_DIS << lane_offset, 345 - GENMASK(3, 0) << lane_offset); 326 + /* Cleanup the protocol configuration registers */ 327 + lynx_28g_rmw(priv, PCC8, 0, PCC8_MSK(lane)); 328 + 329 + /* Disable the SGMII PCS */ 330 + lynx_28g_lane_rmw(lane, SGMIIaCR1, 0, SGMIIaCR1_SGPCS_EN); 331 + 346 332 break; 347 333 default: 348 334 break; ··· 352 336 353 337 static void lynx_28g_lane_set_sgmii(struct lynx_28g_lane *lane) 354 338 { 355 - u32 lane_offset = LNa_PCC_OFFSET(lane); 356 339 struct lynx_28g_priv *priv = lane->priv; 357 340 struct lynx_28g_pll *pll; 358 341 359 342 lynx_28g_cleanup_lane(lane); 360 343 361 344 /* Setup the lane to run in SGMII */ 362 - lynx_28g_rmw(priv, PCC8, 363 - PCC8_SGMII << lane_offset, 364 - GENMASK(3, 0) << lane_offset); 345 + lynx_28g_rmw(priv, PCC8, PCC8_SGMIInCFG_EN(lane), PCC8_MSK(lane)); 365 346 366 347 /* Setup the protocol select and SerDes parallel interface width */ 367 348 lynx_28g_lane_rmw(lane, LNaGCR0, ··· 403 390 static void lynx_28g_lane_set_10gbaser(struct lynx_28g_lane *lane) 404 391 { 405 392 struct lynx_28g_priv *priv = lane->priv; 406 - u32 lane_offset = LNa_PCC_OFFSET(lane); 407 393 struct lynx_28g_pll *pll; 408 394 409 395 lynx_28g_cleanup_lane(lane); 410 396 411 397 /* Enable the SXGMII lane */ 412 - lynx_28g_rmw(priv, PCCC, 413 - PCCC_10GBASER << lane_offset, 414 - GENMASK(3, 0) << lane_offset); 398 + lynx_28g_rmw(priv, PCCC, PCCC_SXGMIInCFG_EN(lane) | 399 + PCCC_SXGMIInCFG_XFI(lane, 1), PCCC_MSK(lane)); 415 400 416 401 /* Setup the protocol select and SerDes parallel interface width */ 417 402 lynx_28g_lane_rmw(lane, LNaGCR0,