cache-c.c 1.8 KB

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