cache.c 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. // SPDX-License-Identifier: GPL-2.0-or-later
  2. /*
  3. * Copyright (C) 2019 Stephan Gerhold <stephan@gerhold.net>
  4. */
  5. #include <common.h>
  6. #include <cpu_func.h>
  7. #include <asm/armv7.h>
  8. #include <asm/cache.h>
  9. #include <asm/pl310.h>
  10. #define PL310_WAY_MASK 0xff
  11. #if !CONFIG_IS_ENABLED(SYS_DCACHE_OFF)
  12. void enable_caches(void)
  13. {
  14. /* Enable D-cache. I-cache is already enabled in start.S */
  15. dcache_enable();
  16. }
  17. #endif
  18. #ifdef CONFIG_SYS_L2_PL310
  19. void v7_outer_cache_disable(void)
  20. {
  21. struct pl310_regs *const pl310 = (struct pl310_regs *)CONFIG_SYS_PL310_BASE;
  22. /*
  23. * Linux expects the L2 cache to be turned off by the bootloader.
  24. * Otherwise, it fails very early (shortly after decompressing the kernel).
  25. *
  26. * On U8500, the L2 cache can be only turned on/off from the secure world.
  27. * Instead, prevent usage of the L2 cache by locking all ways.
  28. * The kernel needs to unlock them to make the L2 cache work again.
  29. */
  30. writel(PL310_WAY_MASK, &pl310->pl310_lockdown_dbase);
  31. writel(PL310_WAY_MASK, &pl310->pl310_lockdown_ibase);
  32. }
  33. #endif