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>
20 #include <asm/global_data.h>
22 #include <asm/armv7m.h>
23 #include <asm/arch/stm32.h>
24 #include <asm/arch/gpio.h>
25 #include <asm/arch/syscfg.h>
27 #include <linux/delay.h>
29 DECLARE_GLOBAL_DATA_PTR;
33 #ifndef CONFIG_SUPPORT_SPL
36 rv = uclass_get_device(UCLASS_RAM, 0, &dev);
38 debug("DRAM init failed: %d\n", rv);
43 return fdtdec_setup_mem_size_base();
46 int dram_init_banksize(void)
48 return fdtdec_setup_memory_banksize();
51 #ifdef CONFIG_SPL_BUILD
52 #ifdef CONFIG_SPL_OS_BOOT
53 int spl_start_uboot(void)
55 debug("SPL: booting kernel\n");
56 /* break into full u-boot on 'c' */
57 return serial_tstc() && serial_getc() == 'c';
61 int spl_dram_init(void)
65 rv = uclass_get_device(UCLASS_RAM, 0, &dev);
67 debug("DRAM init failed: %d\n", rv);
70 void spl_board_init(void)
72 preloader_console_init();
74 arch_cpu_init(); /* to configure mpu for sdram rw permissions */
76 u32 spl_boot_device(void)
78 return BOOT_DEVICE_XIP;
82 int board_late_init(void)
84 struct gpio_desc gpio = {};
87 node = fdt_node_offset_by_compatible(gd->fdt_blob, 0, "st,led1");
91 gpio_request_by_name_nodev(offset_to_ofnode(node), "led-gpio", 0, &gpio,
94 if (dm_gpio_is_valid(&gpio)) {
95 dm_gpio_set_value(&gpio, 0);
97 dm_gpio_set_value(&gpio, 1);
101 node = fdt_node_offset_by_compatible(gd->fdt_blob, 0, "st,button1");
105 gpio_request_by_name_nodev(offset_to_ofnode(node), "button-gpio", 0,
108 if (dm_gpio_is_valid(&gpio)) {
109 if (dm_gpio_get_value(&gpio))
110 puts("usr button is at HIGH LEVEL\n");
112 puts("usr button is at LOW LEVEL\n");
120 #ifdef CONFIG_ETH_DESIGNWARE
121 const char *phy_mode;
124 node = fdt_node_offset_by_compatible(gd->fdt_blob, 0, "st,stm32-dwmac");
128 phy_mode = fdt_getprop(gd->fdt_blob, node, "phy-mode", NULL);
130 switch (phy_get_interface_by_name(phy_mode)) {
131 case PHY_INTERFACE_MODE_RMII:
132 STM32_SYSCFG->pmc |= SYSCFG_PMC_MII_RMII_SEL;
134 case PHY_INTERFACE_MODE_MII:
135 STM32_SYSCFG->pmc &= ~SYSCFG_PMC_MII_RMII_SEL;
138 printf("PHY interface %s not supported !\n", phy_mode);
142 #if defined(CONFIG_CMD_BMP)
143 bmp_display((ulong)stmicroelectronics_uboot_logo_8bit_rle,
144 BMP_ALIGN_CENTER, BMP_ALIGN_CENTER);
145 #endif /* CONFIG_CMD_BMP */