All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 00/12] Add power management support for MXS PHY
@ 2013-10-12  9:09 Peter Chen
  2013-10-12  9:09 ` [PATCH 01/12] usb: phy-mxs: Add auto clock and power setting Peter Chen
                   ` (11 more replies)
  0 siblings, 12 replies; 32+ messages in thread
From: Peter Chen @ 2013-10-12  9:09 UTC (permalink / raw)
  To: linux-arm-kernel

Hi Felipe,

The serial adds power management support for MXS PHY, it includes:

- Add three common PHY API, .set_wakeup, .notify_suspend, notify_resume.
- Related above API implementation at mxs phy driver
- misc changes for mxs phy to support low power mode and wakeup.

Hi Shawn,

The last four are devicetree related patches to support above
mxs phy features.

Peter Chen (12):
  usb: phy-mxs: Add auto clock and power setting
  usb: phy-mxs: Enable IC fixes for mx6 SoC serial
  usb: phy-mxs: Add anatop regmap
  usb: phy: add notify suspend and resume callback
  usb: phy-mxs: Add implementation of nofity_suspend and notify_resume
  usb: phy: Add set_wakeup API
  usb: phy-mxs: Add implementation of set_wakeup
  usb: phy-mxs: Add system suspend/resume API
  usb: phy-mxs: update binding for adding anatop phandle
  ARM: dts: imx6: add anatop phandle for usbphy
  usb: phy-mxs: update binding for adding disconnect line property
  ARM: dts: imx6: Add disconnect_line_without_vbus property for usbphy

 Documentation/devicetree/bindings/usb/mxs-phy.txt |    6 +
 arch/arm/boot/dts/imx6qdl.dtsi                    |    3 +
 drivers/usb/phy/phy-mxs-usb.c                     |  247 ++++++++++++++++++++-
 include/linux/usb/phy.h                           |   39 ++++
 4 files changed, 291 insertions(+), 4 deletions(-)

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

* [PATCH 01/12] usb: phy-mxs: Add auto clock and power setting
  2013-10-12  9:09 [PATCH 00/12] Add power management support for MXS PHY Peter Chen
@ 2013-10-12  9:09 ` Peter Chen
  2013-10-12  9:09 ` [PATCH 02/12] usb: phy-mxs: Enable IC fixes for mx6 SoC serial Peter Chen
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 32+ messages in thread
From: Peter Chen @ 2013-10-12  9:09 UTC (permalink / raw)
  To: linux-arm-kernel

With the auto setting, the PHY's clock and power can be
recovered correctly from low power mode, it is ganranteed by IC logic.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
 drivers/usb/phy/phy-mxs-usb.c |   20 +++++++++++++++++---
 1 files changed, 17 insertions(+), 3 deletions(-)

diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index a0628d6..87ba429 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -31,6 +31,11 @@
 
 #define BM_USBPHY_CTRL_SFTRST			BIT(31)
 #define BM_USBPHY_CTRL_CLKGATE			BIT(30)
+#define BM_USBPHY_CTRL_ENAUTOSET_USBCLKS	BIT(26)
+#define BM_USBPHY_CTRL_ENAUTOCLR_USBCLKGATE	BIT(25)
+#define BM_USBPHY_CTRL_ENAUTOCLR_PHY_PWD	BIT(20)
+#define BM_USBPHY_CTRL_ENAUTOCLR_CLKGATE	BIT(19)
+#define BM_USBPHY_CTRL_ENAUTO_PWRON_PLL		BIT(18)
 #define BM_USBPHY_CTRL_ENUTMILEVEL3		BIT(15)
 #define BM_USBPHY_CTRL_ENUTMILEVEL2		BIT(14)
 #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT	BIT(1)
@@ -99,9 +104,18 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
 	/* Power up the PHY */
 	writel(0, base + HW_USBPHY_PWD);
 
-	/* enable FS/LS device */
-	writel(BM_USBPHY_CTRL_ENUTMILEVEL2 |
-	       BM_USBPHY_CTRL_ENUTMILEVEL3,
+	/*
+	 * USB PHY Ctrl Setting
+	 * - Auto clock/power on
+	 * - Enable full/low speed support
+	 */
+	writel(BM_USBPHY_CTRL_ENAUTOSET_USBCLKS |
+		BM_USBPHY_CTRL_ENAUTOCLR_USBCLKGATE |
+		BM_USBPHY_CTRL_ENAUTOCLR_PHY_PWD |
+		BM_USBPHY_CTRL_ENAUTOCLR_CLKGATE |
+		BM_USBPHY_CTRL_ENAUTO_PWRON_PLL |
+		BM_USBPHY_CTRL_ENUTMILEVEL2 |
+		BM_USBPHY_CTRL_ENUTMILEVEL3,
 	       base + HW_USBPHY_CTRL_SET);
 
 	return 0;
-- 
1.7.1

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

* [PATCH 02/12] usb: phy-mxs: Enable IC fixes for mx6 SoC serial
  2013-10-12  9:09 [PATCH 00/12] Add power management support for MXS PHY Peter Chen
  2013-10-12  9:09 ` [PATCH 01/12] usb: phy-mxs: Add auto clock and power setting Peter Chen
@ 2013-10-12  9:09 ` Peter Chen
  2013-10-12  9:38   ` Marek Vasut
  2013-10-14  9:09   ` Shawn Guo
  2013-10-12  9:09 ` [PATCH 03/12] usb: phy-mxs: Add anatop regmap Peter Chen
                   ` (9 subsequent siblings)
  11 siblings, 2 replies; 32+ messages in thread
From: Peter Chen @ 2013-10-12  9:09 UTC (permalink / raw)
  To: linux-arm-kernel

After adding IC fixes bits, some PHY bugs are fixed by
IC logic.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
 drivers/usb/phy/phy-mxs-usb.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index 87ba429..831b13e 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -29,6 +29,10 @@
 #define HW_USBPHY_CTRL_SET			0x34
 #define HW_USBPHY_CTRL_CLR			0x38
 
+#define HW_USBPHY_IP				0x90
+#define HW_USBPHY_IP_SET			0x94
+#define HW_USBPHY_IP_CLR			0x98
+
 #define BM_USBPHY_CTRL_SFTRST			BIT(31)
 #define BM_USBPHY_CTRL_CLKGATE			BIT(30)
 #define BM_USBPHY_CTRL_ENAUTOSET_USBCLKS	BIT(26)
@@ -40,6 +44,8 @@
 #define BM_USBPHY_CTRL_ENUTMILEVEL2		BIT(14)
 #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT	BIT(1)
 
+#define BM_USBPHY_IP_FIX                       (BIT(17) | BIT(18))
+
 #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
 
 enum imx_phy_type {
@@ -118,6 +124,10 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
 		BM_USBPHY_CTRL_ENUTMILEVEL3,
 	       base + HW_USBPHY_CTRL_SET);
 
+	/* Enable IC solution */
+	if (is_mx6q_phy(mxs_phy) || is_mx6sl_phy(mxs_phy))
+		writel(BM_USBPHY_IP_FIX, base + HW_USBPHY_IP_SET);
+
 	return 0;
 }
 
-- 
1.7.1

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

* [PATCH 03/12] usb: phy-mxs: Add anatop regmap
  2013-10-12  9:09 [PATCH 00/12] Add power management support for MXS PHY Peter Chen
  2013-10-12  9:09 ` [PATCH 01/12] usb: phy-mxs: Add auto clock and power setting Peter Chen
  2013-10-12  9:09 ` [PATCH 02/12] usb: phy-mxs: Enable IC fixes for mx6 SoC serial Peter Chen
@ 2013-10-12  9:09 ` Peter Chen
  2013-10-12  9:09 ` [PATCH 04/12] usb: phy: add notify suspend and resume callback Peter Chen
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 32+ messages in thread
From: Peter Chen @ 2013-10-12  9:09 UTC (permalink / raw)
  To: linux-arm-kernel

It is needed by mx6 SoC serial, but not for mx23 and mx28.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
 drivers/usb/phy/phy-mxs-usb.c |   17 ++++++++++++++++-
 1 files changed, 16 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index 831b13e..e0b0de0 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -21,6 +21,8 @@
 #include <linux/err.h>
 #include <linux/io.h>
 #include <linux/of_device.h>
+#include <linux/regmap.h>
+#include <linux/mfd/syscon.h>
 
 #define DRIVER_NAME "mxs_phy"
 
@@ -58,6 +60,7 @@ struct mxs_phy {
 	struct usb_phy phy;
 	struct clk *clk;
 	enum imx_phy_type devtype;
+	struct regmap *regmap_anatop;
 };
 
 static inline int is_mx6q_phy(struct mxs_phy *data)
@@ -203,9 +206,10 @@ static int mxs_phy_probe(struct platform_device *pdev)
 	int ret;
 	const struct of_device_id *of_id =
 			of_match_device(mxs_phy_dt_ids, &pdev->dev);
+	struct device_node *np = pdev->dev.of_node;
 
 	/* This driver is DT-only version now */
-	if (!of_id)
+	if (!of_id || !np)
 		return -ENXIO;
 
 	pdev->id_entry = of_id->data;
@@ -228,6 +232,17 @@ static int mxs_phy_probe(struct platform_device *pdev)
 		return -ENOMEM;
 	}
 
+	/* Some SoCs don't have anatop registers */
+	if (of_get_property(np, "fsl,anatop", NULL)) {
+		mxs_phy->regmap_anatop = syscon_regmap_lookup_by_phandle
+			(np, "fsl,anatop");
+		if (IS_ERR(mxs_phy->regmap_anatop)) {
+			dev_dbg(&pdev->dev,
+				"failed to find regmap for anatop\n");
+			return PTR_ERR(mxs_phy->regmap_anatop);
+		}
+	}
+
 	mxs_phy->phy.io_priv		= base;
 	mxs_phy->phy.dev		= &pdev->dev;
 	mxs_phy->phy.label		= DRIVER_NAME;
-- 
1.7.1

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

