Skip to contentSkip to conversation

arm64: dts: mediatek: Introduce MT8195 LAPTOP and IOT's USB configurations

PATCH In review Macpaul Lin 5 participants 14 messages Jan 5, 2023 – Feb 9, 2023

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

PATCH 1/3 arm64: dts: mediatek: Introduce MT8195 LAPTOP and IOT's USB configurations

Introduce the split MT8195 laptop and iot USB configurations. The hardware specifications for LAPTOP devices is different from IOT devices. The major differences include some hardware constrains for dual-role switch for USB controllers in different configurations, especially for power management and other control flows as well.

Here are some hardware specifiction differences listed:
1. LAPTOP (Cherry Tomato boards) don't support USB gadget (device mode).
2. IOT devices must support multiple gadget devices and host mode.
3. Dual-role switch is not fully supported. Only USB PORT0 support dual-role switch.
4. Power management is designed in primary and secondary dominator. For a dual-role port, the device controller is the primary controller for power management; while the host controller is the secondary. LAPTOP devices should remove device nodes for avoiding abnormal behavior.

This modifcation is to add USB configurations "mt8195-laptop-usb.dtsi" for LAPTOP devices, and add "mt8195-iot-usb.dtsi" for IOT devices.

To remove common USB configurations for mt8195.dtsi and switch includes dtsi these new files for the boards will come in next patch.

---
 .../boot/dts/mediatek/mt8195-iot-usb.dtsi     | 122 ++++++++++++++++++
 .../boot/dts/mediatek/mt8195-laptop-usb.dtsi  | 102 +++++++++++++++
 2 files changed, 224 insertions(+)
 create mode 100644 arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi
 create mode 100644 arch/arm64/boot/dts/mediatek/mt8195-laptop-usb.dtsi
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +122 -0
new file mode 100644
index 000000000000..f9bd79542044
@@ -0,0 +1,122 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2022 MediaTek Inc.
+ */
+
+#include "mt8195.dtsi"
+
+/ {
+	soc {
+		ssusb: ssusb@11200000 {
+			compatible ="mediatek,mt8183-mtu3", "mediatek,mtu3";
+			reg = <0 0x11201000 0 0x2dff>,
+			      <0 0x11203e00 0 0x0100>;
+			reg-names = "mac", "ippc";
+			interrupts = <GIC_SPI 128 IRQ_TYPE_LEVEL_HIGH 0>;
+			phys = <&u2port0 PHY_TYPE_USB2>,
+			       <&u3port0 PHY_TYPE_USB3>;
+			clocks = <&infracfg_ao CLK_INFRA_AO_SSUSB>,
+				 <&topckgen CLK_TOP_SSUSB_REF>,
+				 <&infracfg_ao CLK_INFRA_AO_SSUSB_XHCI>;
+			clock-names = "sys_ck", "ref_ck", "mcu_ck";
+			#address-cells = <2>;
+			#size-cells = <2>;
+			ranges;
+			status = "disabled";
+
+			xhci0: xhci@11200000 {
+				compatible = "mediatek,mt8195-xhci",
+					     "mediatek,mtk-xhci";
+				reg = <0 0x11200000 0 0x1000>;
+				reg-names = "mac";
+				interrupts = <GIC_SPI 129 IRQ_TYPE_LEVEL_HIGH 0>;
+				assigned-clocks = <&topckgen CLK_TOP_USB_TOP>,
+						  <&topckgen CLK_TOP_SSUSB_XHCI>;
+				assigned-clock-parents = <&topckgen CLK_TOP_UNIVPLL_D5_D4>,
+							 <&topckgen CLK_TOP_UNIVPLL_D5_D4>;
+				clocks = <&infracfg_ao CLK_INFRA_AO_SSUSB>,
+					 <&infracfg_ao CLK_INFRA_AO_SSUSB_XHCI>,
+					 <&topckgen CLK_TOP_SSUSB_REF>,
+					 <&apmixedsys CLK_APMIXED_USB1PLL>;
+				clock-names = "sys_ck", "xhci_ck", "ref_ck", "mcu_ck";
+				status = "disabled";
+			};
+		};
+
+		xhci1: xhci1@11290000 {
+			compatible = "mediatek,mt8195-xhci",
+				     "mediatek,mtk-xhci";
+			reg = <0 0x11290000 0 0x1000>,
+			      <0 0x11293e00 0 0x0100>;
+			reg-names = "mac", "ippc";
+			interrupts = <GIC_SPI 530 IRQ_TYPE_LEVEL_HIGH 0>;
+			phys = <&u2port1 PHY_TYPE_USB2>,
+			       <&u3port1 PHY_TYPE_USB3>;
+			assigned-clocks = <&topckgen CLK_TOP_USB_TOP_1P>,
+					  <&topckgen CLK_TOP_SSUSB_XHCI_1P>;
+			assigned-clock-parents = <&topckgen CLK_TOP_UNIVPLL_D5_D4>,
+						 <&topckgen CLK_TOP_UNIVPLL_D5_D4>;
+			clocks = <&pericfg_ao CLK_PERI_AO_SSUSB_1P_BUS>,
+				 <&pericfg_ao CLK_PERI_AO_SSUSB_1P_XHCI>,
+				 <&topckgen CLK_TOP_SSUSB_P1_REF>,
+				 <&apmixedsys CLK_APMIXED_USB1PLL>;
+			clock-names = "sys_ck", "xhci_ck", "ref_ck", "mcu_ck";
+			status = "disabled";
+		};
+
+		ssusb1: usb1@112a1000 {
+			compatible = "mediatek,mt8183-mtu3", "mediatek,mtu3";
+			reg = <0 0x112a1000 0 0x2dff>,
+				  <0 0x112a3e00 0 0x0100>;
+			reg-names = "mac", "ippc";
+			interrupts = <GIC_SPI 532 IRQ_TYPE_LEVEL_HIGH 0>;
+			phys = <&u2port2 PHY_TYPE_USB2>;
+			assigned-clocks = <&topckgen CLK_TOP_USB_TOP_2P>;
+			assigned-clock-parents = <&topckgen CLK_TOP_UNIVPLL_D5_D4>;
+			clocks = <&pericfg_ao CLK_PERI_AO_SSUSB_2P_BUS>,
+				 <&topckgen CLK_TOP_SSUSB_P2_REF>,
+				 <&pericfg_ao CLK_PERI_AO_SSUSB_2P_XHCI>;
+			clock-names = "sys_ck", "ref_ck", "mcu_ck";
+			mediatek,syscon-wakeup = <&pericfg 0x400 4>;
+			#address-cells = <2>;
+			#size-cells = <2>;
+			ranges;
+			status = "disabled";
+
+			xhci2: xhci2@112a0000 {
+				compatible = "mediatek,mt8195-xhci","mediatek,mtk-xhci";
+				reg = <0 0x112a0000 0 0x1000>;
+				reg-names = "mac";
+				interrupts-extended = <&gic GIC_SPI 533 IRQ_TYPE_LEVEL_HIGH 0>,
+					      <&pio 220 IRQ_TYPE_EDGE_FALLING>;
+				assigned-clocks = <&topckgen CLK_TOP_SSUSB_XHCI_2P>;
+				assigned-clock-parents = <&topckgen CLK_TOP_UNIVPLL_D5_D4>;
+				clocks = <&pericfg_ao CLK_PERI_AO_SSUSB_2P_XHCI>;
+				clock-names = "sys_ck";
+				status = "disabled";
+			};
+		};
+
+		xhci3: xhci3@112b0000 {
+			compatible = "mediatek,mt8195-xhci",
+				     "mediatek,mtk-xhci";
+			reg = <0 0x112b0000 0 0x1000>,
+			      <0 0x112b3e00 0 0x0100>;
+			reg-names = "mac", "ippc";
+			interrupts = <GIC_SPI 536 IRQ_TYPE_LEVEL_HIGH 0>;
+			phys = <&u2port3 PHY_TYPE_USB2>;
+			assigned-clocks = <&topckgen CLK_TOP_USB_TOP_3P>,
+					  <&topckgen CLK_TOP_SSUSB_XHCI_3P>;
+			assigned-clock-parents = <&topckgen CLK_TOP_UNIVPLL_D5_D4>,
+						 <&topckgen CLK_TOP_UNIVPLL_D5_D4>;
+			clocks = <&pericfg_ao CLK_PERI_AO_SSUSB_3P_BUS>,
+				 <&pericfg_ao CLK_PERI_AO_SSUSB_3P_XHCI>,
+				 <&topckgen CLK_TOP_SSUSB_P3_REF>;
+			clock-names = "sys_ck", "xhci_ck", "ref_ck";
+			mediatek,syscon-wakeup = <&pericfg 0x400 106>;
+			wakeup-source;
+			usb2-lpm-disable;
+			status = "disabled";
+		};
+	};
+};
arch/arm64/boot/dts/mediatek/mt8195-laptop-usb.dtsi new file +102 -0

