summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTomas Rezucha <[email protected]>2025-08-28 15:35:55 +0200
committerTomas Rezucha <[email protected]>2025-08-28 15:35:55 +0200
commit38f41f5fa28943086cd36653e0914fd59cb7ed03 (patch)
treef623729de28c6ade8fe4674a2eb25250b41e3b2d
parentedf188280a52d92fc167532ba9269a038d2fb8a7 (diff)
fix(dcd/dwc2): Fix reset procedure for versions >=4.20a
-rw-r--r--src/portable/synopsys/dwc2/dwc2_common.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/portable/synopsys/dwc2/dwc2_common.c b/src/portable/synopsys/dwc2/dwc2_common.c
index b001f343d..9b8333ad2 100644
--- a/src/portable/synopsys/dwc2/dwc2_common.c
+++ b/src/portable/synopsys/dwc2/dwc2_common.c
@@ -1,7 +1,7 @@
/*
* The MIT License (MIT)
*
- * Copyright (c) 2024 Ha Thach (tinyusb.org)
+ * Copyright (c) 2024-2025 Ha Thach (tinyusb.org)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
@@ -45,11 +45,14 @@
//
//--------------------------------------------------------------------
static void reset_core(dwc2_regs_t* dwc2) {
+ // load gsnpsid (it is not readable after reset is asserted)
+ uint32_t gsnpsid = dwc2->gsnpsid;
+
// reset core
dwc2->grstctl |= GRSTCTL_CSRST;
- if ((dwc2->gsnpsid & DWC2_CORE_REV_MASK) < (DWC2_CORE_REV_4_20a & DWC2_CORE_REV_MASK)) {
- // prior v42.0 CSRST is self-clearing
+ if ((gsnpsid & DWC2_CORE_REV_MASK) < (DWC2_CORE_REV_4_20a & DWC2_CORE_REV_MASK)) {
+ // prior v4.20a CSRST is self-clearing
while (dwc2->grstctl & GRSTCTL_CSRST) {}
} else {
// From v4.20a CSRST bit is write only, CSRT_DONE (w1c) is introduced for checking.