void ara_board_exit(void) { int i; /* Run the board specific code */ if (board_info->board_exit) { board_info->board_exit(board_info); } /* * First unregister the TCA64xx I/O Expanders and associated I2C bus(ses). * Done in reverse order from registration to account for IRQ chaining * between I/O Expander chips. */ for (i = board_info->nr_io_expanders - 1; i >= 0; i--) { struct io_expander_info *io_exp = &board_info->io_expanders[i]; if (io_exp->io_exp_driver_data) tca64xx_deinit(io_exp->io_exp_driver_data); if (io_exp->i2c_dev) up_i2cuninitialize(io_exp->i2c_dev); } /* Lastly unregister the GPIO Chip driver */ stm32_gpio_deinit(); board_info = NULL; }
void board_exit(void) { int i; /* If we were able to bringup the refclk, turn it off now. */ if (vreg_get_pwr_state(&refclk_main_vreg) == VREG_PWR_UP) { vreg_put(&refclk_main_vreg); } /* * Unregister the TCA64xx I/O Expanders and associated I2C * bus(ses). Done in reverse order from registration to account * for IRQ chaining between I/O Expander chips. */ for (i = evt1_board_info.nr_io_expanders - 1; i >= 0; i--) { struct io_expander_info *io_exp = &evt1_board_info.io_expanders[i]; if (io_exp->io_exp_driver_data) tca64xx_deinit(io_exp->io_exp_driver_data); if (io_exp->i2c_dev) up_i2cuninitialize(io_exp->i2c_dev); } /* Lastly unregister the GPIO Chip driver */ stm32_gpio_deinit(); }
void board_exit(void) { int i; /* * First unregister the TCA64xx I/O Expanders and associated I2C bus(ses). * Done in reverse order from registration to account for IRQ chaining * between I/O Expander chips. */ for (i = sdb_board_info.nr_io_expanders - 1; i >= 0; i--) { struct io_expander_info *io_exp = &sdb_board_info.io_expanders[i]; if (io_exp->io_exp_driver_data) tca64xx_deinit(io_exp->io_exp_driver_data); if (io_exp->i2c_dev) up_i2cuninitialize(io_exp->i2c_dev); } /* Disable the I/O Expanders power */ vreg_put(&ioexp_vreg); /* Lastly unregister the GPIO Chip driver */ stm32_gpio_deinit(); }
struct ara_board_info *ara_board_init(void) { int i; enum hwid hwid = board_get_hwid(); board_info = NULL; /* Check HWID, assign board_info struct and the Switch ES revision */ switch (hwid) { case HWID_DB3_0_1: board_info = &db3_board_info; dbg_info("HWID found as DB3.0/3.1\n"); break; case HWID_DB3_2: /* DB3.0/1 with ES3 Switch */ board_info = &db3_board_info; board_info->sw_data.rev = SWITCH_REV_ES3; dbg_info("HWID found as DB3.2\n"); break; case HWID_DB3_5: /* EVT1.5 + DB3.5 pwrmon + specific mapping of physical interfaces */ board_info = &evt1_5_board_info; board_info->pwrmon = &db3_5_pwrmon; board_info->interfaces = db3_5_interfaces; board_info->nr_interfaces = db3_5_nr_interfaces; dbg_info("HWID found as DB3.5\n"); break; case HWID_EVT1: board_info = &evt1_board_info; dbg_info("HWID found as EVT1\n"); break; case HWID_EVT1_5: board_info = &evt1_5_board_info; dbg_info("HWID found as EVT1.5\n"); break; case HWID_EVT1_6: board_info = &evt1_5_board_info; board_info->sw_data.rev = SWITCH_REV_ES2; dbg_info("HWID found as EVT1.6\n"); break; default: return NULL; } /* Disable the I/O Expanders for now */ for (i = 0; i < board_info->nr_io_expanders; i++) { struct io_expander_info *io_exp = &board_info->io_expanders[i]; stm32_configgpio(io_exp->reset); stm32_gpiowrite(io_exp->reset, 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(); /* Register the TCA64xx I/O Expanders GPIOs to Gpio Chip */ for (i = 0; i < board_info->nr_io_expanders; i++) { struct io_expander_info *io_exp = &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); goto err_deinit_gpio; } 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); goto err_uninit_i2c; } } } /* Run the board specific code */ if (board_info->board_init) { if (board_info->board_init(board_info)) { dbg_error("%s(): Failed to initalize board\n", __func__); goto err_uninit_i2c; } } /* Return the board specific info */ return board_info; err_uninit_i2c: /* Done in reverse order to account for possible IRQ chaining. */ for (i = board_info->nr_io_expanders - 1; i >= 0; i--) { struct io_expander_info *io_exp = &board_info->io_expanders[i]; if (io_exp->i2c_dev) { up_i2cuninitialize(io_exp->i2c_dev); } } err_deinit_gpio: stm32_gpio_deinit(); /* Leave the I/O expanders in reset here. */ return NULL; }