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

phy: phy-mtk-tphy: add configurable parameters for slew rate calibrate

There are two parameters, ref_clk and coefficient, for U2 slew rate
calibrate which may vary on different SoCs, here allow them to be
configurable

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Reviewed-by: Matthias Brugger <matthias.bgg@gmail.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>

authored by

Chunfeng Yun and committed by
Kishon Vijay Abraham I
8833ebf4 40363256

+15 -5
+15 -5
drivers/phy/mediatek/phy-mtk-tphy.c
··· 306 306 const struct mtk_phy_pdata *pdata; 307 307 struct mtk_phy_instance **phys; 308 308 int nphys; 309 + int src_ref_clk; /* MHZ, reference clock for slew rate calibrate */ 310 + int src_coef; /* coefficient for slew rate calibrate */ 309 311 }; 310 312 311 313 static void hs_slew_rate_calibrate(struct mtk_tphy *tphy, ··· 362 360 writel(tmp, fmreg + U3P_U2FREQ_FMMONR1); 363 361 364 362 if (fm_out) { 365 - /* ( 1024 / FM_OUT ) x reference clock frequency x 0.028 */ 366 - tmp = U3P_FM_DET_CYCLE_CNT * U3P_REF_CLK * U3P_SLEW_RATE_COEF; 367 - tmp /= fm_out; 363 + /* ( 1024 / FM_OUT ) x reference clock frequency x coef */ 364 + tmp = tphy->src_ref_clk * tphy->src_coef; 365 + tmp = (tmp * U3P_FM_DET_CYCLE_CNT) / fm_out; 368 366 calibration_val = DIV_ROUND_CLOSEST(tmp, U3P_SR_COEF_DIVISOR); 369 367 } else { 370 368 /* if FM detection fail, set default value */ 371 369 calibration_val = 4; 372 370 } 373 - dev_dbg(tphy->dev, "phy:%d, fm_out:%d, calib:%d\n", 374 - instance->index, fm_out, calibration_val); 371 + dev_dbg(tphy->dev, "phy:%d, fm_out:%d, calib:%d (clk:%d, coef:%d)\n", 372 + instance->index, fm_out, calibration_val, 373 + tphy->src_ref_clk, tphy->src_coef); 375 374 376 375 /* set HS slew rate */ 377 376 tmp = readl(com + U3P_USBPHYACR5); ··· 1043 1040 1044 1041 tphy->u3phya_ref = NULL; 1045 1042 } 1043 + 1044 + tphy->src_ref_clk = U3P_REF_CLK; 1045 + tphy->src_coef = U3P_SLEW_RATE_COEF; 1046 + /* update parameters of slew rate calibrate if exist */ 1047 + device_property_read_u32(dev, "mediatek,src-ref-clk-mhz", 1048 + &tphy->src_ref_clk); 1049 + device_property_read_u32(dev, "mediatek,src-coef", &tphy->src_coef); 1046 1050 1047 1051 port = 0; 1048 1052 for_each_child_of_node(np, child_np) {