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

phy: fsl-imx8mq-usb: add i.MX95 tuning support

The i.MX8MP and i.MX95 USB3 PHY have different tuning parameter for same
tuning field, this will add i.MX95 tuning support.

Reviewed-by: Jun Li <jun.li@nxp.com>
Signed-off-by: Xu Yang <xu.yang_2@nxp.com>
Link: https://lore.kernel.org/r/20250430094502.2723983-4-xu.yang_2@nxp.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>

authored by

Xu Yang and committed by
Vinod Koul
e75d564f b15ee09d

+74
+74
drivers/phy/freescale/phy-fsl-imx8mq-usb.c
··· 293 293 return DIV_ROUND_CLOSEST(percent - 94U, 2); 294 294 } 295 295 296 + static u32 imx95_phy_tx_vref_tune_from_property(u32 percent) 297 + { 298 + percent = clamp(percent, 90U, 108U); 299 + 300 + switch (percent) { 301 + case 90 ... 91: 302 + percent = 0; 303 + break; 304 + case 92 ... 96: 305 + percent -= 91; 306 + break; 307 + case 97 ... 104: 308 + percent -= 92; 309 + break; 310 + case 105 ... 108: 311 + percent -= 93; 312 + break; 313 + } 314 + 315 + return percent; 316 + } 317 + 296 318 static u32 phy_tx_rise_tune_from_property(u32 percent) 297 319 { 298 320 switch (percent) { ··· 326 304 return 1; 327 305 default: 328 306 return 0; 307 + } 308 + } 309 + 310 + static u32 imx95_phy_tx_rise_tune_from_property(u32 percent) 311 + { 312 + percent = clamp(percent, 90U, 120U); 313 + 314 + switch (percent) { 315 + case 90 ... 99: 316 + return 3; 317 + case 101 ... 115: 318 + return 1; 319 + case 116 ... 120: 320 + return 0; 321 + default: 322 + return 2; 329 323 } 330 324 } 331 325 ··· 390 352 return 7; 391 353 } 392 354 } 355 + 356 + static u32 imx95_phy_comp_dis_tune_from_property(u32 percent) 357 + { 358 + percent = clamp(percent, 94, 104); 359 + 360 + switch (percent) { 361 + case 94 ... 95: 362 + percent = 0; 363 + break; 364 + case 96 ... 98: 365 + percent -= 95; 366 + break; 367 + case 99 ... 102: 368 + percent -= 96; 369 + break; 370 + case 103 ... 104: 371 + percent -= 97; 372 + break; 373 + } 374 + 375 + return percent; 376 + } 377 + 393 378 static u32 phy_pcs_tx_swing_full_from_property(u32 percent) 394 379 { 395 380 percent = min(percent, 100U); ··· 423 362 static void imx8m_get_phy_tuning_data(struct imx8mq_usb_phy *imx_phy) 424 363 { 425 364 struct device *dev = imx_phy->phy->dev.parent; 365 + bool is_imx95 = false; 366 + 367 + if (device_is_compatible(dev, "fsl,imx95-usb-phy")) 368 + is_imx95 = true; 426 369 427 370 if (device_property_read_u32(dev, "fsl,phy-tx-vref-tune-percent", 428 371 &imx_phy->tx_vref_tune)) 429 372 imx_phy->tx_vref_tune = PHY_TUNE_DEFAULT; 373 + else if (is_imx95) 374 + imx_phy->tx_vref_tune = 375 + imx95_phy_tx_vref_tune_from_property(imx_phy->tx_vref_tune); 430 376 else 431 377 imx_phy->tx_vref_tune = 432 378 phy_tx_vref_tune_from_property(imx_phy->tx_vref_tune); ··· 441 373 if (device_property_read_u32(dev, "fsl,phy-tx-rise-tune-percent", 442 374 &imx_phy->tx_rise_tune)) 443 375 imx_phy->tx_rise_tune = PHY_TUNE_DEFAULT; 376 + else if (is_imx95) 377 + imx_phy->tx_rise_tune = 378 + imx95_phy_tx_rise_tune_from_property(imx_phy->tx_rise_tune); 444 379 else 445 380 imx_phy->tx_rise_tune = 446 381 phy_tx_rise_tune_from_property(imx_phy->tx_rise_tune); ··· 465 394 if (device_property_read_u32(dev, "fsl,phy-comp-dis-tune-percent", 466 395 &imx_phy->comp_dis_tune)) 467 396 imx_phy->comp_dis_tune = PHY_TUNE_DEFAULT; 397 + else if (is_imx95) 398 + imx_phy->comp_dis_tune = 399 + imx95_phy_comp_dis_tune_from_property(imx_phy->comp_dis_tune); 468 400 else 469 401 imx_phy->comp_dis_tune = 470 402 phy_comp_dis_tune_from_property(imx_phy->comp_dis_tune);