cache-c.c 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. /*
  2. * Blackfin cache control code (simpler control-style functions)
  3. *
  4. * Copyright 2004-2009 Analog Devices Inc.
  5. *
  6. * Licensed under the GPL-2 or later.
  7. */
  8. #include <linux/init.h>
  9. #include <asm/blackfin.h>
  10. #include <asm/cplbinit.h>
  11. /* Invalidate the Entire Data cache by
  12. * clearing DMC[1:0] bits
  13. */
  14. void blackfin_invalidate_entire_dcache(void)
  15. {
  16. u32 dmem = bfin_read_DMEM_CONTROL();
  17. bfin_write_DMEM_CONTROL(dmem & ~0xc);
  18. SSYNC();
  19. bfin_write_DMEM_CONTROL(dmem);
  20. SSYNC();
  21. }
  22. /* Invalidate the Entire Instruction cache by
  23. * clearing IMC bit
  24. */
  25. void blackfin_invalidate_entire_icache(void)
  26. {
  27. u32 imem = bfin_read_IMEM_CONTROL();
  28. bfin_write_IMEM_CONTROL(imem & ~0x4);
  29. SSYNC();
  30. bfin_write_IMEM_CONTROL(imem);
  31. SSYNC();
  32. }
  33. #if defined(CONFIG_BFIN_ICACHE) || defined(CONFIG_BFIN_DCACHE)
  34. static void
  35. bfin_cache_init(struct cplb_entry *cplb_tbl, unsigned long cplb_addr,
  36. unsigned long cplb_data, unsigned long mem_control,
  37. unsigned long mem_mask)
  38. {
  39. int i;
  40. for (i = 0; i < MAX_CPLBS; i++) {
  41. bfin_write32(cplb_addr + i * 4, cplb_tbl[i].addr);
  42. bfin_write32(cplb_data + i * 4, cplb_tbl[i].data);
  43. }
  44. _enable_cplb(mem_control, mem_mask);
  45. }
  46. #ifdef CONFIG_BFIN_ICACHE
  47. void __cpuinit bfin_icache_init(struct cplb_entry *icplb_tbl)
  48. {
  49. bfin_cache_init(icplb_tbl, ICPLB_ADDR0, ICPLB_DATA0, IMEM_CONTROL,
  50. (IMC | ENICPLB));
  51. }
  52. #endif
  53. #ifdef CONFIG_BFIN_DCACHE
  54. void __cpuinit bfin_dcache_init(struct cplb_entry *dcplb_tbl)
  55. {
  56. /*
  57. * Anomaly notes:
  58. * 05000287 - We implement workaround #2 - Change the DMEM_CONTROL
  59. * register, so that the port preferences for DAG0 and DAG1 are set
  60. * to port B
  61. */
  62. bfin_cache_init(dcplb_tbl, DCPLB_ADDR0, DCPLB_DATA0, DMEM_CONTROL,
  63. (DMEM_CNTR | PORT_PREF0 | (ANOMALY_05000287 ? PORT_PREF1 : 0)));
  64. }
  65. #endif
  66. #endif