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

phy: phy-mtk-tphy: add a new reference clock

Usually the digital and analog phys use the same reference clock,
but some platforms have two separate reference clocks for each of
them, so add another optional clock to support them.
In order to keep the clock names consistent with PHY IP's, change
the da_ref for analog phy and ref clock for digital phy.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>

authored by

Chunfeng Yun and committed by
Kishon Vijay Abraham I
12d0c0be 360f4344

+18 -1
+18 -1
drivers/phy/mediatek/phy-mtk-tphy.c
··· 298 298 struct u2phy_banks u2_banks; 299 299 struct u3phy_banks u3_banks; 300 300 }; 301 - struct clk *ref_clk; /* reference clock of anolog phy */ 301 + struct clk *ref_clk; /* reference clock of (digital) phy */ 302 + struct clk *da_ref_clk; /* reference clock of analog phy */ 302 303 u32 index; 303 304 u8 type; 304 305 int eye_src; ··· 926 925 return ret; 927 926 } 928 927 928 + ret = clk_prepare_enable(instance->da_ref_clk); 929 + if (ret) { 930 + dev_err(tphy->dev, "failed to enable da_ref\n"); 931 + clk_disable_unprepare(instance->ref_clk); 932 + return ret; 933 + } 934 + 929 935 switch (instance->type) { 930 936 case PHY_TYPE_USB2: 931 937 u2_phy_instance_init(tphy, instance); ··· 992 984 u2_phy_instance_exit(tphy, instance); 993 985 994 986 clk_disable_unprepare(instance->ref_clk); 987 + clk_disable_unprepare(instance->da_ref_clk); 995 988 return 0; 996 989 } 997 990 ··· 1177 1168 if (IS_ERR(instance->ref_clk)) { 1178 1169 dev_err(dev, "failed to get ref_clk(id-%d)\n", port); 1179 1170 retval = PTR_ERR(instance->ref_clk); 1171 + goto put_child; 1172 + } 1173 + 1174 + instance->da_ref_clk = 1175 + devm_clk_get_optional(&phy->dev, "da_ref"); 1176 + if (IS_ERR(instance->da_ref_clk)) { 1177 + dev_err(dev, "failed to get da_ref_clk(id-%d)\n", port); 1178 + retval = PTR_ERR(instance->da_ref_clk); 1180 1179 goto put_child; 1181 1180 } 1182 1181 }