blob: a4b5cff61d988b0a1a5a9d181a0406caa234adad [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 Glass691d7192020-05-10 11:40:02 -06007#include <init.h>
Simon Glass336d4612020-02-03 07:36:16 -07008#include <malloc.h>
Weijie Gao9bf72ba2020-11-12 16:35:33 +08009#include <asm/addrspace.h>
Simon Glass401d1c42020-10-30 21:38:53 -060010#include <asm/global_data.h>
Simon Glasscd93d622020-05-10 11:40:13 -060011#include <linux/bitops.h>
Stefan Roese4c835a62018-09-05 15:12:35 +020012#include <linux/io.h>
13#include <linux/sizes.h>
Stefan Roese4c835a62018-09-05 15:12:35 +020014
Weijie Gao02cd4492020-04-21 09:28:34 +020015DECLARE_GLOBAL_DATA_PTR;
Stefan Roese4c835a62018-09-05 15:12:35 +020016
17int dram_init(void)
18{
Weijie Gao9bf72ba2020-11-12 16:35:33 +080019 gd->ram_size = get_ram_size((void *)KSEG1, SZ_256M);
Stefan Roese4c835a62018-09-05 15:12:35 +020020
21 return 0;
22}
Stefan Roese9814fb22019-05-28 08:11:37 +020023
24int last_stage_init(void)
25{
26 void *src, *dst;
27
28 src = malloc(SZ_64K);
29 dst = malloc(SZ_64K);
30 if (!src || !dst) {
31 printf("Can't allocate buffer for cache cleanup copy!\n");
32 return 0;
33 }
34
35 /*
36 * It has been noticed, that sometimes the d-cache is not in a
37 * "clean-state" when U-Boot is running on MT7688. This was
38 * detected when using the ethernet driver (which uses d-cache)
39 * and a TFTP command does not complete. Copying an area of 64KiB
40 * in DDR at a very late bootup time in U-Boot, directly before
41 * calling into the prompt, seems to fix this issue.
42 */
43 memcpy(dst, src, SZ_64K);
44 free(src);
45 free(dst);
46
47 return 0;
48}