Skip to content

Commit 8482ad1

Browse files
tore-espressifroma-jam
authored andcommitted
fix(dcd/dwc2): Fix reset procedure for versions >=4.20a
1 parent 0739483 commit 8482ad1

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
@@ -44,11 +44,14 @@
4444
//
4545
//--------------------------------------------------------------------
4646
static void reset_core(dwc2_regs_t* dwc2) {
47+
// load gsnpsid (it is not readable after reset is asserted)
48+
uint32_t gsnpsid = dwc2->gsnpsid;
49+
4750
// reset core
4851
dwc2->grstctl |= GRSTCTL_CSRST;
4952

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

0 commit comments

Comments
 (0)