From b00879d2cccef63594f4b2c5cadebcbd311e7e97 Mon Sep 17 00:00:00 2001 From: Max Krummenacher Date: Wed, 31 Mar 2021 17:19:23 +0200 Subject: colibri-imx8x: hardcode the on module usb hub to bypass mode The on module USB hub connects upstream to SoC USB_OTG2 and provides two downstream ports, one to the on module Wi-Fi, one to the SODIMM connector. In bypass mode the upstream port is directly connected to the SODIMM connector pins. Related-to: ELB-3853 Signed-off-by: Max Krummenacher --- board/toradex/colibri-imx8x/colibri-imx8x.c | 47 ++++++++++++++++++++++++++++- 1 file changed, 46 insertions(+), 1 deletion(-) diff --git a/board/toradex/colibri-imx8x/colibri-imx8x.c b/board/toradex/colibri-imx8x/colibri-imx8x.c index 9098815424..5bc4fba5b9 100644 --- a/board/toradex/colibri-imx8x/colibri-imx8x.c +++ b/board/toradex/colibri-imx8x/colibri-imx8x.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0+ /* - * Copyright 2018-2019 Toradex + * Copyright 2018-2021 Toradex */ #include #include @@ -20,6 +20,7 @@ #include #include +#include #include #include @@ -125,8 +126,52 @@ int board_phy_config(struct phy_device *phydev) } #endif +#define I2C_ONMODULE_BUS 0 +#define I2C_GPIO_EXPANDER 0x43 +#define FXL6408_REG_IODIR 0x3 +#define FXL6408_REG_OUTPUT 0x5 +#define FXL6408_REG_OPENDR 0x7 +/* + * On-module GPIO expander FXL6408 drives management signals for + * on-module USB Hub. + */ +static void init_gpio_expander(void) +{ +#ifdef CONFIG_DM_I2C + struct udevice *dev; + int ret; + u8 temp; + + ret = i2c_get_chip_for_busnum(I2C_ONMODULE_BUS, I2C_GPIO_EXPANDER, + 1, &dev); + if (ret) { + printf("%s: Cannot find dev %d on I2C bus %d\n", __func__, + I2C_GPIO_EXPANDER, I2C_ONMODULE_BUS); + return; + } + + /* + * On-module USB3803 Hub has bypass mode. It connects + * directly its upstream PHY with its downstream PHY#3 port which then + * goes to the carrier board USBH port. + * Turn on the Bypass# and deassert the Reset# signals, + * i.e. BYPASS_N = 0, RESET_N = 1 + * Refer to + * https://www.onsemi.com/pdf/datasheet/fxl6408-d.pdf, Page 9 + */ + temp = 0x30; /* set GPIO 4 and 5 as output */ + dm_i2c_write(dev, 3, &temp, 1); + temp = 0xcf; /* take GPIO 4 and 5 out of tristate */ + dm_i2c_write(dev, 7, &temp, 1); + temp = 0x10; /* set GPIO 4=1 and GPIO5=0 */ + dm_i2c_write(dev, 5, &temp, 1); +#endif +} + int board_init(void) { + init_gpio_expander(); + gpio_request(USB_CDET_GPIO, "usb_cdet"); #ifdef CONFIG_SNVS_SEC_SC_AUTO -- cgit v1.2.3