LKML Archive on lore.kernel.org
 help / color / Atom feed
* [PATCH v3 0/7]  add support USB for MT8183
@ 2019-08-30  7:40 Chunfeng Yun
  2019-08-30  7:40 ` [PATCH v3 1/7] dt-bindings: usb: mtu3: support USB wakeup " Chunfeng Yun
                   ` (7 more replies)
  0 siblings, 8 replies; 17+ messages in thread
From: Chunfeng Yun @ 2019-08-30  7:40 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring
  Cc: Mark Rutland, Matthias Brugger, Mathias Nyman, Chunfeng Yun,
	linux-usb, devicetree, linux-arm-kernel, linux-mediatek,
	linux-kernel

This series support USB DRD controller and enable it's remote
wakeup functoin for MT8183, they depend on the following
series patches:

1. this series add support MT6358 PMIC
  [v5,01/10] mfd: mt6397: clean up code
  https://patchwork.kernel.org/patch/11110487/

2. this series add support pericfg syscon
  [v2,1/2] dt-bindings: clock: mediatek: add pericfg for MT8183
  https://patchwork.kernel.org/patch/11118183/

3. add property mediatek,discth for tphy
  [06/11] phy: phy-mtk-tphy: add a property for disconnect threshold
  https://patchwork.kernel.org/patch/11110695/

v3 changes:
  1. changes micros define
  2. remove #reset-cell
  3. update dependent series

v2 changes:
  add patch [7/7]

Chunfeng Yun (7):
  dt-bindings: usb: mtu3: support USB wakeup for MT8183
  dt-bindings: usb: mtk-xhci: support USB wakeup for MT8183
  usb: mtu3: support ip-sleep wakeup for MT8183
  usb: mtk-xhci: support ip-sleep wakeup for MT8183
  arm64: dts: mt8183: add usb and phy nodes
  arm64: dts: mt8183: enable USB remote wakeup
  arm64: dts: mt8183: tune disconnect threshold of u2phy

 .../bindings/usb/mediatek,mtk-xhci.txt        |  1 +
 .../devicetree/bindings/usb/mediatek,mtu3.txt |  1 +
 arch/arm64/boot/dts/mediatek/mt8183-evb.dts   | 23 +++++++
 arch/arm64/boot/dts/mediatek/mt8183.dtsi      | 63 +++++++++++++++++++
 drivers/usb/host/xhci-mtk.c                   | 14 ++++-
 drivers/usb/mtu3/mtu3_host.c                  | 14 ++++-
 6 files changed, 114 insertions(+), 2 deletions(-)

-- 
2.23.0


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

* [PATCH v3 1/7] dt-bindings: usb: mtu3: support USB wakeup for MT8183
  2019-08-30  7:40 [PATCH v3 0/7] add support USB for MT8183 Chunfeng Yun
@ 2019-08-30  7:40 ` " Chunfeng Yun
  2019-09-02 13:39   ` Rob Herring
  2019-08-30  7:40 ` [PATCH v3 2/7] dt-bindings: usb: mtk-xhci: " Chunfeng Yun
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 17+ messages in thread
From: Chunfeng Yun @ 2019-08-30  7:40 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring
  Cc: Mark Rutland, Matthias Brugger, Mathias Nyman, Chunfeng Yun,
	linux-usb, devicetree, linux-arm-kernel, linux-mediatek,
	linux-kernel

Support USB wakeup by ip-sleep mode for MT8183

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v2~v3: no changes
---
 Documentation/devicetree/bindings/usb/mediatek,mtu3.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt b/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
index 3382b5cb471d..ed954bedcd2f 100644
--- a/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtu3.txt
@@ -48,6 +48,7 @@ Optional properties:
 	"wakeup-source", and has two arguments:
 	- the first one : register base address of the glue layer in syscon;
 	- the second one : hardware version of the glue layer
+		- 0 : used by mt8183 etc
 		- 1 : used by mt8173 etc
 		- 2 : used by mt2712 etc
  - mediatek,u3p-dis-msk : mask to disable u3ports, bit0 for u3port0,
-- 
2.23.0


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

* [PATCH v3 2/7] dt-bindings: usb: mtk-xhci: support USB wakeup for MT8183
  2019-08-30  7:40 [PATCH v3 0/7] add support USB for MT8183 Chunfeng Yun
  2019-08-30  7:40 ` [PATCH v3 1/7] dt-bindings: usb: mtu3: support USB wakeup " Chunfeng Yun
@ 2019-08-30  7:40 ` " Chunfeng Yun
  2019-09-02 13:39   ` Rob Herring
  2019-08-30  7:40 ` [PATCH v3 3/7] usb: mtu3: support ip-sleep " Chunfeng Yun
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 17+ messages in thread
From: Chunfeng Yun @ 2019-08-30  7:40 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring
  Cc: Mark Rutland, Matthias Brugger, Mathias Nyman, Chunfeng Yun,
	linux-usb, devicetree, linux-arm-kernel, linux-mediatek,
	linux-kernel

Support USB wakeup by ip-sleep mode for MT8183

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v2~v3: no changes
---
 Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
index 266c2d917a28..9a0a9eb0456f 100644
--- a/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
+++ b/Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt
@@ -41,6 +41,7 @@ Optional properties:
 	"wakeup-source", and has two arguments:
 	- the first one : register base address of the glue layer in syscon;
 	- the second one : hardware version of the glue layer
+		- 0 : used by mt8183 etc
 		- 1 : used by mt8173 etc
 		- 2 : used by mt2712 etc
  - mediatek,u3p-dis-msk : mask to disable u3ports, bit0 for u3port0,
-- 
2.23.0


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

* [PATCH v3 3/7] usb: mtu3: support ip-sleep wakeup for MT8183
  2019-08-30  7:40 [PATCH v3 0/7] add support USB for MT8183 Chunfeng Yun
  2019-08-30  7:40 ` [PATCH v3 1/7] dt-bindings: usb: mtu3: support USB wakeup " Chunfeng Yun
  2019-08-30  7:40 ` [PATCH v3 2/7] dt-bindings: usb: mtk-xhci: " Chunfeng Yun
@ 2019-08-30  7:40 ` " Chunfeng Yun
  2019-09-02  9:23   ` kbuild test robot
  2019-09-11 18:44   ` Guenter Roeck
  2019-08-30  7:40 ` [PATCH v3 4/7] usb: mtk-xhci: " Chunfeng Yun
                   ` (4 subsequent siblings)
  7 siblings, 2 replies; 17+ messages in thread
