cpu.c 987 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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 <cpu_func.h>
  16. #include <irq_func.h>
  17. #include <asm/cache.h>
  18. #include <asm/system.h>
  19. static void cache_flush(void);
  20. int cleanup_before_linux (void)
  21. {
  22. /*
  23. * this function is called just before we call linux
  24. * it prepares the processor for linux
  25. *
  26. * we turn off caches etc ...
  27. */
  28. disable_interrupts();
  29. /* turn off I/D-cache */
  30. icache_disable();
  31. dcache_disable();
  32. l2_cache_disable();
  33. /* flush I/D-cache */
  34. cache_flush();
  35. return 0;
  36. }
  37. /* flush I/D-cache */
  38. static void cache_flush (void)
  39. {
  40. #if !(CONFIG_IS_ENABLED(SYS_ICACHE_OFF) && CONFIG_IS_ENABLED(SYS_DCACHE_OFF))
  41. unsigned long i = 0;
  42. asm ("mcr p15, 0, %0, c7, c7, 0": :"r" (i));
  43. #endif
  44. }