From b5bb4868b8a0eb8a6f5f37015d5837b43d887ad6 Mon Sep 17 00:00:00 2001 From: Frank Wang Date: Tue, 15 Aug 2017 17:31:11 +0800 Subject: [PATCH] phy: rockchip-inno-usb2: put phy-port into suspend during probe Let us put phy-port into suspend mode at initialization time for saving power consumption, and usb controller will resume it during probe time if needed. Change-Id: Id3a66af8ff17612d54fbc80db087bf67eaee7726 Signed-off-by: Frank Wang --- drivers/phy/phy-rockchip-inno-usb2.c | 34 +++++++++++++++++++--------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/drivers/phy/phy-rockchip-inno-usb2.c b/drivers/phy/phy-rockchip-inno-usb2.c index fbcf8f3b2081..2a755a49439c 100644 --- a/drivers/phy/phy-rockchip-inno-usb2.c +++ b/drivers/phy/phy-rockchip-inno-usb2.c @@ -1294,7 +1294,6 @@ static int rockchip_usb2phy_host_port_init(struct rockchip_usb2phy *rphy, rport->port_id = USB2PHY_PORT_HOST; rport->port_cfg = &rphy->phy_cfg->port_cfgs[USB2PHY_PORT_HOST]; - rport->suspended = true; mutex_init(&rport->mutex); INIT_DELAYED_WORK(&rport->sm_work, rockchip_usb2phy_sm_work); @@ -1314,6 +1313,16 @@ static int rockchip_usb2phy_host_port_init(struct rockchip_usb2phy *rphy, return ret; } + /* + * Let us put phy-port into suspend mode here for saving power + * consumption, and usb controller will resume it during probe + * time if needed. + */ + ret = property_enable(rphy, &rport->port_cfg->phy_sus, true); + if (ret) + return ret; + rport->suspended = true; + return 0; } @@ -1339,14 +1348,6 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, rport->port_id = USB2PHY_PORT_OTG; rport->port_cfg = &rphy->phy_cfg->port_cfgs[USB2PHY_PORT_OTG]; rport->state = OTG_STATE_UNDEFINED; - - /* - * set suspended flag to true, but actually don't - * put phy in suspend mode, it aims to enable usb - * phy and clock in power_on() called by usb controller - * driver during probe. - */ - rport->suspended = true; rport->vbus_attached = false; rport->perip_connected = false; @@ -1385,13 +1386,13 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, extcon_set_state(rphy->edev, EXTCON_USB_VBUS_EN, true); gpiod_set_value_cansleep(rport->vbus_drv_gpio, 1); } - return 0; + goto out; } rport->vbus_always_on = of_property_read_bool(child_np, "rockchip,vbus-always-on"); if (rport->vbus_always_on) - return 0; + goto out; wake_lock_init(&rport->wakelock, WAKE_LOCK_SUSPEND, "rockchip_otg"); INIT_DELAYED_WORK(&rport->chg_work, rockchip_chg_detect_work); @@ -1455,6 +1456,17 @@ static int rockchip_usb2phy_otg_port_init(struct rockchip_usb2phy *rphy, } } +out: + /* + * Let us put phy-port into suspend mode here for saving power + * consumption, and usb controller will resume it during probe + * time if needed. + */ + ret = property_enable(rphy, &rport->port_cfg->phy_sus, true); + if (ret) + return ret; + rport->suspended = true; + return 0; }