phy: ti: usb2: Fix logic on -EPROBE_DEFER
If clk_get() returns -EPROBE_DEFER then we should just return instead of falling back to old clock name. Use clk_prepare_enable() and clk_disable_unprepare() instead of splitting up prepare/unprepare from enable/disable. Signed-off-by: Roger Quadros <rogerq@ti.com> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
This commit is contained in:
parent
32fcf6fc6c
commit
ed31ee7cf1
@ -135,9 +135,9 @@ static int omap_usb_power_on(struct phy *x)
|
|||||||
|
|
||||||
static int omap_usb2_disable_clocks(struct omap_usb *phy)
|
static int omap_usb2_disable_clocks(struct omap_usb *phy)
|
||||||
{
|
{
|
||||||
clk_disable(phy->wkupclk);
|
clk_disable_unprepare(phy->wkupclk);
|
||||||
if (!IS_ERR(phy->optclk))
|
if (!IS_ERR(phy->optclk))
|
||||||
clk_disable(phy->optclk);
|
clk_disable_unprepare(phy->optclk);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -146,14 +146,14 @@ static int omap_usb2_enable_clocks(struct omap_usb *phy)
|
|||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
ret = clk_enable(phy->wkupclk);
|
ret = clk_prepare_enable(phy->wkupclk);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(phy->dev, "Failed to enable wkupclk %d\n", ret);
|
dev_err(phy->dev, "Failed to enable wkupclk %d\n", ret);
|
||||||
goto err0;
|
goto err0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!IS_ERR(phy->optclk)) {
|
if (!IS_ERR(phy->optclk)) {
|
||||||
ret = clk_enable(phy->optclk);
|
ret = clk_prepare_enable(phy->optclk);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
dev_err(phy->dev, "Failed to enable optclk %d\n", ret);
|
dev_err(phy->dev, "Failed to enable optclk %d\n", ret);
|
||||||
goto err1;
|
goto err1;
|
||||||
@ -346,13 +346,52 @@ static int omap_usb2_probe(struct platform_device *pdev)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
otg->set_host = omap_usb_set_host;
|
|
||||||
otg->set_peripheral = omap_usb_set_peripheral;
|
phy->wkupclk = devm_clk_get(phy->dev, "wkupclk");
|
||||||
|
if (IS_ERR(phy->wkupclk)) {
|
||||||
|
if (PTR_ERR(phy->wkupclk) == -EPROBE_DEFER)
|
||||||
|
return -EPROBE_DEFER;
|
||||||
|
|
||||||
|
dev_warn(&pdev->dev, "unable to get wkupclk %ld, trying old name\n",
|
||||||
|
PTR_ERR(phy->wkupclk));
|
||||||
|
phy->wkupclk = devm_clk_get(phy->dev, "usb_phy_cm_clk32k");
|
||||||
|
|
||||||
|
if (IS_ERR(phy->wkupclk)) {
|
||||||
|
if (PTR_ERR(phy->wkupclk) != -EPROBE_DEFER)
|
||||||
|
dev_err(&pdev->dev, "unable to get usb_phy_cm_clk32k\n");
|
||||||
|
return PTR_ERR(phy->wkupclk);
|
||||||
|
} else {
|
||||||
|
dev_warn(&pdev->dev,
|
||||||
|
"found usb_phy_cm_clk32k, please fix DTS\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
phy->optclk = devm_clk_get(phy->dev, "refclk");
|
||||||
|
if (IS_ERR(phy->optclk)) {
|
||||||
|
if (PTR_ERR(phy->optclk) == -EPROBE_DEFER)
|
||||||
|
return -EPROBE_DEFER;
|
||||||
|
|
||||||
|
dev_dbg(&pdev->dev, "unable to get refclk, trying old name\n");
|
||||||
|
phy->optclk = devm_clk_get(phy->dev, "usb_otg_ss_refclk960m");
|
||||||
|
|
||||||
|
if (IS_ERR(phy->optclk)) {
|
||||||
|
if (PTR_ERR(phy->optclk) != -EPROBE_DEFER) {
|
||||||
|
dev_dbg(&pdev->dev,
|
||||||
|
"unable to get usb_otg_ss_refclk960m\n");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
dev_warn(&pdev->dev,
|
||||||
|
"found usb_otg_ss_refclk960m, please fix DTS\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
otg->set_host = omap_usb_set_host;
|
||||||
|
otg->set_peripheral = omap_usb_set_peripheral;
|
||||||
if (phy_data->flags & OMAP_USB2_HAS_SET_VBUS)
|
if (phy_data->flags & OMAP_USB2_HAS_SET_VBUS)
|
||||||
otg->set_vbus = omap_usb_set_vbus;
|
otg->set_vbus = omap_usb_set_vbus;
|
||||||
if (phy_data->flags & OMAP_USB2_HAS_START_SRP)
|
if (phy_data->flags & OMAP_USB2_HAS_START_SRP)
|
||||||
otg->start_srp = omap_usb_start_srp;
|
otg->start_srp = omap_usb_start_srp;
|
||||||
otg->usb_phy = &phy->phy;
|
otg->usb_phy = &phy->phy;
|
||||||
|
|
||||||
platform_set_drvdata(pdev, phy);
|
platform_set_drvdata(pdev, phy);
|
||||||
pm_runtime_enable(phy->dev);
|
pm_runtime_enable(phy->dev);
|
||||||
@ -367,42 +406,12 @@ static int omap_usb2_probe(struct platform_device *pdev)
|
|||||||
omap_usb_power_off(generic_phy);
|
omap_usb_power_off(generic_phy);
|
||||||
|
|
||||||
phy_provider = devm_of_phy_provider_register(phy->dev,
|
phy_provider = devm_of_phy_provider_register(phy->dev,
|
||||||
of_phy_simple_xlate);
|
of_phy_simple_xlate);
|
||||||
if (IS_ERR(phy_provider)) {
|
if (IS_ERR(phy_provider)) {
|
||||||
pm_runtime_disable(phy->dev);
|
pm_runtime_disable(phy->dev);
|
||||||
return PTR_ERR(phy_provider);
|
return PTR_ERR(phy_provider);
|
||||||
}
|
}
|
||||||
|
|
||||||
phy->wkupclk = devm_clk_get(phy->dev, "wkupclk");
|
|
||||||
if (IS_ERR(phy->wkupclk)) {
|
|
||||||
dev_warn(&pdev->dev, "unable to get wkupclk, trying old name\n");
|
|
||||||
phy->wkupclk = devm_clk_get(phy->dev, "usb_phy_cm_clk32k");
|
|
||||||
if (IS_ERR(phy->wkupclk)) {
|
|
||||||
dev_err(&pdev->dev, "unable to get usb_phy_cm_clk32k\n");
|
|
||||||
pm_runtime_disable(phy->dev);
|
|
||||||
return PTR_ERR(phy->wkupclk);
|
|
||||||
} else {
|
|
||||||
dev_warn(&pdev->dev,
|
|
||||||
"found usb_phy_cm_clk32k, please fix DTS\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
clk_prepare(phy->wkupclk);
|
|
||||||
|
|
||||||
phy->optclk = devm_clk_get(phy->dev, "refclk");
|
|
||||||
if (IS_ERR(phy->optclk)) {
|
|
||||||
dev_dbg(&pdev->dev, "unable to get refclk, trying old name\n");
|
|
||||||
phy->optclk = devm_clk_get(phy->dev, "usb_otg_ss_refclk960m");
|
|
||||||
if (IS_ERR(phy->optclk)) {
|
|
||||||
dev_dbg(&pdev->dev,
|
|
||||||
"unable to get usb_otg_ss_refclk960m\n");
|
|
||||||
} else {
|
|
||||||
dev_warn(&pdev->dev,
|
|
||||||
"found usb_otg_ss_refclk960m, please fix DTS\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!IS_ERR(phy->optclk))
|
|
||||||
clk_prepare(phy->optclk);
|
|
||||||
|
|
||||||
usb_add_phy_dev(&phy->phy);
|
usb_add_phy_dev(&phy->phy);
|
||||||
|
|
||||||
@ -413,9 +422,6 @@ static int omap_usb2_remove(struct platform_device *pdev)
|
|||||||
{
|
{
|
||||||
struct omap_usb *phy = platform_get_drvdata(pdev);
|
struct omap_usb *phy = platform_get_drvdata(pdev);
|
||||||
|
|
||||||
clk_unprepare(phy->wkupclk);
|
|
||||||
if (!IS_ERR(phy->optclk))
|
|
||||||
clk_unprepare(phy->optclk);
|
|
||||||
usb_remove_phy(&phy->phy);
|
usb_remove_phy(&phy->phy);
|
||||||
pm_runtime_disable(phy->dev);
|
pm_runtime_disable(phy->dev);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user