cpu.c 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2010,2011
  4. * Vladimir Khusainov, Emcraft Systems, vlad@emcraft.com
  5. *
  6. * (C) Copyright 2015
  7. * Kamil Lulko, <kamil.lulko@gmail.com>
  8. */
  9. #include <common.h>
  10. #include <cpu_func.h>
  11. #include <irq_func.h>
  12. #include <asm/io.h>
  13. #include <asm/armv7m.h>
  14. /*
  15. * This is called right before passing control to
  16. * the Linux kernel point.
  17. */
  18. int cleanup_before_linux(void)
  19. {
  20. /*
  21. * this function is called just before we call linux
  22. * it prepares the processor for linux
  23. *
  24. * disable interrupt and turn off caches etc ...
  25. */
  26. disable_interrupts();
  27. /*
  28. * turn off D-cache
  29. * dcache_disable() in turn flushes the d-cache
  30. * MPU is still enabled & can't be disabled as the u-boot
  31. * code might be running in sdram which by default is not
  32. * executable area.
  33. */
  34. dcache_disable();
  35. /* invalidate to make sure no cache line gets dirty between
  36. * dcache flushing and disabling dcache */
  37. invalidate_dcache_all();
  38. icache_disable();
  39. invalidate_icache_all();
  40. return 0;
  41. }
  42. /*
  43. * Perform the low-level reset.
  44. */
  45. void reset_cpu(ulong addr)
  46. {
  47. /*
  48. * Perform reset but keep priority group unchanged.
  49. */
  50. writel((V7M_AIRCR_VECTKEY << V7M_AIRCR_VECTKEY_SHIFT)
  51. | (V7M_SCB->aircr & V7M_AIRCR_PRIGROUP_MSK)
  52. | V7M_AIRCR_SYSRESET, &V7M_SCB->aircr);
  53. }