* [PATCH v3 00/11] Add power management support for MXS PHY
@ 2013-11-05 1:49 Peter Chen
2013-11-05 1:49 ` [PATCH v3 02/11] usb: phy-mxs: Add auto clock and power setting Peter Chen
` (7 more replies)
0 siblings, 8 replies; 28+ messages in thread
From: Peter Chen @ 2013-11-05 1:49 UTC (permalink / raw)
To: balbi-l0cyMroinI0, shawn.guo-QSEj5FYQhm4dnm+yROfE0A,
rob.herring-bsGFqQB8/DxBDgjK7y7TUQ,
grant.likely-QSEj5FYQhm4dnm+yROfE0A
Cc: alexander.shishkin-VuQAYsv1563Yd54FQh9/CA,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
festevam-Re5JQEeQqe8AvxtiuMwx3w, marex-ynQEQJNshbs,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ, m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ,
frank.li-KZfg59tc24xl57MIdRCFDg,
peter.chen-KZfg59tc24xl57MIdRCFDg,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-doc-u79uwXL29TY76Z2rM5mHXA
Hi Felipe & Shawn,
The serial adds power management support for MXS PHY, it includes:
- Add three common PHY APIs, .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.
My github tree: https://github.com/hzpeterchen/linux-usb
branch: master
It is based on linux-next-1029.
Changes for v3:
- Using flag bit to indicate SoC features/bugs, so we can remove
platform_device_id.
- Remove 3 unnecessary dts/doc patches due to above change
- Several comment change
Changes for v2:
- Add missing patches which introduce platform judgement code [1/14,2/14]
- re-order the patch sequence, like doc->dts->source file,
the reviewers can know the meaning of dt properties before review source
- Add description of two IC problems exsiting at mxs PHY; change
"high speed" to "HS" and "non-high speed" to "FS/LS" [5/14]
- Change the dt property disconnect-line-without-vbus
that the separator should be "-" not the "_", meanwhile, related source
code has changed.
- Using one local variable to get the function return val to avoid long
condition statement. [13/14]
Peter Chen (11):
usb: phy-mxs: Add platform judgement code
usb: phy-mxs: Add auto clock and power setting
usb: doc: phy-mxs: update binding for adding anatop phandle
ARM: dts: imx6: add anatop phandle for usbphy
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-mxs: Enable IC fixes for related SoCs
usb: phy: Add set_wakeup API
usb: phy-mxs: Add implementation of set_wakeup
usb: phy-mxs: Add system suspend/resume API
Documentation/devicetree/bindings/usb/mxs-phy.txt | 2 +
arch/arm/boot/dts/imx6qdl.dtsi | 2 +
drivers/usb/phy/phy-mxs-usb.c | 313 ++++++++++++++++++++-
include/linux/usb/phy.h | 39 +++
4 files changed, 341 insertions(+), 15 deletions(-)
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 28+ messages in thread
* [PATCH v3 01/11] usb: phy-mxs: Add platform judgement code
[not found] ` <1383616183-10511-1-git-send-email-peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
@ 2013-11-05 1:49 ` Peter Chen
2013-11-05 2:29 ` Shawn Guo
2013-11-05 1:49 ` [PATCH v3 04/11] ARM: dts: imx6: add anatop phandle for usbphy Peter Chen
` (2 subsequent siblings)
3 siblings, 1 reply; 28+ messages in thread
From: Peter Chen @ 2013-11-05 1:49 UTC (permalink / raw)
To: balbi-l0cyMroinI0, shawn.guo-QSEj5FYQhm4dnm+yROfE0A,
rob.herring-bsGFqQB8/DxBDgjK7y7TUQ,
grant.likely-QSEj5FYQhm4dnm+yROfE0A
Cc: alexander.shishkin-VuQAYsv1563Yd54FQh9/CA,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
festevam-Re5JQEeQqe8AvxtiuMwx3w, marex-ynQEQJNshbs,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ, m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ,
frank.li-KZfg59tc24xl57MIdRCFDg,
peter.chen-KZfg59tc24xl57MIdRCFDg,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-doc-u79uwXL29TY76Z2rM5mHXA
The mxs-phy has several bugs and features at different
versions, the driver code can get it through of_device_id.data.
Signed-off-by: Peter Chen <peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
---
drivers/usb/phy/phy-mxs-usb.c | 59 ++++++++++++++++++++++++++++++++++------
1 files changed, 50 insertions(+), 9 deletions(-)
diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index fdd33b4..8b9d80c 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -1,5 +1,5 @@
/*
- * Copyright 2012 Freescale Semiconductor, Inc.
+ * Copyright 2012-2013 Freescale Semiconductor, Inc.
* Copyright (C) 2012 Marek Vasut <marex-ynQEQJNshbs@public.gmane.org>
* on behalf of DENX Software Engineering GmbH
*
@@ -20,6 +20,7 @@
#include <linux/delay.h>
#include <linux/err.h>
#include <linux/io.h>
+#include <linux/of_device.h>
#define DRIVER_NAME "mxs_phy"
@@ -34,13 +35,55 @@
#define BM_USBPHY_CTRL_ENUTMILEVEL2 BIT(14)
#define BM_USBPHY_CTRL_ENHOSTDISCONDETECT BIT(1)
+#define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
+
+/* Do disconnection between PHY and controller without vbus */
+#define MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS BIT(0)
+
+/*
+ * The PHY will be in messy if there is an wakeup after putting
+ * bus to suspend (set portsc.suspendM) but before setting PHY to low
+ * power mode (set portsc.phcd).
+ */
+#define MXS_PHY_ABNORAML_IN_SUSPEND BIT(1)
+
+/*
+ * The SOF sends too fast after resuming, it will cause disconnection
+ * between host and high speed device.
+ */
+#define MXS_PHY_SENDING_SOF_TOO_FAST BIT(2)
+
+struct mxs_phy_platform_flag {
+ unsigned int flags;
+};
+
+static const struct mxs_phy_platform_flag imx23_phy_data = {
+ .flags = MXS_PHY_ABNORAML_IN_SUSPEND | MXS_PHY_SENDING_SOF_TOO_FAST,
+};
+
+static const struct mxs_phy_platform_flag imx6q_phy_data = {
+ .flags = MXS_PHY_SENDING_SOF_TOO_FAST |
+ MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS,
+};
+
+static const struct mxs_phy_platform_flag imx6sl_phy_data = {
+ .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS,
+};
+
+static const struct of_device_id mxs_phy_dt_ids[] = {
+ { .compatible = "fsl,imx6sl-usbphy", .data = &imx6sl_phy_data, },
+ { .compatible = "fsl,imx6q-usbphy", .data = &imx6q_phy_data, },
+ { .compatible = "fsl,imx23-usbphy", .data = &imx23_phy_data, },
+ { /* sentinel */ }
+};
+MODULE_DEVICE_TABLE(of, mxs_phy_dt_ids);
+
struct mxs_phy {
struct usb_phy phy;
struct clk *clk;
+ unsigned int flags;
};
-#define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
-
static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
{
int ret;
@@ -131,6 +174,9 @@ static int mxs_phy_probe(struct platform_device *pdev)
struct clk *clk;
struct mxs_phy *mxs_phy;
int ret;
+ const struct of_device_id *of_id =
+ of_match_device(mxs_phy_dt_ids, &pdev->dev);
+ const struct mxs_phy_platform_flag *platform_flag = of_id->data;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
base = devm_ioremap_resource(&pdev->dev, res);
@@ -163,6 +209,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
ATOMIC_INIT_NOTIFIER_HEAD(&mxs_phy->phy.notifier);
mxs_phy->clk = clk;
+ mxs_phy->flags = platform_flag->flags;
platform_set_drvdata(pdev, &mxs_phy->phy);
@@ -182,12 +229,6 @@ static int mxs_phy_remove(struct platform_device *pdev)
return 0;
}
-static const struct of_device_id mxs_phy_dt_ids[] = {
- { .compatible = "fsl,imx23-usbphy", },
- { /* sentinel */ }
-};
-MODULE_DEVICE_TABLE(of, mxs_phy_dt_ids);
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 02/11] usb: phy-mxs: Add auto clock and power setting
2013-11-05 1:49 [PATCH v3 00/11] Add power management support for MXS PHY Peter Chen
@ 2013-11-05 1:49 ` Peter Chen
2013-11-05 1:49 ` [PATCH v3 03/11] usb: doc: phy-mxs: update binding for adding anatop phandle Peter Chen
` (6 subsequent siblings)
7 siblings, 0 replies; 28+ messages in thread
From: Peter Chen @ 2013-11-05 1:49 UTC (permalink / raw)
To: balbi, shawn.guo, rob.herring, grant.likely
Cc: alexander.shishkin, linux-usb, linux-arm-kernel, festevam, marex,
kernel, m.grzeschik, frank.li, peter.chen, gregkh, devicetree,
linux-doc
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 8b9d80c..472fe36 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)
@@ -96,9 +101,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] 28+ messages in thread
* [PATCH v3 03/11] usb: doc: phy-mxs: update binding for adding anatop phandle
2013-11-05 1:49 [PATCH v3 00/11] Add power management support for MXS PHY Peter Chen
2013-11-05 1:49 ` [PATCH v3 02/11] usb: phy-mxs: Add auto clock and power setting Peter Chen
@ 2013-11-05 1:49 ` Peter Chen
2013-11-05 2:34 ` Shawn Guo
[not found] ` <1383616183-10511-1-git-send-email-peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
` (5 subsequent siblings)
7 siblings, 1 reply; 28+ messages in thread
From: Peter Chen @ 2013-11-05 1:49 UTC (permalink / raw)
To: balbi, shawn.guo, rob.herring, grant.likely
Cc: marex, devicetree, m.grzeschik, frank.li, linux-doc,
alexander.shishkin, gregkh, linux-usb, peter.chen, kernel,
festevam, 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..e2d5211 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 is only for mx6 SoC serial
Example:
usbphy1: usbphy@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] 28+ messages in thread
* [PATCH v3 04/11] ARM: dts: imx6: add anatop phandle for usbphy
[not found] ` <1383616183-10511-1-git-send-email-peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2013-11-05 1:49 ` [PATCH v3 01/11] usb: phy-mxs: Add platform judgement code Peter Chen
@ 2013-11-05 1:49 ` Peter Chen
2013-11-05 2:41 ` Shawn Guo
2013-11-05 1:49 ` [PATCH v3 08/11] usb: phy-mxs: Enable IC fixes for related SoCs Peter Chen
2013-11-05 1:49 ` [PATCH v3 09/11] usb: phy: Add set_wakeup API Peter Chen
3 siblings, 1 reply; 28+ messages in thread
From: Peter Chen @ 2013-11-05 1:49 UTC (permalink / raw)
To: balbi-l0cyMroinI0, shawn.guo-QSEj5FYQhm4dnm+yROfE0A,
rob.herring-bsGFqQB8/DxBDgjK7y7TUQ,
grant.likely-QSEj5FYQhm4dnm+yROfE0A
Cc: alexander.shishkin-VuQAYsv1563Yd54FQh9/CA,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
festevam-Re5JQEeQqe8AvxtiuMwx3w, marex-ynQEQJNshbs,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ, m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ,
frank.li-KZfg59tc24xl57MIdRCFDg,
peter.chen-KZfg59tc24xl57MIdRCFDg,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-doc-u79uwXL29TY76Z2rM5mHXA
Add anatop phandle for usbphy
Signed-off-by: Peter Chen <peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
---
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 226ce75..bb79678 100644
--- a/arch/arm/boot/dts/imx6qdl.dtsi
+++ b/arch/arm/boot/dts/imx6qdl.dtsi
@@ -559,6 +559,7 @@
reg = <0x020c9000 0x1000>;
interrupts = <0 44 0x04>;
clocks = <&clks 182>;
+ fsl,anatop = <&anatop>;
};
usbphy2: usbphy@020ca000 {
@@ -566,6 +567,7 @@
reg = <0x020ca000 0x1000>;
interrupts = <0 45 0x04>;
clocks = <&clks 183>;
+ fsl,anatop = <&anatop>;
};
snvs@020cc000 {
--
1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 05/11] usb: phy-mxs: Add anatop regmap
2013-11-05 1:49 [PATCH v3 00/11] Add power management support for MXS PHY Peter Chen
` (2 preceding siblings ...)
[not found] ` <1383616183-10511-1-git-send-email-peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
@ 2013-11-05 1:49 ` Peter Chen
2013-11-05 2:47 ` Shawn Guo
2013-11-05 1:49 ` [PATCH v3 06/11] usb: phy: add notify suspend and resume callback Peter Chen
` (3 subsequent siblings)
7 siblings, 1 reply; 28+ messages in thread
From: Peter Chen @ 2013-11-05 1:49 UTC (permalink / raw)
To: balbi, shawn.guo, rob.herring, grant.likely
Cc: alexander.shishkin, linux-usb, linux-arm-kernel, festevam, marex,
kernel, m.grzeschik, frank.li, peter.chen, gregkh, devicetree,
linux-doc
It is needed by imx6 SoC serial, but not for imx23 and imx28.
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/phy/phy-mxs-usb.c | 15 +++++++++++++++
1 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index 472fe36..8cdfbf1 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"
@@ -87,6 +89,7 @@ struct mxs_phy {
struct usb_phy phy;
struct clk *clk;
unsigned int flags;
+ struct regmap *regmap_anatop;
};
static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
@@ -191,6 +194,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
const struct of_device_id *of_id =
of_match_device(mxs_phy_dt_ids, &pdev->dev);
const struct mxs_phy_platform_flag *platform_flag = of_id->data;
+ struct device_node *np = pdev->dev.of_node;
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
base = devm_ioremap_resource(&pdev->dev, res);
@@ -210,6 +214,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] 28+ messages in thread
* [PATCH v3 06/11] usb: phy: add notify suspend and resume callback
2013-11-05 1:49 [PATCH v3 00/11] Add power management support for MXS PHY Peter Chen
` (3 preceding siblings ...)
2013-11-05 1:49 ` [PATCH v3 05/11] usb: phy-mxs: Add anatop regmap Peter Chen
@ 2013-11-05 1:49 ` Peter Chen
2013-11-05 1:49 ` [PATCH v3 07/11] usb: phy-mxs: Add implementation of nofity_suspend and notify_resume Peter Chen
` (2 subsequent siblings)
7 siblings, 0 replies; 28+ messages in thread
From: Peter Chen @ 2013-11-05 1:49 UTC (permalink / raw)
To: balbi, shawn.guo, rob.herring, grant.likely
Cc: marex, devicetree, m.grzeschik, frank.li, linux-doc,
alexander.shishkin, gregkh, linux-usb, peter.chen, kernel,
festevam, 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] 28+ messages in thread
* [PATCH v3 07/11] usb: phy-mxs: Add implementation of nofity_suspend and notify_resume
2013-11-05 1:49 [PATCH v3 00/11] Add power management support for MXS PHY Peter Chen
` (4 preceding siblings ...)
2013-11-05 1:49 ` [PATCH v3 06/11] usb: phy: add notify suspend and resume callback Peter Chen
@ 2013-11-05 1:49 ` Peter Chen
2013-11-05 1:49 ` [PATCH v3 10/11] usb: phy-mxs: Add implementation of set_wakeup Peter Chen
2013-11-05 1:49 ` [PATCH v3 11/11] usb: phy-mxs: Add system suspend/resume API Peter Chen
7 siblings, 0 replies; 28+ messages in thread
From: Peter Chen @ 2013-11-05 1:49 UTC (permalink / raw)
To: balbi, shawn.guo, rob.herring, grant.likely
Cc: alexander.shishkin, linux-usb, linux-arm-kernel, festevam, marex,
kernel, m.grzeschik, frank.li, peter.chen, gregkh, devicetree,
linux-doc
Implementation of notify_suspend and notify_resume will be different
according to mxs_phy_platform_flag->flags.
Signed-off-by: Peter Chen <peter.chen@freescale.com>
---
drivers/usb/phy/phy-mxs-usb.c | 54 +++++++++++++++++++++++++++++++++++++---
1 files changed, 50 insertions(+), 4 deletions(-)
diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index 8cdfbf1..c794011 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -161,8 +161,8 @@ static int mxs_phy_suspend(struct usb_phy *x, int suspend)
static int mxs_phy_on_connect(struct usb_phy *phy,
enum usb_device_speed speed)
{
- dev_dbg(phy->dev, "%s speed device has connected\n",
- (speed == USB_SPEED_HIGH) ? "high" : "non-high");
+ dev_dbg(phy->dev, "%s device has connected\n",
+ (speed == USB_SPEED_HIGH) ? "HS" : "FS/LS");
if (speed == USB_SPEED_HIGH)
writel(BM_USBPHY_CTRL_ENHOSTDISCONDETECT,
@@ -174,8 +174,8 @@ static int mxs_phy_on_connect(struct usb_phy *phy,
static int mxs_phy_on_disconnect(struct usb_phy *phy,
enum usb_device_speed speed)
{
- dev_dbg(phy->dev, "%s speed device has disconnected\n",
- (speed == USB_SPEED_HIGH) ? "high" : "non-high");
+ dev_dbg(phy->dev, "%s device has disconnected\n",
+ (speed == USB_SPEED_HIGH) ? "HS" : "FS/LS");
if (speed == USB_SPEED_HIGH)
writel(BM_USBPHY_CTRL_ENHOSTDISCONDETECT,
@@ -184,6 +184,48 @@ static int mxs_phy_on_disconnect(struct usb_phy *phy,
return 0;
}
+static int mxs_phy_on_suspend(struct usb_phy *phy,
+ enum usb_device_speed speed)
+{
+ struct mxs_phy *mxs_phy = to_mxs_phy(phy);
+
+ dev_dbg(phy->dev, "%s device has suspended\n",
+ (speed == USB_SPEED_HIGH) ? "HS" : "FS/LS");
+
+ /* delay 4ms to wait bus entering idle */
+ usleep_range(4000, 5000);
+
+ if (mxs_phy->flags & MXS_PHY_ABNORAML_IN_SUSPEND) {
+ 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;
+}
+
+/*
+ * 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 device has resumed\n",
+ (speed == USB_SPEED_HIGH) ? "HS" : "FS/LS");
+
+ 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;
+}
+
static int mxs_phy_probe(struct platform_device *pdev)
{
struct resource *res;
@@ -239,6 +281,10 @@ static int mxs_phy_probe(struct platform_device *pdev)
mxs_phy->clk = clk;
mxs_phy->flags = platform_flag->flags;
+ if (mxs_phy->flags & MXS_PHY_SENDING_SOF_TOO_FAST) {
+ mxs_phy->phy.notify_suspend = mxs_phy_on_suspend;
+ mxs_phy->phy.notify_resume = mxs_phy_on_resume;
+ }
platform_set_drvdata(pdev, &mxs_phy->phy);
--
1.7.1
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 08/11] usb: phy-mxs: Enable IC fixes for related SoCs
[not found] ` <1383616183-10511-1-git-send-email-peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2013-11-05 1:49 ` [PATCH v3 01/11] usb: phy-mxs: Add platform judgement code Peter Chen
2013-11-05 1:49 ` [PATCH v3 04/11] ARM: dts: imx6: add anatop phandle for usbphy Peter Chen
@ 2013-11-05 1:49 ` Peter Chen
[not found] ` <1383616183-10511-9-git-send-email-peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2013-11-05 1:49 ` [PATCH v3 09/11] usb: phy: Add set_wakeup API Peter Chen
3 siblings, 1 reply; 28+ messages in thread
From: Peter Chen @ 2013-11-05 1:49 UTC (permalink / raw)
To: balbi-l0cyMroinI0, shawn.guo-QSEj5FYQhm4dnm+yROfE0A,
rob.herring-bsGFqQB8/DxBDgjK7y7TUQ,
grant.likely-QSEj5FYQhm4dnm+yROfE0A
Cc: alexander.shishkin-VuQAYsv1563Yd54FQh9/CA,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
festevam-Re5JQEeQqe8AvxtiuMwx3w, marex-ynQEQJNshbs,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ, m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ,
frank.li-KZfg59tc24xl57MIdRCFDg,
peter.chen-KZfg59tc24xl57MIdRCFDg,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-doc-u79uwXL29TY76Z2rM5mHXA
Some PHY bugs are fixed by IC logic, but these bits are not
enabled by default, so we enable them at driver.
Signed-off-by: Peter Chen <peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
---
drivers/usb/phy/phy-mxs-usb.c | 32 ++++++++++++++++++++++++++++++--
1 files changed, 30 insertions(+), 2 deletions(-)
diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index c794011..b7e1744 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -31,6 +31,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)
@@ -60,6 +64,18 @@
*/
#define MXS_PHY_SENDING_SOF_TOO_FAST BIT(2)
+/*
+ * IC fix for MXS_PHY_ABNORAML_IN_SUSPEND, bit 17 is the effective bit
+ * in HW_USBPHY_IP.
+ */
+#define MXS_PHY_FIX_ABNORAML_IN_SUSPEND BIT(17)
+
+/*
+ * IC fix for MXS_PHY_SENDING_SOF_TOO_FAST, bit 18 is the effective bit
+ * in HW_USBPHY_IP.
+ */
+#define MXS_PHY_FIX_SENDING_SOF_TOO_FAST BIT(18)
+
struct mxs_phy_platform_flag {
unsigned int flags;
};
@@ -70,11 +86,14 @@ static const struct mxs_phy_platform_flag imx23_phy_data = {
static const struct mxs_phy_platform_flag imx6q_phy_data = {
.flags = MXS_PHY_SENDING_SOF_TOO_FAST |
- MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS,
+ MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS |
+ MXS_PHY_FIX_ABNORAML_IN_SUSPEND,
};
static const struct mxs_phy_platform_flag imx6sl_phy_data = {
- .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS,
+ .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS |
+ MXS_PHY_FIX_ABNORAML_IN_SUSPEND |
+ MXS_PHY_FIX_SENDING_SOF_TOO_FAST,
};
static const struct of_device_id mxs_phy_dt_ids[] = {
@@ -118,6 +137,15 @@ static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
BM_USBPHY_CTRL_ENUTMILEVEL3,
base + HW_USBPHY_CTRL_SET);
+ /* Enable IC solution */
+ if (mxs_phy->flags & MXS_PHY_FIX_ABNORAML_IN_SUSPEND)
+ writel(MXS_PHY_FIX_ABNORAML_IN_SUSPEND,
+ base + HW_USBPHY_IP_SET);
+
+ if (mxs_phy->flags & MXS_PHY_FIX_SENDING_SOF_TOO_FAST)
+ writel(MXS_PHY_FIX_SENDING_SOF_TOO_FAST,
+ base + HW_USBPHY_IP_SET);
+
return 0;
}
--
1.7.1
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 09/11] usb: phy: Add set_wakeup API
[not found] ` <1383616183-10511-1-git-send-email-peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
` (2 preceding siblings ...)
2013-11-05 1:49 ` [PATCH v3 08/11] usb: phy-mxs: Enable IC fixes for related SoCs Peter Chen
@ 2013-11-05 1:49 ` Peter Chen
3 siblings, 0 replies; 28+ messages in thread
From: Peter Chen @ 2013-11-05 1:49 UTC (permalink / raw)
To: balbi-l0cyMroinI0, shawn.guo-QSEj5FYQhm4dnm+yROfE0A,
rob.herring-bsGFqQB8/DxBDgjK7y7TUQ,
grant.likely-QSEj5FYQhm4dnm+yROfE0A
Cc: alexander.shishkin-VuQAYsv1563Yd54FQh9/CA,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
festevam-Re5JQEeQqe8AvxtiuMwx3w, marex-ynQEQJNshbs,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ, m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ,
frank.li-KZfg59tc24xl57MIdRCFDg,
peter.chen-KZfg59tc24xl57MIdRCFDg,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-doc-u79uwXL29TY76Z2rM5mHXA
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-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
---
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
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply related [flat|nested] 28+ messages in thread
* [PATCH v3 10/11] usb: phy-mxs: Add implementation of set_wakeup
2013-11-05 1:49 [PATCH v3 00/11] Add power management support for MXS PHY Peter Chen
` (5 preceding siblings ...)
2013-11-05 1:49 ` [PATCH v3 07/11] usb: phy-mxs: Add implementation of nofity_suspend and notify_resume Peter Chen
@ 2013-11-05 1:49 ` Peter Chen
2013-11-05 1:49 ` [PATCH v3 11/11] usb: phy-mxs: Add system suspend/resume API Peter Chen
7 siblings, 0 replies; 28+ messages in thread
From: Peter Chen @ 2013-11-05 1:49 UTC (permalink / raw)
To: balbi, shawn.guo, rob.herring, grant.likely
Cc: alexander.shishkin, linux-usb, linux-arm-kernel, festevam, marex,
kernel, m.grzeschik, frank.li, peter.chen, gregkh, devicetree,
linux-doc
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 | 79 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 79 insertions(+), 0 deletions(-)
diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index b7e1744..ff8b98c 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,6 +52,19 @@
#define BM_USBPHY_CTRL_ENUTMILEVEL2 BIT(14)
#define BM_USBPHY_CTRL_ENHOSTDISCONDETECT BIT(1)
+#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)
/* Do disconnection between PHY and controller without vbus */
@@ -149,6 +168,48 @@ 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;
+
+ /* If the SoCs don't need to disconnect line without vbus, quit */
+ if (!(mxs_phy->flags & MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS))
+ return;
+
+ /* If the SoCs don't have anatop, quit */
+ if (!mxs_phy->regmap_anatop)
+ 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);
@@ -186,6 +247,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)
{
@@ -304,6 +382,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] 28+ messages in thread
* [PATCH v3 11/11] usb: phy-mxs: Add system suspend/resume API
2013-11-05 1:49 [PATCH v3 00/11] Add power management support for MXS PHY Peter Chen
` (6 preceding siblings ...)
2013-11-05 1:49 ` [PATCH v3 10/11] usb: phy-mxs: Add implementation of set_wakeup Peter Chen
@ 2013-11-05 1:49 ` Peter Chen
[not found] ` <1383616183-10511-12-git-send-email-peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
7 siblings, 1 reply; 28+ messages in thread
From: Peter Chen @ 2013-11-05 1:49 UTC (permalink / raw)
To: balbi, shawn.guo, rob.herring, grant.likely
Cc: alexander.shishkin, linux-usb, linux-arm-kernel, festevam, marex,
kernel, m.grzeschik, frank.li, peter.chen, gregkh, devicetree,
linux-doc
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 | 66 +++++++++++++++++++++++++++++++++++++++--
1 files changed, 63 insertions(+), 3 deletions(-)
diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
index ff8b98c..4588c72 100644
--- a/drivers/usb/phy/phy-mxs-usb.c
+++ b/drivers/usb/phy/phy-mxs-usb.c
@@ -55,11 +55,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)
@@ -83,6 +90,15 @@
*/
#define MXS_PHY_SENDING_SOF_TOO_FAST BIT(2)
+/* imx23 style PHY */
+#define MXS_PHY_IMX23 BIT(3)
+
+/* imx6q style PHY */
+#define MXS_PHY_IMX6Q BIT(4)
+
+/* imx6sl style PHY */
+#define MXS_PHY_IMX6SL BIT(5)
+
/*
* IC fix for MXS_PHY_ABNORAML_IN_SUSPEND, bit 17 is the effective bit
* in HW_USBPHY_IP.
@@ -100,19 +116,23 @@ struct mxs_phy_platform_flag {
};
static const struct mxs_phy_platform_flag imx23_phy_data = {
- .flags = MXS_PHY_ABNORAML_IN_SUSPEND | MXS_PHY_SENDING_SOF_TOO_FAST,
+ .flags = MXS_PHY_ABNORAML_IN_SUSPEND |
+ MXS_PHY_SENDING_SOF_TOO_FAST |
+ MXS_PHY_IMX23,
};
static const struct mxs_phy_platform_flag imx6q_phy_data = {
.flags = MXS_PHY_SENDING_SOF_TOO_FAST |
MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS |
- MXS_PHY_FIX_ABNORAML_IN_SUSPEND,
+ MXS_PHY_FIX_ABNORAML_IN_SUSPEND |
+ MXS_PHY_IMX6Q,
};
static const struct mxs_phy_platform_flag imx6sl_phy_data = {
.flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS |
MXS_PHY_FIX_ABNORAML_IN_SUSPEND |
- MXS_PHY_FIX_SENDING_SOF_TOO_FAST,
+ MXS_PHY_FIX_SENDING_SOF_TOO_FAST |
+ MXS_PHY_IMX6SL,
};
static const struct of_device_id mxs_phy_dt_ids[] = {
@@ -210,6 +230,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;
+
+ /* If the SoCs don't have anatop, quit */
+ if (!mxs_phy->regmap_anatop)
+ return;
+
+ if (mxs_phy->flags & MXS_PHY_IMX6Q)
+ regmap_write(mxs_phy->regmap_anatop, reg,
+ BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG);
+ else if (mxs_phy->flags & MXS_PHY_IMX6SL)
+ 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);
@@ -395,6 +431,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;
@@ -411,6 +448,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,
@@ -418,6 +477,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] 28+ messages in thread
* Re: [PATCH v3 01/11] usb: phy-mxs: Add platform judgement code
2013-11-05 1:49 ` [PATCH v3 01/11] usb: phy-mxs: Add platform judgement code Peter Chen
@ 2013-11-05 2:29 ` Shawn Guo
2013-11-05 2:48 ` Peter Chen
0 siblings, 1 reply; 28+ messages in thread
From: Shawn Guo @ 2013-11-05 2:29 UTC (permalink / raw)
To: Peter Chen
Cc: balbi, rob.herring, grant.likely, alexander.shishkin, linux-usb,
linux-arm-kernel, festevam, marex, kernel, m.grzeschik, frank.li,
gregkh, devicetree, linux-doc
On Tue, Nov 05, 2013 at 09:49:33AM +0800, Peter Chen wrote:
> The mxs-phy has several bugs and features at different
> versions, the driver code can get it through of_device_id.data.
>
> Signed-off-by: Peter Chen <peter.chen@freescale.com>
> ---
> drivers/usb/phy/phy-mxs-usb.c | 59 ++++++++++++++++++++++++++++++++++------
> 1 files changed, 50 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
> index fdd33b4..8b9d80c 100644
> --- a/drivers/usb/phy/phy-mxs-usb.c
> +++ b/drivers/usb/phy/phy-mxs-usb.c
> @@ -1,5 +1,5 @@
> /*
> - * Copyright 2012 Freescale Semiconductor, Inc.
> + * Copyright 2012-2013 Freescale Semiconductor, Inc.
> * Copyright (C) 2012 Marek Vasut <marex@denx.de>
> * on behalf of DENX Software Engineering GmbH
> *
> @@ -20,6 +20,7 @@
> #include <linux/delay.h>
> #include <linux/err.h>
> #include <linux/io.h>
> +#include <linux/of_device.h>
>
> #define DRIVER_NAME "mxs_phy"
>
> @@ -34,13 +35,55 @@
> #define BM_USBPHY_CTRL_ENUTMILEVEL2 BIT(14)
> #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT BIT(1)
>
> +#define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
> +
> +/* Do disconnection between PHY and controller without vbus */
> +#define MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS BIT(0)
> +
> +/*
> + * The PHY will be in messy if there is an wakeup after putting
> + * bus to suspend (set portsc.suspendM) but before setting PHY to low
> + * power mode (set portsc.phcd).
> + */
> +#define MXS_PHY_ABNORAML_IN_SUSPEND BIT(1)
> +
> +/*
> + * The SOF sends too fast after resuming, it will cause disconnection
> + * between host and high speed device.
> + */
> +#define MXS_PHY_SENDING_SOF_TOO_FAST BIT(2)
> +
> +struct mxs_phy_platform_flag {
> + unsigned int flags;
> +};
We should design it as a structure not only for flags but any data that
we may need to define. That said, mxs_phy_platform_flag is not a good
name to me. I think mxs_phy_data should be more scalable and future
proof, considering one day we may have more to add into the structure.
> +
> +static const struct mxs_phy_platform_flag imx23_phy_data = {
> + .flags = MXS_PHY_ABNORAML_IN_SUSPEND | MXS_PHY_SENDING_SOF_TOO_FAST,
> +};
> +
> +static const struct mxs_phy_platform_flag imx6q_phy_data = {
> + .flags = MXS_PHY_SENDING_SOF_TOO_FAST |
> + MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS,
> +};
> +
> +static const struct mxs_phy_platform_flag imx6sl_phy_data = {
> + .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS,
> +};
> +
> +static const struct of_device_id mxs_phy_dt_ids[] = {
> + { .compatible = "fsl,imx6sl-usbphy", .data = &imx6sl_phy_data, },
> + { .compatible = "fsl,imx6q-usbphy", .data = &imx6q_phy_data, },
> + { .compatible = "fsl,imx23-usbphy", .data = &imx23_phy_data, },
> + { /* sentinel */ }
> +};
> +MODULE_DEVICE_TABLE(of, mxs_phy_dt_ids);
> +
> struct mxs_phy {
> struct usb_phy phy;
> struct clk *clk;
> + unsigned int flags;
Here, we should have a pointer to struct mxs_phy_data.
Shawn
> };
>
> -#define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
> -
> static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
> {
> int ret;
> @@ -131,6 +174,9 @@ static int mxs_phy_probe(struct platform_device *pdev)
> struct clk *clk;
> struct mxs_phy *mxs_phy;
> int ret;
> + const struct of_device_id *of_id =
> + of_match_device(mxs_phy_dt_ids, &pdev->dev);
> + const struct mxs_phy_platform_flag *platform_flag = of_id->data;
>
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> base = devm_ioremap_resource(&pdev->dev, res);
> @@ -163,6 +209,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
> ATOMIC_INIT_NOTIFIER_HEAD(&mxs_phy->phy.notifier);
>
> mxs_phy->clk = clk;
> + mxs_phy->flags = platform_flag->flags;
>
> platform_set_drvdata(pdev, &mxs_phy->phy);
>
> @@ -182,12 +229,6 @@ static int mxs_phy_remove(struct platform_device *pdev)
> return 0;
> }
>
> -static const struct of_device_id mxs_phy_dt_ids[] = {
> - { .compatible = "fsl,imx23-usbphy", },
> - { /* sentinel */ }
> -};
> -MODULE_DEVICE_TABLE(of, mxs_phy_dt_ids);
> -
> static struct platform_driver mxs_phy_driver = {
> .probe = mxs_phy_probe,
> .remove = mxs_phy_remove,
> --
> 1.7.1
>
>
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v3 03/11] usb: doc: phy-mxs: update binding for adding anatop phandle
2013-11-05 1:49 ` [PATCH v3 03/11] usb: doc: phy-mxs: update binding for adding anatop phandle Peter Chen
@ 2013-11-05 2:34 ` Shawn Guo
2013-11-05 2:50 ` Peter Chen
0 siblings, 1 reply; 28+ messages in thread
From: Shawn Guo @ 2013-11-05 2:34 UTC (permalink / raw)
To: Peter Chen
Cc: balbi, rob.herring, grant.likely, alexander.shishkin, linux-usb,
linux-arm-kernel, festevam, marex, kernel, m.grzeschik, frank.li,
gregkh, devicetree, linux-doc
On Tue, Nov 05, 2013 at 09:49:35AM +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..e2d5211 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"
This needs update too, as we now have another two compatible strings.
> - reg: Should contain registers location and length
> - interrupts: Should contain phy interrupt
> +- fsl,anatop: phandle for anatop register, it is only for mx6 SoC serial
imx6 SoC series
Shawn
>
> Example:
> usbphy1: usbphy@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] 28+ messages in thread
* Re: [PATCH v3 04/11] ARM: dts: imx6: add anatop phandle for usbphy
2013-11-05 1:49 ` [PATCH v3 04/11] ARM: dts: imx6: add anatop phandle for usbphy Peter Chen
@ 2013-11-05 2:41 ` Shawn Guo
2013-11-05 2:53 ` Peter Chen
0 siblings, 1 reply; 28+ messages in thread
From: Shawn Guo @ 2013-11-05 2:41 UTC (permalink / raw)
To: Peter Chen
Cc: balbi, rob.herring, grant.likely, alexander.shishkin, linux-usb,
linux-arm-kernel, festevam, marex, kernel, m.grzeschik, frank.li,
gregkh, devicetree, linux-doc
On Tue, Nov 05, 2013 at 09:49:36AM +0800, Peter Chen wrote:
> 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(-)
Does imx6sl.dtsi need the same update?
Shawn
>
> diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi
> index 226ce75..bb79678 100644
> --- a/arch/arm/boot/dts/imx6qdl.dtsi
> +++ b/arch/arm/boot/dts/imx6qdl.dtsi
> @@ -559,6 +559,7 @@
> reg = <0x020c9000 0x1000>;
> interrupts = <0 44 0x04>;
> clocks = <&clks 182>;
> + fsl,anatop = <&anatop>;
> };
>
> usbphy2: usbphy@020ca000 {
> @@ -566,6 +567,7 @@
> reg = <0x020ca000 0x1000>;
> interrupts = <0 45 0x04>;
> clocks = <&clks 183>;
> + fsl,anatop = <&anatop>;
> };
>
> snvs@020cc000 {
> --
> 1.7.1
>
>
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v3 05/11] usb: phy-mxs: Add anatop regmap
2013-11-05 1:49 ` [PATCH v3 05/11] usb: phy-mxs: Add anatop regmap Peter Chen
@ 2013-11-05 2:47 ` Shawn Guo
[not found] ` <20131105024753.GH19770-rvtDTF3kK1ictlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
0 siblings, 1 reply; 28+ messages in thread
From: Shawn Guo @ 2013-11-05 2:47 UTC (permalink / raw)
To: Peter Chen
Cc: balbi, rob.herring, grant.likely, alexander.shishkin, linux-usb,
linux-arm-kernel, festevam, marex, kernel, m.grzeschik, frank.li,
gregkh, devicetree, linux-doc
On Tue, Nov 05, 2013 at 09:49:37AM +0800, Peter Chen wrote:
> It is needed by imx6 SoC serial, but not for imx23 and imx28.
s/serial/series
Should we have another MXS_PHY_XXX flag for this, so that we can
explicitly check when anatop must be there?
Shawn
>
> Signed-off-by: Peter Chen <peter.chen@freescale.com>
> ---
> drivers/usb/phy/phy-mxs-usb.c | 15 +++++++++++++++
> 1 files changed, 15 insertions(+), 0 deletions(-)
>
> diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
> index 472fe36..8cdfbf1 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"
>
> @@ -87,6 +89,7 @@ struct mxs_phy {
> struct usb_phy phy;
> struct clk *clk;
> unsigned int flags;
> + struct regmap *regmap_anatop;
> };
>
> static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
> @@ -191,6 +194,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
> const struct of_device_id *of_id =
> of_match_device(mxs_phy_dt_ids, &pdev->dev);
> const struct mxs_phy_platform_flag *platform_flag = of_id->data;
> + struct device_node *np = pdev->dev.of_node;
>
> res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> base = devm_ioremap_resource(&pdev->dev, res);
> @@ -210,6 +214,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 [flat|nested] 28+ messages in thread
* Re: [PATCH v3 01/11] usb: phy-mxs: Add platform judgement code
2013-11-05 2:29 ` Shawn Guo
@ 2013-11-05 2:48 ` Peter Chen
0 siblings, 0 replies; 28+ messages in thread
From: Peter Chen @ 2013-11-05 2:48 UTC (permalink / raw)
To: Shawn Guo
Cc: balbi, rob.herring, grant.likely, alexander.shishkin, linux-usb,
linux-arm-kernel, festevam, marex, kernel, m.grzeschik, frank.li,
gregkh, devicetree, linux-doc
On Tue, Nov 05, 2013 at 10:29:50AM +0800, Shawn Guo wrote:
> On Tue, Nov 05, 2013 at 09:49:33AM +0800, Peter Chen wrote:
> > The mxs-phy has several bugs and features at different
> > versions, the driver code can get it through of_device_id.data.
> >
> > Signed-off-by: Peter Chen <peter.chen@freescale.com>
> > ---
> > drivers/usb/phy/phy-mxs-usb.c | 59 ++++++++++++++++++++++++++++++++++------
> > 1 files changed, 50 insertions(+), 9 deletions(-)
> >
> > diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
> > index fdd33b4..8b9d80c 100644
> > --- a/drivers/usb/phy/phy-mxs-usb.c
> > +++ b/drivers/usb/phy/phy-mxs-usb.c
> > @@ -1,5 +1,5 @@
> > /*
> > - * Copyright 2012 Freescale Semiconductor, Inc.
> > + * Copyright 2012-2013 Freescale Semiconductor, Inc.
> > * Copyright (C) 2012 Marek Vasut <marex@denx.de>
> > * on behalf of DENX Software Engineering GmbH
> > *
> > @@ -20,6 +20,7 @@
> > #include <linux/delay.h>
> > #include <linux/err.h>
> > #include <linux/io.h>
> > +#include <linux/of_device.h>
> >
> > #define DRIVER_NAME "mxs_phy"
> >
> > @@ -34,13 +35,55 @@
> > #define BM_USBPHY_CTRL_ENUTMILEVEL2 BIT(14)
> > #define BM_USBPHY_CTRL_ENHOSTDISCONDETECT BIT(1)
> >
> > +#define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
> > +
> > +/* Do disconnection between PHY and controller without vbus */
> > +#define MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS BIT(0)
> > +
> > +/*
> > + * The PHY will be in messy if there is an wakeup after putting
> > + * bus to suspend (set portsc.suspendM) but before setting PHY to low
> > + * power mode (set portsc.phcd).
> > + */
> > +#define MXS_PHY_ABNORAML_IN_SUSPEND BIT(1)
> > +
> > +/*
> > + * The SOF sends too fast after resuming, it will cause disconnection
> > + * between host and high speed device.
> > + */
> > +#define MXS_PHY_SENDING_SOF_TOO_FAST BIT(2)
> > +
> > +struct mxs_phy_platform_flag {
> > + unsigned int flags;
> > +};
>
> We should design it as a structure not only for flags but any data that
> we may need to define. That said, mxs_phy_platform_flag is not a good
> name to me. I think mxs_phy_data should be more scalable and future
> proof, considering one day we may have more to add into the structure.
>
> > +
> > +static const struct mxs_phy_platform_flag imx23_phy_data = {
> > + .flags = MXS_PHY_ABNORAML_IN_SUSPEND | MXS_PHY_SENDING_SOF_TOO_FAST,
> > +};
> > +
> > +static const struct mxs_phy_platform_flag imx6q_phy_data = {
> > + .flags = MXS_PHY_SENDING_SOF_TOO_FAST |
> > + MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS,
> > +};
> > +
> > +static const struct mxs_phy_platform_flag imx6sl_phy_data = {
> > + .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS,
> > +};
> > +
> > +static const struct of_device_id mxs_phy_dt_ids[] = {
> > + { .compatible = "fsl,imx6sl-usbphy", .data = &imx6sl_phy_data, },
> > + { .compatible = "fsl,imx6q-usbphy", .data = &imx6q_phy_data, },
> > + { .compatible = "fsl,imx23-usbphy", .data = &imx23_phy_data, },
> > + { /* sentinel */ }
> > +};
> > +MODULE_DEVICE_TABLE(of, mxs_phy_dt_ids);
> > +
> > struct mxs_phy {
> > struct usb_phy phy;
> > struct clk *clk;
> > + unsigned int flags;
>
> Here, we should have a pointer to struct mxs_phy_data.
>
Will change both of two names.
Peter
> >
> > -#define to_mxs_phy(p) container_of((p), struct mxs_phy, phy)
> > -
> > static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
> > {
> > int ret;
> > @@ -131,6 +174,9 @@ static int mxs_phy_probe(struct platform_device *pdev)
> > struct clk *clk;
> > struct mxs_phy *mxs_phy;
> > int ret;
> > + const struct of_device_id *of_id =
> > + of_match_device(mxs_phy_dt_ids, &pdev->dev);
> > + const struct mxs_phy_platform_flag *platform_flag = of_id->data;
> >
> > res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > base = devm_ioremap_resource(&pdev->dev, res);
> > @@ -163,6 +209,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
> > ATOMIC_INIT_NOTIFIER_HEAD(&mxs_phy->phy.notifier);
> >
> > mxs_phy->clk = clk;
> > + mxs_phy->flags = platform_flag->flags;
> >
> > platform_set_drvdata(pdev, &mxs_phy->phy);
> >
> > @@ -182,12 +229,6 @@ static int mxs_phy_remove(struct platform_device *pdev)
> > return 0;
> > }
> >
> > -static const struct of_device_id mxs_phy_dt_ids[] = {
> > - { .compatible = "fsl,imx23-usbphy", },
> > - { /* sentinel */ }
> > -};
> > -MODULE_DEVICE_TABLE(of, mxs_phy_dt_ids);
> > -
> > static struct platform_driver mxs_phy_driver = {
> > .probe = mxs_phy_probe,
> > .remove = mxs_phy_remove,
> > --
> > 1.7.1
> >
> >
--
Best Regards,
Peter Chen
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v3 03/11] usb: doc: phy-mxs: update binding for adding anatop phandle
2013-11-05 2:34 ` Shawn Guo
@ 2013-11-05 2:50 ` Peter Chen
2013-11-05 3:15 ` Shawn Guo
0 siblings, 1 reply; 28+ messages in thread
From: Peter Chen @ 2013-11-05 2:50 UTC (permalink / raw)
To: Shawn Guo
Cc: marex, devicetree, m.grzeschik, frank.li, linux-doc,
alexander.shishkin, gregkh, linux-usb, rob.herring, balbi, kernel,
grant.likely, festevam, linux-arm-kernel
On Tue, Nov 05, 2013 at 10:34:06AM +0800, Shawn Guo wrote:
> On Tue, Nov 05, 2013 at 09:49:35AM +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..e2d5211 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"
>
> This needs update too, as we now have another two compatible strings.
>
One question, this is needed to change when adding compatible string
to dts or using that compatible string at driver?
> > - reg: Should contain registers location and length
> > - interrupts: Should contain phy interrupt
> > +- fsl,anatop: phandle for anatop register, it is only for mx6 SoC serial
>
> imx6 SoC series
>
Will change
--
Best Regards,
Peter Chen
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v3 04/11] ARM: dts: imx6: add anatop phandle for usbphy
2013-11-05 2:41 ` Shawn Guo
@ 2013-11-05 2:53 ` Peter Chen
2013-11-05 3:16 ` Shawn Guo
0 siblings, 1 reply; 28+ messages in thread
From: Peter Chen @ 2013-11-05 2:53 UTC (permalink / raw)
To: Shawn Guo
Cc: marex, devicetree, m.grzeschik, frank.li, linux-doc,
alexander.shishkin, gregkh, linux-usb, rob.herring, balbi, kernel,
grant.likely, festevam, linux-arm-kernel
On Tue, Nov 05, 2013 at 10:41:33AM +0800, Shawn Guo wrote:
> On Tue, Nov 05, 2013 at 09:49:36AM +0800, Peter Chen wrote:
> > 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(-)
>
> Does imx6sl.dtsi need the same update?
>
It is needed (for chipidea, it is the same), but I still have
no time to test on it. Will add them later.
Peter
> Shawn
>
> >
> > diff --git a/arch/arm/boot/dts/imx6qdl.dtsi b/arch/arm/boot/dts/imx6qdl.dtsi
> > index 226ce75..bb79678 100644
> > --- a/arch/arm/boot/dts/imx6qdl.dtsi
> > +++ b/arch/arm/boot/dts/imx6qdl.dtsi
> > @@ -559,6 +559,7 @@
> > reg = <0x020c9000 0x1000>;
> > interrupts = <0 44 0x04>;
> > clocks = <&clks 182>;
> > + fsl,anatop = <&anatop>;
> > };
> >
> > usbphy2: usbphy@020ca000 {
> > @@ -566,6 +567,7 @@
> > reg = <0x020ca000 0x1000>;
> > interrupts = <0 45 0x04>;
> > clocks = <&clks 183>;
> > + fsl,anatop = <&anatop>;
> > };
> >
> > snvs@020cc000 {
> > --
> > 1.7.1
> >
> >
--
Best Regards,
Peter Chen
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v3 11/11] usb: phy-mxs: Add system suspend/resume API
2013-11-05 3:05 ` Shawn Guo
@ 2013-11-05 2:59 ` Peter Chen
2013-11-05 4:04 ` Shawn Guo
0 siblings, 1 reply; 28+ messages in thread
From: Peter Chen @ 2013-11-05 2:59 UTC (permalink / raw)
To: Shawn Guo
Cc: balbi, rob.herring, grant.likely, alexander.shishkin, linux-usb,
linux-arm-kernel, festevam, marex, kernel, m.grzeschik, frank.li,
gregkh, devicetree, linux-doc
On Tue, Nov 05, 2013 at 11:05:15AM +0800, Shawn Guo wrote:
> On Tue, Nov 05, 2013 at 09:49:43AM +0800, Peter Chen wrote:
> > 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 | 66 +++++++++++++++++++++++++++++++++++++++--
> > 1 files changed, 63 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
> > index ff8b98c..4588c72 100644
> > --- a/drivers/usb/phy/phy-mxs-usb.c
> > +++ b/drivers/usb/phy/phy-mxs-usb.c
> > @@ -55,11 +55,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)
> > @@ -83,6 +90,15 @@
> > */
> > #define MXS_PHY_SENDING_SOF_TOO_FAST BIT(2)
> >
> > +/* imx23 style PHY */
> > +#define MXS_PHY_IMX23 BIT(3)
> > +
> > +/* imx6q style PHY */
> > +#define MXS_PHY_IMX6Q BIT(4)
> > +
> > +/* imx6sl style PHY */
> > +#define MXS_PHY_IMX6SL BIT(5)
> > +
>
> We will not need these, if we do what I suggested to carry a pointer
> to mxs_phy_data in mxs_phy.
>
> struct mxs_phy {
> ...
> struct mxs_phy_data *data;
> };
>
> The check then can be done like below.
>
> static inline int is_imx6q_phy(struct mxs_phy *mxs_phy)
> {
> return mxs_phy->data == &imx6q_phy_data;
> }
>
What's the benefit compared to current one?
Peter
> Shawn
>
> > /*
> > * IC fix for MXS_PHY_ABNORAML_IN_SUSPEND, bit 17 is the effective bit
> > * in HW_USBPHY_IP.
> > @@ -100,19 +116,23 @@ struct mxs_phy_platform_flag {
> > };
> >
> > static const struct mxs_phy_platform_flag imx23_phy_data = {
> > - .flags = MXS_PHY_ABNORAML_IN_SUSPEND | MXS_PHY_SENDING_SOF_TOO_FAST,
> > + .flags = MXS_PHY_ABNORAML_IN_SUSPEND |
> > + MXS_PHY_SENDING_SOF_TOO_FAST |
> > + MXS_PHY_IMX23,
> > };
> >
> > static const struct mxs_phy_platform_flag imx6q_phy_data = {
> > .flags = MXS_PHY_SENDING_SOF_TOO_FAST |
> > MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS |
> > - MXS_PHY_FIX_ABNORAML_IN_SUSPEND,
> > + MXS_PHY_FIX_ABNORAML_IN_SUSPEND |
> > + MXS_PHY_IMX6Q,
> > };
> >
> > static const struct mxs_phy_platform_flag imx6sl_phy_data = {
> > .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS |
> > MXS_PHY_FIX_ABNORAML_IN_SUSPEND |
> > - MXS_PHY_FIX_SENDING_SOF_TOO_FAST,
> > + MXS_PHY_FIX_SENDING_SOF_TOO_FAST |
> > + MXS_PHY_IMX6SL,
> > };
> >
> > static const struct of_device_id mxs_phy_dt_ids[] = {
> > @@ -210,6 +230,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;
> > +
> > + /* If the SoCs don't have anatop, quit */
> > + if (!mxs_phy->regmap_anatop)
> > + return;
> > +
> > + if (mxs_phy->flags & MXS_PHY_IMX6Q)
> > + regmap_write(mxs_phy->regmap_anatop, reg,
> > + BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG);
> > + else if (mxs_phy->flags & MXS_PHY_IMX6SL)
> > + 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);
> > @@ -395,6 +431,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;
> > @@ -411,6 +448,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,
> > @@ -418,6 +477,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
> >
> >
--
Best Regards,
Peter Chen
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v3 04/11] ARM: dts: imx6: add anatop phandle for usbphy
[not found] ` <20131105031654.GL19770-rvtDTF3kK1ictlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
@ 2013-11-05 3:02 ` Peter Chen
0 siblings, 0 replies; 28+ messages in thread
From: Peter Chen @ 2013-11-05 3:02 UTC (permalink / raw)
To: Shawn Guo
Cc: balbi-l0cyMroinI0, rob.herring-bsGFqQB8/DxBDgjK7y7TUQ,
grant.likely-QSEj5FYQhm4dnm+yROfE0A,
alexander.shishkin-VuQAYsv1563Yd54FQh9/CA,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
festevam-Re5JQEeQqe8AvxtiuMwx3w, marex-ynQEQJNshbs,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ, m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ,
frank.li-KZfg59tc24xl57MIdRCFDg,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-doc-u79uwXL29TY76Z2rM5mHXA
On Tue, Nov 05, 2013 at 11:16:57AM +0800, Shawn Guo wrote:
> On Tue, Nov 05, 2013 at 10:53:08AM +0800, Peter Chen wrote:
> > On Tue, Nov 05, 2013 at 10:41:33AM +0800, Shawn Guo wrote:
> > > On Tue, Nov 05, 2013 at 09:49:36AM +0800, Peter Chen wrote:
> > > > Add anatop phandle for usbphy
> > > >
> > > > Signed-off-by: Peter Chen <peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
> > > > ---
> > > > arch/arm/boot/dts/imx6qdl.dtsi | 2 ++
> > > > 1 files changed, 2 insertions(+), 0 deletions(-)
> > >
> > > Does imx6sl.dtsi need the same update?
> > >
> >
> > It is needed (for chipidea, it is the same), but I still have
> > no time to test on it. Will add them later.
>
> So all "fsl,imx6sl-usbphy" code is untested so far?
>
> Shawn
Yes, "fsl,imx23-usbphy" and "fsl,imx6q-usbphy" have been tested,
I will test imx6sl during this patchset review cycle.
--
Best Regards,
Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v3 11/11] usb: phy-mxs: Add system suspend/resume API
[not found] ` <1383616183-10511-12-git-send-email-peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
@ 2013-11-05 3:05 ` Shawn Guo
2013-11-05 2:59 ` Peter Chen
0 siblings, 1 reply; 28+ messages in thread
From: Shawn Guo @ 2013-11-05 3:05 UTC (permalink / raw)
To: Peter Chen
Cc: balbi-l0cyMroinI0, rob.herring-bsGFqQB8/DxBDgjK7y7TUQ,
grant.likely-QSEj5FYQhm4dnm+yROfE0A,
alexander.shishkin-VuQAYsv1563Yd54FQh9/CA,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
festevam-Re5JQEeQqe8AvxtiuMwx3w, marex-ynQEQJNshbs,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ, m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ,
frank.li-KZfg59tc24xl57MIdRCFDg,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-doc-u79uwXL29TY76Z2rM5mHXA
On Tue, Nov 05, 2013 at 09:49:43AM +0800, Peter Chen wrote:
> 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-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
> ---
> drivers/usb/phy/phy-mxs-usb.c | 66 +++++++++++++++++++++++++++++++++++++++--
> 1 files changed, 63 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
> index ff8b98c..4588c72 100644
> --- a/drivers/usb/phy/phy-mxs-usb.c
> +++ b/drivers/usb/phy/phy-mxs-usb.c
> @@ -55,11 +55,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)
> @@ -83,6 +90,15 @@
> */
> #define MXS_PHY_SENDING_SOF_TOO_FAST BIT(2)
>
> +/* imx23 style PHY */
> +#define MXS_PHY_IMX23 BIT(3)
> +
> +/* imx6q style PHY */
> +#define MXS_PHY_IMX6Q BIT(4)
> +
> +/* imx6sl style PHY */
> +#define MXS_PHY_IMX6SL BIT(5)
> +
We will not need these, if we do what I suggested to carry a pointer
to mxs_phy_data in mxs_phy.
struct mxs_phy {
...
struct mxs_phy_data *data;
};
The check then can be done like below.
static inline int is_imx6q_phy(struct mxs_phy *mxs_phy)
{
return mxs_phy->data == &imx6q_phy_data;
}
Shawn
> /*
> * IC fix for MXS_PHY_ABNORAML_IN_SUSPEND, bit 17 is the effective bit
> * in HW_USBPHY_IP.
> @@ -100,19 +116,23 @@ struct mxs_phy_platform_flag {
> };
>
> static const struct mxs_phy_platform_flag imx23_phy_data = {
> - .flags = MXS_PHY_ABNORAML_IN_SUSPEND | MXS_PHY_SENDING_SOF_TOO_FAST,
> + .flags = MXS_PHY_ABNORAML_IN_SUSPEND |
> + MXS_PHY_SENDING_SOF_TOO_FAST |
> + MXS_PHY_IMX23,
> };
>
> static const struct mxs_phy_platform_flag imx6q_phy_data = {
> .flags = MXS_PHY_SENDING_SOF_TOO_FAST |
> MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS |
> - MXS_PHY_FIX_ABNORAML_IN_SUSPEND,
> + MXS_PHY_FIX_ABNORAML_IN_SUSPEND |
> + MXS_PHY_IMX6Q,
> };
>
> static const struct mxs_phy_platform_flag imx6sl_phy_data = {
> .flags = MXS_PHY_DISCONNECT_LINE_WITHOUT_VBUS |
> MXS_PHY_FIX_ABNORAML_IN_SUSPEND |
> - MXS_PHY_FIX_SENDING_SOF_TOO_FAST,
> + MXS_PHY_FIX_SENDING_SOF_TOO_FAST |
> + MXS_PHY_IMX6SL,
> };
>
> static const struct of_device_id mxs_phy_dt_ids[] = {
> @@ -210,6 +230,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;
> +
> + /* If the SoCs don't have anatop, quit */
> + if (!mxs_phy->regmap_anatop)
> + return;
> +
> + if (mxs_phy->flags & MXS_PHY_IMX6Q)
> + regmap_write(mxs_phy->regmap_anatop, reg,
> + BM_ANADIG_ANA_MISC0_STOP_MODE_CONFIG);
> + else if (mxs_phy->flags & MXS_PHY_IMX6SL)
> + 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);
> @@ -395,6 +431,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;
> @@ -411,6 +448,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,
> @@ -418,6 +477,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
>
>
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v3 03/11] usb: doc: phy-mxs: update binding for adding anatop phandle
2013-11-05 2:50 ` Peter Chen
@ 2013-11-05 3:15 ` Shawn Guo
0 siblings, 0 replies; 28+ messages in thread
From: Shawn Guo @ 2013-11-05 3:15 UTC (permalink / raw)
To: Peter Chen
Cc: marex, devicetree, m.grzeschik, frank.li, linux-doc,
alexander.shishkin, gregkh, linux-usb, rob.herring, balbi, kernel,
grant.likely, festevam, linux-arm-kernel
On Tue, Nov 05, 2013 at 10:50:02AM +0800, Peter Chen wrote:
> On Tue, Nov 05, 2013 at 10:34:06AM +0800, Shawn Guo wrote:
> > On Tue, Nov 05, 2013 at 09:49:35AM +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..e2d5211 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"
> >
> > This needs update too, as we now have another two compatible strings.
> >
>
> One question, this is needed to change when adding compatible string
> to dts or using that compatible string at driver?
When compatible match table in the driver gets new entries.
Shawn
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v3 04/11] ARM: dts: imx6: add anatop phandle for usbphy
2013-11-05 2:53 ` Peter Chen
@ 2013-11-05 3:16 ` Shawn Guo
[not found] ` <20131105031654.GL19770-rvtDTF3kK1ictlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
0 siblings, 1 reply; 28+ messages in thread
From: Shawn Guo @ 2013-11-05 3:16 UTC (permalink / raw)
To: Peter Chen
Cc: balbi, rob.herring, grant.likely, alexander.shishkin, linux-usb,
linux-arm-kernel, festevam, marex, kernel, m.grzeschik, frank.li,
gregkh, devicetree, linux-doc
On Tue, Nov 05, 2013 at 10:53:08AM +0800, Peter Chen wrote:
> On Tue, Nov 05, 2013 at 10:41:33AM +0800, Shawn Guo wrote:
> > On Tue, Nov 05, 2013 at 09:49:36AM +0800, Peter Chen wrote:
> > > 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(-)
> >
> > Does imx6sl.dtsi need the same update?
> >
>
> It is needed (for chipidea, it is the same), but I still have
> no time to test on it. Will add them later.
So all "fsl,imx6sl-usbphy" code is untested so far?
Shawn
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v3 11/11] usb: phy-mxs: Add system suspend/resume API
2013-11-05 2:59 ` Peter Chen
@ 2013-11-05 4:04 ` Shawn Guo
0 siblings, 0 replies; 28+ messages in thread
From: Shawn Guo @ 2013-11-05 4:04 UTC (permalink / raw)
To: Peter Chen
Cc: balbi, rob.herring, grant.likely, alexander.shishkin, linux-usb,
linux-arm-kernel, festevam, marex, kernel, m.grzeschik, frank.li,
gregkh, devicetree, linux-doc
On Tue, Nov 05, 2013 at 10:59:17AM +0800, Peter Chen wrote:
> > > @@ -83,6 +90,15 @@
> > > */
> > > #define MXS_PHY_SENDING_SOF_TOO_FAST BIT(2)
> > >
> > > +/* imx23 style PHY */
> > > +#define MXS_PHY_IMX23 BIT(3)
> > > +
> > > +/* imx6q style PHY */
> > > +#define MXS_PHY_IMX6Q BIT(4)
> > > +
> > > +/* imx6sl style PHY */
> > > +#define MXS_PHY_IMX6SL BIT(5)
> > > +
> >
> > We will not need these, if we do what I suggested to carry a pointer
> > to mxs_phy_data in mxs_phy.
> >
> > struct mxs_phy {
> > ...
> > struct mxs_phy_data *data;
> > };
> >
> > The check then can be done like below.
> >
> > static inline int is_imx6q_phy(struct mxs_phy *mxs_phy)
> > {
> > return mxs_phy->data == &imx6q_phy_data;
> > }
> >
>
> What's the benefit compared to current one?
Save those pointless flags.
Shawn
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v3 05/11] usb: phy-mxs: Add anatop regmap
[not found] ` <20131105024753.GH19770-rvtDTF3kK1ictlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
@ 2013-11-05 5:17 ` Peter Chen
0 siblings, 0 replies; 28+ messages in thread
From: Peter Chen @ 2013-11-05 5:17 UTC (permalink / raw)
To: Shawn Guo
Cc: balbi-l0cyMroinI0, rob.herring-bsGFqQB8/DxBDgjK7y7TUQ,
grant.likely-QSEj5FYQhm4dnm+yROfE0A,
alexander.shishkin-VuQAYsv1563Yd54FQh9/CA,
linux-usb-u79uwXL29TY76Z2rM5mHXA,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r,
festevam-Re5JQEeQqe8AvxtiuMwx3w, marex-ynQEQJNshbs,
kernel-bIcnvbaLZ9MEGnE8C9+IrQ, m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ,
frank.li-KZfg59tc24xl57MIdRCFDg,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
devicetree-u79uwXL29TY76Z2rM5mHXA,
linux-doc-u79uwXL29TY76Z2rM5mHXA
On Tue, Nov 05, 2013 at 10:47:55AM +0800, Shawn Guo wrote:
> On Tue, Nov 05, 2013 at 09:49:37AM +0800, Peter Chen wrote:
> > It is needed by imx6 SoC serial, but not for imx23 and imx28.
>
> s/serial/series
>
> Should we have another MXS_PHY_XXX flag for this, so that we can
> explicitly check when anatop must be there?
>
OK, I will add it, it can let the imx23/28 do not check dts.
> Shawn
>
> >
> > Signed-off-by: Peter Chen <peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
> > ---
> > drivers/usb/phy/phy-mxs-usb.c | 15 +++++++++++++++
> > 1 files changed, 15 insertions(+), 0 deletions(-)
> >
> > diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
> > index 472fe36..8cdfbf1 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"
> >
> > @@ -87,6 +89,7 @@ struct mxs_phy {
> > struct usb_phy phy;
> > struct clk *clk;
> > unsigned int flags;
> > + struct regmap *regmap_anatop;
> > };
> >
> > static int mxs_phy_hw_init(struct mxs_phy *mxs_phy)
> > @@ -191,6 +194,7 @@ static int mxs_phy_probe(struct platform_device *pdev)
> > const struct of_device_id *of_id =
> > of_match_device(mxs_phy_dt_ids, &pdev->dev);
> > const struct mxs_phy_platform_flag *platform_flag = of_id->data;
> > + struct device_node *np = pdev->dev.of_node;
> >
> > res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
> > base = devm_ioremap_resource(&pdev->dev, res);
> > @@ -210,6 +214,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
> >
> >
--
Best Regards,
Peter Chen
--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v3 08/11] usb: phy-mxs: Enable IC fixes for related SoCs
[not found] ` <1383616183-10511-9-git-send-email-peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
@ 2013-11-05 21:02 ` Michał Mirosław
2013-11-06 7:35 ` Peter Chen
0 siblings, 1 reply; 28+ messages in thread
From: Michał Mirosław @ 2013-11-05 21:02 UTC (permalink / raw)
To: Peter Chen
Cc: Felipe Balbi, Shawn Guo, rob.herring-bsGFqQB8/DxBDgjK7y7TUQ,
grant.likely-QSEj5FYQhm4dnm+yROfE0A, Marek Vašut,
devicetree-u79uwXL29TY76Z2rM5mHXA,
m.grzeschik-bIcnvbaLZ9MEGnE8C9+IrQ,
frank.li-KZfg59tc24xl57MIdRCFDg, linux-doc-u79uwXL29TY76Z2rM5mHXA,
alexander.shishkin-VuQAYsv1563Yd54FQh9/CA,
gregkh-hQyY1W1yCW8ekmWlsbkhG0B+6BGkLq7r,
linux-usb-u79uwXL29TY76Z2rM5mHXA, kernel-bIcnvbaLZ9MEGnE8C9+IrQ,
festevam-Re5JQEeQqe8AvxtiuMwx3w,
linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
2013/11/5 Peter Chen <peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
>
> Some PHY bugs are fixed by IC logic, but these bits are not
> enabled by default, so we enable them at driver.
>
> Signed-off-by: Peter Chen <peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
> ---
> drivers/usb/phy/phy-mxs-usb.c | 32 ++++++++++++++++++++++++++++++--
> 1 files changed, 30 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
> index c794011..b7e1744 100644
> --- a/drivers/usb/phy/phy-mxs-usb.c
> +++ b/drivers/usb/phy/phy-mxs-usb.c
> @@ -31,6 +31,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)
> @@ -60,6 +64,18 @@
> */
> #define MXS_PHY_SENDING_SOF_TOO_FAST BIT(2)
>
> +/*
> + * IC fix for MXS_PHY_ABNORAML_IN_SUSPEND, bit 17 is the effective bit
> + * in HW_USBPHY_IP.
> + */
> +#define MXS_PHY_FIX_ABNORAML_IN_SUSPEND BIT(17)
[...]
s/ABNORAML/ABNORMAL/ ?
Best Regards,
Michał Mirosław
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 28+ messages in thread
* Re: [PATCH v3 08/11] usb: phy-mxs: Enable IC fixes for related SoCs
2013-11-05 21:02 ` Michał Mirosław
@ 2013-11-06 7:35 ` Peter Chen
0 siblings, 0 replies; 28+ messages in thread
From: Peter Chen @ 2013-11-06 7:35 UTC (permalink / raw)
To: Michał Mirosław
Cc: Felipe Balbi, Shawn Guo, rob.herring, grant.likely,
Marek Vašut, devicetree, m.grzeschik, frank.li, linux-doc,
alexander.shishkin, gregkh, linux-usb, kernel, festevam,
linux-arm-kernel@lists.infradead.org
On Tue, Nov 05, 2013 at 10:02:35PM +0100, Michał Mirosław wrote:
> 2013/11/5 Peter Chen <peter.chen@freescale.com>
> >
> > Some PHY bugs are fixed by IC logic, but these bits are not
> > enabled by default, so we enable them at driver.
> >
> > Signed-off-by: Peter Chen <peter.chen@freescale.com>
> > ---
> > drivers/usb/phy/phy-mxs-usb.c | 32 ++++++++++++++++++++++++++++++--
> > 1 files changed, 30 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/usb/phy/phy-mxs-usb.c b/drivers/usb/phy/phy-mxs-usb.c
> > index c794011..b7e1744 100644
> > --- a/drivers/usb/phy/phy-mxs-usb.c
> > +++ b/drivers/usb/phy/phy-mxs-usb.c
> > @@ -31,6 +31,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)
> > @@ -60,6 +64,18 @@
> > */
> > #define MXS_PHY_SENDING_SOF_TOO_FAST BIT(2)
> >
> > +/*
> > + * IC fix for MXS_PHY_ABNORAML_IN_SUSPEND, bit 17 is the effective bit
> > + * in HW_USBPHY_IP.
> > + */
> > +#define MXS_PHY_FIX_ABNORAML_IN_SUSPEND BIT(17)
> [...]
>
> s/ABNORAML/ABNORMAL/ ?
>
thanks.
--
Best Regards,
Peter Chen
^ permalink raw reply [flat|nested] 28+ messages in thread
end of thread, other threads:[~2013-11-06 7:35 UTC | newest]
Thread overview: 28+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-05 1:49 [PATCH v3 00/11] Add power management support for MXS PHY Peter Chen
2013-11-05 1:49 ` [PATCH v3 02/11] usb: phy-mxs: Add auto clock and power setting Peter Chen
2013-11-05 1:49 ` [PATCH v3 03/11] usb: doc: phy-mxs: update binding for adding anatop phandle Peter Chen
2013-11-05 2:34 ` Shawn Guo
2013-11-05 2:50 ` Peter Chen
2013-11-05 3:15 ` Shawn Guo
[not found] ` <1383616183-10511-1-git-send-email-peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2013-11-05 1:49 ` [PATCH v3 01/11] usb: phy-mxs: Add platform judgement code Peter Chen
2013-11-05 2:29 ` Shawn Guo
2013-11-05 2:48 ` Peter Chen
2013-11-05 1:49 ` [PATCH v3 04/11] ARM: dts: imx6: add anatop phandle for usbphy Peter Chen
2013-11-05 2:41 ` Shawn Guo
2013-11-05 2:53 ` Peter Chen
2013-11-05 3:16 ` Shawn Guo
[not found] ` <20131105031654.GL19770-rvtDTF3kK1ictlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
2013-11-05 3:02 ` Peter Chen
2013-11-05 1:49 ` [PATCH v3 08/11] usb: phy-mxs: Enable IC fixes for related SoCs Peter Chen
[not found] ` <1383616183-10511-9-git-send-email-peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2013-11-05 21:02 ` Michał Mirosław
2013-11-06 7:35 ` Peter Chen
2013-11-05 1:49 ` [PATCH v3 09/11] usb: phy: Add set_wakeup API Peter Chen
2013-11-05 1:49 ` [PATCH v3 05/11] usb: phy-mxs: Add anatop regmap Peter Chen
2013-11-05 2:47 ` Shawn Guo
[not found] ` <20131105024753.GH19770-rvtDTF3kK1ictlrPMvKcciBecyulp+rMXqFh9Ls21Oc@public.gmane.org>
2013-11-05 5:17 ` Peter Chen
2013-11-05 1:49 ` [PATCH v3 06/11] usb: phy: add notify suspend and resume callback Peter Chen
2013-11-05 1:49 ` [PATCH v3 07/11] usb: phy-mxs: Add implementation of nofity_suspend and notify_resume Peter Chen
2013-11-05 1:49 ` [PATCH v3 10/11] usb: phy-mxs: Add implementation of set_wakeup Peter Chen
2013-11-05 1:49 ` [PATCH v3 11/11] usb: phy-mxs: Add system suspend/resume API Peter Chen
[not found] ` <1383616183-10511-12-git-send-email-peter.chen-KZfg59tc24xl57MIdRCFDg@public.gmane.org>
2013-11-05 3:05 ` Shawn Guo
2013-11-05 2:59 ` Peter Chen
2013-11-05 4:04 ` Shawn Guo
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).