mirror of
https://github.com/torvalds/linux.git
synced 2026-06-07 22:14:04 +02:00
phy: rockchip-inno-usb2: add wake_lock function
Prevent the system from entering suspend when usb cable is connecetd. Change-Id: I50c4a09d9142ebeb2d4e2a0ab2df59f98ef99737 Signed-off-by: Frank Wang <frank.wang@rock-chips.com>
This commit is contained in:
parent
153538b270
commit
9f2fb93354
|
|
@ -36,6 +36,7 @@
|
|||
#include <linux/mfd/syscon.h>
|
||||
#include <linux/usb/of.h>
|
||||
#include <linux/usb/otg.h>
|
||||
#include <linux/wakelock.h>
|
||||
|
||||
#define BIT_WRITEABLE_SHIFT 16
|
||||
#define SCHEDULE_DELAY (60 * HZ)
|
||||
|
|
@ -255,6 +256,7 @@ struct rockchip_usb2phy_port {
|
|||
struct regulator *vbus;
|
||||
const struct rockchip_usb2phy_port_cfg *port_cfg;
|
||||
struct notifier_block event_nb;
|
||||
struct wake_lock wakelock;
|
||||
enum usb_otg_state state;
|
||||
enum usb_dr_mode mode;
|
||||
};
|
||||
|
|
@ -1022,6 +1024,7 @@ static void rockchip_usb2phy_otg_sm_work(struct work_struct *work)
|
|||
switch (rphy->chg_type) {
|
||||
case POWER_SUPPLY_TYPE_USB:
|
||||
dev_dbg(&rport->phy->dev, "sdp cable is connected\n");
|
||||
wake_lock(&rport->wakelock);
|
||||
cable = EXTCON_CHG_USB_SDP;
|
||||
mutex_unlock(&rport->mutex);
|
||||
rockchip_usb2phy_power_on(rport->phy);
|
||||
|
|
@ -1037,6 +1040,7 @@ static void rockchip_usb2phy_otg_sm_work(struct work_struct *work)
|
|||
break;
|
||||
case POWER_SUPPLY_TYPE_USB_CDP:
|
||||
dev_dbg(&rport->phy->dev, "cdp cable is connected\n");
|
||||
wake_lock(&rport->wakelock);
|
||||
cable = EXTCON_CHG_USB_CDP;
|
||||
mutex_unlock(&rport->mutex);
|
||||
rockchip_usb2phy_power_on(rport->phy);
|
||||
|
|
@ -1072,6 +1076,7 @@ static void rockchip_usb2phy_otg_sm_work(struct work_struct *work)
|
|||
rphy->chg_type = POWER_SUPPLY_TYPE_UNKNOWN;
|
||||
rport->perip_connected = false;
|
||||
sch_work = false;
|
||||
wake_unlock(&rport->wakelock);
|
||||
} else if (!rport->vbus_attached) {
|
||||
dev_dbg(&rport->phy->dev, "usb disconnect\n");
|
||||
rport->state = OTG_STATE_B_IDLE;
|
||||
|
|
@ -1079,6 +1084,7 @@ static void rockchip_usb2phy_otg_sm_work(struct work_struct *work)
|
|||
rphy->chg_state = USB_CHG_STATE_UNDEFINED;
|
||||
rphy->chg_type = POWER_SUPPLY_TYPE_UNKNOWN;
|
||||
delay = OTG_SCHEDULE_DELAY;
|
||||
wake_unlock(&rport->wakelock);
|
||||
}
|
||||
break;
|
||||
case OTG_STATE_A_HOST:
|
||||
|
|
@ -1614,6 +1620,7 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy,
|
|||
if (rport->vbus_always_on)
|
||||
goto out;
|
||||
|
||||
wake_lock_init(&rport->wakelock, WAKE_LOCK_SUSPEND, "rockchip_otg");
|
||||
INIT_DELAYED_WORK(&rport->bypass_uart_work,
|
||||
rockchip_usb_bypass_uart_work);
|
||||
INIT_DELAYED_WORK(&rport->chg_work, rockchip_chg_detect_work);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user