* [PATCH 04/12] usb: phy: add notify suspend and resume callback
  2013-10-12  9:09 [PATCH 00/12] Add power management support for MXS PHY Peter Chen
                   ` (2 preceding siblings ...)
  2013-10-12  9:09 ` [PATCH 03/12] usb: phy-mxs: Add anatop regmap Peter Chen
@ 2013-10-12  9:09 ` Peter Chen
  2013-10-12  9:09 ` [PATCH 05/12] usb: phy-mxs: Add implementation of nofity_suspend and notify_resume Peter Chen
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 32+ messages in thread
From: Peter Chen @ 2013-10-12  9:09 UTC (permalink / raw)
  To: linux-arm-kernel

They are used to notify PHY that the controller enters suspend
or finishes resume.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
 include/linux/usb/phy.h |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index 6c0b1c5..a747960 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -116,6 +116,11 @@ struct usb_phy {
 			enum usb_device_speed speed);
 	int	(*notify_disconnect)(struct usb_phy *x,
 			enum usb_device_speed speed);
+	int	(*notify_suspend)(struct usb_phy *x,
+			enum usb_device_speed speed);
+	int	(*notify_resume)(struct usb_phy *x,
+			enum usb_device_speed speed);
+
 };
 
 /**
@@ -282,6 +287,24 @@ usb_phy_notify_disconnect(struct usb_phy *x, enum usb_device_speed speed)
 		return 0;
 }
 
+static inline int usb_phy_notify_suspend
+	(struct usb_phy *x, enum usb_device_speed speed)
+{
+	if (x && x->notify_suspend)
+		return x->notify_suspend(x, speed);
+	else
+		return 0;
+}
+
+static inline int usb_phy_notify_resume
+	(struct usb_phy *x, enum usb_device_speed speed)
+{
+	if (x && x->notify_resume)
+		return x->notify_resume(x, speed);
+	else
+		return 0;
+}
+
 /* notifiers */
 static inline int
 usb_register_notifier(struct usb_phy *x, struct notifier_block *nb)
-- 
1.7.1

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

* [PATCH 05/12] usb: phy-mxs: Add implementation of nofity_suspend and notify_resume
  2013-10-12  9:09 [PATCH 00/12] Add power management support for MXS PHY Peter Chen
                   ` (3 preceding siblings ...)
  2013-10-12  9:09 ` [PATCH 04/12] usb: phy: add notify suspend and resume callback Peter Chen
@ 2013-10-12  9:09 ` Peter Chen
  2013-10-12  9:42   ` Marek Vasut
  2013-10-12  9:09 ` [PATCH 06/12] usb: phy: Add set_wakeup API Peter Chen
                   ` (6 subsequent siblings)
  11 siblings, 1 reply; 32+ messages in thread
From: Peter Chen @ 2013-10-12  9:09 UTC (permalink / raw)
  To: linux-arm-kernel

Add notify_suspend and notify_resume according to different SoCs.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
 drivers/usb/phy/phy-mxs-usb.c |   73 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 73 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index e0b0de0..8661dae 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -197,6 +197,78 @@ static int mxs_phy_on_disconnect(struct usb_phy *phy,
 	return 0;
 }
 
+static int mxs_phy_on_suspend_workaround(struct usb_phy *phy,
+		enum usb_device_speed speed)
+{
+	dev_dbg(phy->dev, "%s speed device has suspended\n",
+		(speed == USB_SPEED_HIGH) ? "high" : "non-high");
+
+	/* delay 4ms to wait bus entering idle */
+	usleep_range(4000, 5000);
+
+	/*
+	 * Workaround for wakeup signal between portsc.suspendM
+	 * and PHY enters low power mode.
+	 */
+	writel_relaxed(0xffffffff, phy->io_priv + HW_USBPHY_PWD);
+	writel_relaxed(0, phy->io_priv + HW_USBPHY_PWD);
+
+	if (speed == USB_SPEED_HIGH)
+		writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT,
+				phy->io_priv + HW_USBPHY_CTRL_CLR);
+
+	return 0;
+}
+
+static int mxs_phy_on_suspend(struct usb_phy *phy,
+		enum usb_device_speed speed)
+{
+	dev_dbg(phy->dev, "%s speed device has suspended\n",
+		(speed == USB_SPEED_HIGH) ? "high" : "non-high");
+
+	if (speed == USB_SPEED_HIGH)
+		writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT,
+				phy->io_priv + HW_USBPHY_CTRL_CLR);
+
+	return 0;
+}
+
+/*
+ * The resume signal must be finished here.
+ */
+static int mxs_phy_on_resume(struct usb_phy *phy,
+		enum usb_device_speed speed)
+{
+	dev_dbg(phy->dev, "%s speed device has resumed\n",
+		(speed == USB_SPEED_HIGH) ? "high" : "non-high");
+
+	if (speed == USB_SPEED_HIGH) {
+		/* Make sure the device has switched to High-Speed mode */
+		udelay(500);
+		writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT,
+				phy->io_priv + HW_USBPHY_CTRL_SET);
+	}
+
+	return 0;
+}
+
+/*
+ * For mxs PHY, there are two PHY issues related to suspend/resume.
+ * For mx23 and mx28, both of two issues are existed.
+ * For mx6q and mx6dl, only one issue is existed.
+ * For mx6 sololite, none issue is existed.
+ */
+static void mxs_phy_workaround(struct mxs_phy *mxs_phy)
+{
+	if (is_mx23_phy(mxs_phy)) {
+		mxs_phy->phy.notify_suspend = mxs_phy_on_suspend_workaround;
+		mxs_phy->phy.notify_resume = mxs_phy_on_resume;
+	} else if (is_mx6q_phy(mxs_phy)) {
+		mxs_phy->phy.notify_suspend = mxs_phy_on_suspend;
+		mxs_phy->phy.notify_resume = mxs_phy_on_resume;
+	}
+}
+
 static int mxs_phy_probe(struct platform_device *pdev)
 {
 	struct resource *res;
@@ -257,6 +329,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
 
 	mxs_phy->clk = clk;
 	mxs_phy->devtype = pdev->id_entry->driver_data;
+	mxs_phy_workaround(mxs_phy);
 
 	platform_set_drvdata(pdev, &mxs_phy->phy);
 
-- 
1.7.1

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

* [PATCH 06/12] usb: phy: Add set_wakeup API
  2013-10-12  9:09 [PATCH 00/12] Add power management support for MXS PHY Peter Chen
                   ` (4 preceding siblings ...)
  2013-10-12  9:09 ` [PATCH 05/12] usb: phy-mxs: Add implementation of nofity_suspend and notify_resume Peter Chen
@ 2013-10-12  9:09 ` Peter Chen
  2013-10-12  9:09 ` [PATCH 07/12] usb: phy-mxs: Add implementation of set_wakeup Peter Chen
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 32+ messages in thread
From: Peter Chen @ 2013-10-12  9:09 UTC (permalink / raw)
  To: linux-arm-kernel

This API is used to set wakeup enable at PHY registers, in that
case, the PHY can be waken up from suspend due to external events,
like vbus change, dp/dm change and id change.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
 include/linux/usb/phy.h |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/include/linux/usb/phy.h b/include/linux/usb/phy.h
index a747960..c6ebe1d 100644
--- a/include/linux/usb/phy.h
+++ b/include/linux/usb/phy.h
@@ -111,6 +111,13 @@ struct usb_phy {
 	int	(*set_suspend)(struct usb_phy *x,
 				int suspend);
 
+	/*
+	 * Set wakeup enable for PHY, in that case, the PHY can be
+	 * waken up from suspend status due to external events,
+	 * like vbus change, dp/dm change and id.
+	 */
+	int	(*set_wakeup)(struct usb_phy *x, bool enabled);
+
 	/* notify phy connect status change */
 	int	(*notify_connect)(struct usb_phy *x,
 			enum usb_device_speed speed);
@@ -270,6 +277,15 @@ usb_phy_set_suspend(struct usb_phy *x, int suspend)
 }
 
 static inline int
+usb_phy_set_wakeup(struct usb_phy *x, bool enabled)
+{
+	if (x && x->set_wakeup)
+		return x->set_wakeup(x, enabled);
+	else
+		return 0;
+}
+
+static inline int
 usb_phy_notify_connect(struct usb_phy *x, enum usb_device_speed speed)
 {
 	if (x && x->notify_connect)
-- 
1.7.1

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

* [PATCH 07/12] usb: phy-mxs: Add implementation of set_wakeup
  2013-10-12  9:09 [PATCH 00/12] Add power management support for MXS PHY Peter Chen
                   ` (5 preceding siblings ...)
  2013-10-12  9:09 ` [PATCH 06/12] usb: phy: Add set_wakeup API Peter Chen
@ 2013-10-12  9:09 ` Peter Chen
  2013-10-12  9:44   ` Marek Vasut
  2013-10-12  9:09 ` [PATCH 08/12] usb: phy-mxs: Add system suspend/resume API Peter Chen
                   ` (4 subsequent siblings)
  11 siblings, 1 reply; 32+ messages in thread
From: Peter Chen @ 2013-10-12  9:09 UTC (permalink / raw)
  To: linux-arm-kernel

When we need the PHY can be waken up by external signals,
we can call this API. Besides, we call mxs_phy_disconnect_line
at this API to close the connection between USB PHY and
controller, after that, the line state from controller is SE0.
Once the PHY is out of power, without calling mxs_phy_disconnect_line,
there are unknown wakeups due to dp/dm floating at device mode.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
 drivers/usb/phy/phy-mxs-usb.c |   82 ++++++++++++++++++++++++++++++++++++++++-
 1 files changed, 81 insertions(+), 1 deletions(-)

diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index 8661dae..693f9a4 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -31,6 +31,9 @@
 #define HW_USBPHY_CTRL_SET			0x34
 #define HW_USBPHY_CTRL_CLR			0x38
 
+#define HW_USBPHY_DEBUG_SET			0x54
+#define HW_USBPHY_DEBUG_CLR			0x58
+
 #define HW_USBPHY_IP				0x90
 #define HW_USBPHY_IP_SET			0x94
 #define HW_USBPHY_IP_CLR			0x98
@@ -39,6 +42,9 @@
 #define BM_USBPHY_CTRL_CLKGATE			BIT(30)
 #define BM_USBPHY_CTRL_ENAUTOSET_USBCLKS	BIT(26)
 #define BM_USBPHY_CTRL_ENAUTOCLR_USBCLKGATE	BIT(25)
+#define BM_USBPHY_CTRL_ENVBUSCHG_WKUP		BIT(23)
+#define BM_USBPHY_CTRL_ENIDCHG_WKUP		BIT(22)
+#define BM_USBPHY_CTRL_ENDPDMCHG_WKUP		BIT(21)
 #define BM_USBPHY_CTRL_ENAUTOCLR_PHY_PWD	BIT(20)
 #define BM_USBPHY_CTRL_ENAUTOCLR_CLKGATE	BIT(19)
 #define BM_USBPHY_CTRL_ENAUTO_PWRON_PLL		BIT(18)
@@ -46,7 +52,20 @@
 #define BM_USBPHY_CTRL_ENUTMILEVEL2		BIT(14)
 #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT	BIT(1)
 
-#define BM_USBPHY_IP_FIX                       (BIT(17) | BIT(18))
+#define BM_USBPHY_IP_FIX			(BIT(17) | BIT(18))
+
+#define BM_USBPHY_DEBUG_CLKGATE			BIT(30)
+
+/* Anatop Registers */
+#define ANADIG_USB1_VBUS_DET_STAT		0x1c0
+
+#define ANADIG_USB1_LOOPBACK_SET		0x1e4
+#define ANADIG_USB1_LOOPBACK_CLR		0x1e8
+
+#define BM_ANADIG_USB1_VBUS_DET_STAT_VBUS_VALID	BIT(3)
+
+#define BM_ANADIG_USB1_LOOPBACK_UTMI_DIG_TST1	BIT(2)
+#define BM_ANADIG_USB1_LOOPBACK_TSTI_TX_EN	BIT(5)
 
 #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
 
@@ -61,6 +80,7 @@ struct mxs_phy {
 	struct clk *clk;
 	enum imx_phy_type devtype;
 	struct regmap *regmap_anatop;
+	bool disconnect_line_without_vbus_is_needed;
 };
 
 static inline int is_mx6q_phy(struct mxs_phy *data)
@@ -134,6 +154,44 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
 	return 0;
 }
 
+static void mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool on)
+{
+	void __iomem *base = mxs_phy->phy.io_priv;
+	bool vbus_is_on = false;
+	static bool line_is_disconnected;
+	unsigned int vbus_value = 0;
+
+	/* Only the SoCs have anatop need below operation */
+	if (!mxs_phy->disconnect_line_without_vbus_is_needed)
+		return;
+
+	regmap_read(mxs_phy->regmap_anatop, ANADIG_USB1_VBUS_DET_STAT,
+			&vbus_value);
+	if (vbus_value & BM_ANADIG_USB1_VBUS_DET_STAT_VBUS_VALID)
+		vbus_is_on = true;
+
+	if (on && !vbus_is_on) {
+		writel_relaxed(BM_USBPHY_DEBUG_CLKGATE,
+			base + HW_USBPHY_DEBUG_CLR);
+		regmap_write(mxs_phy->regmap_anatop, ANADIG_USB1_LOOPBACK_SET,
+				BM_ANADIG_USB1_LOOPBACK_UTMI_DIG_TST1 |
+				BM_ANADIG_USB1_LOOPBACK_TSTI_TX_EN);
+		/* Delay some time, and let Linestate be SE0 for controller */
+		usleep_range(500, 1000);
+		line_is_disconnected = true;
+	} else if (line_is_disconnected) {
+		regmap_write(mxs_phy->regmap_anatop, ANADIG_USB1_LOOPBACK_CLR,
+				BM_ANADIG_USB1_LOOPBACK_UTMI_DIG_TST1 |
+				BM_ANADIG_USB1_LOOPBACK_TSTI_TX_EN);
+		writel_relaxed(BM_USBPHY_DEBUG_CLKGATE,
+				base + HW_USBPHY_DEBUG_SET);
+		line_is_disconnected = false;
+	}
+
+	dev_dbg(mxs_phy->phy.dev, "line is %s\n", line_is_disconnected
+			? "disconnected" : "connected");
+}
+
 static int mxs_phy_init(struct usb_phy *phy)
 {
 	struct mxs_phy *mxs_phy = to_mxs_phy(phy);
@@ -171,6 +229,23 @@ static int mxs_phy_suspend(struct usb_phy *x, int suspend)
 	return 0;
 }
 
