From c34ee93382ebe586427d7d07b3556c3085bc0de9 Mon Sep 17 00:00:00 2001 From: Zain Wang Date: Fri, 6 Sep 2019 11:16:01 +0800 Subject: [PATCH] phy: phy-rockchip-inno-usb2: add force IRQ wakeup control Some chips like rk3328 not support wakeup-config in dts, So we should set wakeup IRQ enable in driver if we need new wakeup source. Change-Id: I735eee54bb4943b8c85a9a477f1cf9d255fc4312 Signed-off-by: Zain Wang --- drivers/phy/rockchip/phy-rockchip-inno-usb2.c | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c index 68f175548764..6b9c644a6856 100644 --- a/drivers/phy/rockchip/phy-rockchip-inno-usb2.c +++ b/drivers/phy/rockchip/phy-rockchip-inno-usb2.c @@ -1895,6 +1895,11 @@ next_child: goto put_child; } + if (of_property_read_bool(np, "wakeup-source")) + device_init_wakeup(rphy->dev, true); + else + device_init_wakeup(rphy->dev, false); + return 0; put_child: @@ -2114,6 +2119,10 @@ static int rockchip_usb2phy_pm_suspend(struct device *dev) struct rockchip_usb2phy_port *rport; unsigned int index; int ret = 0; + bool wakeup_enable = false; + + if (device_may_wakeup(rphy->dev)) + wakeup_enable = true; for (index = 0; index < rphy->phy_cfg->num_ports; index++) { rport = &rphy->ports[index]; @@ -2135,6 +2144,10 @@ static int rockchip_usb2phy_pm_suspend(struct device *dev) } } + if (rport->port_id == USB2PHY_PORT_OTG && wakeup_enable && + rport->bvalid_irq > 0) + enable_irq_wake(rport->bvalid_irq); + /* activate the linestate to detect the next interrupt. */ mutex_lock(&rport->mutex); ret = rockchip_usb2phy_enable_line_irq(rphy, rport, true); @@ -2144,6 +2157,9 @@ static int rockchip_usb2phy_pm_suspend(struct device *dev) return ret; } + if (wakeup_enable && rport->ls_irq > 0) + enable_irq_wake(rport->ls_irq); + /* enter low power state */ rockchip_usb2phy_low_power_enable(rphy, rport, true); } @@ -2158,6 +2174,10 @@ static int rockchip_usb2phy_pm_resume(struct device *dev) unsigned int index; bool iddig; int ret = 0; + bool wakeup_enable = false; + + if (device_may_wakeup(rphy->dev)) + wakeup_enable = true; if (rphy->phy_cfg->phy_tuning) ret = rphy->phy_cfg->phy_tuning(rphy); @@ -2197,6 +2217,13 @@ static int rockchip_usb2phy_pm_resume(struct device *dev) } } + if (rport->port_id == USB2PHY_PORT_OTG && wakeup_enable && + rport->bvalid_irq > 0) + disable_irq_wake(rport->bvalid_irq); + + if (wakeup_enable && rport->ls_irq > 0) + disable_irq_wake(rport->ls_irq); + /* exit low power state */ rockchip_usb2phy_low_power_enable(rphy, rport, false); }