From: Chunfeng Yun @ 2019-08-30  7:40 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring
  Cc: Mark Rutland, Matthias Brugger, Mathias Nyman, Chunfeng Yun,
	linux-usb, devicetree, linux-arm-kernel, linux-mediatek,
	linux-kernel

Support USB wakeup by ip-sleep mode for MT8183, it's similar to
MT8173

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v3: changes micros define

v2: no changes
---
 drivers/usb/mtu3/mtu3_host.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/mtu3/mtu3_host.c b/drivers/usb/mtu3/mtu3_host.c
index c871b94f3e6f..4f8208885ebd 100644
--- a/drivers/usb/mtu3/mtu3_host.c
+++ b/drivers/usb/mtu3/mtu3_host.c
@@ -18,6 +18,12 @@
 #include "mtu3.h"
 #include "mtu3_dr.h"
 
+/* mt8183 etc */
+#define PERI_WK_CTRL0	0x20
+#define WC0_IS_C(x)	(((x) & 0xf) << 28)  /* cycle debounce */
+#define WC0_IS_P	BIT(12)	/* polarity */
+#define WC0_IS_EN	BIT(6)
+
 /* mt8173 etc */
 #define PERI_WK_CTRL1	0x4
 #define WC1_IS_C(x)	(((x) & 0xf) << 26)  /* cycle debounce */
@@ -30,7 +36,8 @@
 #define SSC_SPM_INT_EN		BIT(1)
 
 enum ssusb_uwk_vers {
-	SSUSB_UWK_V1 = 1,
+	SSUSB_UWK_V0 = 0,
+	SSUSB_UWK_V1,
 	SSUSB_UWK_V2,
 };
 
