blob: 459a9673ebe8054b419032f9948b6c8aec1cf3d6 [file] [log] [blame]
Stefan Roese4c835a62018-09-05 15:12:35 +02001// SPDX-License-Identifier: GPL-2.0+
2/*
3 * Copyright (C) 2018 Stefan Roese <sr@denx.de>
4 */
5
6#include <common.h>
Simon Glass336d4612020-02-03 07:36:16 -07007#include <malloc.h>
Stefan Roese4c835a62018-09-05 15:12:35 +02008#include <linux/io.h>
9#include <linux/sizes.h>
Stefan Roese4c835a62018-09-05 15:12:35 +020010
Weijie Gao02cd4492020-04-21 09:28:34 +020011DECLARE_GLOBAL_DATA_PTR;
Stefan Roese4c835a62018-09-05 15:12:35 +020012
13int dram_init(void)
14{
Weijie Gao02cd4492020-04-21 09:28:34 +020015#ifdef CONFIG_SKIP_LOWLEVEL_INIT
Stefan Roese4c835a62018-09-05 15:12:35 +020016 gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE, SZ_256M);
Weijie Gao02cd4492020-04-21 09:28:34 +020017#endif
Stefan Roese4c835a62018-09-05 15:12:35 +020018
19 return 0;
20}
Stefan Roese9814fb22019-05-28 08:11:37 +020021
22int last_stage_init(void)
23{
24 void *src, *dst;
25
26 src = malloc(SZ_64K);
27 dst = malloc(SZ_64K);
28 if (!src || !dst) {
29 printf("Can't allocate buffer for cache cleanup copy!\n");
30 return 0;
31 }
32
33 /*
34 * It has been noticed, that sometimes the d-cache is not in a
35 * "clean-state" when U-Boot is running on MT7688. This was
36 * detected when using the ethernet driver (which uses d-cache)
37 * and a TFTP command does not complete. Copying an area of 64KiB
38 * in DDR at a very late bootup time in U-Boot, directly before
39 * calling into the prompt, seems to fix this issue.
40 */
41 memcpy(dst, src, SZ_64K);
42 free(src);
43 free(dst);
44
45 return 0;
46}