summaryrefslogtreecommitdiff
path: root/drivers/phy/broadcom/phy-brcm-usb-init.c
diff options
context:
space:
mode:
authorAl Cooper <alcooperx@gmail.com>2020-01-03 13:18:02 -0500
committerKishon Vijay Abraham I <kishon@ti.com>2020-01-08 12:58:06 +0530
commitf1c0db40a3ade1f1a39e5794d728f2953d817322 (patch)
treebf7b48a51f2d1c5fce0f5294c65ae997609d99a4 /drivers/phy/broadcom/phy-brcm-usb-init.c
parent6597af4e4835ec0709638d48f73c11b5c624790f (diff)
phy: usb: Add "wake on" functionality
Add the ability to handle USB wake events from USB devices when in S2 mode. Typically there is some additional configuration needed to tell the USB device to generate the wake event when suspended but this varies with the different USB device classes. For example, on USB Ethernet dongles, ethtool should be used to enable the magic packet wake functionality in the dongle. NOTE: This requires that the "power/wakeup" sysfs entry for the USB device generating the wakeup be set to "enabled". This functionality requires a special hardware sideband path that will trigger the AON_PM_L2 interrupt needed to wake the system from S2 even though the USB host controllers are in IDDQ (low power state) and most USB related clocks are shut off. For the sideband signaling to work we need to leave the usbx_freerun clock running, but this clock consumes very little power by design. There's a bug in the XHCI wake hardware so only EHCI/OHCI wake is currently supported. Signed-off-by: Al Cooper <alcooperx@gmail.com> Reviewed-by: Florian Fainelli <f.fainelli@gmail.com> Signed-off-by: Kishon Vijay Abraham I <kishon@ti.com>
Diffstat (limited to 'drivers/phy/broadcom/phy-brcm-usb-init.c')
-rw-r--r--drivers/phy/broadcom/phy-brcm-usb-init.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/drivers/phy/broadcom/phy-brcm-usb-init.c b/drivers/phy/broadcom/phy-brcm-usb-init.c
index ac7f7995c11f..58882c10396a 100644
--- a/drivers/phy/broadcom/phy-brcm-usb-init.c
+++ b/drivers/phy/broadcom/phy-brcm-usb-init.c
@@ -58,6 +58,8 @@
#define USB_CTRL_USB_PM_SOFT_RESET_MASK 0x40000000 /* option */
#define USB_CTRL_USB_PM_USB20_HC_RESETB_MASK 0x30000000 /* option */
#define USB_CTRL_USB_PM_USB20_HC_RESETB_VAR_MASK 0x00300000 /* option */
+#define USB_CTRL_USB_PM_RMTWKUP_EN_MASK 0x00000001
+#define USB_CTRL_USB_PM_STATUS 0x38
#define USB_CTRL_USB30_CTL1 0x60
#define USB_CTRL_USB30_CTL1_PHY3_PLL_SEQ_START_MASK 0x00000010
#define USB_CTRL_USB30_CTL1_PHY3_RESETB_MASK 0x00010000
@@ -855,6 +857,10 @@ void brcm_usb_init_common(struct brcm_usb_init_params *params)
u32 reg;
void __iomem *ctrl = params->ctrl_regs;
+ /* Clear any pending wake conditions */
+ reg = brcmusb_readl(USB_CTRL_REG(ctrl, USB_PM_STATUS));
+ brcmusb_writel(reg, USB_CTRL_REG(ctrl, USB_PM_STATUS));
+
/* Take USB out of power down */
if (USB_CTRL_MASK_FAMILY(params, PLL_CTL, PLL_IDDQ_PWRDN)) {
USB_CTRL_UNSET_FAMILY(params, PLL_CTL, PLL_IDDQ_PWRDN);
@@ -1010,6 +1016,17 @@ void brcm_usb_uninit_xhci(struct brcm_usb_init_params *params)
USB_CTRL_SET(params->ctrl_regs, USB30_PCTL, PHY3_IDDQ_OVERRIDE);
}
+void brcm_usb_wake_enable(struct brcm_usb_init_params *params,
+ int enable)
+{
+ void __iomem *ctrl = params->ctrl_regs;
+
+ if (enable)
+ USB_CTRL_SET(ctrl, USB_PM, RMTWKUP_EN);
+ else
+ USB_CTRL_UNSET(ctrl, USB_PM, RMTWKUP_EN);
+}
+
void brcm_usb_set_family_map(struct brcm_usb_init_params *params)
{
int fam;