@@ -43,6 +50,11 @@ static void ssusb_wakeup_ip_sleep_set(struct ssusb_mtk *ssusb, bool enable)
 	u32 reg, msk, val;
 
 	switch (ssusb->uwk_vers) {
+	case SSUSB_UWK_V0:
+		reg = ssusb->uwk_reg_base + PERI_WK_CTRL0;
+		msk = WC0_IS_EN | WC0_IS_C(0xf) | WC0_IS_P;
+		val = enable ? (WC0_IS_EN | WC0_IS_C(0x8)) : 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;
-- 
2.23.0


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

* [PATCH v3 4/7] usb: mtk-xhci: support ip-sleep wakeup for MT8183
  2019-08-30  7:40 [PATCH v3 0/7] add support USB for MT8183 Chunfeng Yun
                   ` (2 preceding siblings ...)
  2019-08-30  7:40 ` [PATCH v3 3/7] usb: mtu3: support ip-sleep " Chunfeng Yun
@ 2019-08-30  7:40 ` " Chunfeng Yun
  2019-09-02 11:58   ` kbuild test robot
  2019-08-30  7:40 ` [PATCH v3 5/7] arm64: dts: mt8183: add usb and phy nodes Chunfeng Yun
                   ` (3 subsequent siblings)
  7 siblings, 1 reply; 17+ messages in thread
From: Chunfeng Yun @ 2019-08-30  7:40 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring
  Cc: Mark Rutland, Matthias Brugger, Mathias Nyman, Chunfeng Yun,
	linux-usb, devicetree, linux-arm-kernel, linux-mediatek,
	linux-kernel

Support USB wakeup by ip-sleep mode for MT8183, it's similar to
MT8173

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v3: change micros define

v2: no changes
---
 drivers/usb/host/xhci-mtk.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/usb/host/xhci-mtk.c b/drivers/usb/host/xhci-mtk.c
index 026fe18972d3..9b30a868a7ab 100644
--- a/drivers/usb/host/xhci-mtk.c
+++ b/drivers/usb/host/xhci-mtk.c
@@ -57,6 +57,12 @@
 #define CTRL_U2_FORCE_PLL_STB	BIT(28)
 
 /* usb remote wakeup registers in syscon */
+/* mt8183 etc */
+#define PERI_WK_CTRL0	0x20
+#define WC0_IS_C(x)	(((x) & 0xf) << 28)  /* cycle debounce */
+#define WC0_IS_P	BIT(12)	/* polarity */
+#define WC0_IS_EN	BIT(6)
+
 /* mt8173 etc */
 #define PERI_WK_CTRL1	0x4
 #define WC1_IS_C(x)	(((x) & 0xf) << 26)  /* cycle debounce */
@@ -69,7 +75,8 @@
 #define SSC_SPM_INT_EN		BIT(1)
 
 enum ssusb_uwk_vers {
-	SSUSB_UWK_V1 = 1,
+	SSUSB_UWK_V0 = 0,
+	SSUSB_UWK_V1,
 	SSUSB_UWK_V2,
 };
 
@@ -282,6 +289,11 @@ static void usb_wakeup_ip_sleep_set(struct xhci_hcd_mtk *mtk, bool enable)
 	u32 reg, msk, val;
 
 	switch (mtk->uwk_vers) {
+	case SSUSB_UWK_V0:
+		reg = mtk->uwk_reg_base + PERI_WK_CTRL0;
+		msk = WC0_IS_EN | WC0_IS_C(0xf) | WC0_IS_P;
+		val = enable ? (WC0_IS_EN | WC0_IS_C(0x8)) : 0;
+		break;
 	case SSUSB_UWK_V1:
 		reg = mtk->uwk_reg_base + PERI_WK_CTRL1;
 		msk = WC1_IS_EN | WC1_IS_C(0xf) | WC1_IS_P;
-- 
2.23.0


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

* [PATCH v3 5/7] arm64: dts: mt8183: add usb and phy nodes
  2019-08-30  7:40 [PATCH v3 0/7] add support USB for MT8183 Chunfeng Yun
                   ` (3 preceding siblings ...)
  2019-08-30  7:40 ` [PATCH v3 4/7] usb: mtk-xhci: " Chunfeng Yun
@ 2019-08-30  7:40 ` Chunfeng Yun
  2019-09-03 11:25   ` kbuild test robot
  2019-08-30  7:40 ` [PATCH v3 6/7] arm64: dts: mt8183: enable USB remote wakeup Chunfeng Yun
                   ` (2 subsequent siblings)
  7 siblings, 1 reply; 17+ messages in thread
From: Chunfeng Yun @ 2019-08-30  7:40 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring
  Cc: Mark Rutland, Matthias Brugger, Mathias Nyman, Chunfeng Yun,
	linux-usb, devicetree, linux-arm-kernel, linux-mediatek,
	linux-kernel

Add USB related nodes for MT8183, set it as host mode by default.

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v2~v3: no changes
---
 arch/arm64/boot/dts/mediatek/mt8183-evb.dts | 22 +++++++++
 arch/arm64/boot/dts/mediatek/mt8183.dtsi    | 55 +++++++++++++++++++++
 2 files changed, 77 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8183-evb.dts b/arch/arm64/boot/dts/mediatek/mt8183-evb.dts
index d8e555cbb5d3..142ff52f0f42 100644
--- a/arch/arm64/boot/dts/mediatek/mt8183-evb.dts
+++ b/arch/arm64/boot/dts/mediatek/mt8183-evb.dts
@@ -6,7 +6,9 @@
  */
 
 /dts-v1/;
+#include <dt-bindings/gpio/gpio.h>
 #include "mt8183.dtsi"
+#include "mt6358.dtsi"
 
 / {
 	model = "MediaTek MT8183 evaluation board";
@@ -24,6 +26,16 @@
 	chosen {
 		stdout-path = "serial0:921600n8";
 	};
+
+	usb_vbus: regulator@0 {
+		compatible = "regulator-fixed";
+		regulator-name = "p0_vbus";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		gpio = <&pio 42 GPIO_ACTIVE_HIGH>;
+		enable-active-high;
+		regulator-always-on;
+	};
 };
 
 &auxadc {
@@ -135,6 +147,16 @@
 
 };
 
+&ssusb {
+	vusb33-supply = <&mt6358_vusb_reg>;
+	dr_mode = "host";
+	status = "okay";
+};
+
+&usb_host {
+	status = "okay";
+};
+
 &uart0 {
 	status = "okay";
 };
diff --git a/arch/arm64/boot/dts/mediatek/mt8183.dtsi b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
index c2749c4631bc..28da334237c6 100644
--- a/arch/arm64/boot/dts/mediatek/mt8183.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
@@ -8,6 +8,7 @@
 #include <dt-bindings/clock/mt8183-clk.h>
 #include <dt-bindings/interrupt-controller/arm-gic.h>
 #include <dt-bindings/interrupt-controller/irq.h>
+#include <dt-bindings/phy/phy.h>
 #include "mt8183-pinfunc.h"
 
 / {
@@ -372,6 +373,35 @@
 			status = "disabled";
 		};
 
+		ssusb: usb@11201000 {
+			compatible = "mediatek,mt8183-mtu3", "mediatek,mtu3";
+			reg = <0 0x11201000 0 0x2e00>,
+			      <0 0x11203e00 0 0x0100>;
+			reg-names = "mac", "ippc";
+			interrupts = <GIC_SPI 72 IRQ_TYPE_LEVEL_LOW>;
+			phys = <&u2port0 PHY_TYPE_USB2>,
+			       <&u3port0 PHY_TYPE_USB3>;
+			clocks = <&infracfg CLK_INFRA_UNIPRO_SCK>,
+				 <&infracfg CLK_INFRA_USB>;
+			clock-names = "sys_ck", "ref_ck";
+			#address-cells = <2>;
+			#size-cells = <2>;
+			ranges;
+			status = "disabled";
+
+			usb_host: xhci@11200000 {
+				compatible = "mediatek,mt8183-xhci",
+					     "mediatek,mtk-xhci";
+				reg = <0 0x11200000 0 0x1000>;
+				reg-names = "mac";
+				interrupts = <GIC_SPI 73 IRQ_TYPE_LEVEL_LOW>;
+				clocks = <&infracfg CLK_INFRA_UNIPRO_SCK>,
+					 <&infracfg CLK_INFRA_USB>;
+				clock-names = "sys_ck", "ref_ck";
+				status = "disabled";
+			};
+		};
+
 		audiosys: syscon@11220000 {
 			compatible = "mediatek,mt8183-audiosys", "syscon";
 			reg = <0 0x11220000 0 0x1000>;
@@ -384,6 +414,31 @@
 			reg = <0 0x11f10000 0 0x1000>;
 		};
 
+		u3phy: usb-phy@11f40000 {
+			compatible = "mediatek,mt8183-tphy",
+				     "mediatek,generic-tphy-v2";
+			#address-cells = <1>;
+			#size-cells = <1>;
+			ranges = <0 0 0x11f40000 0x1000>;
+			status = "okay";
+
+			u2port0: usb-phy@0 {
+				reg = <0x0 0x700>;
+				clocks = <&clk26m>;
+				clock-names = "ref";
+				#phy-cells = <1>;
+				status = "okay";
+			};
+
+			u3port0: usb-phy@0700 {
+				reg = <0x0700 0x900>;
+				clocks = <&clk26m>;
+				clock-names = "ref";
+				#phy-cells = <1>;
+				status = "okay";
+			};
+		};
+
 		mfgcfg: syscon@13000000 {
 			compatible = "mediatek,mt8183-mfgcfg", "syscon";
 			reg = <0 0x13000000 0 0x1000>;
-- 
2.23.0


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

* [PATCH v3 6/7] arm64: dts: mt8183: enable USB remote wakeup
  2019-08-30  7:40 [PATCH v3 0/7] add support USB for MT8183 Chunfeng Yun
                   ` (4 preceding siblings ...)
  2019-08-30  7:40 ` [PATCH v3 5/7] arm64: dts: mt8183: add usb and phy nodes Chunfeng Yun
@ 2019-08-30  7:40 ` Chunfeng Yun
  2019-08-30  7:40 ` [PATCH v3 7/7] arm64: dts: mt8183: tune disconnect threshold of u2phy Chunfeng Yun
  2019-09-04  1:54 ` [PATCH v3 0/7] add support USB for MT8183 Chunfeng Yun
  7 siblings, 0 replies; 17+ messages in thread
From: Chunfeng Yun @ 2019-08-30  7:40 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring
  Cc: Mark Rutland, Matthias Brugger, Mathias Nyman, Chunfeng Yun,
	linux-usb, devicetree, linux-arm-kernel, linux-mediatek,
	linux-kernel

Enable USB remote wakeup for MT8183

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v3: remove '#reset-cells'

v2: no changes
---
 arch/arm64/boot/dts/mediatek/mt8183-evb.dts | 1 +
 arch/arm64/boot/dts/mediatek/mt8183.dtsi    | 7 +++++++
 2 files changed, 8 insertions(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8183-evb.dts b/arch/arm64/boot/dts/mediatek/mt8183-evb.dts
index 142ff52f0f42..077256f3397b 100644
--- a/arch/arm64/boot/dts/mediatek/mt8183-evb.dts
+++ b/arch/arm64/boot/dts/mediatek/mt8183-evb.dts
@@ -150,6 +150,7 @@
 &ssusb {
 	vusb33-supply = <&mt6358_vusb_reg>;
 	dr_mode = "host";
+	wakeup-source;
 	status = "okay";
 };
 
diff --git a/arch/arm64/boot/dts/mediatek/mt8183.dtsi b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
index 28da334237c6..dc3e859849c7 100644
--- a/arch/arm64/boot/dts/mediatek/mt8183.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
@@ -215,6 +215,12 @@
 			#clock-cells = <1>;
 		};
 
+		pericfg: syscon@10003000 {
+			compatible = "mediatek,mt8183-pericfg", "syscon";
+			reg = <0 0x10003000 0 0x1000>;
+			#clock-cells = <1>;
+		};
+
 		pio: pinctrl@10005000 {
 			compatible = "mediatek,mt8183-pinctrl";
 			reg = <0 0x10005000 0 0x1000>,
@@ -384,6 +390,7 @@
 			clocks = <&infracfg CLK_INFRA_UNIPRO_SCK>,
 				 <&infracfg CLK_INFRA_USB>;
 			clock-names = "sys_ck", "ref_ck";
+			mediatek,syscon-wakeup = <&pericfg 0x400 0>;
 			#address-cells = <2>;
 			#size-cells = <2>;
 			ranges;
-- 
2.23.0


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

* [PATCH v3 7/7] arm64: dts: mt8183: tune disconnect threshold of u2phy
  2019-08-30  7:40 [PATCH v3 0/7] add support USB for MT8183 Chunfeng Yun
                   ` (5 preceding siblings ...)
  2019-08-30  7:40 ` [PATCH v3 6/7] arm64: dts: mt8183: enable USB remote wakeup Chunfeng Yun
@ 2019-08-30  7:40 ` Chunfeng Yun
  2019-09-04  1:54 ` [PATCH v3 0/7] add support USB for MT8183 Chunfeng Yun
  7 siblings, 0 replies; 17+ messages in thread
From: Chunfeng Yun @ 2019-08-30  7:40 UTC (permalink / raw)
  To: Greg Kroah-Hartman, Rob Herring
  Cc: Mark Rutland, Matthias Brugger, Mathias Nyman, Chunfeng Yun,
	linux-usb, devicetree, linux-arm-kernel, linux-mediatek,
	linux-kernel

Set DISCTH to max-15, replace the default value 8, due to
default disconnect threshold is lower than USB SPEC define

Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
---
v3: no changes

v2: new patch
---
 arch/arm64/boot/dts/mediatek/mt8183.dtsi | 1 +
 1 file changed, 1 insertion(+)

diff --git a/arch/arm64/boot/dts/mediatek/mt8183.dtsi b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
index dc3e859849c7..5168e345ea3f 100644
--- a/arch/arm64/boot/dts/mediatek/mt8183.dtsi
+++ b/arch/arm64/boot/dts/mediatek/mt8183.dtsi
@@ -434,6 +434,7 @@
 				clocks = <&clk26m>;
 				clock-names = "ref";
 				#phy-cells = <1>;
+				mediatek,discth = <15>;
 				status = "okay";
 			};
 
-- 
2.23.0


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

* Re: [PATCH v3 3/7] usb: mtu3: support ip-sleep wakeup for MT8183
  2019-08-30  7:40 ` [PATCH v3 3/7] usb: mtu3: support ip-sleep " Chunfeng Yun
@ 2019-09-02  9:23   ` kbuild test robot
  2019-09-11 18:44   ` Guenter Roeck
  1 sibling, 0 replies; 17+ messages in thread
From: kbuild test robot @ 2019-09-02  9:23 UTC (permalink / raw)
  To: Chunfeng Yun
  Cc: kbuild-all, Greg Kroah-Hartman, Rob Herring, Mark Rutland,
	Matthias Brugger, Mathias Nyman, Chunfeng Yun, linux-usb,
	devicetree, linux-arm-kernel, linux-mediatek, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 4512 bytes --]

Hi Chunfeng,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[cannot apply to v5.3-rc6 next-20190830]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Chunfeng-Yun/add-support-USB-for-MT8183/20190901-163637
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 7.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=ia64 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from include/linux/bitops.h:5:0,
                    from include/linux/kernel.h:12,
                    from include/linux/clk.h:13,
                    from drivers//usb/mtu3/mtu3_host.c:10:
   drivers//usb/mtu3/mtu3_host.c: In function 'ssusb_wakeup_ip_sleep_set':
>> include/linux/bits.h:8:19: warning: large integer implicitly truncated to unsigned type [-Woverflow]
    #define BIT(nr)   (UL(1) << (nr))
                      ^
>> drivers//usb/mtu3/mtu3_host.c:25:19: note: in expansion of macro 'BIT'
    #define WC0_IS_EN BIT(6)
                      ^~~
>> drivers//usb/mtu3/mtu3_host.c:55:9: note: in expansion of macro 'WC0_IS_EN'
      msk = WC0_IS_EN | WC0_IS_C(0xf) | WC0_IS_P;
            ^~~~~~~~~
--
   In file included from include/linux/bitops.h:5:0,
                    from include/linux/kernel.h:12,
                    from include/linux/clk.h:13,
                    from drivers/usb/mtu3/mtu3_host.c:10:
   drivers/usb/mtu3/mtu3_host.c: In function 'ssusb_wakeup_ip_sleep_set':
>> include/linux/bits.h:8:19: warning: large integer implicitly truncated to unsigned type [-Woverflow]
    #define BIT(nr)   (UL(1) << (nr))
                      ^
   drivers/usb/mtu3/mtu3_host.c:25:19: note: in expansion of macro 'BIT'
    #define WC0_IS_EN BIT(6)
                      ^~~
   drivers/usb/mtu3/mtu3_host.c:55:9: note: in expansion of macro 'WC0_IS_EN'
      msk = WC0_IS_EN | WC0_IS_C(0xf) | WC0_IS_P;
            ^~~~~~~~~

vim +/WC0_IS_EN +55 drivers//usb/mtu3/mtu3_host.c

  > 10	#include <linux/clk.h>
    11	#include <linux/iopoll.h>
    12	#include <linux/irq.h>
    13	#include <linux/kernel.h>
    14	#include <linux/mfd/syscon.h>
    15	#include <linux/of_device.h>
    16	#include <linux/regmap.h>
    17	
    18	#include "mtu3.h"
    19	#include "mtu3_dr.h"
    20	
    21	/* mt8183 etc */
    22	#define PERI_WK_CTRL0	0x20
    23	#define WC0_IS_C(x)	(((x) & 0xf) << 28)  /* cycle debounce */
    24	#define WC0_IS_P	BIT(12)	/* polarity */
  > 25	#define WC0_IS_EN	BIT(6)
    26	
    27	/* mt8173 etc */
    28	#define PERI_WK_CTRL1	0x4
    29	#define WC1_IS_C(x)	(((x) & 0xf) << 26)  /* cycle debounce */
    30	#define WC1_IS_EN	BIT(25)
    31	#define WC1_IS_P	BIT(6)  /* polarity for ip sleep */
    32	
    33	/* mt2712 etc */
    34	#define PERI_SSUSB_SPM_CTRL	0x0
    35	#define SSC_IP_SLEEP_EN	BIT(4)
    36	#define SSC_SPM_INT_EN		BIT(1)
    37	
    38	enum ssusb_uwk_vers {
    39		SSUSB_UWK_V0 = 0,
    40		SSUSB_UWK_V1,
    41		SSUSB_UWK_V2,
    42	};
    43	
    44	/*
    45	 * ip-sleep wakeup mode:
    46	 * all clocks can be turn off, but power domain should be kept on
    47	 */
    48	static void ssusb_wakeup_ip_sleep_set(struct ssusb_mtk *ssusb, bool enable)
    49	{
    50		u32 reg, msk, val;
    51	
    52		switch (ssusb->uwk_vers) {
    53		case SSUSB_UWK_V0:
    54			reg = ssusb->uwk_reg_base + PERI_WK_CTRL0;
  > 55			msk = WC0_IS_EN | WC0_IS_C(0xf) | WC0_IS_P;
    56			val = enable ? (WC0_IS_EN | WC0_IS_C(0x8)) : 0;
    57			break;
    58		case SSUSB_UWK_V1:
    59			reg = ssusb->uwk_reg_base + PERI_WK_CTRL1;
    60			msk = WC1_IS_EN | WC1_IS_C(0xf) | WC1_IS_P;
    61			val = enable ? (WC1_IS_EN | WC1_IS_C(0x8)) : 0;
    62			break;
    63		case SSUSB_UWK_V2:
    64			reg = ssusb->uwk_reg_base + PERI_SSUSB_SPM_CTRL;
    65			msk = SSC_IP_SLEEP_EN | SSC_SPM_INT_EN;
    66			val = enable ? msk : 0;
    67			break;
    68		default:
    69			return;
    70		}
    71		regmap_update_bits(ssusb->uwk, reg, msk, val);
    72	}
    73	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 54621 bytes --]

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

* Re: [PATCH v3 4/7] usb: mtk-xhci: support ip-sleep wakeup for MT8183
  2019-08-30  7:40 ` [PATCH v3 4/7] usb: mtk-xhci: " Chunfeng Yun
@ 2019-09-02 11:58   ` kbuild test robot
  0 siblings, 0 replies; 17+ messages in thread
From: kbuild test robot @ 2019-09-02 11:58 UTC (permalink / raw)
  To: Chunfeng Yun
  Cc: kbuild-all, Greg Kroah-Hartman, Rob Herring, Mark Rutland,
	Matthias Brugger, Mathias Nyman, Chunfeng Yun, linux-usb,
	devicetree, linux-arm-kernel, linux-mediatek, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3555 bytes --]

