/* EVT1 */ static int evt1_board_init(struct ara_board_info *board_info) { int rc; /* For now, just always enable REFCLK_MAIN and the buffers. */ rc = vreg_config(&refclk_main_vreg) || vreg_get(&refclk_main_vreg); if (rc) { dbg_error("%s: can't start REFCLK_MAIN: %d\n", __func__, rc); return ERROR; } /* Configure the switch power supply lines. */ rc = vreg_config(&sw_vreg); if (rc) { dbg_error("%s: can't configure switch regulators: %d\n", __func__, rc); return ERROR; } stm32_configgpio(evt1_board_info.sw_data.gpio_reset); up_udelay(POWER_SWITCH_OFF_STAB_TIME_US); /* Configure the wake/detect lines. */ stm32_configgpio(WD_1_DET_IN_GPIO); stm32_configgpio(WD_2_DET_IN_GPIO); stm32_configgpio(WD_3A_DET_IN_GPIO); stm32_configgpio(WD_3B_DET_IN_GPIO); stm32_configgpio(WD_4A_DET_IN_GPIO); stm32_configgpio(WD_4B_DET_IN_GPIO); stm32_configgpio(WD_5_DET_IN_GPIO); stm32_configgpio(WD_8A_DET_IN_GPIO); stm32_configgpio(WD_8B_DET_IN_GPIO); /* Configure the module release pins */ stm32_configgpio(MOD_RELEASE_1_CONFIG); stm32_configgpio(MOD_RELEASE_2_CONFIG); stm32_configgpio(MOD_RELEASE_3A_CONFIG); stm32_configgpio(MOD_RELEASE_3B_CONFIG); stm32_configgpio(MOD_RELEASE_4A_CONFIG); stm32_configgpio(MOD_RELEASE_4B_CONFIG); stm32_configgpio(MOD_RELEASE_5_CONFIG); /* Configure ARA key input pin */ stm32_configgpio(ARA_KEY_CONFIG); /* * (Module hotplug pins unconfigured. TODO, part of SW-1942.) */ return 0; }
/** * @brief Configure all the voltage regulators associated with an interface * to their default states. * @param iface interface to configure */ static int interface_config(struct interface *iface) { int rc = 0; dbg_verbose("Configuring interface %s.\n", iface->name ? iface->name : "unknown"); /* Configure default state for the regulator pins */ rc = vreg_config(iface->vreg); /* * Configure WAKEOUT as input, floating so that it does not interfere * with the wake and detect input pin */ if (iface->wake_out) { if (stm32_configgpio(iface->wake_out | GPIO_INPUT) < 0) { dbg_error("%s: Failed to configure WAKEOUT pin for interface %s\n", __func__, iface->name ? iface->name : "unknown"); rc = -1; } } iface->power_state = false; return rc; }
struct ara_board_info *board_init(void) { int i; /* Pretty lights */ stm32_configgpio(SVC_LED_GREEN); stm32_gpiowrite(SVC_LED_GREEN, false); /* Disable these for now */ stm32_configgpio(SVC_RST_IOEXP); stm32_gpiowrite(SVC_RST_IOEXP, false); /* * Register the STM32 GPIOs to Gpio Chip * * This needs to happen before the I/O Expanders registration, which * uses some STM32 pins */ stm32_gpio_init(); /* * Configure the switch and I/O Expander reset and power supply lines. * Hold all the lines low while we turn on the power rails. */ vreg_config(&ioexp_vreg); vreg_config(&sw_vreg); stm32_configgpio(sdb_board_info.sw_data.gpio_reset); up_udelay(POWER_SWITCH_OFF_STAB_TIME_US); /* * Enable 1P1 and 1P8, used by the I/O Expanders */ vreg_get(&ioexp_vreg); /* Register the TCA64xx I/O Expanders GPIOs to Gpio Chip */ for (i = 0; i < sdb_board_info.nr_io_expanders; i++) { struct io_expander_info *io_exp = &sdb_board_info.io_expanders[i]; io_exp->i2c_dev = up_i2cinitialize(io_exp->i2c_bus); if (!io_exp->i2c_dev) { dbg_error("%s(): Failed to get I/O Expander I2C bus %u\n", __func__, io_exp->i2c_bus); } else { if (tca64xx_init(&io_exp->io_exp_driver_data, io_exp->part, io_exp->i2c_dev, io_exp->i2c_addr, io_exp->reset, io_exp->irq, io_exp->gpio_base) < 0) { dbg_error("%s(): Failed to register I/O Expander(0x%02x)\n", __func__, io_exp->i2c_addr); up_i2cuninitialize(io_exp->i2c_dev); } } } /* Hold USB_HUB_RESET high */ gpio_direction_out(USB_HUB_RESET, 1); return &sdb_board_info; }
/* EVT1.5 */ static int evt1_5_board_init(struct ara_board_info *board_info) { int rc; /* * VSYS and VCHG are active high with a pull-up. * Initialize these lines as output low to prevent any spurious * activation at boot time. */ gpio_direction_out(VSYS_EN1_N, 0); gpio_direction_out(VSYS_EN2_N, 0); gpio_direction_out(VSYS_EN3A_N, 0); gpio_direction_out(VSYS_EN3B_N, 0); gpio_direction_out(VSYS_EN4A_N, 0); gpio_direction_out(VSYS_EN4B_N, 0); gpio_direction_out(VSYS_EN5_N, 0); gpio_direction_out(VCHG_EN1_N, 0); gpio_direction_out(VCHG_EN2_N, 0); gpio_direction_out(VCHG_EN3A_N, 0); gpio_direction_out(VCHG_EN3B_N, 0); gpio_direction_out(VCHG_EN4A_N, 0); gpio_direction_out(VCHG_EN4B_N, 0); gpio_direction_out(VCHG_EN5_N, 0); /* For now, just always enable REFCLK_MAIN and the buffers. */ rc = vreg_config(&refclk_main_vreg) || vreg_get(&refclk_main_vreg); if (rc) { dbg_error("%s: can't start REFCLK_MAIN: %d\n", __func__, rc); return ERROR; } /* Configure Switch Standby Boot line */ stm32_configgpio(SW_STANDBY_N); /* Configure the switch power supply lines. */ rc = vreg_config(&sw_vreg); if (rc) { dbg_error("%s: can't configure switch regulators: %d\n", __func__, rc); return ERROR; } stm32_configgpio(evt1_5_board_info.sw_data.gpio_reset); up_udelay(POWER_SWITCH_OFF_STAB_TIME_US); /* Configure the wake/detect lines. */ stm32_configgpio(WD_1_DET_IN_GPIO); stm32_configgpio(WD_2_DET_IN_GPIO); stm32_configgpio(WD_3A_DET_IN_GPIO); stm32_configgpio(WD_3B_DET_IN_GPIO); stm32_configgpio(WD_4A_DET_IN_GPIO); stm32_configgpio(WD_4B_DET_IN_GPIO); stm32_configgpio(WD_5_DET_IN_GPIO); stm32_configgpio(WD_8A_DET_IN_GPIO); stm32_configgpio(WD_8B_DET_IN_GPIO); /* Configure the module release pins */ stm32_configgpio(MOD_RELEASE_1_CONFIG); stm32_configgpio(MOD_RELEASE_2_CONFIG); stm32_configgpio(MOD_RELEASE_3A_CONFIG); stm32_configgpio(MOD_RELEASE_3B_CONFIG); stm32_configgpio(MOD_RELEASE_4A_CONFIG); stm32_configgpio(MOD_RELEASE_4B_CONFIG); stm32_configgpio(MOD_RELEASE_5_CONFIG); /* Configure ARA key input pin */ stm32_configgpio(ARA_KEY_CONFIG); /* * (Module hotplug pins unconfigured. TODO, part of SW-1942.) */ /* Configure AP Wake from OFF pin */ gpio_set_value(PM_CBL_PWR_N_GPIO, 1); gpio_direction_out(PM_CBL_PWR_N_GPIO, 1); return 0; }
struct ara_board_info *board_init(void) { int i; int rc; /* Disable the I/O expanders for now. */ stm32_configgpio(SVC_RST_IOEXP1_GPIO); stm32_configgpio(SVC_RST_IOEXP2_GPIO); stm32_gpiowrite(SVC_RST_IOEXP1_GPIO, false); stm32_gpiowrite(SVC_RST_IOEXP2_GPIO, false); /* * Register STM32 GPIOs to GPIO chip framework. This has to happen * before the following configuration, which depends on STM32 GPIO * pin numbers. */ stm32_gpio_init(); /* Register the TCA64xx I/O Expanders to the gpio chip core. */ for (i = 0; i < evt1_board_info.nr_io_expanders; i++) { struct io_expander_info *io_exp = &evt1_board_info.io_expanders[i]; io_exp->i2c_dev = up_i2cinitialize(io_exp->i2c_bus); if (!io_exp->i2c_dev) { dbg_error("%s(): Failed to get I/O Expander I2C bus %u\n", __func__, io_exp->i2c_bus); board_exit(); return NULL; } if (tca64xx_init(&io_exp->io_exp_driver_data, io_exp->part, io_exp->i2c_dev, io_exp->i2c_addr, io_exp->reset, io_exp->irq, io_exp->gpio_base) < 0) { dbg_error("%s(): Failed to register I/O Expander(0x%02x)\n", __func__, io_exp->i2c_addr); board_exit(); return NULL; } } /* For now, just always enable REFCLK_MAIN and the buffers. */ rc = vreg_config(&refclk_main_vreg) || vreg_get(&refclk_main_vreg); if (rc) { dbg_error("%s: can't start REFCLK_MAIN: %d\n", __func__, rc); board_exit(); return NULL; } /* Configure the switch power supply lines. */ rc = vreg_config(&sw_vreg); if (rc) { dbg_error("%s: can't configure switch regulators: %d\n", __func__, rc); board_exit(); return NULL; } stm32_configgpio(evt1_board_info.sw_data.gpio_reset); up_udelay(POWER_SWITCH_OFF_STAB_TIME_US); /* Configure the wake/detect lines. */ stm32_configgpio(WD_1_DET_IN_GPIO); stm32_configgpio(WD_2_DET_IN_GPIO); stm32_configgpio(WD_3A_DET_IN_GPIO); stm32_configgpio(WD_3B_DET_IN_GPIO); stm32_configgpio(WD_4A_DET_IN_GPIO); stm32_configgpio(WD_4B_DET_IN_GPIO); stm32_configgpio(WD_5_DET_IN_GPIO); stm32_configgpio(WD_8A_DET_IN_GPIO); stm32_configgpio(WD_8B_DET_IN_GPIO); /* Configure the ARA key. */ stm32_configgpio(ARA_KEY_GPIO); /* * (Module hotplug pins unconfigured. TODO, part of SW-1942.) */ return &evt1_board_info; }