From 69e9c386dd3734a01af79ca1cc565896facfb9f6 Mon Sep 17 00:00:00 2001 From: Rene Straub Date: Wed, 25 Oct 2023 21:41:40 +0200 Subject: [PATCH] hw21/26: power up extension module early The extension module is connected to the system I2C bus. Before the module is powered, it can pull the lines low, preventing I2C access to the board descriptor. - enable extension module power already in SPL id: 417848 --- board/nm/nmhw21/board.c | 41 +++++++++++++++++++++++++---------------- 1 file changed, 25 insertions(+), 16 deletions(-) diff --git a/board/nm/nmhw21/board.c b/board/nm/nmhw21/board.c index 143488e7ea..85ac392223 100644 --- a/board/nm/nmhw21/board.c +++ b/board/nm/nmhw21/board.c @@ -794,6 +794,27 @@ static void init_bd_spl(void) } } +static void power_um(void) +{ + int bus; + + da9063_init(CONFIG_PMIC_I2C_BUS); + + bus = da9063_claim_i2c_bus(); + + REQUEST_AND_CLEAR_GPIO(GPIO_RST_UM_N); /* Assert reset (active low) */ + REQUEST_AND_CLEAR_GPIO(GPIO_CTRL_WDIS_N); + mdelay(1); + + da9063_set_gpio(PMIC_UM_SUPPLY_VSEL_IO, 0); /* Set voltage to 3.3V */ + mdelay(1); + + da9063_set_gpio(PMIC_UM_SUPPLY_EN_IO, 1); /* Enable Supply */ + mdelay(10); + + da9063_release_i2c_bus(bus); +} + void am33xx_spl_board_init(void) { /* Set CPU speed to 600 MHz (fix) */ @@ -805,6 +826,9 @@ void am33xx_spl_board_init(void) /* Configure both I2C buses used */ init_i2c(); + /* Power on Extension/User module, so it doesn't block I2C bus */ + power_um(); + /* Get board descriptor */ init_bd_spl(); @@ -1045,30 +1069,15 @@ static void init_usb_hub(void) static void init_user_module(void) { - int bus; - - bus = da9063_claim_i2c_bus(); - puts("UM: "); REQUEST_AND_CLEAR_GPIO(GPIO_RST_UM_N); /* Assert reset (active low) */ - REQUEST_AND_CLEAR_GPIO(GPIO_CTRL_WDIS_N) /* TODO: CHECK */ - - /* TODO: Should this be done at first power up as well? */ - da9063_set_gpio(PMIC_UM_SUPPLY_EN_IO, 0); /* Switch Supply off */ - mdelay(30); /* Give time to discharge output */ - - da9063_set_gpio(PMIC_UM_SUPPLY_VSEL_IO, 0); /* Set voltage to 3.3V */ - mdelay(1); - - da9063_set_gpio(PMIC_UM_SUPPLY_EN_IO, 1); /* Enable Supply */ + REQUEST_AND_CLEAR_GPIO(GPIO_CTRL_WDIS_N); /* TODO: CHECK */ mdelay(10); gpio_direction_input(GPIO_RST_UM_N); /* Release reset (open drain) */ mdelay(10); - da9063_release_i2c_bus(bus); - mdelay(200); /* Give module some time to boot */ um_init(CONFIG_UM_I2C_BUS); /* Try to detect user module */