+static int mxs_phy_set_wakeup(struct usb_phy *x, bool enabled)
+{
+	struct mxs_phy *mxs_phy = to_mxs_phy(x);
+	u32 value = BM_USBPHY_CTRL_ENVBUSCHG_WKUP |
+			BM_USBPHY_CTRL_ENDPDMCHG_WKUP |
+				BM_USBPHY_CTRL_ENIDCHG_WKUP;
+	if (enabled) {
+		mxs_phy_disconnect_line(mxs_phy, true);
+		writel_relaxed(value, x->io_priv + HW_USBPHY_CTRL_SET);
+	} else {
+		writel_relaxed(value, x->io_priv + HW_USBPHY_CTRL_CLR);
+		mxs_phy_disconnect_line(mxs_phy, false);
+	}
+
+	return 0;
+}
+
 static int mxs_phy_on_connect(struct usb_phy *phy,
 		enum usb_device_speed speed)
 {
@@ -315,6 +390,10 @@ static int mxs_phy_probe(struct platform_device *pdev)
 		}
 	}
 
+	if (of_find_property(np, "disconnect_line_without_vbus", NULL) &&
+			mxs_phy->regmap_anatop)
+		mxs_phy->disconnect_line_without_vbus_is_needed = true;
+
 	mxs_phy->phy.io_priv		= base;
 	mxs_phy->phy.dev		= &pdev->dev;
 	mxs_phy->phy.label		= DRIVER_NAME;
@@ -324,6 +403,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
 	mxs_phy->phy.notify_connect	= mxs_phy_on_connect;
 	mxs_phy->phy.notify_disconnect	= mxs_phy_on_disconnect;
 	mxs_phy->phy.type		= USB_PHY_TYPE_USB2;
+	mxs_phy->phy.set_wakeup		= mxs_phy_set_wakeup;
 
 	ATOMIC_INIT_NOTIFIER_HEAD(&mxs_phy->phy.notifier);
 
-- 
1.7.1

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

* [PATCH 08/12] usb: phy-mxs: Add system suspend/resume API
  2013-10-12  9:09 [PATCH 00/12] Add power management support for MXS PHY Peter Chen
                   ` (6 preceding siblings ...)
  2013-10-12  9:09 ` [PATCH 07/12] usb: phy-mxs: Add implementation of set_wakeup Peter Chen
@ 2013-10-12  9:09 ` Peter Chen
  2013-10-12  9:09 ` [PATCH 09/12] usb: phy-mxs: update binding for adding anatop phandle Peter Chen
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 32+ messages in thread
From: Peter Chen @ 2013-10-12  9:09 UTC (permalink / raw)
  To: linux-arm-kernel

We need this to keep PHY's power on or off during the system
suspend mode. If we need to enable USB wakeup, then we
must keep PHY's power being on during the system suspend mode.
Otherwise, we need to keep PHY's power being off to save power.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
 drivers/usb/phy/phy-mxs-usb.c |   47 +++++++++++++++++++++++++++++++++++++++++
 1 files changed, 47 insertions(+), 0 deletions(-)

diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index 693f9a4..a91ddc0 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -57,11 +57,18 @@
 #define BM_USBPHY_DEBUG_CLKGATE			BIT(30)
 
 /* Anatop Registers */
+#define ANADIG_ANA_MISC0			0x150
+#define ANADIG_ANA_MISC0_SET			0x154
+#define ANADIG_ANA_MISC0_CLR			0x158
+
 #define ANADIG_USB1_VBUS_DET_STAT		0x1c0
 
 #define ANADIG_USB1_LOOPBACK_SET		0x1e4
 #define ANADIG_USB1_LOOPBACK_CLR		0x1e8
 
+#define BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG	BIT(12)
+#define BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG_SL BIT(11)
+
 #define BM_ANADIG_USB1_VBUS_DET_STAT_VBUS_VALID	BIT(3)
 
 #define BM_ANADIG_USB1_LOOPBACK_UTMI_DIG_TST1	BIT(2)
@@ -192,6 +199,22 @@ static void mxs_phy_disconnect_line(struct mxs_phy *mxs_phy, bool on)
 			? "disconnected" : "connected");
 }
 
+static void mxs_phy_enable_ldo_in_suspend(struct mxs_phy *mxs_phy, bool on)
+{
+	unsigned int reg = on ? ANADIG_ANA_MISC0_SET : ANADIG_ANA_MISC0_CLR;
+
+	/* Only the SoCs have anatop need below operation */
+	if (!mxs_phy->regmap_anatop)
+		return;
+
+	if (is_mx6q_phy(mxs_phy))
+		regmap_write(mxs_phy->regmap_anatop, reg,
+			BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG);
+	else if (is_mx6sl_phy(mxs_phy))
+		regmap_write(mxs_phy->regmap_anatop,
+			reg, BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG_SL);
+}
+
 static int mxs_phy_init(struct usb_phy *phy)
 {
 	struct mxs_phy *mxs_phy = to_mxs_phy(phy);
@@ -413,6 +436,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
 
 	platform_set_drvdata(pdev, &mxs_phy->phy);
 
+	device_set_wakeup_capable(&pdev->dev, true);
 	ret = usb_add_phy_dev(&mxs_phy->phy);
 	if (ret)
 		return ret;
@@ -429,6 +453,28 @@ static int mxs_phy_remove(struct platform_device *pdev)
 	return 0;
 }
 
