Commit b97476965bf292c13074e01de4bd39253de0ef66

Authored by Vikas Manocha
Committed by Tom Rini
1 parent ea744fca0e

stm32: stm32f7: add spl build support

This commit supports booting from stm32 internal nor flash. spl U-Boot
initializes the sdram memory, copies next image (e.g. standard U-Boot)
to sdram & then jumps to entry point.

Here are the flash memory addresses for U-Boot-spl & standard U-Boot:
	- spl U-Boot		: 0x0800_0000
	- standard U-Boot	: 0x0800_8000

To compile u-boot without spl: Remove SUPPORT_SPL configuration
(arch/arm/mach-stm32/Kconfig)

Signed-off-by: Vikas Manocha <vikas.manocha@st.com>
[trini: Rework Kconfig logic a bit]
Signed-off-by: Tom Rini <trini@konsulko.com>

Showing 5 changed files with 65 additions and 3 deletions Side-by-side Diff

arch/arm/mach-stm32/Kconfig
... ... @@ -8,6 +8,23 @@
8 8  
9 9 config STM32F7
10 10 bool "stm32f7 family"
  11 + select SUPPORT_SPL
  12 + select SPL
  13 + select SPL_CLK
  14 + select SPL_DM
  15 + select SPL_DM_SEQ_ALIAS
  16 + select SPL_DRIVERS_MISC_SUPPORT
  17 + select SPL_GPIO_SUPPORT
  18 + select SPL_LIBCOMMON_SUPPORT
  19 + select SPL_LIBGENERIC_SUPPORT
  20 + select SPL_MTD_SUPPORT
  21 + select SPL_OF_CONTROL
  22 + select SPL_OF_LIBFDT
  23 + select SPL_OF_TRANSLATE
  24 + select SPL_PINCTRL
  25 + select SPL_RAM
  26 + select SPL_SERIAL_SUPPORT
  27 + select SPL_SYS_MALLOC_SIMPLE
11 28  
12 29 source "arch/arm/mach-stm32/stm32f4/Kconfig"
13 30 source "arch/arm/mach-stm32/stm32f1/Kconfig"
board/st/stm32f746-disco/stm32f746-disco.c
... ... @@ -8,6 +8,7 @@
8 8 #include <common.h>
9 9 #include <dm.h>
10 10 #include <ram.h>
  11 +#include <spl.h>
11 12 #include <asm/io.h>
12 13 #include <asm/armv7m.h>
13 14 #include <asm/arch/stm32.h>
14 15  
15 16  
... ... @@ -36,16 +37,18 @@
36 37 }
37 38 int dram_init(void)
38 39 {
39   - struct udevice *dev;
40 40 int rv;
41 41 fdt_addr_t mr_base, mr_size;
42 42  
  43 +#ifndef CONFIG_SUPPORT_SPL
  44 + struct udevice *dev;
43 45 rv = uclass_get_device(UCLASS_RAM, 0, &dev);
44 46 if (rv) {
45 47 debug("DRAM init failed: %d\n", rv);
46 48 return rv;
47 49 }
48 50  
  51 +#endif
49 52 rv = get_memory_base_size(&mr_base, &mr_size);
50 53 if (rv)
51 54 return rv;
... ... @@ -87,6 +90,28 @@
87 90 }
88 91 #endif
89 92  
  93 +#ifdef CONFIG_SPL_BUILD
  94 +int spl_dram_init(void)
  95 +{
  96 + struct udevice *dev;
  97 + int rv;
  98 + rv = uclass_get_device(UCLASS_RAM, 0, &dev);
  99 + if (rv)
  100 + debug("DRAM init failed: %d\n", rv);
  101 + return rv;
  102 +}
  103 +void spl_board_init(void)
  104 +{
  105 + spl_dram_init();
  106 + preloader_console_init();
  107 + arch_cpu_init(); /* to configure mpu for sdram rw permissions */
  108 +}
  109 +u32 spl_boot_device(void)
  110 +{
  111 + return BOOT_DEVICE_NOR;
  112 +}
  113 +
  114 +#endif
90 115 u32 get_board_rev(void)
91 116 {
92 117 return 0;
configs/stm32f746-disco_defconfig
... ... @@ -39,7 +39,6 @@
39 39 CONFIG_PINCTRL=y
40 40 # CONFIG_PINCTRL_FULL is not set
41 41 CONFIG_PINCTRL_STM32=y
42   -# CONFIG_SPL_SERIAL_PRESENT is not set
43 42 CONFIG_DM_SPI=y
44 43 CONFIG_STM32_QSPI=y
45 44 CONFIG_OF_LIBFDT_OVERLAY=y
drivers/pinctrl/Kconfig
... ... @@ -69,6 +69,7 @@
69 69 config SPL_PINCTRL_FULL
70 70 bool "Support full pin controllers in SPL"
71 71 depends on SPL_PINCTRL && SPL_OF_CONTROL
  72 + default n if TARGET_STM32F746_DISCO
72 73 default y
73 74 help
74 75 This option is an SPL-variant of the PINCTRL_FULL option.
include/configs/stm32f746-disco.h
... ... @@ -10,8 +10,13 @@
10 10  
11 11 #define CONFIG_SYS_FLASH_BASE 0x08000000
12 12 #define CONFIG_SYS_INIT_SP_ADDR 0x20050000
13   -#define CONFIG_SYS_TEXT_BASE 0x08000000
14 13  
  14 +#ifdef CONFIG_SUPPORT_SPL
  15 +#define CONFIG_SYS_TEXT_BASE 0xC0000000
  16 +#else
  17 +#define CONFIG_SYS_TEXT_BASE CONFIG_SYS_FLASH_BASE
  18 +#endif
  19 +
15 20 /*
16 21 * Configuration of the external SDRAM memory
17 22 */
... ... @@ -69,5 +74,20 @@
69 74 #define CONFIG_CMD_CACHE
70 75 #define CONFIG_BOARD_LATE_INIT
71 76 #define CONFIG_DISPLAY_BOARDINFO
  77 +
  78 +/* For SPL */
  79 +#ifdef CONFIG_SUPPORT_SPL
  80 +#define CONFIG_SPL_STACK CONFIG_SYS_INIT_SP_ADDR
  81 +#define CONFIG_SPL_FRAMEWORK
  82 +#define CONFIG_SPL_BOARD_INIT
  83 +#define CONFIG_SPL_TEXT_BASE CONFIG_SYS_FLASH_BASE
  84 +#define CONFIG_SYS_MONITOR_LEN (512 * 1024)
  85 +#define CONFIG_SYS_SPL_LEN 0x00008000
  86 +#define CONFIG_SYS_UBOOT_START 0XC00003FD
  87 +#define CONFIG_SYS_UBOOT_BASE (CONFIG_SYS_FLASH_BASE + \
  88 + CONFIG_SYS_SPL_LEN)
  89 +#endif
  90 +/* For SPL ends */
  91 +
72 92 #endif /* __CONFIG_H */