Lines Matching full:qmp

23 #include "phy-qcom-qmp.h"
24 #include "phy-qcom-qmp-pcs-misc-v3.h"
25 #include "phy-qcom-qmp-pcs-usb-v4.h"
26 #include "phy-qcom-qmp-pcs-usb-v5.h"
758 static int qmp_usb_legacy_serdes_init(struct qmp_usb *qmp) in qmp_usb_legacy_serdes_init() argument
760 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_legacy_serdes_init()
761 void __iomem *serdes = qmp->serdes; in qmp_usb_legacy_serdes_init()
772 struct qmp_usb *qmp = phy_get_drvdata(phy); in qmp_usb_legacy_init_dp_com() local
773 void __iomem *dp_com = qmp->dp_com; in qmp_usb_legacy_init_dp_com()
777 /* override hardware control for reset of qmp phy */ in qmp_usb_legacy_init_dp_com()
788 /* bring both QMP USB and QMP DP PHYs PCS block out of reset */ in qmp_usb_legacy_init_dp_com()
799 struct qmp_usb *qmp = phy_get_drvdata(phy); in qmp_usb_legacy_init() local
800 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_legacy_init()
801 void __iomem *pcs = qmp->pcs; in qmp_usb_legacy_init()
804 ret = regulator_bulk_enable(cfg->num_vregs, qmp->vregs); in qmp_usb_legacy_init()
806 dev_err(qmp->dev, "failed to enable regulators, err=%d\n", ret); in qmp_usb_legacy_init()
810 ret = reset_control_bulk_assert(cfg->num_resets, qmp->resets); in qmp_usb_legacy_init()
812 dev_err(qmp->dev, "reset assert failed\n"); in qmp_usb_legacy_init()
816 ret = reset_control_bulk_deassert(cfg->num_resets, qmp->resets); in qmp_usb_legacy_init()
818 dev_err(qmp->dev, "reset deassert failed\n"); in qmp_usb_legacy_init()
822 ret = clk_bulk_prepare_enable(cfg->num_clks, qmp->clks); in qmp_usb_legacy_init()
833 reset_control_bulk_assert(cfg->num_resets, qmp->resets); in qmp_usb_legacy_init()
835 regulator_bulk_disable(cfg->num_vregs, qmp->vregs); in qmp_usb_legacy_init()
842 struct qmp_usb *qmp = phy_get_drvdata(phy); in qmp_usb_legacy_exit() local
843 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_legacy_exit()
845 reset_control_bulk_assert(cfg->num_resets, qmp->resets); in qmp_usb_legacy_exit()
847 clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks); in qmp_usb_legacy_exit()
849 regulator_bulk_disable(cfg->num_vregs, qmp->vregs); in qmp_usb_legacy_exit()
856 struct qmp_usb *qmp = phy_get_drvdata(phy); in qmp_usb_legacy_power_on() local
857 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_legacy_power_on()
858 void __iomem *tx = qmp->tx; in qmp_usb_legacy_power_on()
859 void __iomem *rx = qmp->rx; in qmp_usb_legacy_power_on()
860 void __iomem *pcs = qmp->pcs; in qmp_usb_legacy_power_on()
865 qmp_usb_legacy_serdes_init(qmp); in qmp_usb_legacy_power_on()
867 ret = clk_prepare_enable(qmp->pipe_clk); in qmp_usb_legacy_power_on()
869 dev_err(qmp->dev, "pipe_clk enable failed err=%d\n", ret); in qmp_usb_legacy_power_on()
878 qmp_usb_legacy_configure_lane(qmp->tx2, cfg->tx_tbl, cfg->tx_tbl_num, 2); in qmp_usb_legacy_power_on()
879 qmp_usb_legacy_configure_lane(qmp->rx2, cfg->rx_tbl, cfg->rx_tbl_num, 2); in qmp_usb_legacy_power_on()
896 dev_err(qmp->dev, "phy initialization timed-out\n"); in qmp_usb_legacy_power_on()
903 clk_disable_unprepare(qmp->pipe_clk); in qmp_usb_legacy_power_on()
910 struct qmp_usb *qmp = phy_get_drvdata(phy); in qmp_usb_legacy_power_off() local
911 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_legacy_power_off()
913 clk_disable_unprepare(qmp->pipe_clk); in qmp_usb_legacy_power_off()
916 qphy_setbits(qmp->pcs, cfg->regs[QPHY_SW_RESET], SW_RESET); in qmp_usb_legacy_power_off()
919 qphy_clrbits(qmp->pcs, cfg->regs[QPHY_START_CTRL], in qmp_usb_legacy_power_off()
923 qphy_clrbits(qmp->pcs, cfg->regs[QPHY_PCS_POWER_DOWN_CONTROL], in qmp_usb_legacy_power_off()
956 struct qmp_usb *qmp = phy_get_drvdata(phy); in qmp_usb_legacy_set_mode() local
958 qmp->mode = mode; in qmp_usb_legacy_set_mode()
970 static void qmp_usb_legacy_enable_autonomous_mode(struct qmp_usb *qmp) in qmp_usb_legacy_enable_autonomous_mode() argument
972 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_legacy_enable_autonomous_mode()
973 void __iomem *pcs_usb = qmp->pcs_usb ?: qmp->pcs; in qmp_usb_legacy_enable_autonomous_mode()
974 void __iomem *pcs_misc = qmp->pcs_misc; in qmp_usb_legacy_enable_autonomous_mode()
977 if (qmp->mode == PHY_MODE_USB_HOST_SS || in qmp_usb_legacy_enable_autonomous_mode()
978 qmp->mode == PHY_MODE_USB_DEVICE_SS) in qmp_usb_legacy_enable_autonomous_mode()
999 static void qmp_usb_legacy_disable_autonomous_mode(struct qmp_usb *qmp) in qmp_usb_legacy_disable_autonomous_mode() argument
1001 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_legacy_disable_autonomous_mode()
1002 void __iomem *pcs_usb = qmp->pcs_usb ?: qmp->pcs; in qmp_usb_legacy_disable_autonomous_mode()
1003 void __iomem *pcs_misc = qmp->pcs_misc; in qmp_usb_legacy_disable_autonomous_mode()
1019 struct qmp_usb *qmp = dev_get_drvdata(dev); in qmp_usb_legacy_runtime_suspend() local
1020 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_legacy_runtime_suspend()
1022 dev_vdbg(dev, "Suspending QMP phy, mode:%d\n", qmp->mode); in qmp_usb_legacy_runtime_suspend()
1024 if (!qmp->phy->init_count) { in qmp_usb_legacy_runtime_suspend()
1029 qmp_usb_legacy_enable_autonomous_mode(qmp); in qmp_usb_legacy_runtime_suspend()
1031 clk_disable_unprepare(qmp->pipe_clk); in qmp_usb_legacy_runtime_suspend()
1032 clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks); in qmp_usb_legacy_runtime_suspend()
1039 struct qmp_usb *qmp = dev_get_drvdata(dev); in qmp_usb_legacy_runtime_resume() local
1040 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_legacy_runtime_resume()
1043 dev_vdbg(dev, "Resuming QMP phy, mode:%d\n", qmp->mode); in qmp_usb_legacy_runtime_resume()
1045 if (!qmp->phy->init_count) { in qmp_usb_legacy_runtime_resume()
1050 ret = clk_bulk_prepare_enable(cfg->num_clks, qmp->clks); in qmp_usb_legacy_runtime_resume()
1054 ret = clk_prepare_enable(qmp->pipe_clk); in qmp_usb_legacy_runtime_resume()
1057 clk_bulk_disable_unprepare(cfg->num_clks, qmp->clks); in qmp_usb_legacy_runtime_resume()
1061 qmp_usb_legacy_disable_autonomous_mode(qmp); in qmp_usb_legacy_runtime_resume()
1071 static int qmp_usb_legacy_vreg_init(struct qmp_usb *qmp) in qmp_usb_legacy_vreg_init() argument
1073 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_legacy_vreg_init()
1074 struct device *dev = qmp->dev; in qmp_usb_legacy_vreg_init()
1078 qmp->vregs = devm_kcalloc(dev, num, sizeof(*qmp->vregs), GFP_KERNEL); in qmp_usb_legacy_vreg_init()
1079 if (!qmp->vregs) in qmp_usb_legacy_vreg_init()
1083 qmp->vregs[i].supply = cfg->vreg_list[i]; in qmp_usb_legacy_vreg_init()
1085 return devm_regulator_bulk_get(dev, num, qmp->vregs); in qmp_usb_legacy_vreg_init()
1088 static int qmp_usb_legacy_reset_init(struct qmp_usb *qmp) in qmp_usb_legacy_reset_init() argument
1090 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_legacy_reset_init()
1091 struct device *dev = qmp->dev; in qmp_usb_legacy_reset_init()
1095 qmp->resets = devm_kcalloc(dev, cfg->num_resets, in qmp_usb_legacy_reset_init()
1096 sizeof(*qmp->resets), GFP_KERNEL); in qmp_usb_legacy_reset_init()
1097 if (!qmp->resets) in qmp_usb_legacy_reset_init()
1101 qmp->resets[i].id = cfg->reset_list[i]; in qmp_usb_legacy_reset_init()
1103 ret = devm_reset_control_bulk_get_exclusive(dev, cfg->num_resets, qmp->resets); in qmp_usb_legacy_reset_init()
1110 static int qmp_usb_legacy_clk_init(struct qmp_usb *qmp) in qmp_usb_legacy_clk_init() argument
1112 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_legacy_clk_init()
1113 struct device *dev = qmp->dev; in qmp_usb_legacy_clk_init()
1117 qmp->clks = devm_kcalloc(dev, num, sizeof(*qmp->clks), GFP_KERNEL); in qmp_usb_legacy_clk_init()
1118 if (!qmp->clks) in qmp_usb_legacy_clk_init()
1122 qmp->clks[i].id = cfg->clk_list[i]; in qmp_usb_legacy_clk_init()
1124 return devm_clk_bulk_get(dev, num, qmp->clks); in qmp_usb_legacy_clk_init()
1150 static int phy_pipe_clk_register(struct qmp_usb *qmp, struct device_node *np) in phy_pipe_clk_register() argument
1152 struct clk_fixed_rate *fixed = &qmp->pipe_clk_fixed; in phy_pipe_clk_register()
1158 dev_err(qmp->dev, "%pOFn: No clock-output-names\n", np); in phy_pipe_clk_register()
1164 /* controllers using QMP phys use 125MHz pipe clock interface */ in phy_pipe_clk_register()
1168 ret = devm_clk_hw_register(qmp->dev, &fixed->hw); in phy_pipe_clk_register()
1180 return devm_add_action_or_reset(qmp->dev, phy_clk_release_provider, np); in phy_pipe_clk_register()
1198 static int qmp_usb_legacy_parse_dt_legacy(struct qmp_usb *qmp, struct device_node *np) in qmp_usb_legacy_parse_dt_legacy() argument
1200 struct platform_device *pdev = to_platform_device(qmp->dev); in qmp_usb_legacy_parse_dt_legacy()
1201 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_legacy_parse_dt_legacy()
1202 struct device *dev = qmp->dev; in qmp_usb_legacy_parse_dt_legacy()
1205 qmp->serdes = devm_platform_ioremap_resource(pdev, 0); in qmp_usb_legacy_parse_dt_legacy()
1206 if (IS_ERR(qmp->serdes)) in qmp_usb_legacy_parse_dt_legacy()
1207 return PTR_ERR(qmp->serdes); in qmp_usb_legacy_parse_dt_legacy()
1209 qmp->dp_com = devm_platform_ioremap_resource(pdev, 1); in qmp_usb_legacy_parse_dt_legacy()
1210 if (IS_ERR(qmp->dp_com)) in qmp_usb_legacy_parse_dt_legacy()
1211 return PTR_ERR(qmp->dp_com); in qmp_usb_legacy_parse_dt_legacy()
1219 qmp->tx = devm_of_iomap(dev, np, 0, NULL); in qmp_usb_legacy_parse_dt_legacy()
1220 if (IS_ERR(qmp->tx)) in qmp_usb_legacy_parse_dt_legacy()
1221 return PTR_ERR(qmp->tx); in qmp_usb_legacy_parse_dt_legacy()
1223 qmp->rx = devm_of_iomap(dev, np, 1, NULL); in qmp_usb_legacy_parse_dt_legacy()
1224 if (IS_ERR(qmp->rx)) in qmp_usb_legacy_parse_dt_legacy()
1225 return PTR_ERR(qmp->rx); in qmp_usb_legacy_parse_dt_legacy()
1227 qmp->pcs = qmp_usb_legacy_iomap(dev, np, 2, exclusive); in qmp_usb_legacy_parse_dt_legacy()
1228 if (IS_ERR(qmp->pcs)) in qmp_usb_legacy_parse_dt_legacy()
1229 return PTR_ERR(qmp->pcs); in qmp_usb_legacy_parse_dt_legacy()
1232 qmp->pcs_usb = qmp->pcs + cfg->pcs_usb_offset; in qmp_usb_legacy_parse_dt_legacy()
1235 qmp->tx2 = devm_of_iomap(dev, np, 3, NULL); in qmp_usb_legacy_parse_dt_legacy()
1236 if (IS_ERR(qmp->tx2)) in qmp_usb_legacy_parse_dt_legacy()
1237 return PTR_ERR(qmp->tx2); in qmp_usb_legacy_parse_dt_legacy()
1239 qmp->rx2 = devm_of_iomap(dev, np, 4, NULL); in qmp_usb_legacy_parse_dt_legacy()
1240 if (IS_ERR(qmp->rx2)) in qmp_usb_legacy_parse_dt_legacy()
1241 return PTR_ERR(qmp->rx2); in qmp_usb_legacy_parse_dt_legacy()
1243 qmp->pcs_misc = devm_of_iomap(dev, np, 5, NULL); in qmp_usb_legacy_parse_dt_legacy()
1245 qmp->pcs_misc = devm_of_iomap(dev, np, 3, NULL); in qmp_usb_legacy_parse_dt_legacy()
1248 if (IS_ERR(qmp->pcs_misc)) { in qmp_usb_legacy_parse_dt_legacy()
1250 qmp->pcs_misc = NULL; in qmp_usb_legacy_parse_dt_legacy()
1253 qmp->pipe_clk = devm_get_clk_from_child(dev, np, NULL); in qmp_usb_legacy_parse_dt_legacy()
1254 if (IS_ERR(qmp->pipe_clk)) { in qmp_usb_legacy_parse_dt_legacy()
1255 return dev_err_probe(dev, PTR_ERR(qmp->pipe_clk), in qmp_usb_legacy_parse_dt_legacy()
1262 static int qmp_usb_legacy_parse_dt(struct qmp_usb *qmp) in qmp_usb_legacy_parse_dt() argument
1264 struct platform_device *pdev = to_platform_device(qmp->dev); in qmp_usb_legacy_parse_dt()
1265 const struct qmp_phy_cfg *cfg = qmp->cfg; in qmp_usb_legacy_parse_dt()
1267 struct device *dev = qmp->dev; in qmp_usb_legacy_parse_dt()
1277 qmp->serdes = base + offs->serdes; in qmp_usb_legacy_parse_dt()
1278 qmp->pcs = base + offs->pcs; in qmp_usb_legacy_parse_dt()
1279 qmp->pcs_usb = base + offs->pcs_usb; in qmp_usb_legacy_parse_dt()
1280 qmp->tx = base + offs->tx; in qmp_usb_legacy_parse_dt()
1281 qmp->rx = base + offs->rx; in qmp_usb_legacy_parse_dt()
1283 qmp->pipe_clk = devm_clk_get(dev, "pipe"); in qmp_usb_legacy_parse_dt()
1284 if (IS_ERR(qmp->pipe_clk)) { in qmp_usb_legacy_parse_dt()
1285 return dev_err_probe(dev, PTR_ERR(qmp->pipe_clk), in qmp_usb_legacy_parse_dt()
1297 struct qmp_usb *qmp; in qmp_usb_legacy_probe() local
1300 qmp = devm_kzalloc(dev, sizeof(*qmp), GFP_KERNEL); in qmp_usb_legacy_probe()
1301 if (!qmp) in qmp_usb_legacy_probe()
1304 qmp->dev = dev; in qmp_usb_legacy_probe()
1306 qmp->cfg = of_device_get_match_data(dev); in qmp_usb_legacy_probe()
1307 if (!qmp->cfg) in qmp_usb_legacy_probe()
1310 ret = qmp_usb_legacy_clk_init(qmp); in qmp_usb_legacy_probe()
1314 ret = qmp_usb_legacy_reset_init(qmp); in qmp_usb_legacy_probe()
1318 ret = qmp_usb_legacy_vreg_init(qmp); in qmp_usb_legacy_probe()
1325 ret = qmp_usb_legacy_parse_dt_legacy(qmp, np); in qmp_usb_legacy_probe()
1328 ret = qmp_usb_legacy_parse_dt(qmp); in qmp_usb_legacy_probe()
1343 ret = phy_pipe_clk_register(qmp, np); in qmp_usb_legacy_probe()
1347 qmp->phy = devm_phy_create(dev, np, &qmp_usb_legacy_phy_ops); in qmp_usb_legacy_probe()
1348 if (IS_ERR(qmp->phy)) { in qmp_usb_legacy_probe()
1349 ret = PTR_ERR(qmp->phy); in qmp_usb_legacy_probe()
1354 phy_set_drvdata(qmp->phy, qmp); in qmp_usb_legacy_probe()
1369 .compatible = "qcom,sc7180-qmp-usb3-phy",
1372 .compatible = "qcom,sc8180x-qmp-usb3-phy",
1375 .compatible = "qcom,sdm845-qmp-usb3-phy",
1378 .compatible = "qcom,sm8150-qmp-usb3-phy",
1381 .compatible = "qcom,sm8250-qmp-usb3-phy",
1384 .compatible = "qcom,sm8350-qmp-usb3-phy",
1387 .compatible = "qcom,sm8450-qmp-usb3-phy",
1397 .name = "qcom-qmp-usb-legacy-phy",
1406 MODULE_DESCRIPTION("Qualcomm QMP legacy USB+DP PHY driver");