usb: dwc2: Add reset ctrl to driver
PATCH v2 1/1 usb: dwc2: Add reset ctrl to driver
Add code to reset all reset signals as in usb DT node. A reset property is an optional feature, so only print out a warning and do not fail if a reset property is not present.
If a reset property is discovered, then use it to deassert, thus bringing the IP out of reset.
---
v2:
- Assert reset when .remove.
--- drivers/usb/host/dwc2.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
drivers/usb/host/dwc2.c +31 -0
@@ -15,6 +15,7 @@#include <wait_bit.h> #include <asm/io.h> #include <power/regulator.h> +#include <reset.h> #include "dwc2.h"
@@ -49,6 +50,8 @@ struct dwc2_priv {*/ bool hnp_srp_disable;bool oc_disable; + +struct reset_ctl_bulk resets; };#ifndef CONFIG_DM_USB
@@ -1124,11 +1127,37 @@ int _submit_int_msg(struct dwc2_priv *priv, struct usb_device *dev, } } +static int dwc2_reset (struct udevice *dev) +{ +int ret; +struct dwc2_priv *priv =dev_get_priv (dev); + + ret =reset_get_bulk (dev, &priv->resets); +if (ret) { +dev_warn (dev,"Can't get reset: %d\n" , ret); +return ret; + } + + ret =reset_deassert_bulk (&priv->resets); +if (ret) { +reset_release_bulk (&priv->resets); +dev_err (dev,"Failed to reset: %d\n" , ret); +return ret; + } + +return 0 ; +} +static int dwc2_init_common (struct udevice *dev,struct dwc2_priv *priv) {struct dwc2_core_regs *regs = priv->regs;uint32_t snpsid;int i, j; +int ret; + + ret =dwc2_reset (dev); +if (ret) +return ret; snpsid =readl (®s->gsnpsid); dev_info(dev, "Core Release: %x.%03x\n",
@@ -1303,6 +1332,8 @@ static int dwc2_usb_remove(struct udevice *dev)dwc2_uninit_common (priv->regs); +reset_release_bulk (&priv->resets); +return 0 ; }
Signature · 1 line
2.2.2
PATCH v2 1/1 usb: dwc2: Add reset ctrl to driver
Quoted 39 lines · Ley Foon Tan
Add code to reset all reset signals as in usb DT node. A reset property is an optional feature, so only print out a warning and do not fail if a reset property is not present.
If a reset property is discovered, then use it to deassert, thus bringing the IP out of reset.
Signed-off-by Ley Foon Tan <[email protected]>---
v2:
- Assert reset when .remove.--- drivers/usb/host/dwc2.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)drivers/usb/host/dwc2.c +3
-0@@ -15,6 +15,7 @@#include <wait_bit.h> #include <asm/io.h> #include <power/regulator.h> +#include <reset.h> #include "dwc2.h" @@ -49,6 +50,8 @@ struct dwc2_priv {*/ bool hnp_srp_disable;bool oc_disable; + +struct reset_ctl_bulk resets; };#ifndef CONFIG_DM_USB @@ -1124,11 +1127,37 @@ int _submit_int_msg(struct dwc2_priv *priv, struct usb_device *dev, }
drivers/usb/host/dwc2.c int _submit_int_msg(struct dwc2_priv *priv, struct usb_device *dev, · line 1137
Quoted 10 lines
drivers/usb/host/dwc2.c +8
-0} +static int dwc2_reset (struct udevice *dev) +{ +int ret; +struct dwc2_priv *priv =dev_get_priv (dev); + + ret =reset_get_bulk (dev, &priv->resets); +if (ret) { +dev_warn (dev,"Can't get reset: %d\n" , ret);
So this now generates a ton of warnings on Gen5 , right ? Did you test it on any Gen5 board recently ?
Quoted 27 lines
drivers/usb/host/dwc2.c +18
-0+return ret; + } + + ret =reset_deassert_bulk (&priv->resets); +if (ret) { +reset_release_bulk (&priv->resets); +dev_err (dev,"Failed to reset: %d\n" , ret); +return ret; + } + +return 0 ; +} +static int dwc2_init_common (struct udevice *dev,struct dwc2_priv *priv) {struct dwc2_core_regs *regs = priv->regs;uint32_t snpsid;int i, j; +int ret; + + ret =dwc2_reset (dev); +if (ret) +return ret; snpsid =readl (®s->gsnpsid); dev_info(dev, "Core Release: %x.%03x\n",
drivers/usb/host/dwc2.c static int dwc2_usb_remove(struct udevice *dev) · line 1335
Quoted 4 lines
drivers/usb/host/dwc2.c +1
-0@@ -1303,6 +1332,8 @@ static int dwc2_usb_remove(struct udevice *dev)dwc2_uninit_common (priv->regs); +reset_release_bulk (&priv->resets);
Dont you need to assert the resets too ?
Quoted 4 lines
drivers/usb/host/dwc2.c +0
-0return 0 ; }
Signature · 2 lines
Best regards, Marek Vasut
PATCH v2 1/1 usb: dwc2: Add reset ctrl to driver
Quoted 42 lines · Marek Vasut
Quoted 41 lines · Ley Foon Tan
Add code to reset all reset signals as in usb DT node. A reset property is an optional feature, so only print out a warning and do not fail if a reset property is not present.
If a reset property is discovered, then use it to deassert, thus bringing the IP out of reset.
Signed-off-by Ley Foon Tan <[email protected]>---
v2:
- Assert reset when .remove.--- drivers/usb/host/dwc2.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)drivers/usb/host/dwc2.c +3
-0@@ -15,6 +15,7 @@#include <wait_bit.h> #include <asm/io.h> #include <power/regulator.h> +#include <reset.h> #include "dwc2.h" @@ -49,6 +50,8 @@ struct dwc2_priv {*/ bool hnp_srp_disable;bool oc_disable; + +struct reset_ctl_bulk resets; };#ifndef CONFIG_DM_USB @@ -1124,11 +1127,37 @@ int _submit_int_msg(struct dwc2_priv *priv, struct usb_device *dev, } }
Quoted 11 lines
drivers/usb/host/dwc2.c int _submit_int_msg(struct dwc2_priv *priv, struct usb_device *dev, · line 1137
Quoted 8 lines
drivers/usb/host/dwc2.c +8
-0+static int dwc2_reset (struct udevice *dev) +{ +int ret; +struct dwc2_priv *priv =dev_get_priv (dev); + + ret =reset_get_bulk (dev, &priv->resets); +if (ret) { +dev_warn (dev,"Can't get reset: %d\n" , ret);So this now generates a ton of warnings on Gen5 , right ? Did you test it on any Gen5 board recently ?
Will change to "return 0" if can't find reset in dts, so it will not fail the probe.
It will not print warning by default. I don't have Gen5 board, but I tested with Stratix 10 by removing reset from USB DT node. We will not see the warning.
Quoted 29 lines
Quoted 29 lines
drivers/usb/host/dwc2.c +18
-0+return ret; + } + + ret =reset_deassert_bulk (&priv->resets); +if (ret) { +reset_release_bulk (&priv->resets); +dev_err (dev,"Failed to reset: %d\n" , ret); +return ret; + } + +return 0 ; +} +static int dwc2_init_common (struct udevice *dev,struct dwc2_priv *priv) {struct dwc2_core_regs *regs = priv->regs;uint32_t snpsid;int i, j; +int ret; + + ret =dwc2_reset (dev); +if (ret) +return ret; snpsid =readl (®s->gsnpsid); dev_info(dev, "Core Release: %x.%03x\n",@@ -1303,6 +1332,8 @@ static int dwc2_usb_remove(struct udevice *dev)
Quoted 5 lines
drivers/usb/host/dwc2.c static int dwc2_usb_remove(struct udevice *dev) · line 1335
Quoted 3 lines
drivers/usb/host/dwc2.c +1
-0dwc2_uninit_common (priv->regs); +reset_release_bulk (&priv->resets);Dont you need to assert the resets too ?
reset_release_bulk will assert the reset if it is requested before.
Quoted 6 lines
drivers/usb/host/dwc2.c static int dwc2_usb_remove(struct udevice *dev) · line 1339
Quoted 5 lines
drivers/usb/host/dwc2.c +0
-0return 0 ; }
Regards
Ley Foon
PATCH v2 1/1 usb: dwc2: Add reset ctrl to driver
Quoted 55 lines · Ley Foon Tan
Quoted 42 lines · Marek Vasut
Quoted 41 lines · Ley Foon Tan
Add code to reset all reset signals as in usb DT node. A reset property is an optional feature, so only print out a warning and do not fail if a reset property is not present.
If a reset property is discovered, then use it to deassert, thus bringing the IP out of reset.
Signed-off-by Ley Foon Tan <[email protected]>---
v2:
- Assert reset when .remove.--- drivers/usb/host/dwc2.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)drivers/usb/host/dwc2.c +3
-0@@ -15,6 +15,7 @@#include <wait_bit.h> #include <asm/io.h> #include <power/regulator.h> +#include <reset.h> #include "dwc2.h" @@ -49,6 +50,8 @@ struct dwc2_priv {*/ bool hnp_srp_disable;bool oc_disable; + +struct reset_ctl_bulk resets; };#ifndef CONFIG_DM_USB @@ -1124,11 +1127,37 @@ int _submit_int_msg(struct dwc2_priv *priv, struct usb_device *dev, } }Quoted 11 lines
drivers/usb/host/dwc2.c int _submit_int_msg(struct dwc2_priv *priv, struct usb_device *dev, · line 1137
Quoted 8 lines
drivers/usb/host/dwc2.c +8
-0+static int dwc2_reset (struct udevice *dev) +{ +int ret; +struct dwc2_priv *priv =dev_get_priv (dev); + + ret =reset_get_bulk (dev, &priv->resets); +if (ret) { +dev_warn (dev,"Can't get reset: %d\n" , ret);So this now generates a ton of warnings on Gen5 , right ? Did you test it on any Gen5 board recently ?
Quoted 2 lines
Will change to "return 0" if can't find reset in dts, so it will not fail the probe.
But that's a valid error. Maybe some ifdef CONFIG_RESET would be more appropriate ? Look at what the other drivers do.
Quoted 3 lines
It will not print warning by default. I don't have Gen5 board, but I tested with Stratix 10 by removing reset from USB DT node. We will not see the warning.
Paging Simon, he's been doing a lot of good work on Gen5 recently. You should CC him on changes too :)
Quoted 43 lines
Quoted 28 lines
Quoted 28 lines
drivers/usb/host/dwc2.c +18
-0+return ret; + } + + ret =reset_deassert_bulk (&priv->resets); +if (ret) { +reset_release_bulk (&priv->resets); +dev_err (dev,"Failed to reset: %d\n" , ret); +return ret; + } + +return 0 ; +} +static int dwc2_init_common (struct udevice *dev,struct dwc2_priv *priv) {struct dwc2_core_regs *regs = priv->regs;uint32_t snpsid;int i, j; +int ret; + + ret =dwc2_reset (dev); +if (ret) +return ret; snpsid =readl (®s->gsnpsid); dev_info(dev, "Core Release: %x.%03x\n",@@ -1303,6 +1332,8 @@ static int dwc2_usb_remove(struct udevice *dev)Quoted 5 lines
drivers/usb/host/dwc2.c static int dwc2_usb_remove(struct udevice *dev) · line 1335
Quoted 3 lines
drivers/usb/host/dwc2.c +1
-0dwc2_uninit_common (priv->regs); +reset_release_bulk (&priv->resets);Dont you need to assert the resets too ?
reset_release_bulkwill assert the reset if it is requested before.Quoted 6 lines
drivers/usb/host/dwc2.c static int dwc2_usb_remove(struct udevice *dev) · line 1339
Quoted 5 lines
drivers/usb/host/dwc2.c +0
-0return 0 ; }Regards
Ley Foon
Signature · 2 lines
Best regards, Marek Vasut
PATCH v2 1/1 usb: dwc2: Add reset ctrl to driver
Quoted 56 lines · Marek Vasut
Quoted 55 lines · Ley Foon Tan
Quoted 53 lines · Marek Vasut
Quoted 39 lines · Ley Foon Tan
Add code to reset all reset signals as in usb DT node. A reset property is an optional feature, so only print out a warning and do not fail if a reset property is not present.
If a reset property is discovered, then use it to deassert, thus bringing the IP out of reset.
Signed-off-by Ley Foon Tan <[email protected]>---
v2:
- Assert reset when .remove.--- drivers/usb/host/dwc2.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)drivers/usb/host/dwc2.c +3
-0@@ -15,6 +15,7 @@#include <wait_bit.h> #include <asm/io.h> #include <power/regulator.h> +#include <reset.h> #include "dwc2.h" @@ -49,6 +50,8 @@ struct dwc2_priv {*/ bool hnp_srp_disable;bool oc_disable; + +struct reset_ctl_bulk resets; };#ifndef CONFIG_DM_USB @@ -1124,11 +1127,37 @@ int _submit_int_msg(struct dwc2_priv *priv, struct usb_device *dev, }drivers/usb/host/dwc2.c int _submit_int_msg(struct dwc2_priv *priv, struct usb_device *dev, · line 1137
Quoted 10 lines
drivers/usb/host/dwc2.c +8
-0} +static int dwc2_reset (struct udevice *dev) +{ +int ret; +struct dwc2_priv *priv =dev_get_priv (dev); + + ret =reset_get_bulk (dev, &priv->resets); +if (ret) { +dev_warn (dev,"Can't get reset: %d\n" , ret);So this now generates a ton of warnings on Gen5 , right ? Did you test it on any Gen5 board recently ?
Quoted 5 lines
Quoted 2 lines
Will change to "return 0" if can't find reset in dts, so it will not fail the probe.
But that's a valid error. Maybe some ifdef
CONFIG_RESETwould be more appropriate ? Look at what the other drivers do.
Platforms that doesn't support reset framework shouldn't treat it as error. Other drivers don't have CONFIG_RESET too.
Quoted 50 lines
Quoted 4 lines
It will not print warning by default. I don't have Gen5 board, but I tested with Stratix 10 by removing reset from USB DT node. We will not see the warning.
Paging Simon, he's been doing a lot of good work on Gen5 recently. You should CC him on changes too :)
Quoted 42 lines
Quoted 28 lines
Quoted 28 lines
drivers/usb/host/dwc2.c +18
-0+return ret; + } + + ret =reset_deassert_bulk (&priv->resets); +if (ret) { +reset_release_bulk (&priv->resets); +dev_err (dev,"Failed to reset: %d\n" , ret); +return ret; + } + +return 0 ; +} +static int dwc2_init_common (struct udevice *dev,struct dwc2_priv *priv) {struct dwc2_core_regs *regs = priv->regs;uint32_t snpsid;int i, j; +int ret; + + ret =dwc2_reset (dev); +if (ret) +return ret; snpsid =readl (®s->gsnpsid); dev_info(dev, "Core Release: %x.%03x\n",@@ -1303,6 +1332,8 @@ static int dwc2_usb_remove(struct udevice *dev)Quoted 5 lines
drivers/usb/host/dwc2.c static int dwc2_usb_remove(struct udevice *dev) · line 1335
Quoted 3 lines
drivers/usb/host/dwc2.c +1
-0dwc2_uninit_common (priv->regs); +reset_release_bulk (&priv->resets);Dont you need to assert the resets too ?
reset_release_bulkwill assert the reset if it is requested before.Quoted 6 lines
drivers/usb/host/dwc2.c static int dwc2_usb_remove(struct udevice *dev) · line 1339
Quoted 5 lines
drivers/usb/host/dwc2.c +0
-0return 0 ; }Regards
Ley Foon
Regards
Ley Foon
PATCH v2 1/1 usb: dwc2: Add reset ctrl to driver
Quoted 57 lines · Ley Foon Tan
Quoted 56 lines · Marek Vasut
Quoted 55 lines · Ley Foon Tan
Quoted 53 lines · Marek Vasut
Quoted 39 lines · Ley Foon Tan
Add code to reset all reset signals as in usb DT node. A reset property is an optional feature, so only print out a warning and do not fail if a reset property is not present.
If a reset property is discovered, then use it to deassert, thus bringing the IP out of reset.
Signed-off-by Ley Foon Tan <[email protected]>---
v2:
- Assert reset when .remove.--- drivers/usb/host/dwc2.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)drivers/usb/host/dwc2.c +3
-0@@ -15,6 +15,7 @@#include <wait_bit.h> #include <asm/io.h> #include <power/regulator.h> +#include <reset.h> #include "dwc2.h" @@ -49,6 +50,8 @@ struct dwc2_priv {*/ bool hnp_srp_disable;bool oc_disable; + +struct reset_ctl_bulk resets; };#ifndef CONFIG_DM_USB @@ -1124,11 +1127,37 @@ int _submit_int_msg(struct dwc2_priv *priv, struct usb_device *dev, }drivers/usb/host/dwc2.c int _submit_int_msg(struct dwc2_priv *priv, struct usb_device *dev, · line 1137
Quoted 10 lines
drivers/usb/host/dwc2.c +8
-0} +static int dwc2_reset (struct udevice *dev) +{ +int ret; +struct dwc2_priv *priv =dev_get_priv (dev); + + ret =reset_get_bulk (dev, &priv->resets); +if (ret) { +dev_warn (dev,"Can't get reset: %d\n" , ret);So this now generates a ton of warnings on Gen5 , right ? Did you test it on any Gen5 board recently ?
Quoted 7 lines
Quoted 5 lines
Quoted 2 lines
Will change to "return 0" if can't find reset in dts, so it will not fail the probe.
But that's a valid error. Maybe some ifdef
CONFIG_RESETwould be more appropriate ? Look at what the other drivers do.Platforms that doesn't support reset framework shouldn't treat it as error. Other drivers don't have
CONFIG_RESETtoo.
What about platforms that do have reset and fail requesting it ? The error would be ignored on those ?
Signature · 2 lines
Best regards, Marek Vasut