cpu.c 964 B

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