Commit 7021deae authored by Greg Kroah-Hartman's avatar Greg Kroah-Hartman

Merge tag 'phy-for-4.2-rc' of...

Merge tag 'phy-for-4.2-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy into usb-linus

Kishon writes:

phy: for 4.2-rc

*) Fix PIPE3 PM so that all its users (PCIe, SATA, USB) can
   idle and resume
*) Fix a compiler error in pxa
*) Fix pll divider values in berlin-usb phy driver
Signed-off-by: default avatarKishon Vijay Abraham I <kishon@ti.com>
parents aca3a048 dcb54fcb
...@@ -56,6 +56,7 @@ config PHY_EXYNOS_MIPI_VIDEO ...@@ -56,6 +56,7 @@ config PHY_EXYNOS_MIPI_VIDEO
config PHY_PXA_28NM_HSIC config PHY_PXA_28NM_HSIC
tristate "Marvell USB HSIC 28nm PHY Driver" tristate "Marvell USB HSIC 28nm PHY Driver"
depends on HAS_IOMEM
select GENERIC_PHY select GENERIC_PHY
help help
Enable this to support Marvell USB HSIC PHY driver for Marvell Enable this to support Marvell USB HSIC PHY driver for Marvell
...@@ -66,6 +67,7 @@ config PHY_PXA_28NM_HSIC ...@@ -66,6 +67,7 @@ config PHY_PXA_28NM_HSIC
config PHY_PXA_28NM_USB2 config PHY_PXA_28NM_USB2
tristate "Marvell USB 2.0 28nm PHY Driver" tristate "Marvell USB 2.0 28nm PHY Driver"
depends on HAS_IOMEM
select GENERIC_PHY select GENERIC_PHY
help help
Enable this to support Marvell USB 2.0 PHY driver for Marvell Enable this to support Marvell USB 2.0 PHY driver for Marvell
......
...@@ -105,9 +105,9 @@ ...@@ -105,9 +105,9 @@
static const u32 phy_berlin_pll_dividers[] = { static const u32 phy_berlin_pll_dividers[] = {
/* Berlin 2 */ /* Berlin 2 */
CLK_REF_DIV(0xc) | FEEDBACK_CLK_DIV(0x54),
/* Berlin 2CD */
CLK_REF_DIV(0x6) | FEEDBACK_CLK_DIV(0x55), CLK_REF_DIV(0x6) | FEEDBACK_CLK_DIV(0x55),
/* Berlin 2CD/Q */
CLK_REF_DIV(0xc) | FEEDBACK_CLK_DIV(0x54),
}; };
struct phy_berlin_usb_priv { struct phy_berlin_usb_priv {
......
...@@ -28,7 +28,6 @@ ...@@ -28,7 +28,6 @@
#include <linux/delay.h> #include <linux/delay.h>
#include <linux/phy/omap_control_phy.h> #include <linux/phy/omap_control_phy.h>
#include <linux/of_platform.h> #include <linux/of_platform.h>
#include <linux/spinlock.h>
#define PLL_STATUS 0x00000004 #define PLL_STATUS 0x00000004
#define PLL_GO 0x00000008 #define PLL_GO 0x00000008
...@@ -83,10 +82,6 @@ struct ti_pipe3 { ...@@ -83,10 +82,6 @@ struct ti_pipe3 {
struct clk *refclk; struct clk *refclk;
struct clk *div_clk; struct clk *div_clk;
struct pipe3_dpll_map *dpll_map; struct pipe3_dpll_map *dpll_map;
bool enabled;
spinlock_t lock; /* serialize clock enable/disable */
/* the below flag is needed specifically for SATA */
bool refclk_enabled;
}; };
static struct pipe3_dpll_map dpll_map_usb[] = { static struct pipe3_dpll_map dpll_map_usb[] = {
...@@ -137,6 +132,9 @@ static struct pipe3_dpll_params *ti_pipe3_get_dpll_params(struct ti_pipe3 *phy) ...@@ -137,6 +132,9 @@ static struct pipe3_dpll_params *ti_pipe3_get_dpll_params(struct ti_pipe3 *phy)
return NULL; return NULL;
} }
static int ti_pipe3_enable_clocks(struct ti_pipe3 *phy);
static void ti_pipe3_disable_clocks(struct ti_pipe3 *phy);
static int ti_pipe3_power_off(struct phy *x) static int ti_pipe3_power_off(struct phy *x)
{ {
struct ti_pipe3 *phy = phy_get_drvdata(x); struct ti_pipe3 *phy = phy_get_drvdata(x);
...@@ -217,6 +215,7 @@ static int ti_pipe3_init(struct phy *x) ...@@ -217,6 +215,7 @@ static int ti_pipe3_init(struct phy *x)
u32 val; u32 val;
int ret = 0; int ret = 0;
ti_pipe3_enable_clocks(phy);
/* /*
* Set pcie_pcs register to 0x96 for proper functioning of phy * Set pcie_pcs register to 0x96 for proper functioning of phy
* as recommended in AM572x TRM SPRUHZ6, section 18.5.2.2, table * as recommended in AM572x TRM SPRUHZ6, section 18.5.2.2, table
...@@ -250,33 +249,35 @@ static int ti_pipe3_exit(struct phy *x) ...@@ -250,33 +249,35 @@ static int ti_pipe3_exit(struct phy *x)
u32 val; u32 val;
unsigned long timeout; unsigned long timeout;
/* SATA DPLL can't be powered down due to Errata i783 and PCIe /* SATA DPLL can't be powered down due to Errata i783 */
* does not have internal DPLL if (of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-sata"))
*/
if (of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-sata") ||
of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-pcie"))
return 0; return 0;
/* Put DPLL in IDLE mode */ /* PCIe doesn't have internal DPLL */
val = ti_pipe3_readl(phy->pll_ctrl_base, PLL_CONFIGURATION2); if (!of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-pcie")) {
val |= PLL_IDLE; /* Put DPLL in IDLE mode */
ti_pipe3_writel(phy->pll_ctrl_base, PLL_CONFIGURATION2, val); val = ti_pipe3_readl(phy->pll_ctrl_base, PLL_CONFIGURATION2);
val |= PLL_IDLE;
/* wait for LDO and Oscillator to power down */ ti_pipe3_writel(phy->pll_ctrl_base, PLL_CONFIGURATION2, val);
timeout = jiffies + msecs_to_jiffies(PLL_IDLE_TIME);
do {
cpu_relax();
val = ti_pipe3_readl(phy->pll_ctrl_base, PLL_STATUS);
if ((val & PLL_TICOPWDN) && (val & PLL_LDOPWDN))
break;
} while (!time_after(jiffies, timeout));
if (!(val & PLL_TICOPWDN) || !(val & PLL_LDOPWDN)) { /* wait for LDO and Oscillator to power down */
dev_err(phy->dev, "Failed to power down: PLL_STATUS 0x%x\n", timeout = jiffies + msecs_to_jiffies(PLL_IDLE_TIME);
val); do {
return -EBUSY; cpu_relax();
val = ti_pipe3_readl(phy->pll_ctrl_base, PLL_STATUS);
if ((val & PLL_TICOPWDN) && (val & PLL_LDOPWDN))
break;
} while (!time_after(jiffies, timeout));
if (!(val & PLL_TICOPWDN) || !(val & PLL_LDOPWDN)) {
dev_err(phy->dev, "Failed to power down: PLL_STATUS 0x%x\n",
val);
return -EBUSY;
}
} }
ti_pipe3_disable_clocks(phy);
return 0; return 0;
} }
static struct phy_ops ops = { static struct phy_ops ops = {
...@@ -306,7 +307,6 @@ static int ti_pipe3_probe(struct platform_device *pdev) ...@@ -306,7 +307,6 @@ static int ti_pipe3_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
phy->dev = &pdev->dev; phy->dev = &pdev->dev;
spin_lock_init(&phy->lock);
if (!of_device_is_compatible(node, "ti,phy-pipe3-pcie")) { if (!of_device_is_compatible(node, "ti,phy-pipe3-pcie")) {
match = of_match_device(ti_pipe3_id_table, &pdev->dev); match = of_match_device(ti_pipe3_id_table, &pdev->dev);
...@@ -402,6 +402,10 @@ static int ti_pipe3_probe(struct platform_device *pdev) ...@@ -402,6 +402,10 @@ static int ti_pipe3_probe(struct platform_device *pdev)
platform_set_drvdata(pdev, phy); platform_set_drvdata(pdev, phy);
pm_runtime_enable(phy->dev); pm_runtime_enable(phy->dev);
/* Prevent auto-disable of refclk for SATA PHY due to Errata i783 */
if (of_device_is_compatible(node, "ti,phy-pipe3-sata"))
if (!IS_ERR(phy->refclk))
clk_prepare_enable(phy->refclk);
generic_phy = devm_phy_create(phy->dev, NULL, &ops); generic_phy = devm_phy_create(phy->dev, NULL, &ops);
if (IS_ERR(generic_phy)) if (IS_ERR(generic_phy))
...@@ -413,63 +417,33 @@ static int ti_pipe3_probe(struct platform_device *pdev) ...@@ -413,63 +417,33 @@ static int ti_pipe3_probe(struct platform_device *pdev)
if (IS_ERR(phy_provider)) if (IS_ERR(phy_provider))
return PTR_ERR(phy_provider); return PTR_ERR(phy_provider);
pm_runtime_get(&pdev->dev);
return 0; return 0;
} }
static int ti_pipe3_remove(struct platform_device *pdev) static int ti_pipe3_remove(struct platform_device *pdev)
{ {
if (!pm_runtime_suspended(&pdev->dev))
pm_runtime_put(&pdev->dev);
pm_runtime_disable(&pdev->dev); pm_runtime_disable(&pdev->dev);
return 0; return 0;
} }
#ifdef CONFIG_PM static int ti_pipe3_enable_clocks(struct ti_pipe3 *phy)
static int ti_pipe3_enable_refclk(struct ti_pipe3 *phy)
{ {
if (!IS_ERR(phy->refclk) && !phy->refclk_enabled) { int ret = 0;
int ret;
if (!IS_ERR(phy->refclk)) {
ret = clk_prepare_enable(phy->refclk); ret = clk_prepare_enable(phy->refclk);
if (ret) { if (ret) {
dev_err(phy->dev, "Failed to enable refclk %d\n", ret); dev_err(phy->dev, "Failed to enable refclk %d\n", ret);
return ret; return ret;
} }
phy->refclk_enabled = true;
} }
return 0;
}
static void ti_pipe3_disable_refclk(struct ti_pipe3 *phy)
{
if (!IS_ERR(phy->refclk))
clk_disable_unprepare(phy->refclk);
phy->refclk_enabled = false;
}
static int ti_pipe3_enable_clocks(struct ti_pipe3 *phy)
{
int ret = 0;
unsigned long flags;
spin_lock_irqsave(&phy->lock, flags);
if (phy->enabled)
goto err1;
ret = ti_pipe3_enable_refclk(phy);
if (ret)
goto err1;
if (!IS_ERR(phy->wkupclk)) { if (!IS_ERR(phy->wkupclk)) {
ret = clk_prepare_enable(phy->wkupclk); ret = clk_prepare_enable(phy->wkupclk);
if (ret) { if (ret) {
dev_err(phy->dev, "Failed to enable wkupclk %d\n", ret); dev_err(phy->dev, "Failed to enable wkupclk %d\n", ret);
goto err2; goto disable_refclk;
} }
} }
...@@ -477,96 +451,33 @@ static int ti_pipe3_enable_clocks(struct ti_pipe3 *phy) ...@@ -477,96 +451,33 @@ static int ti_pipe3_enable_clocks(struct ti_pipe3 *phy)
ret = clk_prepare_enable(phy->div_clk); ret = clk_prepare_enable(phy->div_clk);
if (ret) { if (ret) {
dev_err(phy->dev, "Failed to enable div_clk %d\n", ret); dev_err(phy->dev, "Failed to enable div_clk %d\n", ret);
goto err3; goto disable_wkupclk;
} }
} }
phy->enabled = true;
spin_unlock_irqrestore(&phy->lock, flags);
return 0; return 0;
err3: disable_wkupclk:
if (!IS_ERR(phy->wkupclk)) if (!IS_ERR(phy->wkupclk))
clk_disable_unprepare(phy->wkupclk); clk_disable_unprepare(phy->wkupclk);
err2: disable_refclk:
if (!IS_ERR(phy->refclk)) if (!IS_ERR(phy->refclk))
clk_disable_unprepare(phy->refclk); clk_disable_unprepare(phy->refclk);
ti_pipe3_disable_refclk(phy);
err1:
spin_unlock_irqrestore(&phy->lock, flags);
return ret; return ret;
} }
static void ti_pipe3_disable_clocks(struct ti_pipe3 *phy) static void ti_pipe3_disable_clocks(struct ti_pipe3 *phy)
{ {
unsigned long flags;
spin_lock_irqsave(&phy->lock, flags);
if (!phy->enabled) {
spin_unlock_irqrestore(&phy->lock, flags);
return;
}
if (!IS_ERR(phy->wkupclk)) if (!IS_ERR(phy->wkupclk))
clk_disable_unprepare(phy->wkupclk); clk_disable_unprepare(phy->wkupclk);
/* Don't disable refclk for SATA PHY due to Errata i783 */ if (!IS_ERR(phy->refclk))
if (!of_device_is_compatible(phy->dev->of_node, "ti,phy-pipe3-sata")) clk_disable_unprepare(phy->refclk);
ti_pipe3_disable_refclk(phy);
if (!IS_ERR(phy->div_clk)) if (!IS_ERR(phy->div_clk))
clk_disable_unprepare(phy->div_clk); clk_disable_unprepare(phy->div_clk);
phy->enabled = false;
spin_unlock_irqrestore(&phy->lock, flags);
}
static int ti_pipe3_runtime_suspend(struct device *dev)
{
struct ti_pipe3 *phy = dev_get_drvdata(dev);
ti_pipe3_disable_clocks(phy);
return 0;
} }
static int ti_pipe3_runtime_resume(struct device *dev)
{
struct ti_pipe3 *phy = dev_get_drvdata(dev);
int ret = 0;
ret = ti_pipe3_enable_clocks(phy);
return ret;
}
static int ti_pipe3_suspend(struct device *dev)
{
struct ti_pipe3 *phy = dev_get_drvdata(dev);
ti_pipe3_disable_clocks(phy);
return 0;
}
static int ti_pipe3_resume(struct device *dev)
{
struct ti_pipe3 *phy = dev_get_drvdata(dev);
int ret;
ret = ti_pipe3_enable_clocks(phy);
if (ret)
return ret;
pm_runtime_disable(dev);
pm_runtime_set_active(dev);
pm_runtime_enable(dev);
return 0;
}
#endif
static const struct dev_pm_ops ti_pipe3_pm_ops = {
SET_RUNTIME_PM_OPS(ti_pipe3_runtime_suspend,
ti_pipe3_runtime_resume, NULL)
SET_SYSTEM_SLEEP_PM_OPS(ti_pipe3_suspend, ti_pipe3_resume)
};
static const struct of_device_id ti_pipe3_id_table[] = { static const struct of_device_id ti_pipe3_id_table[] = {
{ {
.compatible = "ti,phy-usb3", .compatible = "ti,phy-usb3",
...@@ -592,7 +503,6 @@ static struct platform_driver ti_pipe3_driver = { ...@@ -592,7 +503,6 @@ static struct platform_driver ti_pipe3_driver = {
.remove = ti_pipe3_remove, .remove = ti_pipe3_remove,
.driver = { .driver = {
.name = "ti-pipe3", .name = "ti-pipe3",
.pm = &ti_pipe3_pm_ops,
.of_match_table = ti_pipe3_id_table, .of_match_table = ti_pipe3_id_table,
}, },
}; };
......
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