Skip to content

Commit 3975e68

Browse files
lategoodbyegregkh
authored andcommitted
usb: dwc2: gadget: Introduce register restore flags
dwc2_restore_device_registers() use a single boolean to decide about the register restoring behavior. So replace this with a flags parameter, which can be extended later. No functional change intended. Signed-off-by: Stefan Wahren <wahrenst@gmx.net> Link: https://lore.kernel.org/r/20250217134132.36786-2-wahrenst@gmx.net Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 7b2328c commit 3975e68

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

drivers/usb/dwc2/core.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,6 +1127,8 @@ struct dwc2_hsotg {
11271127
#define DWC2_FS_IOT_ID 0x55310000
11281128
#define DWC2_HS_IOT_ID 0x55320000
11291129

1130+
#define DWC2_RESTORE_DCTL BIT(0)
1131+
11301132
#if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
11311133
union dwc2_hcd_internal_flags {
11321134
u32 d32;
@@ -1420,7 +1422,7 @@ int dwc2_hsotg_set_test_mode(struct dwc2_hsotg *hsotg, int testmode);
14201422
#define dwc2_is_device_connected(hsotg) (hsotg->connected)
14211423
#define dwc2_is_device_enabled(hsotg) (hsotg->enabled)
14221424
int dwc2_backup_device_registers(struct dwc2_hsotg *hsotg);
1423-
int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg, int remote_wakeup);
1425+
int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg, unsigned int flags);
14241426
int dwc2_gadget_enter_hibernation(struct dwc2_hsotg *hsotg);
14251427
int dwc2_gadget_exit_hibernation(struct dwc2_hsotg *hsotg,
14261428
int rem_wakeup, int reset);
@@ -1459,7 +1461,7 @@ static inline int dwc2_hsotg_set_test_mode(struct dwc2_hsotg *hsotg,
14591461
static inline int dwc2_backup_device_registers(struct dwc2_hsotg *hsotg)
14601462
{ return 0; }
14611463
static inline int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg,
1462-
int remote_wakeup)
1464+
unsigned int flags)
14631465
{ return 0; }
14641466
static inline int dwc2_gadget_enter_hibernation(struct dwc2_hsotg *hsotg)
14651467
{ return 0; }

drivers/usb/dwc2/gadget.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5204,11 +5204,11 @@ int dwc2_backup_device_registers(struct dwc2_hsotg *hsotg)
52045204
* if controller power were disabled.
52055205
*
52065206
* @hsotg: Programming view of the DWC_otg controller
5207-
* @remote_wakeup: Indicates whether resume is initiated by Device or Host.
5207+
* @flags: Defines which registers should be restored.
52085208
*
52095209
* Return: 0 if successful, negative error code otherwise
52105210
*/
5211-
int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg, int remote_wakeup)
5211+
int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg, unsigned int flags)
52125212
{
52135213
struct dwc2_dregs_backup *dr;
52145214
int i;
@@ -5224,7 +5224,7 @@ int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg, int remote_wakeup)
52245224
}
52255225
dr->valid = false;
52265226

5227-
if (!remote_wakeup)
5227+
if (flags & DWC2_RESTORE_DCTL)
52285228
dwc2_writel(hsotg, dr->dctl, DCTL);
52295229

52305230
dwc2_writel(hsotg, dr->daintmsk, DAINTMSK);
@@ -5415,6 +5415,7 @@ int dwc2_gadget_exit_hibernation(struct dwc2_hsotg *hsotg,
54155415
u32 gpwrdn;
54165416
u32 dctl;
54175417
int ret = 0;
5418+
unsigned int flags = 0;
54185419
struct dwc2_gregs_backup *gr;
54195420
struct dwc2_dregs_backup *dr;
54205421

@@ -5477,6 +5478,7 @@ int dwc2_gadget_exit_hibernation(struct dwc2_hsotg *hsotg,
54775478
dctl = dwc2_readl(hsotg, DCTL);
54785479
dctl |= DCTL_PWRONPRGDONE;
54795480
dwc2_writel(hsotg, dctl, DCTL);
5481+
flags |= DWC2_RESTORE_DCTL;
54805482
}
54815483
/* Wait for interrupts which must be cleared */
54825484
mdelay(2);
@@ -5492,7 +5494,7 @@ int dwc2_gadget_exit_hibernation(struct dwc2_hsotg *hsotg,
54925494
}
54935495

54945496
/* Restore device registers */
5495-
ret = dwc2_restore_device_registers(hsotg, rem_wakeup);
5497+
ret = dwc2_restore_device_registers(hsotg, flags);
54965498
if (ret) {
54975499
dev_err(hsotg->dev, "%s: failed to restore device registers\n",
54985500
__func__);
@@ -5620,7 +5622,7 @@ int dwc2_gadget_exit_partial_power_down(struct dwc2_hsotg *hsotg,
56205622
/* Restore DCFG */
56215623
dwc2_writel(hsotg, dr->dcfg, DCFG);
56225624

5623-
ret = dwc2_restore_device_registers(hsotg, 0);
5625+
ret = dwc2_restore_device_registers(hsotg, DWC2_RESTORE_DCTL);
56245626
if (ret) {
56255627
dev_err(hsotg->dev, "%s: failed to restore device registers\n",
56265628
__func__);

0 commit comments

Comments
 (0)