cpu.c 915 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2002
  4. * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  5. * Marius Groeger <mgroeger@sysgo.de>
  6. *
  7. * (C) Copyright 2002
  8. * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
  9. */
  10. /*
  11. * CPU specific code
  12. */
  13. #include <common.h>
  14. #include <command.h>
  15. #include <asm/system.h>
  16. static void cache_flush(void);
  17. int cleanup_before_linux (void)
  18. {
  19. /*
  20. * this function is called just before we call linux
  21. * it prepares the processor for linux
  22. *
  23. * we turn off caches etc ...
  24. */
  25. disable_interrupts ();
  26. /* turn off I/D-cache */
  27. icache_disable();
  28. dcache_disable();
  29. l2_cache_disable();
  30. /* flush I/D-cache */
  31. cache_flush();
  32. return 0;
  33. }
  34. /* flush I/D-cache */
  35. static void cache_flush (void)
  36. {
  37. #if !(defined(CONFIG_SYS_ICACHE_OFF) && defined(CONFIG_SYS_DCACHE_OFF))
  38. unsigned long i = 0;
  39. asm ("mcr p15, 0, %0, c7, c7, 0": :"r" (i));
  40. #endif
  41. }