mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-04-04 21:42:31 -04:00
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>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
7b2328c5a0
commit
3975e68cf3
@@ -1127,6 +1127,8 @@ struct dwc2_hsotg {
|
||||
#define DWC2_FS_IOT_ID 0x55310000
|
||||
#define DWC2_HS_IOT_ID 0x55320000
|
||||
|
||||
#define DWC2_RESTORE_DCTL BIT(0)
|
||||
|
||||
#if IS_ENABLED(CONFIG_USB_DWC2_HOST) || IS_ENABLED(CONFIG_USB_DWC2_DUAL_ROLE)
|
||||
union dwc2_hcd_internal_flags {
|
||||
u32 d32;
|
||||
@@ -1420,7 +1422,7 @@ int dwc2_hsotg_set_test_mode(struct dwc2_hsotg *hsotg, int testmode);
|
||||
#define dwc2_is_device_connected(hsotg) (hsotg->connected)
|
||||
#define dwc2_is_device_enabled(hsotg) (hsotg->enabled)
|
||||
int dwc2_backup_device_registers(struct dwc2_hsotg *hsotg);
|
||||
int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg, int remote_wakeup);
|
||||
int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg, unsigned int flags);
|
||||
int dwc2_gadget_enter_hibernation(struct dwc2_hsotg *hsotg);
|
||||
int dwc2_gadget_exit_hibernation(struct dwc2_hsotg *hsotg,
|
||||
int rem_wakeup, int reset);
|
||||
@@ -1459,7 +1461,7 @@ static inline int dwc2_hsotg_set_test_mode(struct dwc2_hsotg *hsotg,
|
||||
static inline int dwc2_backup_device_registers(struct dwc2_hsotg *hsotg)
|
||||
{ return 0; }
|
||||
static inline int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg,
|
||||
int remote_wakeup)
|
||||
unsigned int flags)
|
||||
{ return 0; }
|
||||
static inline int dwc2_gadget_enter_hibernation(struct dwc2_hsotg *hsotg)
|
||||
{ return 0; }
|
||||
|
||||
@@ -5204,11 +5204,11 @@ int dwc2_backup_device_registers(struct dwc2_hsotg *hsotg)
|
||||
* if controller power were disabled.
|
||||
*
|
||||
* @hsotg: Programming view of the DWC_otg controller
|
||||
* @remote_wakeup: Indicates whether resume is initiated by Device or Host.
|
||||
* @flags: Defines which registers should be restored.
|
||||
*
|
||||
* Return: 0 if successful, negative error code otherwise
|
||||
*/
|
||||
int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg, int remote_wakeup)
|
||||
int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg, unsigned int flags)
|
||||
{
|
||||
struct dwc2_dregs_backup *dr;
|
||||
int i;
|
||||
@@ -5224,7 +5224,7 @@ int dwc2_restore_device_registers(struct dwc2_hsotg *hsotg, int remote_wakeup)
|
||||
}
|
||||
dr->valid = false;
|
||||
|
||||
if (!remote_wakeup)
|
||||
if (flags & DWC2_RESTORE_DCTL)
|
||||
dwc2_writel(hsotg, dr->dctl, DCTL);
|
||||
|
||||
dwc2_writel(hsotg, dr->daintmsk, DAINTMSK);
|
||||
@@ -5415,6 +5415,7 @@ int dwc2_gadget_exit_hibernation(struct dwc2_hsotg *hsotg,
|
||||
u32 gpwrdn;
|
||||
u32 dctl;
|
||||
int ret = 0;
|
||||
unsigned int flags = 0;
|
||||
struct dwc2_gregs_backup *gr;
|
||||
struct dwc2_dregs_backup *dr;
|
||||
|
||||
@@ -5477,6 +5478,7 @@ int dwc2_gadget_exit_hibernation(struct dwc2_hsotg *hsotg,
|
||||
dctl = dwc2_readl(hsotg, DCTL);
|
||||
dctl |= DCTL_PWRONPRGDONE;
|
||||
dwc2_writel(hsotg, dctl, DCTL);
|
||||
flags |= DWC2_RESTORE_DCTL;
|
||||
}
|
||||
/* Wait for interrupts which must be cleared */
|
||||
mdelay(2);
|
||||
@@ -5492,7 +5494,7 @@ int dwc2_gadget_exit_hibernation(struct dwc2_hsotg *hsotg,
|
||||
}
|
||||
|
||||
/* Restore device registers */
|
||||
ret = dwc2_restore_device_registers(hsotg, rem_wakeup);
|
||||
ret = dwc2_restore_device_registers(hsotg, flags);
|
||||
if (ret) {
|
||||
dev_err(hsotg->dev, "%s: failed to restore device registers\n",
|
||||
__func__);
|
||||
@@ -5620,7 +5622,7 @@ int dwc2_gadget_exit_partial_power_down(struct dwc2_hsotg *hsotg,
|
||||
/* Restore DCFG */
|
||||
dwc2_writel(hsotg, dr->dcfg, DCFG);
|
||||
|
||||
ret = dwc2_restore_device_registers(hsotg, 0);
|
||||
ret = dwc2_restore_device_registers(hsotg, DWC2_RESTORE_DCTL);
|
||||
if (ret) {
|
||||
dev_err(hsotg->dev, "%s: failed to restore device registers\n",
|
||||
__func__);
|
||||
|
||||
Reference in New Issue
Block a user