Merge tag 'u-boot-atmel-fixes-2020.07-a' of https://gitlab.denx.de/u-boot/custodians...
[oweals/u-boot.git] / arch / x86 / cpu / ivybridge / sdram.c
index 201368c9c7ce36f2349eaf8f9f7ba6bb7bdc3a76..99bc48021e6900fdb439fc2b1e8e04de99dfa93e 100644 (file)
@@ -1,3 +1,4 @@
+// SPDX-License-Identifier: GPL-2.0
 /*
  * Copyright (c) 2011 The Chromium OS Authors.
  * (C) Copyright 2010,2011
@@ -6,19 +7,20 @@
  * Portions from Coreboot mainboard/google/link/romstage.c
  * Copyright (C) 2007-2010 coresystems GmbH
  * Copyright (C) 2011 Google Inc.
- *
- * SPDX-License-Identifier:    GPL-2.0
  */
 
 #include <common.h>
 #include <errno.h>
 #include <fdtdec.h>
+#include <init.h>
+#include <log.h>
 #include <malloc.h>
 #include <net.h>
 #include <rtc.h>
 #include <spi.h>
 #include <spi_flash.h>
 #include <syscon.h>
+#include <sysreset.h>
 #include <asm/cpu.h>
 #include <asm/processor.h>
 #include <asm/gpio.h>
@@ -46,9 +48,11 @@ ulong board_get_usable_ram_top(ulong total_size)
        return mrc_common_board_get_usable_ram_top(total_size);
 }
 
-void dram_init_banksize(void)
+int dram_init_banksize(void)
 {
        mrc_common_dram_init_banksize();
+
+       return 0;
 }
 
 static int read_seed_from_cmos(struct pei_data *pei_data)
@@ -113,7 +117,7 @@ static int prepare_mrc_cache(struct pei_data *pei_data)
        ret = read_seed_from_cmos(pei_data);
        if (ret)
                return ret;
-       ret = mrccache_get_region(NULL, &entry);
+       ret = mrccache_get_region(MRC_TYPE_NORMAL, NULL, &entry);
        if (ret)
                return ret;
        mrc_cache = mrccache_find_current(&entry);
@@ -231,7 +235,6 @@ static int sdram_find(struct udevice *dev)
        uint32_t tseg_base, uma_size, tolud;
        uint64_t tom, me_base, touud;
        uint64_t uma_memory_base = 0;
-       uint64_t uma_memory_size;
        unsigned long long tomk;
        uint16_t ggc;
        u32 val;
@@ -296,7 +299,6 @@ static int sdram_find(struct udevice *dev)
                tolud += uma_size << 10;
                /* UMA starts at old TOLUD */
                uma_memory_base = tomk * 1024ULL;
-               uma_memory_size = uma_size * 1024ULL;
                debug("ME UMA base %llx size %uM\n", me_base, uma_size >> 10);
        }
 
@@ -310,13 +312,11 @@ static int sdram_find(struct udevice *dev)
                debug("%uM UMA", uma_size >> 10);
                tomk -= uma_size;
                uma_memory_base = tomk * 1024ULL;
-               uma_memory_size += uma_size * 1024ULL;
 
                /* GTT Graphics Stolen Memory Size (GGMS) */
                uma_size = ((ggc >> 8) & 0x3) * 1024ULL;
                tomk -= uma_size;
                uma_memory_base = tomk * 1024ULL;
-               uma_memory_size += uma_size * 1024ULL;
                debug(" and %uM GTT\n", uma_size >> 10);
        }
 
@@ -325,7 +325,6 @@ static int sdram_find(struct udevice *dev)
        uma_size = (uma_memory_base - tseg_base) >> 10;
        tomk -= uma_size;
        uma_memory_base = tomk * 1024ULL;
-       uma_memory_size += uma_size * 1024ULL;
        debug("TSEG base 0x%08x size %uM\n", tseg_base, uma_size >> 10);
 
        debug("Available memory below 4GB: %lluM\n", tomk >> 10);
@@ -501,7 +500,7 @@ int dram_init(void)
        /* If MRC data is not found we cannot continue S3 resume. */
        if (pei_data->boot_mode == PEI_BOOT_RESUME && !pei_data->mrc_input) {
                debug("Giving up in sdram_initialize: No MRC data\n");
-               reset_cpu(0);
+               sysreset_walk_halt(SYSRESET_COLD);
        }
 
        /* Pass console handler in pei_data */
@@ -540,12 +539,14 @@ int dram_init(void)
 
        /* S3 resume: don't save scrambler seed or MRC data */
        if (pei_data->boot_mode != PEI_BOOT_RESUME) {
+               struct mrc_output *mrc = &gd->arch.mrc[MRC_TYPE_NORMAL];
+
                /*
                 * This will be copied to SDRAM in reserve_arch(), then written
                 * to SPI flash in mrccache_save()
                 */
-               gd->arch.mrc_output = (char *)pei_data->mrc_output;
-               gd->arch.mrc_output_len = pei_data->mrc_output_len;
+               mrc->buf = (char *)pei_data->mrc_output;
+               mrc->len = pei_data->mrc_output_len;
                ret = write_seeds_to_cmos(pei_data);
                if (ret)
                        debug("Failed to write seeds to CMOS: %d\n", ret);