From: chunfeng.yun@mediatek.com (Chunfeng Yun)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 4/7] usb: mtu3: use APIs of mtu_wakeup to support remote wakeup
Date: Sat, 9 Dec 2017 16:45:33 +0800 [thread overview]
Message-ID: <1512809136-2779-5-git-send-email-chunfeng.yun@mediatek.com> (raw)
In-Reply-To: <1512809136-2779-1-git-send-email-chunfeng.yun@mediatek.com>
On some platforms, there are two SSUSB IPs, but the old way of
usb wakeup doesn't support it, so use the new APIs of mtu_wakeup
to support it.
Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
drivers/usb/mtu3/mtu3.h | 2 ++
drivers/usb/mtu3/mtu3_host.c | 39 +++++++++++++++++++++++----------------
2 files changed, 25 insertions(+), 16 deletions(-)
diff --git a/drivers/usb/mtu3/mtu3.h b/drivers/usb/mtu3/mtu3.h
index 3c888d9..9f3eb79 100644
--- a/drivers/usb/mtu3/mtu3.h
+++ b/drivers/usb/mtu3/mtu3.h
@@ -255,6 +255,8 @@ struct ssusb_mtk {
/* usb wakeup for host mode */
bool wakeup_en;
struct regmap *pericfg;
+ struct mtu_wakeup *uwk;
+ bool new_wakeup;
};
/**
diff --git a/drivers/usb/mtu3/mtu3_host.c b/drivers/usb/mtu3/mtu3_host.c
index 7e948c0..f769b65 100644
--- a/drivers/usb/mtu3/mtu3_host.c
+++ b/drivers/usb/mtu3/mtu3_host.c
@@ -14,6 +14,7 @@
#include <linux/mfd/syscon.h>
#include <linux/of_device.h>
#include <linux/regmap.h>
+#include <linux/soc/mediatek/usb-wakeup.h>
#include "mtu3.h"
#include "mtu3_dr.h"
@@ -56,24 +57,26 @@ static void ssusb_wakeup_ip_sleep_dis(struct ssusb_mtk *ssusb)
int ssusb_wakeup_of_property_parse(struct ssusb_mtk *ssusb,
struct device_node *dn)
{
- struct device *dev = ssusb->dev;
+ /* try the new way first */
+ ssusb->new_wakeup = of_property_read_bool(dn, "wakeup-source");
+ if (ssusb->new_wakeup) {
+ ssusb->uwk = devm_of_uwk_get_by_index(ssusb->dev, dn, 0);
+ if (IS_ERR(ssusb->uwk))
+ dev_err(ssusb->dev, "fail to get mtu_wakeup\n");
+
+ return PTR_ERR_OR_ZERO(ssusb->uwk);
+ }
- /*
- * Wakeup function is optional, so it is not an error if this property
- * does not exist, and in such case, no need to get relative
- * properties anymore.
- */
+ /* Wakeup function is optional. (deprecated, use the new way instead) */
ssusb->wakeup_en = of_property_read_bool(dn, "mediatek,enable-wakeup");
- if (!ssusb->wakeup_en)
- return 0;
-
- ssusb->pericfg = syscon_regmap_lookup_by_phandle(dn,
+ if (ssusb->wakeup_en) {
+ ssusb->pericfg = syscon_regmap_lookup_by_phandle(dn,
"mediatek,syscon-wakeup");
- if (IS_ERR(ssusb->pericfg)) {
- dev_err(dev, "fail to get pericfg regs\n");
- return PTR_ERR(ssusb->pericfg);
+ if (IS_ERR(ssusb->pericfg)) {
+ dev_err(ssusb->dev, "fail to get pericfg regs\n");
+ return PTR_ERR(ssusb->pericfg);
+ }
}
-
return 0;
}
@@ -235,7 +238,9 @@ void ssusb_host_exit(struct ssusb_mtk *ssusb)
int ssusb_wakeup_enable(struct ssusb_mtk *ssusb)
{
- if (ssusb->wakeup_en)
+ if (ssusb->new_wakeup)
+ mtu_wakeup_enable(ssusb->uwk);
+ else if (ssusb->wakeup_en)
ssusb_wakeup_ip_sleep_en(ssusb);
return 0;
@@ -243,6 +248,8 @@ int ssusb_wakeup_enable(struct ssusb_mtk *ssusb)
void ssusb_wakeup_disable(struct ssusb_mtk *ssusb)
{
- if (ssusb->wakeup_en)
+ if (ssusb->new_wakeup)
+ mtu_wakeup_disable(ssusb->uwk);
+ else if (ssusb->wakeup_en)
ssusb_wakeup_ip_sleep_dis(ssusb);
}
--
1.9.1
next prev parent reply other threads:[~2017-12-09 8:45 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-12-09 8:45 [PATCH 0/7] Add USB remote wakeup driver Chunfeng Yun
2017-12-09 8:45 ` [PATCH 1/7] soc: mediatek: Add USB " Chunfeng Yun
2017-12-15 20:55 ` Rob Herring
2017-12-21 6:50 ` Chunfeng Yun
2017-12-09 8:45 ` [PATCH 2/7] dt-bindings: soc: mediatek: add bindings document for USB wakeup Chunfeng Yun
2017-12-09 8:45 ` [PATCH 3/7] usb: xhci-mtk: use APIs of mtu_wakeup to support remote wakeup Chunfeng Yun
2017-12-09 8:45 ` Chunfeng Yun [this message]
2017-12-09 8:45 ` [PATCH 5/7] dt-bindings: usb: mtk-xhci: add USB wakeup properties Chunfeng Yun
2017-12-09 8:45 ` [PATCH 6/7] dt-bindings: usb: mtu3: " Chunfeng Yun
2017-12-09 8:45 ` [PATCH 7/7] arm64: dts: mt8173: add uwk node and remove unused usb property Chunfeng Yun
2017-12-15 20:55 ` [PATCH 0/7] Add USB remote wakeup driver Rob Herring
2017-12-21 6:48 ` Chunfeng Yun
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1512809136-2779-5-git-send-email-chunfeng.yun@mediatek.com \
--to=chunfeng.yun@mediatek.com \
--cc=linux-arm-kernel@lists.infradead.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox