Lines Matching refs:hsphy

141 static int qcom_snps_hsphy_clk_init(struct qcom_snps_hsphy *hsphy)  in qcom_snps_hsphy_clk_init()  argument
143 struct device *dev = hsphy->dev; in qcom_snps_hsphy_clk_init()
145 hsphy->num_clks = 2; in qcom_snps_hsphy_clk_init()
146 hsphy->clks = devm_kcalloc(dev, hsphy->num_clks, sizeof(*hsphy->clks), GFP_KERNEL); in qcom_snps_hsphy_clk_init()
147 if (!hsphy->clks) in qcom_snps_hsphy_clk_init()
154 hsphy->clks[0].id = "cfg_ahb"; in qcom_snps_hsphy_clk_init()
155 hsphy->clks[0].clk = devm_clk_get_optional(dev, "cfg_ahb"); in qcom_snps_hsphy_clk_init()
156 if (IS_ERR(hsphy->clks[0].clk)) in qcom_snps_hsphy_clk_init()
157 return dev_err_probe(dev, PTR_ERR(hsphy->clks[0].clk), in qcom_snps_hsphy_clk_init()
160 hsphy->clks[1].id = "ref"; in qcom_snps_hsphy_clk_init()
161 hsphy->clks[1].clk = devm_clk_get(dev, "ref"); in qcom_snps_hsphy_clk_init()
162 if (IS_ERR(hsphy->clks[1].clk)) in qcom_snps_hsphy_clk_init()
163 return dev_err_probe(dev, PTR_ERR(hsphy->clks[1].clk), in qcom_snps_hsphy_clk_init()
183 static int qcom_snps_hsphy_suspend(struct qcom_snps_hsphy *hsphy) in qcom_snps_hsphy_suspend() argument
185 dev_dbg(&hsphy->phy->dev, "Suspend QCOM SNPS PHY\n"); in qcom_snps_hsphy_suspend()
187 if (hsphy->mode == PHY_MODE_USB_HOST) { in qcom_snps_hsphy_suspend()
189 qcom_snps_hsphy_write_mask(hsphy->base, in qcom_snps_hsphy_suspend()
194 qcom_snps_hsphy_write_mask(hsphy->base, in qcom_snps_hsphy_suspend()
202 static int qcom_snps_hsphy_resume(struct qcom_snps_hsphy *hsphy) in qcom_snps_hsphy_resume() argument
204 dev_dbg(&hsphy->phy->dev, "Resume QCOM SNPS PHY, mode\n"); in qcom_snps_hsphy_resume()
211 struct qcom_snps_hsphy *hsphy = dev_get_drvdata(dev); in qcom_snps_hsphy_runtime_suspend() local
213 if (!hsphy->phy_initialized) in qcom_snps_hsphy_runtime_suspend()
216 return qcom_snps_hsphy_suspend(hsphy); in qcom_snps_hsphy_runtime_suspend()
221 struct qcom_snps_hsphy *hsphy = dev_get_drvdata(dev); in qcom_snps_hsphy_runtime_resume() local
223 if (!hsphy->phy_initialized) in qcom_snps_hsphy_runtime_resume()
226 return qcom_snps_hsphy_resume(hsphy); in qcom_snps_hsphy_runtime_resume()
232 struct qcom_snps_hsphy *hsphy = phy_get_drvdata(phy); in qcom_snps_hsphy_set_mode() local
234 hsphy->mode = mode; in qcom_snps_hsphy_set_mode()
388 struct qcom_snps_hsphy *hsphy = phy_get_drvdata(phy); in qcom_snps_hsphy_init() local
393 ret = regulator_bulk_enable(ARRAY_SIZE(hsphy->vregs), hsphy->vregs); in qcom_snps_hsphy_init()
397 ret = clk_bulk_prepare_enable(hsphy->num_clks, hsphy->clks); in qcom_snps_hsphy_init()
403 ret = reset_control_assert(hsphy->phy_reset); in qcom_snps_hsphy_init()
411 ret = reset_control_deassert(hsphy->phy_reset); in qcom_snps_hsphy_init()
417 qcom_snps_hsphy_write_mask(hsphy->base, USB2_PHY_USB_PHY_CFG0, in qcom_snps_hsphy_init()
420 qcom_snps_hsphy_write_mask(hsphy->base, USB2_PHY_USB_PHY_UTMI_CTRL5, in qcom_snps_hsphy_init()
422 qcom_snps_hsphy_write_mask(hsphy->base, in qcom_snps_hsphy_init()
425 qcom_snps_hsphy_write_mask(hsphy->base, in qcom_snps_hsphy_init()
428 qcom_snps_hsphy_write_mask(hsphy->base, USB2_PHY_USB_PHY_REFCLK_CTRL, in qcom_snps_hsphy_init()
430 qcom_snps_hsphy_write_mask(hsphy->base, in qcom_snps_hsphy_init()
433 qcom_snps_hsphy_write_mask(hsphy->base, USB2_PHY_USB_PHY_HS_PHY_CTRL1, in qcom_snps_hsphy_init()
436 for (i = 0; i < ARRAY_SIZE(hsphy->update_seq_cfg); i++) { in qcom_snps_hsphy_init()
437 if (hsphy->update_seq_cfg[i].need_update) in qcom_snps_hsphy_init()
438 qcom_snps_hsphy_write_mask(hsphy->base, in qcom_snps_hsphy_init()
439 hsphy->update_seq_cfg[i].offset, in qcom_snps_hsphy_init()
440 hsphy->update_seq_cfg[i].mask, in qcom_snps_hsphy_init()
441 hsphy->update_seq_cfg[i].value); in qcom_snps_hsphy_init()
444 qcom_snps_hsphy_write_mask(hsphy->base, in qcom_snps_hsphy_init()
448 qcom_snps_hsphy_write_mask(hsphy->base, USB2_PHY_USB_PHY_HS_PHY_CTRL2, in qcom_snps_hsphy_init()
452 qcom_snps_hsphy_write_mask(hsphy->base, USB2_PHY_USB_PHY_UTMI_CTRL0, in qcom_snps_hsphy_init()
455 qcom_snps_hsphy_write_mask(hsphy->base, USB2_PHY_USB_PHY_HS_PHY_CTRL_COMMON0, in qcom_snps_hsphy_init()
458 qcom_snps_hsphy_write_mask(hsphy->base, USB2_PHY_USB_PHY_UTMI_CTRL5, in qcom_snps_hsphy_init()
461 qcom_snps_hsphy_write_mask(hsphy->base, USB2_PHY_USB_PHY_HS_PHY_CTRL2, in qcom_snps_hsphy_init()
464 qcom_snps_hsphy_write_mask(hsphy->base, USB2_PHY_USB_PHY_CFG0, in qcom_snps_hsphy_init()
467 hsphy->phy_initialized = true; in qcom_snps_hsphy_init()
472 clk_bulk_disable_unprepare(hsphy->num_clks, hsphy->clks); in qcom_snps_hsphy_init()
474 regulator_bulk_disable(ARRAY_SIZE(hsphy->vregs), hsphy->vregs); in qcom_snps_hsphy_init()
481 struct qcom_snps_hsphy *hsphy = phy_get_drvdata(phy); in qcom_snps_hsphy_exit() local
483 reset_control_assert(hsphy->phy_reset); in qcom_snps_hsphy_exit()
484 clk_bulk_disable_unprepare(hsphy->num_clks, hsphy->clks); in qcom_snps_hsphy_exit()
485 regulator_bulk_disable(ARRAY_SIZE(hsphy->vregs), hsphy->vregs); in qcom_snps_hsphy_exit()
486 hsphy->phy_initialized = false; in qcom_snps_hsphy_exit()
543 struct qcom_snps_hsphy *hsphy; in qcom_snps_hsphy_read_override_param_seq() local
549 hsphy = dev_get_drvdata(dev); in qcom_snps_hsphy_read_override_param_seq()
557 &hsphy->update_seq_cfg[i]); in qcom_snps_hsphy_read_override_param_seq()
558 dev_dbg(&hsphy->phy->dev, "Read param: %s dt_val: %d reg_val: 0x%x\n", in qcom_snps_hsphy_read_override_param_seq()
559 cfg[i].prop_name, val, hsphy->update_seq_cfg[i].value); in qcom_snps_hsphy_read_override_param_seq()
567 struct qcom_snps_hsphy *hsphy; in qcom_snps_hsphy_probe() local
573 hsphy = devm_kzalloc(dev, sizeof(*hsphy), GFP_KERNEL); in qcom_snps_hsphy_probe()
574 if (!hsphy) in qcom_snps_hsphy_probe()
577 hsphy->dev = dev; in qcom_snps_hsphy_probe()
579 hsphy->base = devm_platform_ioremap_resource(pdev, 0); in qcom_snps_hsphy_probe()
580 if (IS_ERR(hsphy->base)) in qcom_snps_hsphy_probe()
581 return PTR_ERR(hsphy->base); in qcom_snps_hsphy_probe()
583 ret = qcom_snps_hsphy_clk_init(hsphy); in qcom_snps_hsphy_probe()
587 hsphy->phy_reset = devm_reset_control_get_exclusive(&pdev->dev, NULL); in qcom_snps_hsphy_probe()
588 if (IS_ERR(hsphy->phy_reset)) { in qcom_snps_hsphy_probe()
590 return PTR_ERR(hsphy->phy_reset); in qcom_snps_hsphy_probe()
593 num = ARRAY_SIZE(hsphy->vregs); in qcom_snps_hsphy_probe()
595 hsphy->vregs[i].supply = qcom_snps_hsphy_vreg_names[i]; in qcom_snps_hsphy_probe()
597 ret = devm_regulator_bulk_get(dev, num, hsphy->vregs); in qcom_snps_hsphy_probe()
616 hsphy->phy = generic_phy; in qcom_snps_hsphy_probe()
618 dev_set_drvdata(dev, hsphy); in qcom_snps_hsphy_probe()
619 phy_set_drvdata(generic_phy, hsphy); in qcom_snps_hsphy_probe()