Skip to content

Commit 38f41f5

Browse files
fix(dcd/dwc2): Fix reset procedure for versions >=4.20a
1 parent edf1882 commit 38f41f5

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/portable/synopsys/dwc2/dwc2_common.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* The MIT License (MIT)
33
*
4-
* Copyright (c) 2024 Ha Thach (tinyusb.org)
4+
* Copyright (c) 2024-2025 Ha Thach (tinyusb.org)
55
*
66
* Permission is hereby granted, free of charge, to any person obtaining a copy
77
* of this software and associated documentation files (the "Software"), to deal
@@ -45,11 +45,14 @@
4545
//
4646
//--------------------------------------------------------------------
4747
static void reset_core(dwc2_regs_t* dwc2) {
48+
// load gsnpsid (it is not readable after reset is asserted)
49+
uint32_t gsnpsid = dwc2->gsnpsid;
50+
4851
// reset core
4952
dwc2->grstctl |= GRSTCTL_CSRST;
5053

51-
if ((dwc2->gsnpsid & DWC2_CORE_REV_MASK) < (DWC2_CORE_REV_4_20a & DWC2_CORE_REV_MASK)) {
52-
// prior v42.0 CSRST is self-clearing
54+
if ((gsnpsid & DWC2_CORE_REV_MASK) < (DWC2_CORE_REV_4_20a & DWC2_CORE_REV_MASK)) {
55+
// prior v4.20a CSRST is self-clearing
5356
while (dwc2->grstctl & GRSTCTL_CSRST) {}
5457
} else {
5558
// From v4.20a CSRST bit is write only, CSRT_DONE (w1c) is introduced for checking.

0 commit comments

Comments
 (0)