l2cache.c 668 B

1234567891011121314151617181920212223242526272829
  1. #include <linux/init.h>
  2. #include <linux/kernel.h>
  3. #include <linux/string.h>
  4. #include <memmap.h>
  5. #include <hwregs/reg_map.h>
  6. #include <hwregs/reg_rdwr.h>
  7. #include <hwregs/l2cache_defs.h>
  8. #include <asm/io.h>
  9. #define L2CACHE_SIZE 64
  10. int __init l2cache_init(void)
  11. {
  12. reg_l2cache_rw_ctrl ctrl = {0};
  13. reg_l2cache_rw_cfg cfg = {.en = regk_l2cache_yes};
  14. ctrl.csize = L2CACHE_SIZE;
  15. ctrl.cbase = L2CACHE_SIZE / 4 + (L2CACHE_SIZE % 4 ? 1 : 0);
  16. REG_WR(l2cache, regi_l2cache, rw_ctrl, ctrl);
  17. /* Flush the tag memory */
  18. memset((void *)(MEM_INTMEM_START | MEM_NON_CACHEABLE), 0, 2*1024);
  19. /* Enable the cache */
  20. REG_WR(l2cache, regi_l2cache, rw_cfg, cfg);
  21. return 0;
  22. }