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.
13 #include <phy_interface.h>
18 #include <st_logo_data.h>
21 #include <asm/armv7m.h>
22 #include <asm/arch/stm32.h>
23 #include <asm/arch/gpio.h>
24 #include <asm/arch/syscfg.h>
26 #include <linux/delay.h>
28 DECLARE_GLOBAL_DATA_PTR;
32 #ifndef CONFIG_SUPPORT_SPL
35 rv = uclass_get_device(UCLASS_RAM, 0, &dev);
37 debug("DRAM init failed: %d\n", rv);
42 return fdtdec_setup_mem_size_base();
45 int dram_init_banksize(void)
47 return fdtdec_setup_memory_banksize();
50 int board_early_init_f(void)
55 #ifdef CONFIG_SPL_BUILD
56 #ifdef CONFIG_SPL_OS_BOOT
57 int spl_start_uboot(void)
59 debug("SPL: booting kernel\n");
60 /* break into full u-boot on 'c' */
61 return serial_tstc() && serial_getc() == 'c';
65 int spl_dram_init(void)
69 rv = uclass_get_device(UCLASS_RAM, 0, &dev);
71 debug("DRAM init failed: %d\n", rv);
74 void spl_board_init(void)
77 preloader_console_init();
78 arch_cpu_init(); /* to configure mpu for sdram rw permissions */
80 u32 spl_boot_device(void)
82 return BOOT_DEVICE_XIP;
86 u32 get_board_rev(void)
91 int board_late_init(void)
93 struct gpio_desc gpio = {};
96 node = fdt_node_offset_by_compatible(gd->fdt_blob, 0, "st,led1");
100 gpio_request_by_name_nodev(offset_to_ofnode(node), "led-gpio", 0, &gpio,
103 if (dm_gpio_is_valid(&gpio)) {
104 dm_gpio_set_value(&gpio, 0);
106 dm_gpio_set_value(&gpio, 1);
110 node = fdt_node_offset_by_compatible(gd->fdt_blob, 0, "st,button1");
114 gpio_request_by_name_nodev(offset_to_ofnode(node), "button-gpio", 0,
117 if (dm_gpio_is_valid(&gpio)) {
118 if (dm_gpio_get_value(&gpio))
119 puts("usr button is at HIGH LEVEL\n");
121 puts("usr button is at LOW LEVEL\n");
129 gd->bd->bi_boot_params = gd->bd->bi_dram[0].start + 0x100;
131 #ifdef CONFIG_ETH_DESIGNWARE
132 const char *phy_mode;
135 node = fdt_node_offset_by_compatible(gd->fdt_blob, 0, "st,stm32-dwmac");
139 phy_mode = fdt_getprop(gd->fdt_blob, node, "phy-mode", NULL);
141 switch (phy_get_interface_by_name(phy_mode)) {
142 case PHY_INTERFACE_MODE_RMII:
143 STM32_SYSCFG->pmc |= SYSCFG_PMC_MII_RMII_SEL;
145 case PHY_INTERFACE_MODE_MII:
146 STM32_SYSCFG->pmc &= ~SYSCFG_PMC_MII_RMII_SEL;
149 printf("PHY interface %s not supported !\n", phy_mode);
153 #if defined(CONFIG_CMD_BMP)
154 bmp_display((ulong)stmicroelectronics_uboot_logo_8bit_rle,
155 BMP_ALIGN_CENTER, BMP_ALIGN_CENTER);
156 #endif /* CONFIG_CMD_BMP */