102 lines not on this page · raw message

Signature · 1 line
2.18.0
#1 lore raw

PATCH 2/3 arm64: dts: mediatek: switch MT8195 boards into different USB configurations

This modification includes
1. Remove common USB configurations in mt8195.dtsi.
2. Switch include dtsi "mt8195-laptop-usb.dtsi" for LAPTOP devices.
- mt8195-cherry.dtsi
- mt8195-evb.dts
3. Switch include dtsi "mt8195-iot-usb.dtsi" for IOT devices.
- mt8195-demo.dts

---
 .../boot/dts/mediatek/mt8195-cherry.dtsi      |  2 +-
 arch/arm64/boot/dts/mediatek/mt8195-demo.dts  |  2 +-
 arch/arm64/boot/dts/mediatek/mt8195-evb.dts   |  2 +-
 arch/arm64/boot/dts/mediatek/mt8195.dtsi      | 97 -------------------
 4 files changed, 3 insertions(+), 100 deletions(-)
arch/arm64/boot/dts/mediatek/mt8195-cherry.dtsi +1 -1
index 560103e29017..a28da16d1d74 100644
@@ -5,7 +5,7 @@
 
 #include <dt-bindings/gpio/gpio.h>
 #include <dt-bindings/spmi/spmi.h>
-#include "mt8195.dtsi"
+#include "mt8195-laptop-usb.dtsi"
 #include "mt6359.dtsi"
 
 / {
arch/arm64/boot/dts/mediatek/mt8195-demo.dts +1 -1
index dec85d254838..07a864cb8b54 100644
@@ -5,7 +5,7 @@
  */
 /dts-v1/;
 
-#include "mt8195.dtsi"
+#include "mt8195-iot-usb.dtsi"
 #include "mt6359.dtsi"
 
 #include <dt-bindings/gpio/gpio.h>
arch/arm64/boot/dts/mediatek/mt8195-evb.dts +1 -1
index 690dc7717f2c..c7026c0f2ca9 100644
@@ -4,7 +4,7 @@
  * Author: Seiya Wang <[email protected]>
  */
 /dts-v1/;
-#include "mt8195.dtsi"
+#include "mt8195-laptop-usb.dtsi"
 
 / {
 	model = "MediaTek MT8195 evaluation board";
arch/arm64/boot/dts/mediatek/mt8195.dtsi +0 -97

109 lines not on this page · raw message

Signature · 1 line
2.18.0
#2 lore raw

PATCH 3/3 arm64: dts: mediatek: enable USB device port for mt8195-demo board

In reply to Macpaul Lin

1. Enable USB device port (USB port0).
2. Enable u2 speed for other USB HOST (USB port1/2/3).
3. Configure mt6360 (TYPEC) related pinctrls.

Note: Full dual-role switch capability requires TYPEC MUX driver and dts update will be send in separate patches.

---
 arch/arm64/boot/dts/mediatek/mt8195-demo.dts | 51 ++++++++++++++++++++
 1 file changed, 51 insertions(+)
arch/arm64/boot/dts/mediatek/mt8195-demo.dts +51 -0
index 07a864cb8b54..207bb5f4c58f 100644
@@ -12,6 +12,7 @@
 #include <dt-bindings/input/input.h>
 #include <dt-bindings/pinctrl/mt8195-pinfunc.h>
 #include <dt-bindings/regulator/mediatek,mt6360-regulator.h>
+#include <dt-bindings/usb/pd.h>
 
 / {
 	model = "MediaTek MT8195 demo board";
@@ -380,6 +381,22 @@
 		};
 	};
 
+	mt6360_pins: mt6360-pins {
+		pins {
+			pinmux = <PINMUX_GPIO100__FUNC_GPIO100>,
+				 <PINMUX_GPIO101__FUNC_GPIO101>;
+			input-enable;
+			bias-pull-up;
+		};
+	};
+
+	u3_p0_vbus: u3_p0vbusdefault {
+		pins_cmd_dat {
+			pinmux = <PINMUX_GPIO63__FUNC_VBUSVALID>;
+			input-enable;
+		};
+	};
+
 	uart0_pins: uart0-pins {
 		pins {
 			pinmux = <PINMUX_GPIO98__FUNC_UTXD0>,
@@ -393,6 +410,14 @@
 				 <PINMUX_GPIO103__FUNC_URXD1>;
 		};
 	};
+
+	usb_otg_vbus: usb-otg-vbus-regulator {
+		compatible = "regulator-fixed";
+		regulator-name = "otg-vbus";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		enable-active-high;
+	};
 };
 
 
@@ -412,6 +437,22 @@
 	status = "okay";
 };
 
+&u3port0 {
+	status = "okay";
+};
+
+&u2port1 {
+	status = "okay";
+};
+
+&u2port2 {
+	status = "okay";
+};
+
+&u2port3 {
+	status = "okay";
+};
+
 &u3phy0 {
 	status = "okay";
 };
@@ -428,6 +469,16 @@
 	status = "okay";
 };
 
+&ssusb {
+	pinctrl-names = "default";
+	pinctrl-0 = <&u3_p0_vbus>;
+	vusb33-supply = <&mt6359_vusb_ldo_reg>;
+	dr_mode = "otg";
+	mediatek,usb3-drd;
+	usb-role-switch;
+	status = "okay";
+};
+
 &xhci0 {
 	vusb33-supply = <&mt6359_vusb_ldo_reg>;
 	vbus-supply = <&otg_vbus_regulator>;
Signature · 1 line
2.18.0
#3 lore raw

Re: [PATCH 3/3] arm64: dts: mediatek: enable USB device port for mt8195-demo board

Quoted 28 lines · Macpaul Lin

1. Enable USB device port (USB port0).
2. Enable u2 speed for other USB HOST (USB port1/2/3).
3. Configure mt6360 (TYPEC) related pinctrls.

Note: Full dual-role switch capability requires TYPEC MUX driver and dts update will be send in separate patches.

---
 arch/arm64/boot/dts/mediatek/mt8195-demo.dts | 51 ++++++++++++++++++++
 1 file changed, 51 insertions(+)
arch/arm64/boot/dts/mediatek/mt8195-demo.dts +1 -0
index 07a864cb8b54..207bb5f4c58f 100644
@@ -12,6 +12,7 @@
 #include <dt-bindings/input/input.h>
 #include <dt-bindings/pinctrl/mt8195-pinfunc.h>
 #include <dt-bindings/regulator/mediatek,mt6360-regulator.h>
+#include <dt-bindings/usb/pd.h>
 
 / {
 	model = "MediaTek MT8195 demo board";
@@ -380,6 +381,22 @@
 		};
 	};
 

arch/arm64/boot/dts/mediatek/mt8195-demo.dts line 393

