phy: qcom-qmp-combo: restructure PHY creation
In preparation for supporting devicetree bindings which do not use child nodes, move the PHY creation to probe() proper and parse the serdes, dp_com and dp_serdes resources in a dedicated legacy devicetree helper. Reviewed-by: Dmitry Baryshkov <dmitry.baryshkov@linaro.org> Signed-off-by: Johan Hovold <johan+linaro@kernel.org> Link: https://lore.kernel.org/r/20221121085058.31213-5-johan+linaro@kernel.org Signed-off-by: Vinod Koul <vkoul@kernel.org>
This commit is contained in:
parent
774903ca6c
commit
b3982f2144
@ -2471,11 +2471,9 @@ static int phy_dp_clks_register(struct qmp_combo *qmp, struct device_node *np)
|
||||
return devm_add_action_or_reset(qmp->dev, phy_clk_release_provider, np);
|
||||
}
|
||||
|
||||
static int qmp_combo_create_dp(struct qmp_combo *qmp, struct device_node *np)
|
||||
static int qmp_combo_parse_dt_lecacy_dp(struct qmp_combo *qmp, struct device_node *np)
|
||||
{
|
||||
struct device *dev = qmp->dev;
|
||||
struct phy *generic_phy;
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* Get memory resources from the DP child node:
|
||||
@ -2496,25 +2494,13 @@ static int qmp_combo_create_dp(struct qmp_combo *qmp, struct device_node *np)
|
||||
if (IS_ERR(qmp->dp_tx2))
|
||||
return PTR_ERR(qmp->dp_tx2);
|
||||
|
||||
generic_phy = devm_phy_create(dev, np, &qmp_combo_dp_phy_ops);
|
||||
if (IS_ERR(generic_phy)) {
|
||||
ret = PTR_ERR(generic_phy);
|
||||
dev_err(dev, "failed to create DP PHY: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
qmp->dp_phy = generic_phy;
|
||||
phy_set_drvdata(generic_phy, qmp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int qmp_combo_create_usb(struct qmp_combo *qmp, struct device_node *np)
|
||||
static int qmp_combo_parse_dt_lecacy_usb(struct qmp_combo *qmp, struct device_node *np)
|
||||
{
|
||||
const struct qmp_phy_cfg *cfg = qmp->cfg;
|
||||
struct device *dev = qmp->dev;
|
||||
struct phy *generic_phy;
|
||||
int ret;
|
||||
|
||||
/*
|
||||
* Get memory resources from the USB child node:
|
||||
@ -2556,15 +2542,34 @@ static int qmp_combo_create_usb(struct qmp_combo *qmp, struct device_node *np)
|
||||
"failed to get pipe clock\n");
|
||||
}
|
||||
|
||||
generic_phy = devm_phy_create(dev, np, &qmp_combo_usb_phy_ops);
|
||||
if (IS_ERR(generic_phy)) {
|
||||
ret = PTR_ERR(generic_phy);
|
||||
dev_err(dev, "failed to create USB PHY: %d\n", ret);
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
qmp->usb_phy = generic_phy;
|
||||
phy_set_drvdata(generic_phy, qmp);
|
||||
static int qmp_combo_parse_dt_legacy(struct qmp_combo *qmp, struct device_node *usb_np,
|
||||
struct device_node *dp_np)
|
||||
{
|
||||
struct platform_device *pdev = to_platform_device(qmp->dev);
|
||||
int ret;
|
||||
|
||||
qmp->serdes = devm_platform_ioremap_resource(pdev, 0);
|
||||
if (IS_ERR(qmp->serdes))
|
||||
return PTR_ERR(qmp->serdes);
|
||||
|
||||
qmp->dp_com = devm_platform_ioremap_resource(pdev, 1);
|
||||
if (IS_ERR(qmp->dp_com))
|
||||
return PTR_ERR(qmp->dp_com);
|
||||
|
||||
qmp->dp_serdes = devm_platform_ioremap_resource(pdev, 2);
|
||||
if (IS_ERR(qmp->dp_serdes))
|
||||
return PTR_ERR(qmp->dp_serdes);
|
||||
|
||||
ret = qmp_combo_parse_dt_lecacy_usb(qmp, usb_np);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
ret = qmp_combo_parse_dt_lecacy_dp(qmp, dp_np);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@ -2587,18 +2592,6 @@ static int qmp_combo_probe(struct platform_device *pdev)
|
||||
if (!qmp->cfg)
|
||||
return -EINVAL;
|
||||
|
||||
qmp->serdes = devm_platform_ioremap_resource(pdev, 0);
|
||||
if (IS_ERR(qmp->serdes))
|
||||
return PTR_ERR(qmp->serdes);
|
||||
|
||||
qmp->dp_com = devm_platform_ioremap_resource(pdev, 1);
|
||||
if (IS_ERR(qmp->dp_com))
|
||||
return PTR_ERR(qmp->dp_com);
|
||||
|
||||
qmp->dp_serdes = devm_platform_ioremap_resource(pdev, 2);
|
||||
if (IS_ERR(qmp->dp_serdes))
|
||||
return PTR_ERR(qmp->dp_serdes);
|
||||
|
||||
mutex_init(&qmp->phy_mutex);
|
||||
|
||||
ret = qmp_combo_clk_init(qmp);
|
||||
@ -2623,6 +2616,10 @@ static int qmp_combo_probe(struct platform_device *pdev)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
ret = qmp_combo_parse_dt_legacy(qmp, usb_np, dp_np);
|
||||
if (ret)
|
||||
goto err_node_put;
|
||||
|
||||
pm_runtime_set_active(dev);
|
||||
ret = devm_pm_runtime_enable(dev);
|
||||
if (ret)
|
||||
@ -2633,22 +2630,32 @@ static int qmp_combo_probe(struct platform_device *pdev)
|
||||
*/
|
||||
pm_runtime_forbid(dev);
|
||||
|
||||
ret = qmp_combo_create_usb(qmp, usb_np);
|
||||
if (ret)
|
||||
goto err_node_put;
|
||||
|
||||
ret = phy_pipe_clk_register(qmp, usb_np);
|
||||
if (ret)
|
||||
goto err_node_put;
|
||||
|
||||
ret = qmp_combo_create_dp(qmp, dp_np);
|
||||
if (ret)
|
||||
goto err_node_put;
|
||||
|
||||
ret = phy_dp_clks_register(qmp, dp_np);
|
||||
if (ret)
|
||||
goto err_node_put;
|
||||
|
||||
qmp->usb_phy = devm_phy_create(dev, usb_np, &qmp_combo_usb_phy_ops);
|
||||
if (IS_ERR(qmp->usb_phy)) {
|
||||
ret = PTR_ERR(qmp->usb_phy);
|
||||
dev_err(dev, "failed to create USB PHY: %d\n", ret);
|
||||
goto err_node_put;
|
||||
}
|
||||
|
||||
phy_set_drvdata(qmp->usb_phy, qmp);
|
||||
|
||||
qmp->dp_phy = devm_phy_create(dev, dp_np, &qmp_combo_dp_phy_ops);
|
||||
if (IS_ERR(qmp->dp_phy)) {
|
||||
ret = PTR_ERR(qmp->dp_phy);
|
||||
dev_err(dev, "failed to create DP PHY: %d\n", ret);
|
||||
goto err_node_put;
|
||||
}
|
||||
|
||||
phy_set_drvdata(qmp->dp_phy, qmp);
|
||||
|
||||
phy_provider = devm_of_phy_provider_register(dev, of_phy_simple_xlate);
|
||||
|
||||
of_node_put(usb_np);
|
||||
|
Loading…
x
Reference in New Issue
Block a user