Hi Chunfeng,

I love your patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[cannot apply to v5.3-rc6 next-20190830]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Chunfeng-Yun/add-support-USB-for-MT8183/20190901-163637
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 7.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=ia64 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   In file included from include/linux/bitops.h:5:0,
                    from include/linux/kernel.h:12,
                    from include/linux/clk.h:13,
                    from drivers/usb/host/xhci-mtk.c:10:
   drivers/usb/host/xhci-mtk.c: In function 'usb_wakeup_ip_sleep_set':
   include/linux/bits.h:8:19: warning: large integer implicitly truncated to unsigned type [-Woverflow]
    #define BIT(nr)   (UL(1) << (nr))
                      ^
>> drivers/usb/host/xhci-mtk.c:64:19: note: in expansion of macro 'BIT'
    #define WC0_IS_EN BIT(6)
                      ^~~
>> drivers/usb/host/xhci-mtk.c:294:9: note: in expansion of macro 'WC0_IS_EN'
      msk = WC0_IS_EN | WC0_IS_C(0xf) | WC0_IS_P;
            ^~~~~~~~~

vim +/BIT +64 drivers/usb/host/xhci-mtk.c

  > 10	#include <linux/clk.h>
    11	#include <linux/dma-mapping.h>
    12	#include <linux/iopoll.h>
    13	#include <linux/kernel.h>
    14	#include <linux/mfd/syscon.h>
    15	#include <linux/module.h>
    16	#include <linux/of.h>
    17	#include <linux/platform_device.h>
    18	#include <linux/pm_runtime.h>
    19	#include <linux/regmap.h>
    20	#include <linux/regulator/consumer.h>
    21	
    22	#include "xhci.h"
    23	#include "xhci-mtk.h"
    24	
    25	/* ip_pw_ctrl0 register */
    26	#define CTRL0_IP_SW_RST	BIT(0)
    27	
    28	/* ip_pw_ctrl1 register */
    29	#define CTRL1_IP_HOST_PDN	BIT(0)
    30	
    31	/* ip_pw_ctrl2 register */
    32	#define CTRL2_IP_DEV_PDN	BIT(0)
    33	
    34	/* ip_pw_sts1 register */
    35	#define STS1_IP_SLEEP_STS	BIT(30)
    36	#define STS1_U3_MAC_RST	BIT(16)
    37	#define STS1_XHCI_RST		BIT(11)
    38	#define STS1_SYS125_RST	BIT(10)
    39	#define STS1_REF_RST		BIT(8)
    40	#define STS1_SYSPLL_STABLE	BIT(0)
    41	
    42	/* ip_xhci_cap register */
    43	#define CAP_U3_PORT_NUM(p)	((p) & 0xff)
    44	#define CAP_U2_PORT_NUM(p)	(((p) >> 8) & 0xff)
    45	
    46	/* u3_ctrl_p register */
    47	#define CTRL_U3_PORT_HOST_SEL	BIT(2)
    48	#define CTRL_U3_PORT_PDN	BIT(1)
    49	#define CTRL_U3_PORT_DIS	BIT(0)
    50	
    51	/* u2_ctrl_p register */
    52	#define CTRL_U2_PORT_HOST_SEL	BIT(2)
    53	#define CTRL_U2_PORT_PDN	BIT(1)
    54	#define CTRL_U2_PORT_DIS	BIT(0)
    55	
    56	/* u2_phy_pll register */
    57	#define CTRL_U2_FORCE_PLL_STB	BIT(28)
    58	
    59	/* usb remote wakeup registers in syscon */
    60	/* mt8183 etc */
    61	#define PERI_WK_CTRL0	0x20
    62	#define WC0_IS_C(x)	(((x) & 0xf) << 28)  /* cycle debounce */
    63	#define WC0_IS_P	BIT(12)	/* polarity */
  > 64	#define WC0_IS_EN	BIT(6)
    65	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 54621 bytes --]

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

