UPSTREAM: soc/mediatek/mt8188: Fix USB2 detection issue

MT8188 supports port0/port1 download. The hardware needs a trapping pin
to select the port to use. When port1 is selected, the phy of port1 will
be switched to port0. That is, port1 connector will be the physical line
of port0. Since port0 phy isn't initialized in coreboot, switch back to
port1 phy.

BUG=b:269059211
TEST=can detect USB2 devices in depthcharge.

(cherry picked from commit ed2b6a5a17fd71e6069f3aa017341694e77df777)

Original-Change-Id: Ic97d0bd9d0233883196b2e73ac2a22cd8ea9466b
Original-Signed-off-by: Shaocheng Wang <shaocheng.wang@mediatek.corp-partner.google.com>
Original-Reviewed-on: https://review.coreboot.org/c/coreboot/+/73170
Original-Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
Original-Reviewed-by: Rex-BC Chen <rex-bc.chen@mediatek.com>
Original-Reviewed-by: Yu-Ping Wu <yupingso@google.com>
Original-Reviewed-by: Yidi Lin <yidilin@google.com>
GitOrigin-RevId: ed2b6a5a17fd71e6069f3aa017341694e77df777
Change-Id: Ib7240e6d46b80ff8fab22a76a45cc43d5bce7d63
Reviewed-on: https://chromium-review.googlesource.com/c/chromiumos/third_party/coreboot/+/4280738
Commit-Queue: Kangheui Won <khwon@chromium.org>
Tested-by: CopyBot Service Account <copybot.service@gmail.com>
Reviewed-by: Kangheui Won <khwon@chromium.org>
diff --git a/src/soc/mediatek/mt8188/usb.c b/src/soc/mediatek/mt8188/usb.c
index 2312e2d..75d4667 100644
--- a/src/soc/mediatek/mt8188/usb.c
+++ b/src/soc/mediatek/mt8188/usb.c
@@ -11,7 +11,22 @@
 #include <soc/pll_common.h>
 #include <soc/usb.h>
 
+#define TRAP_USB20_P1_USBD1_EN 0x10005600
+
+static void mt_set_trapping_pin(void)
+{
+	/*
+	 * MT8188 supports port0/port1 download. The hardware needs a trapping pin to
+	 * select the port to use. When port1 is selected, the phy of port1 will be
+	 * switched to port0. That is, port1 connector will be the physical line of
+	 * port0. Since port0 phy isn't initialized in coreboot, switch back to port1
+	 * phy.
+	 */
+	setbits32p(TRAP_USB20_P1_USBD1_EN, BIT(9));
+}
+
 void mtk_usb_prepare(void)
 {
 	mt_pll_set_usb_clock();
+	mt_set_trapping_pin();
 }