linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v3 00/13] usb: phy: msm: Fixes, cleanups and DT support
@ 2013-10-14 15:24 Ivan T. Ivanov
  2013-10-14 15:24 ` [PATCH v3 01/13] usb: phy: msm: Move mach depndend code to platform data Ivan T. Ivanov
                   ` (12 more replies)
  0 siblings, 13 replies; 19+ messages in thread
From: Ivan T. Ivanov @ 2013-10-14 15:24 UTC (permalink / raw)
  To: balbi
  Cc: rob.herring, pawel.moll, mark.rutland, swarren, ijc+devicetree,
	rob, davidb, dwalker, bryanh, linux, gregkh, grant.likely, jackp,
	mgautam, dsegal, linux-usb, devicetree, linux-doc, linux-kernel,
	linux-arm-msm, linux-arm-kernel, Ivan T. Ivanov

From: "Ivan T. Ivanov" <iivanov@mm-sol.com>

Hi, 

This is third version of MSM OTG clean up patches.
 
v3
--
* In patch 1 - functions for reseting PHY and LINK controller just
  call platform code if available.
* New stuff is: cleaning up unneeded/unused driver state variables
* Simplified regulator names. There is no references to these names
  in tree, so there should not be a problem with this.
* Replace the USB specific clock names with the more standard 'core' 
  and 'iface' ... names.   
* Added devicetree support 

v2
--
* Fix compilation issue in patch 1
* Separate regulator changes
* Merge devm_ related changes to one commit
* Drop Lindent patch

v1
--
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 (13):
  usb: phy: msm: Move mach depndend code to platform data
  usb: phy: msm: Move global regulators variables to driver state
  usb: phy: msm: Migrate to Managed Device 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: Replace custom enum usb_mode_type with enum
    usb_dr_mode
  usb: phy: msm: Drop default usb_dr_mode from platform data.
  usb: phy: msm: Remove unused pclk_src_name
  usb: phy: msm: Switch clock consumer strings
  usb: phy: msm: Remove HSUSB prefix from requlator names
  usb: phy: msm: Properly check core interrupt number
  usb: phy: msm: Add device tree support and binding information

 .../devicetree/bindings/usb/msm-hsusb.txt          |   58 +++
 arch/arm/mach-msm/board-msm7x30.c                  |   37 +-
 arch/arm/mach-msm/board-qsd8x50.c                  |   37 +-
 arch/arm/mach-msm/devices-msm7x00.c                |    4 +-
 arch/arm/mach-msm/devices-msm7x30.c                |    8 +-
 arch/arm/mach-msm/devices-qsd8x50.c                |    6 +-
 drivers/usb/phy/phy-msm-usb.c                      |  470 +++++++++-----------
 include/linux/usb/msm_hsusb.h                      |   45 +-
 8 files changed, 362 insertions(+), 303 deletions(-)

-- 
1.7.9.5


^ permalink raw reply	[flat|nested] 19+ messages in thread

* [PATCH v3 01/13] usb: phy: msm: Move mach depndend code to platform data
  2013-10-14 15:24 [PATCH v3 00/13] usb: phy: msm: Fixes, cleanups and DT support Ivan T. Ivanov
@ 2013-10-14 15:24 ` Ivan T. Ivanov
  2013-10-14 22:52   ` Felipe Balbi
  2013-10-14 15:24 ` [PATCH v3 02/13] usb: phy: msm: Move global regulators variables to driver state Ivan T. Ivanov
                   ` (11 subsequent siblings)
  12 siblings, 1 reply; 19+ messages in thread
From: Ivan T. Ivanov @ 2013-10-14 15:24 UTC (permalink / raw)
  To: balbi
  Cc: rob.herring, pawel.moll, mark.rutland, swarren, ijc+devicetree,
	rob, davidb, dwalker, bryanh, linux, gregkh, grant.likely, jackp,
	mgautam, dsegal, linux-usb, devicetree, linux-doc, linux-kernel,
	linux-arm-msm, linux-arm-kernel, Ivan T. Ivanov

From: "Ivan T. Ivanov" <iivanov@mm-sol.com>

This patch fix compilation error and is an intermediate step
before the addition of DeviceTree support for newer targets.

Cc: David Brown <davidb@codeaurora.org>
Cc: Daniel Walker <dwalker@fifo99.com>
Cc: Felipe Balbi <balbi@ti.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com>
---
 arch/arm/mach-msm/board-msm7x30.c |   35 +++++++++++++++++++++++++++++++++++
 arch/arm/mach-msm/board-qsd8x50.c |   35 +++++++++++++++++++++++++++++++++++
 drivers/usb/phy/phy-msm-usb.c     |   34 ++++++++++++++--------------------
 include/linux/usb/msm_hsusb.h     |    3 +++
 4 files changed, 87 insertions(+), 20 deletions(-)

diff --git a/arch/arm/mach-msm/board-msm7x30.c b/arch/arm/mach-msm/board-msm7x30.c
index f9af5a4..46de789 100644
--- a/arch/arm/mach-msm/board-msm7x30.c
+++ b/arch/arm/mach-msm/board-msm7x30.c
@@ -30,6 +30,7 @@
 #include <asm/memory.h>
 #include <asm/setup.h>
 
+#include <mach/clk.h>
 #include <mach/msm_iomap.h>
 #include <mach/dma.h>
 
@@ -60,10 +61,44 @@ static int hsusb_phy_init_seq[] = {
 	-1
 };
 
+static int hsusb_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,
+	.link_clk_reset		= hsusb_link_clk_reset,
+	.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 5f933bc..9169ec3 100644
--- a/arch/arm/mach-msm/board-qsd8x50.c
+++ b/arch/arm/mach-msm/board-qsd8x50.c
@@ -31,6 +31,7 @@
 #include <mach/irqs.h>
 #include <mach/sirc.h>
 #include <mach/vreg.h>
+#include <mach/clk.h>
 #include <linux/platform_data/mmc-msm_sdcc.h>
 
 #include "devices.h"
@@ -81,10 +82,44 @@ static int hsusb_phy_init_seq[] = {
 	-1
 };
 
+static int hsusb_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,
+	.link_clk_reset		= hsusb_link_clk_reset,
+	.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 e9d4cd9..118798d 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"
 
@@ -308,33 +306,29 @@ static void ulpi_init(struct msm_otg *motg)
 
 static int msm_otg_link_clk_reset(struct msm_otg *motg, bool assert)
 {
-	int ret;
+	int ret = 0;
+
+	if (!motg->pdata->link_clk_reset)
+		return ret;
+
+	ret = motg->pdata->link_clk_reset(motg->clk, assert);
+	if (ret)
+		dev_err(motg->phy.dev, "usb link clk reset failed\n");
 
-	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;
+	int ret = 0;
 
-	ret = clk_reset(motg->phy_reset_clk, CLK_RESET_ASSERT);
-	if (ret) {
-		dev_err(motg->phy.dev, "usb phy clk assert failed\n");
+	if (!motg->pdata->phy_clk_reset)
 		return ret;
-	}
-	usleep_range(10000, 12000);
-	ret = clk_reset(motg->phy_reset_clk, CLK_RESET_DEASSERT);
+
+	ret = motg->pdata->phy_clk_reset(motg->phy_reset_clk);
 	if (ret)
-		dev_err(motg->phy.dev, "usb phy clk deassert failed\n");
+		dev_err(motg->phy.dev, "usb phy clk assert failed\n");
+
 	return ret;
 }
 
diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h
index 22a396c..3275483 100644
--- a/include/linux/usb/msm_hsusb.h
+++ b/include/linux/usb/msm_hsusb.h
@@ -20,6 +20,7 @@
 
 #include <linux/types.h>
 #include <linux/usb/otg.h>
