Stefan Roese | 65da15e | 2018-09-05 15:12:35 +0200 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
| 2 | /* |
| 3 | * Copyright (C) 2018 Stefan Roese <sr@denx.de> |
| 4 | */ |
| 5 | |
| 6 | #include <common.h> |
Simon Glass | 9758973 | 2020-05-10 11:40:02 -0600 | [diff] [blame^] | 7 | #include <init.h> |
Simon Glass | 9bc1564 | 2020-02-03 07:36:16 -0700 | [diff] [blame] | 8 | #include <malloc.h> |
Stefan Roese | 65da15e | 2018-09-05 15:12:35 +0200 | [diff] [blame] | 9 | #include <linux/io.h> |
| 10 | #include <linux/sizes.h> |
Stefan Roese | 65da15e | 2018-09-05 15:12:35 +0200 | [diff] [blame] | 11 | |
developer | 29b37c5 | 2020-04-21 09:28:34 +0200 | [diff] [blame] | 12 | DECLARE_GLOBAL_DATA_PTR; |
Stefan Roese | 65da15e | 2018-09-05 15:12:35 +0200 | [diff] [blame] | 13 | |
| 14 | int dram_init(void) |
| 15 | { |
developer | 29b37c5 | 2020-04-21 09:28:34 +0200 | [diff] [blame] | 16 | #ifdef CONFIG_SKIP_LOWLEVEL_INIT |
Stefan Roese | 65da15e | 2018-09-05 15:12:35 +0200 | [diff] [blame] | 17 | gd->ram_size = get_ram_size((void *)CONFIG_SYS_SDRAM_BASE, SZ_256M); |
developer | 29b37c5 | 2020-04-21 09:28:34 +0200 | [diff] [blame] | 18 | #endif |
Stefan Roese | 65da15e | 2018-09-05 15:12:35 +0200 | [diff] [blame] | 19 | |
| 20 | return 0; |
| 21 | } |
Stefan Roese | 17679e4 | 2019-05-28 08:11:37 +0200 | [diff] [blame] | 22 | |
| 23 | int last_stage_init(void) |
| 24 | { |
| 25 | void *src, *dst; |
| 26 | |
| 27 | src = malloc(SZ_64K); |
| 28 | dst = malloc(SZ_64K); |
| 29 | if (!src || !dst) { |
| 30 | printf("Can't allocate buffer for cache cleanup copy!\n"); |
| 31 | return 0; |
| 32 | } |
| 33 | |
| 34 | /* |
| 35 | * It has been noticed, that sometimes the d-cache is not in a |
| 36 | * "clean-state" when U-Boot is running on MT7688. This was |
| 37 | * detected when using the ethernet driver (which uses d-cache) |
| 38 | * and a TFTP command does not complete. Copying an area of 64KiB |
| 39 | * in DDR at a very late bootup time in U-Boot, directly before |
| 40 | * calling into the prompt, seems to fix this issue. |
| 41 | */ |
| 42 | memcpy(dst, src, SZ_64K); |
| 43 | free(src); |
| 44 | free(dst); |
| 45 | |
| 46 | return 0; |
| 47 | } |