Skip to contentSkip to conversation

usb/mtu3: power down device ip at setup

PATCH Superseded Hsin-Yi, Wang 3 participants 11 messages Nov 28, 2018 – Nov 29, 2018 1 message not in the archive

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 usb/mtu3: power down device ip at setup

Originally, when dr_mode is USB_DR_MODE_HOST, it didn't power down device ip, so host ip sleep will fail at ssusb_host_disable.

Power down device ip at ssusb_host_setup.

---
 drivers/usb/mtu3/mtu3_host.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/usb/mtu3/mtu3_host.c +8 -0
index c871b94f3e6f..d17cf43305db 100644
@@ -192,9 +192,17 @@ int ssusb_host_disable(struct ssusb_mtk *ssusb, bool suspend)
 static void ssusb_host_setup(struct ssusb_mtk *ssusb)
 {
 	struct otg_switch_mtk *otg_sx = &ssusb->otg_switch;
+	void __iomem *ibase = ssusb->ippc_base;
 
 	host_ports_num_get(ssusb);
 
+	/*
+	 * device ip is default power-on in fact
+	 * power down device ip, otherwise ip-sleep will fail
+	 */
+	if (ssusb->dr_mode == USB_DR_MODE_HOST)
+		mtu3_setbits(ibase, U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN);
+
 	/*
 	 * power on host and power on/enable all ports
 	 * if support OTG, gadget driver will switch port0 to device mode
Signature · 1 line
2.18.1
maintainer
#1 lore raw

Hi Hsin-Yi,

Quoted 15 lines · Wang

Originally, when dr_mode is USB_DR_MODE_HOST, it didn't power down device ip, so host ip sleep will fail at ssusb_host_disable.

Power down device ip at ssusb_host_setup.

---
 drivers/usb/mtu3/mtu3_host.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/usb/mtu3/mtu3_host.c +0 -0
index c871b94f3e6f..d17cf43305db 100644

drivers/usb/mtu3/mtu3_host.c int ssusb_host_disable(struct ssusb_mtk *ssusb, bool suspend) · line 200

Quoted 9 lines
drivers/usb/mtu3/mtu3_host.c +3 -0
@@ -192,9 +192,17 @@ int ssusb_host_disable(struct ssusb_mtk *ssusb, bool suspend)
 static void ssusb_host_setup(struct ssusb_mtk *ssusb)
 {
 	struct otg_switch_mtk *otg_sx = &ssusb->otg_switch;
+	void __iomem *ibase = ssusb->ippc_base;
 
 	host_ports_num_get(ssusb);
 
+	/*
+	 * device ip is default power-on in fact

The device ip is power-off by default, no need power down it here.

On which platform did you encounter the issue?

Quoted 10 lines
drivers/usb/mtu3/mtu3_host.c +5 -0
+	 * power down device ip, otherwise ip-sleep will fail
+	 */
+	if (ssusb->dr_mode == USB_DR_MODE_HOST)
+		mtu3_setbits(ibase, U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN);
+
 
 
 	/*
drivers/usb/mtu3/mtu3_host.c +0 -0
 	 * power on host and power on/enable all ports
 	 * if support OTG, gadget driver will switch port0 to device mode
#2 lore raw

Hi Chunfeng,
On mt8183, We found ip sleep failed!!! with powerd_dbus_suspend. Referenced from xhci, it power down device ip at xhci_mtk_ssusb_config(). Also if dr_mode is PERIPHERAL and OTG, they both power down device ip at ssusb_gadget_init().

Quoted 44 lines · Chunfeng Yun

Hi Hsin-Yi,

Quoted 15 lines · Wang

Originally, when dr_mode is USB_DR_MODE_HOST, it didn't power down device ip, so host ip sleep will fail at ssusb_host_disable.

Power down device ip at ssusb_host_setup.

---
 drivers/usb/mtu3/mtu3_host.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/usb/mtu3/mtu3_host.c +0 -0
index c871b94f3e6f..d17cf43305db 100644

drivers/usb/mtu3/mtu3_host.c int ssusb_host_disable(struct ssusb_mtk *ssusb, bool suspend) · line 200

Quoted 9 lines
drivers/usb/mtu3/mtu3_host.c +3 -0
@@ -192,9 +192,17 @@ int ssusb_host_disable(struct ssusb_mtk *ssusb, bool suspend)
 static void ssusb_host_setup(struct ssusb_mtk *ssusb)
 {
      struct otg_switch_mtk *otg_sx = &ssusb->otg_switch;
+     void __iomem *ibase = ssusb->ippc_base;
 
      host_ports_num_get(ssusb);
 
+     /*
+      * device ip is default power-on in fact

The device ip is power-off by default, no need power down it here.

On which platform did you encounter the issue?

Quoted 10 lines
drivers/usb/mtu3/mtu3_host.c +5 -0
+      * power down device ip, otherwise ip-sleep will fail
+      */
+     if (ssusb->dr_mode == USB_DR_MODE_HOST)
+             mtu3_setbits(ibase, U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN);
+
 
 
      /*

* power on host and power on/enable all ports
* if support OTG, gadget driver will switch port0 to device mode

maintainer
#4 lore raw
In reply to a message not in the archive
Quoted 2 lines · Hsin-Yi Wang

Hi Chunfeng,
On mt8183, We found ip sleep failed!!! with powerd_dbus_suspend.

Did you enable usb device mode in BROM or LK stage? e.g. download image by fastboot / flashtool

Quoted 2 lines

Referenced from xhci, it also power down device ip at
xhci_mtk_ssusb_config().

It may happen when user downloads images by usb device in LK/BROM stage, but not disable it before enter kernel stage.

Quoted 2 lines

Also if dr_mode is PERIPHERAL and OTG, they both power down device ip
at ssusb_gadget_init().

Yes, it tries to save power;

Quoted 37 lines

On Wed, Nov 28, 2018 at 2:22 PM Chunfeng Yun
<[email protected]> wrote:

        Hi Hsin-Yi,
        
        On Wed, 2018-11-28 at 14:04 +0800, Hsin-Yi, Wang wrote:
        > Originally, when dr_mode is USB_DR_MODE_HOST, it didn't
        power down device ip,
        > so host ip sleep will fail at ssusb_host_disable.
        > 
        > Power down device ip at ssusb_host_setup.
        > 
        > Signed-off-by: Hsin-Yi, Wang <[email protected]>
        > ---
        >  drivers/usb/mtu3/mtu3_host.c | 8 ++++++++
        >  1 file changed, 8 insertions(+)
        > 
        > diff --git a/drivers/usb/mtu3/mtu3_host.c
        b/drivers/usb/mtu3/mtu3_host.c
        > index c871b94f3e6f..d17cf43305db 100644
        > --- a/drivers/usb/mtu3/mtu3_host.c
        > +++ b/drivers/usb/mtu3/mtu3_host.c
        > @@ -192,9 +192,17 @@ int ssusb_host_disable(struct ssusb_mtk
        *ssusb, bool suspend)
        >  static void ssusb_host_setup(struct ssusb_mtk *ssusb)
        >  {
        >       struct otg_switch_mtk *otg_sx = &ssusb->otg_switch;
        > +     void __iomem *ibase = ssusb->ippc_base;
        >  
        >       host_ports_num_get(ssusb);
        >  
        > +     /*
        > +      * device ip is default power-on in fact
        The device ip is power-off by default, no need power down it
        here.
Quoted 8 lines
        On which platform did you encounter the issue?
        
        > +      * power down device ip, otherwise ip-sleep will fail
        > +      */
        > +     if (ssusb->dr_mode == USB_DR_MODE_HOST)
        > +             mtu3_setbits(ibase, U3D_SSUSB_IP_PW_CTRL2,
        SSUSB_IP_DEV_PDN);
        > +

Could you please put it in ssusb_ip_sw_reset(), after ip reset, in mtu3_plat.c, if it fix the issue?

Quoted 6 lines

> /*
> * power on host and power on/enable all ports
> * if support OTG, gadget driver will switch port0 to
device mode

#5 lore raw

PATCH v2 1/1 usb/mtu3: power down device ip at setup

In reply to Hsin-Yi, Wang

Originally, when dr_mode is USB_DR_MODE_HOST, it didn't power down device ip, so host ip sleep will fail at ssusb_host_disable.

Power down device ip at ssusb_host_setup.

---
 drivers/usb/mtu3/mtu3_plat.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/usb/mtu3/mtu3_plat.c +6 -0
index 46551f6d16fd..cdef66141e20 100644
@@ -200,6 +200,12 @@ static void ssusb_ip_sw_reset(struct ssusb_mtk *ssusb)
 	mtu3_setbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL0, SSUSB_IP_SW_RST);
 	udelay(1);
 	mtu3_clrbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL0, SSUSB_IP_SW_RST);
+
+	/*
+	 * device ip is default power-on in fact
+	 * power down device ip, otherwise ip-sleep will fail
+	 */
+	mtu3_setbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN);
 }
 
 /* ignore the error if the clock does not exist */
