PCI: dra7xx: Group PHY API invocations
No functional change. PHY APIs like phy_init()/phy_power_on() are invoked from multiple places. Group all the PHY APIs in dra7xx_pcie_enable_phy() and dra7xx_pcie_disable_phy() and use these functions for enabling or disabling the PHY. Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com> Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
This commit is contained in:
Родитель
ebe85a44aa
Коммит
1f6c4501c6
|
@ -324,6 +324,45 @@ static int __init dra7xx_add_pcie_port(struct dra7xx_pcie *dra7xx,
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void dra7xx_pcie_disable_phy(struct dra7xx_pcie *dra7xx)
|
||||||
|
{
|
||||||
|
int phy_count = dra7xx->phy_count;
|
||||||
|
|
||||||
|
while (phy_count--) {
|
||||||
|
phy_power_off(dra7xx->phy[phy_count]);
|
||||||
|
phy_exit(dra7xx->phy[phy_count]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static int dra7xx_pcie_enable_phy(struct dra7xx_pcie *dra7xx)
|
||||||
|
{
|
||||||
|
int phy_count = dra7xx->phy_count;
|
||||||
|
int ret;
|
||||||
|
int i;
|
||||||
|
|
||||||
|
for (i = 0; i < phy_count; i++) {
|
||||||
|
ret = phy_init(dra7xx->phy[i]);
|
||||||
|
if (ret < 0)
|
||||||
|
goto err_phy;
|
||||||
|
|
||||||
|
ret = phy_power_on(dra7xx->phy[i]);
|
||||||
|
if (ret < 0) {
|
||||||
|
phy_exit(dra7xx->phy[i]);
|
||||||
|
goto err_phy;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
err_phy:
|
||||||
|
while (--i >= 0) {
|
||||||
|
phy_power_off(dra7xx->phy[i]);
|
||||||
|
phy_exit(dra7xx->phy[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static int __init dra7xx_pcie_probe(struct platform_device *pdev)
|
static int __init dra7xx_pcie_probe(struct platform_device *pdev)
|
||||||
{
|
{
|
||||||
u32 reg;
|
u32 reg;
|
||||||
|
@ -382,22 +421,18 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev)
|
||||||
phy[i] = devm_phy_get(dev, name);
|
phy[i] = devm_phy_get(dev, name);
|
||||||
if (IS_ERR(phy[i]))
|
if (IS_ERR(phy[i]))
|
||||||
return PTR_ERR(phy[i]);
|
return PTR_ERR(phy[i]);
|
||||||
|
|
||||||
ret = phy_init(phy[i]);
|
|
||||||
if (ret < 0)
|
|
||||||
goto err_phy;
|
|
||||||
|
|
||||||
ret = phy_power_on(phy[i]);
|
|
||||||
if (ret < 0) {
|
|
||||||
phy_exit(phy[i]);
|
|
||||||
goto err_phy;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
dra7xx->base = base;
|
dra7xx->base = base;
|
||||||
dra7xx->phy = phy;
|
dra7xx->phy = phy;
|
||||||
dra7xx->phy_count = phy_count;
|
dra7xx->phy_count = phy_count;
|
||||||
|
|
||||||
|
ret = dra7xx_pcie_enable_phy(dra7xx);
|
||||||
|
if (ret) {
|
||||||
|
dev_err(dev, "failed to enable phy\n");
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
pm_runtime_enable(dev);
|
pm_runtime_enable(dev);
|
||||||
ret = pm_runtime_get_sync(dev);
|
ret = pm_runtime_get_sync(dev);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
|
@ -432,12 +467,7 @@ err_gpio:
|
||||||
|
|
||||||
err_get_sync:
|
err_get_sync:
|
||||||
pm_runtime_disable(dev);
|
pm_runtime_disable(dev);
|
||||||
|
dra7xx_pcie_disable_phy(dra7xx);
|
||||||
err_phy:
|
|
||||||
while (--i >= 0) {
|
|
||||||
phy_power_off(phy[i]);
|
|
||||||
phy_exit(phy[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -474,12 +504,8 @@ static int dra7xx_pcie_resume(struct device *dev)
|
||||||
static int dra7xx_pcie_suspend_noirq(struct device *dev)
|
static int dra7xx_pcie_suspend_noirq(struct device *dev)
|
||||||
{
|
{
|
||||||
struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
|
struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
|
||||||
int count = dra7xx->phy_count;
|
|
||||||
|
|
||||||
while (count--) {
|
dra7xx_pcie_disable_phy(dra7xx);
|
||||||
phy_power_off(dra7xx->phy[count]);
|
|
||||||
phy_exit(dra7xx->phy[count]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -487,31 +513,15 @@ static int dra7xx_pcie_suspend_noirq(struct device *dev)
|
||||||
static int dra7xx_pcie_resume_noirq(struct device *dev)
|
static int dra7xx_pcie_resume_noirq(struct device *dev)
|
||||||
{
|
{
|
||||||
struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
|
struct dra7xx_pcie *dra7xx = dev_get_drvdata(dev);
|
||||||
int phy_count = dra7xx->phy_count;
|
|
||||||
int ret;
|
int ret;
|
||||||
int i;
|
|
||||||
|
|
||||||
for (i = 0; i < phy_count; i++) {
|
ret = dra7xx_pcie_enable_phy(dra7xx);
|
||||||
ret = phy_init(dra7xx->phy[i]);
|
if (ret) {
|
||||||
if (ret < 0)
|
dev_err(dev, "failed to enable phy\n");
|
||||||
goto err_phy;
|
return ret;
|
||||||
|
|
||||||
ret = phy_power_on(dra7xx->phy[i]);
|
|
||||||
if (ret < 0) {
|
|
||||||
phy_exit(dra7xx->phy[i]);
|
|
||||||
goto err_phy;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
err_phy:
|
|
||||||
while (--i >= 0) {
|
|
||||||
phy_power_off(dra7xx->phy[i]);
|
|
||||||
phy_exit(dra7xx->phy[i]);
|
|
||||||
}
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
Загрузка…
Ссылка в новой задаче