
23 Apr
2024
23 Apr
'24
1:11 a.m.
On 4/22/24 7:31 AM, Kongyang Liu wrote:
[...]
@@ -167,9 +168,20 @@ static void dwc_otg_core_reset(struct udevice *dev, dev_info(dev, "%s: Timeout!\n", __func__);
/* Core Soft Reset */
snpsid = readl(®s->gsnpsid); writel(DWC2_GRSTCTL_CSFTRST, ®s->grstctl);
ret = wait_for_bit_le32(®s->grstctl, DWC2_GRSTCTL_CSFTRST,
false, 1000, false);
if ((snpsid & DWC2_SNPSID_VER_MASK) < (DWC2_SNPSID_DEVID_VER_420a & DWC2_SNPSID_VER_MASK)) {
ret = wait_for_bit_le32(®s->grstctl, DWC2_GRSTCTL_CSFTRST,
false, 1000, false);
} else {
ret = wait_for_bit_le32(®s->grstctl, DWC2_GRSTCTL_GSFTRST_DONE,
true, 1000, false);
greset = readl(®s->grstctl);
greset &= ~DWC2_GRSTCTL_CSFTRST;
greset |= DWC2_GRSTCTL_GSFTRST_DONE;
writel(greset, ®s->grstctl);
Same comments as above.
Maybe this should be pulled into dedicated function to avoid duplication?
For U-Boot, the dwc2 USB driver is split into two modules: host and gadget. Each has its own register definitions and definitions for register bits, which makes it difficult to extract a single function. Moreover, deciding where to place this function is also an issue.
There is drivers/usb/common/ for such code. The register macros can probably be unified into a single header too.