From c66fbec4e2ee28d2089e16d253f2aa5d51996013 Mon Sep 17 00:00:00 2001 From: retro98boy Date: Mon, 9 Jun 2025 21:45:59 +0800 Subject: [PATCH] CAINIAO CNIoT-CORE: switch USB 2.0 access from the Type-C port to the four contacts on the side of the host --- .../meson-g12b-a311d-cainiao-cniot-core.dts | 19 ++++++++++++++- .../meson-g12b-a311d-cainiao-cniot-core.dts | 19 ++++++++++++++- .../add-board-cainiao-cniot-core.patch | 23 ++++++++++++++++--- 3 files changed, 56 insertions(+), 5 deletions(-) diff --git a/patch/kernel/archive/meson64-6.12/dt/meson-g12b-a311d-cainiao-cniot-core.dts b/patch/kernel/archive/meson64-6.12/dt/meson-g12b-a311d-cainiao-cniot-core.dts index 0490a3b4d..b310fc52f 100644 --- a/patch/kernel/archive/meson64-6.12/dt/meson-g12b-a311d-cainiao-cniot-core.dts +++ b/patch/kernel/archive/meson64-6.12/dt/meson-g12b-a311d-cainiao-cniot-core.dts @@ -176,6 +176,23 @@ vin-supply = <&dc_in>; }; + /* + * The Type-C port on the host is switched with the four USB contacts on the side of the host via GPIOA_14. + * Since the Type-C port on the host is either used for power supply or blocked by the dock, + * switching USB 2.0 access to the four contacts on the side of the host is a better choice. + * To use the Type-C port for data transmission, + * you only need to set GPIOA_14 in the node below to a high level. + */ + usb_switch: regulator-usb-switch { + compatible = "regulator-fixed"; + enable-active-low; + gpio = <&gpio GPIOA_14 GPIO_ACTIVE_LOW>; + regulator-name = "usb_switch"; + regulator-always-on; + regulator-boot-on; + vin-supply = <&dc_in>; + }; + vdd_amp: regulator-vdd-amp { compatible = "regulator-fixed"; enable-active-high; @@ -558,7 +575,7 @@ }; &usb2_phy1 { - phy-supply = <&_power>; + phy-supply = <&usb_switch>; }; &usb3_pcie_phy { diff --git a/patch/kernel/archive/meson64-6.15/dt/meson-g12b-a311d-cainiao-cniot-core.dts b/patch/kernel/archive/meson64-6.15/dt/meson-g12b-a311d-cainiao-cniot-core.dts index 0490a3b4d..b310fc52f 100644 --- a/patch/kernel/archive/meson64-6.15/dt/meson-g12b-a311d-cainiao-cniot-core.dts +++ b/patch/kernel/archive/meson64-6.15/dt/meson-g12b-a311d-cainiao-cniot-core.dts @@ -176,6 +176,23 @@ vin-supply = <&dc_in>; }; + /* + * The Type-C port on the host is switched with the four USB contacts on the side of the host via GPIOA_14. + * Since the Type-C port on the host is either used for power supply or blocked by the dock, + * switching USB 2.0 access to the four contacts on the side of the host is a better choice. + * To use the Type-C port for data transmission, + * you only need to set GPIOA_14 in the node below to a high level. + */ + usb_switch: regulator-usb-switch { + compatible = "regulator-fixed"; + enable-active-low; + gpio = <&gpio GPIOA_14 GPIO_ACTIVE_LOW>; + regulator-name = "usb_switch"; + regulator-always-on; + regulator-boot-on; + vin-supply = <&dc_in>; + }; + vdd_amp: regulator-vdd-amp { compatible = "regulator-fixed"; enable-active-high; @@ -558,7 +575,7 @@ }; &usb2_phy1 { - phy-supply = <&_power>; + phy-supply = <&usb_switch>; }; &usb3_pcie_phy { diff --git a/patch/u-boot/v2025.04/board_cainiao-cniot-core/add-board-cainiao-cniot-core.patch b/patch/u-boot/v2025.04/board_cainiao-cniot-core/add-board-cainiao-cniot-core.patch index d98179d40..fc7096280 100644 --- a/patch/u-boot/v2025.04/board_cainiao-cniot-core/add-board-cainiao-cniot-core.patch +++ b/patch/u-boot/v2025.04/board_cainiao-cniot-core/add-board-cainiao-cniot-core.patch @@ -128,10 +128,10 @@ index 00000000..345d9b86 +CONFIG_ZSTD=y diff --git a/dts/upstream/src/arm64/amlogic/meson-g12b-a311d-cainiao-cniot-core.dts b/dts/upstream/src/arm64/amlogic/meson-g12b-a311d-cainiao-cniot-core.dts new file mode 100644 -index 00000000..40b81e87 +index 00000000..53318e9d --- /dev/null +++ b/dts/upstream/src/arm64/amlogic/meson-g12b-a311d-cainiao-cniot-core.dts -@@ -0,0 +1,571 @@ +@@ -0,0 +1,588 @@ +// SPDX-License-Identifier: (GPL-2.0+ OR MIT) +/* + * Copyright (c) 2019 BayLibre, SAS @@ -310,6 +310,23 @@ index 00000000..40b81e87 + vin-supply = <&dc_in>; + }; + ++ /* ++ * The Type-C port on the host is switched with the four USB contacts on the side of the host via GPIOA_14. ++ * Since the Type-C port on the host is either used for power supply or blocked by the dock, ++ * switching USB 2.0 access to the four contacts on the side of the host is a better choice. ++ * To use the Type-C port for data transmission, ++ * you only need to set GPIOA_14 in the node below to a high level. ++ */ ++ usb_switch: regulator-usb-switch { ++ compatible = "regulator-fixed"; ++ enable-active-low; ++ gpio = <&gpio GPIOA_14 GPIO_ACTIVE_LOW>; ++ regulator-name = "usb_switch"; ++ regulator-always-on; ++ regulator-boot-on; ++ vin-supply = <&dc_in>; ++ }; ++ + vdd_amp: regulator-vdd-amp { + compatible = "regulator-fixed"; + enable-active-high; @@ -692,7 +709,7 @@ index 00000000..40b81e87 +}; + +&usb2_phy1 { -+ phy-supply = <&_power>; ++ phy-supply = <&usb_switch>; +}; + +&usb3_pcie_phy {