Commit 52b99773 authored by Johan Hovold's avatar Johan Hovold Committed by Vinod Koul

phy: qcom-qmp-pcie: clean up probe initialisation

Stop abusing the driver data pointer and instead pass the driver state
structure directly to the initialisation helpers during probe.
Reviewed-by: default avatarDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Signed-off-by: default avatarJohan Hovold <johan+linaro@kernel.org>
Link: https://lore.kernel.org/r/20221105145939.20318-6-johan+linaro@kernel.orgSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 393ed5d5
...@@ -2037,9 +2037,10 @@ static int qmp_pcie_set_mode(struct phy *phy, enum phy_mode mode, int submode) ...@@ -2037,9 +2037,10 @@ static int qmp_pcie_set_mode(struct phy *phy, enum phy_mode mode, int submode)
return 0; return 0;
} }
static int qmp_pcie_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg) static int qmp_pcie_vreg_init(struct qmp_pcie *qmp)
{ {
struct qmp_pcie *qmp = dev_get_drvdata(dev); const struct qmp_phy_cfg *cfg = qmp->cfg;
struct device *dev = qmp->dev;
int num = cfg->num_vregs; int num = cfg->num_vregs;
int i; int i;
...@@ -2053,9 +2054,10 @@ static int qmp_pcie_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg) ...@@ -2053,9 +2054,10 @@ static int qmp_pcie_vreg_init(struct device *dev, const struct qmp_phy_cfg *cfg)
return devm_regulator_bulk_get(dev, num, qmp->vregs); return devm_regulator_bulk_get(dev, num, qmp->vregs);
} }
static int qmp_pcie_reset_init(struct device *dev, const struct qmp_phy_cfg *cfg) static int qmp_pcie_reset_init(struct qmp_pcie *qmp)
{ {
struct qmp_pcie *qmp = dev_get_drvdata(dev); const struct qmp_phy_cfg *cfg = qmp->cfg;
struct device *dev = qmp->dev;
int i; int i;
int ret; int ret;
...@@ -2074,9 +2076,10 @@ static int qmp_pcie_reset_init(struct device *dev, const struct qmp_phy_cfg *cfg ...@@ -2074,9 +2076,10 @@ static int qmp_pcie_reset_init(struct device *dev, const struct qmp_phy_cfg *cfg
return 0; return 0;
} }
static int qmp_pcie_clk_init(struct device *dev, const struct qmp_phy_cfg *cfg) static int qmp_pcie_clk_init(struct qmp_pcie *qmp)
{ {
struct qmp_pcie *qmp = dev_get_drvdata(dev); const struct qmp_phy_cfg *cfg = qmp->cfg;
struct device *dev = qmp->dev;
int num = cfg->num_clks; int num = cfg->num_clks;
int i; int i;
...@@ -2164,18 +2167,15 @@ static const struct phy_ops qmp_pcie_ops = { ...@@ -2164,18 +2167,15 @@ static const struct phy_ops qmp_pcie_ops = {
.owner = THIS_MODULE, .owner = THIS_MODULE,
}; };
static int qmp_pcie_create(struct device *dev, struct device_node *np, static int qmp_pcie_create(struct qmp_pcie *qmp, struct device_node *np)
void __iomem *serdes, const struct qmp_phy_cfg *cfg)
{ {
struct qmp_pcie *qmp = dev_get_drvdata(dev); const struct qmp_phy_cfg *cfg = qmp->cfg;
struct device *dev = qmp->dev;
struct phy *generic_phy; struct phy *generic_phy;
int ret; int ret;
qmp->mode = PHY_MODE_PCIE_RC; qmp->mode = PHY_MODE_PCIE_RC;
qmp->cfg = cfg;
qmp->serdes = serdes;
/* /*
* Get memory resources for the PHY: * Get memory resources for the PHY:
* Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2. * Resources are indexed as: tx -> 0; rx -> 1; pcs -> 2.
...@@ -2247,8 +2247,6 @@ static int qmp_pcie_probe(struct platform_device *pdev) ...@@ -2247,8 +2247,6 @@ static int qmp_pcie_probe(struct platform_device *pdev)
struct device *dev = &pdev->dev; struct device *dev = &pdev->dev;
struct device_node *child; struct device_node *child;
struct phy_provider *phy_provider; struct phy_provider *phy_provider;
void __iomem *serdes;
const struct qmp_phy_cfg *cfg = NULL;
struct qmp_pcie *qmp; struct qmp_pcie *qmp;
int ret; int ret;
...@@ -2257,28 +2255,27 @@ static int qmp_pcie_probe(struct platform_device *pdev) ...@@ -2257,28 +2255,27 @@ static int qmp_pcie_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
qmp->dev = dev; qmp->dev = dev;
dev_set_drvdata(dev, qmp);
cfg = of_device_get_match_data(dev); qmp->cfg = of_device_get_match_data(dev);
if (!cfg) if (!qmp->cfg)
return -EINVAL; return -EINVAL;
WARN_ON_ONCE(!cfg->pwrdn_ctrl); WARN_ON_ONCE(!qmp->cfg->pwrdn_ctrl);
WARN_ON_ONCE(!cfg->phy_status); WARN_ON_ONCE(!qmp->cfg->phy_status);
serdes = devm_platform_ioremap_resource(pdev, 0); qmp->serdes = devm_platform_ioremap_resource(pdev, 0);
if (IS_ERR(serdes)) if (IS_ERR(qmp->serdes))
return PTR_ERR(serdes); return PTR_ERR(qmp->serdes);
ret = qmp_pcie_clk_init(dev, cfg); ret = qmp_pcie_clk_init(qmp);
if (ret) if (ret)
return ret; return ret;
ret = qmp_pcie_reset_init(dev, cfg); ret = qmp_pcie_reset_init(qmp);
if (ret) if (ret)
return ret; return ret;
ret = qmp_pcie_vreg_init(dev, cfg); ret = qmp_pcie_vreg_init(qmp);
if (ret) if (ret)
return ret; return ret;
...@@ -2286,7 +2283,7 @@ static int qmp_pcie_probe(struct platform_device *pdev) ...@@ -2286,7 +2283,7 @@ static int qmp_pcie_probe(struct platform_device *pdev)
if (!child) if (!child)
return -EINVAL; return -EINVAL;
ret = qmp_pcie_create(dev, child, serdes, cfg); ret = qmp_pcie_create(qmp, child);
if (ret) if (ret)
goto err_node_put; goto err_node_put;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment