All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC PATCH] usb: mtu3: fix random remote wakeup
@ 2019-11-14  2:33 ` Chunfeng Yun
  0 siblings, 0 replies; 3+ messages in thread
From: Chunfeng Yun @ 2019-11-14  2:33 UTC (permalink / raw)
  To: Tianping Fang
  Cc: Greg Kroah-Hartman, Matthias Brugger, Chunfeng Yun, linux-usb,
	devicetree, linux-kernel, linux-arm-kernel, linux-mediatek

Wakeup_signal will toggle status according to ssusb_ip_sleep signal
after debounce time, so need add a delay time and wait for wakeup_signal
toggle to complete, then enable the remote wakeup. Meanwhile reduce the
debounce time of wakeup_signal. These will avoid spurious wakeup event.

Signed-off-by: Tianping Fang <tianping.fang@mediatek.com>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
Note, depends on following patch not merged:

    [v3,3/7] usb: mtu3: support ip-sleep wakeup for MT8183
    https://patchwork.kernel.org/patch/11123151/
---
 drivers/usb/mtu3/mtu3_host.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/mtu3/mtu3_host.c b/drivers/usb/mtu3/mtu3_host.c
index 182c9439c15a..ca48ff751c8b 100644
--- a/drivers/usb/mtu3/mtu3_host.c
+++ b/drivers/usb/mtu3/mtu3_host.c
@@ -53,12 +53,12 @@ static void ssusb_wakeup_ip_sleep_set(struct ssusb_mtk *ssusb, bool enable)
 	case SSUSB_UWK_V0:
 		reg = ssusb->uwk_reg_base + PERI_WK_CTRL0;
 		msk = (u32)(WC0_IS_EN | WC0_IS_C(0xf) | WC0_IS_P);
-		val = enable ? (WC0_IS_EN | WC0_IS_C(0x8)) : 0;
+		val = enable ? (WC0_IS_EN | WC0_IS_C(0x3)) : 0;
 		break;
 	case SSUSB_UWK_V1:
 		reg = ssusb->uwk_reg_base + PERI_WK_CTRL1;
 		msk = WC1_IS_EN | WC1_IS_C(0xf) | WC1_IS_P;
-		val = enable ? (WC1_IS_EN | WC1_IS_C(0x8)) : 0;
+		val = enable ? (WC1_IS_EN | WC1_IS_C(0x3)) : 0;
 		break;
 	case SSUSB_UWK_V2:
 		reg = ssusb->uwk_reg_base + PERI_SSUSB_SPM_CTRL;
@@ -197,6 +197,8 @@ int ssusb_host_disable(struct ssusb_mtk *ssusb, bool suspend)
 			  (value & SSUSB_IP_SLEEP_STS), 100, 100000);
 	if (ret)
 		dev_err(ssusb->dev, "ip sleep failed!!!\n");
+	else  /* wait for wakeup_signal toggle done after enter ip-sleep */
+		usleep_range(245, 255);
 
 	return ret;
 }
-- 
2.23.0

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [RFC PATCH] usb: mtu3: fix random remote wakeup
@ 2019-11-14  2:33 ` Chunfeng Yun
  0 siblings, 0 replies; 3+ messages in thread
From: Chunfeng Yun @ 2019-11-14  2:33 UTC (permalink / raw)
  To: Tianping Fang
  Cc: devicetree, Greg Kroah-Hartman, linux-usb, linux-kernel,
	Chunfeng Yun, linux-mediatek, Matthias Brugger, linux-arm-kernel

Wakeup_signal will toggle status according to ssusb_ip_sleep signal
after debounce time, so need add a delay time and wait for wakeup_signal
toggle to complete, then enable the remote wakeup. Meanwhile reduce the
debounce time of wakeup_signal. These will avoid spurious wakeup event.

Signed-off-by: Tianping Fang <tianping.fang@mediatek.com>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
Note, depends on following patch not merged:

    [v3,3/7] usb: mtu3: support ip-sleep wakeup for MT8183
    https://patchwork.kernel.org/patch/11123151/
---
 drivers/usb/mtu3/mtu3_host.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/mtu3/mtu3_host.c b/drivers/usb/mtu3/mtu3_host.c
index 182c9439c15a..ca48ff751c8b 100644
--- a/drivers/usb/mtu3/mtu3_host.c
+++ b/drivers/usb/mtu3/mtu3_host.c
@@ -53,12 +53,12 @@ static void ssusb_wakeup_ip_sleep_set(struct ssusb_mtk *ssusb, bool enable)
 	case SSUSB_UWK_V0:
 		reg = ssusb->uwk_reg_base + PERI_WK_CTRL0;
 		msk = (u32)(WC0_IS_EN | WC0_IS_C(0xf) | WC0_IS_P);
