Merge tag 'u-boot-atmel-fixes-2020.07-a' of https://gitlab.denx.de/u-boot/custodians...
[oweals/u-boot.git] / board / compulab / cm_fx6 / spl.c
index 6fe937b4180fba98add32988d9820cc73d96680f..7d8243563ae3c7ed07abf6376e23efc1fac6b541 100644 (file)
@@ -1,14 +1,16 @@
+// SPDX-License-Identifier: GPL-2.0+
 /*
  * SPL specific code for Compulab CM-FX6 board
  *
  * Copyright (C) 2014, Compulab Ltd - http://compulab.co.il/
  *
  * Author: Nikita Kiryanov <nikita@compulab.co.il>
- *
- * SPDX-License-Identifier:    GPL-2.0+
  */
 
 #include <common.h>
+#include <clock_legacy.h>
+#include <hang.h>
+#include <init.h>
 #include <spl.h>
 #include <asm/io.h>
 #include <asm/gpio.h>
 #include <asm/arch/clock.h>
 #include <asm/arch/sys_proto.h>
 #include <asm/arch/crm_regs.h>
-#include <asm/imx-common/iomux-v3.h>
-#include <fsl_esdhc.h>
+#include <asm/mach-imx/iomux-v3.h>
+#include <fsl_esdhc_imx.h>
+#include <linux/delay.h>
 #include "common.h"
 
-DECLARE_GLOBAL_DATA_PTR;
-
 enum ddr_config {
        DDR_16BIT_256MB,
        DDR_32BIT_512MB,
@@ -174,6 +175,8 @@ static struct mx6_ddr_sysinfo cm_fx6_sysinfo_q = {
        .mif3_mode      = 3,
        .rst_to_cke     = 0x23,
        .sde_to_rst     = 0x10,
+       .refsel = 1,            /* Refresh cycles at 32KHz */
+       .refr = 7,              /* 8 refresh commands per refresh cycle */
 };
 
 static struct mx6_ddr3_cfg cm_fx6_ddr3_cfg_q = {
@@ -303,7 +306,7 @@ static void cm_fx6_setup_uart(void)
 static void cm_fx6_setup_ecspi(void)
 {
        cm_fx6_set_ecspi_iomux();
-       enable_cspi_clock(1, 0);
+       enable_spi_clk(1, 0);
 }
 #else
 static void cm_fx6_setup_ecspi(void) { }
@@ -313,7 +316,6 @@ void board_init_f(ulong dummy)
 {
        struct mxc_ccm_reg *mxc_ccm = (struct mxc_ccm_reg *)CCM_BASE_ADDR;
 
-       gd = &gdata;
        /*
         * We don't use DMA in SPL, but we do need it in U-Boot. U-Boot
         * initializes DMA very early (before all board code), so the only
@@ -333,21 +335,19 @@ void board_init_f(ulong dummy)
                puts("!!!ERROR!!! DRAM detection failed!!!\n");
                hang();
        }
-
-       memset(__bss_start, 0, __bss_end - __bss_start);
-       board_init_r(NULL, 0);
 }
 
-void spl_board_init(void)
+void board_boot_order(u32 *spl_boot_list)
 {
-       u32 boot_device = spl_boot_device();
-
-       if (boot_device == BOOT_DEVICE_SPI)
-               puts("Booting from SPI flash\n");
-       else if (boot_device == BOOT_DEVICE_MMC1)
-               puts("Booting from MMC\n");
-       else
-               puts("Unknown boot device\n");
+       spl_boot_list[0] = spl_boot_device();
+       switch (spl_boot_list[0]) {
+       case BOOT_DEVICE_SPI:
+               spl_boot_list[1] = BOOT_DEVICE_MMC1;
+               break;
+       case BOOT_DEVICE_MMC1:
+               spl_boot_list[1] = BOOT_DEVICE_SPI;
+               break;
+       }
 }
 
 #ifdef CONFIG_SPL_MMC_SUPPORT