Skip to content

Commit 5095d04

Browse files
Ryceancurryvinodkoul
authored andcommitted
phy: usb: Turn off phy when port is in suspend
The COMMONONN bit turns off the PHY when the host controller puts it into suspend state. This can happen during the following... - Nothing is connected to the port - The host controller goes into low power mode whatever due to auto suspend or system suspend. With COMMONONN we also must unset U2_FREECLK_EXISTS since the UTMI clock is fed by the PHY. With these changes we see a power savings of ~12mW when port is in suspend. Reviewed-by: Florian Fainelli <florian.fainelli@broadcom.com> Signed-off-by: Justin Chen <justin.chen@broadcom.com> Link: https://lore.kernel.org/r/1686859578-45242-2-git-send-email-justin.chen@broadcom.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
1 parent c0c2fcb commit 5095d04

2 files changed

Lines changed: 21 additions & 2 deletions

File tree

drivers/phy/broadcom/phy-brcm-usb-init-synopsys.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,8 @@
5959
#define USB_CTLR_TP_DIAG1_wake_MASK BIT(1)
6060
#define USB_CTRL_CTLR_CSHCR 0x50
6161
#define USB_CTRL_CTLR_CSHCR_ctl_pme_en_MASK BIT(18)
62+
#define USB_CTRL_P0_U2PHY_CFG1 0x68
63+
#define USB_CTRL_P0_U2PHY_CFG1_COMMONONN_MASK BIT(10)
6264

6365
/* Register definitions for the USB_PHY block in 7211b0 */
6466
#define USB_PHY_PLL_CTL 0x00
@@ -90,6 +92,8 @@
9092
#define BDC_EC_AXIRDA_RTS_MASK GENMASK(31, 28)
9193
#define BDC_EC_AXIRDA_RTS_SHIFT 28
9294

95+
#define USB_XHCI_GBL_GUSB2PHYCFG 0x100
96+
#define USB_XHCI_GBL_GUSB2PHYCFG_U2_FREECLK_EXISTS_MASK BIT(30)
9397

9498
static void usb_mdio_write_7211b0(struct brcm_usb_init_params *params,
9599
uint8_t addr, uint16_t data)
@@ -140,13 +144,17 @@ static void xhci_soft_reset(struct brcm_usb_init_params *params,
140144
int on_off)
141145
{
142146
void __iomem *ctrl = params->regs[BRCM_REGS_CTRL];
147+
void __iomem *xhci_gbl = params->regs[BRCM_REGS_XHCI_GBL];
143148

144149
/* Assert reset */
145-
if (on_off)
150+
if (on_off) {
146151
USB_CTRL_UNSET(ctrl, USB_PM, XHC_SOFT_RESETB);
147152
/* De-assert reset */
148-
else
153+
} else {
149154
USB_CTRL_SET(ctrl, USB_PM, XHC_SOFT_RESETB);
155+
/* Required for COMMONONN to be set */
156+
USB_XHCI_GBL_UNSET(xhci_gbl, GUSB2PHYCFG, U2_FREECLK_EXISTS);
157+
}
150158
}
151159

152160
static void usb_init_ipp(struct brcm_usb_init_params *params)
@@ -320,6 +328,9 @@ static void usb_init_common_7216(struct brcm_usb_init_params *params)
320328
/* 1 millisecond - for USB clocks to settle down */
321329
usleep_range(1000, 2000);
322330

331+
/* Disable PHY when port is suspended */
332+
USB_CTRL_SET(ctrl, P0_U2PHY_CFG1, COMMONONN);
333+
323334
usb_wake_enable_7216(params, false);
324335
usb_init_common(params);
325336
}

drivers/phy/broadcom/phy-brcm-usb-init.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@ enum brcmusb_reg_sel {
3434
brcm_usb_ctrl_unset(USB_CTRL_REG(base, reg), \
3535
USB_CTRL_##reg##_##field##_MASK)
3636

37+
#define USB_XHCI_GBL_REG(base, reg) ((void __iomem *)base + USB_XHCI_GBL_##reg)
38+
#define USB_XHCI_GBL_SET(base, reg, field) \
39+
brcm_usb_ctrl_set(USB_XHCI_GBL_REG(base, reg), \
40+
USB_XHCI_GBL_##reg##_##field##_MASK)
41+
#define USB_XHCI_GBL_UNSET(base, reg, field) \
42+
brcm_usb_ctrl_unset(USB_XHCI_GBL_REG(base, reg), \
43+
USB_XHCI_GBL_##reg##_##field##_MASK)
44+
3745
struct brcm_usb_init_params;
3846

3947
struct brcm_usb_init_ops {

0 commit comments

Comments
 (0)