Add power management support for MXS PHY
Subsystems (3)
v3 cover Add power management support for MXS PHY
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(-)
PATCH v3 1/11 usb: phy-mxs: Add platform judgement code
The mxs-phy has several bugs and features at different versions, the driver code can get it through of_device_id.data.
--- drivers/usb/phy/phy-mxs-usb.c | 59 ++++++++++++++++++++++++++++++++++------ 1 files changed, 50 insertions(+), 9 deletions(-)
drivers/usb/phy/phy-mxs-usb.c +50 -9
@@ -1,5 +1,5 @@/* -* Copyright 2012 Freescale Semiconductor, Inc. +* Copyright 2012-2013 Freescale Semiconductor, Inc. * Copyright (C) 2012 Marek Vasut <[email protected]> * 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); -static struct platform_driver mxs_phy_driver = { .probe = mxs_phy_probe, .remove = mxs_phy_remove,
Signature · 1 line
1.7.1
PATCH v3 1/11 usb: phy-mxs: Add platform judgement code
Quoted 42 lines · Peter Chen
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 <[email protected]>--- drivers/usb/phy/phy-mxs-usb.c | 59 ++++++++++++++++++++++++++++++++++------ 1 files changed, 50 insertions(+), 9 deletions(-)drivers/usb/phy/phy-mxs-usb.c +13
-1@@ -1,5 +1,5 @@/* -* Copyright 2012 Freescale Semiconductor, Inc. +* Copyright 2012-2013 Freescale Semiconductor, Inc. * Copyright (C) 2012 Marek Vasut <[email protected]> * 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)
drivers/usb/phy/phy-mxs-usb.c line 58
Quoted 10 lines
drivers/usb/phy/phy-mxs-usb.c +10
-0+ +/* +* 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.
Quoted 16 lines
drivers/usb/phy/phy-mxs-usb.c +16
-0+ +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, },
drivers/usb/phy/phy-mxs-usb.c line 84
Quoted 10 lines
drivers/usb/phy/phy-mxs-usb.c +7
-0+ { .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
Quoted 42 lines
drivers/usb/phy/phy-mxs-usb.c +4
-8}; -#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,Signature · 1 line
1.7.1
PATCH v3 1/11 usb: phy-mxs: Add platform judgement code
Quoted 79 lines · Shawn Guo
Quoted 42 lines · Peter Chen
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 <[email protected]>--- drivers/usb/phy/phy-mxs-usb.c | 59 ++++++++++++++++++++++++++++++++++------ 1 files changed, 50 insertions(+), 9 deletions(-)drivers/usb/phy/phy-mxs-usb.c +13
-1@@ -1,5 +1,5 @@/* -* Copyright 2012 Freescale Semiconductor, Inc. +* Copyright 2012-2013 Freescale Semiconductor, Inc. * Copyright (C) 2012 Marek Vasut <[email protected]> * 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)drivers/usb/phy/phy-mxs-usb.c line 58
Quoted 10 lines
drivers/usb/phy/phy-mxs-usb.c +10
-0+ +/* +* 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_flagis not a good name to me. I thinkmxs_phy_datashould be more scalable and future proof, considering one day we may have more to add into the structure.Quoted 20 lines
drivers/usb/phy/phy-mxs-usb.c +20
-0+ +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 */ } +};
Quoted 9 lines
drivers/usb/phy/phy-mxs-usb.c line 84
Quoted 6 lines
drivers/usb/phy/phy-mxs-usb.c +3
-0+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
Quoted 41 lines
Quoted 41 lines
drivers/usb/phy/phy-mxs-usb.c +4
-8-#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,Signature · 1 line
1.7.1
Signature · 2 lines
Best Regards, Peter Chen
PATCH v3 2/11 usb: phy-mxs: Add auto clock and power setting
In reply to Peter ChenWith the auto setting, the PHY's clock and power can be recovered correctly from low power mode, it is ganranteed by IC logic.
--- drivers/usb/phy/phy-mxs-usb.c | 20 +++++++++++++++++--- 1 files changed, 17 insertions(+), 3 deletions(-)
drivers/usb/phy/phy-mxs-usb.c +17 -3
@@ -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 ;
Signature · 1 line
1.7.1
PATCH v3 3/11 usb: doc: phy-mxs: update binding for adding anatop phandle
In reply to Peter ChenAdd anatop phandle which is used to access anatop registers to control PHY's power and other USB operations.
--- Documentation/devicetree/bindings/usb/mxs-phy.txt | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
Documentation/devicetree/bindings/usb/mxs-phy.txt +2 -0
@@ -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 at 020c9000 { compatible = "fsl,imx6q-usbphy", "fsl,imx23-usbphy"; reg = <0x020c9000 0x1000>; interrupts = <0 44 0x04>; + fsl,anatop = <&anatop>; };
Signature · 1 line
1.7.1
PATCH v3 3/11 usb: doc: phy-mxs: update binding for adding anatop phandle
Quoted 13 lines · Peter Chen
Add anatop phandle which is used to access anatop registers to control PHY's power and other USB operations.
Signed-off-by Peter Chen <[email protected]>--- Documentation/devicetree/bindings/usb/mxs-phy.txt | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)Documentation/devicetree/bindings/usb/mxs-phy.txt +0
-0
Documentation/devicetree/bindings/usb/mxs-phy.txt Required properties: · line 4
Quoted 1 line
Documentation/devicetree/bindings/usb/mxs-phy.txt +0
-0@@ -4,10 +4,12 @@ Required properties: - compatible: Should be "fsl,imx23-usbphy"
This needs update too, as we now have another two compatible strings.
Documentation/devicetree/bindings/usb/mxs-phy.txt Required properties: · line 7
Quoted 3 lines
Documentation/devicetree/bindings/usb/mxs-phy.txt +1
-0- 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
Quoted 12 lines
Documentation/devicetree/bindings/usb/mxs-phy.txt +1
-0Example: usbphy1: usbphy at 020c9000 { compatible = "fsl,imx6q-usbphy", "fsl,imx23-usbphy"; reg = <0x020c9000 0x1000>; interrupts = <0 44 0x04>; + fsl,anatop = <&anatop>; };Signature · 1 line
1.7.1
PATCH v3 3/11 usb: doc: phy-mxs: update binding for adding anatop phandle
Quoted 9 lines · Shawn Guo
Quoted 8 lines · Peter Chen
Add anatop phandle which is used to access anatop registers to control PHY's power and other USB operations.
Signed-off-by Peter Chen <[email protected]>--- Documentation/devicetree/bindings/usb/mxs-phy.txt | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
Quoted 9 lines
Documentation/devicetree/bindings/usb/mxs-phy.txt Required properties: · line 4
Quoted 6 lines
Documentation/devicetree/bindings/usb/mxs-phy.txt +0
-0@@ -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?
Quoted 6 lines
Documentation/devicetree/bindings/usb/mxs-phy.txt Required properties: · line 7
Quoted 3 lines
Documentation/devicetree/bindings/usb/mxs-phy.txt +1
-0- reg: Should contain registers location and length - interrupts: Should contain phy interrupt +- fsl,anatop: phandle for anatop register, it is only for mx6 SoC serialimx6 SoC series
Will change
Signature · 2 lines
Best Regards, Peter Chen
PATCH v3 3/11 usb: doc: phy-mxs: update binding for adding anatop phandle
Quoted 20 lines · Peter Chen
Quoted 9 lines · Shawn Guo
Quoted 8 lines · Peter Chen
Add anatop phandle which is used to access anatop registers to control PHY's power and other USB operations.
Signed-off-by Peter Chen <[email protected]>--- Documentation/devicetree/bindings/usb/mxs-phy.txt | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)Quoted 9 lines
Documentation/devicetree/bindings/usb/mxs-phy.txt Required properties: · line 4
Quoted 6 lines
Documentation/devicetree/bindings/usb/mxs-phy.txt +0
-0@@ -4,10 +4,12 @@ Required properties: - compatible: Should be "fsl,imx23-usbphy"This needs update too, as we now have another two compatible strings.
Quoted 2 lines
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
PATCH v3 4/11 ARM: dts: imx6: add anatop phandle for usbphy
In reply to Peter ChenAdd anatop phandle for usbphy
--- arch/arm/boot/dts/imx6qdl.dtsi | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
arch/arm/boot/dts/imx6qdl.dtsi +2 -0
@@ -559,6 +559,7 @@ reg = <0x020c9000 0x1000>; interrupts = <0 44 0x04>; clocks = <&clks 182>; + fsl,anatop = <&anatop>; }; usbphy2: usbphy at 020ca000 {
@@ -566,6 +567,7 @@ reg = <0x020ca000 0x1000>; interrupts = <0 45 0x04>; clocks = <&clks 183>; + fsl,anatop = <&anatop>; }; snvs at 020cc000 {
Signature · 1 line
1.7.1
PATCH v3 4/11 ARM: dts: imx6: add anatop phandle for usbphy
Quoted 6 lines · Peter Chen
Add anatop phandle for usbphy
Signed-off-by Peter Chen <[email protected]>--- arch/arm/boot/dts/imx6qdl.dtsi | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
Does imx6sl.dtsi need the same update?
Shawn
Quoted 25 lines
arch/arm/boot/dts/imx6qdl.dtsi +2
-0@@ -559,6 +559,7 @@ reg = <0x020c9000 0x1000>; interrupts = <0 44 0x04>; clocks = <&clks 182>; + fsl,anatop = <&anatop>; }; usbphy2: usbphy at 020ca000 {@@ -566,6 +567,7 @@ reg = <0x020ca000 0x1000>; interrupts = <0 45 0x04>; clocks = <&clks 183>; + fsl,anatop = <&anatop>; }; snvs at 020cc000 {Signature · 1 line
1.7.1
PATCH v3 4/11 ARM: dts: imx6: add anatop phandle for usbphy
Quoted 10 lines · Shawn Guo
Quoted 6 lines · Peter Chen
Add anatop phandle for usbphy
Signed-off-by Peter Chen <[email protected]>--- arch/arm/boot/dts/imx6qdl.dtsi | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)Does
imx6sl.dtsineed 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
Quoted 27 lines
Shawn
Quoted 25 lines
arch/arm/boot/dts/imx6qdl.dtsi +2
-0@@ -559,6 +559,7 @@ reg = <0x020c9000 0x1000>; interrupts = <0 44 0x04>; clocks = <&clks 182>; + fsl,anatop = <&anatop>; }; usbphy2: usbphy at 020ca000 {@@ -566,6 +567,7 @@ reg = <0x020ca000 0x1000>; interrupts = <0 45 0x04>; clocks = <&clks 183>; + fsl,anatop = <&anatop>; }; snvs at 020cc000 {Signature · 1 line
1.7.1
Signature · 2 lines
Best Regards, Peter Chen
PATCH v3 4/11 ARM: dts: imx6: add anatop phandle for usbphy
Quoted 9 lines · Peter Chen
Quoted 8 lines · Shawn Guo
Quoted 6 lines · Peter Chen
Add anatop phandle for usbphy
Signed-off-by Peter Chen <[email protected]>--- arch/arm/boot/dts/imx6qdl.dtsi | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
Quoted 5 lines
Quoted 2 lines
Does
imx6sl.dtsineed 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
PATCH v3 4/11 ARM: dts: imx6: add anatop phandle for usbphy
Quoted 13 lines · Shawn Guo
Quoted 12 lines · Peter Chen
Quoted 10 lines · Shawn Guo
Quoted 6 lines · Peter Chen
Add anatop phandle for usbphy
Signed-off-by Peter Chen <[email protected]>--- arch/arm/boot/dts/imx6qdl.dtsi | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)Does
imx6sl.dtsineed the same update?
Quoted 6 lines
Quoted 2 lines
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.
Signature · 2 lines
Best Regards, Peter Chen
PATCH v3 5/11 usb: phy-mxs: Add anatop regmap
In reply to Peter ChenIt is needed by imx6 SoC serial, but not for imx23 and imx28.
--- drivers/usb/phy/phy-mxs-usb.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-)
drivers/usb/phy/phy-mxs-usb.c +15 -0
@@ -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 ;
Signature · 1 line
1.7.1
PATCH v3 5/11 usb: phy-mxs: Add anatop regmap
Quoted 1 line · Peter Chen
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
Quoted 57 lines
Signed-off-by Peter Chen <[email protected]>--- drivers/usb/phy/phy-mxs-usb.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-)drivers/usb/phy/phy-mxs-usb.c +15
-0@@ -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 ;Signature · 1 line
1.7.1
PATCH v3 5/11 usb: phy-mxs: Add anatop regmap
Quoted 8 lines · Shawn Guo
Quoted 1 line · Peter Chen
It is needed by imx6 SoC serial, but not for imx23 and imx28.
s/serial/series
Should we have another
MXS_PHY_XXXflag 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.
Quoted 59 lines
Shawn
Quoted 57 lines
Signed-off-by Peter Chen <[email protected]>--- drivers/usb/phy/phy-mxs-usb.c | 15 +++++++++++++++ 1 files changed, 15 insertions(+), 0 deletions(-)drivers/usb/phy/phy-mxs-usb.c +15
-0@@ -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 ;Signature · 1 line
1.7.1
Signature · 2 lines
Best Regards, Peter Chen
PATCH v3 6/11 usb: phy: add notify suspend and resume callback
In reply to Peter ChenThey are used to notify PHY that the controller enters suspend or finishes resume.
--- include/linux/usb/phy.h | 23 +++++++++++++++++++++++ 1 files changed, 23 insertions(+), 0 deletions(-)
include/linux/usb/phy.h +23 -0
@@ -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)
Signature · 1 line
1.7.1
PATCH v3 7/11 usb: phy-mxs: Add implementation of nofity_suspend and notify_resume
In reply to Peter ChenImplementation of notify_suspend and notify_resume will be different according to mxs_phy_platform_flag->flags.
--- drivers/usb/phy/phy-mxs-usb.c | 54 +++++++++++++++++++++++++++++++++++++--- 1 files changed, 50 insertions(+), 4 deletions(-)
drivers/usb/phy/phy-mxs-usb.c +50 -4
@@ -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);
Signature · 1 line
1.7.1
PATCH v3 8/11 usb: phy-mxs: Enable IC fixes for related SoCs
In reply to Peter ChenSome PHY bugs are fixed by IC logic, but these bits are not enabled by default, so we enable them at driver.
--- drivers/usb/phy/phy-mxs-usb.c | 32 ++++++++++++++++++++++++++++++-- 1 files changed, 30 insertions(+), 2 deletions(-)
drivers/usb/phy/phy-mxs-usb.c +30 -2
@@ -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 ; }
Signature · 1 line
1.7.1
PATCH v3 8/11 usb: phy-mxs: Enable IC fixes for related SoCs
2013/11/5 Peter Chen <[email protected]>
Quoted 25 lines
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 <[email protected]>--- drivers/usb/phy/phy-mxs-usb.c | 32 ++++++++++++++++++++++++++++++-- 1 files changed, 30 insertions(+), 2 deletions(-)drivers/usb/phy/phy-mxs-usb.c +4
-0@@ -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)
drivers/usb/phy/phy-mxs-usb.c line 71
Quoted 8 lines
drivers/usb/phy/phy-mxs-usb.c +5
-0@@ -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
PATCH v3 8/11 usb: phy-mxs: Enable IC fixes for related SoCs
Quoted 29 lines · Micha? Miros?aw
2013/11/5 Peter Chen <[email protected]>
Quoted 28 lines
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 <[email protected]>--- drivers/usb/phy/phy-mxs-usb.c | 32 ++++++++++++++++++++++++++++++-- 1 files changed, 30 insertions(+), 2 deletions(-)drivers/usb/phy/phy-mxs-usb.c +4
-0@@ -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)
Quoted 9 lines
drivers/usb/phy/phy-mxs-usb.c line 71
Quoted 5 lines
drivers/usb/phy/phy-mxs-usb.c +5
-0+/* +* 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.
Signature · 2 lines
Best Regards, Peter Chen
PATCH v3 9/11 usb: phy: Add set_wakeup API
In reply to Peter ChenThis 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.
--- include/linux/usb/phy.h | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
include/linux/usb/phy.h +16 -0
@@ -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)
Signature · 1 line
1.7.1
PATCH v3 10/11 usb: phy-mxs: Add implementation of set_wakeup
In reply to Peter ChenWhen 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.
--- drivers/usb/phy/phy-mxs-usb.c | 79 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 79 insertions(+), 0 deletions(-)
drivers/usb/phy/phy-mxs-usb.c +79 -0
@@ -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);
Signature · 1 line
1.7.1
PATCH v3 11/11 usb: phy-mxs: Add system suspend/resume API
In reply to Peter ChenWe 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.
--- drivers/usb/phy/phy-mxs-usb.c | 66 +++++++++++++++++++++++++++++++++++++++-- 1 files changed, 63 insertions(+), 3 deletions(-)
drivers/usb/phy/phy-mxs-usb.c +63 -3
@@ -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, }, };
Signature · 1 line
1.7.1
PATCH v3 11/11 usb: phy-mxs: Add system suspend/resume API
Quoted 36 lines · Peter Chen
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 <[email protected]>--- drivers/usb/phy/phy-mxs-usb.c | 66 +++++++++++++++++++++++++++++++++++++++-- 1 files changed, 63 insertions(+), 3 deletions(-)drivers/usb/phy/phy-mxs-usb.c +7
-0@@ -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)
drivers/usb/phy/phy-mxs-usb.c line 101
Quoted 10 lines
drivers/usb/phy/phy-mxs-usb.c +9
-0+/* 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
Quoted 102 lines
drivers/usb/phy/phy-mxs-usb.c +47
-3/* * 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, }, };Signature · 1 line
1.7.1
PATCH v3 11/11 usb: phy-mxs: Add system suspend/resume API
Quoted 56 lines · Shawn Guo
Quoted 36 lines · Peter Chen
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 <[email protected]>--- drivers/usb/phy/phy-mxs-usb.c | 66 +++++++++++++++++++++++++++++++++++++++-- 1 files changed, 63 insertions(+), 3 deletions(-)drivers/usb/phy/phy-mxs-usb.c +7
-0@@ -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)drivers/usb/phy/phy-mxs-usb.c line 101
Quoted 10 lines
drivers/usb/phy/phy-mxs-usb.c +9
-0+/* 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_datainmxs_phy.struct mxs_phy { ... struct mxs_phy_data *data; };
Quoted 7 lines
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
Quoted 104 lines
Shawn
Quoted 102 lines
drivers/usb/phy/phy-mxs-usb.c +47
-3/* * 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, }, };Signature · 1 line
1.7.1
Signature · 2 lines
Best Regards, Peter Chen
PATCH v3 11/11 usb: phy-mxs: Add system suspend/resume API
Quoted 24 lines · Peter Chen
Quoted 24 lines
drivers/usb/phy/phy-mxs-usb.c line 101
Quoted 13 lines
drivers/usb/phy/phy-mxs-usb.c +9
-0@@ -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_datainmxs_phy.struct mxs_phy { ... struct mxs_phy_data *data; };The check then can be done like below.
Quoted 7 lines
Quoted 5 lines
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