Lines Matching full:qmp

25 #include "phy-qcom-qmp.h"
26 #include "phy-qcom-qmp-pcs-misc-v3.h"
27 #include "phy-qcom-qmp-pcs-pcie-v4.h"
28 #include "phy-qcom-qmp-pcs-pcie-v4_20.h"
29 #include "phy-qcom-qmp-pcs-pcie-v5.h"
30 #include "phy-qcom-qmp-pcs-pcie-v5_20.h"
31 #include "phy-qcom-qmp-pcs-pcie-v6.h"
32 #include "phy-qcom-qmp-pcs-pcie-v6_20.h"
33 #include "phy-qcom-qmp-pcie-qhp.h"
2215 /* QMP PHY pipe clock interface rate */
3116 static void qmp_pcie_init_port_b(struct qmp_pcie *qmp, const struct qmp_phy_cfg_tbls *tbls) in qmp_pcie_init_port_b() argument
3118 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_pcie_init_port_b()
3122 tx3 = qmp->port_b + offs->tx; in qmp_pcie_init_port_b()
3123 rx3 = qmp->port_b + offs->rx; in qmp_pcie_init_port_b()
3124 tx4 = qmp->port_b + offs->tx2; in qmp_pcie_init_port_b()
3125 rx4 = qmp->port_b + offs->rx2; in qmp_pcie_init_port_b()
3134 static void qmp_pcie_init_registers(struct qmp_pcie *qmp, const struct qmp_phy_cfg_tbls *tbls) in qmp_pcie_init_registers() argument
3136 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_pcie_init_registers()
3137 void __iomem *serdes = qmp->serdes; in qmp_pcie_init_registers()
3138 void __iomem *tx = qmp->tx; in qmp_pcie_init_registers()
3139 void __iomem *rx = qmp->rx; in qmp_pcie_init_registers()
3140 void __iomem *tx2 = qmp->tx2; in qmp_pcie_init_registers()
3141 void __iomem *rx2 = qmp->rx2; in qmp_pcie_init_registers()
3142 void __iomem *pcs = qmp->pcs; in qmp_pcie_init_registers()
3143 void __iomem *pcs_misc = qmp->pcs_misc; in qmp_pcie_init_registers()
3144 void __iomem *ln_shrd = qmp->ln_shrd; in qmp_pcie_init_registers()
3162 if (cfg->lanes >= 4 && qmp->tcsr_4ln_config) { in qmp_pcie_init_registers()
3164 qmp_pcie_init_port_b(qmp, tbls); in qmp_pcie_init_registers()
3172 struct qmp_pcie *qmp = phy_get_drvdata(phy); in qmp_pcie_init() local
3173 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_pcie_init()
3176 ret = regulator_bulk_enable(cfg->num_vregs, qmp->vregs); in qmp_pcie_init()
3178 dev_err(qmp->dev, "failed to enable regulators, err=%d\n", ret); in qmp_pcie_init()
3182 ret = reset_control_bulk_assert(cfg->num_resets, qmp->resets); in qmp_pcie_init()
3184 dev_err(qmp->dev, "reset assert failed\n"); in qmp_pcie_init()
3188 ret = reset_control_assert(qmp->nocsr_reset); in qmp_pcie_init()
3190 dev_err(qmp->dev, "no-csr reset assert failed\n"); in qmp_pcie_init()
3196 ret = reset_control_bulk_deassert(cfg->num_resets, qmp->resets); in qmp_pcie_init()
3198 dev_err(qmp->dev, "reset deassert failed\n"); in qmp_pcie_init()
3202 ret = clk_bulk_prepare_enable(ARRAY_SIZE(qmp_pciephy_clk_l), qmp->clks); in qmp_pcie_init()
3209 reset_control_bulk_assert(cfg->num_resets, qmp->resets); in qmp_pcie_init()
3211 regulator_bulk_disable(cfg->num_vregs, qmp->vregs); in qmp_pcie_init()
3218 struct qmp_pcie *qmp = phy_get_drvdata(phy); in qmp_pcie_exit() local
3219 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_pcie_exit()
3221 reset_control_bulk_assert(cfg->num_resets, qmp->resets); in qmp_pcie_exit()
3223 clk_bulk_disable_unprepare(ARRAY_SIZE(qmp_pciephy_clk_l), qmp->clks); in qmp_pcie_exit()
3225 regulator_bulk_disable(cfg->num_vregs, qmp->vregs); in qmp_pcie_exit()
3232 struct qmp_pcie *qmp = phy_get_drvdata(phy); in qmp_pcie_power_on() local
3233 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_pcie_power_on()
3235 void __iomem *pcs = qmp->pcs; in qmp_pcie_power_on()
3243 if (qmp->mode == PHY_MODE_PCIE_RC) in qmp_pcie_power_on()
3248 qmp_pcie_init_registers(qmp, &cfg->tbls); in qmp_pcie_power_on()
3249 qmp_pcie_init_registers(qmp, mode_tbls); in qmp_pcie_power_on()
3251 ret = clk_bulk_prepare_enable(qmp->num_pipe_clks, qmp->pipe_clks); in qmp_pcie_power_on()
3255 ret = reset_control_deassert(qmp->nocsr_reset); in qmp_pcie_power_on()
3257 dev_err(qmp->dev, "no-csr reset deassert failed\n"); in qmp_pcie_power_on()
3275 dev_err(qmp->dev, "phy initialization timed-out\n"); in qmp_pcie_power_on()
3282 clk_bulk_disable_unprepare(qmp->num_pipe_clks, qmp->pipe_clks); in qmp_pcie_power_on()
3289 struct qmp_pcie *qmp = phy_get_drvdata(phy); in qmp_pcie_power_off() local
3290 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_pcie_power_off()
3292 clk_bulk_disable_unprepare(qmp->num_pipe_clks, qmp->pipe_clks); in qmp_pcie_power_off()
3295 qphy_setbits(qmp->pcs, cfg->regs[QPHY_SW_RESET], SW_RESET); in qmp_pcie_power_off()
3298 qphy_clrbits(qmp->pcs, cfg->regs[QPHY_START_CTRL], in qmp_pcie_power_off()
3302 qphy_clrbits(qmp->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL], in qmp_pcie_power_off()
3336 struct qmp_pcie *qmp = phy_get_drvdata(phy); in qmp_pcie_set_mode() local
3341 qmp->mode = submode; in qmp_pcie_set_mode()
3358 static int qmp_pcie_vreg_init(struct qmp_pcie *qmp) in qmp_pcie_vreg_init() argument
3360 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_pcie_vreg_init()
3361 struct device *dev = qmp->dev; in qmp_pcie_vreg_init()
3365 qmp->vregs = devm_kcalloc(dev, num, sizeof(*qmp->vregs), GFP_KERNEL); in qmp_pcie_vreg_init()
3366 if (!qmp->vregs) in qmp_pcie_vreg_init()
3370 qmp->vregs[i].supply = cfg->vreg_list[i]; in qmp_pcie_vreg_init()
3372 return devm_regulator_bulk_get(dev, num, qmp->vregs); in qmp_pcie_vreg_init()
3375 static int qmp_pcie_reset_init(struct qmp_pcie *qmp) in qmp_pcie_reset_init() argument
3377 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_pcie_reset_init()
3378 struct device *dev = qmp->dev; in qmp_pcie_reset_init()
3382 qmp->resets = devm_kcalloc(dev, cfg->num_resets, in qmp_pcie_reset_init()
3383 sizeof(*qmp->resets), GFP_KERNEL); in qmp_pcie_reset_init()
3384 if (!qmp->resets) in qmp_pcie_reset_init()
3388 qmp->resets[i].id = cfg->reset_list[i]; in qmp_pcie_reset_init()
3390 ret = devm_reset_control_bulk_get_exclusive(dev, cfg->num_resets, qmp->resets); in qmp_pcie_reset_init()
3395 qmp->nocsr_reset = devm_reset_control_get_exclusive(dev, "phy_nocsr"); in qmp_pcie_reset_init()
3396 if (IS_ERR(qmp->nocsr_reset)) in qmp_pcie_reset_init()
3397 return dev_err_probe(dev, PTR_ERR(qmp->nocsr_reset), in qmp_pcie_reset_init()
3404 static int qmp_pcie_clk_init(struct qmp_pcie *qmp) in qmp_pcie_clk_init() argument
3406 struct device *dev = qmp->dev; in qmp_pcie_clk_init()
3410 qmp->clks = devm_kcalloc(dev, num, sizeof(*qmp->clks), GFP_KERNEL); in qmp_pcie_clk_init()
3411 if (!qmp->clks) in qmp_pcie_clk_init()
3415 qmp->clks[i].id = qmp_pciephy_clk_l[i]; in qmp_pcie_clk_init()
3417 return devm_clk_bulk_get_optional(dev, num, qmp->clks); in qmp_pcie_clk_init()
3443 static int phy_pipe_clk_register(struct qmp_pcie *qmp, struct device_node *np) in phy_pipe_clk_register() argument
3445 struct clk_fixed_rate *fixed = &qmp->pipe_clk_fixed; in phy_pipe_clk_register()
3451 dev_err(qmp->dev, "%pOFn: No clock-output-names\n", np); in phy_pipe_clk_register()
3458 * Controllers using QMP PHY-s use 125MHz pipe clock interface in phy_pipe_clk_register()
3461 if (qmp->cfg->pipe_clock_rate) in phy_pipe_clk_register()
3462 fixed->fixed_rate = qmp->cfg->pipe_clock_rate; in phy_pipe_clk_register()
3468 ret = devm_clk_hw_register(qmp->dev, &fixed->hw); in phy_pipe_clk_register()
3480 return devm_add_action_or_reset(qmp->dev, phy_clk_release_provider, np); in phy_pipe_clk_register()
3483 static int qmp_pcie_parse_dt_legacy(struct qmp_pcie *qmp, struct device_node *np) in qmp_pcie_parse_dt_legacy() argument
3485 struct platform_device *pdev = to_platform_device(qmp->dev); in qmp_pcie_parse_dt_legacy()
3486 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_pcie_parse_dt_legacy()
3487 struct device *dev = qmp->dev; in qmp_pcie_parse_dt_legacy()
3490 qmp->serdes = devm_platform_ioremap_resource(pdev, 0); in qmp_pcie_parse_dt_legacy()
3491 if (IS_ERR(qmp->serdes)) in qmp_pcie_parse_dt_legacy()
3492 return PTR_ERR(qmp->serdes); in qmp_pcie_parse_dt_legacy()
3500 qmp->tx = devm_of_iomap(dev, np, 0, NULL); in qmp_pcie_parse_dt_legacy()
3501 if (IS_ERR(qmp->tx)) in qmp_pcie_parse_dt_legacy()
3502 return PTR_ERR(qmp->tx); in qmp_pcie_parse_dt_legacy()
3505 qmp->rx = qmp->tx; in qmp_pcie_parse_dt_legacy()
3507 qmp->rx = devm_of_iomap(dev, np, 1, NULL); in qmp_pcie_parse_dt_legacy()
3508 if (IS_ERR(qmp->rx)) in qmp_pcie_parse_dt_legacy()
3509 return PTR_ERR(qmp->rx); in qmp_pcie_parse_dt_legacy()
3511 qmp->pcs = devm_of_iomap(dev, np, 2, NULL); in qmp_pcie_parse_dt_legacy()
3512 if (IS_ERR(qmp->pcs)) in qmp_pcie_parse_dt_legacy()
3513 return PTR_ERR(qmp->pcs); in qmp_pcie_parse_dt_legacy()
3516 qmp->tx2 = devm_of_iomap(dev, np, 3, NULL); in qmp_pcie_parse_dt_legacy()
3517 if (IS_ERR(qmp->tx2)) in qmp_pcie_parse_dt_legacy()
3518 return PTR_ERR(qmp->tx2); in qmp_pcie_parse_dt_legacy()
3520 qmp->rx2 = devm_of_iomap(dev, np, 4, NULL); in qmp_pcie_parse_dt_legacy()
3521 if (IS_ERR(qmp->rx2)) in qmp_pcie_parse_dt_legacy()
3522 return PTR_ERR(qmp->rx2); in qmp_pcie_parse_dt_legacy()
3524 qmp->pcs_misc = devm_of_iomap(dev, np, 5, NULL); in qmp_pcie_parse_dt_legacy()
3526 qmp->pcs_misc = devm_of_iomap(dev, np, 3, NULL); in qmp_pcie_parse_dt_legacy()
3529 if (IS_ERR(qmp->pcs_misc) && in qmp_pcie_parse_dt_legacy()
3530 of_device_is_compatible(dev->of_node, "qcom,ipq6018-qmp-pcie-phy")) in qmp_pcie_parse_dt_legacy()
3531 qmp->pcs_misc = qmp->pcs + 0x400; in qmp_pcie_parse_dt_legacy()
3533 if (IS_ERR(qmp->pcs_misc)) { in qmp_pcie_parse_dt_legacy()
3537 return PTR_ERR(qmp->pcs_misc); in qmp_pcie_parse_dt_legacy()
3547 qmp->num_pipe_clks = 1; in qmp_pcie_parse_dt_legacy()
3548 qmp->pipe_clks[0].id = "pipe"; in qmp_pcie_parse_dt_legacy()
3549 qmp->pipe_clks[0].clk = clk; in qmp_pcie_parse_dt_legacy()
3554 static int qmp_pcie_get_4ln_config(struct qmp_pcie *qmp) in qmp_pcie_get_4ln_config() argument
3560 tcsr = syscon_regmap_lookup_by_phandle_args(qmp->dev->of_node, in qmp_pcie_get_4ln_config()
3568 dev_err(qmp->dev, "failed to lookup syscon: %d\n", ret); in qmp_pcie_get_4ln_config()
3574 dev_err(qmp->dev, "failed to read tcsr: %d\n", ret); in qmp_pcie_get_4ln_config()
3578 qmp->tcsr_4ln_config = ret; in qmp_pcie_get_4ln_config()
3580 dev_dbg(qmp->dev, "4ln_config_sel = %d\n", qmp->tcsr_4ln_config); in qmp_pcie_get_4ln_config()
3585 static int qmp_pcie_parse_dt(struct qmp_pcie *qmp) in qmp_pcie_parse_dt() argument
3587 struct platform_device *pdev = to_platform_device(qmp->dev); in qmp_pcie_parse_dt()
3588 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_pcie_parse_dt()
3590 struct device *dev = qmp->dev; in qmp_pcie_parse_dt()
3597 ret = qmp_pcie_get_4ln_config(qmp); in qmp_pcie_parse_dt()
3605 qmp->serdes = base + offs->serdes; in qmp_pcie_parse_dt()
3606 qmp->pcs = base + offs->pcs; in qmp_pcie_parse_dt()
3607 qmp->pcs_misc = base + offs->pcs_misc; in qmp_pcie_parse_dt()
3608 qmp->tx = base + offs->tx; in qmp_pcie_parse_dt()
3609 qmp->rx = base + offs->rx; in qmp_pcie_parse_dt()
3612 qmp->tx2 = base + offs->tx2; in qmp_pcie_parse_dt()
3613 qmp->rx2 = base + offs->rx2; in qmp_pcie_parse_dt()
3616 if (qmp->cfg->lanes >= 4 && qmp->tcsr_4ln_config) { in qmp_pcie_parse_dt()
3617 qmp->port_b = devm_platform_ioremap_resource(pdev, 1); in qmp_pcie_parse_dt()
3618 if (IS_ERR(qmp->port_b)) in qmp_pcie_parse_dt()
3619 return PTR_ERR(qmp->port_b); in qmp_pcie_parse_dt()
3623 qmp->ln_shrd = base + offs->ln_shrd; in qmp_pcie_parse_dt()
3625 qmp->num_pipe_clks = 2; in qmp_pcie_parse_dt()
3626 qmp->pipe_clks[0].id = "pipe"; in qmp_pcie_parse_dt()
3627 qmp->pipe_clks[1].id = "pipediv2"; in qmp_pcie_parse_dt()
3629 ret = devm_clk_bulk_get(dev, 1, qmp->pipe_clks); in qmp_pcie_parse_dt()
3633 ret = devm_clk_bulk_get_optional(dev, qmp->num_pipe_clks - 1, qmp->pipe_clks + 1); in qmp_pcie_parse_dt()
3645 struct qmp_pcie *qmp; in qmp_pcie_probe() local
3648 qmp = devm_kzalloc(dev, sizeof(*qmp), GFP_KERNEL); in qmp_pcie_probe()
3649 if (!qmp) in qmp_pcie_probe()
3652 qmp->dev = dev; in qmp_pcie_probe()
3654 qmp->cfg = of_device_get_match_data(dev); in qmp_pcie_probe()
3655 if (!qmp->cfg) in qmp_pcie_probe()
3658 WARN_ON_ONCE(!qmp->cfg->pwrdn_ctrl); in qmp_pcie_probe()
3659 WARN_ON_ONCE(!qmp->cfg->phy_status); in qmp_pcie_probe()
3661 ret = qmp_pcie_clk_init(qmp); in qmp_pcie_probe()
3665 ret = qmp_pcie_reset_init(qmp); in qmp_pcie_probe()
3669 ret = qmp_pcie_vreg_init(qmp); in qmp_pcie_probe()
3676 ret = qmp_pcie_parse_dt_legacy(qmp, np); in qmp_pcie_probe()
3679 ret = qmp_pcie_parse_dt(qmp); in qmp_pcie_probe()
3684 ret = phy_pipe_clk_register(qmp, np); in qmp_pcie_probe()
3688 qmp->mode = PHY_MODE_PCIE_RC; in qmp_pcie_probe()
3690 qmp->phy = devm_phy_create(dev, np, &qmp_pcie_phy_ops); in qmp_pcie_probe()
3691 if (IS_ERR(qmp->phy)) { in qmp_pcie_probe()
3692 ret = PTR_ERR(qmp->phy); in qmp_pcie_probe()
3697 phy_set_drvdata(qmp->phy, qmp); in qmp_pcie_probe()
3712 .compatible = "qcom,ipq6018-qmp-pcie-phy",
3715 .compatible = "qcom,ipq8074-qmp-gen3-pcie-phy",
3718 .compatible = "qcom,ipq8074-qmp-pcie-phy",
3721 .compatible = "qcom,msm8998-qmp-pcie-phy",
3724 .compatible = "qcom,sa8775p-qmp-gen4x2-pcie-phy",
3727 .compatible = "qcom,sa8775p-qmp-gen4x4-pcie-phy",
3730 .compatible = "qcom,sc8180x-qmp-pcie-phy",
3733 .compatible = "qcom,sc8280xp-qmp-gen3x1-pcie-phy",
3736 .compatible = "qcom,sc8280xp-qmp-gen3x2-pcie-phy",
3739 .compatible = "qcom,sc8280xp-qmp-gen3x4-pcie-phy",
3745 .compatible = "qcom,sdm845-qmp-pcie-phy",
3748 .compatible = "qcom,sdx55-qmp-pcie-phy",
3751 .compatible = "qcom,sdx65-qmp-gen4x2-pcie-phy",
3754 .compatible = "qcom,sm8150-qmp-gen3x1-pcie-phy",
3757 .compatible = "qcom,sm8150-qmp-gen3x2-pcie-phy",
3760 .compatible = "qcom,sm8250-qmp-gen3x1-pcie-phy",
3763 .compatible = "qcom,sm8250-qmp-gen3x2-pcie-phy",
3766 .compatible = "qcom,sm8250-qmp-modem-pcie-phy",
3769 .compatible = "qcom,sm8350-qmp-gen3x1-pcie-phy",
3772 .compatible = "qcom,sm8350-qmp-gen3x2-pcie-phy",
3775 .compatible = "qcom,sm8450-qmp-gen3x1-pcie-phy",
3778 .compatible = "qcom,sm8450-qmp-gen4x2-pcie-phy",
3781 .compatible = "qcom,sm8550-qmp-gen3x2-pcie-phy",
3784 .compatible = "qcom,sm8550-qmp-gen4x2-pcie-phy",
3794 .name = "qcom-qmp-pcie-phy",
3802 MODULE_DESCRIPTION("Qualcomm QMP PCIe PHY driver");