usb: dwc2: Fix the write to W1C fields in HPRT register
Fix the write to the HPRT register which treat W1C fields
as if they were mere RW. This leads to unintended clearing of such fields
This bug was found during the testing on Simics model. Referring to
specification DesignWare Cores USB 2.0 Hi-Speed On-The-Go (OTG)
Databook (3.30a)"5.3.4.8 Host Port Control and Status Register (HPRT)", the
HPRT.PrtPwr is cleared by this mistake. In the Linux driver (contrary to
U-Boot), HPRT is always read using dwc2_read_hprt0 helper function which
clears W1C bits. So after write back those bits are zeroes.
Signed-off-by: Teik Heng Chong <teik.heng.chong@intel.com>
diff --git a/drivers/usb/host/dwc2.h b/drivers/usb/host/dwc2.h
index a6f562f..6f022e3 100644
--- a/drivers/usb/host/dwc2.h
+++ b/drivers/usb/host/dwc2.h
@@ -543,6 +543,10 @@
#define DWC2_HPRT0_PRTSPD_LOW (2 << 17)
#define DWC2_HPRT0_PRTSPD_MASK (0x3 << 17)
#define DWC2_HPRT0_PRTSPD_OFFSET 17
+#define DWC2_HPRT0_W1C_MASK (DWC2_HPRT0_PRTCONNDET | \
+ DWC2_HPRT0_PRTENA | \
+ DWC2_HPRT0_PRTENCHNG | \
+ DWC2_HPRT0_PRTOVRCURRCHNG)
#define DWC2_HAINT_CH0 (1 << 0)
#define DWC2_HAINT_CH0_OFFSET 0
#define DWC2_HAINT_CH1 (1 << 1)