+#include <linux/clk.h>
 
 /**
  * Supported USB modes
@@ -135,6 +136,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 (*link_clk_reset)(struct clk *link_clk, bool assert);
+	int (*phy_clk_reset)(struct clk *phy_clk);
 };
 
 /**
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 02/13] usb: phy: msm: Move global regulators variables to driver state
  2013-10-14 15:24 [PATCH v3 00/13] usb: phy: msm: Fixes, cleanups and DT support Ivan T. Ivanov
  2013-10-14 15:24 ` [PATCH v3 01/13] usb: phy: msm: Move mach depndend code to platform data Ivan T. Ivanov
@ 2013-10-14 15:24 ` Ivan T. Ivanov
  2013-10-14 22:52   ` Felipe Balbi
  2013-10-14 15:24 ` [PATCH v3 03/13] usb: phy: msm: Migrate to Managed Device Resource allocation Ivan T. Ivanov
                   ` (10 subsequent siblings)
  12 siblings, 1 reply; 19+ messages in thread
From: Ivan T. Ivanov @ 2013-10-14 15:24 UTC (permalink / raw)
  To: balbi
  Cc: rob.herring, pawel.moll, mark.rutland, swarren, ijc+devicetree,
	rob, davidb, dwalker, bryanh, linux, gregkh, grant.likely, jackp,
	mgautam, dsegal, linux-usb, devicetree, linux-doc, linux-kernel,
	linux-arm-msm, linux-arm-kernel, Ivan T. Ivanov

From: "Ivan T. Ivanov" <iivanov@mm-sol.com>

Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com>
---
 drivers/usb/phy/phy-msm-usb.c |   82 ++++++++++++++++++++---------------------
 include/linux/usb/msm_hsusb.h |    3 ++
 2 files changed, 42 insertions(+), 43 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 118798d..ab39ecb 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -58,47 +58,43 @@
 #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)) {
+		motg->vddcx = regulator_get(motg->phy.dev, "HSUSB_VDDCX");
+		if (IS_ERR(motg->vddcx)) {
 			dev_err(motg->phy.dev, "unable to get hsusb vddcx\n");
-			return PTR_ERR(hsusb_vddcx);
+			return PTR_ERR(motg->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);
+			regulator_put(motg->vddcx);
 			return ret;
 		}
 
-		ret = regulator_enable(hsusb_vddcx);
+		ret = regulator_enable(motg->vddcx);
 		if (ret) {
 			dev_err(motg->phy.dev, "unable to enable hsusb vddcx\n");
-			regulator_put(hsusb_vddcx);
+			regulator_put(motg->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);
+		regulator_put(motg->vddcx);
 	}
 
 	return ret;
@@ -109,38 +105,38 @@ 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)) {
+		motg->v3p3 = regulator_get(motg->phy.dev, "HSUSB_3p3");
+		if (IS_ERR(motg->v3p3)) {
 			dev_err(motg->phy.dev, "unable to get hsusb 3p3\n");
-			return PTR_ERR(hsusb_3p3);
+			return PTR_ERR(motg->v3p3);
 		}
 
-		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;
 		}
-		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)) {
+		motg->v1p8 = regulator_get(motg->phy.dev, "HSUSB_1p8");
+		if (IS_ERR(motg->v1p8)) {
 			dev_err(motg->phy.dev, "unable to get hsusb 1p8\n");
-			rc = PTR_ERR(hsusb_1p8);
+			rc = PTR_ERR(motg->v1p8);
 			goto disable_3p3;
 		}
-		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;
 		}
-		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;
@@ -149,19 +145,19 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int init)
 		return 0;
 	}
 
-	regulator_disable(hsusb_1p8);
+	regulator_disable(motg->v1p8);
 put_1p8:
-	regulator_put(hsusb_1p8);
+	regulator_put(motg->v1p8);
 disable_3p3:
-	regulator_disable(hsusb_3p3);
+	regulator_disable(motg->v3p3);
 put_3p3:
-	regulator_put(hsusb_3p3);
+	regulator_put(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 +168,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 +181,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 "
@@ -518,8 +514,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))
@@ -555,8 +551,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);
 	}
 
@@ -1519,7 +1515,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;
diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h
index 3275483..8705b01 100644
--- a/include/linux/usb/msm_hsusb.h
+++ b/include/linux/usb/msm_hsusb.h
@@ -183,6 +183,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


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 03/13] usb: phy: msm: Migrate to Managed Device Resource allocation
  2013-10-14 15:24 [PATCH v3 00/13] usb: phy: msm: Fixes, cleanups and DT support Ivan T. Ivanov
  2013-10-14 15:24 ` [PATCH v3 01/13] usb: phy: msm: Move mach depndend code to platform data Ivan T. Ivanov
  2013-10-14 15:24 ` [PATCH v3 02/13] usb: phy: msm: Move global regulators variables to driver state Ivan T. Ivanov
@ 2013-10-14 15:24 ` Ivan T. Ivanov
  2013-10-14 15:24 ` [PATCH v3 04/13] usb: phy: msm: Remove unnecessarily check for valid regulators Ivan T. Ivanov
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Ivan T. Ivanov @ 2013-10-14 15:24 UTC (permalink / raw)
  To: balbi
  Cc: rob.herring, pawel.moll, mark.rutland, swarren, ijc+devicetree,
	rob, davidb, dwalker, bryanh, linux, gregkh, grant.likely, jackp,
	mgautam, dsegal, linux-usb, devicetree, linux-doc, linux-kernel,
	linux-arm-msm, linux-arm-kernel, Ivan T. Ivanov

From: "Ivan T. Ivanov" <iivanov@mm-sol.com>

Move memory, regulators, clocks and irq allocation to
devm_* variants. Properly check for valid clk handles.

Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com>
---
 drivers/usb/phy/phy-msm-usb.c |  192 ++++++++++++++++-------------------------
 1 file changed, 74 insertions(+), 118 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index ab39ecb..136f063 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -63,27 +63,18 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init)
 	int ret = 0;
 
 	if (init) {
-		motg->vddcx = regulator_get(motg->phy.dev, "HSUSB_VDDCX");
-		if (IS_ERR(motg->vddcx)) {
-			dev_err(motg->phy.dev, "unable to get hsusb vddcx\n");
-			return PTR_ERR(motg->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(motg->vddcx);
 			return ret;
 		}
 
 		ret = regulator_enable(motg->vddcx);
-		if (ret) {
+		if (ret)
 			dev_err(motg->phy.dev, "unable to enable hsusb vddcx\n");
-			regulator_put(motg->vddcx);
-		}
 	} else {
 		ret = regulator_set_voltage(motg->vddcx, 0,
 			USB_PHY_VDD_DIG_VOL_MAX);
@@ -93,8 +84,6 @@ static int msm_hsusb_init_vddcx(struct msm_otg *motg, int init)
 		ret = regulator_disable(motg->vddcx);
 		if (ret)
 			dev_err(motg->phy.dev, "unable to disable hsusb vddcx\n");
-
-		regulator_put(motg->vddcx);
 	}
 
 	return ret;
@@ -105,53 +94,38 @@ static int msm_hsusb_ldo_init(struct msm_otg *motg, int init)
 	int rc = 0;
 
 	if (init) {
-		motg->v3p3 = regulator_get(motg->phy.dev, "HSUSB_3p3");
-		if (IS_ERR(motg->v3p3)) {
-			dev_err(motg->phy.dev, "unable to get hsusb 3p3\n");
-			return PTR_ERR(motg->v3p3);
-		}
-
 		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;
+			goto exit;
 		}
 		rc = regulator_enable(motg->v3p3);
 		if (rc) {
 			dev_err(motg->phy.dev, "unable to enable the hsusb 3p3\n");
-			goto put_3p3;
-		}
-		motg->v1p8 = regulator_get(motg->phy.dev, "HSUSB_1p8");
-		if (IS_ERR(motg->v1p8)) {
-			dev_err(motg->phy.dev, "unable to get hsusb 1p8\n");
-			rc = PTR_ERR(motg->v1p8);
-			goto disable_3p3;
+			goto exit;
 		}
 		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(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(motg->v1p8);
-put_1p8:
-	regulator_put(motg->v1p8);
 disable_3p3:
 	regulator_disable(motg->v3p3);
-put_3p3:
-	regulator_put(motg->v3p3);
+exit:
 	return rc;
 }
 
@@ -506,7 +480,7 @@ static int msm_otg_suspend(struct msm_otg *motg)
 
 	clk_disable_unprepare(motg->pclk);
 	clk_disable_unprepare(motg->clk);
-	if (motg->core_clk)
+	if (!IS_ERR(motg->core_clk))
 		clk_disable_unprepare(motg->core_clk);
 
 	if (!IS_ERR(motg->pclk_src))
@@ -546,7 +520,7 @@ static int msm_otg_resume(struct msm_otg *motg)
 
 	clk_prepare_enable(motg->pclk);
 	clk_prepare_enable(motg->clk);
-	if (motg->core_clk)
+	if (!IS_ERR(motg->core_clk))
 		clk_prepare_enable(motg->core_clk);
 
 	if (motg->pdata->phy_type == SNPS_28NM_INTEGRATED_PHY &&
@@ -1414,13 +1388,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(struct msm_otg), 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(struct usb_otg),
+				     GFP_KERNEL);
 	if (!motg->phy.otg) {
 		dev_err(&pdev->dev, "unable to allocate msm_otg\n");
 		return -ENOMEM;
@@ -1430,20 +1405,17 @@ 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);
 
 	/*
 	 * If USB Core is running its protocol engine based on CORE CLK,
@@ -1452,22 +1424,18 @@ static int __init msm_otg_probe(struct platform_device *pdev)
 	 * CORE CLK. For such USB cores, vote for maximum clk frequency
 	 * on pclk source
 	 */
+	 motg->pclk_src = ERR_PTR(-ENOENT);
 	 if (motg->pdata->pclk_src_name) {
-		motg->pclk_src = clk_get(&pdev->dev,
-			motg->pdata->pclk_src_name);
+		motg->pclk_src = devm_clk_get(&pdev->dev,
+					motg->pdata->pclk_src_name);
 		if (IS_ERR(motg->pclk_src))
-			goto put_clk;
-		clk_set_rate(motg->pclk_src, INT_MAX);
-		clk_prepare_enable(motg->pclk_src);
-	} else
-		motg->pclk_src = ERR_PTR(-ENOENT);
-
+			return PTR_ERR(motg->pclk_src);
+	}
 
