cpu.c 995 B

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