Signature · 1 line
2.18.1
maintainer
#6 lore raw

Hi Hsin-Yi,

Quoted 4 lines · Wang

Originally, when dr_mode is USB_DR_MODE_HOST, it didn't power down device ip, so host ip sleep will fail at ssusb_host_disable.

Power down device ip at ssusb_host_setup.

need modify it, not in ssusb_host_setup now

Quoted 12 lines
---
 drivers/usb/mtu3/mtu3_plat.c | 6 ++++++
 1 file changed, 6 insertions(+)
drivers/usb/mtu3/mtu3_plat.c +0 -0
index 46551f6d16fd..cdef66141e20 100644

drivers/usb/mtu3/mtu3_plat.c static void ssusb_ip_sw_reset(struct ssusb_mtk *ssusb) · line 205

Quoted 6 lines
drivers/usb/mtu3/mtu3_plat.c +3 -0
@@ -200,6 +200,12 @@ static void ssusb_ip_sw_reset(struct ssusb_mtk *ssusb)
 	mtu3_setbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL0, SSUSB_IP_SW_RST);
 	udelay(1);
 	mtu3_clrbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL0, SSUSB_IP_SW_RST);
+
+	/*
+	 * device ip is default power-on in fact

change as: device ip maybe poweron in LK/BROM stage before enter kernel stage;

drivers/usb/mtu3/mtu3_plat.c static void ssusb_ip_sw_reset(struct ssusb_mtk *ssusb) · line 206

Quoted 1 line
drivers/usb/mtu3/mtu3_plat.c +1 -0
+	 * power down device ip, otherwise ip-sleep will fail

power down device ip, otherwise ip-sleep will fail when works as host only mode

drivers/usb/mtu3/mtu3_plat.c static void ssusb_ip_sw_reset(struct ssusb_mtk *ssusb) · line 211

Quoted 5 lines
drivers/usb/mtu3/mtu3_plat.c +2 -0
+	 */
+	mtu3_setbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN);
 }
 
 /* ignore the error if the clock does not exist */