* Re: [PATCH v3 1/7] dt-bindings: usb: mtu3: support USB wakeup for MT8183
  2019-08-30  7:40 ` [PATCH v3 1/7] dt-bindings: usb: mtu3: support USB wakeup " Chunfeng Yun
@ 2019-09-02 13:39   ` Rob Herring
  0 siblings, 0 replies; 17+ messages in thread
From: Rob Herring @ 2019-09-02 13:39 UTC (permalink / raw)
  To: Chunfeng Yun; +Cc: Greg Kroah-Hartman, Rob Herring

On Fri, 30 Aug 2019 15:40:48 +0800, Chunfeng Yun wrote:
> Support USB wakeup by ip-sleep mode for MT8183
> 
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
> v2~v3: no changes
> ---
>  Documentation/devicetree/bindings/usb/mediatek,mtu3.txt | 1 +
>  1 file changed, 1 insertion(+)
> 

Acked-by: Rob Herring <robh@kernel.org>


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

* Re: [PATCH v3 2/7] dt-bindings: usb: mtk-xhci: support USB wakeup for MT8183
  2019-08-30  7:40 ` [PATCH v3 2/7] dt-bindings: usb: mtk-xhci: " Chunfeng Yun
@ 2019-09-02 13:39   ` Rob Herring
  0 siblings, 0 replies; 17+ messages in thread
