cpu.c 962 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * (C) Copyright 2004 Texas Insturments
  3. *
  4. * (C) Copyright 2002
  5. * Sysgo Real-Time Solutions, GmbH <www.elinos.com>
  6. * Marius Groeger <mgroeger@sysgo.de>
  7. *
  8. * (C) Copyright 2002
  9. * Gary Jennejohn, DENX Software Engineering, <garyj@denx.de>
  10. *
  11. * SPDX-License-Identifier: GPL-2.0+
  12. */
  13. /*
  14. * CPU specific code
  15. */
  16. #include <common.h>
  17. #include <command.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. /* flush I/D-cache */
  33. cache_flush();
  34. return 0;
  35. }
  36. /* flush I/D-cache */
  37. static void cache_flush (void)
  38. {
  39. /* invalidate both caches and flush btb */
  40. asm ("mcr p15, 0, %0, c7, c7, 0": :"r" (0));
  41. /* mem barrier to sync things */
  42. asm ("mcr p15, 0, %0, c7, c10, 4": :"r" (0));
  43. }