Thanks a lot

#7 lore raw

PATCH v3 1/1 usb/mtu3: power down device ip at setup

In reply to Hsin-Yi, Wang

Originally, when dr_mode is USB_DR_MODE_HOST, it didn't power down device ip, so host ip sleep will fail at ssusb_host_disable.

Power down device ip at ssusb_host_setup.

---
 drivers/usb/mtu3/mtu3_plat.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/usb/mtu3/mtu3_plat.c +7 -0
index 46551f6d16fd..792c420fd4ad 100644
@@ -200,6 +200,13 @@ static void ssusb_ip_sw_reset(struct ssusb_mtk *ssusb)
 	mtu3_setbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL0, SSUSB_IP_SW_RST);
 	udelay(1);
 	mtu3_clrbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL0, SSUSB_IP_SW_RST);
+
+	/*
+	 * device ip maybe poweron in LK/BROM stage before enter kernel stage;
+	 * power down device ip, otherwise ip-sleep will fail when works as host
+	 * only mode
+	 */
+	mtu3_setbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN);
 }
 
 /* ignore the error if the clock does not exist */
Signature · 1 line
2.18.1
#8 lore raw

FYI, the subject line should be [PATCH v3] (not just [V3])

Quoted 8 lines · Wang

Originally, when dr_mode is USB_DR_MODE_HOST, it didn't power down device ip, so host ip sleep will fail at ssusb_host_disable.

Power down device ip at ssusb_host_setup.

---

Next time, add a changelog here (e.g. changes from v1: - ...).

Quoted 8 lines
 drivers/usb/mtu3/mtu3_plat.c | 7 +++++++
 1 file changed, 7 insertions(+)
drivers/usb/mtu3/mtu3_plat.c +0 -0
index 46551f6d16fd..792c420fd4ad 100644

drivers/usb/mtu3/mtu3_plat.c static void ssusb_ip_sw_reset(struct ssusb_mtk *ssusb) · line 205

Quoted 6 lines
drivers/usb/mtu3/mtu3_plat.c +3 -0
@@ -200,6 +200,13 @@ static void ssusb_ip_sw_reset(struct ssusb_mtk *ssusb)
        mtu3_setbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL0, SSUSB_IP_SW_RST);
        udelay(1);
        mtu3_clrbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL0, SSUSB_IP_SW_RST);
