Skip to content

Commit b89b7ed

Browse files
tmon-nordicfabiobaltieri
authored andcommitted
drivers: usb: udc_dwc2: Exit hibernation on disable
The PMU is not reset by core reset and therefore it is necessary to exit hibernation on DWC2 disable to prevent endless PMU interrupt loop when the driver is enabled again. Signed-off-by: Tomasz Moń <[email protected]>
1 parent f765026 commit b89b7ed

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

drivers/usb/udc/udc_dwc2.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1070,11 +1070,6 @@ static void dwc2_exit_hibernation(const struct device *dev)
10701070
sys_set_bits((mem_addr_t)&base->dctl, USB_DWC2_DCTL_PWRONPRGDONE);
10711071
k_msleep(1);
10721072
sys_write32(0xFFFFFFFFUL, (mem_addr_t)&base->gintsts);
1073-
1074-
dwc2_restore_device_registers(dev);
1075-
1076-
priv->hibernated = 0;
1077-
LOG_DBG("Hibernation exit complete");
10781073
}
10791074

10801075
static void cancel_hibernation_request(struct udc_dwc2_data *const priv)
@@ -1971,6 +1966,7 @@ static int udc_dwc2_enable(const struct device *dev)
19711966
static int udc_dwc2_disable(const struct device *dev)
19721967
{
19731968
const struct udc_dwc2_config *const config = dev->config;
1969+
struct udc_dwc2_data *const priv = udc_get_private(dev);
19741970
struct usb_dwc2_reg *const base = dwc2_get_base(dev);
19751971
mem_addr_t dctl_reg = (mem_addr_t)&base->dctl;
19761972
int err;
@@ -1990,6 +1986,12 @@ static int udc_dwc2_disable(const struct device *dev)
19901986
}
19911987

19921988
config->irq_disable_func(dev);
1989+
1990+
if (priv->hibernated) {
1991+
dwc2_exit_hibernation(dev);
1992+
priv->hibernated = 0;
1993+
}
1994+
19931995
sys_clear_bits((mem_addr_t)&base->gahbcfg, USB_DWC2_GAHBCFG_GLBINTRMASK);
19941996

19951997
err = dwc2_quirk_disable(dev);
@@ -2707,6 +2709,10 @@ static void dwc2_handle_hibernation_exit(const struct device *dev,
27072709
struct udc_dwc2_data *const priv = udc_get_private(dev);
27082710

27092711
dwc2_exit_hibernation(dev);
2712+
dwc2_restore_device_registers(dev);
2713+
2714+
priv->hibernated = 0;
2715+
LOG_DBG("Hibernation exit complete");
27102716

27112717
/* Let stack know we are no longer suspended */
27122718
udc_set_suspended(dev, false);

0 commit comments

Comments
 (0)