From: "Ivan T. Ivanov" <[email protected]>
Changes since first version.
* Extend commit messages a little bit.
Following patches make initial cleanup of usb phy found in the Qualcomm
chipsets. Changes include:
* Build time error fix.
* Move driver to Managed Device Resource allocation.
* Checkpatch warnings and error fixes
* Removed usage of global regulators variables.
Ivan T. Ivanov (7):
usb: phy: msm: Move mach depndend code to platform data
usb: phy: msm: Migrate to Managed Device Resource allocation
usb: phy: msm: Move regulator usage to managed resource allocation
usb: phy: msm: Remove unnecessarily check for valid regulators.
usb: phy: msm: Fix WARNING: quoted string split across lines
usb: phy: msm: Fix WARNING: Prefer seq_puts to seq_printf
usb: phy: msm: Lindent the code
arch/arm/mach-msm/board-msm7x30.c | 35 ++++
arch/arm/mach-msm/board-qsd8x50.c | 34 ++++
drivers/usb/phy/phy-msm-usb.c | 384 ++++++++++++++-----------------------
include/linux/usb/msm_hsusb.h | 5 +
4 files changed, 220 insertions(+), 238 deletions(-)
--
1.7.9.5
From: "Ivan T. Ivanov" <[email protected]>
Whether regulators are available or not is checked at driver
probe. If they are not available driver will refuse to load,
so no need to check them again.
Signed-off-by: Ivan T. Ivanov <[email protected]>
---
drivers/usb/phy/phy-msm-usb.c | 10 ----------
1 file changed, 10 deletions(-)
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 8289270..0e7d7ab 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -159,16 +159,6 @@ static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, int on)
{
int ret = 0;
- if (!motg->v1p8 || IS_ERR(motg->v1p8)) {
- pr_err("%s: HSUSB_1p8 is not initialized\n", __func__);
- return -ENODEV;
- }
-
- if (!motg->v3p3 || IS_ERR(motg->v3p3)) {
- pr_err("%s: HSUSB_3p3 is not initialized\n", __func__);
- return -ENODEV;
- }
-
if (on) {
ret = regulator_set_optimum_mode(motg->v1p8,
USB_PHY_1P8_HPM_LOAD);
--
1.7.9.5
From: "Ivan T. Ivanov" <[email protected]>
This patch move global regulators variables to driver state
structire and move allocation of the regulators to be devm managed.
Signed-off-by: Ivan T. Ivanov <[email protected]>
---
drivers/usb/phy/phy-msm-usb.c | 111 +++++++++++++++++++----------------------
include/linux/usb/msm_hsusb.h | 3 ++
2 files changed, 53 insertions(+), 61 deletions(-)
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index cc37f5e..8289270 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -58,47 +58,32 @@
#define USB_PHY_VDD_DIG_VOL_MIN 1000000 /* uV */
#define USB_PHY_VDD_DIG_VOL_MAX 1320000 /* uV */
-static struct regulator *hsusb_3p3;
-static struct regulator *hsusb_1p8;
-static struct regulator *hsusb_vddcx;
-
static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init)
{
int ret = 0;
if (init) {
- hsusb_vddcx = regulator_get(motg->phy.dev, "HSUSB_VDDCX");
- if (IS_ERR(hsusb_vddcx)) {
- dev_err(motg->phy.dev, "unable to get hsusb vddcx\n");
- return PTR_ERR(hsusb_vddcx);
- }
-
- ret = regulator_set_voltage(hsusb_vddcx,
+ ret = regulator_set_voltage(motg->vddcx,
USB_PHY_VDD_DIG_VOL_MIN,
USB_PHY_VDD_DIG_VOL_MAX);
if (ret) {
dev_err(motg->phy.dev, "unable to set the voltage "
"for hsusb vddcx\n");
- regulator_put(hsusb_vddcx);
return ret;
}
- ret = regulator_enable(hsusb_vddcx);
- if (ret) {
+ ret = regulator_enable(motg->vddcx);
+ if (ret)
dev_err(motg->phy.dev, "unable to enable hsusb vddcx\n");
- regulator_put(hsusb_vddcx);
- }
} else {
- ret = regulator_set_voltage(hsusb_vddcx, 0,
+ ret = regulator_set_voltage(motg->vddcx, 0,
USB_PHY_VDD_DIG_VOL_MAX);
if (ret)
dev_err(motg->phy.dev, "unable to set the voltage "
"for hsusb vddcx\n");
- ret = regulator_disable(hsusb_vddcx);
+ ret = regulator_disable(motg->vddcx);
if (ret)
dev_err(motg->phy.dev, "unable to disable hsusb vddcx\n");
-
- regulator_put(hsusb_vddcx);
}
return ret;
@@ -109,59 +94,44 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int init)
int rc = 0;
if (init) {
- hsusb_3p3 = regulator_get(motg->phy.dev, "HSUSB_3p3");
- if (IS_ERR(hsusb_3p3)) {
- dev_err(motg->phy.dev, "unable to get hsusb 3p3\n");
- return PTR_ERR(hsusb_3p3);
- }
-
- rc = regulator_set_voltage(hsusb_3p3, USB_PHY_3P3_VOL_MIN,
+ rc = regulator_set_voltage(motg->v3p3, USB_PHY_3P3_VOL_MIN,
USB_PHY_3P3_VOL_MAX);
if (rc) {
dev_err(motg->phy.dev, "unable to set voltage level "
"for hsusb 3p3\n");
- goto put_3p3;
+ return rc;
}
- rc = regulator_enable(hsusb_3p3);
+ rc = regulator_enable(motg->v3p3);
if (rc) {
dev_err(motg->phy.dev, "unable to enable the hsusb 3p3\n");
- goto put_3p3;
- }
- hsusb_1p8 = regulator_get(motg->phy.dev, "HSUSB_1p8");
- if (IS_ERR(hsusb_1p8)) {
- dev_err(motg->phy.dev, "unable to get hsusb 1p8\n");
- rc = PTR_ERR(hsusb_1p8);
- goto disable_3p3;
+ return rc;
}
- rc = regulator_set_voltage(hsusb_1p8, USB_PHY_1P8_VOL_MIN,
+
+ rc = regulator_set_voltage(motg->v1p8, USB_PHY_1P8_VOL_MIN,
USB_PHY_1P8_VOL_MAX);
if (rc) {
dev_err(motg->phy.dev, "unable to set voltage level "
"for hsusb 1p8\n");
- goto put_1p8;
+ goto disable_3p3;
}
- rc = regulator_enable(hsusb_1p8);
+ rc = regulator_enable(motg->v1p8);
if (rc) {
dev_err(motg->phy.dev, "unable to enable the hsusb 1p8\n");
- goto put_1p8;
+ goto disable_3p3;
}
return 0;
}
- regulator_disable(hsusb_1p8);
-put_1p8:
- regulator_put(hsusb_1p8);
+ regulator_disable(motg->v1p8);
disable_3p3:
- regulator_disable(hsusb_3p3);
-put_3p3:
- regulator_put(hsusb_3p3);
+ regulator_disable(motg->v3p3);
return rc;
}
#ifdef CONFIG_PM_SLEEP
#define USB_PHY_SUSP_DIG_VOL 500000
-static int msm_hsusb_config_vddcx(int high)
+static int msm_hsusb_config_vddcx(struct msm_otg *motg, int high)
{
int max_vol = USB_PHY_VDD_DIG_VOL_MAX;
int min_vol;
@@ -172,7 +142,7 @@ static int msm_hsusb_config_vddcx(int high)
else
min_vol = USB_PHY_SUSP_DIG_VOL;
- ret = regulator_set_voltage(hsusb_vddcx, min_vol, max_vol);
+ ret = regulator_set_voltage(motg->vddcx, min_vol, max_vol);
if (ret) {
pr_err("%s: unable to set the voltage for regulator "
"HSUSB_VDDCX\n", __func__);
@@ -185,44 +155,44 @@ static int msm_hsusb_config_vddcx(int high)
}
#endif
-static int msm_hsusb_ldo_set_mode(int on)
+static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, int on)
{
int ret = 0;
- if (!hsusb_1p8 || IS_ERR(hsusb_1p8)) {
+ if (!motg->v1p8 || IS_ERR(motg->v1p8)) {
pr_err("%s: HSUSB_1p8 is not initialized\n", __func__);
return -ENODEV;
}
- if (!hsusb_3p3 || IS_ERR(hsusb_3p3)) {
+ if (!motg->v3p3 || IS_ERR(motg->v3p3)) {
pr_err("%s: HSUSB_3p3 is not initialized\n", __func__);
return -ENODEV;
}
if (on) {
- ret = regulator_set_optimum_mode(hsusb_1p8,
+ ret = regulator_set_optimum_mode(motg->v1p8,
USB_PHY_1P8_HPM_LOAD);
if (ret < 0) {
pr_err("%s: Unable to set HPM of the regulator "
"HSUSB_1p8\n", __func__);
return ret;
}
- ret = regulator_set_optimum_mode(hsusb_3p3,
+ ret = regulator_set_optimum_mode(motg->v3p3,
USB_PHY_3P3_HPM_LOAD);
if (ret < 0) {
pr_err("%s: Unable to set HPM of the regulator "
"HSUSB_3p3\n", __func__);
- regulator_set_optimum_mode(hsusb_1p8,
+ regulator_set_optimum_mode(motg->v1p8,
USB_PHY_1P8_LPM_LOAD);
return ret;
}
} else {
- ret = regulator_set_optimum_mode(hsusb_1p8,
+ ret = regulator_set_optimum_mode(motg->v1p8,
USB_PHY_1P8_LPM_LOAD);
if (ret < 0)
pr_err("%s: Unable to set LPM of the regulator "
"HSUSB_1p8\n", __func__);
- ret = regulator_set_optimum_mode(hsusb_3p3,
+ ret = regulator_set_optimum_mode(motg->v3p3,
USB_PHY_3P3_LPM_LOAD);
if (ret < 0)
pr_err("%s: Unable to set LPM of the regulator "
@@ -491,8 +461,8 @@ static int msm_otg_suspend(struct msm_otg *motg)
if (motg->pdata->phy_type == SNPS_28NM_INTEGRATED_PHY &&
motg->pdata->otg_control == OTG_PMIC_CONTROL) {
- msm_hsusb_ldo_set_mode(0);
- msm_hsusb_config_vddcx(0);
+ msm_hsusb_ldo_set_mode(motg, 0);
+ msm_hsusb_config_vddcx(motg, 0);
}
if (device_may_wakeup(phy->dev))
@@ -528,8 +498,8 @@ static int msm_otg_resume(struct msm_otg *motg)
if (motg->pdata->phy_type == SNPS_28NM_INTEGRATED_PHY &&
motg->pdata->otg_control == OTG_PMIC_CONTROL) {
- msm_hsusb_ldo_set_mode(1);
- msm_hsusb_config_vddcx(1);
+ msm_hsusb_ldo_set_mode(motg, 1);
+ msm_hsusb_config_vddcx(motg, 1);
writel(readl(USB_PHY_CTRL) & ~PHY_RETEN, USB_PHY_CTRL);
}
@@ -1478,6 +1448,24 @@ static int __init msm_otg_probe(struct platform_device *pdev)
return motg->irq;
}
+ motg->v3p3 = devm_regulator_get(&pdev->dev, "HSUSB_3p3");
+ if (IS_ERR(motg->v3p3)) {
+ dev_err(motg->phy.dev, "unable to get hsusb 3p3\n");
+ return PTR_ERR(motg->v3p3);
+ }
+
+ motg->v1p8 = devm_regulator_get(&pdev->dev, "HSUSB_1p8");
+ if (IS_ERR(motg->v1p8)) {
+ dev_err(motg->phy.dev, "unable to get hsusb 1p8\n");
+ return PTR_ERR(motg->v1p8);
+ }
+
+ motg->vddcx = devm_regulator_get(&pdev->dev, "HSUSB_VDDCX");
+ if (IS_ERR(motg->vddcx)) {
+ dev_err(motg->phy.dev, "unable to get hsusb vddcx\n");
+ return PTR_ERR(motg->vddcx);
+ }
+
clk_prepare_enable(motg->clk);
clk_prepare_enable(motg->pclk);
@@ -1492,7 +1480,7 @@ static int __init msm_otg_probe(struct platform_device *pdev)
dev_err(&pdev->dev, "hsusb vreg configuration failed\n");
goto vddcx_exit;
}
- ret = msm_hsusb_ldo_set_mode(1);
+ ret = msm_hsusb_ldo_set_mode(motg, 1);
if (ret) {
dev_err(&pdev->dev, "hsusb vreg enable failed\n");
goto ldo_exit;
@@ -1598,6 +1586,7 @@ static int msm_otg_remove(struct platform_device *pdev)
clk_put(motg->pclk_src);
}
msm_hsusb_ldo_init(motg, 0);
+ msm_hsusb_init_vddcx(motg, 0);
pm_runtime_set_suspended(&pdev->dev);
return 0;
diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h
index 66081ed..e01f7d4 100644
--- a/include/linux/usb/msm_hsusb.h
+++ b/include/linux/usb/msm_hsusb.h
@@ -182,6 +182,9 @@ struct msm_otg {
enum usb_chg_state chg_state;
enum usb_chg_type chg_type;
u8 dcd_retries;
+ struct regulator *v3p3;
+ struct regulator *v1p8;
+ struct regulator *vddcx;
};
#endif
--
1.7.9.5
From: "Ivan T. Ivanov" <[email protected]>
Use managed device resources to clean up the probe/remove
and get DT support for free.
Signed-off-by: Ivan T. Ivanov <[email protected]>
---
drivers/usb/phy/phy-msm-usb.c | 78 +++++++++++------------------------------
1 file changed, 20 insertions(+), 58 deletions(-)
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index ab1b880..cc37f5e 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1397,13 +1397,14 @@ static int __init msm_otg_probe(struct platform_device *pdev)
return -ENODEV;
}
- motg = kzalloc(sizeof(struct msm_otg), GFP_KERNEL);
+ motg = devm_kzalloc(&pdev->dev, sizeof(*motg), GFP_KERNEL);
if (!motg) {
dev_err(&pdev->dev, "unable to allocate msm_otg\n");
return -ENOMEM;
}
- motg->phy.otg = kzalloc(sizeof(struct usb_otg), GFP_KERNEL);
+ motg->phy.otg = devm_kzalloc(&pdev->dev, sizeof(*motg->phy.otg),
+ GFP_KERNEL);
if (!motg->phy.otg) {
dev_err(&pdev->dev, "unable to allocate msm_otg\n");
return -ENOMEM;
@@ -1413,18 +1414,16 @@ static int __init msm_otg_probe(struct platform_device *pdev)
phy = &motg->phy;
phy->dev = &pdev->dev;
- motg->phy_reset_clk = clk_get(&pdev->dev, "usb_phy_clk");
+ motg->phy_reset_clk = devm_clk_get(&pdev->dev, "usb_phy_clk");
if (IS_ERR(motg->phy_reset_clk)) {
dev_err(&pdev->dev, "failed to get usb_phy_clk\n");
- ret = PTR_ERR(motg->phy_reset_clk);
- goto free_motg;
+ return PTR_ERR(motg->phy_reset_clk);
}
- motg->clk = clk_get(&pdev->dev, "usb_hs_clk");
+ motg->clk = devm_clk_get(&pdev->dev, "usb_hs_clk");
if (IS_ERR(motg->clk)) {
dev_err(&pdev->dev, "failed to get usb_hs_clk\n");
- ret = PTR_ERR(motg->clk);
- goto put_phy_reset_clk;
+ return PTR_ERR(motg->clk);
}
clk_set_rate(motg->clk, 60000000);
@@ -1436,21 +1435,19 @@ static int __init msm_otg_probe(struct platform_device *pdev)
* on pclk source
*/
if (motg->pdata->pclk_src_name) {
- motg->pclk_src = clk_get(&pdev->dev,
+ motg->pclk_src = devm_clk_get(&pdev->dev,
motg->pdata->pclk_src_name);
if (IS_ERR(motg->pclk_src))
- goto put_clk;
+ return PTR_ERR(motg->pclk_src);
clk_set_rate(motg->pclk_src, INT_MAX);
clk_prepare_enable(motg->pclk_src);
} else
motg->pclk_src = ERR_PTR(-ENOENT);
-
- motg->pclk = clk_get(&pdev->dev, "usb_hs_pclk");
+ motg->pclk = devm_clk_get(&pdev->dev, "usb_hs_pclk");
if (IS_ERR(motg->pclk)) {
dev_err(&pdev->dev, "failed to get usb_hs_pclk\n");
- ret = PTR_ERR(motg->pclk);
- goto put_pclk_src;
+ return PTR_ERR(motg->pclk);
}
/*
@@ -1458,30 +1455,27 @@ static int __init msm_otg_probe(struct platform_device *pdev)
* clock is introduced to remove the dependency on AXI
* bus frequency.
*/
- motg->core_clk = clk_get(&pdev->dev, "usb_hs_core_clk");
+ motg->core_clk = devm_clk_get(&pdev->dev, "usb_hs_core_clk");
if (IS_ERR(motg->core_clk))
motg->core_clk = NULL;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
if (!res) {
dev_err(&pdev->dev, "failed to get platform resource mem\n");
- ret = -ENODEV;
- goto put_core_clk;
+ return -ENODEV;
}
- motg->regs = ioremap(res->start, resource_size(res));
+ motg->regs = devm_ioremap_resource(&pdev->dev, res);
if (!motg->regs) {
dev_err(&pdev->dev, "ioremap failed\n");
- ret = -ENOMEM;
- goto put_core_clk;
+ return PTR_ERR(motg->regs);
}
dev_info(&pdev->dev, "OTG regs = %p\n", motg->regs);
motg->irq = platform_get_irq(pdev, 0);
- if (!motg->irq) {
+ if (motg->irq < 0) {
dev_err(&pdev->dev, "platform_get_irq failed\n");
- ret = -ENODEV;
- goto free_regs;
+ return motg->irq;
}
clk_prepare_enable(motg->clk);
@@ -1490,7 +1484,7 @@ static int __init msm_otg_probe(struct platform_device *pdev)
ret = msm_hsusb_init_vddcx(motg, 1);
if (ret) {
dev_err(&pdev->dev, "hsusb vddcx configuration failed\n");
- goto free_regs;
+ return ret;
}
ret = msm_hsusb_ldo_init(motg, 1);
@@ -1512,7 +1506,7 @@ static int __init msm_otg_probe(struct platform_device *pdev)
INIT_WORK(&motg->sm_work, msm_otg_sm_work);
INIT_DELAYED_WORK(&motg->chg_work, msm_chg_detect_work);
- ret = request_irq(motg->irq, msm_otg_irq, IRQF_SHARED,
+ ret = devm_request_irq(&pdev->dev, motg->irq, msm_otg_irq, IRQF_SHARED,
"msm_otg", motg);
if (ret) {
dev_err(&pdev->dev, "request irq failed\n");
@@ -1531,7 +1525,7 @@ static int __init msm_otg_probe(struct platform_device *pdev)
ret = usb_add_phy(&motg->phy, USB_PHY_TYPE_USB2);
if (ret) {
dev_err(&pdev->dev, "usb_add_phy failed\n");
- goto free_irq;
+ goto disable_clks;
}
platform_set_drvdata(pdev, motg);
@@ -1549,8 +1543,6 @@ static int __init msm_otg_probe(struct platform_device *pdev)
pm_runtime_enable(&pdev->dev);
return 0;
-free_irq:
- free_irq(motg->irq, motg);
disable_clks:
clk_disable_unprepare(motg->pclk);
clk_disable_unprepare(motg->clk);
@@ -1558,24 +1550,6 @@ ldo_exit:
msm_hsusb_ldo_init(motg, 0);
vddcx_exit:
msm_hsusb_init_vddcx(motg, 0);
-free_regs:
- iounmap(motg->regs);
-put_core_clk:
- if (motg->core_clk)
- clk_put(motg->core_clk);
- clk_put(motg->pclk);
-put_pclk_src:
- if (!IS_ERR(motg->pclk_src)) {
- clk_disable_unprepare(motg->pclk_src);
- clk_put(motg->pclk_src);
- }
-put_clk:
- clk_put(motg->clk);
-put_phy_reset_clk:
- clk_put(motg->phy_reset_clk);
-free_motg:
- kfree(motg->phy.otg);
- kfree(motg);
return ret;
}
@@ -1598,7 +1572,6 @@ static int msm_otg_remove(struct platform_device *pdev)
pm_runtime_disable(&pdev->dev);
usb_remove_phy(phy);
- free_irq(motg->irq, motg);
/*
* Put PHY in low power mode.
@@ -1626,18 +1599,7 @@ static int msm_otg_remove(struct platform_device *pdev)
}
msm_hsusb_ldo_init(motg, 0);
- iounmap(motg->regs);
pm_runtime_set_suspended(&pdev->dev);
-
- clk_put(motg->phy_reset_clk);
- clk_put(motg->pclk);
- clk_put(motg->clk);
- if (motg->core_clk)
- clk_put(motg->core_clk);
-
- kfree(motg->phy.otg);
- kfree(motg);
-
return 0;
}
--
1.7.9.5
From: "Ivan T. Ivanov" <[email protected]>
Signed-off-by: Ivan T. Ivanov <[email protected]>
---
drivers/usb/phy/phy-msm-usb.c | 99 ++++++++++++++++++++++-------------------
1 file changed, 52 insertions(+), 47 deletions(-)
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 6d05085..111f454 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -45,18 +45,18 @@
#define ULPI_IO_TIMEOUT_USEC (10 * 1000)
-#define USB_PHY_3P3_VOL_MIN 3050000 /* uV */
-#define USB_PHY_3P3_VOL_MAX 3300000 /* uV */
+#define USB_PHY_3P3_VOL_MIN 3050000 /* uV */
+#define USB_PHY_3P3_VOL_MAX 3300000 /* uV */
#define USB_PHY_3P3_HPM_LOAD 50000 /* uA */
#define USB_PHY_3P3_LPM_LOAD 4000 /* uA */
-#define USB_PHY_1P8_VOL_MIN 1800000 /* uV */
-#define USB_PHY_1P8_VOL_MAX 1800000 /* uV */
+#define USB_PHY_1P8_VOL_MIN 1800000 /* uV */
+#define USB_PHY_1P8_VOL_MAX 1800000 /* uV */
#define USB_PHY_1P8_HPM_LOAD 50000 /* uA */
#define USB_PHY_1P8_LPM_LOAD 4000 /* uA */
-#define USB_PHY_VDD_DIG_VOL_MIN 1000000 /* uV */
-#define USB_PHY_VDD_DIG_VOL_MAX 1320000 /* uV */
+#define USB_PHY_VDD_DIG_VOL_MIN 1000000 /* uV */
+#define USB_PHY_VDD_DIG_VOL_MAX 1320000 /* uV */
static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init)
{
@@ -64,8 +64,8 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init)
if (init) {
ret = regulator_set_voltage(motg->vddcx,
- USB_PHY_VDD_DIG_VOL_MIN,
- USB_PHY_VDD_DIG_VOL_MAX);
+ USB_PHY_VDD_DIG_VOL_MIN,
+ USB_PHY_VDD_DIG_VOL_MAX);
if (ret) {
dev_err(motg->phy.dev, "Cannot set vddcx voltage\n");
return ret;
@@ -73,15 +73,17 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init)
ret = regulator_enable(motg->vddcx);
if (ret)
- dev_err(motg->phy.dev, "unable to enable hsusb vddcx\n");
+ dev_err(motg->phy.dev,
+ "unable to enable hsusb vddcx\n");
} else {
ret = regulator_set_voltage(motg->vddcx, 0,
- USB_PHY_VDD_DIG_VOL_MAX);
+ USB_PHY_VDD_DIG_VOL_MAX);
if (ret)
dev_err(motg->phy.dev, "Cannot set vddcx voltage\n");
ret = regulator_disable(motg->vddcx);
if (ret)
- dev_err(motg->phy.dev, "unable to disable hsusb vddcx\n");
+ dev_err(motg->phy.dev,
+ "unable to disable hsusb vddcx\n");
}
return ret;
@@ -93,26 +95,28 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int init)
if (init) {
rc = regulator_set_voltage(motg->v3p3, USB_PHY_3P3_VOL_MIN,
- USB_PHY_3P3_VOL_MAX);
+ USB_PHY_3P3_VOL_MAX);
if (rc) {
dev_err(motg->phy.dev, "Cannot set v3p3 voltage\n");
return rc;
}
rc = regulator_enable(motg->v3p3);
if (rc) {
- dev_err(motg->phy.dev, "unable to enable the hsusb 3p3\n");
+ dev_err(motg->phy.dev,
+ "unable to enable the hsusb 3p3\n");
return rc;
}
rc = regulator_set_voltage(motg->v1p8, USB_PHY_1P8_VOL_MIN,
- USB_PHY_1P8_VOL_MAX);
+ USB_PHY_1P8_VOL_MAX);
if (rc) {
dev_err(motg->phy.dev, "Cannot set v1p8 voltage\n");
goto disable_3p3;
}
rc = regulator_enable(motg->v1p8);
if (rc) {
- dev_err(motg->phy.dev, "unable to enable the hsusb 1p8\n");
+ dev_err(motg->phy.dev,
+ "unable to enable the hsusb 1p8\n");
goto disable_3p3;
}
@@ -156,26 +160,26 @@ static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, int on)
if (on) {
ret = regulator_set_optimum_mode(motg->v1p8,
- USB_PHY_1P8_HPM_LOAD);
+ USB_PHY_1P8_HPM_LOAD);
if (ret < 0) {
pr_err("Could not set HPM for v1p8\n");
return ret;
}
ret = regulator_set_optimum_mode(motg->v3p3,
- USB_PHY_3P3_HPM_LOAD);
+ USB_PHY_3P3_HPM_LOAD);
if (ret < 0) {
pr_err("Could not set HPM for v3p3\n");
regulator_set_optimum_mode(motg->v1p8,
- USB_PHY_1P8_LPM_LOAD);
+ USB_PHY_1P8_LPM_LOAD);
return ret;
}
} else {
ret = regulator_set_optimum_mode(motg->v1p8,
- USB_PHY_1P8_LPM_LOAD);
+ USB_PHY_1P8_LPM_LOAD);
if (ret < 0)
pr_err("Could not set LPM for v1p8\n");
ret = regulator_set_optimum_mode(motg->v3p3,
- USB_PHY_3P3_LPM_LOAD);
+ USB_PHY_3P3_LPM_LOAD);
if (ret < 0)
pr_err("Could not set LPM for v3p3\n");
}
@@ -190,8 +194,7 @@ static int ulpi_read(struct usb_phy *phy, u32 reg)
int cnt = 0;
/* initiate read operation */
- writel(ULPI_RUN | ULPI_READ | ULPI_ADDR(reg),
- USB_ULPI_VIEWPORT);
+ writel(ULPI_RUN | ULPI_READ | ULPI_ADDR(reg), USB_ULPI_VIEWPORT);
/* wait for completion */
while (cnt < ULPI_IO_TIMEOUT_USEC) {
@@ -216,8 +219,7 @@ static int ulpi_write(struct usb_phy *phy, u32 val, u32 reg)
/* initiate write operation */
writel(ULPI_RUN | ULPI_WRITE |
- ULPI_ADDR(reg) | ULPI_DATA(val),
- USB_ULPI_VIEWPORT);
+ ULPI_ADDR(reg) | ULPI_DATA(val), USB_ULPI_VIEWPORT);
/* wait for completion */
while (cnt < ULPI_IO_TIMEOUT_USEC) {
@@ -249,7 +251,7 @@ static void ulpi_init(struct msm_otg *motg)
while (seq[0] >= 0) {
dev_vdbg(motg->phy.dev, "ulpi: write 0x%02x to 0x%02x\n",
- seq[0], seq[1]);
+ seq[0], seq[1]);
ulpi_write(&motg->phy, seq[0], seq[1]);
seq += 2;
}
@@ -277,7 +279,7 @@ static int msm_otg_phy_reset(struct msm_otg *motg)
for (retries = 3; retries > 0; retries--) {
ret = ulpi_write(&motg->phy, ULPI_FUNC_CTRL_SUSPENDM,
- ULPI_CLR(ULPI_FUNC_CTRL));
+ ULPI_CLR(ULPI_FUNC_CTRL));
if (!ret)
break;
ret = pdata->phy_clk_reset(motg->phy_reset_clk);
@@ -429,7 +431,7 @@ static int msm_otg_suspend(struct msm_otg *motg)
writel(readl(USB_USBCMD) | ASYNC_INTR_CTRL | ULPI_STP_CTRL, USB_USBCMD);
if (motg->pdata->phy_type == SNPS_28NM_INTEGRATED_PHY &&
- motg->pdata->otg_control == OTG_PMIC_CONTROL)
+ motg->pdata->otg_control == OTG_PMIC_CONTROL)
writel(readl(USB_PHY_CTRL) | PHY_RETEN, USB_PHY_CTRL);
clk_disable_unprepare(motg->pclk);
@@ -441,7 +443,7 @@ static int msm_otg_suspend(struct msm_otg *motg)
clk_disable_unprepare(motg->pclk_src);
if (motg->pdata->phy_type == SNPS_28NM_INTEGRATED_PHY &&
- motg->pdata->otg_control == OTG_PMIC_CONTROL) {
+ motg->pdata->otg_control == OTG_PMIC_CONTROL) {
msm_hsusb_ldo_set_mode(motg, 0);
msm_hsusb_config_vddcx(motg, 0);
}
@@ -478,7 +480,7 @@ static int msm_otg_resume(struct msm_otg *motg)
clk_prepare_enable(motg->core_clk);
if (motg->pdata->phy_type == SNPS_28NM_INTEGRATED_PHY &&
- motg->pdata->otg_control == OTG_PMIC_CONTROL) {
+ motg->pdata->otg_control == OTG_PMIC_CONTROL) {
msm_hsusb_ldo_set_mode(motg, 1);
msm_hsusb_config_vddcx(motg, 1);
writel(readl(USB_PHY_CTRL) & ~PHY_RETEN, USB_PHY_CTRL);
@@ -510,7 +512,8 @@ static int msm_otg_resume(struct msm_otg *motg)
* PHY. USB state can not be restored. Re-insertion
* of USB cable is the only way to get USB working.
*/
- dev_err(phy->dev, "Unable to resume USB. Re-plugin the cable\n");
+ dev_err(phy->dev,
+ "Unable to resume USB. Re-plugin the cable\n");
msm_otg_reset(phy);
}
@@ -674,7 +677,7 @@ static void msm_otg_start_peripheral(struct usb_phy *phy, int on)
}
static int msm_otg_set_peripheral(struct usb_otg *otg,
- struct usb_gadget *gadget)
+ struct usb_gadget *gadget)
{
struct msm_otg *motg = container_of(otg->phy, struct msm_otg, phy);
@@ -948,10 +951,10 @@ static void msm_chg_block_off(struct msm_otg *motg)
ulpi_write(phy, func_ctrl, ULPI_FUNC_CTRL);
}
-#define MSM_CHG_DCD_POLL_TIME (100 * HZ/1000) /* 100 msec */
-#define MSM_CHG_DCD_MAX_RETRIES 6 /* Tdcd_tmout = 6 * 100 msec */
-#define MSM_CHG_PRIMARY_DET_TIME (40 * HZ/1000) /* TVDPSRC_ON */
-#define MSM_CHG_SECONDARY_DET_TIME (40 * HZ/1000) /* TVDMSRC_ON */
+#define MSM_CHG_DCD_POLL_TIME (100 * HZ/1000) /* 100 msec */
+#define MSM_CHG_DCD_MAX_RETRIES 6 /* Tdcd_tmout = 6 * 100 msec */
+#define MSM_CHG_PRIMARY_DET_TIME (40 * HZ/1000) /* TVDPSRC_ON */
+#define MSM_CHG_SECONDARY_DET_TIME (40 * HZ/1000) /* TVDMSRC_ON */
static void msm_chg_detect_work(struct work_struct *w)
{
struct msm_otg *motg = container_of(w, struct msm_otg, chg_work.work);
@@ -1094,20 +1097,20 @@ static void msm_otg_sm_work(struct work_struct *w)
switch (motg->chg_type) {
case USB_DCP_CHARGER:
msm_otg_notify_charger(motg,
- IDEV_CHG_MAX);
+ IDEV_CHG_MAX);
break;
case USB_CDP_CHARGER:
msm_otg_notify_charger(motg,
- IDEV_CHG_MAX);
+ IDEV_CHG_MAX);
msm_otg_start_peripheral(otg->phy, 1);
otg->phy->state
- = OTG_STATE_B_PERIPHERAL;
+ = OTG_STATE_B_PERIPHERAL;
break;
case USB_SDP_CHARGER:
msm_otg_notify_charger(motg, IUNIT);
msm_otg_start_peripheral(otg->phy, 1);
otg->phy->state
- = OTG_STATE_B_PERIPHERAL;
+ = OTG_STATE_B_PERIPHERAL;
break;
default:
break;
@@ -1135,7 +1138,7 @@ static void msm_otg_sm_work(struct work_struct *w)
case OTG_STATE_B_PERIPHERAL:
dev_dbg(otg->phy->dev, "OTG_STATE_B_PERIPHERAL state\n");
if (!test_bit(B_SESS_VLD, &motg->inputs) ||
- !test_bit(ID, &motg->inputs)) {
+ !test_bit(ID, &motg->inputs)) {
msm_otg_notify_charger(motg, 0);
msm_otg_start_peripheral(otg->phy, 0);
motg->chg_state = USB_CHG_STATE_UNDEFINED;
@@ -1223,7 +1226,7 @@ static int msm_otg_mode_open(struct inode *inode, struct file *file)
}
static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
- size_t count, loff_t *ppos)
+ size_t count, loff_t *ppos)
{
struct seq_file *s = file->private_data;
struct msm_otg *motg = s->private;
@@ -1312,7 +1315,8 @@ static int msm_otg_debugfs_init(struct msm_otg *motg)
return -ENODEV;
msm_otg_dbg_mode = debugfs_create_file("mode", S_IRUGO | S_IWUSR,
- msm_otg_dbg_root, motg, &msm_otg_mode_fops);
+ msm_otg_dbg_root, motg,
+ &msm_otg_mode_fops);
if (!msm_otg_dbg_mode) {
debugfs_remove(msm_otg_dbg_root);
msm_otg_dbg_root = NULL;
@@ -1384,9 +1388,9 @@ static int __init msm_otg_probe(struct platform_device *pdev)
* CORE CLK. For such USB cores, vote for maximum clk frequency
* on pclk source
*/
- if (motg->pdata->pclk_src_name) {
+ if (motg->pdata->pclk_src_name) {
motg->pclk_src = devm_clk_get(&pdev->dev,
- motg->pdata->pclk_src_name);
+ motg->pdata->pclk_src_name);
if (IS_ERR(motg->pclk_src))
return PTR_ERR(motg->pclk_src);
clk_set_rate(motg->pclk_src, INT_MAX);
@@ -1475,7 +1479,7 @@ static int __init msm_otg_probe(struct platform_device *pdev)
INIT_WORK(&motg->sm_work, msm_otg_sm_work);
INIT_DELAYED_WORK(&motg->chg_work, msm_chg_detect_work);
ret = devm_request_irq(&pdev->dev, motg->irq, msm_otg_irq, IRQF_SHARED,
- "msm_otg", motg);
+ "msm_otg", motg);
if (ret) {
dev_err(&pdev->dev, "request irq failed\n");
goto disable_clks;
@@ -1500,10 +1504,11 @@ static int __init msm_otg_probe(struct platform_device *pdev)
device_init_wakeup(&pdev->dev, 1);
if (motg->pdata->mode == USB_OTG &&
- motg->pdata->otg_control == OTG_USER_CONTROL) {
+ motg->pdata->otg_control == OTG_USER_CONTROL) {
ret = msm_otg_debugfs_init(motg);
if (ret)
- dev_dbg(&pdev->dev, "Can not create mode change file\n");
+ dev_dbg(&pdev->dev,
+ "Can not create mode change file\n");
}
pm_runtime_set_active(&pdev->dev);
--
1.7.9.5
From: "Ivan T. Ivanov" <[email protected]>
This fixes checkpatch.pl warnings.
Signed-off-by: Ivan T. Ivanov <[email protected]>
---
drivers/usb/phy/phy-msm-usb.c | 33 +++++++++++----------------------
1 file changed, 11 insertions(+), 22 deletions(-)
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 0e7d7ab..41938e6 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -67,8 +67,7 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init)
USB_PHY_VDD_DIG_VOL_MIN,
USB_PHY_VDD_DIG_VOL_MAX);
if (ret) {
- dev_err(motg->phy.dev, "unable to set the voltage "
- "for hsusb vddcx\n");
+ dev_err(motg->phy.dev, "Cannot set vddcx voltage\n");
return ret;
}
@@ -79,8 +78,7 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init)
ret = regulator_set_voltage(motg->vddcx, 0,
USB_PHY_VDD_DIG_VOL_MAX);
if (ret)
- dev_err(motg->phy.dev, "unable to set the voltage "
- "for hsusb vddcx\n");
+ dev_err(motg->phy.dev, "Cannot set vddcx voltage\n");
ret = regulator_disable(motg->vddcx);
if (ret)
dev_err(motg->phy.dev, "unable to disable hsusb vddcx\n");
@@ -97,8 +95,7 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int init)
rc = regulator_set_voltage(motg->v3p3, USB_PHY_3P3_VOL_MIN,
USB_PHY_3P3_VOL_MAX);
if (rc) {
- dev_err(motg->phy.dev, "unable to set voltage level "
- "for hsusb 3p3\n");
+ dev_err(motg->phy.dev, "Cannot set v3p3 voltage\n");
return rc;
}
rc = regulator_enable(motg->v3p3);
@@ -110,8 +107,7 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int init)
rc = regulator_set_voltage(motg->v1p8, USB_PHY_1P8_VOL_MIN,
USB_PHY_1P8_VOL_MAX);
if (rc) {
- dev_err(motg->phy.dev, "unable to set voltage level "
- "for hsusb 1p8\n");
+ dev_err(motg->phy.dev, "Cannot set v1p8 voltage\n");
goto disable_3p3;
}
rc = regulator_enable(motg->v1p8);
@@ -144,8 +140,7 @@ static int msm_hsusb_config_vddcx(struct msm_otg *motg, int high)
ret = regulator_set_voltage(motg->vddcx, min_vol, max_vol);
if (ret) {
- pr_err("%s: unable to set the voltage for regulator "
- "HSUSB_VDDCX\n", __func__);
+ dev_err(motg->phy.dev, "Cannot set vddcx voltage\n");
return ret;
}
@@ -163,15 +158,13 @@ static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, int on)
ret = regulator_set_optimum_mode(motg->v1p8,
USB_PHY_1P8_HPM_LOAD);
if (ret < 0) {
- pr_err("%s: Unable to set HPM of the regulator "
- "HSUSB_1p8\n", __func__);
+ pr_err("Could not set HPM for v1p8\n");
return ret;
}
ret = regulator_set_optimum_mode(motg->v3p3,
USB_PHY_3P3_HPM_LOAD);
if (ret < 0) {
- pr_err("%s: Unable to set HPM of the regulator "
- "HSUSB_3p3\n", __func__);
+ pr_err("Could not set HPM for v3p3\n");
regulator_set_optimum_mode(motg->v1p8,
USB_PHY_1P8_LPM_LOAD);
return ret;
@@ -180,13 +173,11 @@ static int msm_hsusb_ldo_set_mode(struct msm_otg *motg, int on)
ret = regulator_set_optimum_mode(motg->v1p8,
USB_PHY_1P8_LPM_LOAD);
if (ret < 0)
- pr_err("%s: Unable to set LPM of the regulator "
- "HSUSB_1p8\n", __func__);
+ pr_err("Could not set LPM for v1p8\n");
ret = regulator_set_optimum_mode(motg->v3p3,
USB_PHY_3P3_LPM_LOAD);
if (ret < 0)
- pr_err("%s: Unable to set LPM of the regulator "
- "HSUSB_3p3\n", __func__);
+ pr_err("Could not set LPM for v3p3\n");
}
pr_debug("reg (%s)\n", on ? "HPM" : "LPM");
@@ -519,8 +510,7 @@ static int msm_otg_resume(struct msm_otg *motg)
* PHY. USB state can not be restored. Re-insertion
* of USB cable is the only way to get USB working.
*/
- dev_err(phy->dev, "Unable to resume USB."
- "Re-plugin the cable\n");
+ dev_err(phy->dev, "Unable to resume USB. Re-plugin the cable\n");
msm_otg_reset(phy);
}
@@ -1513,8 +1503,7 @@ static int __init msm_otg_probe(struct platform_device *pdev)
motg->pdata->otg_control == OTG_USER_CONTROL) {
ret = msm_otg_debugfs_init(motg);
if (ret)
- dev_dbg(&pdev->dev, "mode debugfs file is"
- "not available\n");
+ dev_dbg(&pdev->dev, "Can not create mode change file\n");
}
pm_runtime_set_active(&pdev->dev);
--
1.7.9.5
From: "Ivan T. Ivanov" <[email protected]>
This fixes checkpatch.pl warnings.
Signed-off-by: Ivan T. Ivanov <[email protected]>
---
drivers/usb/phy/phy-msm-usb.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 41938e6..6d05085 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1204,13 +1204,13 @@ static int msm_otg_mode_show(struct seq_file *s, void *unused)
switch (otg->phy->state) {
case OTG_STATE_A_HOST:
- seq_printf(s, "host\n");
+ seq_puts(s, "host\n");
break;
case OTG_STATE_B_PERIPHERAL:
- seq_printf(s, "peripheral\n");
+ seq_puts(s, "peripheral\n");
break;
default:
- seq_printf(s, "none\n");
+ seq_puts(s, "none\n");
break;
}
--
1.7.9.5
From: "Ivan T. Ivanov" <[email protected]>
This patch fix compilation error and is an intermediate step
before the addition of DeviceTree support for newer targets.
Fix suggested here: https://lkml.org/lkml/2013/6/19/381
Cc: David Brown <[email protected]>
Cc: Daniel Walker <[email protected]>
Cc: Bryan Huntsman <[email protected]>
Cc: Stephen Boyd <[email protected]>
Signed-off-by: Ivan T. Ivanov <[email protected]>
---
arch/arm/mach-msm/board-msm7x30.c | 35 +++++++++++++++++++++++
arch/arm/mach-msm/board-qsd8x50.c | 34 +++++++++++++++++++++++
drivers/usb/phy/phy-msm-usb.c | 55 ++++++++++---------------------------
include/linux/usb/msm_hsusb.h | 2 ++
4 files changed, 85 insertions(+), 41 deletions(-)
diff --git a/arch/arm/mach-msm/board-msm7x30.c b/arch/arm/mach-msm/board-msm7x30.c
index db3d8c0..4df7daa 100644
--- a/arch/arm/mach-msm/board-msm7x30.c
+++ b/arch/arm/mach-msm/board-msm7x30.c
@@ -31,6 +31,7 @@
#include <asm/setup.h>
#include <mach/board.h>
+#include <mach/clk.h>
#include <mach/msm_iomap.h>
#include <mach/dma.h>
@@ -61,10 +62,44 @@ static int hsusb_phy_init_seq[] = {
-1
};
+static int hsusb_phy_link_clk_reset(struct clk *link_clk, bool assert)
+{
+ int ret;
+
+ if (assert) {
+ ret = clk_reset(link_clk, CLK_RESET_ASSERT);
+ if (ret)
+ pr_err("usb hs_clk assert failed\n");
+ } else {
+ ret = clk_reset(link_clk, CLK_RESET_DEASSERT);
+ if (ret)
+ pr_err("usb hs_clk deassert failed\n");
+ }
+ return ret;
+}
+
+static int hsusb_phy_clk_reset(struct clk *phy_clk)
+{
+ int ret;
+
+ ret = clk_reset(phy_clk, CLK_RESET_ASSERT);
+ if (ret) {
+ pr_err("usb phy clk assert failed\n");
+ return ret;
+ }
+ usleep_range(10000, 12000);
+ ret = clk_reset(phy_clk, CLK_RESET_DEASSERT);
+ if (ret)
+ pr_err("usb phy clk deassert failed\n");
+ return ret;
+}
+
static struct msm_otg_platform_data msm_otg_pdata = {
.phy_init_seq = hsusb_phy_init_seq,
.mode = USB_PERIPHERAL,
.otg_control = OTG_PHY_CONTROL,
+ .phy_link_clk_reset = hsusb_phy_link_clk_reset,
+ .phy_phy_clk_reset = hsusb_phy_clk_reset,
};
struct msm_gpiomux_config msm_gpiomux_configs[GPIOMUX_NGPIOS] = {
diff --git a/arch/arm/mach-msm/board-qsd8x50.c b/arch/arm/mach-msm/board-qsd8x50.c
index f14a73d..d3d92ab 100644
--- a/arch/arm/mach-msm/board-qsd8x50.c
+++ b/arch/arm/mach-msm/board-qsd8x50.c
@@ -82,10 +82,44 @@ static int hsusb_phy_init_seq[] = {
-1
};
+static int hsusb_phy_link_clk_reset(struct clk *link_clk, bool assert)
+{
+ int ret;
+
+ if (assert) {
+ ret = clk_reset(link_clk, CLK_RESET_ASSERT);
+ if (ret)
+ pr_err("usb hs_clk assert failed\n");
+ } else {
+ ret = clk_reset(link_clk, CLK_RESET_DEASSERT);
+ if (ret)
+ pr_err("usb hs_clk deassert failed\n");
+ }
+ return ret;
+}
+
+static int hsusb_phy_clk_reset(struct clk *phy_clk)
+{
+ int ret;
+
+ ret = clk_reset(phy_clk, CLK_RESET_ASSERT);
+ if (ret) {
+ pr_err("usb phy clk assert failed\n");
+ return ret;
+ }
+ usleep_range(10000, 12000);
+ ret = clk_reset(phy_clk, CLK_RESET_DEASSERT);
+ if (ret)
+ pr_err("usb phy clk deassert failed\n");
+ return ret;
+}
+
static struct msm_otg_platform_data msm_otg_pdata = {
.phy_init_seq = hsusb_phy_init_seq,
.mode = USB_PERIPHERAL,
.otg_control = OTG_PHY_CONTROL,
+ .phy_link_clk_reset = hsusb_phy_link_clk_reset,
+ .phy_phy_clk_reset = hsusb_phy_clk_reset,
};
static struct platform_device *devices[] __initdata = {
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index d08f334..ab1b880 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -40,8 +40,6 @@
#include <linux/usb/msm_hsusb_hw.h>
#include <linux/regulator/consumer.h>
-#include <mach/clk.h>
-
#define MSM_USB_BASE (motg->regs)
#define DRIVER_NAME "msm_otg"
@@ -306,51 +304,20 @@ static void ulpi_init(struct msm_otg *motg)
}
}
-static int msm_otg_link_clk_reset(struct msm_otg *motg, bool assert)
-{
- int ret;
-
- if (assert) {
- ret = clk_reset(motg->clk, CLK_RESET_ASSERT);
- if (ret)
- dev_err(motg->phy.dev, "usb hs_clk assert failed\n");
- } else {
- ret = clk_reset(motg->clk, CLK_RESET_DEASSERT);
- if (ret)
- dev_err(motg->phy.dev, "usb hs_clk deassert failed\n");
- }
- return ret;
-}
-
-static int msm_otg_phy_clk_reset(struct msm_otg *motg)
-{
- int ret;
-
- ret = clk_reset(motg->phy_reset_clk, CLK_RESET_ASSERT);
- if (ret) {
- dev_err(motg->phy.dev, "usb phy clk assert failed\n");
- return ret;
- }
- usleep_range(10000, 12000);
- ret = clk_reset(motg->phy_reset_clk, CLK_RESET_DEASSERT);
- if (ret)
- dev_err(motg->phy.dev, "usb phy clk deassert failed\n");
- return ret;
-}
-
static int msm_otg_phy_reset(struct msm_otg *motg)
{
+ struct msm_otg_platform_data *pdata = motg->pdata;
u32 val;
int ret;
int retries;
- ret = msm_otg_link_clk_reset(motg, 1);
+ ret = pdata->phy_link_clk_reset(motg->clk, true);
if (ret)
return ret;
- ret = msm_otg_phy_clk_reset(motg);
+ ret = pdata->phy_clk_reset(motg->phy_reset_clk);
if (ret)
return ret;
- ret = msm_otg_link_clk_reset(motg, 0);
+ ret = pdata->phy_link_clk_reset(motg->clk, false);
if (ret)
return ret;
@@ -362,7 +329,7 @@ static int msm_otg_phy_reset(struct msm_otg *motg)
ULPI_CLR(ULPI_FUNC_CTRL));
if (!ret)
break;
- ret = msm_otg_phy_clk_reset(motg);
+ ret = pdata->phy_clk_reset(motg->phy_reset_clk);
if (ret)
return ret;
}
@@ -370,7 +337,7 @@ static int msm_otg_phy_reset(struct msm_otg *motg)
return -ETIMEDOUT;
/* This reset calibrates the phy, if the above write succeeded */
- ret = msm_otg_phy_clk_reset(motg);
+ ret = pdata->phy_clk_reset(motg->phy_reset_clk);
if (ret)
return ret;
@@ -378,7 +345,7 @@ static int msm_otg_phy_reset(struct msm_otg *motg)
ret = ulpi_read(&motg->phy, ULPI_DEBUG);
if (ret != -ETIMEDOUT)
break;
- ret = msm_otg_phy_clk_reset(motg);
+ ret = pdata->phy_clk_reset(motg->phy_reset_clk);
if (ret)
return ret;
}
@@ -1414,16 +1381,22 @@ static void msm_otg_debugfs_cleanup(void)
static int __init msm_otg_probe(struct platform_device *pdev)
{
int ret = 0;
+ struct msm_otg_platform_data *pdata = pdev->dev.platform_data;
struct resource *res;
struct msm_otg *motg;
struct usb_phy *phy;
dev_info(&pdev->dev, "msm_otg probe\n");
- if (!pdev->dev.platform_data) {
+ if (!pdata) {
dev_err(&pdev->dev, "No platform data given. Bailing out\n");
return -ENODEV;
}
+ if (!pdata->phy_clk_reset || !pdata->phy_link_clk_reset) {
+ dev_err(&pdev->dev, "No phy or link clock reset methods\n");
+ return -ENODEV;
+ }
+
motg = kzalloc(sizeof(struct msm_otg), GFP_KERNEL);
if (!motg) {
dev_err(&pdev->dev, "unable to allocate msm_otg\n");
diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h
index 22a396c..66081ed 100644
--- a/include/linux/usb/msm_hsusb.h
+++ b/include/linux/usb/msm_hsusb.h
@@ -135,6 +135,8 @@ struct msm_otg_platform_data {
enum msm_usb_phy_type phy_type;
void (*setup_gpio)(enum usb_otg_state state);
char *pclk_src_name;
+ int (*phy_link_clk_reset)(struct clk *link_clk, bool assert);
+ int (*phy_clk_reset)(struct clk *phy_clk);
};
/**
--
1.7.9.5
Hi Felipe,
On Tue, 2013-07-09 at 18:47 +0300, Ivan T. Ivanov wrote:
> From: "Ivan T. Ivanov" <[email protected]>
>
> Changes since first version.
> * Extend commit messages a little bit.
>
> Following patches make initial cleanup of usb phy found in the Qualcomm
> chipsets. Changes include:
> * Build time error fix.
> * Move driver to Managed Device Resource allocation.
> * Checkpatch warnings and error fixes
> * Removed usage of global regulators variables.
>
> Ivan T. Ivanov (7):
> usb: phy: msm: Move mach depndend code to platform data
> usb: phy: msm: Migrate to Managed Device Resource allocation
> usb: phy: msm: Move regulator usage to managed resource allocation
> usb: phy: msm: Remove unnecessarily check for valid regulators.
> usb: phy: msm: Fix WARNING: quoted string split across lines
> usb: phy: msm: Fix WARNING: Prefer seq_puts to seq_printf
> usb: phy: msm: Lindent the code
Could you take a look at these patches, please.
I would like to clean up this driver and add support for
controllers which can be found in new MSM8974 chipsets.
If there is something, which you would like to see improved
in this driver, please let me know.
Regards,
Ivan
>
> arch/arm/mach-msm/board-msm7x30.c | 35 ++++
> arch/arm/mach-msm/board-qsd8x50.c | 34 ++++
> drivers/usb/phy/phy-msm-usb.c | 384 ++++++++++++++-----------------------
> include/linux/usb/msm_hsusb.h | 5 +
> 4 files changed, 220 insertions(+), 238 deletions(-)
>
On Tue, Jul 09, 2013 at 06:47:07PM +0300, Ivan T. Ivanov wrote:
> From: "Ivan T. Ivanov" <[email protected]>
>
> This patch fix compilation error and is an intermediate step
> before the addition of DeviceTree support for newer targets.
> Fix suggested here: https://lkml.org/lkml/2013/6/19/381
>
> Cc: David Brown <[email protected]>
> Cc: Daniel Walker <[email protected]>
> Cc: Bryan Huntsman <[email protected]>
> Cc: Stephen Boyd <[email protected]>
>
> Signed-off-by: Ivan T. Ivanov <[email protected]>
I need Acks for arch/arm/*, I'll drop these from my TODO until it's
resent with proper Acks.
--
balbi
On Wed, Jul 24, 2013 at 03:34:43PM +0300, Felipe Balbi wrote:
> On Tue, Jul 09, 2013 at 06:47:07PM +0300, Ivan T. Ivanov wrote:
> > From: "Ivan T. Ivanov" <[email protected]>
> >
> > This patch fix compilation error and is an intermediate step
> > before the addition of DeviceTree support for newer targets.
> > Fix suggested here: https://lkml.org/lkml/2013/6/19/381
> >
> > Cc: David Brown <[email protected]>
> > Cc: Daniel Walker <[email protected]>
> > Cc: Bryan Huntsman <[email protected]>
> > Cc: Stephen Boyd <[email protected]>
> >
> > Signed-off-by: Ivan T. Ivanov <[email protected]>
>
> I need Acks for arch/arm/*, I'll drop these from my TODO until it's
> resent with proper Acks.
btw, you better start using drivers/reset for device-side reset
assertion-deassertion.
cheers
--
balbi
Hi,
On Tue, Jul 09, 2013 at 06:47:08PM +0300, Ivan T. Ivanov wrote:
> From: "Ivan T. Ivanov" <[email protected]>
>
> Use managed device resources to clean up the probe/remove
> and get DT support for free.
>
> Signed-off-by: Ivan T. Ivanov <[email protected]>
> ---
> drivers/usb/phy/phy-msm-usb.c | 78 +++++++++++------------------------------
> 1 file changed, 20 insertions(+), 58 deletions(-)
>
> diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
> index ab1b880..cc37f5e 100644
> --- a/drivers/usb/phy/phy-msm-usb.c
> +++ b/drivers/usb/phy/phy-msm-usb.c
> @@ -1458,30 +1455,27 @@ static int __init msm_otg_probe(struct platform_device *pdev)
> * clock is introduced to remove the dependency on AXI
> * bus frequency.
> */
> - motg->core_clk = clk_get(&pdev->dev, "usb_hs_core_clk");
> + motg->core_clk = devm_clk_get(&pdev->dev, "usb_hs_core_clk");
> if (IS_ERR(motg->core_clk))
> motg->core_clk = NULL;
>
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> if (!res) {
no need to check for the resource when using devm_ioremap_resource()
> dev_err(&pdev->dev, "failed to get platform resource mem\n");
> - ret = -ENODEV;
> - goto put_core_clk;
> + return -ENODEV;
> }
>
> - motg->regs = ioremap(res->start, resource_size(res));
> + motg->regs = devm_ioremap_resource(&pdev->dev, res);
> if (!motg->regs) {
> dev_err(&pdev->dev, "ioremap failed\n");
don't print error messages when using devm_ioremap_resource()
--
balbi
On Tue, Jul 09, 2013 at 06:47:09PM +0300, Ivan T. Ivanov wrote:
> From: "Ivan T. Ivanov" <[email protected]>
>
> This patch move global regulators variables to driver state
> structire and move allocation of the regulators to be devm managed.
split into two patches please. One for moving the global regulators into
your structure and a separate patch to move to devm_*
--
balbi
Hi,
On Wed, 2013-07-24 at 15:38 +0300, Felipe Balbi wrote:
> Hi,
>
> On Tue, Jul 09, 2013 at 06:47:08PM +0300, Ivan T. Ivanov wrote:
> > From: "Ivan T. Ivanov" <[email protected]>
> >
> > Use managed device resources to clean up the probe/remove
> > and get DT support for free.
> >
> > Signed-off-by: Ivan T. Ivanov <[email protected]>
> > ---
> > drivers/usb/phy/phy-msm-usb.c | 78 +++++++++++------------------------------
> > 1 file changed, 20 insertions(+), 58 deletions(-)
> >
> > diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
> > index ab1b880..cc37f5e 100644
> > --- a/drivers/usb/phy/phy-msm-usb.c
> > +++ b/drivers/usb/phy/phy-msm-usb.c
> > @@ -1458,30 +1455,27 @@ static int __init msm_otg_probe(struct platform_device *pdev)
> > * clock is introduced to remove the dependency on AXI
> > * bus frequency.
> > */
> > - motg->core_clk = clk_get(&pdev->dev, "usb_hs_core_clk");
> > + motg->core_clk = devm_clk_get(&pdev->dev, "usb_hs_core_clk");
> > if (IS_ERR(motg->core_clk))
> > motg->core_clk = NULL;
> >
> > res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > if (!res) {
>
> no need to check for the resource when using devm_ioremap_resource()
>
> > dev_err(&pdev->dev, "failed to get platform resource mem\n");
> > - ret = -ENODEV;
> > - goto put_core_clk;
> > + return -ENODEV;
> > }
> >
> > - motg->regs = ioremap(res->start, resource_size(res));
> > + motg->regs = devm_ioremap_resource(&pdev->dev, res);
> > if (!motg->regs) {
> > dev_err(&pdev->dev, "ioremap failed\n");
>
> don't print error messages when using devm_ioremap_resource()
Will fix these places and re-send,
Thank you,
Ivan
On Wed, 2013-07-24 at 15:39 +0300, Felipe Balbi wrote:
> On Tue, Jul 09, 2013 at 06:47:09PM +0300, Ivan T. Ivanov wrote:
> > From: "Ivan T. Ivanov" <[email protected]>
> >
> > This patch move global regulators variables to driver state
> > structire and move allocation of the regulators to be devm managed.
>
> split into two patches please. One for moving the global regulators into
> your structure and a separate patch to move to devm_*
>
Ok, will do and resend.
Ivan
Hi Felipe,
On Thu, 2013-07-25 at 16:43 +0300, Ivan T. Ivanov wrote:
> On Wed, 2013-07-24 at 15:39 +0300, Felipe Balbi wrote:
> > On Tue, Jul 09, 2013 at 06:47:09PM +0300, Ivan T. Ivanov wrote:
> > > From: "Ivan T. Ivanov" <[email protected]>
> > >
> > > This patch move global regulators variables to driver state
> > > structire and move allocation of the regulators to be devm managed.
> >
> > split into two patches please. One for moving the global regulators into
> > your structure and a separate patch to move to devm_*
> >
Would you accept patch which convert all resources allocation to devm_
variants in single patch or you prefer separate patches for memory,
clocks, regulators and irq?
Regards,
Ivan
>
> Ok, will do and resend.
>
> Ivan
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
> the body of a message to [email protected]
> More majordomo info at http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
On Fri, Jul 26, 2013 at 03:31:34PM +0300, Ivan T. Ivanov wrote:
>
> Hi Felipe,
>
> On Thu, 2013-07-25 at 16:43 +0300, Ivan T. Ivanov wrote:
> > On Wed, 2013-07-24 at 15:39 +0300, Felipe Balbi wrote:
> > > On Tue, Jul 09, 2013 at 06:47:09PM +0300, Ivan T. Ivanov wrote:
> > > > From: "Ivan T. Ivanov" <[email protected]>
> > > >
> > > > This patch move global regulators variables to driver state
> > > > structire and move allocation of the regulators to be devm managed.
> > >
> > > split into two patches please. One for moving the global regulators into
> > > your structure and a separate patch to move to devm_*
> > >
>
> Would you accept patch which convert all resources allocation to devm_
> variants in single patch or you prefer separate patches for memory,
> clocks, regulators and irq?
devm_* all over the place should be fine ;-)
--
balbi
On Fri, 2013-07-26 at 23:28 +0300, Felipe Balbi wrote:
> On Fri, Jul 26, 2013 at 03:31:34PM +0300, Ivan T. Ivanov wrote:
> >
> > Hi Felipe,
> >
> > On Thu, 2013-07-25 at 16:43 +0300, Ivan T. Ivanov wrote:
> > > On Wed, 2013-07-24 at 15:39 +0300, Felipe Balbi wrote:
> > > > On Tue, Jul 09, 2013 at 06:47:09PM +0300, Ivan T. Ivanov wrote:
> > > > > From: "Ivan T. Ivanov" <[email protected]>
> > > > >
> > > > > This patch move global regulators variables to driver state
> > > > > structire and move allocation of the regulators to be devm managed.
> > > >
> > > > split into two patches please. One for moving the global regulators into
> > > > your structure and a separate patch to move to devm_*
> > > >
> >
> > Would you accept patch which convert all resources allocation to devm_
> > variants in single patch or you prefer separate patches for memory,
> > clocks, regulators and irq?
>
> devm_* all over the place should be fine ;-)
>
Thanks, it is coming.
Regards,
Ivan