-	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);
 	}
 
 	/*
@@ -1475,65 +1443,78 @@ 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");
-	if (IS_ERR(motg->core_clk))
-		motg->core_clk = NULL;
+	motg->core_clk = devm_clk_get(&pdev->dev, "usb_hs_core_clk");
 
 	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;
-	}
+	motg->regs = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(motg->regs))
+		return PTR_ERR(motg->regs);
 
-	motg->regs = ioremap(res->start, resource_size(res));
-	if (!motg->regs) {
-		dev_err(&pdev->dev, "ioremap failed\n");
-		ret = -ENOMEM;
-		goto put_core_clk;
-	}
 	dev_info(&pdev->dev, "OTG regs = %p\n", motg->regs);
 
 	motg->irq = platform_get_irq(pdev, 0);
 	if (!motg->irq) {
 		dev_err(&pdev->dev, "platform_get_irq failed\n");
-		ret = -ENODEV;
-		goto free_regs;
+		return motg->irq;
+	}
+
+	motg->vddcx = devm_regulator_get(motg->phy.dev, "HSUSB_VDDCX");
+	if (IS_ERR(motg->vddcx)) {
+		dev_err(motg->phy.dev, "unable to get hsusb vddcx\n");
+		return PTR_ERR(motg->vddcx);
+	}
+
+	motg->v3p3 = devm_regulator_get(motg->phy.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(motg->phy.dev, "HSUSB_1p8");
+	if (IS_ERR(motg->v1p8)) {
+		dev_err(motg->phy.dev, "unable to get hsusb 1p8\n");
+		return PTR_ERR(motg->v1p8);
+	}
+
+	clk_set_rate(motg->clk, 60000000);
+	if (!IS_ERR(motg->pclk_src)) {
+		clk_set_rate(motg->pclk_src, INT_MAX);
+		clk_prepare_enable(motg->pclk_src);
 	}
 
 	clk_prepare_enable(motg->clk);
 	clk_prepare_enable(motg->pclk);
 
+	if (!IS_ERR(motg->core_clk))
+		clk_prepare_enable(motg->core_clk);
+
 	ret = msm_hsusb_init_vddcx(motg, 1);
 	if (ret) {
 		dev_err(&pdev->dev, "hsusb vddcx configuration failed\n");
-		goto free_regs;
+		goto disable_clks;
 	}
 
 	ret = msm_hsusb_ldo_init(motg, 1);
 	if (ret) {
 		dev_err(&pdev->dev, "hsusb vreg configuration failed\n");
-		goto vddcx_exit;
+		goto disable_vddcx;
 	}
 	ret = msm_hsusb_ldo_set_mode(motg, 1);
 	if (ret) {
 		dev_err(&pdev->dev, "hsusb vreg enable failed\n");
-		goto ldo_exit;
+		goto disable_ldo;
 	}
 
-	if (motg->core_clk)
-		clk_prepare_enable(motg->core_clk);
-
 	writel(0, USB_USBINTR);
 	writel(0, USB_OTGSC);
 
 	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");
-		goto disable_clks;
+		goto disable_ldo;
 	}
 
 	phy->init = msm_otg_reset;
@@ -1548,7 +1529,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_ldo;
 	}
 
 	platform_set_drvdata(pdev, motg);
@@ -1566,33 +1547,18 @@ 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_ldo:
+	msm_hsusb_ldo_init(motg, 0);
+disable_vddcx:
+	msm_hsusb_init_vddcx(motg, 0);
 disable_clks:
 	clk_disable_unprepare(motg->pclk);
 	clk_disable_unprepare(motg->clk);
-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)) {
+	if (!IS_ERR(motg->core_clk))
+		clk_disable_unprepare(motg->core_clk);
+	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;
 }
 
@@ -1615,7 +1581,7 @@ static int msm_otg_remove(struct platform_device *pdev)
 	pm_runtime_disable(&pdev->dev);
 
 	usb_remove_phy(phy);
-	free_irq(motg->irq, motg);
+	disable_irq(motg->irq);
 
 	/*
 	 * Put PHY in low power mode.
@@ -1635,26 +1601,15 @@ static int msm_otg_remove(struct platform_device *pdev)
 
 	clk_disable_unprepare(motg->pclk);
 	clk_disable_unprepare(motg->clk);
-	if (motg->core_clk)
+	if (!IS_ERR(motg->core_clk))
 		clk_disable_unprepare(motg->core_clk);
-	if (!IS_ERR(motg->pclk_src)) {
+	if (!IS_ERR(motg->pclk_src))
 		clk_disable_unprepare(motg->pclk_src);
-		clk_put(motg->pclk_src);
-	}
+
 	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;
 }
 
@@ -1736,6 +1691,7 @@ static const struct dev_pm_ops msm_otg_dev_pm_ops = {
 #endif
 
 static struct platform_driver msm_otg_driver = {
+	.probe = msm_otg_probe,
 	.remove = msm_otg_remove,
 	.driver = {
 		.name = DRIVER_NAME,
@@ -1746,7 +1702,7 @@ static struct platform_driver msm_otg_driver = {
 	},
 };
 
-module_platform_driver_probe(msm_otg_driver, msm_otg_probe);
+module_platform_driver(msm_otg_driver);
 
 MODULE_LICENSE("GPL v2");
 MODULE_DESCRIPTION("MSM USB transceiver driver");
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 04/13] usb: phy: msm: Remove unnecessarily check for valid regulators.
  2013-10-14 15:24 [PATCH v3 00/13] usb: phy: msm: Fixes, cleanups and DT support Ivan T. Ivanov
                   ` (2 preceding siblings ...)
  2013-10-14 15:24 ` [PATCH v3 03/13] usb: phy: msm: Migrate to Managed Device Resource allocation Ivan T. Ivanov
@ 2013-10-14 15:24 ` Ivan T. Ivanov
  2013-10-14 15:24 ` [PATCH v3 05/13] usb: phy: msm: Fix WARNING: quoted string split across lines Ivan T. Ivanov
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Ivan T. Ivanov @ 2013-10-14 15:24 UTC (permalink / raw)
  To: balbi
  Cc: rob.herring, pawel.moll, mark.rutland, swarren, ijc+devicetree,
	rob, davidb, dwalker, bryanh, linux, gregkh, grant.likely, jackp,
	mgautam, dsegal, linux-usb, devicetree, linux-doc, linux-kernel,
	linux-arm-msm, linux-arm-kernel, Ivan T. Ivanov

From: "Ivan T. Ivanov" <iivanov@mm-sol.com>

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 <iivanov@mm-sol.com>
---
 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 136f063..b77441b 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


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 05/13] usb: phy: msm: Fix WARNING: quoted string split across lines
  2013-10-14 15:24 [PATCH v3 00/13] usb: phy: msm: Fixes, cleanups and DT support Ivan T. Ivanov
                   ` (3 preceding siblings ...)
  2013-10-14 15:24 ` [PATCH v3 04/13] usb: phy: msm: Remove unnecessarily check for valid regulators Ivan T. Ivanov
@ 2013-10-14 15:24 ` Ivan T. Ivanov
  2013-10-14 15:24 ` [PATCH v3 06/13] usb: phy: msm: Fix WARNING: Prefer seq_puts to seq_printf Ivan T. Ivanov
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Ivan T. Ivanov @ 2013-10-14 15:24 UTC (permalink / raw)
  To: balbi
  Cc: rob.herring, pawel.moll, mark.rutland, swarren, ijc+devicetree,
	rob, davidb, dwalker, bryanh, linux, gregkh, grant.likely, jackp,
	mgautam, dsegal, linux-usb, devicetree, linux-doc, linux-kernel,
	linux-arm-msm, linux-arm-kernel, Ivan T. Ivanov

From: "Ivan T. Ivanov" <iivanov@mm-sol.com>

This fixes checkpatch.pl warnings.

Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com>
---
 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 b77441b..28cab03 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");
 			goto exit;
 		}
 		rc = regulator_enable(motg->v3p3);
@@ -109,8 +106,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");
@@ -546,8 +537,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);
 	}
 
@@ -1529,8 +1519,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


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 06/13] usb: phy: msm: Fix WARNING: Prefer seq_puts to seq_printf
  2013-10-14 15:24 [PATCH v3 00/13] usb: phy: msm: Fixes, cleanups and DT support Ivan T. Ivanov
                   ` (4 preceding siblings ...)
  2013-10-14 15:24 ` [PATCH v3 05/13] usb: phy: msm: Fix WARNING: quoted string split across lines Ivan T. Ivanov
@ 2013-10-14 15:24 ` Ivan T. Ivanov
  2013-10-14 15:24 ` [PATCH v3 07/13] usb: phy: msm: Replace custom enum usb_mode_type with enum usb_dr_mode Ivan T. Ivanov
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Ivan T. Ivanov @ 2013-10-14 15:24 UTC (permalink / raw)
  To: balbi
  Cc: rob.herring, pawel.moll, mark.rutland, swarren, ijc+devicetree,
	rob, davidb, dwalker, bryanh, linux, gregkh, grant.likely, jackp,
	mgautam, dsegal, linux-usb, devicetree, linux-doc, linux-kernel,
	linux-arm-msm, linux-arm-kernel, Ivan T. Ivanov

From: "Ivan T. Ivanov" <iivanov@mm-sol.com>

This fixes checkpatch.pl warnings.

Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com>
---
 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 28cab03..46800c0 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1231,13 +1231,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


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 07/13] usb: phy: msm: Replace custom enum usb_mode_type with enum usb_dr_mode
  2013-10-14 15:24 [PATCH v3 00/13] usb: phy: msm: Fixes, cleanups and DT support Ivan T. Ivanov
                   ` (5 preceding siblings ...)
  2013-10-14 15:24 ` [PATCH v3 06/13] usb: phy: msm: Fix WARNING: Prefer seq_puts to seq_printf Ivan T. Ivanov
@ 2013-10-14 15:24 ` Ivan T. Ivanov
  2013-10-14 15:24 ` [PATCH v3 08/13] usb: phy: msm: Drop default usb_dr_mode from platform data Ivan T. Ivanov
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Ivan T. Ivanov @ 2013-10-14 15:24 UTC (permalink / raw)
  To: balbi
  Cc: rob.herring, pawel.moll, mark.rutland, swarren, ijc+devicetree,
	rob, davidb, dwalker, bryanh, linux, gregkh, grant.likely, jackp,
	mgautam, dsegal, linux-usb, devicetree, linux-doc, linux-kernel,
	linux-arm-msm, linux-arm-kernel, Ivan T. Ivanov

From: "Ivan T. Ivanov" <iivanov@mm-sol.com>

Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com>
---
 arch/arm/mach-msm/board-msm7x30.c |    2 +-
 arch/arm/mach-msm/board-qsd8x50.c |    2 +-
 drivers/usb/phy/phy-msm-usb.c     |   40 ++++++++++++++++++-------------------
 include/linux/usb/msm_hsusb.h     |   19 ++----------------
 4 files changed, 24 insertions(+), 39 deletions(-)

diff --git a/arch/arm/mach-msm/board-msm7x30.c b/arch/arm/mach-msm/board-msm7x30.c
index 46de789..0c4c200 100644
--- a/arch/arm/mach-msm/board-msm7x30.c
+++ b/arch/arm/mach-msm/board-msm7x30.c
@@ -95,7 +95,7 @@ static int hsusb_phy_clk_reset(struct clk *phy_clk)
 
 static struct msm_otg_platform_data msm_otg_pdata = {
 	.phy_init_seq		= hsusb_phy_init_seq,
-	.mode                   = USB_PERIPHERAL,
+	.mode                   = USB_DR_MODE_PERIPHERAL,
 	.otg_control		= OTG_PHY_CONTROL,
 	.link_clk_reset		= hsusb_link_clk_reset,
 	.phy_clk_reset		= hsusb_phy_clk_reset,
diff --git a/arch/arm/mach-msm/board-qsd8x50.c b/arch/arm/mach-msm/board-qsd8x50.c
index 9169ec3..4c74861 100644
--- a/arch/arm/mach-msm/board-qsd8x50.c
+++ b/arch/arm/mach-msm/board-qsd8x50.c
@@ -116,7 +116,7 @@ static int hsusb_phy_clk_reset(struct clk *phy_clk)
 
 static struct msm_otg_platform_data msm_otg_pdata = {
 	.phy_init_seq		= hsusb_phy_init_seq,
-	.mode                   = USB_PERIPHERAL,
+	.mode                   = USB_DR_MODE_PERIPHERAL,
 	.otg_control		= OTG_PHY_CONTROL,
 	.link_clk_reset		= hsusb_link_clk_reset,
 	.phy_clk_reset		= hsusb_phy_clk_reset,
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 46800c0..2aca042 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -372,10 +372,10 @@ static int msm_otg_reset(struct usb_phy *phy)
 
 	if (pdata->otg_control == OTG_PHY_CONTROL) {
 		val = readl(USB_OTGSC);
-		if (pdata->mode == USB_OTG) {
+		if (pdata->mode == USB_DR_MODE_OTG) {
 			ulpi_val = ULPI_INT_IDGRD | ULPI_INT_SESS_VALID;
 			val |= OTGSC_IDIE | OTGSC_BSVIE;
-		} else if (pdata->mode == USB_PERIPHERAL) {
+		} else if (pdata->mode == USB_DR_MODE_PERIPHERAL) {
 			ulpi_val = ULPI_INT_SESS_VALID;
 			val |= OTGSC_BSVIE;
 		}
@@ -636,7 +636,7 @@ static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
 	 * Fail host registration if this board can support
 	 * only peripheral configuration.
 	 */
