SPDX: Convert all of our single license tags to Linux Kernel style
[platform/kernel/u-boot.git] / board / st / stm32f746-disco / stm32f746-disco.c
index aeaa311..e21cfc6 100644 (file)
@@ -1,21 +1,21 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
- * (C) Copyright 2016
- * Vikas Manocha, <vikas.manocha@st.com>
- *
- * SPDX-License-Identifier:    GPL-2.0+
+ * Copyright (C) 2016, STMicroelectronics - All Rights Reserved
+ * Author(s): Vikas Manocha, <vikas.manocha@st.com> for STMicroelectronics.
  */
 
 #include <common.h>
 #include <dm.h>
+#include <lcd.h>
 #include <ram.h>
+#include <spl.h>
+#include <splash.h>
+#include <st_logo_data.h>
+#include <video.h>
 #include <asm/io.h>
 #include <asm/armv7m.h>
 #include <asm/arch/stm32.h>
 #include <asm/arch/gpio.h>
-#include <asm/arch/fmc.h>
-#include <dm/platform_data/serial_stm32x7.h>
-#include <asm/arch/stm32_periph.h>
-#include <asm/arch/stm32_defs.h>
 #include <asm/arch/syscfg.h>
 #include <asm/gpio.h>
 
@@ -36,16 +36,18 @@ int get_memory_base_size(fdt_addr_t *mr_base, fdt_addr_t *mr_size)
 }
 int dram_init(void)
 {
-       struct udevice *dev;
        int rv;
        fdt_addr_t mr_base, mr_size;
 
+#ifndef CONFIG_SUPPORT_SPL
+       struct udevice *dev;
        rv = uclass_get_device(UCLASS_RAM, 0, &dev);
        if (rv) {
                debug("DRAM init failed: %d\n", rv);
                return rv;
        }
 
+#endif
        rv = get_memory_base_size(&mr_base, &mr_size);
        if (rv)
                return rv;
@@ -68,25 +70,42 @@ int dram_init_banksize(void)
        return 0;
 }
 
-#ifdef CONFIG_ETH_DESIGNWARE
-static int stmmac_setup(void)
+int board_early_init_f(void)
 {
-       clock_setup(SYSCFG_CLOCK_CFG);
-       /* Set >RMII mode */
-       STM32_SYSCFG->pmc |= SYSCFG_PMC_MII_RMII_SEL;
-       clock_setup(STMMAC_CLOCK_CFG);
-
        return 0;
 }
 
-int board_early_init_f(void)
+#ifdef CONFIG_SPL_BUILD
+#ifdef CONFIG_SPL_OS_BOOT
+int spl_start_uboot(void)
 {
-       stmmac_setup();
-
-       return 0;
+       debug("SPL: booting kernel\n");
+       /* break into full u-boot on 'c' */
+       return serial_tstc() && serial_getc() == 'c';
 }
 #endif
 
+int spl_dram_init(void)
+{
+       struct udevice *dev;
+       int rv;
+       rv = uclass_get_device(UCLASS_RAM, 0, &dev);
+       if (rv)
+               debug("DRAM init failed: %d\n", rv);
+       return rv;
+}
+void spl_board_init(void)
+{
+       spl_dram_init();
+       preloader_console_init();
+       arch_cpu_init(); /* to configure mpu for sdram rw permissions */
+}
+u32 spl_boot_device(void)
+{
+       return BOOT_DEVICE_XIP;
+}
+
+#endif
 u32 get_board_rev(void)
 {
        return 0;
@@ -101,7 +120,7 @@ int board_late_init(void)
        if (node < 0)
                return -1;
 
-       gpio_request_by_name_nodev(gd->fdt_blob, node, "led-gpio", 0, &gpio,
+       gpio_request_by_name_nodev(offset_to_ofnode(node), "led-gpio", 0, &gpio,
                                   GPIOD_IS_OUT);
 
        if (dm_gpio_is_valid(&gpio)) {
@@ -115,8 +134,8 @@ int board_late_init(void)
        if (node < 0)
                return -1;
 
-       gpio_request_by_name_nodev(gd->fdt_blob, node, "button-gpio", 0, &gpio,
-                                  GPIOD_IS_IN);
+       gpio_request_by_name_nodev(offset_to_ofnode(node), "button-gpio", 0,
+                                  &gpio, GPIOD_IS_IN);
 
        if (dm_gpio_is_valid(&gpio)) {
                if (dm_gpio_get_value(&gpio))
@@ -131,5 +150,16 @@ int board_late_init(void)
 int board_init(void)
 {
        gd->bd->bi_boot_params = gd->bd->bi_dram[0].start + 0x100;
+
+#ifdef CONFIG_ETH_DESIGNWARE
+       /* Set >RMII mode */
+       STM32_SYSCFG->pmc |= SYSCFG_PMC_MII_RMII_SEL;
+#endif
+
+#if defined(CONFIG_CMD_BMP)
+       bmp_display((ulong)stmicroelectronics_uboot_logo_8bit_rle,
+                   BMP_ALIGN_CENTER, BMP_ALIGN_CENTER);
+#endif /* CONFIG_CMD_BMP */
+
        return 0;
 }