cache-c.c 1.9 KB

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