void __init stm32_eth_init(void) { #if defined(CONFIG_STM32_MAC) int platform; /* * Enable clocks */ STM32_RCC->ahb1enr |= STM32_RCC_ENR_ETHMACEN | STM32_RCC_ENR_ETHMACTXEN | STM32_RCC_ENR_ETHMACRXEN; /* * Fix-up and register platform device */ platform = stm32_platform_get(); switch (platform) { case PLATFORM_STM32_STM3220G_EVAL: case PLATFORM_STM32_STM3240G_EVAL: case PLATFORM_STM32_STM_SOM: eth_device.dev.platform_data = &stm3220g_eval_eth_data; break; default: break; } platform_device_register(ð_device); #endif }
/* * Register the Flash platform device with the kernel. */ void __init stm32_flash_init(void) { unsigned int size = 0; /* * Calculate Flash and partition sizes at run time */ switch (stm32_platform_get()) { case PLATFORM_STM32_STM3220G_EVAL: case PLATFORM_STM32_STM3240G_EVAL: /* Size of NOR Flash on the STM-MEM add-on module */ size = 8*1024*1024; break; case PLATFORM_STM32_STM_STM32F439_SOM: flash_dev.name = stm32f4x9_flash_dev_name; flash_dev.dev.platform_data = &stm32f4_flash_data; case PLATFORM_STM32_STM_SOM: flash_dev.resource[0].start = 0x64000000; size = 16*1024*1024; break; case PLATFORM_STM32_STM_STM32F7_SOM: flash_dev.resource[0].start = CONFIG_FLASH_MEM_BASE; size = CONFIG_FLASH_SIZE; break; default: printk(KERN_ERR "%s: Unknown platform %#x, exit\n", __func__, stm32_platform_get()); goto xit; } flash_resources[0].end = flash_resources[0].start + size - 1; #if !defined(ENABLE_SPLASHSCREEN_PARTITION) flash_partitions[2].size = size - FLASH_JFFS2_OFFSET; #else flash_partitions[2].size = size - FLASH_JFFS2_OFFSET - FLASH_SPLASH_SIZE; flash_partitions[3].offset = size - FLASH_SPLASH_SIZE; #endif /* * Register a platform device for the external Flash. * If there is no external Flash in your design, or * you don't want to use it in your application, just * comment out the line below. */ platform_device_register(&flash_dev); xit: return; }
void __init stm32_i2c_gpio_init(void) { int platform; /* * Initialize board-specific data */ platform = stm32_platform_get(); switch (platform) { case PLATFORM_STM32_STM_STM32F7_SOM: stm32_gpio_i2c_device.dev.platform_data = &stm32f7som_i2c_gpio_data; break; default: break; } /* * Register the platform device */ if (stm32_gpio_i2c_device.dev.platform_data) platform_device_register(&stm32_gpio_i2c_device); }
/* * Register the STM32 specific SPI controllers and devices with the kernel. */ void __init stm32_spi_init(void) { int p = stm32_platform_get(); #if defined(CONFIG_STM32_SPI1) platform_set_drvdata(&spi_stm32_dev1, (void *) stm32_clock_get(CLOCK_PCLK2)); platform_device_register(&spi_stm32_dev1); #endif #if defined(CONFIG_STM32_SPI2) platform_set_drvdata(&spi_stm32_dev2, (void *) stm32_clock_get(CLOCK_PCLK1)); platform_device_register(&spi_stm32_dev2); #endif #if defined(CONFIG_STM32_SPI3) platform_set_drvdata(&spi_stm32_dev3, (void *) stm32_clock_get(CLOCK_PCLK1)); platform_device_register(&spi_stm32_dev3); #endif #if defined(CONFIG_STM32_SPI4) platform_set_drvdata(&spi_stm32_dev4, (void *) stm32_clock_get(CLOCK_PCLK2)); platform_device_register(&spi_stm32_dev4); #endif #if defined(CONFIG_STM32_SPI5) platform_set_drvdata(&spi_stm32_dev5, (void *) stm32_clock_get(CLOCK_PCLK2)); platform_device_register(&spi_stm32_dev5); #endif #if defined(CONFIG_STM32_SPI6) platform_set_drvdata(&spi_stm32_dev6, (void *) stm32_clock_get(CLOCK_PCLK2)); platform_device_register(&spi_stm32_dev6); #endif if (p == PLATFORM_STM32_STM_SOM || p == PLATFORM_STM32_STM_STM32F439_SOM) { /* This assumes that there is an SPI Flash device * handwired to SPI5 on the breadboard area of SOM-BSB-EXT. * SPI Flash can be accessed either via SPIDEV interface * and this takes precedence if SPIDEV is enabled in the kernel. * If SPIDEV is disabled, then SPI Flash can be * accessed via the Flash MTD interface */ #if defined(CONFIG_STM32_SPI5) && \ (defined(CONFIG_MTD_M25P80) || defined(CONFIG_SPI_SPIDEV)) /* * Flash MTD partitioning. * This is used only if CONFIG_SPIDEV is undefined */ #if !defined(CONFIG_SPI_SPIDEV) /* * SPI Flash partitioning: */ # define FLASH_JFFS2_OFFSET__STM32F4_SOM (1024 * 1024 * 1) # define FLASH_SIZE__STM32F4_SOM (1024 * 1024 * 4) static struct mtd_partition spi_stm32_flash_partitions__stm32f4_som[] = { { .name = "spi_flash_part0", .size = FLASH_JFFS2_OFFSET__STM32F4_SOM, .offset = 0, }, { .name = "spi_flash_part1", .size = FLASH_SIZE__STM32F4_SOM - FLASH_JFFS2_OFFSET__STM32F4_SOM, .offset = FLASH_JFFS2_OFFSET__STM32F4_SOM, }, };
/* * Register the STM32 specific I2C devices with the kernel. */ void __init stm32_i2c_init(void) { int p = stm32_platform_get(); #if defined(CONFIG_STM32_I2C1) /* * Pass the device parameters to the driver */ i2c_stm32_data_dev1.ref_clk = stm32_clock_get(CLOCK_PCLK1); platform_set_drvdata(&i2c_stm32_dev1, &i2c_stm32_data_dev1); /* * Register a platform device for this interface */ platform_device_register(&i2c_stm32_dev1); #endif #if defined(CONFIG_STM32_I2C2) /* * Pass the device parameters to the driver */ i2c_stm32_data_dev2.ref_clk = stm32_clock_get(CLOCK_PCLK1); platform_set_drvdata(&i2c_stm32_dev2, &i2c_stm32_data_dev2); /* * Register a platform device for this interface */ platform_device_register(&i2c_stm32_dev2); #endif #if defined(CONFIG_STM32_I2C3) /* * Pass the device parameters to the driver */ i2c_stm32_data_dev3.ref_clk = stm32_clock_get(CLOCK_PCLK1); platform_set_drvdata(&i2c_stm32_dev3, &i2c_stm32_data_dev3); /* * Register a platform device for this interface */ platform_device_register(&i2c_stm32_dev3); #endif #if defined(CONFIG_STM32_I2C4) /* * Pass the device parameters to the driver */ i2c_stm32_data_dev4.ref_clk = stm32_clock_get(CLOCK_PCLK1); platform_set_drvdata(&i2c_stm32_dev4, &i2c_stm32_data_dev4); /* * Register a platform device for this interface */ platform_device_register(&i2c_stm32_dev4); #endif /* * Perform board-specific I2C device registration */ if (p == PLATFORM_STM32_STM_SOM || p == PLATFORM_STM32_STM_STM32F439_SOM || p == PLATFORM_STM32_STM_STM32F7_SOM) { #if defined(CONFIG_STM32_I2C1) /* * This assumes that a compatible I2C EEPROM is * wired to I2C_1 in the baseboard area. */ #if defined(CONFIG_EEPROM_AT24) static struct i2c_board_info i2c_eeprom__dongle = { I2C_BOARD_INFO("24c512", 0x56) }; #endif #if defined(CONFIG_EEPROM_AT24) i2c_register_board_info(0, &i2c_eeprom__dongle, 1); #endif #endif } else if (p == PLATFORM_STM32_STM_DISCO) { #if defined(CONFIG_STM32_I2C3) #if defined(CONFIG_GPIO_PCAL6416A) static struct pcal6416a_platform_data stm32f4_pcal6416a_gpio_pdata = { .gpio_base = STM32_GPIO_LEN, }; #endif static struct i2c_board_info __initdata stm32f4_bdinfo_i2c3[] = { #if defined(CONFIG_GPIO_PCAL6416A) { I2C_BOARD_INFO("pcal6416a", 0x21), .platform_data = &stm32f4_pcal6416a_gpio_pdata, }, #endif #if defined(CONFIG_EEPROM_AT24) {