-		val = enable ? (WC0_IS_EN | WC0_IS_C(0x8)) : 0;
+		val = enable ? (WC0_IS_EN | WC0_IS_C(0x3)) : 0;
 		break;
 	case SSUSB_UWK_V1:
 		reg = ssusb->uwk_reg_base + PERI_WK_CTRL1;
 		msk = WC1_IS_EN | WC1_IS_C(0xf) | WC1_IS_P;
-		val = enable ? (WC1_IS_EN | WC1_IS_C(0x8)) : 0;
+		val = enable ? (WC1_IS_EN | WC1_IS_C(0x3)) : 0;
 		break;
 	case SSUSB_UWK_V2:
 		reg = ssusb->uwk_reg_base + PERI_SSUSB_SPM_CTRL;
@@ -197,6 +197,8 @@ int ssusb_host_disable(struct ssusb_mtk *ssusb, bool suspend)
 			  (value & SSUSB_IP_SLEEP_STS), 100, 100000);
 	if (ret)
 		dev_err(ssusb->dev, "ip sleep failed!!!\n");
+	else  /* wait for wakeup_signal toggle done after enter ip-sleep */
+		usleep_range(245, 255);
 
 	return ret;
 }
-- 
2.23.0
_______________________________________________
Linux-mediatek mailing list
Linux-mediatek@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-mediatek

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [RFC PATCH] usb: mtu3: fix random remote wakeup
@ 2019-11-14  2:33 ` Chunfeng Yun
  0 siblings, 0 replies; 3+ messages in thread
From: Chunfeng Yun @ 2019-11-14  2:33 UTC (permalink / raw)
  To: Tianping Fang
  Cc: devicetree, Greg Kroah-Hartman, linux-usb, linux-kernel,
	Chunfeng Yun, linux-mediatek, Matthias Brugger, linux-arm-kernel

Wakeup_signal will toggle status according to ssusb_ip_sleep signal
after debounce time, so need add a delay time and wait for wakeup_signal
toggle to complete, then enable the remote wakeup. Meanwhile reduce the
debounce time of wakeup_signal. These will avoid spurious wakeup event.

Signed-off-by: Tianping Fang <tianping.fang@mediatek.com>
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
Note, depends on following patch not merged:

    [v3,3/7] usb: mtu3: support ip-sleep wakeup for MT8183
    https://patchwork.kernel.org/patch/11123151/
---
 drivers/usb/mtu3/mtu3_host.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/mtu3/mtu3_host.c b/drivers/usb/mtu3/mtu3_host.c
index 182c9439c15a..ca48ff751c8b 100644
--- a/drivers/usb/mtu3/mtu3_host.c
+++ b/drivers/usb/mtu3/mtu3_host.c
@@ -53,12 +53,12 @@ static void ssusb_wakeup_ip_sleep_set(struct ssusb_mtk *ssusb, bool enable)
 	case SSUSB_UWK_V0:
 		reg = ssusb->uwk_reg_base + PERI_WK_CTRL0;
 		msk = (u32)(WC0_IS_EN | WC0_IS_C(0xf) | WC0_IS_P);
-		val = enable ? (WC0_IS_EN | WC0_IS_C(0x8)) : 0;
+		val = enable ? (WC0_IS_EN | WC0_IS_C(0x3)) : 0;
 		break;
 	case SSUSB_UWK_V1:
 		reg = ssusb->uwk_reg_base + PERI_WK_CTRL1;
 		msk = WC1_IS_EN | WC1_IS_C(0xf) | WC1_IS_P;
-		val = enable ? (WC1_IS_EN | WC1_IS_C(0x8)) : 0;
+		val = enable ? (WC1_IS_EN | WC1_IS_C(0x3)) : 0;
 		break;
 	case SSUSB_UWK_V2:
 		reg = ssusb->uwk_reg_base + PERI_SSUSB_SPM_CTRL;
@@ -197,6 +197,8 @@ int ssusb_host_disable(struct ssusb_mtk *ssusb, bool suspend)
 			  (value & SSUSB_IP_SLEEP_STS), 100, 100000);
 	if (ret)
 		dev_err(ssusb->dev, "ip sleep failed!!!\n");
+	else  /* wait for wakeup_signal toggle done after enter ip-sleep */
+		usleep_range(245, 255);
 
 	return ret;
 }
-- 
2.23.0
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-11-14  2:33 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-11-14  2:33 [RFC PATCH] usb: mtu3: fix random remote wakeup Chunfeng Yun
2019-11-14  2:33 ` Chunfeng Yun
2019-11-14  2:33 ` Chunfeng Yun

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.