+static int mxs_phy_system_suspend(struct device *dev)
+{
+	struct mxs_phy *mxs_phy = dev_get_drvdata(dev);
+
+	if (device_may_wakeup(dev))
+		mxs_phy_enable_ldo_in_suspend(mxs_phy, true);
+
+	return 0;
+}
+
+static int mxs_phy_system_resume(struct device *dev)
+{
+	struct mxs_phy *mxs_phy = dev_get_drvdata(dev);
+
+	if (device_may_wakeup(dev))
+		mxs_phy_enable_ldo_in_suspend(mxs_phy, false);
+
+	return 0;
+}
+
+SIMPLE_DEV_PM_OPS(mxs_phy_pm, mxs_phy_system_suspend, mxs_phy_system_resume);
+
 static struct platform_driver mxs_phy_driver = {
 	.probe = mxs_phy_probe,
 	.remove = mxs_phy_remove,
@@ -436,6 +482,7 @@ static struct platform_driver mxs_phy_driver = {
 		.name = DRIVER_NAME,
 		.owner	= THIS_MODULE,
 		.of_match_table = mxs_phy_dt_ids,
+		.pm = &mxs_phy_pm,
 	 },
 };
 
-- 
1.7.1

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

* [PATCH 09/12] usb: phy-mxs: update binding for adding anatop phandle
  2013-10-12  9:09 [PATCH 00/12] Add power management support for MXS PHY Peter Chen
                   ` (7 preceding siblings ...)
  2013-10-12  9:09 ` [PATCH 08/12] usb: phy-mxs: Add system suspend/resume API Peter Chen
@ 2013-10-12  9:09 ` Peter Chen
  2013-10-14  9:22   ` Shawn Guo
  2013-10-12  9:09 ` [PATCH 10/12] ARM: dts: imx6: add anatop phandle for usbphy Peter Chen
                   ` (2 subsequent siblings)
  11 siblings, 1 reply; 32+ messages in thread
From: Peter Chen @ 2013-10-12  9:09 UTC (permalink / raw)
  To: linux-arm-kernel

Add anatop phandle which is used to access anatop registers to
control PHY's power and other USB operations.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
 Documentation/devicetree/bindings/usb/mxs-phy.txt |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/mxs-phy.txt b/Documentation/devicetree/bindings/usb/mxs-phy.txt
index 5835b27..1a9bd85 100644
--- a/Documentation/devicetree/bindings/usb/mxs-phy.txt
+++ b/Documentation/devicetree/bindings/usb/mxs-phy.txt
@@ -4,10 +4,12 @@ Required properties:
 - compatible: Should be "fsl,imx23-usbphy"
 - reg: Should contain registers location and length
 - interrupts: Should contain phy interrupt
+- fsl,anatop: phandle for anatop register
 
 Example:
 usbphy1: usbphy at 020c9000 {
 	compatible = "fsl,imx6q-usbphy", "fsl,imx23-usbphy";
 	reg = <0x020c9000 0x1000>;
 	interrupts = <0 44 0x04>;
+	fsl,anatop = <&anatop>;
 };
-- 
1.7.1

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

* [PATCH 10/12] ARM: dts: imx6: add anatop phandle for usbphy
  2013-10-12  9:09 [PATCH 00/12] Add power management support for MXS PHY Peter Chen
                   ` (8 preceding siblings ...)
  2013-10-12  9:09 ` [PATCH 09/12] usb: phy-mxs: update binding for adding anatop phandle Peter Chen
@ 2013-10-12  9:09 ` Peter Chen
  2013-10-12  9:09 ` [PATCH 11/12] usb: phy-mxs: update binding for adding disconnect line property Peter Chen
  2013-10-12  9:09 ` [PATCH 12/12] ARM: dts: imx6: Add disconnect_line_without_vbus property for usbphy Peter Chen
  11 siblings, 0 replies; 32+ messages in thread
From: Peter Chen @ 2013-10-12  9:09 UTC (permalink / raw)
  To: linux-arm-kernel

Add anatop phandle for usbphy

Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
 arch/arm/boot/dts/imx6qdl.dtsi |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi
index ef51342..145ece2 100644
--- a/arch/arm/boot/dts/imx6qdl.dtsi
+++ b/arch/arm/boot/dts/imx6qdl.dtsi
@@ -541,6 +541,7 @@
 				reg = <0x020c9000 0x1000>;
 				interrupts = <0 44 0x04>;
 				clocks = <&clks 182>;
+				fsl,anatop = <&anatop>;
 			};
 
 			usbphy2: usbphy at 020ca000 {
@@ -548,6 +549,7 @@
 				reg = <0x020ca000 0x1000>;
 				interrupts = <0 45 0x04>;
 				clocks = <&clks 183>;
+				fsl,anatop = <&anatop>;
 			};
 
 			snvs at 020cc000 {
-- 
1.7.1

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

* [PATCH 11/12] usb: phy-mxs: update binding for adding disconnect line property
  2013-10-12  9:09 [PATCH 00/12] Add power management support for MXS PHY Peter Chen
                   ` (9 preceding siblings ...)
  2013-10-12  9:09 ` [PATCH 10/12] ARM: dts: imx6: add anatop phandle for usbphy Peter Chen
@ 2013-10-12  9:09 ` Peter Chen
  2013-10-12  9:47   ` Marek Vasut
  2013-10-12 15:05   ` Thomas Petazzoni
  2013-10-12  9:09 ` [PATCH 12/12] ARM: dts: imx6: Add disconnect_line_without_vbus property for usbphy Peter Chen
  11 siblings, 2 replies; 32+ messages in thread
From: Peter Chen @ 2013-10-12  9:09 UTC (permalink / raw)
  To: linux-arm-kernel

This property is used to disconnect line between USB PHY and
USB controller.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
 Documentation/devicetree/bindings/usb/mxs-phy.txt |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/Documentation/devicetree/bindings/usb/mxs-phy.txt b/Documentation/devicetree/bindings/usb/mxs-phy.txt
index 1a9bd85..099b0bb 100644
--- a/Documentation/devicetree/bindings/usb/mxs-phy.txt
+++ b/Documentation/devicetree/bindings/usb/mxs-phy.txt
@@ -5,6 +5,9 @@ Required properties:
 - reg: Should contain registers location and length
 - interrupts: Should contain phy interrupt
 - fsl,anatop: phandle for anatop register
+- disconnect_line_without_vbus: needs to disconnect
+connection between USB PHY and controller, it can avoid
+unexpected wakeup interrupt when the PHY is out of power
 
 Example:
 usbphy1: usbphy at 020c9000 {
@@ -12,4 +15,5 @@ usbphy1: usbphy at 020c9000 {
 	reg = <0x020c9000 0x1000>;
 	interrupts = <0 44 0x04>;
 	fsl,anatop = <&anatop>;
+	disconnect_line_without_vbus;
 };
-- 
1.7.1

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

* [PATCH 12/12] ARM: dts: imx6: Add disconnect_line_without_vbus property for usbphy
  2013-10-12  9:09 [PATCH 00/12] Add power management support for MXS PHY Peter Chen
                   ` (10 preceding siblings ...)
  2013-10-12  9:09 ` [PATCH 11/12] usb: phy-mxs: update binding for adding disconnect line property Peter Chen
@ 2013-10-12  9:09 ` Peter Chen
  11 siblings, 0 replies; 32+ messages in thread
From: Peter Chen @ 2013-10-12  9:09 UTC (permalink / raw)
  To: linux-arm-kernel

When the vbus is not there and the PHY is out of power, we need to
disconnect connection between USB PHY and USB controller, otherwise
the unexpected USB wakeup will occur due to dp/dm change at device
mode.

Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
 arch/arm/boot/dts/imx6qdl.dtsi |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi
index 145ece2..b95ab40 100644
--- a/arch/arm/boot/dts/imx6qdl.dtsi
+++ b/arch/arm/boot/dts/imx6qdl.dtsi
@@ -542,6 +542,7 @@
 				interrupts = <0 44 0x04>;
 				clocks = <&clks 182>;
 				fsl,anatop = <&anatop>;
+				disconnect_line_without_vbus;
 			};
 
 			usbphy2: usbphy at 020ca000 {
-- 
1.7.1

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

* [PATCH 02/12] usb: phy-mxs: Enable IC fixes for mx6 SoC serial
  2013-10-12  9:09 ` [PATCH 02/12] usb: phy-mxs: Enable IC fixes for mx6 SoC serial Peter Chen
@ 2013-10-12  9:38   ` Marek Vasut
  2013-10-14  1:31     ` Peter Chen
  2013-10-14  9:09   ` Shawn Guo
  1 sibling, 1 reply; 32+ messages in thread
From: Marek Vasut @ 2013-10-12  9:38 UTC (permalink / raw)
  To: linux-arm-kernel

Hi,

> After adding IC fixes bits, some PHY bugs are fixed by
> IC logic.

Can you please elaborate what those bits do exactly ? They seem like a magic 
stuff to me thus far, which is not exactly helpful . I can't find them in the 
datasheet either.

> Signed-off-by: Peter Chen <peter.chen@freescale.com>
> ---
>  drivers/usb/phy/phy-mxs-usb.c |   10 ++++++++++
>  1 files changed, 10 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
> index 87ba429..831b13e 100644
> --- a/drivers/usb/phy/phy-mxs-usb.c
> +++ b/drivers/usb/phy/phy-mxs-usb.c
> @@ -29,6 +29,10 @@
>  #define HW_USBPHY_CTRL_SET			0x34
>  #define HW_USBPHY_CTRL_CLR			0x38
> 
> +#define HW_USBPHY_IP				0x90
> +#define HW_USBPHY_IP_SET			0x94
> +#define HW_USBPHY_IP_CLR			0x98
> +
>  #define BM_USBPHY_CTRL_SFTRST			BIT(31)
>  #define BM_USBPHY_CTRL_CLKGATE			BIT(30)
>  #define BM_USBPHY_CTRL_ENAUTOSET_USBCLKS	BIT(26)
> @@ -40,6 +44,8 @@
>  #define BM_USBPHY_CTRL_ENUTMILEVEL2		BIT(14)
>  #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT	BIT(1)
> 
> +#define BM_USBPHY_IP_FIX                       (BIT(17) | BIT(18))
> +
>  #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
> 
>  enum imx_phy_type {
> @@ -118,6 +124,10 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
>  		BM_USBPHY_CTRL_ENUTMILEVEL3,
>  	       base + HW_USBPHY_CTRL_SET);
> 
> +	/* Enable IC solution */
> +	if (is_mx6q_phy(mxs_phy) || is_mx6sl_phy(mxs_phy))
> +		writel(BM_USBPHY_IP_FIX, base + HW_USBPHY_IP_SET);
> +
>  	return 0;
>  }