From: Rob Herring @ 2019-09-02 13:39 UTC (permalink / raw)
  To: Chunfeng Yun
  Cc: Greg Kroah-Hartman, Rob Herring, Mark Rutland, Matthias Brugger,
	Mathias Nyman, Chunfeng Yun, linux-usb, devicetree,
	linux-arm-kernel, linux-mediatek, linux-kernel

On Fri, 30 Aug 2019 15:40:49 +0800, Chunfeng Yun wrote:
> Support USB wakeup by ip-sleep mode for MT8183
> 
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
> v2~v3: no changes
> ---
>  Documentation/devicetree/bindings/usb/mediatek,mtk-xhci.txt | 1 +
>  1 file changed, 1 insertion(+)
> 

Acked-by: Rob Herring <robh@kernel.org>


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

* Re: [PATCH v3 5/7] arm64: dts: mt8183: add usb and phy nodes
  2019-08-30  7:40 ` [PATCH v3 5/7] arm64: dts: mt8183: add usb and phy nodes Chunfeng Yun
@ 2019-09-03 11:25   ` kbuild test robot
  0 siblings, 0 replies; 17+ messages in thread
From: kbuild test robot @ 2019-09-03 11:25 UTC (permalink / raw)
  To: Chunfeng Yun
  Cc: kbuild-all, Greg Kroah-Hartman, Rob Herring, Mark Rutland,
	Matthias Brugger, Mathias Nyman, Chunfeng Yun, linux-usb,
	devicetree, linux-arm-kernel, linux-mediatek, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 1280 bytes --]

Hi Chunfeng,

I love your patch! Yet something to improve:

[auto build test ERROR on linus/master]
[cannot apply to v5.3-rc7 next-20190902]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Chunfeng-Yun/add-support-USB-for-MT8183/20190901-163637
config: arm64-allmodconfig (attached as .config)
compiler: aarch64-linux-gcc (GCC) 7.4.0
reproduce:
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        GCC_VERSION=7.4.0 make.cross ARCH=arm64 

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>

All errors (new ones prefixed by >>):

>> arch/arm64/boot/dts/mediatek/mt8183-evb.dts:11:10: fatal error: mt6358.dtsi: No such file or directory
      11 | #include "mt6358.dtsi"
         |          ^~~~~~~~~~~~~
   compilation terminated.

vim +11 arch/arm64/boot/dts/mediatek/mt8183-evb.dts

  > 11	#include "mt6358.dtsi"
    12	

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 66348 bytes --]

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

* Re: [PATCH v3 0/7]  add support USB for MT8183
  2019-08-30  7:40 [PATCH v3 0/7] add support USB for MT8183 Chunfeng Yun
                   ` (6 preceding siblings ...)
  2019-08-30  7:40 ` [PATCH v3 7/7] arm64: dts: mt8183: tune disconnect threshold of u2phy Chunfeng Yun
@ 2019-09-04  1:54 ` Chunfeng Yun
  2019-09-04  7:06   ` Greg Kroah-Hartman
  7 siblings, 1 reply; 17+ messages in thread
From: Chunfeng Yun @ 2019-09-04  1:54 UTC (permalink / raw)
  To: Greg Kroah-Hartman
  Cc: Rob Herring, Mark Rutland, Matthias Brugger, Mathias Nyman,
	linux-usb, devicetree, linux-arm-kernel, linux-mediatek,
	linux-kernel

Hi Greg,


  Please don't try to pick up this series, the dependent ones are still
under public review, I'll fix build warning and send out new version
after the dependent ones are applied
  Sorry for inconvenience

Thanks

