cpu.c 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  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 <asm/io.h>
  11. #include <asm/armv7m.h>
  12. /*
  13. * This is called right before passing control to
  14. * the Linux kernel point.
  15. */
  16. int cleanup_before_linux(void)
  17. {
  18. /*
  19. * this function is called just before we call linux
  20. * it prepares the processor for linux
  21. *
  22. * disable interrupt and turn off caches etc ...
  23. */
  24. disable_interrupts();
  25. /*
  26. * turn off D-cache
  27. * dcache_disable() in turn flushes the d-cache
  28. * MPU is still enabled & can't be disabled as the u-boot
  29. * code might be running in sdram which by default is not
  30. * executable area.
  31. */
  32. dcache_disable();
  33. /* invalidate to make sure no cache line gets dirty between
  34. * dcache flushing and disabling dcache */
  35. invalidate_dcache_all();
  36. icache_disable();
  37. invalidate_icache_all();
  38. return 0;
  39. }
  40. /*
  41. * Perform the low-level reset.
  42. */
  43. void reset_cpu(ulong addr)
  44. {
  45. /*
  46. * Perform reset but keep priority group unchanged.
  47. */
  48. writel((V7M_AIRCR_VECTKEY << V7M_AIRCR_VECTKEY_SHIFT)
  49. | (V7M_SCB->aircr & V7M_AIRCR_PRIGROUP_MSK)
  50. | V7M_AIRCR_SYSRESET, &V7M_SCB->aircr);
  51. }