mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-05-05 20:33:49 -04:00
Merge tag 'for-4.0-rc' of git://git.kernel.org/pub/scm/linux/kernel/git/kishon/linux-phy into usb-linus
Kishon writes: contains fixes all over drivers/phy and includes the following *) Using phy_get_drvdata instead of dev_get_drvdata in armada375-usb2.c *) Fixes w.r.t checking return values in regmap APIs, protecting regmap ops with spin lock and directly using regmap_update_bits instead of having a separate function to do the same in the various PHYs used in exynos. *) check return value in platform_get_resource of hix5hd2-sata PHY *) Removed NULL terminating entry from phys array and fix off-by-one valid value checking for args->args[0] in of_xlate of exynos USB PHY. *) Fixup rockchip_usb_phy_power_on failure path *) Fix devm_phy_match to find the correct match in phy core and also fix to return the correct value from PHY APIs if PM runtime is not enabled. *) Removed redundant code in twl4030 and xgene *) Fixed sizeof during memory allocation in miphy PHYs *) simplify ti_pipe3_dpll_wait_lock implementation, fix missing clk_prepare when using old dt name and nit pick in MOUDLE_ALIAS in TI PHYs.
This commit is contained in:
@@ -37,7 +37,7 @@ static int armada375_usb_phy_init(struct phy *phy)
|
||||
struct armada375_cluster_phy *cluster_phy;
|
||||
u32 reg;
|
||||
|
||||
cluster_phy = dev_get_drvdata(phy->dev.parent);
|
||||
cluster_phy = phy_get_drvdata(phy);
|
||||
if (!cluster_phy)
|
||||
return -ENODEV;
|
||||
|
||||
@@ -131,6 +131,7 @@ static int armada375_usb_phy_probe(struct platform_device *pdev)
|
||||
cluster_phy->reg = usb_cluster_base;
|
||||
|
||||
dev_set_drvdata(dev, cluster_phy);
|
||||
phy_set_drvdata(phy, cluster_phy);
|
||||
|
||||
phy_provider = devm_of_phy_provider_register(&pdev->dev,
|
||||
armada375_usb_phy_xlate);
|
||||
|
||||
@@ -52,7 +52,9 @@ static void devm_phy_consume(struct device *dev, void *res)
|
||||
|
||||
static int devm_phy_match(struct device *dev, void *res, void *match_data)
|
||||
{
|
||||
return res == match_data;
|
||||
struct phy **phy = res;
|
||||
|
||||
return *phy == match_data;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -223,6 +225,7 @@ int phy_init(struct phy *phy)
|
||||
ret = phy_pm_runtime_get_sync(phy);
|
||||
if (ret < 0 && ret != -ENOTSUPP)
|
||||
return ret;
|
||||
ret = 0; /* Override possible ret == -ENOTSUPP */
|
||||
|
||||
mutex_lock(&phy->mutex);
|
||||
if (phy->init_count == 0 && phy->ops->init) {
|
||||
@@ -231,8 +234,6 @@ int phy_init(struct phy *phy)
|
||||
dev_err(&phy->dev, "phy init failed --> %d\n", ret);
|
||||
goto out;
|
||||
}
|
||||
} else {
|
||||
ret = 0; /* Override possible ret == -ENOTSUPP */
|
||||
}
|
||||
++phy->init_count;
|
||||
|
||||
@@ -253,6 +254,7 @@ int phy_exit(struct phy *phy)
|
||||
ret = phy_pm_runtime_get_sync(phy);
|
||||
if (ret < 0 && ret != -ENOTSUPP)
|
||||
return ret;
|
||||
ret = 0; /* Override possible ret == -ENOTSUPP */
|
||||
|
||||
mutex_lock(&phy->mutex);
|
||||
if (phy->init_count == 1 && phy->ops->exit) {
|
||||
@@ -287,6 +289,7 @@ int phy_power_on(struct phy *phy)
|
||||
ret = phy_pm_runtime_get_sync(phy);
|
||||
if (ret < 0 && ret != -ENOTSUPP)
|
||||
return ret;
|
||||
ret = 0; /* Override possible ret == -ENOTSUPP */
|
||||
|
||||
mutex_lock(&phy->mutex);
|
||||
if (phy->power_count == 0 && phy->ops->power_on) {
|
||||
@@ -295,8 +298,6 @@ int phy_power_on(struct phy *phy)
|
||||
dev_err(&phy->dev, "phy poweron failed --> %d\n", ret);
|
||||
goto out;
|
||||
}
|
||||
} else {
|
||||
ret = 0; /* Override possible ret == -ENOTSUPP */
|
||||
}
|
||||
++phy->power_count;
|
||||
mutex_unlock(&phy->mutex);
|
||||
|
||||
@@ -30,28 +30,13 @@ struct exynos_dp_video_phy {
|
||||
const struct exynos_dp_video_phy_drvdata *drvdata;
|
||||
};
|
||||
|
||||
static void exynos_dp_video_phy_pwr_isol(struct exynos_dp_video_phy *state,
|
||||
unsigned int on)
|
||||
{
|
||||
unsigned int val;
|
||||
|
||||
if (IS_ERR(state->regs))
|
||||
return;
|
||||
|
||||
val = on ? 0 : EXYNOS5_PHY_ENABLE;
|
||||
|
||||
regmap_update_bits(state->regs, state->drvdata->phy_ctrl_offset,
|
||||
EXYNOS5_PHY_ENABLE, val);
|
||||
}
|
||||
|
||||
static int exynos_dp_video_phy_power_on(struct phy *phy)
|
||||
{
|
||||
struct exynos_dp_video_phy *state = phy_get_drvdata(phy);
|
||||
|
||||
/* Disable power isolation on DP-PHY */
|
||||
exynos_dp_video_phy_pwr_isol(state, 0);
|
||||
|
||||
return 0;
|
||||
return regmap_update_bits(state->regs, state->drvdata->phy_ctrl_offset,
|
||||
EXYNOS5_PHY_ENABLE, EXYNOS5_PHY_ENABLE);
|
||||
}
|
||||
|
||||
static int exynos_dp_video_phy_power_off(struct phy *phy)
|
||||
@@ -59,9 +44,8 @@ static int exynos_dp_video_phy_power_off(struct phy *phy)
|
||||
struct exynos_dp_video_phy *state = phy_get_drvdata(phy);
|
||||
|
||||
/* Enable power isolation on DP-PHY */
|
||||
exynos_dp_video_phy_pwr_isol(state, 1);
|
||||
|
||||
return 0;
|
||||
return regmap_update_bits(state->regs, state->drvdata->phy_ctrl_offset,
|
||||
EXYNOS5_PHY_ENABLE, 0);
|
||||
}
|
||||
|
||||
static struct phy_ops exynos_dp_video_phy_ops = {
|
||||
|
||||
@@ -43,7 +43,6 @@ struct exynos_mipi_video_phy {
|
||||
} phys[EXYNOS_MIPI_PHYS_NUM];
|
||||
spinlock_t slock;
|
||||
void __iomem *regs;
|
||||
struct mutex mutex;
|
||||
struct regmap *regmap;
|
||||
};
|
||||
|
||||
@@ -59,8 +58,9 @@ static int __set_phy_state(struct exynos_mipi_video_phy *state,
|
||||
else
|
||||
reset = EXYNOS4_MIPI_PHY_SRESETN;
|
||||
|
||||
if (state->regmap) {
|
||||
mutex_lock(&state->mutex);
|
||||
spin_lock(&state->slock);
|
||||
|
||||
if (!IS_ERR(state->regmap)) {
|
||||
regmap_read(state->regmap, offset, &val);
|
||||
if (on)
|
||||
val |= reset;
|
||||
@@ -72,11 +72,9 @@ static int __set_phy_state(struct exynos_mipi_video_phy *state,
|
||||
else if (!(val & EXYNOS4_MIPI_PHY_RESET_MASK))
|
||||
val &= ~EXYNOS4_MIPI_PHY_ENABLE;
|
||||
regmap_write(state->regmap, offset, val);
|
||||
mutex_unlock(&state->mutex);
|
||||
} else {
|
||||
addr = state->regs + EXYNOS_MIPI_PHY_CONTROL(id / 2);
|
||||
|
||||
spin_lock(&state->slock);
|
||||
val = readl(addr);
|
||||
if (on)
|
||||
val |= reset;
|
||||
@@ -90,9 +88,9 @@ static int __set_phy_state(struct exynos_mipi_video_phy *state,
|
||||
val &= ~EXYNOS4_MIPI_PHY_ENABLE;
|
||||
|
||||
writel(val, addr);
|
||||
spin_unlock(&state->slock);
|
||||
}
|
||||
|
||||
spin_unlock(&state->slock);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -158,7 +156,6 @@ static int exynos_mipi_video_phy_probe(struct platform_device *pdev)
|
||||
|
||||
dev_set_drvdata(dev, state);
|
||||
spin_lock_init(&state->slock);
|
||||
mutex_init(&state->mutex);
|
||||
|
||||
for (i = 0; i < EXYNOS_MIPI_PHYS_NUM; i++) {
|
||||
struct phy *phy = devm_phy_create(dev, NULL,
|
||||
|
||||
@@ -250,7 +250,6 @@ static const struct samsung_usb2_common_phy exynos4210_phys[] = {
|
||||
.power_on = exynos4210_power_on,
|
||||
.power_off = exynos4210_power_off,
|
||||
},
|
||||
{},
|
||||
};
|
||||
|
||||
const struct samsung_usb2_phy_config exynos4210_usb2_phy_config = {
|
||||
|
||||
@@ -361,7 +361,6 @@ static const struct samsung_usb2_common_phy exynos4x12_phys[] = {
|
||||
.power_on = exynos4x12_power_on,
|
||||
.power_off = exynos4x12_power_off,
|
||||
},
|
||||
{},
|
||||
};
|
||||
|
||||
const struct samsung_usb2_phy_config exynos3250_usb2_phy_config = {
|
||||
|
||||
@@ -531,7 +531,7 @@ static struct phy *exynos5_usbdrd_phy_xlate(struct device *dev,
|
||||
{
|
||||
struct exynos5_usbdrd_phy *phy_drd = dev_get_drvdata(dev);
|
||||
|
||||
if (WARN_ON(args->args[0] > EXYNOS5_DRDPHYS_NUM))
|
||||
if (WARN_ON(args->args[0] >= EXYNOS5_DRDPHYS_NUM))
|
||||
return ERR_PTR(-ENODEV);
|
||||
|
||||
return phy_drd->phys[args->args[0]].phy;
|
||||
|
||||
@@ -391,7 +391,6 @@ static const struct samsung_usb2_common_phy exynos5250_phys[] = {
|
||||
.power_on = exynos5250_power_on,
|
||||
.power_off = exynos5250_power_off,
|
||||
},
|
||||
{},
|
||||
};
|
||||
|
||||
const struct samsung_usb2_phy_config exynos5250_usb2_phy_config = {
|
||||
|
||||
@@ -147,6 +147,9 @@ static int hix5hd2_sata_phy_probe(struct platform_device *pdev)
|
||||
return -ENOMEM;
|
||||
|
||||
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
|
||||
if (!res)
|
||||
return -EINVAL;
|
||||
|
||||
priv->base = devm_ioremap(dev, res->start, resource_size(res));
|
||||
if (!priv->base)
|
||||
return -ENOMEM;
|
||||
|
||||
@@ -228,6 +228,7 @@ struct miphy28lp_dev {
|
||||
struct regmap *regmap;
|
||||
struct mutex miphy_mutex;
|
||||
struct miphy28lp_phy **phys;
|
||||
int nphys;
|
||||
};
|
||||
|
||||
struct miphy_initval {
|
||||
@@ -1116,7 +1117,7 @@ static struct phy *miphy28lp_xlate(struct device *dev,
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
|
||||
for (index = 0; index < of_get_child_count(dev->of_node); index++)
|
||||
for (index = 0; index < miphy_dev->nphys; index++)
|
||||
if (phynode == miphy_dev->phys[index]->phy->dev.of_node) {
|
||||
miphy_phy = miphy_dev->phys[index];
|
||||
break;
|
||||
@@ -1138,6 +1139,7 @@ static struct phy *miphy28lp_xlate(struct device *dev,
|
||||
|
||||
static struct phy_ops miphy28lp_ops = {
|
||||
.init = miphy28lp_init,
|
||||
.owner = THIS_MODULE,
|
||||
};
|
||||
|
||||
static int miphy28lp_probe_resets(struct device_node *node,
|
||||
@@ -1200,16 +1202,15 @@ static int miphy28lp_probe(struct platform_device *pdev)
|
||||
struct miphy28lp_dev *miphy_dev;
|
||||
struct phy_provider *provider;
|
||||
struct phy *phy;
|
||||
int chancount, port = 0;
|
||||
int ret;
|
||||
int ret, port = 0;
|
||||
|
||||
miphy_dev = devm_kzalloc(&pdev->dev, sizeof(*miphy_dev), GFP_KERNEL);
|
||||
if (!miphy_dev)
|
||||
return -ENOMEM;
|
||||
|
||||
chancount = of_get_child_count(np);
|
||||
miphy_dev->phys = devm_kzalloc(&pdev->dev, sizeof(phy) * chancount,
|
||||
GFP_KERNEL);
|
||||
miphy_dev->nphys = of_get_child_count(np);
|
||||
miphy_dev->phys = devm_kcalloc(&pdev->dev, miphy_dev->nphys,
|
||||
sizeof(*miphy_dev->phys), GFP_KERNEL);
|
||||
if (!miphy_dev->phys)
|
||||
return -ENOMEM;
|
||||
|
||||
|
||||
@@ -150,6 +150,7 @@ struct miphy365x_dev {
|
||||
struct regmap *regmap;
|
||||
struct mutex miphy_mutex;
|
||||
struct miphy365x_phy **phys;
|
||||
int nphys;
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -485,7 +486,7 @@ static struct phy *miphy365x_xlate(struct device *dev,
|
||||
return ERR_PTR(-EINVAL);
|
||||
}
|
||||
|
||||
for (index = 0; index < of_get_child_count(dev->of_node); index++)
|
||||
for (index = 0; index < miphy_dev->nphys; index++)
|
||||
if (phynode == miphy_dev->phys[index]->phy->dev.of_node) {
|
||||
miphy_phy = miphy_dev->phys[index];
|
||||
break;
|
||||
@@ -541,16 +542,15 @@ static int miphy365x_probe(struct platform_device *pdev)
|
||||
struct miphy365x_dev *miphy_dev;
|
||||
struct phy_provider *provider;
|
||||
struct phy *phy;
|
||||
int chancount, port = 0;
|
||||
int ret;
|
||||
int ret, port = 0;
|
||||
|
||||
miphy_dev = devm_kzalloc(&pdev->dev, sizeof(*miphy_dev), GFP_KERNEL);
|
||||
if (!miphy_dev)
|
||||
return -ENOMEM;
|
||||
|
||||
chancount = of_get_child_count(np);
|
||||
miphy_dev->phys = devm_kzalloc(&pdev->dev, sizeof(phy) * chancount,
|
||||
GFP_KERNEL);
|
||||
miphy_dev->nphys = of_get_child_count(np);
|
||||
miphy_dev->phys = devm_kcalloc(&pdev->dev, miphy_dev->nphys,
|
||||
sizeof(*miphy_dev->phys), GFP_KERNEL);
|
||||
if (!miphy_dev->phys)
|
||||
return -ENOMEM;
|
||||
|
||||
|
||||
@@ -360,7 +360,7 @@ static void __exit omap_control_phy_exit(void)
|
||||
}
|
||||
module_exit(omap_control_phy_exit);
|
||||
|
||||
MODULE_ALIAS("platform: omap_control_phy");
|
||||
MODULE_ALIAS("platform:omap_control_phy");
|
||||
MODULE_AUTHOR("Texas Instruments Inc.");
|
||||
MODULE_DESCRIPTION("OMAP Control Module PHY Driver");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
|
||||
@@ -296,10 +296,11 @@ static int omap_usb2_probe(struct platform_device *pdev)
|
||||
dev_warn(&pdev->dev,
|
||||
"found usb_otg_ss_refclk960m, please fix DTS\n");
|
||||
}
|
||||
} else {
|
||||
clk_prepare(phy->optclk);
|
||||
}
|
||||
|
||||
if (!IS_ERR(phy->optclk))
|
||||
clk_prepare(phy->optclk);
|
||||
|
||||
usb_add_phy_dev(&phy->phy);
|
||||
|
||||
return 0;
|
||||
@@ -383,7 +384,7 @@ static struct platform_driver omap_usb2_driver = {
|
||||
|
||||
module_platform_driver(omap_usb2_driver);
|
||||
|
||||
MODULE_ALIAS("platform: omap_usb2");
|
||||
MODULE_ALIAS("platform:omap_usb2");
|
||||
MODULE_AUTHOR("Texas Instruments Inc.");
|
||||
MODULE_DESCRIPTION("OMAP USB2 phy driver");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
|
||||
@@ -61,8 +61,6 @@ static int rockchip_usb_phy_power_off(struct phy *_phy)
|
||||
return ret;
|
||||
|
||||
clk_disable_unprepare(phy->clk);
|
||||
if (ret)
|
||||
return ret;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -78,8 +76,10 @@ static int rockchip_usb_phy_power_on(struct phy *_phy)
|
||||
|
||||
/* Power up usb phy analog blocks by set siddq 0 */
|
||||
ret = rockchip_usb_phy_power(phy, 0);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
clk_disable_unprepare(phy->clk);
|
||||
return ret;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -165,15 +165,11 @@ static int ti_pipe3_dpll_wait_lock(struct ti_pipe3 *phy)
|
||||
cpu_relax();
|
||||
val = ti_pipe3_readl(phy->pll_ctrl_base, PLL_STATUS);
|
||||
if (val & PLL_LOCK)
|
||||
break;
|
||||
return 0;
|
||||
} while (!time_after(jiffies, timeout));
|
||||
|
||||
if (!(val & PLL_LOCK)) {
|
||||
dev_err(phy->dev, "DPLL failed to lock\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
return 0;
|
||||
dev_err(phy->dev, "DPLL failed to lock\n");
|
||||
return -EBUSY;
|
||||
}
|
||||
|
||||
static int ti_pipe3_dpll_program(struct ti_pipe3 *phy)
|
||||
@@ -608,7 +604,7 @@ static struct platform_driver ti_pipe3_driver = {
|
||||
|
||||
module_platform_driver(ti_pipe3_driver);
|
||||
|
||||
MODULE_ALIAS("platform: ti_pipe3");
|
||||
MODULE_ALIAS("platform:ti_pipe3");
|
||||
MODULE_AUTHOR("Texas Instruments Inc.");
|
||||
MODULE_DESCRIPTION("TI PIPE3 phy driver");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
|
||||
@@ -666,7 +666,6 @@ static int twl4030_usb_probe(struct platform_device *pdev)
|
||||
twl->dev = &pdev->dev;
|
||||
twl->irq = platform_get_irq(pdev, 0);
|
||||
twl->vbus_supplied = false;
|
||||
twl->linkstat = -EINVAL;
|
||||
twl->linkstat = OMAP_MUSB_UNKNOWN;
|
||||
|
||||
twl->phy.dev = twl->dev;
|
||||
|
||||
@@ -1704,7 +1704,6 @@ static int xgene_phy_probe(struct platform_device *pdev)
|
||||
for (i = 0; i < MAX_LANE; i++)
|
||||
ctx->sata_param.speed[i] = 2; /* Default to Gen3 */
|
||||
|
||||
ctx->dev = &pdev->dev;
|
||||
platform_set_drvdata(pdev, ctx);
|
||||
|
||||
ctx->phy = devm_phy_create(ctx->dev, NULL, &xgene_phy_ops);
|
||||
|
||||
Reference in New Issue
Block a user