RE: [PATCH] drivers: usb: host: Fix the write to W1C fields in HPRT register

2023-02-06 Thread Chong, Teik Heng
-Original Message-
From: Marek Vasut  
Sent: Thursday, 2 February, 2023 11:16 PM
To: Chong, Teik Heng ; u-boot@lists.denx.de
Cc: Simon ; Chee, Tien Fong 
; Hea, Kok Kiang ; Lim, Elly 
Siew Chin ; Kho, Sin Hui ; 
Lokanathan, Raaj ; Maniyam, Dinesh 
; Ng, Boon Khai ; Yuslaimi, 
Alif Zakuan ; Zamri, Muhammad Hazim Izzat 
; Lim, Jit Loon ; 
Tang, Sieu Mun 
Subject: Re: [PATCH] drivers: usb: host: Fix the write to W1C fields in HPRT 
register

On 2/2/23 02:14, teik.heng.ch...@intel.com wrote:

The subject tags are 'usb: dwc2:' .

> diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c index 
> 23060fc369..9818f9be94 100644
> --- a/drivers/usb/host/dwc2.c
> +++ b/drivers/usb/host/dwc2.c
> @@ -315,9 +315,7 @@ static void dwc_otg_core_host_init(struct udevice 
> *dev,
>   
>   /* Turn on the vbus power. */
>   if (readl(®s->gintsts) & DWC2_GINTSTS_CURMODE_HOST) {
> - hprt0 = readl(®s->hprt0);
> - hprt0 &= ~(DWC2_HPRT0_PRTENA | DWC2_HPRT0_PRTCONNDET);
> - hprt0 &= ~(DWC2_HPRT0_PRTENCHNG | DWC2_HPRT0_PRTOVRCURRCHNG);
> + hprt0 = readl(®s->hprt0) & ~DWC2_HPRT0_W1C_MASK;
>   if (!(hprt0 & DWC2_HPRT0_PRTPWR)) {
>   hprt0 |= DWC2_HPRT0_PRTPWR;
>   writel(hprt0, ®s->hprt0);
> @@ -748,7 +746,7 @@ static int dwc_otg_submit_rh_msg_out(struct dwc2_priv 
> *priv,
>   case (USB_REQ_CLEAR_FEATURE << 8) | USB_RECIP_OTHER | USB_TYPE_CLASS:
>   switch (wValue) {
>   case USB_PORT_FEAT_C_CONNECTION:
> - setbits_le32(®s->hprt0, DWC2_HPRT0_PRTCONNDET);
> + clrsetbits_le32(®s->hprt0, DWC2_HPRT0_W1C_MASK, 
> +DWC2_HPRT0_PRTCONNDET);
>   break;
>   }
>   break;
> @@ -759,21 +757,13 @@ static int dwc_otg_submit_rh_msg_out(struct dwc2_priv 
> *priv,
>   break;
>   
>   case USB_PORT_FEAT_RESET:
> - clrsetbits_le32(®s->hprt0, DWC2_HPRT0_PRTENA |
> - DWC2_HPRT0_PRTCONNDET |
> - DWC2_HPRT0_PRTENCHNG |
> - DWC2_HPRT0_PRTOVRCURRCHNG,
> - DWC2_HPRT0_PRTRST);
> + clrsetbits_le32(®s->hprt0, DWC2_HPRT0_W1C_MASK, 
> +DWC2_HPRT0_PRTRST);

The code above used to be clearing the W1C (write 1 to clear) bits , while the 
changed code is no longer clearing those bits. Is that correct ?

yes

[...]


Re: [PATCH] drivers: usb: host: Fix the write to W1C fields in HPRT register

2023-02-02 Thread Marek Vasut

On 2/2/23 02:14, teik.heng.ch...@intel.com wrote:

The subject tags are 'usb: dwc2:' .


diff --git a/drivers/usb/host/dwc2.c b/drivers/usb/host/dwc2.c
index 23060fc369..9818f9be94 100644
--- a/drivers/usb/host/dwc2.c
+++ b/drivers/usb/host/dwc2.c
@@ -315,9 +315,7 @@ static void dwc_otg_core_host_init(struct udevice *dev,
  
  	/* Turn on the vbus power. */

if (readl(®s->gintsts) & DWC2_GINTSTS_CURMODE_HOST) {
-   hprt0 = readl(®s->hprt0);
-   hprt0 &= ~(DWC2_HPRT0_PRTENA | DWC2_HPRT0_PRTCONNDET);
-   hprt0 &= ~(DWC2_HPRT0_PRTENCHNG | DWC2_HPRT0_PRTOVRCURRCHNG);
+   hprt0 = readl(®s->hprt0) & ~DWC2_HPRT0_W1C_MASK;
if (!(hprt0 & DWC2_HPRT0_PRTPWR)) {
hprt0 |= DWC2_HPRT0_PRTPWR;
writel(hprt0, ®s->hprt0);
@@ -748,7 +746,7 @@ static int dwc_otg_submit_rh_msg_out(struct dwc2_priv *priv,
case (USB_REQ_CLEAR_FEATURE << 8) | USB_RECIP_OTHER | USB_TYPE_CLASS:
switch (wValue) {
case USB_PORT_FEAT_C_CONNECTION:
-   setbits_le32(®s->hprt0, DWC2_HPRT0_PRTCONNDET);
+   clrsetbits_le32(®s->hprt0, DWC2_HPRT0_W1C_MASK, 
DWC2_HPRT0_PRTCONNDET);
break;
}
break;
@@ -759,21 +757,13 @@ static int dwc_otg_submit_rh_msg_out(struct dwc2_priv 
*priv,
break;
  
  		case USB_PORT_FEAT_RESET:

-   clrsetbits_le32(®s->hprt0, DWC2_HPRT0_PRTENA |
-   DWC2_HPRT0_PRTCONNDET |
-   DWC2_HPRT0_PRTENCHNG |
-   DWC2_HPRT0_PRTOVRCURRCHNG,
-   DWC2_HPRT0_PRTRST);
+   clrsetbits_le32(®s->hprt0, DWC2_HPRT0_W1C_MASK, 
DWC2_HPRT0_PRTRST);


The code above used to be clearing the W1C (write 1 to clear) bits , 
while the changed code is no longer clearing those bits. Is that correct ?


[...]