Best regards,
Marek Vasut

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

* [PATCH 05/12] usb: phy-mxs: Add implementation of nofity_suspend and notify_resume
  2013-10-12  9:09 ` [PATCH 05/12] usb: phy-mxs: Add implementation of nofity_suspend and notify_resume Peter Chen
@ 2013-10-12  9:42   ` Marek Vasut
  2013-10-14  1:36     ` Peter Chen
  0 siblings, 1 reply; 32+ messages in thread
From: Marek Vasut @ 2013-10-12  9:42 UTC (permalink / raw)
  To: linux-arm-kernel

Dear Peter Chen,

> Add notify_suspend and notify_resume according to different SoCs.
> 
> Signed-off-by: Peter Chen <peter.chen@freescale.com>
> ---
>  drivers/usb/phy/phy-mxs-usb.c |   73
> +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 73
> insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
> index e0b0de0..8661dae 100644
> --- a/drivers/usb/phy/phy-mxs-usb.c
> +++ b/drivers/usb/phy/phy-mxs-usb.c
> @@ -197,6 +197,78 @@ static int mxs_phy_on_disconnect(struct usb_phy *phy,
>  	return 0;
>  }
> 
> +static int mxs_phy_on_suspend_workaround(struct usb_phy *phy,
> +		enum usb_device_speed speed)
> +{
> +	dev_dbg(phy->dev, "%s speed device has suspended\n",
> +		(speed == USB_SPEED_HIGH) ? "high" : "non-high");

HS : FS/LS you mean?

> +
> +	/* delay 4ms to wait bus entering idle */
> +	usleep_range(4000, 5000);
> +
> +	/*
> +	 * Workaround for wakeup signal between portsc.suspendM
> +	 * and PHY enters low power mode.
> +	 */
> +	writel_relaxed(0xffffffff, phy->io_priv + HW_USBPHY_PWD);
> +	writel_relaxed(0, phy->io_priv + HW_USBPHY_PWD);
> +
> +	if (speed == USB_SPEED_HIGH)
> +		writel_relaxed(BM_USBPHY_CTRL_ENHOSTDISCONDETECT,
> +				phy->io_priv + HW_USBPHY_CTRL_CLR);
> +
> +	return 0;
> +}

[...]

> +/*
> + * For mxs PHY, there are two PHY issues related to suspend/resume.
> + * For mx23 and mx28, both of two issues are existed.
> + * For mx6q and mx6dl, only one issue is existed.
> + * For mx6 sololite, none issue is existed.
> + */
> +static void mxs_phy_workaround(struct mxs_phy *mxs_phy)
> +{
> +	if (is_mx23_phy(mxs_phy)) {

This is_mx23_phy() returns 1 for mx28 too? It's not too clear, not even from the 
comment above, a short comment here would help for sure.

> +		mxs_phy->phy.notify_suspend = mxs_phy_on_suspend_workaround;
> +		mxs_phy->phy.notify_resume = mxs_phy_on_resume;
> +	} else if (is_mx6q_phy(mxs_phy)) {
> +		mxs_phy->phy.notify_suspend = mxs_phy_on_suspend;
> +		mxs_phy->phy.notify_resume = mxs_phy_on_resume;
> +	}
> +}
> +
>  static int mxs_phy_probe(struct platform_device *pdev)
>  {
>  	struct resource *res;
> @@ -257,6 +329,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
> 
>  	mxs_phy->clk = clk;
>  	mxs_phy->devtype = pdev->id_entry->driver_data;
> +	mxs_phy_workaround(mxs_phy);
> 
>  	platform_set_drvdata(pdev, &mxs_phy->phy);

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

* [PATCH 07/12] usb: phy-mxs: Add implementation of set_wakeup
  2013-10-12  9:09 ` [PATCH 07/12] usb: phy-mxs: Add implementation of set_wakeup Peter Chen
@ 2013-10-12  9:44   ` Marek Vasut
  2013-10-14  1:41     ` Peter Chen
  0 siblings, 1 reply; 32+ messages in thread
From: Marek Vasut @ 2013-10-12  9:44 UTC (permalink / raw)
  To: linux-arm-kernel

Dear Peter Chen,

> When we need the PHY can be waken up by external signals,
> we can call this API. Besides, we call mxs_phy_disconnect_line
> at this API to close the connection between USB PHY and
> controller, after that, the line state from controller is SE0.
> Once the PHY is out of power, without calling mxs_phy_disconnect_line,
> there are unknown wakeups due to dp/dm floating at device mode.
> 
> Signed-off-by: Peter Chen <peter.chen@freescale.com>
> ---
>  drivers/usb/phy/phy-mxs-usb.c |   82
> ++++++++++++++++++++++++++++++++++++++++- 1 files changed, 81
> insertions(+), 1 deletions(-)

[...]

> +static int mxs_phy_set_wakeup(struct usb_phy *x, bool enabled)
> +{
> +	struct mxs_phy *mxs_phy = to_mxs_phy(x);
> +	u32 value = BM_USBPHY_CTRL_ENVBUSCHG_WKUP |
> +			BM_USBPHY_CTRL_ENDPDMCHG_WKUP |
> +				BM_USBPHY_CTRL_ENIDCHG_WKUP;

Does this stuff pass checkpatch at all? I mean, this alignment seems a bit 
strange.

> +	if (enabled) {
> +		mxs_phy_disconnect_line(mxs_phy, true);
> +		writel_relaxed(value, x->io_priv + HW_USBPHY_CTRL_SET);
> +	} else {
> +		writel_relaxed(value, x->io_priv + HW_USBPHY_CTRL_CLR);
> +		mxs_phy_disconnect_line(mxs_phy, false);
> +	}
> +
> +	return 0;
> +}
> +
>  static int mxs_phy_on_connect(struct usb_phy *phy,
>  		enum usb_device_speed speed)
>  {
> @@ -315,6 +390,10 @@ static int mxs_phy_probe(struct platform_device *pdev)
>  		}
>  	}
> 
> +	if (of_find_property(np, "disconnect_line_without_vbus", NULL) &&
> +			mxs_phy->regmap_anatop)

You might want to introduce a variable here to make the condition shorter:

var = of_find....
if (var && mxs_phy->...)

> +		mxs_phy->disconnect_line_without_vbus_is_needed = true;
> +
>  	mxs_phy->phy.io_priv		= base;
>  	mxs_phy->phy.dev		= &pdev->dev;
>  	mxs_phy->phy.label		= DRIVER_NAME;
> @@ -324,6 +403,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
>  	mxs_phy->phy.notify_connect	= mxs_phy_on_connect;
>  	mxs_phy->phy.notify_disconnect	= mxs_phy_on_disconnect;
>  	mxs_phy->phy.type		= USB_PHY_TYPE_USB2;
> +	mxs_phy->phy.set_wakeup		= mxs_phy_set_wakeup;
> 
>  	ATOMIC_INIT_NOTIFIER_HEAD(&mxs_phy->phy.notifier);

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

* [PATCH 11/12] usb: phy-mxs: update binding for adding disconnect line property
  2013-10-12  9:09 ` [PATCH 11/12] usb: phy-mxs: update binding for adding disconnect line property Peter Chen
@ 2013-10-12  9:47   ` Marek Vasut
  2013-10-14  1:44     ` Peter Chen
  2013-10-12 15:05   ` Thomas Petazzoni
  1 sibling, 1 reply; 32+ messages in thread
From: Marek Vasut @ 2013-10-12  9:47 UTC (permalink / raw)
  To: linux-arm-kernel

Dear Peter Chen,

> This property is used to disconnect line between USB PHY and
> USB controller.
> 
> Signed-off-by: Peter Chen <peter.chen@freescale.com>
> ---
>  Documentation/devicetree/bindings/usb/mxs-phy.txt |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/usb/mxs-phy.txt
> b/Documentation/devicetree/bindings/usb/mxs-phy.txt index 1a9bd85..099b0bb
> 100644
> --- a/Documentation/devicetree/bindings/usb/mxs-phy.txt
> +++ b/Documentation/devicetree/bindings/usb/mxs-phy.txt
> @@ -5,6 +5,9 @@ Required properties:
>  - reg: Should contain registers location and length
>  - interrupts: Should contain phy interrupt
>  - fsl,anatop: phandle for anatop register
> +- disconnect_line_without_vbus: needs to disconnect
> +connection between USB PHY and controller, it can avoid
> +unexpected wakeup interrupt when the PHY is out of power

Uh oh, this might needs some rewording. I didn't understand the reason for this 
prop before I checked the 12/12 patch.

Best regards,
Marek Vasut

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

* [PATCH 11/12] usb: phy-mxs: update binding for adding disconnect line property
  2013-10-12  9:09 ` [PATCH 11/12] usb: phy-mxs: update binding for adding disconnect line property Peter Chen
  2013-10-12  9:47   ` Marek Vasut
@ 2013-10-12 15:05   ` Thomas Petazzoni
  2013-10-14  1:45     ` Peter Chen
  1 sibling, 1 reply; 32+ messages in thread
From: Thomas Petazzoni @ 2013-10-12 15:05 UTC (permalink / raw)
  To: linux-arm-kernel

Dear Peter Chen,

