Lines Matching refs:qphy

420 static void qusb2_phy_override_phy_params(struct qusb2_phy *qphy)  in qusb2_phy_override_phy_params()  argument
422 const struct qusb2_phy_cfg *cfg = qphy->cfg; in qusb2_phy_override_phy_params()
423 struct override_params *or = &qphy->overrides; in qusb2_phy_override_phy_params()
426 qusb2_write_mask(qphy->base, QUSB2PHY_IMP_CTRL1, in qusb2_phy_override_phy_params()
431 qusb2_write_mask(qphy->base, QUSB2PHY_PLL_BIAS_CONTROL_2, in qusb2_phy_override_phy_params()
436 qusb2_write_mask(qphy->base, QUSB2PHY_CHG_CTRL2, in qusb2_phy_override_phy_params()
441 qusb2_write_mask(qphy->base, cfg->regs[QUSB2PHY_PORT_TUNE1], in qusb2_phy_override_phy_params()
446 qusb2_write_mask(qphy->base, cfg->regs[QUSB2PHY_PORT_TUNE1], in qusb2_phy_override_phy_params()
453 qusb2_setbits(qphy->base, in qusb2_phy_override_phy_params()
457 qusb2_clrbits(qphy->base, in qusb2_phy_override_phy_params()
463 qusb2_write_mask(qphy->base, cfg->regs[QUSB2PHY_PORT_TUNE2], in qusb2_phy_override_phy_params()
473 static void qusb2_phy_set_tune2_param(struct qusb2_phy *qphy) in qusb2_phy_set_tune2_param() argument
475 struct device *dev = &qphy->phy->dev; in qusb2_phy_set_tune2_param()
476 const struct qusb2_phy_cfg *cfg = qphy->cfg; in qusb2_phy_set_tune2_param()
480 if (!qphy->cell) in qusb2_phy_set_tune2_param()
490 val = nvmem_cell_read(qphy->cell, NULL); in qusb2_phy_set_tune2_param()
498 qusb2_write_mask(qphy->base, cfg->regs[QUSB2PHY_PORT_TUNE1], in qusb2_phy_set_tune2_param()
502 qusb2_write_mask(qphy->base, cfg->regs[QUSB2PHY_PORT_TUNE2], in qusb2_phy_set_tune2_param()
510 struct qusb2_phy *qphy = phy_get_drvdata(phy); in qusb2_phy_set_mode() local
512 qphy->mode = mode; in qusb2_phy_set_mode()
519 struct qusb2_phy *qphy = dev_get_drvdata(dev); in qusb2_phy_runtime_suspend() local
520 const struct qusb2_phy_cfg *cfg = qphy->cfg; in qusb2_phy_runtime_suspend()
523 dev_vdbg(dev, "Suspending QUSB2 Phy, mode:%d\n", qphy->mode); in qusb2_phy_runtime_suspend()
525 if (!qphy->phy_initialized) { in qusb2_phy_runtime_suspend()
537 switch (qphy->mode) { in qusb2_phy_runtime_suspend()
555 writel(intr_mask, qphy->base + cfg->regs[QUSB2PHY_INTR_CTRL]); in qusb2_phy_runtime_suspend()
559 qusb2_setbits(qphy->base, in qusb2_phy_runtime_suspend()
566 if (qphy->mode != PHY_MODE_INVALID) { in qusb2_phy_runtime_suspend()
567 qusb2_setbits(qphy->base, cfg->regs[QUSB2PHY_PORT_TEST1], in qusb2_phy_runtime_suspend()
570 qusb2_clrbits(qphy->base, cfg->regs[QUSB2PHY_PORT_TEST1], in qusb2_phy_runtime_suspend()
574 if (!qphy->has_se_clk_scheme) in qusb2_phy_runtime_suspend()
575 clk_disable_unprepare(qphy->ref_clk); in qusb2_phy_runtime_suspend()
577 clk_disable_unprepare(qphy->cfg_ahb_clk); in qusb2_phy_runtime_suspend()
578 clk_disable_unprepare(qphy->iface_clk); in qusb2_phy_runtime_suspend()
585 struct qusb2_phy *qphy = dev_get_drvdata(dev); in qusb2_phy_runtime_resume() local
586 const struct qusb2_phy_cfg *cfg = qphy->cfg; in qusb2_phy_runtime_resume()
589 dev_vdbg(dev, "Resuming QUSB2 phy, mode:%d\n", qphy->mode); in qusb2_phy_runtime_resume()
591 if (!qphy->phy_initialized) { in qusb2_phy_runtime_resume()
596 ret = clk_prepare_enable(qphy->iface_clk); in qusb2_phy_runtime_resume()
602 ret = clk_prepare_enable(qphy->cfg_ahb_clk); in qusb2_phy_runtime_resume()
608 if (!qphy->has_se_clk_scheme) { in qusb2_phy_runtime_resume()
609 ret = clk_prepare_enable(qphy->ref_clk); in qusb2_phy_runtime_resume()
616 writel(0x0, qphy->base + cfg->regs[QUSB2PHY_INTR_CTRL]); in qusb2_phy_runtime_resume()
620 qusb2_clrbits(qphy->base, in qusb2_phy_runtime_resume()
628 clk_disable_unprepare(qphy->cfg_ahb_clk); in qusb2_phy_runtime_resume()
630 clk_disable_unprepare(qphy->iface_clk); in qusb2_phy_runtime_resume()
637 struct qusb2_phy *qphy = phy_get_drvdata(phy); in qusb2_phy_init() local
638 const struct qusb2_phy_cfg *cfg = qphy->cfg; in qusb2_phy_init()
646 ret = regulator_bulk_enable(ARRAY_SIZE(qphy->vregs), qphy->vregs); in qusb2_phy_init()
650 ret = clk_prepare_enable(qphy->iface_clk); in qusb2_phy_init()
657 ret = clk_prepare_enable(qphy->cfg_ahb_clk); in qusb2_phy_init()
664 ret = reset_control_assert(qphy->phy_reset); in qusb2_phy_init()
673 ret = reset_control_deassert(qphy->phy_reset); in qusb2_phy_init()
680 qusb2_setbits(qphy->base, cfg->regs[QUSB2PHY_PORT_POWERDOWN], in qusb2_phy_init()
681 qphy->cfg->disable_ctrl); in qusb2_phy_init()
685 val = readl(qphy->base + QUSB2PHY_PLL_TEST); in qusb2_phy_init()
688 qcom_qusb2_phy_configure(qphy->base, cfg->regs, cfg->tbl, in qusb2_phy_init()
692 qusb2_phy_override_phy_params(qphy); in qusb2_phy_init()
695 qusb2_phy_set_tune2_param(qphy); in qusb2_phy_init()
698 qusb2_clrbits(qphy->base, cfg->regs[QUSB2PHY_PORT_POWERDOWN], in qusb2_phy_init()
705 qphy->has_se_clk_scheme = true; in qusb2_phy_init()
712 if (qphy->tcsr) { in qusb2_phy_init()
713 ret = regmap_read(qphy->tcsr, qphy->cfg->clk_scheme_offset, in qusb2_phy_init()
724 qphy->has_se_clk_scheme = false; in qusb2_phy_init()
731 if (!qphy->has_se_clk_scheme) { in qusb2_phy_init()
732 ret = clk_prepare_enable(qphy->ref_clk); in qusb2_phy_init()
741 if (!qphy->has_se_clk_scheme) in qusb2_phy_init()
746 writel(val, qphy->base + QUSB2PHY_PLL_TEST); in qusb2_phy_init()
749 readl(qphy->base + QUSB2PHY_PLL_TEST); in qusb2_phy_init()
755 val = readb(qphy->base + cfg->regs[QUSB2PHY_PLL_STATUS]); in qusb2_phy_init()
762 qphy->phy_initialized = true; in qusb2_phy_init()
767 if (!qphy->has_se_clk_scheme) in qusb2_phy_init()
768 clk_disable_unprepare(qphy->ref_clk); in qusb2_phy_init()
770 reset_control_assert(qphy->phy_reset); in qusb2_phy_init()
772 clk_disable_unprepare(qphy->cfg_ahb_clk); in qusb2_phy_init()
774 clk_disable_unprepare(qphy->iface_clk); in qusb2_phy_init()
776 regulator_bulk_disable(ARRAY_SIZE(qphy->vregs), qphy->vregs); in qusb2_phy_init()
783 struct qusb2_phy *qphy = phy_get_drvdata(phy); in qusb2_phy_exit() local
786 qusb2_setbits(qphy->base, qphy->cfg->regs[QUSB2PHY_PORT_POWERDOWN], in qusb2_phy_exit()
787 qphy->cfg->disable_ctrl); in qusb2_phy_exit()
789 if (!qphy->has_se_clk_scheme) in qusb2_phy_exit()
790 clk_disable_unprepare(qphy->ref_clk); in qusb2_phy_exit()
792 reset_control_assert(qphy->phy_reset); in qusb2_phy_exit()
794 clk_disable_unprepare(qphy->cfg_ahb_clk); in qusb2_phy_exit()
795 clk_disable_unprepare(qphy->iface_clk); in qusb2_phy_exit()
797 regulator_bulk_disable(ARRAY_SIZE(qphy->vregs), qphy->vregs); in qusb2_phy_exit()
799 qphy->phy_initialized = false; in qusb2_phy_exit()
844 struct qusb2_phy *qphy; in qusb2_phy_probe() local
853 qphy = devm_kzalloc(dev, sizeof(*qphy), GFP_KERNEL); in qusb2_phy_probe()
854 if (!qphy) in qusb2_phy_probe()
856 or = &qphy->overrides; in qusb2_phy_probe()
859 qphy->base = devm_ioremap_resource(dev, res); in qusb2_phy_probe()
860 if (IS_ERR(qphy->base)) in qusb2_phy_probe()
861 return PTR_ERR(qphy->base); in qusb2_phy_probe()
863 qphy->cfg_ahb_clk = devm_clk_get(dev, "cfg_ahb"); in qusb2_phy_probe()
864 if (IS_ERR(qphy->cfg_ahb_clk)) { in qusb2_phy_probe()
865 ret = PTR_ERR(qphy->cfg_ahb_clk); in qusb2_phy_probe()
871 qphy->ref_clk = devm_clk_get(dev, "ref"); in qusb2_phy_probe()
872 if (IS_ERR(qphy->ref_clk)) { in qusb2_phy_probe()
873 ret = PTR_ERR(qphy->ref_clk); in qusb2_phy_probe()
879 qphy->iface_clk = devm_clk_get_optional(dev, "iface"); in qusb2_phy_probe()
880 if (IS_ERR(qphy->iface_clk)) in qusb2_phy_probe()
881 return PTR_ERR(qphy->iface_clk); in qusb2_phy_probe()
883 qphy->phy_reset = devm_reset_control_get_by_index(&pdev->dev, 0); in qusb2_phy_probe()
884 if (IS_ERR(qphy->phy_reset)) { in qusb2_phy_probe()
886 return PTR_ERR(qphy->phy_reset); in qusb2_phy_probe()
889 num = ARRAY_SIZE(qphy->vregs); in qusb2_phy_probe()
891 qphy->vregs[i].supply = qusb2_phy_vreg_names[i]; in qusb2_phy_probe()
893 ret = devm_regulator_bulk_get(dev, num, qphy->vregs); in qusb2_phy_probe()
902 qphy->cfg = of_device_get_match_data(dev); in qusb2_phy_probe()
904 qphy->tcsr = syscon_regmap_lookup_by_phandle(dev->of_node, in qusb2_phy_probe()
906 if (IS_ERR(qphy->tcsr)) { in qusb2_phy_probe()
908 qphy->tcsr = NULL; in qusb2_phy_probe()
911 qphy->cell = devm_nvmem_cell_get(dev, NULL); in qusb2_phy_probe()
912 if (IS_ERR(qphy->cell)) { in qusb2_phy_probe()
913 if (PTR_ERR(qphy->cell) == -EPROBE_DEFER) in qusb2_phy_probe()
915 qphy->cell = NULL; in qusb2_phy_probe()
976 qphy->phy = generic_phy; in qusb2_phy_probe()
978 dev_set_drvdata(dev, qphy); in qusb2_phy_probe()
979 phy_set_drvdata(generic_phy, qphy); in qusb2_phy_probe()