Quoted 10 lines
arch/arm64/boot/dts/mediatek/mt8195-demo.dts +10 -0
+	mt6360_pins: mt6360-pins {
+		pins {
+			pinmux = <PINMUX_GPIO100__FUNC_GPIO100>,
+				 <PINMUX_GPIO101__FUNC_GPIO101>;
+			input-enable;
+			bias-pull-up;
+		};
+	};
+
+	u3_p0_vbus: u3_p0vbusdefault {

No underscores in node names. Also does not look correct naming. Please run make dtbs_check (see Documentation/devicetree/bindings/writing-schema.rst for instructions).

arch/arm64/boot/dts/mediatek/mt8195-demo.dts line 394

Quoted 1 line
arch/arm64/boot/dts/mediatek/mt8195-demo.dts +1 -0
+		pins_cmd_dat {

Same problem.

Best regards,
Krzysztof

#4 lore raw

Re: [PATCH 3/3] arm64: dts: mediatek: enable USB device port for mt8195-demo board

Quoted 29 lines · Krzysztof Kozlowski
Quoted 28 lines · Macpaul Lin

1. Enable USB device port (USB port0).
2. Enable u2 speed for other USB HOST (USB port1/2/3).
3. Configure mt6360 (TYPEC) related pinctrls.

Note: Full dual-role switch capability requires TYPEC MUX driver and dts update will be send in separate patches.

---
  arch/arm64/boot/dts/mediatek/mt8195-demo.dts | 51 ++++++++++++++++++++
  1 file changed, 51 insertions(+)
arch/arm64/boot/dts/mediatek/mt8195-demo.dts +1 -0
index 07a864cb8b54..207bb5f4c58f 100644
@@ -12,6 +12,7 @@
  #include <dt-bindings/input/input.h>
  #include <dt-bindings/pinctrl/mt8195-pinfunc.h>
  #include <dt-bindings/regulator/mediatek,mt6360-regulator.h>
+#include <dt-bindings/usb/pd.h>
 
  / {
  	model = "MediaTek MT8195 demo board";
@@ -380,6 +381,22 @@
  		};
  	};
 
Quoted 14 lines

arch/arm64/boot/dts/mediatek/mt8195-demo.dts line 393

Quoted 10 lines
arch/arm64/boot/dts/mediatek/mt8195-demo.dts +10 -0
+	mt6360_pins: mt6360-pins {
+		pins {
+			pinmux = <PINMUX_GPIO100__FUNC_GPIO100>,
+				 <PINMUX_GPIO101__FUNC_GPIO101>;
+			input-enable;
+			bias-pull-up;
+		};
+	};
+
+	u3_p0_vbus: u3_p0vbusdefault {

No underscores in node names. Also does not look correct naming. Please run make dtbs_check (see Documentation/devicetree/bindings/writing-schema.rst for instructions).

Thanks for the suggest.
I'm trying to request IT to setup for the environment for supporting "make dtbs_check". This should be fix in next patch.

Quoted 4 lines

arch/arm64/boot/dts/mediatek/mt8195-demo.dts line 394

Quoted 1 line
arch/arm64/boot/dts/mediatek/mt8195-demo.dts +1 -0
+		pins_cmd_dat {

Same problem.

Got it.

Quoted 4 lines

Best regards,
Krzysztof

Thanks!
Macpaul Lin

maintainer
#5 lore raw

Re: [PATCH 3/3] arm64: dts: mediatek: enable USB device port for mt8195-demo board

In reply to Macpaul Lin
Quoted 86 lines · Macpaul Lin

1. Enable USB device port (USB port0).
2. Enable u2 speed for other USB HOST (USB port1/2/3).
3. Configure mt6360 (TYPEC) related pinctrls.

Note: Full dual-role switch capability requires TYPEC MUX driver and dts update will be send in separate patches.

---
  arch/arm64/boot/dts/mediatek/mt8195-demo.dts | 51 ++++++++++++++++++++
  1 file changed, 51 insertions(+)
arch/arm64/boot/dts/mediatek/mt8195-demo.dts +41 -0
index 07a864cb8b54..207bb5f4c58f 100644
@@ -12,6 +12,7 @@
  #include <dt-bindings/input/input.h>
  #include <dt-bindings/pinctrl/mt8195-pinfunc.h>
  #include <dt-bindings/regulator/mediatek,mt6360-regulator.h>
+#include <dt-bindings/usb/pd.h>
 
  / {
  	model = "MediaTek MT8195 demo board";
@@ -380,6 +381,22 @@
  		};
  	};
 
+	mt6360_pins: mt6360-pins {
+		pins {
+			pinmux = <PINMUX_GPIO100__FUNC_GPIO100>,
+				 <PINMUX_GPIO101__FUNC_GPIO101>;
+			input-enable;
+			bias-pull-up;
+		};
+	};
+
+	u3_p0_vbus: u3_p0vbusdefault {
+		pins_cmd_dat {
+			pinmux = <PINMUX_GPIO63__FUNC_VBUSVALID>;
+			input-enable;
+		};
+	};
+
  	uart0_pins: uart0-pins {
  		pins {
  			pinmux = <PINMUX_GPIO98__FUNC_UTXD0>,
@@ -393,6 +410,14 @@
  				 <PINMUX_GPIO103__FUNC_URXD1>;
  		};
  	};
+
+	usb_otg_vbus: usb-otg-vbus-regulator {
+		compatible = "regulator-fixed";
+		regulator-name = "otg-vbus";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		enable-active-high;
+	};
  };
 
 
@@ -412,6 +437,22 @@
  	status = "okay";
  };
 
+&u3port0 {
+	status = "okay";
+};
+
+&u2port1 {
+	status = "okay";
+};
+
+&u2port2 {
+	status = "okay";
+};
+
+&u2port3 {
+	status = "okay";
+};
+
  &u3phy0 {
  	status = "okay";
  };

arch/arm64/boot/dts/mediatek/mt8195-demo.dts line 477

Quoted 9 lines
arch/arm64/boot/dts/mediatek/mt8195-demo.dts +6 -0
@@ -428,6 +469,16 @@
  	status = "okay";
  };
 
+&ssusb {
+	pinctrl-names = "default";
+	pinctrl-0 = <&u3_p0_vbus>;
+	vusb33-supply = <&mt6359_vusb_ldo_reg>;
+	dr_mode = "otg";
+	mediatek,usb3-drd;

What it that used for?
git grep didn't gave me any hit.

Regards,
Matthias

Quoted 7 lines
arch/arm64/boot/dts/mediatek/mt8195-demo.dts +4 -0
+	usb-role-switch;
+	status = "okay";
+};
+
  &xhci0 {
  	vusb33-supply = <&mt6359_vusb_ldo_reg>;
  	vbus-supply = <&otg_vbus_regulator>;
#6 lore raw

Re: [PATCH 3/3] arm64: dts: mediatek: enable USB device port for mt8195-demo board

Quoted 94 lines · Matthias Brugger
Quoted 92 lines · Macpaul Lin

1. Enable USB device port (USB port0).
2. Enable u2 speed for other USB HOST (USB port1/2/3).
3. Configure mt6360 (TYPEC) related pinctrls.

Note: Full dual-role switch capability requires TYPEC MUX driver and dts
update will be send in separate patches.

---
  arch/arm64/boot/dts/mediatek/mt8195-demo.dts | 51
++++++++++++++++++++
  1 file changed, 51 insertions(+)
arch/arm64/boot/dts/mediatek/mt8195-demo.dts +41 -0
index 07a864cb8b54..207bb5f4c58f 100644
@@ -12,6 +12,7 @@
  #include <dt-bindings/input/input.h>
  #include <dt-bindings/pinctrl/mt8195-pinfunc.h>
  #include <dt-bindings/regulator/mediatek,mt6360-regulator.h>
+#include <dt-bindings/usb/pd.h>
 
  / {
  	model = "MediaTek MT8195 demo board";
@@ -380,6 +381,22 @@
  		};
  	};
 
+	mt6360_pins: mt6360-pins {
+		pins {
+			pinmux = <PINMUX_GPIO100__FUNC_GPIO100>,
+				 <PINMUX_GPIO101__FUNC_GPIO101>;
+			input-enable;
+			bias-pull-up;
+		};
+	};
+
+	u3_p0_vbus: u3_p0vbusdefault {
+		pins_cmd_dat {
+			pinmux = <PINMUX_GPIO63__FUNC_VBUSVALID>;
+			input-enable;
+		};
+	};
+
  	uart0_pins: uart0-pins {
  		pins {
  			pinmux = <PINMUX_GPIO98__FUNC_UTXD0>,
@@ -393,6 +410,14 @@
  				 <PINMUX_GPIO103__FUNC_URXD1>;
  		};
  	};
+
+	usb_otg_vbus: usb-otg-vbus-regulator {
+		compatible = "regulator-fixed";
+		regulator-name = "otg-vbus";
+		regulator-min-microvolt = <5000000>;
+		regulator-max-microvolt = <5000000>;
+		enable-active-high;
+	};
  };
 
 
@@ -412,6 +437,22 @@
  	status = "okay";
  };
 
+&u3port0 {
+	status = "okay";
+};
+
+&u2port1 {
+	status = "okay";
+};
+
+&u2port2 {
+	status = "okay";
+};
+
+&u2port3 {
+	status = "okay";
+};
+
  &u3phy0 {
  	status = "okay";
  };
@@ -428,6 +469,16 @@
  	status = "okay";
  };
 
Quoted 9 lines

arch/arm64/boot/dts/mediatek/mt8195-demo.dts line 477

