2023-10-13 12:59:26

by Mehta, Piyush

[permalink] [raw]
Subject: [PATCH V2] usb: dwc3: xilinx: add reset-controller support

Add a reset-controller for supporting Xilinx versal platforms. To reset
the USB controller, get the reset ID from device-tree and using ID trigger
the reset, with the assert and deassert reset controller APIs for USB
controller initialization.

Signed-off-by: Piyush Mehta <[email protected]>
---
Changes in V2:
- Removed unnecessary delay between assert and deassert.
- Updated commit message.

Link: https://lore.kernel.org/all/[email protected]/
---
drivers/usb/dwc3/dwc3-xilinx.c | 14 +++++++-------
1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/drivers/usb/dwc3/dwc3-xilinx.c b/drivers/usb/dwc3/dwc3-xilinx.c
index 19307d24f3a0..5b7e92f476de 100644
--- a/drivers/usb/dwc3/dwc3-xilinx.c
+++ b/drivers/usb/dwc3/dwc3-xilinx.c
@@ -32,9 +32,6 @@
#define XLNX_USB_TRAFFIC_ROUTE_CONFIG 0x005C
#define XLNX_USB_TRAFFIC_ROUTE_FPD 0x1

-/* Versal USB Reset ID */
-#define VERSAL_USB_RESET_ID 0xC104036
-
#define XLNX_USB_FPD_PIPE_CLK 0x7c
#define PIPE_CLK_DESELECT 1
#define PIPE_CLK_SELECT 0
@@ -72,20 +69,23 @@ static void dwc3_xlnx_mask_phy_rst(struct dwc3_xlnx *priv_data, bool mask)
static int dwc3_xlnx_init_versal(struct dwc3_xlnx *priv_data)
{
struct device *dev = priv_data->dev;
+ struct reset_control *crst;
int ret;

+ crst = devm_reset_control_get_exclusive(dev, NULL);
+ if (IS_ERR(crst))
+ return dev_err_probe(dev, PTR_ERR(crst), "failed to get reset signal\n");
+
dwc3_xlnx_mask_phy_rst(priv_data, false);

/* Assert and De-assert reset */
- ret = zynqmp_pm_reset_assert(VERSAL_USB_RESET_ID,
- PM_RESET_ACTION_ASSERT);
+ ret = reset_control_assert(crst);
if (ret < 0) {
dev_err_probe(dev, ret, "failed to assert Reset\n");
return ret;
}

- ret = zynqmp_pm_reset_assert(VERSAL_USB_RESET_ID,
- PM_RESET_ACTION_RELEASE);
+ ret = reset_control_deassert(crst);
if (ret < 0) {
dev_err_probe(dev, ret, "failed to De-assert Reset\n");
return ret;
--
2.17.1


2023-10-20 22:57:30

by Thinh Nguyen

[permalink] [raw]
Subject: Re: [PATCH V2] usb: dwc3: xilinx: add reset-controller support

On Fri, Oct 13, 2023, Piyush Mehta wrote:
> Add a reset-controller for supporting Xilinx versal platforms. To reset
> the USB controller, get the reset ID from device-tree and using ID trigger
> the reset, with the assert and deassert reset controller APIs for USB
> controller initialization.
>
> Signed-off-by: Piyush Mehta <[email protected]>
> ---
> Changes in V2:
> - Removed unnecessary delay between assert and deassert.
> - Updated commit message.
>
> Link: https://urldefense.com/v3/__https://lore.kernel.org/all/[email protected]/__;!!A4F2R9G_pg!bfb-RqDhjA0qIQNJAgzN9gEJwRreQtrSyytdCt-ysljuyyvoMnLB3onr7h2qLi3R0GQfn0SuAoW_I15iQSsRjvjV$
> ---
> drivers/usb/dwc3/dwc3-xilinx.c | 14 +++++++-------
> 1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/usb/dwc3/dwc3-xilinx.c b/drivers/usb/dwc3/dwc3-xilinx.c
> index 19307d24f3a0..5b7e92f476de 100644
> --- a/drivers/usb/dwc3/dwc3-xilinx.c
> +++ b/drivers/usb/dwc3/dwc3-xilinx.c
> @@ -32,9 +32,6 @@
> #define XLNX_USB_TRAFFIC_ROUTE_CONFIG 0x005C
> #define XLNX_USB_TRAFFIC_ROUTE_FPD 0x1
>
> -/* Versal USB Reset ID */
> -#define VERSAL_USB_RESET_ID 0xC104036
> -
> #define XLNX_USB_FPD_PIPE_CLK 0x7c
> #define PIPE_CLK_DESELECT 1
> #define PIPE_CLK_SELECT 0
> @@ -72,20 +69,23 @@ static void dwc3_xlnx_mask_phy_rst(struct dwc3_xlnx *priv_data, bool mask)
> static int dwc3_xlnx_init_versal(struct dwc3_xlnx *priv_data)
> {
> struct device *dev = priv_data->dev;
> + struct reset_control *crst;
> int ret;
>
> + crst = devm_reset_control_get_exclusive(dev, NULL);
> + if (IS_ERR(crst))
> + return dev_err_probe(dev, PTR_ERR(crst), "failed to get reset signal\n");
> +
> dwc3_xlnx_mask_phy_rst(priv_data, false);
>
> /* Assert and De-assert reset */
> - ret = zynqmp_pm_reset_assert(VERSAL_USB_RESET_ID,
> - PM_RESET_ACTION_ASSERT);
> + ret = reset_control_assert(crst);
> if (ret < 0) {
> dev_err_probe(dev, ret, "failed to assert Reset\n");
> return ret;
> }
>
> - ret = zynqmp_pm_reset_assert(VERSAL_USB_RESET_ID,
> - PM_RESET_ACTION_RELEASE);
> + ret = reset_control_deassert(crst);
> if (ret < 0) {
> dev_err_probe(dev, ret, "failed to De-assert Reset\n");
> return ret;
> --
> 2.17.1
>

Acked-by: Thinh Nguyen <[email protected]>

Thanks,
Thinh