+
+       /*
+        * device ip maybe poweron in LK/BROM stage before enter kernel stage;

I'd replace LK with a more generic "firmware" term. e.g. "device ip may be powered on in firmware/BROM stage before entering kernel stage;"

drivers/usb/mtu3/mtu3_plat.c static void ssusb_ip_sw_reset(struct ssusb_mtk *ssusb) · line 206

Quoted 1 line
drivers/usb/mtu3/mtu3_plat.c +1 -0
+        * power down device ip, otherwise ip-sleep will fail when works as host

s/works/working/

Quoted 9 lines
drivers/usb/mtu3/mtu3_plat.c +3 -1
+        * only mode
+        */
+       mtu3_setbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN);
 }
 
 /* ignore the error if the clock does not exist */
--

2.18.1

Thanks.

#9 lore raw

PATCH v4 1/1 usb/mtu3: power down device ip at setup

In reply to Hsin-Yi, Wang

Originally, when dr_mode is USB_DR_MODE_HOST, it didn't power down device ip, so host ip sleep will fail at ssusb_host_disable.

Power down device ip at ssusb_host_setup.

---
ChangeLog:
V3->V4:
*update comment

---
 drivers/usb/mtu3/mtu3_plat.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/usb/mtu3/mtu3_plat.c +8 -0
index 46551f6d16fd..e086630e41a9 100644
@@ -200,6 +200,14 @@ static void ssusb_ip_sw_reset(struct ssusb_mtk *ssusb)
 	mtu3_setbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL0, SSUSB_IP_SW_RST);
 	udelay(1);
 	mtu3_clrbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL0, SSUSB_IP_SW_RST);
+
+	/*
+	 * device ip may be powered on in firmware/BROM stage before entering
+	 * kernel stage;
+	 * power down device ip, otherwise ip-sleep will fail when working as
+	 * host only mode
+	 */
+	mtu3_setbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN);
 }
 
 /* ignore the error if the clock does not exist */
Signature · 1 line
2.18.1
maintainer Acked-by on v4 1/1
#10 lore raw

hi Hsin-Yi,

Quoted 23 lines · Wang

Originally, when dr_mode is USB_DR_MODE_HOST, it didn't power down device ip, so host ip sleep will fail at ssusb_host_disable.

Power down device ip at ssusb_host_setup.

---
ChangeLog:
V3->V4:
*update comment

---
 drivers/usb/mtu3/mtu3_plat.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/usb/mtu3/mtu3_plat.c +1 -0
index 46551f6d16fd..e086630e41a9 100644
@@ -200,6 +200,14 @@ static void ssusb_ip_sw_reset(struct ssusb_mtk *ssusb)
 	mtu3_setbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL0, SSUSB_IP_SW_RST);
 	udelay(1);
 	mtu3_clrbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL0, SSUSB_IP_SW_RST);
+

drivers/usb/mtu3/mtu3_plat.c static void ssusb_ip_sw_reset(struct ssusb_mtk *ssusb) · line 213

Quoted 10 lines
drivers/usb/mtu3/mtu3_plat.c +7 -0
+	/*
+	 * device ip may be powered on in firmware/BROM stage before entering
+	 * kernel stage;
+	 * power down device ip, otherwise ip-sleep will fail when working as
+	 * host only mode
+	 */
+	mtu3_setbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN);
 }
 
 /* ignore the error if the clock does not exist */

Thanks a lot

#11 lore raw

Thanks!

Quoted 44 lines · Chunfeng Yun

hi Hsin-Yi,

Quoted 23 lines · Wang

Originally, when dr_mode is USB_DR_MODE_HOST, it didn't power down device ip, so host ip sleep will fail at ssusb_host_disable.

Power down device ip at ssusb_host_setup.

---
ChangeLog:
V3->V4:
*update comment

---
 drivers/usb/mtu3/mtu3_plat.c | 8 ++++++++
 1 file changed, 8 insertions(+)
drivers/usb/mtu3/mtu3_plat.c +1 -0
index 46551f6d16fd..e086630e41a9 100644
@@ -200,6 +200,14 @@ static void ssusb_ip_sw_reset(struct ssusb_mtk *ssusb)
      mtu3_setbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL0, SSUSB_IP_SW_RST);
      udelay(1);
      mtu3_clrbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL0, SSUSB_IP_SW_RST);
+

drivers/usb/mtu3/mtu3_plat.c static void ssusb_ip_sw_reset(struct ssusb_mtk *ssusb) · line 213

Quoted 10 lines
drivers/usb/mtu3/mtu3_plat.c +7 -0
+     /*
+      * device ip may be powered on in firmware/BROM stage before entering
+      * kernel stage;
+      * power down device ip, otherwise ip-sleep will fail when working as
+      * host only mode
+      */
+     mtu3_setbits(ssusb->ippc_base, U3D_SSUSB_IP_PW_CTRL2, SSUSB_IP_DEV_PDN);
 }
 
 /* ignore the error if the clock does not exist */

Thanks a lot