On Sat, 12 Oct 2013 17:09:45 +0800, Peter Chen wrote:
> This property is used to disconnect line between USB PHY and
> USB controller.
> 
> Signed-off-by: Peter Chen <peter.chen@freescale.com>
> ---
>  Documentation/devicetree/bindings/usb/mxs-phy.txt |    4 ++++
>  1 files changed, 4 insertions(+), 0 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/usb/mxs-phy.txt b/Documentation/devicetree/bindings/usb/mxs-phy.txt
> index 1a9bd85..099b0bb 100644
> --- a/Documentation/devicetree/bindings/usb/mxs-phy.txt
> +++ b/Documentation/devicetree/bindings/usb/mxs-phy.txt
> @@ -5,6 +5,9 @@ Required properties:
>  - reg: Should contain registers location and length
>  - interrupts: Should contain phy interrupt
>  - fsl,anatop: phandle for anatop register
> +- disconnect_line_without_vbus: needs to disconnect
> +connection between USB PHY and controller, it can avoid
> +unexpected wakeup interrupt when the PHY is out of power
>  
>  Example:
>  usbphy1: usbphy at 020c9000 {
> @@ -12,4 +15,5 @@ usbphy1: usbphy at 020c9000 {
>  	reg = <0x020c9000 0x1000>;
>  	interrupts = <0 44 0x04>;
>  	fsl,anatop = <&anatop>;
> +	disconnect_line_without_vbus;
>  };

Device Tree properties use "-" as a separator, not "_". So, it should
be:

	disconnect-line-without-vbus

Also, all your patches touching Device Tree bindings should be Cc'ed to
the devicetree@ mailing list.

Thomas
-- 
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com

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

* [PATCH 02/12] usb: phy-mxs: Enable IC fixes for mx6 SoC serial
  2013-10-12  9:38   ` Marek Vasut
@ 2013-10-14  1:31     ` Peter Chen
  2013-10-14  2:07       ` Marek Vasut
  0 siblings, 1 reply; 32+ messages in thread
From: Peter Chen @ 2013-10-14  1:31 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Oct 12, 2013 at 11:38:16AM +0200, Marek Vasut wrote:
> Hi,
> 
> > After adding IC fixes bits, some PHY bugs are fixed by
> > IC logic.
> 
> Can you please elaborate what those bits do exactly ? They seem like a magic 
> stuff to me thus far, which is not exactly helpful . I can't find them in the 
> datasheet either.
> 

Yes, these bits are added at late TO verion for i.mx 6, and these TO versions
will be for mass production, unfortunately, the related doc update may be 
forgotten.

These two bits are related to two PHY bugs, two PHY bugs are still existed
at mx28 and mx23, one bug is fixed at mx6dq and mx6dl, and both of two
bugs are fixed at later mx6 (like mx6sololite and later SoCs), but the IC
fixes are not enabled by default, it needs software opens it.

-- 

Best Regards,
Peter Chen

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

* [PATCH 05/12] usb: phy-mxs: Add implementation of nofity_suspend and notify_resume
  2013-10-12  9:42   ` Marek Vasut
@ 2013-10-14  1:36     ` Peter Chen
  2013-10-14  2:08       ` Marek Vasut
  0 siblings, 1 reply; 32+ messages in thread
From: Peter Chen @ 2013-10-14  1:36 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Oct 12, 2013 at 11:42:06AM +0200, Marek Vasut wrote:
> Dear Peter Chen,
> 
> > Add notify_suspend and notify_resume according to different SoCs.
> > 
> > Signed-off-by: Peter Chen <peter.chen@freescale.com>
> > ---
> >  drivers/usb/phy/phy-mxs-usb.c |   73
> > +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 73
> > insertions(+), 0 deletions(-)
> > 
> > diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
> > index e0b0de0..8661dae 100644
> > --- a/drivers/usb/phy/phy-mxs-usb.c
> > +++ b/drivers/usb/phy/phy-mxs-usb.c
> > @@ -197,6 +197,78 @@ static int mxs_phy_on_disconnect(struct usb_phy *phy,
> >  	return 0;
> >  }
> > 
> > +static int mxs_phy_on_suspend_workaround(struct usb_phy *phy,
> > +		enum usb_device_speed speed)
> > +{
> > +	dev_dbg(phy->dev, "%s speed device has suspended\n",
> > +		(speed == USB_SPEED_HIGH) ? "high" : "non-high");
> 
> HS : FS/LS you mean?

Yes, it is what I mean.
OK, I will change to HS and FS/LS.

> 
> > +/*
> > + * For mxs PHY, there are two PHY issues related to suspend/resume.
> > + * For mx23 and mx28, both of two issues are existed.
> > + * For mx6q and mx6dl, only one issue is existed.
> > + * For mx6 sololite, none issue is existed.
> > + */
> > +static void mxs_phy_workaround(struct mxs_phy *mxs_phy)
> > +{
> > +	if (is_mx23_phy(mxs_phy)) {
> 
> This is_mx23_phy() returns 1 for mx28 too? It's not too clear, not even from the 
> comment above, a short comment here would help for sure.

mx23 and mx28 PHY are the same PHY, so the fixes are the same.
Anything I need to add?

-- 

Best Regards,
Peter Chen

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

* [PATCH 07/12] usb: phy-mxs: Add implementation of set_wakeup
  2013-10-12  9:44   ` Marek Vasut
@ 2013-10-14  1:41     ` Peter Chen
  0 siblings, 0 replies; 32+ messages in thread
From: Peter Chen @ 2013-10-14  1:41 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Oct 12, 2013 at 11:44:59AM +0200, Marek Vasut wrote:
> 
> > +static int mxs_phy_set_wakeup(struct usb_phy *x, bool enabled)
> > +{
> > +	struct mxs_phy *mxs_phy = to_mxs_phy(x);
> > +	u32 value = BM_USBPHY_CTRL_ENVBUSCHG_WKUP |
> > +			BM_USBPHY_CTRL_ENDPDMCHG_WKUP |
> > +				BM_USBPHY_CTRL_ENIDCHG_WKUP;
> 
> Does this stuff pass checkpatch at all? I mean, this alignment seems a bit 
> strange.

Yes, it passed.

	u32 value = BM_USBPHY_CTRL_ENVBUSCHG_WKUP |
			BM_USBPHY_CTRL_ENDPDMCHG_WKUP | /* two tabs for last line */
				BM_USBPHY_CTRL_ENIDCHG_WKUP; /* one tab for last line */

Any better suggestions?

> 
> > +	if (enabled) {
> > +		mxs_phy_disconnect_line(mxs_phy, true);
> > +		writel_relaxed(value, x->io_priv + HW_USBPHY_CTRL_SET);
> > +	} else {
> > +		writel_relaxed(value, x->io_priv + HW_USBPHY_CTRL_CLR);
> > +		mxs_phy_disconnect_line(mxs_phy, false);
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> >  static int mxs_phy_on_connect(struct usb_phy *phy,
> >  		enum usb_device_speed speed)
> >  {
> > @@ -315,6 +390,10 @@ static int mxs_phy_probe(struct platform_device *pdev)
> >  		}
> >  	}
> > 
> > +	if (of_find_property(np, "disconnect_line_without_vbus", NULL) &&
> > +			mxs_phy->regmap_anatop)
> 
> You might want to introduce a variable here to make the condition shorter:
> 
> var = of_find....
> if (var && mxs_phy->...)

I will change.


-- 

Best Regards,
Peter Chen

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

* [PATCH 11/12] usb: phy-mxs: update binding for adding disconnect line property
  2013-10-12  9:47   ` Marek Vasut
@ 2013-10-14  1:44     ` Peter Chen
  0 siblings, 0 replies; 32+ messages in thread
From: Peter Chen @ 2013-10-14  1:44 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Oct 12, 2013 at 11:47:06AM +0200, Marek Vasut wrote:
> Dear Peter Chen,
> 
> > This property is used to disconnect line between USB PHY and
> > USB controller.
> > 
> > Signed-off-by: Peter Chen <peter.chen@freescale.com>
> > ---
> >  Documentation/devicetree/bindings/usb/mxs-phy.txt |    4 ++++
> >  1 files changed, 4 insertions(+), 0 deletions(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/usb/mxs-phy.txt
> > b/Documentation/devicetree/bindings/usb/mxs-phy.txt index 1a9bd85..099b0bb
> > 100644
> > --- a/Documentation/devicetree/bindings/usb/mxs-phy.txt
> > +++ b/Documentation/devicetree/bindings/usb/mxs-phy.txt
> > @@ -5,6 +5,9 @@ Required properties:
> >  - reg: Should contain registers location and length
> >  - interrupts: Should contain phy interrupt
> >  - fsl,anatop: phandle for anatop register
> > +- disconnect_line_without_vbus: needs to disconnect
> > +connection between USB PHY and controller, it can avoid
> > +unexpected wakeup interrupt when the PHY is out of power
> 
> Uh oh, this might needs some rewording. I didn't understand the reason for this 
> prop before I checked the 12/12 patch.
> 

So, the better sequence like below, correct?

Binding doc patch
source code change patch
dts file patch

-- 

Best Regards,
Peter Chen

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

* [PATCH 11/12] usb: phy-mxs: update binding for adding disconnect line property
  2013-10-12 15:05   ` Thomas Petazzoni
@ 2013-10-14  1:45     ` Peter Chen
  0 siblings, 0 replies; 32+ messages in thread
From: Peter Chen @ 2013-10-14  1:45 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Oct 12, 2013 at 05:05:23PM +0200, Thomas Petazzoni wrote:
> Dear Peter Chen,
> 
> On Sat, 12 Oct 2013 17:09:45 +0800, Peter Chen wrote:
> > This property is used to disconnect line between USB PHY and
> > USB controller.
> > 
> > Signed-off-by: Peter Chen <peter.chen@freescale.com>
> > ---
> >  Documentation/devicetree/bindings/usb/mxs-phy.txt |    4 ++++
> >  1 files changed, 4 insertions(+), 0 deletions(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/usb/mxs-phy.txt b/Documentation/devicetree/bindings/usb/mxs-phy.txt
> > index 1a9bd85..099b0bb 100644
> > --- a/Documentation/devicetree/bindings/usb/mxs-phy.txt
> > +++ b/Documentation/devicetree/bindings/usb/mxs-phy.txt
> > @@ -5,6 +5,9 @@ Required properties:
> >  - reg: Should contain registers location and length
> >  - interrupts: Should contain phy interrupt
> >  - fsl,anatop: phandle for anatop register
> > +- disconnect_line_without_vbus: needs to disconnect
> > +connection between USB PHY and controller, it can avoid
> > +unexpected wakeup interrupt when the PHY is out of power
> >  
> >  Example:
> >  usbphy1: usbphy at 020c9000 {
> > @@ -12,4 +15,5 @@ usbphy1: usbphy at 020c9000 {
> >  	reg = <0x020c9000 0x1000>;
> >  	interrupts = <0 44 0x04>;
> >  	fsl,anatop = <&anatop>;
> > +	disconnect_line_without_vbus;
> >  };
> 
> Device Tree properties use "-" as a separator, not "_". So, it should
> be:
> 
> 	disconnect-line-without-vbus
> 
> Also, all your patches touching Device Tree bindings should be Cc'ed to
> the devicetree@ mailing list.
> 

Thanks, I will change, and cc DT ML and maintainer, thanks.

-- 

Best Regards,
Peter Chen

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

* [PATCH 02/12] usb: phy-mxs: Enable IC fixes for mx6 SoC serial
  2013-10-14  2:07       ` Marek Vasut
@ 2013-10-14  1:58         ` Peter Chen
  0 siblings, 0 replies; 32+ messages in thread
From: Peter Chen @ 2013-10-14  1:58 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Oct 14, 2013 at 04:07:10AM +0200, Marek Vasut wrote:
> Dear Peter Chen,
> 
> > On Sat, Oct 12, 2013 at 11:38:16AM +0200, Marek Vasut wrote:
> > > Hi,
> > > 
> > > > After adding IC fixes bits, some PHY bugs are fixed by
> > > > IC logic.
> > > 
> > > Can you please elaborate what those bits do exactly ? They seem like a
> > > magic stuff to me thus far, which is not exactly helpful . I can't find
> > > them in the datasheet either.
> > 
> > Yes, these bits are added at late TO verion for i.mx 6, and these TO
> > versions will be for mass production, unfortunately, the related doc
> > update may be forgotten.
> > 
> > These two bits are related to two PHY bugs, two PHY bugs are still existed
> > at mx28 and mx23, one bug is fixed at mx6dq and mx6dl, and both of two
> > bugs are fixed at later mx6 (like mx6sololite and later SoCs), but the IC
> > fixes are not enabled by default, it needs software opens it.
> 
> Sure, I get it. But what exactly does that bit do? Can you add a proper (and 
> likely beefy) comment into the code to supplement the missing parts in the 
> datasheet?

OK, I will add them at v2.

-- 

Best Regards,
Peter Chen

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

* [PATCH 02/12] usb: phy-mxs: Enable IC fixes for mx6 SoC serial
  2013-10-14  1:31     ` Peter Chen
@ 2013-10-14  2:07       ` Marek Vasut
  2013-10-14  1:58         ` Peter Chen
  0 siblings, 1 reply; 32+ messages in thread
From: Marek Vasut @ 2013-10-14  2:07 UTC (permalink / raw)
  To: linux-arm-kernel

Dear Peter Chen,

> On Sat, Oct 12, 2013 at 11:38:16AM +0200, Marek Vasut wrote:
> > Hi,
> > 
> > > After adding IC fixes bits, some PHY bugs are fixed by
> > > IC logic.
> > 
> > Can you please elaborate what those bits do exactly ? They seem like a
> > magic stuff to me thus far, which is not exactly helpful . I can't find
> > them in the datasheet either.
> 
> Yes, these bits are added at late TO verion for i.mx 6, and these TO
> versions will be for mass production, unfortunately, the related doc
> update may be forgotten.
> 
> These two bits are related to two PHY bugs, two PHY bugs are still existed
> at mx28 and mx23, one bug is fixed at mx6dq and mx6dl, and both of two
> bugs are fixed at later mx6 (like mx6sololite and later SoCs), but the IC
> fixes are not enabled by default, it needs software opens it.

Sure, I get it. But what exactly does that bit do? Can you add a proper (and 
likely beefy) comment into the code to supplement the missing parts in the 
datasheet?

Best regards,
Marek Vasut

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

* [PATCH 05/12] usb: phy-mxs: Add implementation of nofity_suspend and notify_resume
  2013-10-14  1:36     ` Peter Chen
@ 2013-10-14  2:08       ` Marek Vasut
  0 siblings, 0 replies; 32+ messages in thread
From: Marek Vasut @ 2013-10-14  2:08 UTC (permalink / raw)
  To: linux-arm-kernel

Dear Peter Chen,

> On Sat, Oct 12, 2013 at 11:42:06AM +0200, Marek Vasut wrote:
> > Dear Peter Chen,
> > 
> > > Add notify_suspend and notify_resume according to different SoCs.
> > > 
> > > Signed-off-by: Peter Chen <peter.chen@freescale.com>
> > > ---
> > > 
> > >  drivers/usb/phy/phy-mxs-usb.c |   73
> > > 
> > > +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 73
> > > insertions(+), 0 deletions(-)
> > > 
> > > diff --git a/drivers/usb/phy/phy-mxs-usb.c
> > > b/drivers/usb/phy/phy-mxs-usb.c index e0b0de0..8661dae 100644
> > > --- a/drivers/usb/phy/phy-mxs-usb.c
> > > +++ b/drivers/usb/phy/phy-mxs-usb.c
> > > @@ -197,6 +197,78 @@ static int mxs_phy_on_disconnect(struct usb_phy
> > > *phy,
> > > 
> > >  	return 0;
> > >  
> > >  }
> > > 
> > > +static int mxs_phy_on_suspend_workaround(struct usb_phy *phy,
> > > +		enum usb_device_speed speed)
> > > +{
> > > +	dev_dbg(phy->dev, "%s speed device has suspended\n",
> > > +		(speed == USB_SPEED_HIGH) ? "high" : "non-high");
> > 
> > HS : FS/LS you mean?
> 
> Yes, it is what I mean.
> OK, I will change to HS and FS/LS.
> 
> > > +/*
> > > + * For mxs PHY, there are two PHY issues related to suspend/resume.
> > > + * For mx23 and mx28, both of two issues are existed.
> > > + * For mx6q and mx6dl, only one issue is existed.
> > > + * For mx6 sololite, none issue is existed.
> > > + */
> > > +static void mxs_phy_workaround(struct mxs_phy *mxs_phy)
> > > +{
> > > +	if (is_mx23_phy(mxs_phy)) {
> > 
> > This is_mx23_phy() returns 1 for mx28 too? It's not too clear, not even
> > from the comment above, a short comment here would help for sure.
> 
> mx23 and mx28 PHY are the same PHY, so the fixes are the same.
> Anything I need to add?

I believe it's OK. But identifying MX28 PHY via is_mx23_phy() might be a little 
confusing. I'm just trying to keep this driver flushed out of my brain here and 
do an unbiased review ;-)

Best regards,
Marek Vasut

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

* [PATCH 02/12] usb: phy-mxs: Enable IC fixes for mx6 SoC serial
  2013-10-12  9:09 ` [PATCH 02/12] usb: phy-mxs: Enable IC fixes for mx6 SoC serial Peter Chen
  2013-10-12  9:38   ` Marek Vasut
@ 2013-10-14  9:09   ` Shawn Guo
  2013-10-14  9:09     ` Peter Chen
  1 sibling, 1 reply; 32+ messages in thread
From: Shawn Guo @ 2013-10-14  9:09 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Oct 12, 2013 at 05:09:36PM +0800, Peter Chen wrote:
> After adding IC fixes bits, some PHY bugs are fixed by
> IC logic.
> 
> Signed-off-by: Peter Chen <peter.chen@freescale.com>
> ---
>  drivers/usb/phy/phy-mxs-usb.c |   10 ++++++++++
>  1 files changed, 10 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
> index 87ba429..831b13e 100644
> --- a/drivers/usb/phy/phy-mxs-usb.c
> +++ b/drivers/usb/phy/phy-mxs-usb.c
> @@ -29,6 +29,10 @@
>  #define HW_USBPHY_CTRL_SET			0x34
>  #define HW_USBPHY_CTRL_CLR			0x38
>  
> +#define HW_USBPHY_IP				0x90
> +#define HW_USBPHY_IP_SET			0x94
> +#define HW_USBPHY_IP_CLR			0x98
> +
>  #define BM_USBPHY_CTRL_SFTRST			BIT(31)
>  #define BM_USBPHY_CTRL_CLKGATE			BIT(30)
>  #define BM_USBPHY_CTRL_ENAUTOSET_USBCLKS	BIT(26)
> @@ -40,6 +44,8 @@
>  #define BM_USBPHY_CTRL_ENUTMILEVEL2		BIT(14)
>  #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT	BIT(1)
>  
> +#define BM_USBPHY_IP_FIX                       (BIT(17) | BIT(18))
> +
>  #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
>  
>  enum imx_phy_type {
> @@ -118,6 +124,10 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
>  		BM_USBPHY_CTRL_ENUTMILEVEL3,
>  	       base + HW_USBPHY_CTRL_SET);
>  
> +	/* Enable IC solution */
> +	if (is_mx6q_phy(mxs_phy) || is_mx6sl_phy(mxs_phy))

Am I missing any dependency/patches here?  Where were is_mx6q_phy() and
is_mx6sl_phy() introduced?

Shawn

> +		writel(BM_USBPHY_IP_FIX, base + HW_USBPHY_IP_SET);
> +
>  	return 0;
>  }
>  
> -- 
> 1.7.1
> 
> 

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

* [PATCH 02/12] usb: phy-mxs: Enable IC fixes for mx6 SoC serial
  2013-10-14  9:09   ` Shawn Guo
@ 2013-10-14  9:09     ` Peter Chen
  2013-10-14  9:29       ` Shawn Guo
  0 siblings, 1 reply; 32+ messages in thread
From: Peter Chen @ 2013-10-14  9:09 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Oct 14, 2013 at 05:09:55PM +0800, Shawn Guo wrote:
> On Sat, Oct 12, 2013 at 05:09:36PM +0800, Peter Chen wrote:
> > After adding IC fixes bits, some PHY bugs are fixed by
> > IC logic.
> > 
> > Signed-off-by: Peter Chen <peter.chen@freescale.com>
> > ---
> >  drivers/usb/phy/phy-mxs-usb.c |   10 ++++++++++
> >  1 files changed, 10 insertions(+), 0 deletions(-)
> > 
> > diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
> > index 87ba429..831b13e 100644
> > --- a/drivers/usb/phy/phy-mxs-usb.c
> > +++ b/drivers/usb/phy/phy-mxs-usb.c
> > @@ -29,6 +29,10 @@
> >  #define HW_USBPHY_CTRL_SET			0x34
> >  #define HW_USBPHY_CTRL_CLR			0x38
> >  
> > +#define HW_USBPHY_IP				0x90
> > +#define HW_USBPHY_IP_SET			0x94
> > +#define HW_USBPHY_IP_CLR			0x98
> > +
> >  #define BM_USBPHY_CTRL_SFTRST			BIT(31)
> >  #define BM_USBPHY_CTRL_CLKGATE			BIT(30)
> >  #define BM_USBPHY_CTRL_ENAUTOSET_USBCLKS	BIT(26)
> > @@ -40,6 +44,8 @@
> >  #define BM_USBPHY_CTRL_ENUTMILEVEL2		BIT(14)
> >  #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT	BIT(1)
> >  
> > +#define BM_USBPHY_IP_FIX                       (BIT(17) | BIT(18))
> > +
> >  #define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
> >  
> >  enum imx_phy_type {
> > @@ -118,6 +124,10 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
> >  		BM_USBPHY_CTRL_ENUTMILEVEL3,
> >  	       base + HW_USBPHY_CTRL_SET);
> >  
> > +	/* Enable IC solution */
> > +	if (is_mx6q_phy(mxs_phy) || is_mx6sl_phy(mxs_phy))
> 
> Am I missing any dependency/patches here?  Where were is_mx6q_phy() and
> is_mx6sl_phy() introduced?
> 
> Shawn
> 
> > +		writel(BM_USBPHY_IP_FIX, base + HW_USBPHY_IP_SET);
> > +
> >  	return 0;
> >  }
> >  
> > -- 
> > 1.7.1
> > 
> > 

Oh, sorry. I forget to put below one to this serial.
Will do at v2

http://marc.info/?l=linux-usb&m=137871552016298&w=2

-- 

Best Regards,
Peter Chen

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

* [PATCH 09/12] usb: phy-mxs: update binding for adding anatop phandle
  2013-10-14  9:22   ` Shawn Guo
@ 2013-10-14  9:10     ` Peter Chen
  0 siblings, 0 replies; 32+ messages in thread
From: Peter Chen @ 2013-10-14  9:10 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Oct 14, 2013 at 05:22:07PM +0800, Shawn Guo wrote:
> On Sat, Oct 12, 2013 at 05:09:43PM +0800, Peter Chen wrote:
> > Add anatop phandle which is used to access anatop registers to
> > control PHY's power and other USB operations.
> > 
> > Signed-off-by: Peter Chen <peter.chen@freescale.com>
> > ---
> >  Documentation/devicetree/bindings/usb/mxs-phy.txt |    2 ++
> >  1 files changed, 2 insertions(+), 0 deletions(-)
> > 
> > diff --git a/Documentation/devicetree/bindings/usb/mxs-phy.txt b/Documentation/devicetree/bindings/usb/mxs-phy.txt
> > index 5835b27..1a9bd85 100644
> > --- a/Documentation/devicetree/bindings/usb/mxs-phy.txt
> > +++ b/Documentation/devicetree/bindings/usb/mxs-phy.txt
> > @@ -4,10 +4,12 @@ Required properties:
> >  - compatible: Should be "fsl,imx23-usbphy"
> >  - reg: Should contain registers location and length
> >  - interrupts: Should contain phy interrupt
> > +- fsl,anatop: phandle for anatop register
> 
> It's only required for imx6 phy not necessarily for imx23/28 phy, right?
> 

Yes, I will comment it

-- 

Best Regards,
Peter Chen

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

* [PATCH 02/12] usb: phy-mxs: Enable IC fixes for mx6 SoC serial
  2013-10-14  9:29       ` Shawn Guo
@ 2013-10-14  9:16         ` Peter Chen
  0 siblings, 0 replies; 32+ messages in thread
From: Peter Chen @ 2013-10-14  9:16 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Oct 14, 2013 at 05:29:21PM +0800, Shawn Guo wrote:
> On Mon, Oct 14, 2013 at 05:09:56PM +0800, Peter Chen wrote:
> > Oh, sorry. I forget to put below one to this serial.
> > Will do at v2
> > 
> > http://marc.info/?l=linux-usb&m=137871552016298&w=2
> 
> Remember to document the new compatible strings in bindings doc.
> 

Will do, thanks

-- 

Best Regards,
Peter Chen

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

* [PATCH 09/12] usb: phy-mxs: update binding for adding anatop phandle
  2013-10-12  9:09 ` [PATCH 09/12] usb: phy-mxs: update binding for adding anatop phandle Peter Chen
@ 2013-10-14  9:22   ` Shawn Guo
  2013-10-14  9:10     ` Peter Chen
  0 siblings, 1 reply; 32+ messages in thread
From: Shawn Guo @ 2013-10-14  9:22 UTC (permalink / raw)
  To: linux-arm-kernel

On Sat, Oct 12, 2013 at 05:09:43PM +0800, Peter Chen wrote:
> Add anatop phandle which is used to access anatop registers to
> control PHY's power and other USB operations.
> 
> Signed-off-by: Peter Chen <peter.chen@freescale.com>
> ---
>  Documentation/devicetree/bindings/usb/mxs-phy.txt |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/Documentation/devicetree/bindings/usb/mxs-phy.txt b/Documentation/devicetree/bindings/usb/mxs-phy.txt
> index 5835b27..1a9bd85 100644
> --- a/Documentation/devicetree/bindings/usb/mxs-phy.txt
> +++ b/Documentation/devicetree/bindings/usb/mxs-phy.txt
> @@ -4,10 +4,12 @@ Required properties:
>  - compatible: Should be "fsl,imx23-usbphy"
>  - reg: Should contain registers location and length
>  - interrupts: Should contain phy interrupt
> +- fsl,anatop: phandle for anatop register

It's only required for imx6 phy not necessarily for imx23/28 phy, right?

Shawn

>  
>  Example:
>  usbphy1: usbphy at 020c9000 {
>  	compatible = "fsl,imx6q-usbphy", "fsl,imx23-usbphy";
>  	reg = <0x020c9000 0x1000>;
>  	interrupts = <0 44 0x04>;
> +	fsl,anatop = <&anatop>;
>  };
> -- 
> 1.7.1
> 
> 

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

* [PATCH 02/12] usb: phy-mxs: Enable IC fixes for mx6 SoC serial
  2013-10-14  9:09     ` Peter Chen
@ 2013-10-14  9:29       ` Shawn Guo
  2013-10-14  9:16         ` Peter Chen
  0 siblings, 1 reply; 32+ messages in thread
From: Shawn Guo @ 2013-10-14  9:29 UTC (permalink / raw)
  To: linux-arm-kernel

On Mon, Oct 14, 2013 at 05:09:56PM +0800, Peter Chen wrote:
> Oh, sorry. I forget to put below one to this serial.
> Will do at v2
> 
> http://marc.info/?l=linux-usb&m=137871552016298&w=2

Remember to document the new compatible strings in bindings doc.

Shawn

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

end of thread, other threads:[~2013-10-14  9:29 UTC | newest]

Thread overview: 32+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-10-12  9:09 [PATCH 00/12] Add power management support for MXS PHY Peter Chen
2013-10-12  9:09 ` [PATCH 01/12] usb: phy-mxs: Add auto clock and power setting Peter Chen
2013-10-12  9:09 ` [PATCH 02/12] usb: phy-mxs: Enable IC fixes for mx6 SoC serial Peter Chen
2013-10-12  9:38   ` Marek Vasut
2013-10-14  1:31     ` Peter Chen
2013-10-14  2:07       ` Marek Vasut
2013-10-14  1:58         ` Peter Chen
2013-10-14  9:09   ` Shawn Guo
2013-10-14  9:09     ` Peter Chen
2013-10-14  9:29       ` Shawn Guo
2013-10-14  9:16         ` Peter Chen
2013-10-12  9:09 ` [PATCH 03/12] usb: phy-mxs: Add anatop regmap Peter Chen
2013-10-12  9:09 ` [PATCH 04/12] usb: phy: add notify suspend and resume callback Peter Chen
2013-10-12  9:09 ` [PATCH 05/12] usb: phy-mxs: Add implementation of nofity_suspend and notify_resume Peter Chen
2013-10-12  9:42   ` Marek Vasut
2013-10-14  1:36     ` Peter Chen
2013-10-14  2:08       ` Marek Vasut
2013-10-12  9:09 ` [PATCH 06/12] usb: phy: Add set_wakeup API Peter Chen
2013-10-12  9:09 ` [PATCH 07/12] usb: phy-mxs: Add implementation of set_wakeup Peter Chen
2013-10-12  9:44   ` Marek Vasut
2013-10-14  1:41     ` Peter Chen
2013-10-12  9:09 ` [PATCH 08/12] usb: phy-mxs: Add system suspend/resume API Peter Chen
2013-10-12  9:09 ` [PATCH 09/12] usb: phy-mxs: update binding for adding anatop phandle Peter Chen
2013-10-14  9:22   ` Shawn Guo
2013-10-14  9:10     ` Peter Chen
2013-10-12  9:09 ` [PATCH 10/12] ARM: dts: imx6: add anatop phandle for usbphy Peter Chen
2013-10-12  9:09 ` [PATCH 11/12] usb: phy-mxs: update binding for adding disconnect line property Peter Chen
2013-10-12  9:47   ` Marek Vasut
2013-10-14  1:44     ` Peter Chen
2013-10-12 15:05   ` Thomas Petazzoni
2013-10-14  1:45     ` Peter Chen
2013-10-12  9:09 ` [PATCH 12/12] ARM: dts: imx6: Add disconnect_line_without_vbus property for usbphy Peter Chen

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.