Quoted 6 lines
arch/arm64/boot/dts/mediatek/mt8195-demo.dts +6 -0
+&ssusb {
+	pinctrl-names = "default";
+	pinctrl-0 = <&u3_p0_vbus>;
+	vusb33-supply = <&mt6359_vusb_ldo_reg>;
+	dr_mode = "otg";
+	mediatek,usb3-drd;

What it that used for?
git grep didn't gave me any hit.

"mediatek,usb3-drd;" can be now removed,

the patch sent out on Jul 8 2022:
"683ff6e485f1 usb: mtu3: check capability of usb3 dual role" already removed the property.

Thanks a lot

Quoted 11 lines

Regards,
Matthias

Quoted 7 lines
arch/arm64/boot/dts/mediatek/mt8195-demo.dts +4 -0
+	usb-role-switch;
+	status = "okay";
+};
+
  &xhci0 {
  	vusb33-supply = <&mt6359_vusb_ldo_reg>;
  	vbus-supply = <&otg_vbus_regulator>;
#7 lore raw
In reply to Macpaul Lin
Quoted 37 lines · Macpaul Lin

Introduce the split MT8195 laptop and iot USB configurations. The hardware specifications for LAPTOP devices is different from IOT devices. The major differences include some hardware constrains for dual-role switch for USB controllers in different configurations, especially for power management and other control flows as well.

Here are some hardware specifiction differences listed:
1. LAPTOP (Cherry Tomato boards) don't support USB gadget (device mode).
2. IOT devices must support multiple gadget devices and host mode.
3. Dual-role switch is not fully supported. Only USB PORT0 support dual-role switch.
4. Power management is designed in primary and secondary dominator. For a dual-role port, the device controller is the primary controller for power management; while the host controller is the secondary. LAPTOP devices should remove device nodes for avoiding abnormal behavior.

This modifcation is to add USB configurations "mt8195-laptop-usb.dtsi" for LAPTOP devices, and add "mt8195-iot-usb.dtsi" for IOT devices.

To remove common USB configurations for mt8195.dtsi and switch includes dtsi these new files for the boards will come in next patch.

---
 .../boot/dts/mediatek/mt8195-iot-usb.dtsi     | 122 ++++++++++++++++++
 .../boot/dts/mediatek/mt8195-laptop-usb.dtsi  | 102 +++++++++++++++
 2 files changed, 224 insertions(+)
 create mode 100644 arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi
 create mode 100644 arch/arm64/boot/dts/mediatek/mt8195-laptop-usb.dtsi
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +0 -0
new file mode 100644
index 000000000000..f9bd79542044

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi line 10

Quoted 10 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +10 -0
@@ -0,0 +1,122 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2022 MediaTek Inc.
+ */
+
+#include "mt8195.dtsi"
+
+/ {
+	soc {
+		ssusb: ssusb@11200000 {

Node name: usb

Quoted 26 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +26 -0
+			compatible ="mediatek,mt8183-mtu3", "mediatek,mtu3";
+			reg = <0 0x11201000 0 0x2dff>,
+			      <0 0x11203e00 0 0x0100>;
+			reg-names = "mac", "ippc";
+			interrupts = <GIC_SPI 128 IRQ_TYPE_LEVEL_HIGH 0>;
+			phys = <&u2port0 PHY_TYPE_USB2>,
+			       <&u3port0 PHY_TYPE_USB3>;
+			clocks = <&infracfg_ao CLK_INFRA_AO_SSUSB>,
+				 <&topckgen CLK_TOP_SSUSB_REF>,
+				 <&infracfg_ao CLK_INFRA_AO_SSUSB_XHCI>;
+			clock-names = "sys_ck", "ref_ck", "mcu_ck";
+			#address-cells = <2>;
+			#size-cells = <2>;
+			ranges;
+			status = "disabled";
+
+			xhci0: xhci@11200000 {
+				compatible = "mediatek,mt8195-xhci",
+					     "mediatek,mtk-xhci";
+				reg = <0 0x11200000 0 0x1000>;
+				reg-names = "mac";
+				interrupts = <GIC_SPI 129 IRQ_TYPE_LEVEL_HIGH 0>;
+				assigned-clocks = <&topckgen CLK_TOP_USB_TOP>,
+						  <&topckgen CLK_TOP_SSUSB_XHCI>;
+				assigned-clock-parents = <&topckgen CLK_TOP_UNIVPLL_D5_D4>,
+							 <&topckgen CLK_TOP_UNIVPLL_D5_D4>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi line 46

Quoted 10 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +10 -0
+				clocks = <&infracfg_ao CLK_INFRA_AO_SSUSB>,
+					 <&infracfg_ao CLK_INFRA_AO_SSUSB_XHCI>,
+					 <&topckgen CLK_TOP_SSUSB_REF>,
+					 <&apmixedsys CLK_APMIXED_USB1PLL>;
+				clock-names = "sys_ck", "xhci_ck", "ref_ck", "mcu_ck";
+				status = "disabled";
+			};
+		};
+
+		xhci1: xhci1@11290000 {

Node names should be generic, so just "xhci"
https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html#generic-names-recommendation

Quoted 11 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +11 -0
+			compatible = "mediatek,mt8195-xhci",
+				     "mediatek,mtk-xhci";
+			reg = <0 0x11290000 0 0x1000>,
+			      <0 0x11293e00 0 0x0100>;
+			reg-names = "mac", "ippc";
+			interrupts = <GIC_SPI 530 IRQ_TYPE_LEVEL_HIGH 0>;
+			phys = <&u2port1 PHY_TYPE_USB2>,
+			       <&u3port1 PHY_TYPE_USB3>;
+			assigned-clocks = <&topckgen CLK_TOP_USB_TOP_1P>,
+					  <&topckgen CLK_TOP_SSUSB_XHCI_1P>;
+			assigned-clock-parents = <&topckgen CLK_TOP_UNIVPLL_D5_D4>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi line 67

Quoted 10 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +10 -0
+						 <&topckgen CLK_TOP_UNIVPLL_D5_D4>;
+			clocks = <&pericfg_ao CLK_PERI_AO_SSUSB_1P_BUS>,
+				 <&pericfg_ao CLK_PERI_AO_SSUSB_1P_XHCI>,
+				 <&topckgen CLK_TOP_SSUSB_P1_REF>,
+				 <&apmixedsys CLK_APMIXED_USB1PLL>;
+			clock-names = "sys_ck", "xhci_ck", "ref_ck", "mcu_ck";
+			status = "disabled";
+		};
+
+		ssusb1: usb1@112a1000 {

usb

Quoted 9 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +9 -0
+			compatible = "mediatek,mt8183-mtu3", "mediatek,mtu3";
+			reg = <0 0x112a1000 0 0x2dff>,
+				  <0 0x112a3e00 0 0x0100>;
+			reg-names = "mac", "ippc";
+			interrupts = <GIC_SPI 532 IRQ_TYPE_LEVEL_HIGH 0>;
+			phys = <&u2port2 PHY_TYPE_USB2>;
+			assigned-clocks = <&topckgen CLK_TOP_USB_TOP_2P>;
+			assigned-clock-parents = <&topckgen CLK_TOP_UNIVPLL_D5_D4>;
+			clocks = <&pericfg_ao CLK_PERI_AO_SSUSB_2P_BUS>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi line 86

Quoted 10 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +10 -0
+				 <&topckgen CLK_TOP_SSUSB_P2_REF>,
+				 <&pericfg_ao CLK_PERI_AO_SSUSB_2P_XHCI>;
+			clock-names = "sys_ck", "ref_ck", "mcu_ck";
+			mediatek,syscon-wakeup = <&pericfg 0x400 4>;
+			#address-cells = <2>;
+			#size-cells = <2>;
+			ranges;
+			status = "disabled";
+
+			xhci2: xhci2@112a0000 {

xhci

Quoted 4 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +4 -0
+				compatible = "mediatek,mt8195-xhci","mediatek,mtk-xhci";
+				reg = <0 0x112a0000 0 0x1000>;
+				reg-names = "mac";
+				interrupts-extended = <&gic GIC_SPI 533 IRQ_TYPE_LEVEL_HIGH 0>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi line 100

Quoted 10 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +10 -0
+					      <&pio 220 IRQ_TYPE_EDGE_FALLING>;
+				assigned-clocks = <&topckgen CLK_TOP_SSUSB_XHCI_2P>;
+				assigned-clock-parents = <&topckgen CLK_TOP_UNIVPLL_D5_D4>;
+				clocks = <&pericfg_ao CLK_PERI_AO_SSUSB_2P_XHCI>;
+				clock-names = "sys_ck";
+				status = "disabled";
+			};
+		};
+
+		xhci3: xhci3@112b0000 {

xhci

Quoted 10 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +10 -0
+			compatible = "mediatek,mt8195-xhci",
+				     "mediatek,mtk-xhci";
+			reg = <0 0x112b0000 0 0x1000>,
+			      <0 0x112b3e00 0 0x0100>;
+			reg-names = "mac", "ippc";
+			interrupts = <GIC_SPI 536 IRQ_TYPE_LEVEL_HIGH 0>;
+			phys = <&u2port3 PHY_TYPE_USB2>;
+			assigned-clocks = <&topckgen CLK_TOP_USB_TOP_3P>,
+					  <&topckgen CLK_TOP_SSUSB_XHCI_3P>;
+			assigned-clock-parents = <&topckgen CLK_TOP_UNIVPLL_D5_D4>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi line 120

Quoted 10 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +10 -0
+						 <&topckgen CLK_TOP_UNIVPLL_D5_D4>;
+			clocks = <&pericfg_ao CLK_PERI_AO_SSUSB_3P_BUS>,
+				 <&pericfg_ao CLK_PERI_AO_SSUSB_3P_XHCI>,
+				 <&topckgen CLK_TOP_SSUSB_P3_REF>;
+			clock-names = "sys_ck", "xhci_ck", "ref_ck";
+			mediatek,syscon-wakeup = <&pericfg 0x400 106>;
+			wakeup-source;
+			usb2-lpm-disable;
+			status = "disabled";
+		};

Best regards,
Krzysztof

#8 lore raw
Quoted 78 lines · Krzysztof Kozlowski
Quoted 52 lines · Macpaul Lin

Introduce the split MT8195 laptop and iot USB configurations. The hardware specifications for LAPTOP devices is different from IOT
devices. The major differences include some hardware constrains for dual-role switch for USB controllers in different configurations, especially for power management and other control flows as well.

Here are some hardware specifiction differences listed:
1. LAPTOP (Cherry Tomato boards) don't support USB gadget (device
mode).
2. IOT devices must support multiple gadget devices and host
mode.
3. Dual-role switch is not fully supported. Only USB PORT0
support
dual-role switch.
4. Power management is designed in primary and secondary
dominator.
For a dual-role port, the device controller is the primary
controller
for power management; while the host controller is the
secondary.
LAPTOP devices should remove device nodes for avoiding
abnormal
behavior.

This modifcation is to add USB configurations "mt8195-laptop- usb.dtsi"
for LAPTOP devices, and add "mt8195-iot-usb.dtsi" for IOT devices.

To remove common USB configurations for mt8195.dtsi and switch includes
dtsi these new files for the boards will come in next patch.

---
 .../boot/dts/mediatek/mt8195-iot-usb.dtsi     | 122
++++++++++++++++++
 .../boot/dts/mediatek/mt8195-laptop-usb.dtsi  | 102
+++++++++++++++
 2 files changed, 224 insertions(+)
 create mode 100644 arch/arm64/boot/dts/mediatek/mt8195-iot-
usb.dtsi
 create mode 100644 arch/arm64/boot/dts/mediatek/mt8195-laptop-

usb.dtsi

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +0 -0
new file mode 100644
index 000000000000..f9bd79542044

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi line 10

Quoted 10 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +10 -0
@@ -0,0 +1,122 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2022 MediaTek Inc.
+ */
+
+#include "mt8195.dtsi"
+
+/ {
+	soc {
+		ssusb: ssusb@11200000 {

Node name: usb

Quoted 12 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+			compatible ="mediatek,mt8183-mtu3",

"mediatek,mtu3";

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +4 -0
+			reg = <0 0x11201000 0 0x2dff>,
+			      <0 0x11203e00 0 0x0100>;
+			reg-names = "mac", "ippc";
+			interrupts = <GIC_SPI 128 IRQ_TYPE_LEVEL_HIGH

0>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +5 -0
+			phys = <&u2port0 PHY_TYPE_USB2>,
+			       <&u3port0 PHY_TYPE_USB3>;
+			clocks = <&infracfg_ao CLK_INFRA_AO_SSUSB>,
+				 <&topckgen CLK_TOP_SSUSB_REF>,
+				 <&infracfg_ao
Quoted 8 lines

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi line 27

Quoted 8 lines

CLK_INFRA_AO_SSUSB_XHCI>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +7 -0
+			clock-names = "sys_ck", "ref_ck", "mcu_ck";
+			#address-cells = <2>;
+			#size-cells = <2>;
+			ranges;
+			status = "disabled";
+
+			xhci0: xhci@11200000 {

s/xhci/usb

Quoted 22 lines
Quoted 22 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +5 -0
+				compatible = "mediatek,mt8195-xhci",
+					     "mediatek,mtk-xhci";
+				reg = <0 0x11200000 0 0x1000>;
+				reg-names = "mac";
+				interrupts = <GIC_SPI 129

IRQ_TYPE_LEVEL_HIGH 0>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+				assigned-clocks = <&topckgen

CLK_TOP_USB_TOP>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+						  <&topckgen

CLK_TOP_SSUSB_XHCI>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+				assigned-clock-parents = <&topckgen

CLK_TOP_UNIVPLL_D5_D4>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+							 <&topckgen

CLK_TOP_UNIVPLL_D5_D4>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+				clocks = <&infracfg_ao

CLK_INFRA_AO_SSUSB>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+					 <&infracfg_ao

CLK_INFRA_AO_SSUSB_XHCI>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +2 -0
+					 <&topckgen CLK_TOP_SSUSB_REF>,
+					 <&apmixedsys

CLK_APMIXED_USB1PLL>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+				clock-names = "sys_ck", "xhci_ck",
Quoted 8 lines

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi line 46

Quoted 6 lines

"ref_ck", "mcu_ck";

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +5 -0
+				status = "disabled";
+			};
+		};
+
+		xhci1: xhci1@11290000 {

Node names should be generic, so just "xhci"

also use "usb", no generic name "xhci" in the following spec

Quoted 1 line

https://urldefense.com/v3/__https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html*generic-names-recommendation__;Iw!!CTRNKA9wMg0ARbw!n5NxtuBHI5f9tS659pqDgRDZNAFxnXriet0G48KA64n1CEWYYsL0vXY0I-Mw99H8a8UDW5KR_79k7IvYg8Er5gNvmkXE9HZH$

Quoted 53 lines
Quoted 27 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +6 -0
+			compatible = "mediatek,mt8195-xhci",
+				     "mediatek,mtk-xhci";
+			reg = <0 0x11290000 0 0x1000>,
+			      <0 0x11293e00 0 0x0100>;
+			reg-names = "mac", "ippc";
+			interrupts = <GIC_SPI 530 IRQ_TYPE_LEVEL_HIGH

0>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +3 -0
+			phys = <&u2port1 PHY_TYPE_USB2>,
+			       <&u3port1 PHY_TYPE_USB3>;
+			assigned-clocks = <&topckgen

CLK_TOP_USB_TOP_1P>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+					  <&topckgen

CLK_TOP_SSUSB_XHCI_1P>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+			assigned-clock-parents = <&topckgen

CLK_TOP_UNIVPLL_D5_D4>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+						 <&topckgen

CLK_TOP_UNIVPLL_D5_D4>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+			clocks = <&pericfg_ao

CLK_PERI_AO_SSUSB_1P_BUS>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+				 <&pericfg_ao

CLK_PERI_AO_SSUSB_1P_XHCI>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +3 -0
+				 <&topckgen CLK_TOP_SSUSB_P1_REF>,
+				 <&apmixedsys CLK_APMIXED_USB1PLL>;
+			clock-names = "sys_ck", "xhci_ck", "ref_ck",

"mcu_ck";

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi line 67

Quoted 4 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +4 -0
+			status = "disabled";
+		};
+
+		ssusb1: usb1@112a1000 {

usb

Quoted 19 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+			compatible = "mediatek,mt8183-mtu3",

"mediatek,mtu3";

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +4 -0
+			reg = <0 0x112a1000 0 0x2dff>,
+				  <0 0x112a3e00 0 0x0100>;
+			reg-names = "mac", "ippc";
+			interrupts = <GIC_SPI 532 IRQ_TYPE_LEVEL_HIGH

0>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +2 -0
+			phys = <&u2port2 PHY_TYPE_USB2>;
+			assigned-clocks = <&topckgen

CLK_TOP_USB_TOP_2P>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+			assigned-clock-parents = <&topckgen

CLK_TOP_UNIVPLL_D5_D4>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+			clocks = <&pericfg_ao

CLK_PERI_AO_SSUSB_2P_BUS>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +2 -0
+				 <&topckgen CLK_TOP_SSUSB_P2_REF>,
+				 <&pericfg_ao

CLK_PERI_AO_SSUSB_2P_XHCI>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +2 -0
+			clock-names = "sys_ck", "ref_ck", "mcu_ck";
+			mediatek,syscon-wakeup = <&pericfg 0x400 4>;
Quoted 8 lines

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi line 86

Quoted 6 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +6 -0
+			#address-cells = <2>;
+			#size-cells = <2>;
+			ranges;
+			status = "disabled";
+
+			xhci2: xhci2@112a0000 {

xhci

use "usb", no need change it when move from mt8195.dtsi

Quoted 15 lines
Quoted 15 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+				compatible = "mediatek,mt8195-

xhci","mediatek,mtk-xhci";

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +3 -0
+				reg = <0 0x112a0000 0 0x1000>;
+				reg-names = "mac";
+				interrupts-extended = <&gic GIC_SPI 533

IRQ_TYPE_LEVEL_HIGH 0>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+					      <&pio 220

IRQ_TYPE_EDGE_FALLING>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+				assigned-clocks = <&topckgen

CLK_TOP_SSUSB_XHCI_2P>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+				assigned-clock-parents = <&topckgen

CLK_TOP_UNIVPLL_D5_D4>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+				clocks = <&pericfg_ao

CLK_PERI_AO_SSUSB_2P_XHCI>;

Quoted 8 lines

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi line 100

Quoted 6 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +6 -0
+				clock-names = "sys_ck";
+				status = "disabled";
+			};
+		};
+
+		xhci3: xhci3@112b0000 {

xhci

usb

Quoted 32 lines
Quoted 20 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +6 -0
+			compatible = "mediatek,mt8195-xhci",
+				     "mediatek,mtk-xhci";
+			reg = <0 0x112b0000 0 0x1000>,
+			      <0 0x112b3e00 0 0x0100>;
+			reg-names = "mac", "ippc";
+			interrupts = <GIC_SPI 536 IRQ_TYPE_LEVEL_HIGH

0>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +2 -0
+			phys = <&u2port3 PHY_TYPE_USB2>;
+			assigned-clocks = <&topckgen

CLK_TOP_USB_TOP_3P>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+					  <&topckgen

CLK_TOP_SSUSB_XHCI_3P>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+			assigned-clock-parents = <&topckgen

CLK_TOP_UNIVPLL_D5_D4>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+						 <&topckgen

CLK_TOP_UNIVPLL_D5_D4>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+			clocks = <&pericfg_ao

CLK_PERI_AO_SSUSB_3P_BUS>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+				 <&pericfg_ao

CLK_PERI_AO_SSUSB_3P_XHCI>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi line 120

Quoted 7 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +7 -0
+				 <&topckgen CLK_TOP_SSUSB_P3_REF>;
+			clock-names = "sys_ck", "xhci_ck", "ref_ck";
+			mediatek,syscon-wakeup = <&pericfg 0x400 106>;
+			wakeup-source;
+			usb2-lpm-disable;
+			status = "disabled";
+		};

Best regards,
Krzysztof

#9 lore raw
Quoted 58 lines · Chunfeng Yun (云春峰) and Krzysztof Kozlowski
Quoted 57 lines · Krzysztof Kozlowski
Quoted 56 lines · Macpaul Lin

Introduce the split MT8195 laptop and iot USB configurations. The hardware specifications for LAPTOP devices is different from IOT
devices. The major differences include some hardware constrains for dual-role switch for USB controllers in different configurations, especially for power management and other control flows as well.

Here are some hardware specifiction differences listed:
1. LAPTOP (Cherry Tomato boards) don't support USB gadget (device
mode).
2. IOT devices must support multiple gadget devices and host
mode.
3. Dual-role switch is not fully supported. Only USB PORT0
support
dual-role switch.
4. Power management is designed in primary and secondary
dominator.
For a dual-role port, the device controller is the primary
controller
for power management; while the host controller is the
secondary.
LAPTOP devices should remove device nodes for avoiding
abnormal
behavior.

This modifcation is to add USB configurations "mt8195-laptop- usb.dtsi"
for LAPTOP devices, and add "mt8195-iot-usb.dtsi" for IOT devices.

To remove common USB configurations for mt8195.dtsi and switch includes
dtsi these new files for the boards will come in next patch.

---
  .../boot/dts/mediatek/mt8195-iot-usb.dtsi     | 122
++++++++++++++++++
  .../boot/dts/mediatek/mt8195-laptop-usb.dtsi  | 102
+++++++++++++++
  2 files changed, 224 insertions(+)

create mode 100644 arch/arm64/boot/dts/mediatek/mt8195-iot-
usb.dtsi
create mode 100644 arch/arm64/boot/dts/mediatek/mt8195-laptop-
usb.dtsi

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +4 -0
new file mode 100644
index 000000000000..f9bd79542044
@@ -0,0 +1,122 @@
+// SPDX-License-Identifier: (GPL-2.0 OR MIT)
+/*
+ * Copyright (C) 2022 MediaTek Inc.
+ */
Quoted 8 lines
Quoted 8 lines

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi line 10

Quoted 6 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +6 -0
+
+#include "mt8195.dtsi"
+
+/ {
+	soc {
+		ssusb: ssusb@11200000 {

Node name: usb

Got it.

Quoted 52 lines
Quoted 13 lines
Quoted 13 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+			compatible ="mediatek,mt8183-mtu3",

"mediatek,mtu3";

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +4 -0
+			reg = <0 0x11201000 0 0x2dff>,
+			      <0 0x11203e00 0 0x0100>;
+			reg-names = "mac", "ippc";
+			interrupts = <GIC_SPI 128 IRQ_TYPE_LEVEL_HIGH

0>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +5 -0
+			phys = <&u2port0 PHY_TYPE_USB2>,
+			       <&u3port0 PHY_TYPE_USB3>;
+			clocks = <&infracfg_ao CLK_INFRA_AO_SSUSB>,
+				 <&topckgen CLK_TOP_SSUSB_REF>,
+				 <&infracfg_ao
Quoted 8 lines

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi line 27

Quoted 8 lines

CLK_INFRA_AO_SSUSB_XHCI>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +7 -0
+			clock-names = "sys_ck", "ref_ck", "mcu_ck";
+			#address-cells = <2>;
+			#size-cells = <2>;
+			ranges;
+			status = "disabled";
+
+			xhci0: xhci@11200000 {

s/xhci/usb

Quoted 22 lines
Quoted 22 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +5 -0
+				compatible = "mediatek,mt8195-xhci",
+					     "mediatek,mtk-xhci";
+				reg = <0 0x11200000 0 0x1000>;
+				reg-names = "mac";
+				interrupts = <GIC_SPI 129

IRQ_TYPE_LEVEL_HIGH 0>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+				assigned-clocks = <&topckgen

CLK_TOP_USB_TOP>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+						  <&topckgen

CLK_TOP_SSUSB_XHCI>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+				assigned-clock-parents = <&topckgen

CLK_TOP_UNIVPLL_D5_D4>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+							 <&topckgen

CLK_TOP_UNIVPLL_D5_D4>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+				clocks = <&infracfg_ao

CLK_INFRA_AO_SSUSB>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+					 <&infracfg_ao

CLK_INFRA_AO_SSUSB_XHCI>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +2 -0
+					 <&topckgen CLK_TOP_SSUSB_REF>,
+					 <&apmixedsys

CLK_APMIXED_USB1PLL>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+				clock-names = "sys_ck", "xhci_ck",
Quoted 8 lines

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi line 46

Quoted 6 lines

"ref_ck", "mcu_ck";

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +5 -0
+				status = "disabled";
+			};
+		};
+
+		xhci1: xhci1@11290000 {

Node names should be generic, so just "xhci"

Quoted 2 lines

also use "usb", no generic name "xhci" in the following spec

Thanks for the reminding. I'll align the naming assignment in origin mt8195.dtsi and in the following specification.

Quoted 36 lines
Quoted 1 line

https://urldefense.com/v3/__https://devicetree-specification.readthedocs.io/en/latest/chapter2-devicetree-basics.html*generic-names-recommendation__;Iw!!CTRNKA9wMg0ARbw!n5NxtuBHI5f9tS659pqDgRDZNAFxnXriet0G48KA64n1CEWYYsL0vXY0I-Mw99H8a8UDW5KR_79k7IvYg8Er5gNvmkXE9HZH$

Quoted 34 lines
Quoted 27 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +6 -0
+			compatible = "mediatek,mt8195-xhci",
+				     "mediatek,mtk-xhci";
+			reg = <0 0x11290000 0 0x1000>,
+			      <0 0x11293e00 0 0x0100>;
+			reg-names = "mac", "ippc";
+			interrupts = <GIC_SPI 530 IRQ_TYPE_LEVEL_HIGH

0>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +3 -0
+			phys = <&u2port1 PHY_TYPE_USB2>,
+			       <&u3port1 PHY_TYPE_USB3>;
+			assigned-clocks = <&topckgen

CLK_TOP_USB_TOP_1P>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+					  <&topckgen

CLK_TOP_SSUSB_XHCI_1P>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+			assigned-clock-parents = <&topckgen

CLK_TOP_UNIVPLL_D5_D4>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+						 <&topckgen

CLK_TOP_UNIVPLL_D5_D4>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+			clocks = <&pericfg_ao

CLK_PERI_AO_SSUSB_1P_BUS>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+				 <&pericfg_ao

CLK_PERI_AO_SSUSB_1P_XHCI>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +3 -0
+				 <&topckgen CLK_TOP_SSUSB_P1_REF>,
+				 <&apmixedsys CLK_APMIXED_USB1PLL>;
+			clock-names = "sys_ck", "xhci_ck", "ref_ck",

"mcu_ck";

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi line 67

Quoted 4 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +4 -0
+			status = "disabled";
+		};
+
+		ssusb1: usb1@112a1000 {

usb

Got it.

Quoted 27 lines
Quoted 19 lines
Quoted 19 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+			compatible = "mediatek,mt8183-mtu3",

"mediatek,mtu3";

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +4 -0
+			reg = <0 0x112a1000 0 0x2dff>,
+				  <0 0x112a3e00 0 0x0100>;
+			reg-names = "mac", "ippc";
+			interrupts = <GIC_SPI 532 IRQ_TYPE_LEVEL_HIGH

0>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +2 -0
+			phys = <&u2port2 PHY_TYPE_USB2>;
+			assigned-clocks = <&topckgen

CLK_TOP_USB_TOP_2P>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+			assigned-clock-parents = <&topckgen

CLK_TOP_UNIVPLL_D5_D4>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+			clocks = <&pericfg_ao

CLK_PERI_AO_SSUSB_2P_BUS>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +2 -0
+				 <&topckgen CLK_TOP_SSUSB_P2_REF>,
+				 <&pericfg_ao

CLK_PERI_AO_SSUSB_2P_XHCI>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +2 -0
+			clock-names = "sys_ck", "ref_ck", "mcu_ck";
+			mediatek,syscon-wakeup = <&pericfg 0x400 4>;
Quoted 8 lines

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi line 86

Quoted 6 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +6 -0
+			#address-cells = <2>;
+			#size-cells = <2>;
+			ranges;
+			status = "disabled";
+
+			xhci2: xhci2@112a0000 {

xhci

Quoted 2 lines

use "usb", no need change it when move from mt8195.dtsi

Got it.

Quoted 23 lines
Quoted 15 lines
Quoted 15 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+				compatible = "mediatek,mt8195-

xhci","mediatek,mtk-xhci";

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +3 -0
+				reg = <0 0x112a0000 0 0x1000>;
+				reg-names = "mac";
+				interrupts-extended = <&gic GIC_SPI 533

IRQ_TYPE_LEVEL_HIGH 0>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+					      <&pio 220

IRQ_TYPE_EDGE_FALLING>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+				assigned-clocks = <&topckgen

CLK_TOP_SSUSB_XHCI_2P>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+				assigned-clock-parents = <&topckgen

CLK_TOP_UNIVPLL_D5_D4>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+				clocks = <&pericfg_ao

CLK_PERI_AO_SSUSB_2P_XHCI>;

Quoted 8 lines

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi line 100

Quoted 6 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +6 -0
+				clock-names = "sys_ck";
+				status = "disabled";
+			};
+		};
+
+		xhci3: xhci3@112b0000 {

xhci

Quoted 1 line

usb

Got it.

Quoted 24 lines
Quoted 24 lines
Quoted 24 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +6 -0
+			compatible = "mediatek,mt8195-xhci",
+				     "mediatek,mtk-xhci";
+			reg = <0 0x112b0000 0 0x1000>,
+			      <0 0x112b3e00 0 0x0100>;
+			reg-names = "mac", "ippc";
+			interrupts = <GIC_SPI 536 IRQ_TYPE_LEVEL_HIGH

0>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +2 -0
+			phys = <&u2port3 PHY_TYPE_USB2>;
+			assigned-clocks = <&topckgen

CLK_TOP_USB_TOP_3P>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+					  <&topckgen

CLK_TOP_SSUSB_XHCI_3P>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+			assigned-clock-parents = <&topckgen

CLK_TOP_UNIVPLL_D5_D4>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+						 <&topckgen

CLK_TOP_UNIVPLL_D5_D4>;

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+			clocks = <&pericfg_ao

CLK_PERI_AO_SSUSB_3P_BUS>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +1 -0
+				 <&pericfg_ao

CLK_PERI_AO_SSUSB_3P_XHCI>,

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +4 -0
+				 <&topckgen CLK_TOP_SSUSB_P3_REF>;
+			clock-names = "sys_ck", "xhci_ck", "ref_ck";
+			mediatek,syscon-wakeup = <&pericfg 0x400 106>;
+			wakeup-source;
Quoted 8 lines
Quoted 8 lines

arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi line 120

Quoted 3 lines
arch/arm64/boot/dts/mediatek/mt8195-iot-usb.dtsi new file +3 -0
+			usb2-lpm-disable;
+			status = "disabled";
+		};

Best regards,
Krzysztof

Thanks
Macpaul Lin

#10 lore raw
In reply to Macpaul Lin

Il 05/01/23 10:28, Macpaul Lin ha scritto:

Quoted 17 lines

Introduce the split MT8195 laptop and iot USB configurations. The hardware specifications for LAPTOP devices is different from IOT devices. The major differences include some hardware constrains for dual-role switch for USB controllers in different configurations, especially for power management and other control flows as well.

Here are some hardware specifiction differences listed:
1. LAPTOP (Cherry Tomato boards) don't support USB gadget (device mode).
2. IOT devices must support multiple gadget devices and host mode.
3. Dual-role switch is not fully supported. Only USB PORT0 support dual-role switch.
4. Power management is designed in primary and secondary dominator. For a dual-role port, the device controller is the primary controller for power management; while the host controller is the secondary. LAPTOP devices should remove device nodes for avoiding abnormal behavior.

Quoted 7 lines

This modifcation is to add USB configurations "mt8195-laptop-usb.dtsi" for LAPTOP devices, and add "mt8195-iot-usb.dtsi" for IOT devices.

To remove common USB configurations for mt8195.dtsi and switch includes dtsi these new files for the boards will come in next patch.

I'm mostly sure that there's no reason to split the two configurations.

I agree in that Tomato doesn't support gadget mode on the Type-A port and I honestly don't currently know (and I'll test that later!) if it would be possible to act as gadget on any of the two Type-C ports.
Of course I agree on the fact that a laptop acting as a gadget may not be useful, but that's not something that I want to judge, as someone may find a usecase.

In any case, even if Tomato does *not* support gadget mode on *any* port at all, I wonder why we wouldn't be able to probe MTU3 (and correctly describe the SoC) on Chromebooks but only on MT8195-based IoT boards...
...and in case there's any real issue, we can always force host mode (with a generic devicetree property!) on the MTU3 on Tomato.

Finally, if we're able to add MTU3 to Tomato boards, this means that we won't be seeing these two DTSI files and that USB nodes are still going to all lie in the main mt8195.dtsi file, without all this duplication that I'm seeing here.

What do you think?

Regards,
Angelo

#11 lore raw
Quoted 34 lines · AngeloGioacchino Del Regno

Il 05/01/23 10:28, Macpaul Lin ha scritto:

Quoted 17 lines

Introduce the split MT8195 laptop and iot USB configurations. The hardware specifications for LAPTOP devices is different from IOT devices. The major differences include some hardware constrains for dual-role switch for USB controllers in different configurations, especially for power management and other control flows as well.

Here are some hardware specifiction differences listed:
   1. LAPTOP (Cherry Tomato boards) don't support USB gadget (device mode).
   2. IOT devices must support multiple gadget devices and host mode.
   3. Dual-role switch is not fully supported. Only USB PORT0 support dual-role switch.
   4. Power management is designed in primary and secondary dominator. For a dual-role port, the device controller is the primary controller for power management; while the host controller is the secondary. LAPTOP devices should remove device nodes for avoiding abnormal behavior.

Quoted 7 lines

This modifcation is to add USB configurations "mt8195-laptop-usb.dtsi" for LAPTOP devices, and add "mt8195-iot-usb.dtsi" for IOT devices.

To remove common USB configurations for mt8195.dtsi and switch includes dtsi these new files for the boards will come in next patch.

I'm mostly sure that there's no reason to split the two configurations.

I agree in that Tomato doesn't support gadget mode on the Type-A port and I honestly don't currently know (and I'll test that later!) if it would be possible to act as gadget on any of the two Type-C ports.
Of course I agree on the fact that a laptop acting as a gadget may not be useful, but that's not something that I want to judge, as someone may find a usecase.

Quoted 5 lines

In any case, even if Tomato does *not* support gadget mode on *any* port at all, I wonder why we wouldn't be able to probe MTU3 (and correctly describe the SoC) on Chromebooks but only on MT8195-based IoT boards...
...and in case there's any real issue, we can always force host mode (with a generic  devicetree property!) on the MTU3 on Tomato.

We are sorry it cannot be achieved by even setting "force host mode" to usb device node. At least, it cannot be done on MT8195.

The basic reason is the power requirements for USB host on a LAPTOP are different from those on an IoT device.

The main cause is low power management. The hardware of each device port is different on MT8195. Even the bit fields definition in registers were different.

Some details such as sequence need to be coordinated with the SPM firmware. When a device hardware is involved in runtime PM, function like remote wakeup and other suspend/resume behavior will be abnormal for a LAPTOP device. If we split the dtsi for different devices, people can choose different configuration in SPM firmware in coreboot or in TF-A to meet the requirement. Hence we'd better not to get more messy code in Linux driver.

Quoted 9 lines

Finally, if we're able to add MTU3 to Tomato boards, this means that we won't be seeing these two DTSI files and that USB nodes are still going to all lie in the main mt8195.dtsi file, without all this duplication that I'm seeing here.

What do you think?

Regards,
Angelo

Thanks for the suggestion, we hope the next platform in the future could avoid this issue and reduce some duplicate dts.

Macpaul Lin

maintainer
#12 lore raw

Hi all,

Quoted 43 lines · Macpaul Lin
Quoted 34 lines · AngeloGioacchino Del Regno

Il 05/01/23 10:28, Macpaul Lin ha scritto:

Quoted 17 lines

Introduce the split MT8195 laptop and iot USB configurations. The hardware specifications for LAPTOP devices is different from IOT devices. The major differences include some hardware constrains for dual-role switch for USB controllers in different configurations, especially for power management and other control flows as well.

Here are some hardware specifiction differences listed:
   1. LAPTOP (Cherry Tomato boards) don't support USB gadget (device mode).
   2. IOT devices must support multiple gadget devices and host mode.
   3. Dual-role switch is not fully supported. Only USB PORT0 support dual-role switch.
   4. Power management is designed in primary and secondary dominator. For a dual-role port, the device controller is the primary controller for power management; while the host controller is the secondary. LAPTOP devices should remove device nodes for avoiding abnormal behavior.

Quoted 7 lines

This modifcation is to add USB configurations "mt8195-laptop-usb.dtsi" for LAPTOP devices, and add "mt8195-iot-usb.dtsi" for IOT devices.

To remove common USB configurations for mt8195.dtsi and switch includes dtsi these new files for the boards will come in next patch.

I'm mostly sure that there's no reason to split the two configurations.

I agree in that Tomato doesn't support gadget mode on the Type-A port and I honestly don't currently know (and I'll test that later!) if it would be possible to act as gadget on any of the two Type-C ports.
Of course I agree on the fact that a laptop acting as a gadget may not be useful, but that's not something that I want to judge, as someone may find a usecase.

Quoted 5 lines

In any case, even if Tomato does *not* support gadget mode on *any* port at all, I wonder why we wouldn't be able to probe MTU3 (and correctly describe the SoC) on Chromebooks but only on MT8195-based IoT boards...
...and in case there's any real issue, we can always force host mode (with a generic  devicetree property!) on the MTU3 on Tomato.

Quoted 8 lines

We are sorry it cannot be achieved by even setting "force host mode" to usb device node. At least, it cannot be done on MT8195.

The basic reason is the power requirements for USB host on a LAPTOP are different from those on an IoT device.

The main cause is low power management. The hardware of each device port is different on MT8195. Even the bit fields definition in registers were different.

Some details such as sequence need to be coordinated with the SPM firmware. When a device hardware is involved in runtime PM, function like remote wakeup and other suspend/resume behavior will be abnormal for a LAPTOP device. If we split the dtsi for different devices, people can choose different configuration in SPM firmware in coreboot or in TF-A to meet the requirement. Hence we'd better not to get more messy code in Linux driver.

I'm not sure I understand everything here. If the XHCI device is a child of the mtu3 node then we have problems with some SPM firmware that is not coordinated with the runtime PM functions of the kernel?

Fixing that in the device tree sounds wrong here. I think the real fix would be, to fix the SPM firmware, so that it can deal with that.

Or is there more to it? If so what? In that case can we try to ignore the runtime PM in the MTU3 kernel driver?

I'm not an USB expert but to me it looks very strange that we can have the XHCI devices nodes as 'standalone' or as children of mtu3. We should try to describe the HW as it is in DT.

Regards,
Matthias

Quoted 13 lines
Quoted 9 lines

Finally, if we're able to add MTU3 to Tomato boards, this means that we won't be seeing these two DTSI files and that USB nodes are still going to all lie in the main mt8195.dtsi file, without all this duplication that I'm seeing here.

What do you think?

Regards,
Angelo

Thanks for the suggestion, we hope the next platform in the future could avoid this issue and reduce some duplicate dts.

Macpaul Lin

#13 lore raw
Quoted 48 lines · Matthias Brugger

Hi all,

Quoted 45 lines · Macpaul Lin
Quoted 34 lines · AngeloGioacchino Del Regno

Il 05/01/23 10:28, Macpaul Lin ha scritto:

Quoted 17 lines

Introduce the split MT8195 laptop and iot USB configurations. The hardware specifications for LAPTOP devices is different from IOT devices. The major differences include some hardware constrains for dual-role switch for USB controllers in different configurations, especially for power management and other control flows as well.

Here are some hardware specifiction differences listed:
   1. LAPTOP (Cherry Tomato boards) don't support USB gadget (device mode).
   2. IOT devices must support multiple gadget devices and host mode.
   3. Dual-role switch is not fully supported. Only USB PORT0 support dual-role switch.
   4. Power management is designed in primary and secondary dominator. For a dual-role port, the device controller is the primary controller for power management; while the host controller is the secondary. LAPTOP devices should remove device nodes for avoiding abnormal behavior.

Quoted 7 lines

This modifcation is to add USB configurations "mt8195-laptop-usb.dtsi" for LAPTOP devices, and add "mt8195-iot-usb.dtsi" for IOT devices.

To remove common USB configurations for mt8195.dtsi and switch includes dtsi these new files for the boards will come in next patch.

I'm mostly sure that there's no reason to split the two configurations.

I agree in that Tomato doesn't support gadget mode on the Type-A port and I honestly don't currently know (and I'll test that later!) if it would be possible to act as gadget on any of the two Type-C ports.
Of course I agree on the fact that a laptop acting as a gadget may not be useful, but that's not something that I want to judge, as someone may find a usecase.

Quoted 5 lines

In any case, even if Tomato does *not* support gadget mode on *any* port at all, I wonder why we wouldn't be able to probe MTU3 (and correctly describe the SoC) on Chromebooks but only on MT8195-based IoT boards...
...and in case there's any real issue, we can always force host mode (with a generic  devicetree property!) on the MTU3 on Tomato.

We are sorry it cannot be achieved by even setting "force host mode" to usb device node. At least, it cannot be done on MT8195.

Quoted 8 lines
Quoted 6 lines

The basic reason is the power requirements for USB host on a LAPTOP are different from those on an IoT device.

The main cause is low power management. The hardware of each device port is different on MT8195. Even the bit fields definition in registers were different.

Some details such as sequence need to be coordinated with the SPM firmware. When a device hardware is involved in runtime PM, function like remote wakeup and other suspend/resume behavior will be abnormal for a LAPTOP device. If we split the dtsi for different devices, people can choose different configuration in SPM firmware in coreboot or in TF-A to meet the requirement. Hence we'd better not to get more messy code in Linux driver.

I'm not sure I understand everything here. If the XHCI device is a child of the mtu3 node then we have problems with some SPM firmware that is not coordinated with the runtime PM functions of the kernel?

The behavior of runtime PM function, especially the behavior of USB remote wake up will be different if mtu3 node is involved, for MT8195.

Quoted 5 lines

Fixing that in the device tree sounds wrong here. I think the real fix would be, to fix the SPM firmware, so that it can deal with that.

Or is there more to it? If so what? In that case can we try to ignore the runtime PM in the MTU3 kernel driver?

I'm not an USB expert but to me it looks very strange that we can have the XHCI devices nodes as 'standalone' or as children of mtu3. We should try to describe the HW as it is in DT.

After a discussion with MTU3 maintainer Chunfeng, we think there might be a way to give it a try to refactor the mtu3 driver.
That is to create an extra USB platform device to handle mtu3 and xhci-mtk as the children at the same level. Both mtu3 platform device xhci-mtk platform device will become the children of a common USB platform device. However, we are not sure if this could work and solved the dependencies. It requires some development time and MediaTek need
to allocate some developer's resource to verify this approach.

Quoted 16 lines

Regards,
Matthias

Quoted 13 lines
Quoted 9 lines

Finally, if we're able to add MTU3 to Tomato boards, this means that we won't be seeing these two DTSI files and that USB nodes are still going to all lie in the main mt8195.dtsi file, without all this duplication that I'm seeing here.

What do you think?

Regards,
Angelo

Thanks for the suggestion, we hope the next platform in the future could avoid this issue and reduce some duplicate dts.

Macpaul Lin

Thanks
Macpaul Lin