1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2016, STMicroelectronics - All Rights Reserved
4 * Author(s): Vikas Manocha, <vikas.manocha@st.com> for STMicroelectronics.
12 #include <phy_interface.h>
17 #include <st_logo_data.h>
20 #include <asm/armv7m.h>
21 #include <asm/arch/stm32.h>
22 #include <asm/arch/gpio.h>
23 #include <asm/arch/syscfg.h>
26 DECLARE_GLOBAL_DATA_PTR;
30 #ifndef CONFIG_SUPPORT_SPL
33 rv = uclass_get_device(UCLASS_RAM, 0, &dev);
35 debug("DRAM init failed: %d\n", rv);
40 return fdtdec_setup_mem_size_base();
43 int dram_init_banksize(void)
45 return fdtdec_setup_memory_banksize();
48 int board_early_init_f(void)
53 #ifdef CONFIG_SPL_BUILD
54 #ifdef CONFIG_SPL_OS_BOOT
55 int spl_start_uboot(void)
57 debug("SPL: booting kernel\n");
58 /* break into full u-boot on 'c' */
59 return serial_tstc() && serial_getc() == 'c';
63 int spl_dram_init(void)
67 rv = uclass_get_device(UCLASS_RAM, 0, &dev);
69 debug("DRAM init failed: %d\n", rv);
72 void spl_board_init(void)
75 preloader_console_init();
76 arch_cpu_init(); /* to configure mpu for sdram rw permissions */
78 u32 spl_boot_device(void)
80 return BOOT_DEVICE_XIP;
84 u32 get_board_rev(void)
89 int board_late_init(void)
91 struct gpio_desc gpio = {};
94 node = fdt_node_offset_by_compatible(gd->fdt_blob, 0, "st,led1");
98 gpio_request_by_name_nodev(offset_to_ofnode(node), "led-gpio", 0, &gpio,
101 if (dm_gpio_is_valid(&gpio)) {
102 dm_gpio_set_value(&gpio, 0);
104 dm_gpio_set_value(&gpio, 1);
108 node = fdt_node_offset_by_compatible(gd->fdt_blob, 0, "st,button1");
112 gpio_request_by_name_nodev(offset_to_ofnode(node), "button-gpio", 0,
115 if (dm_gpio_is_valid(&gpio)) {
116 if (dm_gpio_get_value(&gpio))
117 puts("usr button is at HIGH LEVEL\n");
119 puts("usr button is at LOW LEVEL\n");
127 gd->bd->bi_boot_params = gd->bd->bi_dram[0].start + 0x100;
129 #ifdef CONFIG_ETH_DESIGNWARE
130 const char *phy_mode;
133 node = fdt_node_offset_by_compatible(gd->fdt_blob, 0, "st,stm32-dwmac");
137 phy_mode = fdt_getprop(gd->fdt_blob, node, "phy-mode", NULL);
139 switch (phy_get_interface_by_name(phy_mode)) {
140 case PHY_INTERFACE_MODE_RMII:
141 STM32_SYSCFG->pmc |= SYSCFG_PMC_MII_RMII_SEL;
143 case PHY_INTERFACE_MODE_MII:
144 STM32_SYSCFG->pmc &= ~SYSCFG_PMC_MII_RMII_SEL;
147 printf("PHY interface %s not supported !\n", phy_mode);
151 #if defined(CONFIG_CMD_BMP)
152 bmp_display((ulong)stmicroelectronics_uboot_logo_8bit_rle,
153 BMP_ALIGN_CENTER, BMP_ALIGN_CENTER);
154 #endif /* CONFIG_CMD_BMP */