cpu.c 1.0 KB

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