Skip to content

Commit e75d564

Browse files
Xu Yangvinodkoul
authored andcommitted
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 <[email protected]> Signed-off-by: Xu Yang <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent b15ee09 commit e75d564

File tree

1 file changed

+74
-0
lines changed

1 file changed

+74
-0
lines changed

drivers/phy/freescale/phy-fsl-imx8mq-usb.c

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -293,6 +293,28 @@ static u32 phy_tx_vref_tune_from_property(u32 percent)
293293
return DIV_ROUND_CLOSEST(percent - 94U, 2);
294294
}
295295

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+
296318
static u32 phy_tx_rise_tune_from_property(u32 percent)
297319
{
298320
switch (percent) {
@@ -307,6 +329,22 @@ static u32 phy_tx_rise_tune_from_property(u32 percent)
307329
}
308330
}
309331

332+
static u32 imx95_phy_tx_rise_tune_from_property(u32 percent)
333+
{
334+
percent = clamp(percent, 90U, 120U);
335+
336+
switch (percent) {
337+
case 90 ... 99:
338+
return 3;
339+
case 101 ... 115:
340+
return 1;
341+
case 116 ... 120:
342+
return 0;
343+
default:
344+
return 2;
345+
}
346+
}
347+
310348
static u32 phy_tx_preemp_amp_tune_from_property(u32 microamp)
311349
{
312350
microamp = min(microamp, 1800U);
@@ -352,6 +390,29 @@ static u32 phy_comp_dis_tune_from_property(u32 percent)
352390
return 7;
353391
}
354392
}
393+
394+
static u32 imx95_phy_comp_dis_tune_from_property(u32 percent)
395+
{
396+
percent = clamp(percent, 94, 104);
397+
398+
switch (percent) {
399+
case 94 ... 95:
400+
percent = 0;
401+
break;
402+
case 96 ... 98:
403+
percent -= 95;
404+
break;
405+
case 99 ... 102:
406+
percent -= 96;
407+
break;
408+
case 103 ... 104:
409+
percent -= 97;
410+
break;
411+
}
412+
413+
return percent;
414+
}
415+
355416
static u32 phy_pcs_tx_swing_full_from_property(u32 percent)
356417
{
357418
percent = min(percent, 100U);
@@ -362,17 +423,27 @@ static u32 phy_pcs_tx_swing_full_from_property(u32 percent)
362423
static void imx8m_get_phy_tuning_data(struct imx8mq_usb_phy *imx_phy)
363424
{
364425
struct device *dev = imx_phy->phy->dev.parent;
426+
bool is_imx95 = false;
427+
428+
if (device_is_compatible(dev, "fsl,imx95-usb-phy"))
429+
is_imx95 = true;
365430

366431
if (device_property_read_u32(dev, "fsl,phy-tx-vref-tune-percent",
367432
&imx_phy->tx_vref_tune))
368433
imx_phy->tx_vref_tune = PHY_TUNE_DEFAULT;
434+
else if (is_imx95)
435+
imx_phy->tx_vref_tune =
436+
imx95_phy_tx_vref_tune_from_property(imx_phy->tx_vref_tune);
369437
else
370438
imx_phy->tx_vref_tune =
371439
phy_tx_vref_tune_from_property(imx_phy->tx_vref_tune);
372440

373441
if (device_property_read_u32(dev, "fsl,phy-tx-rise-tune-percent",
374442
&imx_phy->tx_rise_tune))
375443
imx_phy->tx_rise_tune = PHY_TUNE_DEFAULT;
444+
else if (is_imx95)
445+
imx_phy->tx_rise_tune =
446+
imx95_phy_tx_rise_tune_from_property(imx_phy->tx_rise_tune);
376447
else
377448
imx_phy->tx_rise_tune =
378449
phy_tx_rise_tune_from_property(imx_phy->tx_rise_tune);
@@ -394,6 +465,9 @@ static void imx8m_get_phy_tuning_data(struct imx8mq_usb_phy *imx_phy)
394465
if (device_property_read_u32(dev, "fsl,phy-comp-dis-tune-percent",
395466
&imx_phy->comp_dis_tune))
396467
imx_phy->comp_dis_tune = PHY_TUNE_DEFAULT;
468+
else if (is_imx95)
469+
imx_phy->comp_dis_tune =
470+
imx95_phy_comp_dis_tune_from_property(imx_phy->comp_dis_tune);
397471
else
398472
imx_phy->comp_dis_tune =
399473
phy_comp_dis_tune_from_property(imx_phy->comp_dis_tune);

0 commit comments

Comments
 (0)