On Fri, 2019-08-30 at 15:40 +0800, Chunfeng Yun wrote:
> This series support USB DRD controller and enable it's remote
> wakeup functoin for MT8183, they depend on the following
> series patches:
> 
> 1. this series add support MT6358 PMIC
>   [v5,01/10] mfd: mt6397: clean up code
>   https://patchwork.kernel.org/patch/11110487/
> 
> 2. this series add support pericfg syscon
>   [v2,1/2] dt-bindings: clock: mediatek: add pericfg for MT8183
>   https://patchwork.kernel.org/patch/11118183/
> 
> 3. add property mediatek,discth for tphy
>   [06/11] phy: phy-mtk-tphy: add a property for disconnect threshold
>   https://patchwork.kernel.org/patch/11110695/
> 
> v3 changes:
>   1. changes micros define
>   2. remove #reset-cell
>   3. update dependent series
> 
> v2 changes:
>   add patch [7/7]
> 
> Chunfeng Yun (7):
>   dt-bindings: usb: mtu3: support USB wakeup for MT8183
>   dt-bindings: usb: mtk-xhci: support USB wakeup for MT8183
>   usb: mtu3: support ip-sleep wakeup for MT8183
>   usb: mtk-xhci: support ip-sleep wakeup for MT8183
>   arm64: dts: mt8183: add usb and phy nodes
>   arm64: dts: mt8183: enable USB remote wakeup
>   arm64: dts: mt8183: tune disconnect threshold of u2phy
> 
>  .../bindings/usb/mediatek,mtk-xhci.txt        |  1 +
>  .../devicetree/bindings/usb/mediatek,mtu3.txt |  1 +
>  arch/arm64/boot/dts/mediatek/mt8183-evb.dts   | 23 +++++++
>  arch/arm64/boot/dts/mediatek/mt8183.dtsi      | 63 +++++++++++++++++++
>  drivers/usb/host/xhci-mtk.c                   | 14 ++++-
>  drivers/usb/mtu3/mtu3_host.c                  | 14 ++++-
>  6 files changed, 114 insertions(+), 2 deletions(-)
> 



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

* Re: [PATCH v3 0/7]  add support USB for MT8183
  2019-09-04  1:54 ` [PATCH v3 0/7] add support USB for MT8183 Chunfeng Yun
@ 2019-09-04  7:06   ` Greg Kroah-Hartman
  0 siblings, 0 replies; 17+ messages in thread
From: Greg Kroah-Hartman @ 2019-09-04  7:06 UTC (permalink / raw)
  To: Chunfeng Yun
  Cc: Rob Herring, Mark Rutland, Matthias Brugger, Mathias Nyman,
	linux-usb, devicetree, linux-arm-kernel, linux-mediatek,
	linux-kernel

On Wed, Sep 04, 2019 at 09:54:27AM +0800, Chunfeng Yun wrote:
> Hi Greg,
> 
> 
>   Please don't try to pick up this series, the dependent ones are still
> under public review, I'll fix build warning and send out new version
> after the dependent ones are applied
>   Sorry for inconvenience

No problem, now dropped from my review queue.

greg k-h

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

* Re: [PATCH v3 3/7] usb: mtu3: support ip-sleep wakeup for MT8183
  2019-08-30  7:40 ` [PATCH v3 3/7] usb: mtu3: support ip-sleep " Chunfeng Yun
  2019-09-02  9:23   ` kbuild test robot
@ 2019-09-11 18:44   ` Guenter Roeck
  2019-09-16  5:45     ` Chunfeng Yun
  1 sibling, 1 reply; 17+ messages in thread
From: Guenter Roeck @ 2019-09-11 18:44 UTC (permalink / raw)
  To: Chunfeng Yun
  Cc: Greg Kroah-Hartman, Rob Herring, Mark Rutland, devicetree,
	Mathias Nyman, linux-usb, linux-kernel, linux-mediatek,
	Matthias Brugger, linux-arm-kernel

On Fri, Aug 30, 2019 at 03:40:50PM +0800, Chunfeng Yun wrote:
> Support USB wakeup by ip-sleep mode for MT8183, it's similar to
> MT8173
> 
> Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> ---
> v3: changes micros define
> 
> v2: no changes
> ---
>  drivers/usb/mtu3/mtu3_host.c | 14 +++++++++++++-
>  1 file changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/usb/mtu3/mtu3_host.c b/drivers/usb/mtu3/mtu3_host.c
> index c871b94f3e6f..4f8208885ebd 100644
> --- a/drivers/usb/mtu3/mtu3_host.c
> +++ b/drivers/usb/mtu3/mtu3_host.c
> @@ -18,6 +18,12 @@
>  #include "mtu3.h"
>  #include "mtu3_dr.h"
>  
> +/* mt8183 etc */
> +#define PERI_WK_CTRL0	0x20
> +#define WC0_IS_C(x)	(((x) & 0xf) << 28)  /* cycle debounce */
> +#define WC0_IS_P	BIT(12)	/* polarity */
> +#define WC0_IS_EN	BIT(6)
> +

For 64-bit builds, this results in:

drivers/usb/mtu3/mtu3_host.c: In function ‘ssusb_wakeup_ip_sleep_set’:
./include/linux/bits.h:6:19: warning:
	conversion from ‘long unsigned int’ to ‘u32’ {aka ‘unsigned int’}
	changes value from ‘18446744073441120320’ to ‘4026536000’ [-Woverflow]

since WC0_IS_C() is sign extended to 64 bit and then truncated.

Observed with gcc 7.4.0 and 8.3.0.

Guenter

