Lines Matching +full:sm8550 +full:- +full:snps +full:- +full:eusb2 +full:- +full:phy

1 // SPDX-License-Identifier: GPL-2.0
11 #include <linux/phy/phy.h>
125 struct phy *phy; member
135 struct phy *repeater;
138 static int qcom_snps_eusb2_hsphy_set_mode(struct phy *p, enum phy_mode mode, int submode) in qcom_snps_eusb2_hsphy_set_mode()
140 struct qcom_snps_eusb2_hsphy *phy = phy_get_drvdata(p); in qcom_snps_eusb2_hsphy_set_mode() local
142 phy->mode = mode; in qcom_snps_eusb2_hsphy_set_mode()
144 return phy_set_mode_ext(phy->repeater, mode, submode); in qcom_snps_eusb2_hsphy_set_mode()
161 static void qcom_eusb2_default_parameters(struct qcom_snps_eusb2_hsphy *phy) in qcom_eusb2_default_parameters() argument
163 /* default parameters: tx pre-emphasis */ in qcom_eusb2_default_parameters()
164 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_9, in qcom_eusb2_default_parameters()
169 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_9, in qcom_eusb2_default_parameters()
174 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_9, in qcom_eusb2_default_parameters()
179 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_8, in qcom_eusb2_default_parameters()
184 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_8, in qcom_eusb2_default_parameters()
189 static int qcom_eusb2_ref_clk_init(struct qcom_snps_eusb2_hsphy *phy) in qcom_eusb2_ref_clk_init() argument
191 unsigned long ref_clk_freq = clk_get_rate(phy->ref_clk); in qcom_eusb2_ref_clk_init()
195 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_HS_PHY_CTRL_COMMON0, in qcom_eusb2_ref_clk_init()
199 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_2, in qcom_eusb2_ref_clk_init()
203 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_3, in qcom_eusb2_ref_clk_init()
209 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_HS_PHY_CTRL_COMMON0, in qcom_eusb2_ref_clk_init()
213 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_2, in qcom_eusb2_ref_clk_init()
217 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_3, in qcom_eusb2_ref_clk_init()
223 dev_err(&phy->phy->dev, "unsupported ref_clk_freq:%lu\n", ref_clk_freq); in qcom_eusb2_ref_clk_init()
224 return -EINVAL; in qcom_eusb2_ref_clk_init()
227 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_3, in qcom_eusb2_ref_clk_init()
233 static int qcom_snps_eusb2_hsphy_init(struct phy *p) in qcom_snps_eusb2_hsphy_init()
235 struct qcom_snps_eusb2_hsphy *phy = phy_get_drvdata(p); in qcom_snps_eusb2_hsphy_init() local
238 ret = regulator_bulk_enable(ARRAY_SIZE(phy->vregs), phy->vregs); in qcom_snps_eusb2_hsphy_init()
242 ret = phy_init(phy->repeater); in qcom_snps_eusb2_hsphy_init()
244 dev_err(&p->dev, "repeater init failed. %d\n", ret); in qcom_snps_eusb2_hsphy_init()
248 ret = clk_prepare_enable(phy->ref_clk); in qcom_snps_eusb2_hsphy_init()
250 dev_err(&p->dev, "failed to enable ref clock, %d\n", ret); in qcom_snps_eusb2_hsphy_init()
254 ret = reset_control_assert(phy->phy_reset); in qcom_snps_eusb2_hsphy_init()
256 dev_err(&p->dev, "failed to assert phy_reset, %d\n", ret); in qcom_snps_eusb2_hsphy_init()
262 ret = reset_control_deassert(phy->phy_reset); in qcom_snps_eusb2_hsphy_init()
264 dev_err(&p->dev, "failed to de-assert phy_reset, %d\n", ret); in qcom_snps_eusb2_hsphy_init()
268 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG0, in qcom_snps_eusb2_hsphy_init()
271 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_UTMI_CTRL5, POR, POR); in qcom_snps_eusb2_hsphy_init()
273 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_HS_PHY_CTRL_COMMON0, in qcom_snps_eusb2_hsphy_init()
276 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_APB_ACCESS_CMD, in qcom_snps_eusb2_hsphy_init()
279 qcom_snps_eusb2_hsphy_write_mask(phy->base, UTMI_PHY_CMN_CTRL0, TESTBURNIN, 0); in qcom_snps_eusb2_hsphy_init()
281 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_FSEL_SEL, in qcom_snps_eusb2_hsphy_init()
285 ret = qcom_eusb2_ref_clk_init(phy); in qcom_snps_eusb2_hsphy_init()
289 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_1, in qcom_snps_eusb2_hsphy_init()
293 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_4, in qcom_snps_eusb2_hsphy_init()
297 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_4, in qcom_snps_eusb2_hsphy_init()
301 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_5, in qcom_snps_eusb2_hsphy_init()
305 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_6, in qcom_snps_eusb2_hsphy_init()
309 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_CFG_CTRL_5, in qcom_snps_eusb2_hsphy_init()
313 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_HS_PHY_CTRL2, in qcom_snps_eusb2_hsphy_init()
317 qcom_eusb2_default_parameters(phy); in qcom_snps_eusb2_hsphy_init()
319 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_HS_PHY_CTRL2, in qcom_snps_eusb2_hsphy_init()
323 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_UTMI_CTRL0, SLEEPM, SLEEPM); in qcom_snps_eusb2_hsphy_init()
325 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_HS_PHY_CTRL_COMMON0, in qcom_snps_eusb2_hsphy_init()
328 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_HS_PHY_CTRL_COMMON0, in qcom_snps_eusb2_hsphy_init()
331 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_UTMI_CTRL5, POR, 0); in qcom_snps_eusb2_hsphy_init()
333 qcom_snps_eusb2_hsphy_write_mask(phy->base, USB_PHY_HS_PHY_CTRL2, in qcom_snps_eusb2_hsphy_init()
339 clk_disable_unprepare(phy->ref_clk); in qcom_snps_eusb2_hsphy_init()
342 regulator_bulk_disable(ARRAY_SIZE(phy->vregs), phy->vregs); in qcom_snps_eusb2_hsphy_init()
347 static int qcom_snps_eusb2_hsphy_exit(struct phy *p) in qcom_snps_eusb2_hsphy_exit()
349 struct qcom_snps_eusb2_hsphy *phy = phy_get_drvdata(p); in qcom_snps_eusb2_hsphy_exit() local
351 clk_disable_unprepare(phy->ref_clk); in qcom_snps_eusb2_hsphy_exit()
353 regulator_bulk_disable(ARRAY_SIZE(phy->vregs), phy->vregs); in qcom_snps_eusb2_hsphy_exit()
355 phy_exit(phy->repeater); in qcom_snps_eusb2_hsphy_exit()
369 struct device *dev = &pdev->dev; in qcom_snps_eusb2_hsphy_probe()
370 struct device_node *np = dev->of_node; in qcom_snps_eusb2_hsphy_probe()
371 struct qcom_snps_eusb2_hsphy *phy; in qcom_snps_eusb2_hsphy_probe() local
373 struct phy *generic_phy; in qcom_snps_eusb2_hsphy_probe()
377 phy = devm_kzalloc(dev, sizeof(*phy), GFP_KERNEL); in qcom_snps_eusb2_hsphy_probe()
378 if (!phy) in qcom_snps_eusb2_hsphy_probe()
379 return -ENOMEM; in qcom_snps_eusb2_hsphy_probe()
381 phy->base = devm_platform_ioremap_resource(pdev, 0); in qcom_snps_eusb2_hsphy_probe()
382 if (IS_ERR(phy->base)) in qcom_snps_eusb2_hsphy_probe()
383 return PTR_ERR(phy->base); in qcom_snps_eusb2_hsphy_probe()
385 phy->phy_reset = devm_reset_control_get_exclusive(dev, NULL); in qcom_snps_eusb2_hsphy_probe()
386 if (IS_ERR(phy->phy_reset)) in qcom_snps_eusb2_hsphy_probe()
387 return PTR_ERR(phy->phy_reset); in qcom_snps_eusb2_hsphy_probe()
389 phy->ref_clk = devm_clk_get(dev, "ref"); in qcom_snps_eusb2_hsphy_probe()
390 if (IS_ERR(phy->ref_clk)) in qcom_snps_eusb2_hsphy_probe()
391 return dev_err_probe(dev, PTR_ERR(phy->ref_clk), in qcom_snps_eusb2_hsphy_probe()
394 num = ARRAY_SIZE(phy->vregs); in qcom_snps_eusb2_hsphy_probe()
396 phy->vregs[i].supply = eusb2_hsphy_vreg_names[i]; in qcom_snps_eusb2_hsphy_probe()
398 ret = devm_regulator_bulk_get(dev, num, phy->vregs); in qcom_snps_eusb2_hsphy_probe()
403 phy->repeater = devm_of_phy_get_by_index(dev, np, 0); in qcom_snps_eusb2_hsphy_probe()
404 if (IS_ERR(phy->repeater)) in qcom_snps_eusb2_hsphy_probe()
405 return dev_err_probe(dev, PTR_ERR(phy->repeater), in qcom_snps_eusb2_hsphy_probe()
410 dev_err(dev, "failed to create phy %d\n", ret); in qcom_snps_eusb2_hsphy_probe()
414 dev_set_drvdata(dev, phy); in qcom_snps_eusb2_hsphy_probe()
415 phy_set_drvdata(generic_phy, phy); in qcom_snps_eusb2_hsphy_probe()
421 dev_info(dev, "Registered Qcom-eUSB2 phy\n"); in qcom_snps_eusb2_hsphy_probe()
427 { .compatible = "qcom,sm8550-snps-eusb2-phy", },
435 .name = "qcom-snps-eusb2-hsphy",
441 MODULE_DESCRIPTION("Qualcomm SNPS eUSB2 HS PHY driver");