-	if (motg->pdata->mode == USB_PERIPHERAL) {
+	if (motg->pdata->mode == USB_DR_MODE_PERIPHERAL) {
 		dev_info(otg->phy->dev, "Host mode is not supported\n");
 		return -ENODEV;
 	}
@@ -665,7 +665,7 @@ static int msm_otg_set_host(struct usb_otg *otg, struct usb_bus *host)
 	 * Kick the state machine work, if peripheral is not supported
 	 * or peripheral is already registered with us.
 	 */
-	if (motg->pdata->mode == USB_HOST || otg->gadget) {
+	if (motg->pdata->mode == USB_DR_MODE_HOST || otg->gadget) {
 		pm_runtime_get_sync(otg->phy->dev);
 		schedule_work(&motg->sm_work);
 	}
@@ -709,7 +709,7 @@ static int msm_otg_set_peripheral(struct usb_otg *otg,
 	 * Fail peripheral registration if this board can support
 	 * only host configuration.
 	 */
-	if (motg->pdata->mode == USB_HOST) {
+	if (motg->pdata->mode == USB_DR_MODE_HOST) {
 		dev_info(otg->phy->dev, "Peripheral mode is not supported\n");
 		return -ENODEV;
 	}
@@ -734,7 +734,7 @@ static int msm_otg_set_peripheral(struct usb_otg *otg,
 	 * Kick the state machine work, if host is not supported
 	 * or host is already registered with us.
 	 */
-	if (motg->pdata->mode == USB_PERIPHERAL || otg->host) {
+	if (motg->pdata->mode == USB_DR_MODE_PERIPHERAL || otg->host) {
 		pm_runtime_get_sync(otg->phy->dev);
 		schedule_work(&motg->sm_work);
 	}
@@ -1055,7 +1055,7 @@ static void msm_otg_init_sm(struct msm_otg *motg)
 	u32 otgsc = readl(USB_OTGSC);
 
 	switch (pdata->mode) {
-	case USB_OTG:
+	case USB_DR_MODE_OTG:
 		if (pdata->otg_control == OTG_PHY_CONTROL) {
 			if (otgsc & OTGSC_ID)
 				set_bit(ID, &motg->inputs);
@@ -1067,21 +1067,21 @@ static void msm_otg_init_sm(struct msm_otg *motg)
 			else
 				clear_bit(B_SESS_VLD, &motg->inputs);
 		} else if (pdata->otg_control == OTG_USER_CONTROL) {
-			if (pdata->default_mode == USB_HOST) {
-				clear_bit(ID, &motg->inputs);
-			} else if (pdata->default_mode == USB_PERIPHERAL) {
+			if (pdata->default_mode == USB_DR_MODE_PERIPHERAL) {
 				set_bit(ID, &motg->inputs);
 				set_bit(B_SESS_VLD, &motg->inputs);
+			} else if (pdata->default_mode == USB_DR_MODE_HOST) {
+				clear_bit(ID, &motg->inputs);
 			} else {
 				set_bit(ID, &motg->inputs);
 				clear_bit(B_SESS_VLD, &motg->inputs);
 			}
 		}
 		break;
-	case USB_HOST:
+	case USB_DR_MODE_HOST:
 		clear_bit(ID, &motg->inputs);
 		break;
-	case USB_PERIPHERAL:
+	case USB_DR_MODE_PERIPHERAL:
 		set_bit(ID, &motg->inputs);
 		if (otgsc & OTGSC_BSV)
 			set_bit(B_SESS_VLD, &motg->inputs);
@@ -1257,7 +1257,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
 	char buf[16];
 	struct usb_otg *otg = motg->phy.otg;
 	int status = count;
-	enum usb_mode_type req_mode;
+	enum usb_dr_mode req_mode;
 
 	memset(buf, 0x00, sizeof(buf));
 
@@ -1267,18 +1267,18 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
 	}
 
 	if (!strncmp(buf, "host", 4)) {
-		req_mode = USB_HOST;
+		req_mode = USB_DR_MODE_HOST;
 	} else if (!strncmp(buf, "peripheral", 10)) {
-		req_mode = USB_PERIPHERAL;
+		req_mode = USB_DR_MODE_PERIPHERAL;
 	} else if (!strncmp(buf, "none", 4)) {
-		req_mode = USB_NONE;
+		req_mode = USB_DR_MODE_UNKNOWN;
 	} else {
 		status = -EINVAL;
 		goto out;
 	}
 
 	switch (req_mode) {
-	case USB_NONE:
+	case USB_DR_MODE_UNKNOWN:
 		switch (otg->phy->state) {
 		case OTG_STATE_A_HOST:
 		case OTG_STATE_B_PERIPHERAL:
@@ -1289,7 +1289,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
 			goto out;
 		}
 		break;
-	case USB_PERIPHERAL:
+	case USB_DR_MODE_PERIPHERAL:
 		switch (otg->phy->state) {
 		case OTG_STATE_B_IDLE:
 		case OTG_STATE_A_HOST:
@@ -1300,7 +1300,7 @@ static ssize_t msm_otg_mode_write(struct file *file, const char __user *ubuf,
 			goto out;
 		}
 		break;
-	case USB_HOST:
+	case USB_DR_MODE_HOST:
 		switch (otg->phy->state) {
 		case OTG_STATE_B_IDLE:
 		case OTG_STATE_B_PERIPHERAL:
@@ -1515,7 +1515,7 @@ static int __init msm_otg_probe(struct platform_device *pdev)
 	platform_set_drvdata(pdev, motg);
 	device_init_wakeup(&pdev->dev, 1);
 
-	if (motg->pdata->mode == USB_OTG &&
+	if (motg->pdata->mode == USB_DR_MODE_OTG &&
 			motg->pdata->otg_control == OTG_USER_CONTROL) {
 		ret = msm_otg_debugfs_init(motg);
 		if (ret)
diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h
index 8705b01..f9d512e 100644
--- a/include/linux/usb/msm_hsusb.h
+++ b/include/linux/usb/msm_hsusb.h
@@ -23,21 +23,6 @@
 #include <linux/clk.h>
 
 /**
- * Supported USB modes
- *
- * USB_PERIPHERAL       Only peripheral mode is supported.
- * USB_HOST             Only host mode is supported.
- * USB_OTG              OTG mode is supported.
- *
- */
-enum usb_mode_type {
-	USB_NONE = 0,
-	USB_PERIPHERAL,
-	USB_HOST,
-	USB_OTG,
-};
-
-/**
  * OTG control
  *
  * OTG_NO_CONTROL	Id/VBUS notifications not required. Useful in host
@@ -130,9 +115,9 @@ struct msm_otg_platform_data {
 	int *phy_init_seq;
 	void (*vbus_power)(bool on);
 	unsigned power_budget;
-	enum usb_mode_type mode;
+	enum usb_dr_mode mode;
 	enum otg_control_type otg_control;
-	enum usb_mode_type default_mode;
+	enum usb_dr_mode default_mode;
 	enum msm_usb_phy_type phy_type;
 	void (*setup_gpio)(enum usb_otg_state state);
 	char *pclk_src_name;
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 08/13] usb: phy: msm: Drop default usb_dr_mode from platform data.
  2013-10-14 15:24 [PATCH v3 00/13] usb: phy: msm: Fixes, cleanups and DT support Ivan T. Ivanov
                   ` (6 preceding siblings ...)
  2013-10-14 15:24 ` [PATCH v3 07/13] usb: phy: msm: Replace custom enum usb_mode_type with enum usb_dr_mode Ivan T. Ivanov
@ 2013-10-14 15:24 ` Ivan T. Ivanov
  2013-10-14 15:24 ` [PATCH v3 09/13] usb: phy: msm: Remove unused pclk_src_name Ivan T. Ivanov
                   ` (4 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Ivan T. Ivanov @ 2013-10-14 15:24 UTC (permalink / raw)
  To: balbi
  Cc: rob.herring, pawel.moll, mark.rutland, swarren, ijc+devicetree,
	rob, davidb, dwalker, bryanh, linux, gregkh, grant.likely, jackp,
	mgautam, dsegal, linux-usb, devicetree, linux-doc, linux-kernel,
	linux-arm-msm, linux-arm-kernel, Ivan T. Ivanov

From: "Ivan T. Ivanov" <iivanov@mm-sol.com>

USB DT bindings states: "...In case this attribute isn't
passed via DT, USB DRD controllers should default to OTG...",
so remove redundand field.

Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com>
---
 drivers/usb/phy/phy-msm-usb.c |    7 -------
 include/linux/usb/msm_hsusb.h |    3 ---
 2 files changed, 10 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 2aca042..4a23cfa 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1067,15 +1067,8 @@ static void msm_otg_init_sm(struct msm_otg *motg)
 			else
 				clear_bit(B_SESS_VLD, &motg->inputs);
 		} else if (pdata->otg_control == OTG_USER_CONTROL) {
-			if (pdata->default_mode == USB_DR_MODE_PERIPHERAL) {
-				set_bit(ID, &motg->inputs);
-				set_bit(B_SESS_VLD, &motg->inputs);
-			} else if (pdata->default_mode == USB_DR_MODE_HOST) {
-				clear_bit(ID, &motg->inputs);
-			} else {
 				set_bit(ID, &motg->inputs);
 				clear_bit(B_SESS_VLD, &motg->inputs);
-			}
 		}
 		break;
 	case USB_DR_MODE_HOST:
diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h
index f9d512e..72c5830 100644
--- a/include/linux/usb/msm_hsusb.h
+++ b/include/linux/usb/msm_hsusb.h
@@ -106,8 +106,6 @@ enum usb_chg_type {
  * @power_budget: VBUS power budget in mA (0 will be treated as 500mA).
  * @mode: Supported mode (OTG/peripheral/host).
  * @otg_control: OTG switch controlled by user/Id pin
- * @default_mode: Default operational mode. Applicable only if
- *              OTG switch is controller by user.
  * @pclk_src_name: pclk is derived from ebi1_usb_clk in case of 7x27 and 8k
  *              dfab_usb_hs_clk in case of 8660 and 8960.
  */
@@ -117,7 +115,6 @@ struct msm_otg_platform_data {
 	unsigned power_budget;
 	enum usb_dr_mode mode;
 	enum otg_control_type otg_control;
-	enum usb_dr_mode default_mode;
 	enum msm_usb_phy_type phy_type;
 	void (*setup_gpio)(enum usb_otg_state state);
 	char *pclk_src_name;
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 09/13] usb: phy: msm: Remove unused pclk_src_name
  2013-10-14 15:24 [PATCH v3 00/13] usb: phy: msm: Fixes, cleanups and DT support Ivan T. Ivanov
                   ` (7 preceding siblings ...)
  2013-10-14 15:24 ` [PATCH v3 08/13] usb: phy: msm: Drop default usb_dr_mode from platform data Ivan T. Ivanov
@ 2013-10-14 15:24 ` Ivan T. Ivanov
  2013-10-14 15:24 ` [PATCH v3 10/13] usb: phy: msm: Switch clock consumer strings Ivan T. Ivanov
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Ivan T. Ivanov @ 2013-10-14 15:24 UTC (permalink / raw)
  To: balbi
  Cc: rob.herring, pawel.moll, mark.rutland, swarren, ijc+devicetree,
	rob, davidb, dwalker, bryanh, linux, gregkh, grant.likely, jackp,
	mgautam, dsegal, linux-usb, devicetree, linux-doc, linux-kernel,
	linux-arm-msm, linux-arm-kernel, Ivan T. Ivanov

From: "Ivan T. Ivanov" <iivanov@mm-sol.com>

There are no references to 'pclk_src_name' in plaform code,
so it is unused.

Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com>
---
 drivers/usb/phy/phy-msm-usb.c |   26 +-------------------------
 include/linux/usb/msm_hsusb.h |    5 -----
 2 files changed, 1 insertion(+), 30 deletions(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index 4a23cfa..c1020d9 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -464,9 +464,6 @@ static int msm_otg_suspend(struct msm_otg *motg)
 	if (!IS_ERR(motg->core_clk))
 		clk_disable_unprepare(motg->core_clk);
 
-	if (!IS_ERR(motg->pclk_src))
-		clk_disable_unprepare(motg->pclk_src);
-
 	if (motg->pdata->phy_type == SNPS_28NM_INTEGRATED_PHY &&
 			motg->pdata->otg_control == OTG_PMIC_CONTROL) {
 		msm_hsusb_ldo_set_mode(motg, 0);
@@ -496,9 +493,6 @@ static int msm_otg_resume(struct msm_otg *motg)
 	if (!atomic_read(&motg->in_lpm))
 		return 0;
 
-	if (!IS_ERR(motg->pclk_src))
-		clk_prepare_enable(motg->pclk_src);
-
 	clk_prepare_enable(motg->pclk);
 	clk_prepare_enable(motg->clk);
 	if (!IS_ERR(motg->core_clk))
@@ -1394,17 +1388,8 @@ static int __init msm_otg_probe(struct platform_device *pdev)
 	 * If USB Core is running its protocol engine based on CORE CLK,
 	 * CORE CLK  must be running at >55Mhz for correct HSUSB
 	 * operation and USB core cannot tolerate frequency changes on
-	 * CORE CLK. For such USB cores, vote for maximum clk frequency
-	 * on pclk source
+	 * CORE CLK.
 	 */
-	 motg->pclk_src = ERR_PTR(-ENOENT);
-	 if (motg->pdata->pclk_src_name) {
-		motg->pclk_src = devm_clk_get(&pdev->dev,
-					motg->pdata->pclk_src_name);
-		if (IS_ERR(motg->pclk_src))
-			return PTR_ERR(motg->pclk_src);
-	}
-
 	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");
@@ -1450,10 +1435,6 @@ static int __init msm_otg_probe(struct platform_device *pdev)
 	}
 
 	clk_set_rate(motg->clk, 60000000);
-	if (!IS_ERR(motg->pclk_src)) {
-		clk_set_rate(motg->pclk_src, INT_MAX);
-		clk_prepare_enable(motg->pclk_src);
-	}
 
 	clk_prepare_enable(motg->clk);
 	clk_prepare_enable(motg->pclk);
@@ -1529,8 +1510,6 @@ disable_clks:
 	clk_disable_unprepare(motg->clk);
 	if (!IS_ERR(motg->core_clk))
 		clk_disable_unprepare(motg->core_clk);
-	if (!IS_ERR(motg->pclk_src))
-		clk_disable_unprepare(motg->pclk_src);
 	return ret;
 }
 
@@ -1575,9 +1554,6 @@ static int msm_otg_remove(struct platform_device *pdev)
 	clk_disable_unprepare(motg->clk);
 	if (!IS_ERR(motg->core_clk))
 		clk_disable_unprepare(motg->core_clk);
-	if (!IS_ERR(motg->pclk_src))
-		clk_disable_unprepare(motg->pclk_src);
-
 	msm_hsusb_ldo_init(motg, 0);
 
 	pm_runtime_set_suspended(&pdev->dev);
diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h
index 72c5830..262ed80 100644
--- a/include/linux/usb/msm_hsusb.h
+++ b/include/linux/usb/msm_hsusb.h
@@ -106,8 +106,6 @@ enum usb_chg_type {
  * @power_budget: VBUS power budget in mA (0 will be treated as 500mA).
  * @mode: Supported mode (OTG/peripheral/host).
  * @otg_control: OTG switch controlled by user/Id pin
- * @pclk_src_name: pclk is derived from ebi1_usb_clk in case of 7x27 and 8k
- *              dfab_usb_hs_clk in case of 8660 and 8960.
  */
 struct msm_otg_platform_data {
 	int *phy_init_seq;
@@ -117,7 +115,6 @@ struct msm_otg_platform_data {
 	enum otg_control_type otg_control;
 	enum msm_usb_phy_type phy_type;
 	void (*setup_gpio)(enum usb_otg_state state);
-	char *pclk_src_name;
 	int (*link_clk_reset)(struct clk *link_clk, bool assert);
 	int (*phy_clk_reset)(struct clk *phy_clk);
 };
@@ -129,7 +126,6 @@ struct msm_otg_platform_data {
  * @irq: IRQ number assigned for HSUSB controller.
  * @clk: clock struct of usb_hs_clk.
  * @pclk: clock struct of usb_hs_pclk.
- * @pclk_src: pclk source for voting.
  * @phy_reset_clk: clock struct of usb_phy_clk.
  * @core_clk: clock struct of usb_hs_core_clk.
  * @regs: ioremapped register base address.
@@ -150,7 +146,6 @@ struct msm_otg {
 	int irq;
 	struct clk *clk;
 	struct clk *pclk;
-	struct clk *pclk_src;
 	struct clk *phy_reset_clk;
 	struct clk *core_clk;
 	void __iomem *regs;
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 10/13] usb: phy: msm: Switch clock consumer strings
  2013-10-14 15:24 [PATCH v3 00/13] usb: phy: msm: Fixes, cleanups and DT support Ivan T. Ivanov
                   ` (8 preceding siblings ...)
  2013-10-14 15:24 ` [PATCH v3 09/13] usb: phy: msm: Remove unused pclk_src_name Ivan T. Ivanov
@ 2013-10-14 15:24 ` Ivan T. Ivanov
  2013-10-14 15:24 ` [PATCH v3 11/13] usb: phy: msm: Remove HSUSB prefix from requlator names Ivan T. Ivanov
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 19+ messages in thread
From: Ivan T. Ivanov @ 2013-10-14 15:24 UTC (permalink / raw)
  To: balbi
  Cc: rob.herring, pawel.moll, mark.rutland, swarren, ijc+devicetree,
	rob, davidb, dwalker, bryanh, linux, gregkh, grant.likely, jackp,
	mgautam, dsegal, linux-usb, devicetree, linux-doc, linux-kernel,
	linux-arm-msm, linux-arm-kernel, Ivan T. Ivanov, Stephen Boyd

From: "Ivan T. Ivanov" <iivanov@mm-sol.com>

Replace the USB specific clock names in driver
with the more standard 'core' and 'iface' ... names.

Cc: David Brown <davidb@codeaurora.org>
Cc: Stephen Boyd <sboyd@codeaurora.org>
Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com>
---
 arch/arm/mach-msm/devices-msm7x00.c |    4 +-
 arch/arm/mach-msm/devices-msm7x30.c |    8 ++--
 arch/arm/mach-msm/devices-qsd8x50.c |    6 +--
 drivers/usb/phy/phy-msm-usb.c       |   79 +++++++++++++++++++----------------
 include/linux/usb/msm_hsusb.h       |   14 +++----
 5 files changed, 58 insertions(+), 53 deletions(-)

diff --git a/arch/arm/mach-msm/devices-msm7x00.c b/arch/arm/mach-msm/devices-msm7x00.c
index d83404d..e7274e1 100644
--- a/arch/arm/mach-msm/devices-msm7x00.c
+++ b/arch/arm/mach-msm/devices-msm7x00.c
@@ -461,8 +461,8 @@ static struct clk_pcom_desc msm_clocks_7x01a[] = {
 	CLK_PCOM("core",	UART3_CLK,	"msm_serial.2", OFF),
 	CLK_PCOM("uart1dm_clk",	UART1DM_CLK,	NULL, OFF),
 	CLK_PCOM("uart2dm_clk",	UART2DM_CLK,	NULL, 0),
-	CLK_PCOM("usb_hs_clk",	USB_HS_CLK,	"msm_hsusb", OFF),
-	CLK_PCOM("usb_hs_pclk",	USB_HS_P_CLK,	"msm_hsusb", OFF),
+	CLK_PCOM("core",	USB_HS_CLK,	"msm_hsusb", OFF),
+	CLK_PCOM("iface",	USB_HS_P_CLK,	"msm_hsusb", OFF),
 	CLK_PCOM("usb_otg_clk",	USB_OTG_CLK,	NULL, 0),
 	CLK_PCOM("vdc_clk",	VDC_CLK,	NULL, OFF ),
 	CLK_PCOM("vfe_clk",	VFE_CLK,	NULL, OFF),
diff --git a/arch/arm/mach-msm/devices-msm7x30.c b/arch/arm/mach-msm/devices-msm7x30.c
index c15ea8a..b7d00fa 100644
--- a/arch/arm/mach-msm/devices-msm7x30.c
+++ b/arch/arm/mach-msm/devices-msm7x30.c
@@ -212,10 +212,10 @@ static struct clk_pcom_desc msm_clocks_7x30[] = {
 	CLK_PCOM("tv_dac_clk",	TV_DAC_CLK,	NULL, 0),
 	CLK_PCOM("tv_enc_clk",	TV_ENC_CLK,	NULL, 0),
 	CLK_PCOM("core",	UART2_CLK,	"msm_serial.1", 0),
-	CLK_PCOM("usb_phy_clk",	USB_PHY_CLK,	NULL, 0),
-	CLK_PCOM("usb_hs_clk",		USB_HS_CLK,		NULL, OFF),
-	CLK_PCOM("usb_hs_pclk",		USB_HS_P_CLK,		NULL, OFF),
-	CLK_PCOM("usb_hs_core_clk",	USB_HS_CORE_CLK,	NULL, OFF),
+	CLK_PCOM("phy",	USB_PHY_CLK,	NULL, 0),
+	CLK_PCOM("core",		USB_HS_CLK,		NULL, OFF),
+	CLK_PCOM("iface",		USB_HS_P_CLK,		NULL, OFF),
+	CLK_PCOM("alt_core",	USB_HS_CORE_CLK,	NULL, OFF),
 	CLK_PCOM("usb_hs2_clk",		USB_HS2_CLK,		NULL, OFF),
 	CLK_PCOM("usb_hs2_pclk",	USB_HS2_P_CLK,		NULL, OFF),
 	CLK_PCOM("usb_hs2_core_clk",	USB_HS2_CORE_CLK,	NULL, OFF),
diff --git a/arch/arm/mach-msm/devices-qsd8x50.c b/arch/arm/mach-msm/devices-qsd8x50.c
index 9e1e9ce..c9614b8 100644
--- a/arch/arm/mach-msm/devices-qsd8x50.c
+++ b/arch/arm/mach-msm/devices-qsd8x50.c
@@ -363,8 +363,8 @@ static struct clk_pcom_desc msm_clocks_8x50[] = {
 	CLK_PCOM("core",	UART3_CLK,	"msm_serial.2", OFF),
 	CLK_PCOM("uartdm_clk",	UART1DM_CLK,	NULL, OFF),
 	CLK_PCOM("uartdm_clk",	UART2DM_CLK,	NULL, 0),
-	CLK_PCOM("usb_hs_clk",	USB_HS_CLK,	NULL, OFF),
-	CLK_PCOM("usb_hs_pclk",	USB_HS_P_CLK,	NULL, OFF),
+	CLK_PCOM("core",	USB_HS_CLK,	NULL, OFF),
+	CLK_PCOM("iface",	USB_HS_P_CLK,	NULL, OFF),
 	CLK_PCOM("usb_otg_clk",	USB_OTG_CLK,	NULL, 0),
 	CLK_PCOM("vdc_clk",	VDC_CLK,	NULL, OFF | CLK_MIN),
 	CLK_PCOM("vfe_clk",	VFE_CLK,	NULL, OFF),
@@ -374,7 +374,7 @@ static struct clk_pcom_desc msm_clocks_8x50[] = {
 	CLK_PCOM("usb_hs2_pclk",	USB_HS2_P_CLK,	NULL, OFF),
 	CLK_PCOM("usb_hs3_clk",	USB_HS3_CLK,	NULL, OFF),
 	CLK_PCOM("usb_hs3_pclk",	USB_HS3_P_CLK,	NULL, OFF),
-	CLK_PCOM("usb_phy_clk",	USB_PHY_CLK,	NULL, 0),
+	CLK_PCOM("phy",	USB_PHY_CLK,	NULL, 0),
 };
 
 static struct pcom_clk_pdata msm_clock_8x50_pdata = {
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index c1020d9..0bd3ba5 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -262,7 +262,7 @@ static int msm_otg_link_clk_reset(struct msm_otg *motg, bool assert)
 	if (!motg->pdata->link_clk_reset)
 		return ret;
 
-	ret = motg->pdata->link_clk_reset(motg->clk, assert);
+	ret = motg->pdata->link_clk_reset(motg->core_clk, assert);
 	if (ret)
 		dev_err(motg->phy.dev, "usb link clk reset failed\n");
 
@@ -276,7 +276,7 @@ static int msm_otg_phy_clk_reset(struct msm_otg *motg)
 	if (!motg->pdata->phy_clk_reset)
 		return ret;
 
-	ret = motg->pdata->phy_clk_reset(motg->phy_reset_clk);
+	ret = motg->pdata->phy_clk_reset(motg->phy_clk);
 	if (ret)
 		dev_err(motg->phy.dev, "usb phy clk assert failed\n");
 
@@ -459,10 +459,10 @@ static int msm_otg_suspend(struct msm_otg *motg)
 			motg->pdata->otg_control == OTG_PMIC_CONTROL)
 		writel(readl(USB_PHY_CTRL) | PHY_RETEN, USB_PHY_CTRL);
 
-	clk_disable_unprepare(motg->pclk);
-	clk_disable_unprepare(motg->clk);
-	if (!IS_ERR(motg->core_clk))
-		clk_disable_unprepare(motg->core_clk);
+	clk_disable_unprepare(motg->iface_clk);
+	clk_disable_unprepare(motg->core_clk);
+	if (!IS_ERR(motg->alt_core_clk))
+		clk_disable_unprepare(motg->alt_core_clk);
 
 	if (motg->pdata->phy_type == SNPS_28NM_INTEGRATED_PHY &&
 			motg->pdata->otg_control == OTG_PMIC_CONTROL) {
@@ -493,10 +493,10 @@ static int msm_otg_resume(struct msm_otg *motg)
 	if (!atomic_read(&motg->in_lpm))
 		return 0;
 
-	clk_prepare_enable(motg->pclk);
-	clk_prepare_enable(motg->clk);
-	if (!IS_ERR(motg->core_clk))
-		clk_prepare_enable(motg->core_clk);
+	clk_prepare_enable(motg->iface_clk);
+	clk_prepare_enable(motg->core_clk);
+	if (!IS_ERR(motg->alt_core_clk))
+		clk_prepare_enable(motg->alt_core_clk);
 
 	if (motg->pdata->phy_type == SNPS_28NM_INTEGRATED_PHY &&
 			motg->pdata->otg_control == OTG_PMIC_CONTROL) {
@@ -1372,16 +1372,16 @@ static int __init msm_otg_probe(struct platform_device *pdev)
 	phy = &motg->phy;
 	phy->dev = &pdev->dev;
 
-	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");
-		return PTR_ERR(motg->phy_reset_clk);
+	motg->phy_clk = devm_clk_get(&pdev->dev, "phy");
+	if (IS_ERR(motg->phy_clk)) {
+		dev_err(&pdev->dev, "failed to get phy clock\n");
+		return PTR_ERR(motg->phy_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");
-		return PTR_ERR(motg->clk);
+	motg->core_clk = devm_clk_get(&pdev->dev, "core");
+	if (IS_ERR(motg->core_clk)) {
+		dev_err(&pdev->dev, "failed to get core clock\n");
+		return PTR_ERR(motg->core_clk);
 	}
 
 	/*
@@ -1390,18 +1390,22 @@ static int __init msm_otg_probe(struct platform_device *pdev)
 	 * operation and USB core cannot tolerate frequency changes on
 	 * CORE CLK.
 	 */
-	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");
-		return PTR_ERR(motg->pclk);
+
+	motg->iface_clk = devm_clk_get(&pdev->dev, "iface");
+	if (IS_ERR(motg->iface_clk)) {
+		dev_err(&pdev->dev, "failed to get iface clock\n");
+		return PTR_ERR(motg->iface_clk);
 	}
 
 	/*
-	 * USB core clock is not present on all MSM chips. This
+	 * USB alt_core clock is not present on all MSM chips. This
 	 * clock is introduced to remove the dependency on AXI
 	 * bus frequency.
+	 *
+	 * Targets on which link uses asynchronous reset methodology,
+	 * free running clock is not required during the reset.
 	 */
-	motg->core_clk = devm_clk_get(&pdev->dev, "usb_hs_core_clk");
+	motg->alt_core_clk = devm_clk_get(&pdev->dev, "alt_core");
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
 	motg->regs = devm_ioremap_resource(&pdev->dev, res);
@@ -1434,13 +1438,13 @@ static int __init msm_otg_probe(struct platform_device *pdev)
 		return PTR_ERR(motg->v1p8);
 	}
 
-	clk_set_rate(motg->clk, 60000000);
+	clk_set_rate(motg->core_clk, 60000000);
 
-	clk_prepare_enable(motg->clk);
-	clk_prepare_enable(motg->pclk);
+	clk_prepare_enable(motg->core_clk);
+	clk_prepare_enable(motg->iface_clk);
 
-	if (!IS_ERR(motg->core_clk))
-		clk_prepare_enable(motg->core_clk);
+	if (!IS_ERR(motg->alt_core_clk))
+		clk_prepare_enable(motg->alt_core_clk);
 
 	ret = msm_hsusb_init_vddcx(motg, 1);
 	if (ret) {
@@ -1506,10 +1510,10 @@ disable_ldo:
 disable_vddcx:
 	msm_hsusb_init_vddcx(motg, 0);
 disable_clks:
-	clk_disable_unprepare(motg->pclk);
-	clk_disable_unprepare(motg->clk);
-	if (!IS_ERR(motg->core_clk))
-		clk_disable_unprepare(motg->core_clk);
+	clk_disable_unprepare(motg->iface_clk);
+	clk_disable_unprepare(motg->core_clk);
+	if (!IS_ERR(motg->alt_core_clk))
+		clk_disable_unprepare(motg->alt_core_clk);
 	return ret;
 }
 
@@ -1550,10 +1554,11 @@ static int msm_otg_remove(struct platform_device *pdev)
 	if (cnt >= PHY_SUSPEND_TIMEOUT_USEC)
 		dev_err(phy->dev, "Unable to suspend PHY\n");
 
-	clk_disable_unprepare(motg->pclk);
-	clk_disable_unprepare(motg->clk);
-	if (!IS_ERR(motg->core_clk))
-		clk_disable_unprepare(motg->core_clk);
+	clk_disable_unprepare(motg->iface_clk);
+	clk_disable_unprepare(motg->core_clk);
+	if (!IS_ERR(motg->alt_core_clk))
+		clk_disable_unprepare(motg->alt_core_clk);
+
 	msm_hsusb_ldo_init(motg, 0);
 
 	pm_runtime_set_suspended(&pdev->dev);
diff --git a/include/linux/usb/msm_hsusb.h b/include/linux/usb/msm_hsusb.h
index 262ed80..f1b98f2 100644
--- a/include/linux/usb/msm_hsusb.h
+++ b/include/linux/usb/msm_hsusb.h
@@ -124,10 +124,10 @@ struct msm_otg_platform_data {
  * @otg: USB OTG Transceiver structure.
  * @pdata: otg device platform data.
  * @irq: IRQ number assigned for HSUSB controller.
- * @clk: clock struct of usb_hs_clk.
- * @pclk: clock struct of usb_hs_pclk.
- * @phy_reset_clk: clock struct of usb_phy_clk.
- * @core_clk: clock struct of usb_hs_core_clk.
+ * @core_clk: reference to core clock struct.
+ * @iface_clk: reference to interface clock struct.
+ * @phy_clk: reference to PHY clock struct.
+ * @alt_core_clk: reference to alternative clock struct
  * @regs: ioremapped register base address.
  * @inputs: OTG state machine inputs(Id, SessValid etc).
  * @sm_work: OTG state machine work.
@@ -144,10 +144,10 @@ struct msm_otg {
 	struct usb_phy phy;
 	struct msm_otg_platform_data *pdata;
 	int irq;
-	struct clk *clk;
-	struct clk *pclk;
-	struct clk *phy_reset_clk;
 	struct clk *core_clk;
+	struct clk *iface_clk;
+	struct clk *phy_clk;
+	struct clk *alt_core_clk;
 	void __iomem *regs;
 #define ID		0
 #define B_SESS_VLD	1
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 11/13] usb: phy: msm: Remove HSUSB prefix from requlator names
  2013-10-14 15:24 [PATCH v3 00/13] usb: phy: msm: Fixes, cleanups and DT support Ivan T. Ivanov
                   ` (9 preceding siblings ...)
  2013-10-14 15:24 ` [PATCH v3 10/13] usb: phy: msm: Switch clock consumer strings Ivan T. Ivanov
@ 2013-10-14 15:24 ` Ivan T. Ivanov
  2013-10-14 15:24 ` [PATCH v3 12/13] usb: phy: msm: Properly check core interrupt number Ivan T. Ivanov
  2013-10-14 15:24 ` [PATCH v3 13/13] usb: phy: msm: Add device tree support and binding information Ivan T. Ivanov
  12 siblings, 0 replies; 19+ messages in thread
From: Ivan T. Ivanov @ 2013-10-14 15:24 UTC (permalink / raw)
  To: balbi
  Cc: rob.herring, pawel.moll, mark.rutland, swarren, ijc+devicetree,
	rob, davidb, dwalker, bryanh, linux, gregkh, grant.likely, jackp,
	mgautam, dsegal, linux-usb, devicetree, linux-doc, linux-kernel,
	linux-arm-msm, linux-arm-kernel, Ivan T. Ivanov

From: "Ivan T. Ivanov" <iivanov@mm-sol.com>

Prefix did not bring any useful information.

Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com>
---
 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 0bd3ba5..ca2abe6 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1420,19 +1420,19 @@ static int __init msm_otg_probe(struct platform_device *pdev)
 		return motg->irq;
 	}
 
-	motg->vddcx = devm_regulator_get(motg->phy.dev, "HSUSB_VDDCX");
+	motg->vddcx = devm_regulator_get(motg->phy.dev, "vddcx");
 	if (IS_ERR(motg->vddcx)) {
 		dev_err(motg->phy.dev, "unable to get hsusb vddcx\n");
 		return PTR_ERR(motg->vddcx);
 	}
 
-	motg->v3p3 = devm_regulator_get(motg->phy.dev, "HSUSB_3p3");
+	motg->v3p3 = devm_regulator_get(motg->phy.dev, "v3p3");
 	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(motg->phy.dev, "HSUSB_1p8");
+	motg->v1p8 = devm_regulator_get(motg->phy.dev, "v1p8");
 	if (IS_ERR(motg->v1p8)) {
 		dev_err(motg->phy.dev, "unable to get hsusb 1p8\n");
 		return PTR_ERR(motg->v1p8);
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 12/13] usb: phy: msm: Properly check core interrupt number
  2013-10-14 15:24 [PATCH v3 00/13] usb: phy: msm: Fixes, cleanups and DT support Ivan T. Ivanov
                   ` (10 preceding siblings ...)
  2013-10-14 15:24 ` [PATCH v3 11/13] usb: phy: msm: Remove HSUSB prefix from requlator names Ivan T. Ivanov
@ 2013-10-14 15:24 ` Ivan T. Ivanov
  2013-10-14 22:59   ` Felipe Balbi
  2013-10-14 15:24 ` [PATCH v3 13/13] usb: phy: msm: Add device tree support and binding information Ivan T. Ivanov
  12 siblings, 1 reply; 19+ messages in thread
From: Ivan T. Ivanov @ 2013-10-14 15:24 UTC (permalink / raw)
  To: balbi
  Cc: rob.herring, pawel.moll, mark.rutland, swarren, ijc+devicetree,
	rob, davidb, dwalker, bryanh, linux, gregkh, grant.likely, jackp,
	mgautam, dsegal, linux-usb, devicetree, linux-doc, linux-kernel,
	linux-arm-msm, linux-arm-kernel, Ivan T. Ivanov

From: "Ivan T. Ivanov" <iivanov@mm-sol.com>

IRQ with number 0 is valid case, so check for negative
numbers instead.

Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com>
---
 drivers/usb/phy/phy-msm-usb.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index ca2abe6..f34c8a9 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -1415,7 +1415,7 @@ static int __init msm_otg_probe(struct platform_device *pdev)
 	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");
 		return motg->irq;
 	}
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* [PATCH v3 13/13] usb: phy: msm: Add device tree support and binding information
  2013-10-14 15:24 [PATCH v3 00/13] usb: phy: msm: Fixes, cleanups and DT support Ivan T. Ivanov
                   ` (11 preceding siblings ...)
  2013-10-14 15:24 ` [PATCH v3 12/13] usb: phy: msm: Properly check core interrupt number Ivan T. Ivanov
@ 2013-10-14 15:24 ` Ivan T. Ivanov
  12 siblings, 0 replies; 19+ messages in thread
From: Ivan T. Ivanov @ 2013-10-14 15:24 UTC (permalink / raw)
  To: balbi
  Cc: rob.herring, pawel.moll, mark.rutland, swarren, ijc+devicetree,
	rob, davidb, dwalker, bryanh, linux, gregkh, grant.likely, jackp,
	mgautam, dsegal, linux-usb, devicetree, linux-doc, linux-kernel,
	linux-arm-msm, linux-arm-kernel, Ivan T. Ivanov

From: "Ivan T. Ivanov" <iivanov@mm-sol.com>

Allows MSM OTG controller to be specified via device tree.

Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com>
---
 .../devicetree/bindings/usb/msm-hsusb.txt          |   58 +++++++++++++++++++
 drivers/usb/phy/phy-msm-usb.c                      |   59 ++++++++++++++++++--
 2 files changed, 112 insertions(+), 5 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/msm-hsusb.txt b/Documentation/devicetree/bindings/usb/msm-hsusb.txt
index 5ea26c6..4ed8d1a 100644
--- a/Documentation/devicetree/bindings/usb/msm-hsusb.txt
+++ b/Documentation/devicetree/bindings/usb/msm-hsusb.txt
@@ -15,3 +15,61 @@ Example EHCI controller device node:
 		usb-phy = <&usb_otg>;
 	};
 
+
+OTG:
+
+Required properties:
+- compatible:	should contain "qcom,hsusb-otg"
+- regs:			offset and length of the register set in the memory map
+- interrupts:	interrupt-specifier for the OTG interrupt.
+
+- clocks:		A list of phandle + clock-specifier pairs for the
+				clocks listed in clock-names
+- clock-names:	Should contain the following:
+  "phy"			USB PHY reference clock
+  "core"		Protocol engine clock
+  "iface"		Interface bus clock
+  "alt_core"	Optional: Protocol engine clock for targets with asynchronous
+				reset methodology.
+
+- dr_mode:		One of "host", "peripheral" or "otg". Defaults to "otg"
+
+- vdccx-supply:	phandle to the regulator for the vdd supply for
+				digital circuit operation.
+- v1p8-supply:	phandle to the regulator for the 1.8V supply
+- v3p3-supply:	phandle to the regulator for the 3.3V supply
+
+- qcom,phy-type: PHY type can be one of
+				1 - Chipidea 45nm PHY
+				2 - Synopsis 28nm PHY
+
+- qcom,otg-control: OTG control (VBUS and ID notifications) can be one of
+				1 - PHY control
+				2 - PMIC control
+				3 - User control (via debugfs)
+
+Optional properties:
+- qcom,phy-init-sequence: PHY configuration sequence. val, reg pairs
+				terminate with -1
+
+Example HSUSB OTG controller device node:
+
+	usb@f9a55000 {
+		compatible = "qcom,hsusb-otg";
+		reg = <0xf9a55000 0x400>;
+		interrupts = <0 134 0>;;
+		dr_mode = "peripheral";
+
+		clocks = <&gcc GCC_XO_CLK>, <&gcc GCC_USB_HS_SYSTEM_CLK>,
+				<&gcc GCC_USB_HS_AHB_CLK>;
+
+		clock-names = "phy", "core", "iface";
+
+		vddcx-supply = <&pm8841_s2_corner>;
+		v1p8-supply = <&pm8941_l6>;
+		v3p3-supply = <&pm8941_l24>;
+
+		qcom,otg-control = <1>;
+		qcom,phy-type = <2>;
+		qcom,phy-init-sequence = <0x01 0x90 0xffffffff>;
+	};
diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
index f34c8a9..1ecea6f 100644
--- a/drivers/usb/phy/phy-msm-usb.c
+++ b/drivers/usb/phy/phy-msm-usb.c
@@ -30,9 +30,11 @@
 #include <linux/debugfs.h>
 #include <linux/seq_file.h>
 #include <linux/pm_runtime.h>
+#include <linux/of.h>
 
 #include <linux/usb.h>
 #include <linux/usb/otg.h>
+#include <linux/usb/of.h>
 #include <linux/usb/ulpi.h>
 #include <linux/usb/gadget.h>
 #include <linux/usb/hcd.h>
@@ -1342,17 +1344,57 @@ static void msm_otg_debugfs_cleanup(void)
 	debugfs_remove(msm_otg_dbg_root);
 }
 
+struct msm_otg_platform_data *msm_otg_dt_to_pdata(struct platform_device *pdev)
+{
+	struct msm_otg_platform_data *pdata;
+	struct device_node *node = pdev->dev.of_node;
+	int len = 0;
+	u32 val;
+
+	pdata = devm_kzalloc(&pdev->dev, sizeof(*pdata), GFP_KERNEL);
+	if (!pdata) {
+		dev_err(&pdev->dev, "unable to allocate platform data\n");
+		return NULL;
+	}
+
+	pdata->mode = of_usb_get_dr_mode(node);
+	if (pdata->mode == USB_DR_MODE_UNKNOWN)
+		pdata->mode = USB_DR_MODE_OTG;
+
+	pdata->otg_control = OTG_PHY_CONTROL;
+	if (!of_property_read_u32(node, "qcom,otg-control", &val))
+		pdata->otg_control = val;
+
+	pdata->phy_type = CI_45NM_INTEGRATED_PHY;
+	if (!of_property_read_u32(node, "qcom,phy-type", &val))
+		pdata->phy_type = val;
+
+	if (!of_get_property(node, "qcom,phy-init-sequence", &len) || !len)
+		return pdata;
+
+	pdata->phy_init_seq = devm_kzalloc(&pdev->dev, len, GFP_KERNEL);
+	if (!pdata->phy_init_seq)
+		return pdata;
+
+	of_property_read_u32_array(node, "qcom,phy-init-sequence",
+				   pdata->phy_init_seq,
+				   len / sizeof(*pdata->phy_init_seq));
+	return pdata;
+}
+
 static int __init msm_otg_probe(struct platform_device *pdev)
 {
 	int ret = 0;
+	struct msm_otg_platform_data *pdata;
 	struct resource *res;
 	struct msm_otg *motg;
 	struct usb_phy *phy;
 
-	dev_info(&pdev->dev, "msm_otg probe\n");
-	if (!dev_get_platdata(&pdev->dev)) {
-		dev_err(&pdev->dev, "No platform data given. Bailing out\n");
-		return -ENODEV;
+	pdata = dev_get_platdata(&pdev->dev);
+	if (!pdata) {
+		pdata = msm_otg_dt_to_pdata(pdev);
+		if (!pdata)
+			return -ENOMEM;
 	}
 
 	motg = devm_kzalloc(&pdev->dev, sizeof(struct msm_otg), GFP_KERNEL);
@@ -1368,7 +1410,7 @@ static int __init msm_otg_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
-	motg->pdata = dev_get_platdata(&pdev->dev);
+	motg->pdata = pdata;
 	phy = &motg->phy;
 	phy->dev = &pdev->dev;
 
@@ -1643,6 +1685,12 @@ static const struct dev_pm_ops msm_otg_dev_pm_ops = {
 };
 #endif
 
+static struct of_device_id msm_otg_dt_match[] = {
+	{ .compatible = "qcom,hsusb-otg", },
+	{}
+};
+MODULE_DEVICE_TABLE(of, msm_otg_dt_match);
+
 static struct platform_driver msm_otg_driver = {
 	.probe = msm_otg_probe,
 	.remove = msm_otg_remove,
@@ -1652,6 +1700,7 @@ static struct platform_driver msm_otg_driver = {
 #ifdef CONFIG_PM
 		.pm = &msm_otg_dev_pm_ops,
 #endif
+		.of_match_table = msm_otg_dt_match,
 	},
 };
 
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 19+ messages in thread

* Re: [PATCH v3 01/13] usb: phy: msm: Move mach depndend code to platform data
  2013-10-14 15:24 ` [PATCH v3 01/13] usb: phy: msm: Move mach depndend code to platform data Ivan T. Ivanov
@ 2013-10-14 22:52   ` Felipe Balbi
  2013-10-15  7:01     ` Ivan T. Ivanov
  0 siblings, 1 reply; 19+ messages in thread
From: Felipe Balbi @ 2013-10-14 22:52 UTC (permalink / raw)
  To: Ivan T. Ivanov
  Cc: balbi, rob.herring, pawel.moll, mark.rutland, swarren,
	ijc+devicetree, rob, davidb, dwalker, bryanh, linux, gregkh,
	grant.likely, jackp, mgautam, dsegal, linux-usb, devicetree,
	linux-doc, linux-kernel, linux-arm-msm, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 5889 bytes --]

Hi,

On Mon, Oct 14, 2013 at 06:24:28PM +0300, Ivan T. Ivanov wrote:
> From: "Ivan T. Ivanov" <iivanov@mm-sol.com>
> 
> This patch fix compilation error and is an intermediate step
> before the addition of DeviceTree support for newer targets.
> 
> Cc: David Brown <davidb@codeaurora.org>
> Cc: Daniel Walker <dwalker@fifo99.com>
> Cc: Felipe Balbi <balbi@ti.com>
> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com>
> ---
>  arch/arm/mach-msm/board-msm7x30.c |   35 +++++++++++++++++++++++++++++++++++
>  arch/arm/mach-msm/board-qsd8x50.c |   35 +++++++++++++++++++++++++++++++++++
>  drivers/usb/phy/phy-msm-usb.c     |   34 ++++++++++++++--------------------
>  include/linux/usb/msm_hsusb.h     |    3 +++
>  4 files changed, 87 insertions(+), 20 deletions(-)
> 
> diff --git a/arch/arm/mach-msm/board-msm7x30.c b/arch/arm/mach-msm/board-msm7x30.c
> index f9af5a4..46de789 100644
> --- a/arch/arm/mach-msm/board-msm7x30.c
> +++ b/arch/arm/mach-msm/board-msm7x30.c
> @@ -30,6 +30,7 @@
>  #include <asm/memory.h>
>  #include <asm/setup.h>
>  
> +#include <mach/clk.h>
>  #include <mach/msm_iomap.h>
>  #include <mach/dma.h>
>  
> @@ -60,10 +61,44 @@ static int hsusb_phy_init_seq[] = {
>  	-1
>  };
>  
> +static int hsusb_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,
> +	.link_clk_reset		= hsusb_link_clk_reset,
> +	.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 5f933bc..9169ec3 100644
> --- a/arch/arm/mach-msm/board-qsd8x50.c
> +++ b/arch/arm/mach-msm/board-qsd8x50.c
> @@ -31,6 +31,7 @@
>  #include <mach/irqs.h>
>  #include <mach/sirc.h>
>  #include <mach/vreg.h>
> +#include <mach/clk.h>
>  #include <linux/platform_data/mmc-msm_sdcc.h>
>  
>  #include "devices.h"
> @@ -81,10 +82,44 @@ static int hsusb_phy_init_seq[] = {
>  	-1
>  };
>  
> +static int hsusb_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,
> +	.link_clk_reset		= hsusb_link_clk_reset,
> +	.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 e9d4cd9..118798d 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"
>  
> @@ -308,33 +306,29 @@ static void ulpi_init(struct msm_otg *motg)
>  
>  static int msm_otg_link_clk_reset(struct msm_otg *motg, bool assert)
>  {
> -	int ret;
> +	int ret = 0;
> +
> +	if (!motg->pdata->link_clk_reset)
> +		return ret;
> +
> +	ret = motg->pdata->link_clk_reset(motg->clk, assert);
> +	if (ret)
> +		dev_err(motg->phy.dev, "usb link clk reset failed\n");
>  
> -	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;
> +	int ret = 0;
>  
> -	ret = clk_reset(motg->phy_reset_clk, CLK_RESET_ASSERT);
> -	if (ret) {
> -		dev_err(motg->phy.dev, "usb phy clk assert failed\n");
> +	if (!motg->pdata->phy_clk_reset)
>  		return ret;
> -	}
> -	usleep_range(10000, 12000);
> -	ret = clk_reset(motg->phy_reset_clk, CLK_RESET_DEASSERT);
> +
> +	ret = motg->pdata->phy_clk_reset(motg->phy_reset_clk);
>  	if (ret)
> -		dev_err(motg->phy.dev, "usb phy clk deassert failed\n");
> +		dev_err(motg->phy.dev, "usb phy clk assert failed\n");

seems like you're doing more than *just* fixing the build error. Which
build error do you get ?

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v3 02/13] usb: phy: msm: Move global regulators variables to driver state
  2013-10-14 15:24 ` [PATCH v3 02/13] usb: phy: msm: Move global regulators variables to driver state Ivan T. Ivanov
@ 2013-10-14 22:52   ` Felipe Balbi
  0 siblings, 0 replies; 19+ messages in thread
From: Felipe Balbi @ 2013-10-14 22:52 UTC (permalink / raw)
  To: Ivan T. Ivanov
  Cc: balbi, rob.herring, pawel.moll, mark.rutland, swarren,
	ijc+devicetree, rob, davidb, dwalker, bryanh, linux, gregkh,
	grant.likely, jackp, mgautam, dsegal, linux-usb, devicetree,
	linux-doc, linux-kernel, linux-arm-msm, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 208 bytes --]

On Mon, Oct 14, 2013 at 06:24:29PM +0300, Ivan T. Ivanov wrote:
> From: "Ivan T. Ivanov" <iivanov@mm-sol.com>
> 
> Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com>

this one looks good.

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v3 12/13] usb: phy: msm: Properly check core interrupt number
  2013-10-14 15:24 ` [PATCH v3 12/13] usb: phy: msm: Properly check core interrupt number Ivan T. Ivanov
@ 2013-10-14 22:59   ` Felipe Balbi
  2013-10-15  7:12     ` Ivan T. Ivanov
  0 siblings, 1 reply; 19+ messages in thread
From: Felipe Balbi @ 2013-10-14 22:59 UTC (permalink / raw)
  To: Ivan T. Ivanov
  Cc: balbi, rob.herring, pawel.moll, mark.rutland, swarren,
	ijc+devicetree, rob, davidb, dwalker, bryanh, linux, gregkh,
	grant.likely, jackp, mgautam, dsegal, linux-usb, devicetree,
	linux-doc, linux-kernel, linux-arm-msm, linux-arm-kernel

[-- Attachment #1: Type: text/plain, Size: 1005 bytes --]

On Mon, Oct 14, 2013 at 06:24:39PM +0300, Ivan T. Ivanov wrote:
> From: "Ivan T. Ivanov" <iivanov@mm-sol.com>
> 
> IRQ with number 0 is valid case, so check for negative

not entirelly correct... IRQ 0 isn't supposed to be used as a linux IRQ
number IIRC.

> numbers instead.
> 
> Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com>
> ---
>  drivers/usb/phy/phy-msm-usb.c |    2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
> index ca2abe6..f34c8a9 100644
> --- a/drivers/usb/phy/phy-msm-usb.c
> +++ b/drivers/usb/phy/phy-msm-usb.c
> @@ -1415,7 +1415,7 @@ static int __init msm_otg_probe(struct platform_device *pdev)
>  	dev_info(&pdev->dev, "OTG regs = %p\n", motg->regs);
>  
>  	motg->irq = platform_get_irq(pdev, 0);
> -	if (!motg->irq) {
> +	if (motg->irq < 0) {

this check is correct though, since platform_get_irq() will return
-ENXIO if it doesn't find IRQ resource.

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 836 bytes --]

^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v3 01/13] usb: phy: msm: Move mach depndend code to platform data
  2013-10-14 22:52   ` Felipe Balbi
@ 2013-10-15  7:01     ` Ivan T. Ivanov
  0 siblings, 0 replies; 19+ messages in thread
From: Ivan T. Ivanov @ 2013-10-15  7:01 UTC (permalink / raw)
  To: balbi
  Cc: rob.herring, pawel.moll, mark.rutland, swarren, ijc+devicetree,
	rob, davidb, dwalker, bryanh, linux, gregkh, grant.likely, jackp,
	mgautam, dsegal, linux-usb, devicetree, linux-doc, linux-kernel,
	linux-arm-msm, linux-arm-kernel

On Mon, 2013-10-14 at 17:52 -0500, Felipe Balbi wrote: 
> Hi,
> 
> On Mon, Oct 14, 2013 at 06:24:28PM +0300, Ivan T. Ivanov wrote:
> > From: "Ivan T. Ivanov" <iivanov@mm-sol.com>
> > 
> > This patch fix compilation error and is an intermediate step
> > before the addition of DeviceTree support for newer targets.
> > 
> > Cc: David Brown <davidb@codeaurora.org>
> > Cc: Daniel Walker <dwalker@fifo99.com>
> > Cc: Felipe Balbi <balbi@ti.com>
> > Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
> > Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com>
> > ---
> >  arch/arm/mach-msm/board-msm7x30.c |   35 +++++++++++++++++++++++++++++++++++
> >  arch/arm/mach-msm/board-qsd8x50.c |   35 +++++++++++++++++++++++++++++++++++
> >  drivers/usb/phy/phy-msm-usb.c     |   34 ++++++++++++++--------------------
> >  include/linux/usb/msm_hsusb.h     |    3 +++
> >  4 files changed, 87 insertions(+), 20 deletions(-)
> > 
> > diff --git a/arch/arm/mach-msm/board-msm7x30.c b/arch/arm/mach-msm/board-msm7x30.c
> > index f9af5a4..46de789 100644
> > --- a/arch/arm/mach-msm/board-msm7x30.c
> > +++ b/arch/arm/mach-msm/board-msm7x30.c
> > @@ -30,6 +30,7 @@
> >  #include <asm/memory.h>
> >  #include <asm/setup.h>
> >  
> > +#include <mach/clk.h>
> >  #include <mach/msm_iomap.h>
> >  #include <mach/dma.h>
> >  
> > @@ -60,10 +61,44 @@ static int hsusb_phy_init_seq[] = {
> >  	-1
> >  };
> >  
> > +static int hsusb_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,
> > +	.link_clk_reset		= hsusb_link_clk_reset,
> > +	.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 5f933bc..9169ec3 100644
> > --- a/arch/arm/mach-msm/board-qsd8x50.c
> > +++ b/arch/arm/mach-msm/board-qsd8x50.c
> > @@ -31,6 +31,7 @@
> >  #include <mach/irqs.h>
> >  #include <mach/sirc.h>
> >  #include <mach/vreg.h>
> > +#include <mach/clk.h>
> >  #include <linux/platform_data/mmc-msm_sdcc.h>
> >  
> >  #include "devices.h"
> > @@ -81,10 +82,44 @@ static int hsusb_phy_init_seq[] = {
> >  	-1
> >  };
> >  
> > +static int hsusb_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,
> > +	.link_clk_reset		= hsusb_link_clk_reset,
> > +	.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 e9d4cd9..118798d 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"
> >  
> > @@ -308,33 +306,29 @@ static void ulpi_init(struct msm_otg *motg)
> >  
> >  static int msm_otg_link_clk_reset(struct msm_otg *motg, bool assert)
> >  {
> > -	int ret;
> > +	int ret = 0;
> > +
> > +	if (!motg->pdata->link_clk_reset)
> > +		return ret;
> > +
> > +	ret = motg->pdata->link_clk_reset(motg->clk, assert);
> > +	if (ret)
> > +		dev_err(motg->phy.dev, "usb link clk reset failed\n");
> >  
> > -	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;
> > +	int ret = 0;
> >  
> > -	ret = clk_reset(motg->phy_reset_clk, CLK_RESET_ASSERT);
> > -	if (ret) {
> > -		dev_err(motg->phy.dev, "usb phy clk assert failed\n");
> > +	if (!motg->pdata->phy_clk_reset)
> >  		return ret;
> > -	}
> > -	usleep_range(10000, 12000);
> > -	ret = clk_reset(motg->phy_reset_clk, CLK_RESET_DEASSERT);
> > +
> > +	ret = motg->pdata->phy_clk_reset(motg->phy_reset_clk);
> >  	if (ret)
> > -		dev_err(motg->phy.dev, "usb phy clk deassert failed\n");
> > +		dev_err(motg->phy.dev, "usb phy clk assert failed\n");
> 
> seems like you're doing more than *just* fixing the build error. Which
> build error do you get ?

clk_reset() is defined only in mach code which is not available in 
multi platform builds. But you are right, probably I have to mention
that some error messages are also changed. 

With this change driver will loss ability to reset PHY and LINk
controllers on newer targets, but I don't think it is functional 
on them right now (driver resources are not defined on these
boards). I am planing to add reset framework support to driver in
order to support them.

Regards,
Ivan



^ permalink raw reply	[flat|nested] 19+ messages in thread

* Re: [PATCH v3 12/13] usb: phy: msm: Properly check core interrupt number
  2013-10-14 22:59   ` Felipe Balbi
@ 2013-10-15  7:12     ` Ivan T. Ivanov
  0 siblings, 0 replies; 19+ messages in thread
From: Ivan T. Ivanov @ 2013-10-15  7:12 UTC (permalink / raw)
  To: balbi
  Cc: mark.rutland, linux-doc, dwalker, linux, swarren, grant.likely,
	davidb, devicetree, jackp, pawel.moll, ijc+devicetree,
	linux-arm-msm, rob.herring, linux-arm-kernel, dsegal, gregkh,
	linux-usb, linux-kernel, mgautam, bryanh, rob

On Mon, 2013-10-14 at 17:59 -0500, Felipe Balbi wrote: 
> On Mon, Oct 14, 2013 at 06:24:39PM +0300, Ivan T. Ivanov wrote:
> > From: "Ivan T. Ivanov" <iivanov@mm-sol.com>
> > 
> > IRQ with number 0 is valid case, so check for negative
> 
> not entirelly correct... IRQ 0 isn't supposed to be used as a linux IRQ
> number IIRC.

I am not really sure. NO_IRQ is -1 at least on ARM. Also when
taking into account irqdomain's zero as interrupt number is valid??

> 
> > numbers instead.
> > 
> > Signed-off-by: Ivan T. Ivanov <iivanov@mm-sol.com>
> > ---
> >  drivers/usb/phy/phy-msm-usb.c |    2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c
> > index ca2abe6..f34c8a9 100644
> > --- a/drivers/usb/phy/phy-msm-usb.c
> > +++ b/drivers/usb/phy/phy-msm-usb.c
> > @@ -1415,7 +1415,7 @@ static int __init msm_otg_probe(struct platform_device *pdev)
> >  	dev_info(&pdev->dev, "OTG regs = %p\n", motg->regs);
> >  
> >  	motg->irq = platform_get_irq(pdev, 0);
> > -	if (!motg->irq) {
> > +	if (motg->irq < 0) {
> 
> this check is correct though, since platform_get_irq() will return
> -ENXIO if it doesn't find IRQ resource.
> 

Thanks,
Ivan


^ permalink raw reply	[flat|nested] 19+ messages in thread

end of thread, other threads:[~2013-10-15  7:13 UTC | newest]

Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-14 15:24 [PATCH v3 00/13] usb: phy: msm: Fixes, cleanups and DT support Ivan T. Ivanov
2013-10-14 15:24 ` [PATCH v3 01/13] usb: phy: msm: Move mach depndend code to platform data Ivan T. Ivanov
2013-10-14 22:52   ` Felipe Balbi
2013-10-15  7:01     ` Ivan T. Ivanov
2013-10-14 15:24 ` [PATCH v3 02/13] usb: phy: msm: Move global regulators variables to driver state Ivan T. Ivanov
2013-10-14 22:52   ` Felipe Balbi
2013-10-14 15:24 ` [PATCH v3 03/13] usb: phy: msm: Migrate to Managed Device Resource allocation Ivan T. Ivanov
2013-10-14 15:24 ` [PATCH v3 04/13] usb: phy: msm: Remove unnecessarily check for valid regulators Ivan T. Ivanov
2013-10-14 15:24 ` [PATCH v3 05/13] usb: phy: msm: Fix WARNING: quoted string split across lines Ivan T. Ivanov
2013-10-14 15:24 ` [PATCH v3 06/13] usb: phy: msm: Fix WARNING: Prefer seq_puts to seq_printf Ivan T. Ivanov
2013-10-14 15:24 ` [PATCH v3 07/13] usb: phy: msm: Replace custom enum usb_mode_type with enum usb_dr_mode Ivan T. Ivanov
2013-10-14 15:24 ` [PATCH v3 08/13] usb: phy: msm: Drop default usb_dr_mode from platform data Ivan T. Ivanov
2013-10-14 15:24 ` [PATCH v3 09/13] usb: phy: msm: Remove unused pclk_src_name Ivan T. Ivanov
2013-10-14 15:24 ` [PATCH v3 10/13] usb: phy: msm: Switch clock consumer strings Ivan T. Ivanov
2013-10-14 15:24 ` [PATCH v3 11/13] usb: phy: msm: Remove HSUSB prefix from requlator names Ivan T. Ivanov
2013-10-14 15:24 ` [PATCH v3 12/13] usb: phy: msm: Properly check core interrupt number Ivan T. Ivanov
2013-10-14 22:59   ` Felipe Balbi
2013-10-15  7:12     ` Ivan T. Ivanov
2013-10-14 15:24 ` [PATCH v3 13/13] usb: phy: msm: Add device tree support and binding information Ivan T. Ivanov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).