>  /* mt8173 etc */
>  #define PERI_WK_CTRL1	0x4
>  #define WC1_IS_C(x)	(((x) & 0xf) << 26)  /* cycle debounce */
> @@ -30,7 +36,8 @@
>  #define SSC_SPM_INT_EN		BIT(1)
>  
>  enum ssusb_uwk_vers {
> -	SSUSB_UWK_V1 = 1,
> +	SSUSB_UWK_V0 = 0,
> +	SSUSB_UWK_V1,
>  	SSUSB_UWK_V2,
>  };
>  
> @@ -43,6 +50,11 @@ static void ssusb_wakeup_ip_sleep_set(struct ssusb_mtk *ssusb, bool enable)
>  	u32 reg, msk, val;
>  
>  	switch (ssusb->uwk_vers) {
> +	case SSUSB_UWK_V0:
> +		reg = ssusb->uwk_reg_base + PERI_WK_CTRL0;
> +		msk = WC0_IS_EN | WC0_IS_C(0xf) | WC0_IS_P;
> +		val = enable ? (WC0_IS_EN | WC0_IS_C(0x8)) : 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;

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

* Re: [PATCH v3 3/7] usb: mtu3: support ip-sleep wakeup for MT8183
  2019-09-11 18:44   ` Guenter Roeck
@ 2019-09-16  5:45     ` Chunfeng Yun
  0 siblings, 0 replies; 17+ messages in thread
From: Chunfeng Yun @ 2019-09-16  5:45 UTC (permalink / raw)
  To: Guenter Roeck
  Cc: Greg Kroah-Hartman, Rob Herring, Mark Rutland, devicetree,
	Mathias Nyman, linux-usb, linux-kernel, linux-mediatek,
	Matthias Brugger, linux-arm-kernel

On Wed, 2019-09-11 at 11:44 -0700, Guenter Roeck wrote:
> On Fri, Aug 30, 2019 at 03:40:50PM +0800, Chunfeng Yun wrote:
> > Support USB wakeup by ip-sleep mode for MT8183, it's similar to
> > MT8173
> > 
> > Signed-off-by: Chunfeng Yun <chunfeng.yun@mediatek.com>
> > ---
> > v3: changes micros define
> > 
> > v2: no changes
> > ---
> >  drivers/usb/mtu3/mtu3_host.c | 14 +++++++++++++-
> >  1 file changed, 13 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/usb/mtu3/mtu3_host.c b/drivers/usb/mtu3/mtu3_host.c
> > index c871b94f3e6f..4f8208885ebd 100644
> > --- a/drivers/usb/mtu3/mtu3_host.c
> > +++ b/drivers/usb/mtu3/mtu3_host.c
> > @@ -18,6 +18,12 @@
> >  #include "mtu3.h"
> >  #include "mtu3_dr.h"
> >  
> > +/* mt8183 etc */
> > +#define PERI_WK_CTRL0	0x20
> > +#define WC0_IS_C(x)	(((x) & 0xf) << 28)  /* cycle debounce */
> > +#define WC0_IS_P	BIT(12)	/* polarity */
> > +#define WC0_IS_EN	BIT(6)
> > +
> 
> For 64-bit builds, this results in:
> 
> drivers/usb/mtu3/mtu3_host.c: In function ‘ssusb_wakeup_ip_sleep_set’:
> ./include/linux/bits.h:6:19: warning:
> 	conversion from ‘long unsigned int’ to ‘u32’ {aka ‘unsigned int’}
> 	changes value from ‘18446744073441120320’ to ‘4026536000’ [-Woverflow]
> 
> since WC0_IS_C() is sign extended to 64 bit and then truncated.
Got it, thanks a lot

> 
> Observed with gcc 7.4.0 and 8.3.0.
> 
> Guenter
> 
> >  /* mt8173 etc */
> >  #define PERI_WK_CTRL1	0x4
> >  #define WC1_IS_C(x)	(((x) & 0xf) << 26)  /* cycle debounce */
> > @@ -30,7 +36,8 @@
> >  #define SSC_SPM_INT_EN		BIT(1)
> >  
> >  enum ssusb_uwk_vers {
> > -	SSUSB_UWK_V1 = 1,
> > +	SSUSB_UWK_V0 = 0,
> > +	SSUSB_UWK_V1,
> >  	SSUSB_UWK_V2,
> >  };
> >  
> > @@ -43,6 +50,11 @@ static void ssusb_wakeup_ip_sleep_set(struct ssusb_mtk *ssusb, bool enable)
> >  	u32 reg, msk, val;
> >  
> >  	switch (ssusb->uwk_vers) {
> > +	case SSUSB_UWK_V0:
> > +		reg = ssusb->uwk_reg_base + PERI_WK_CTRL0;
> > +		msk = WC0_IS_EN | WC0_IS_C(0xf) | WC0_IS_P;
> > +		val = enable ? (WC0_IS_EN | WC0_IS_C(0x8)) : 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;



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

end of thread, back to index

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-30  7:40 [PATCH v3 0/7] add support USB for MT8183 Chunfeng Yun
2019-08-30  7:40 ` [PATCH v3 1/7] dt-bindings: usb: mtu3: support USB wakeup " Chunfeng Yun
2019-09-02 13:39   ` Rob Herring
2019-08-30  7:40 ` [PATCH v3 2/7] dt-bindings: usb: mtk-xhci: " Chunfeng Yun
2019-09-02 13:39   ` Rob Herring
2019-08-30  7:40 ` [PATCH v3 3/7] usb: mtu3: support ip-sleep " Chunfeng Yun
2019-09-02  9:23   ` kbuild test robot
2019-09-11 18:44   ` Guenter Roeck
2019-09-16  5:45     ` Chunfeng Yun
2019-08-30  7:40 ` [PATCH v3 4/7] usb: mtk-xhci: " Chunfeng Yun
2019-09-02 11:58   ` kbuild test robot
2019-08-30  7:40 ` [PATCH v3 5/7] arm64: dts: mt8183: add usb and phy nodes Chunfeng Yun
2019-09-03 11:25   ` kbuild test robot
2019-08-30  7:40 ` [PATCH v3 6/7] arm64: dts: mt8183: enable USB remote wakeup Chunfeng Yun
2019-08-30  7:40 ` [PATCH v3 7/7] arm64: dts: mt8183: tune disconnect threshold of u2phy Chunfeng Yun
2019-09-04  1:54 ` [PATCH v3 0/7] add support USB for MT8183 Chunfeng Yun
2019-09-04  7:06   ` Greg Kroah-Hartman

LKML Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/lkml/0 lkml/git/0.git
	git clone --mirror https://lore.kernel.org/lkml/1 lkml/git/1.git
	git clone --mirror https://lore.kernel.org/lkml/2 lkml/git/2.git
	git clone --mirror https://lore.kernel.org/lkml/3 lkml/git/3.git
	git clone --mirror https://lore.kernel.org/lkml/4 lkml/git/4.git
	git clone --mirror https://lore.kernel.org/lkml/5 lkml/git/5.git
	git clone --mirror https://lore.kernel.org/lkml/6 lkml/git/6.git
	git clone --mirror https://lore.kernel.org/lkml/7 lkml/git/7.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 lkml lkml/ https://lore.kernel.org/lkml \
		linux-kernel@vger.kernel.org linux-kernel@archiver.kernel.org
	public-inbox-index lkml


Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-kernel


AGPL code for this site: git clone https://public-inbox.org/ public-inbox