/** * @brief Early initialization code. * @details This initialization must be performed just after stack setup * and before any other initialization. */ void __early_init(void) { #ifndef STM32F100_MCUCONF stm32_gpio_init(); #endif stm32_clock_init(); #if defined(HAL_DISABLE_DCACHE) SCB_DisableDCache(); #endif }
/* * STM32 plaform initialization. */ static void __init stm32_init(void) { /* * Configure the IOMUXes of STM32 */ stm32_iomux_init(); #if defined(CONFIG_STM32_DMA) /* * Configure DMA controller and its driver's API */ stm32_dma_init(); #endif #if defined(CONFIG_SERIAL_STM32) /* * Configure the USART devices */ stm32_uart_init(); #endif #if defined(CONFIG_STM32_MAC) /* * Configure the STM32 MAC */ stm32_eth_init(); #endif #if defined(CONFIG_SPI_STM32) /* * Configure the STM32 SPI devices */ stm32_spi_init(); #endif #if defined(CONFIG_I2C_STM32) /* * Configure the STM32 I2C devices */ stm32_i2c_init(); #endif #if defined(CONFIG_MTD_PHYSMAP) /* * Configure external Flash */ stm32_flash_init(); #endif #if defined(CONFIG_MMC_ARMMMCI) /* * Configure SD card controller */ stm32_sdcard_init(); #endif #if defined(CONFIG_RTC_DRV_STM32F2) /* * Initialize the on-chip real-time clock */ stm32_rtc_init(); #endif #if defined(CONFIG_GPIOLIB) /* * Register the MCU GPIO chip */ stm32_gpio_init(); #endif }
/* * STM32 plaform initialization. */ static void __init stm32_init(void) { /* * Configure the IOMUXes of STM32 */ stm32_iomux_init(); #if defined(CONFIG_STM32_DMA) /* * Configure DMA controller and its driver's API */ stm32_dma_init(); #endif #if defined(CONFIG_SERIAL_STM32) /* * Configure the USART devices */ stm32_uart_init(); #endif #if defined(CONFIG_STM32_MAC) /* * Configure the STM32 MAC */ stm32_eth_init(); #endif #if defined(CONFIG_SPI_STM32) /* * Configure the STM32 SPI devices */ stm32_spi_init(); #endif #if defined(CONFIG_I2C_STM32) || defined(CONFIG_I2C_STM32F7) /* * Configure the STM32 I2C devices */ stm32_i2c_init(); #endif #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_STM32F4_MAP) /* * Configure external Flash */ stm32_flash_init(); #endif #if defined(CONFIG_MMC_ARMMMCI) /* * Configure SD card controller */ stm32_sdcard_init(); #endif #if defined(CONFIG_RTC_DRV_STM32F2) /* * Initialize the on-chip real-time clock */ stm32_rtc_init(); #endif #if defined(CONFIG_STM32_USB_OTG_FS) /* * Initialize the USB OTG FS controller */ stm32_usb_otg_fs_init(); #endif #if defined(CONFIG_STM32_USB_OTG_HS) /* * Initialize the USB OTG HS controller */ stm32_usb_otg_hs_init(); #endif #if defined(CONFIG_GPIOLIB) /* * Register the MCU GPIO chip */ stm32_gpio_init(); #endif #if defined(CONFIG_I2C_GPIO) /* * Bit-bang GPIO I2C implementation */ stm32_i2c_gpio_init(); #endif #if defined(CONFIG_STM32_FB) /* * Register LCD controller with the framebuffer driver */ stm32f4x9_fb_init(); #endif }
/** * @brief Early initialization code. * @details GPIO ports and system clocks are initialized before everything * else. */ void __early_init(void) { stm32_gpio_init(); stm32_clock_init(); }
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; }
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; }
void board_initialize(void) { dbg("%d MHz\n", STM32_SYSCLK_FREQUENCY / 1000000); #if defined(CONFIG_GPIO_CHIP_STM32) stm32_gpio_init(); #endif #ifdef CONFIG_STM32_LPTIM1 stm32_lptim1_on(); #endif #ifdef CONFIG_STM32_SPI stm32_spiinitialize(); #endif #ifdef CONFIG_MODS_DIET mods_init(); #endif #ifndef CONFIG_BOARD_INITTHREAD # error "Must enable INITTHREAD" #endif #ifdef CONFIG_DEVICE_CORE device_table_register(&muc_device_table); #ifdef CONFIG_FUSB302 fusb302_register(GPIO_MODS_FUSB302_INT_N, GPIO_MODS_VBUS_PWR_EN); #endif #ifdef CONFIG_FUSB302_USB_EXT extern struct device_driver fusb302_usb_ext_driver; device_register_driver(&fusb302_usb_ext_driver); #endif #ifdef CONFIG_FUSB302_EXT_POWER extern struct device_driver fusb302_ext_power_driver; device_register_driver(&fusb302_ext_power_driver); #endif #ifdef CONFIG_MODS_RAW extern struct device_driver mods_raw_driver; device_register_driver(&mods_raw_driver); #endif #ifdef CONFIG_MODS_RAW_BLINKY extern struct device_driver mods_raw_blinky_driver; device_register_driver(&mods_raw_blinky_driver); #endif #ifdef CONFIG_MODS_RAW_TERMAPP extern struct device_driver mods_raw_termapp_driver; device_register_driver(&mods_raw_termapp_driver); #endif #ifdef CONFIG_MODS_RAW_TEMPERATURE extern struct device_driver mods_raw_temperature_driver; device_register_driver(&mods_raw_temperature_driver); #endif #ifdef CONFIG_GREYBUS_MODS_PTP_DEVICE extern struct device_driver mods_ptp_driver; device_register_driver(&mods_ptp_driver); #endif #ifdef CONFIG_CHARGER_DEVICE_BQ24292 extern struct device_driver bq24292_charger_driver; device_register_driver(&bq24292_charger_driver); #endif #ifdef CONFIG_CHARGER_DEVICE_BQ25896 extern struct device_driver bq25896_charger_driver; device_register_driver(&bq25896_charger_driver); #endif #ifdef CONFIG_GREYBUS_MODS_PTP_CHG_DEVICE_SWITCH extern struct device_driver switch_ptp_chg_driver; device_register_driver(&switch_ptp_chg_driver); #endif #ifdef CONFIG_MAX17050_DEVICE extern struct device_driver batt_driver; device_register_driver(&batt_driver); #endif #ifdef CONFIG_BATTERY_TEMP_DEVICE_MAX17050 extern struct device_driver max17050_battery_temp_driver; device_register_driver(&max17050_battery_temp_driver); #endif #ifdef CONFIG_BATTERY_LEVEL_DEVICE_MAX17050 extern struct device_driver max17050_battery_level_driver; device_register_driver(&max17050_battery_level_driver); #endif #ifdef CONFIG_BATTERY_VOLTAGE_DEVICE_MAX17050 extern struct device_driver max17050_battery_voltage_driver; device_register_driver(&max17050_battery_voltage_driver); #endif #ifdef CONFIG_MHB_APBE_CTRL_DEVICE extern struct device_driver apbe_pwrctrl_driver; device_register_driver(&apbe_pwrctrl_driver); #endif #ifdef CONFIG_BATTERY_GOOD_DEVICE_COMP extern struct device_driver comp_batt_good_driver; device_register_driver(&comp_batt_good_driver); #endif #ifdef CONFIG_GREYBUS_SENSORS_EXT_DUMMY_PRESSURE extern struct device_driver sensor_dummy_pressure_driver; device_register_driver(&sensor_dummy_pressure_driver); #endif #ifdef CONFIG_GREYBUS_SENSORS_EXT_DUMMY_ACCEL extern struct device_driver sensor_dummy_accel_driver; device_register_driver(&sensor_dummy_accel_driver); #endif #ifdef CONFIG_HDMI_DISPLAY extern struct device_driver hdmi_display_driver; device_register_driver(&hdmi_display_driver); #endif #ifdef CONFIG_STM32_UART_DEVICE extern struct device_driver stm32_uart_driver; device_register_driver(&stm32_uart_driver); #endif #if CONFIG_MHB_UART extern struct device_driver mhb_driver; device_register_driver(&mhb_driver); #endif #ifdef CONFIG_MHB_DSI_DISPLAY extern struct device_driver dsi_display_driver; device_register_driver(&dsi_display_driver); #endif #ifdef CONFIG_BACKLIGHT_DCS extern struct device_driver dcs_backlight_driver; device_register_driver(&dcs_backlight_driver); #endif #ifdef CONFIG_BACKLIGHT_ISL98611 extern struct device_driver isl98611_backlight_driver; device_register_driver(&isl98611_backlight_driver); #endif #ifdef CONFIG_BACKLIGHT_LM27965 extern struct device_driver lm27965_backlight_driver; device_register_driver(&lm27965_backlight_driver); #endif #if defined(CONFIG_MHB_CAMERA) extern struct device_driver cam_ext_mhb_driver; device_register_driver(&cam_ext_mhb_driver); #endif #if defined(CONFIG_CAMERA_IMX220) extern struct device_driver imx220_mhb_camera_driver; device_register_driver(&imx220_mhb_camera_driver); #endif #if defined(CONFIG_CAMERA_IMX230) extern struct device_driver imx230_mhb_camera_driver; device_register_driver(&imx230_mhb_camera_driver); #endif #ifdef CONFIG_MODS_AUDIO_TFA9890 extern struct device_driver tfa9890_i2s_direct_driver; device_register_driver(&tfa9890_i2s_direct_driver); extern struct device_driver tfa9890_audio_dev_driver; device_register_driver(&tfa9890_audio_dev_driver); #endif #ifdef CONFIG_MODS_RAW_FACTORY extern struct device_driver display_mux_driver; device_register_driver(&display_mux_driver); extern struct device_driver mods_raw_factory_driver; device_register_driver(&mods_raw_factory_driver); #endif #endif #if defined(CONFIG_CHARGER_BQ24292) (void)bq24292_driver_init(GPIO_MODS_CHG_INT_N, GPIO_MODS_CHG_PG_N); #endif #ifdef CONFIG_BATTERY_MAX17050 struct i2c_dev_s *i2c = up_i2cinitialize(MAX17050_I2C_BUS); if (i2c) { g_battery = max17050_initialize(i2c, MAX17050_I2C_FREQ, GPIO_MODS_CC_ALERT); if (!g_battery) { up_i2cuninitialize(i2c); } } # if defined(CONFIG_BATTERY_STATE) /* Must be initialized after MAX17050 core driver has been initialized */ battery_state_init(); # endif #endif #if !defined(CONFIG_GREYBUS_PTP_EXT_SUPPORTED) /* Set the power paths to be able to use USB VBUS as the system power and * to prevent applying voltage to VBUS pin on the Mod connector. Also, * prevent accepting power from the PCARD VBUS connection. */ gpio_set_value(GPIO_MODS_CHG_VINA_EN, 1); gpio_set_value(GPIO_MODS_CHG_VINB_EN, 0); #endif }
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; }