Wentao Qin has uploaded this change for review.

View Change

mb/google/corsola: Add initialization of USB port0 for Wugtrio

Initialize USB2 port0 to support the SD card and detachable keyboard
functions mounted on port0 during the coreboot stage.

BUG=b:335124437
TEST=boot to OS from USB-A
boot to OS from SD Card
BRANCH=corsola

Change-Id: I725b80593f5fc498a204bf47f943c36ccbd78134
Signed-off-by: Wentao Qin <qinwentao@huaqin.corp-partner.google.com>
---
M src/mainboard/google/corsola/devicetree.cb
M src/mainboard/google/corsola/mainboard.c
M src/soc/mediatek/common/include/soc/usb_common.h
M src/soc/mediatek/common/usb.c
M src/soc/mediatek/mt8186/include/soc/addressmap.h
5 files changed, 24 insertions(+), 2 deletions(-)

git pull ssh://review.coreboot.org:29418/coreboot refs/changes/89/82089/1
diff --git a/src/mainboard/google/corsola/devicetree.cb b/src/mainboard/google/corsola/devicetree.cb
index 300ba7b..7f2d325 100644
--- a/src/mainboard/google/corsola/devicetree.cb
+++ b/src/mainboard/google/corsola/devicetree.cb
@@ -1,5 +1,9 @@
## SPDX-License-Identifier: GPL-2.0-only
fw_config
+ field USB2_PORT 26 27
+ option USB2_PORT1 0
+ option USB2_PORT0 1
+ end
field AUDIO_AMP 28 29
option AMP_ALC1019 0
option AMP_ALC5645 1
diff --git a/src/mainboard/google/corsola/mainboard.c b/src/mainboard/google/corsola/mainboard.c
index a1ba5f9..1471f32 100644
--- a/src/mainboard/google/corsola/mainboard.c
+++ b/src/mainboard/google/corsola/mainboard.c
@@ -53,6 +53,13 @@

setup_usb_host();

+ if (fw_config_probe(FW_CONFIG(USB2_PORT, USB2_PORT0))) {
+ /* Change host to USB2 port0 for initialization */
+ switch_usb_port0_host();
+
+ setup_usb_host();
+ }
+
if (!fw_config_is_provisioned() ||
fw_config_probe(FW_CONFIG(AUDIO_AMP, AMP_ALC1019)))
configure_alc1019();
diff --git a/src/soc/mediatek/common/include/soc/usb_common.h b/src/soc/mediatek/common/include/soc/usb_common.h
index d390b70..fb906c4 100644
--- a/src/soc/mediatek/common/include/soc/usb_common.h
+++ b/src/soc/mediatek/common/include/soc/usb_common.h
@@ -162,5 +162,6 @@
void mtk_usb_adjust_phy_shift(void);

void setup_usb_host(void);
+void switch_usb_port0_host(void);

#endif
diff --git a/src/soc/mediatek/common/usb.c b/src/soc/mediatek/common/usb.c
index b9fe835..79568fd 100644
--- a/src/soc/mediatek/common/usb.c
+++ b/src/soc/mediatek/common/usb.c
@@ -13,6 +13,14 @@
static struct ssusb_ippc_regs *ippc_regs = (void *)(SSUSB_IPPC_BASE);
static struct ssusb_sif_port *phy_ports = (void *)(SSUSB_SIF_BASE);

+#ifdef SOC_MEDIATEK_MT8186_USB_H
+void switch_usb_port0_host(void)
+{
+ ippc_regs = (void *)(SSUSB_IPPC_BASE_p0);
+ phy_ports = (void *)(SSUSB_SIF_BASE_p0);
+}
+#endif
+
static void phy_index_power_on(int index)
{
struct ssusb_sif_port *phy = phy_ports + index;
diff --git a/src/soc/mediatek/mt8186/include/soc/addressmap.h b/src/soc/mediatek/mt8186/include/soc/addressmap.h
index 5f0b10c..298e586 100644
--- a/src/soc/mediatek/mt8186/include/soc/addressmap.h
+++ b/src/soc/mediatek/mt8186/include/soc/addressmap.h
@@ -76,11 +76,13 @@
SPI5_BASE = IO_PHYS + 0x01015000,
I2C5_BASE = IO_PHYS + 0x01016000,
I2C9_BASE = IO_PHYS + 0x01019000,
- /* Corsola uses USB2 port1 instead of USB2 port0. */
+ /* IPPC_BASE is for USB2 port1, IPPC_BASE_p0 is for USB2 port0 */
SSUSB_IPPC_BASE = IO_PHYS + 0x01283E00,
+ SSUSB_IPPC_BASE_p0 = IO_PHYS + 0x01203E00,
MSDC0_BASE = IO_PHYS + 0x01230000,
- /* Corsola uses USB2 port1 instead of USB2 port0. */
+ /* SIF_BASE is for USB2 port1, SIF_BASE_p0 is for USB2 port0 */
SSUSB_SIF_BASE = IO_PHYS + 0x01C80300,
+ SSUSB_SIF_BASE_p0 = IO_PHYS + 0x01CA0300,
EFUSEC_BASE = IO_PHYS + 0x01CB0000,
MIPITX_BASE = IO_PHYS + 0x01CC0000,
MSDC0_TOP_BASE = IO_PHYS + 0x01CD0000,

To view, visit change 82089. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: coreboot
Gerrit-Branch: main
Gerrit-Change-Id: I725b80593f5fc498a204bf47f943c36ccbd78134
Gerrit-Change-Number: 82089
Gerrit-PatchSet: 1
Gerrit-Owner: Wentao Qin <qinwentao@huaqin.corp-partner.google.com>
Gerrit-MessageType: newchange