cacheinit.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. * Copyright 2004-2007 Analog Devices Inc.
  3. *
  4. * This program is free software; you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation; either version 2 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program; if not, see the file COPYING, or write
  16. * to the Free Software Foundation, Inc.,
  17. * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
  18. */
  19. #include <linux/cpu.h>
  20. #include <asm/cacheflush.h>
  21. #include <asm/blackfin.h>
  22. #include <asm/cplb.h>
  23. #include <asm/cplbinit.h>
  24. #if defined(CONFIG_BFIN_ICACHE)
  25. void __cpuinit bfin_icache_init(struct cplb_entry *icplb_tbl)
  26. {
  27. unsigned long ctrl;
  28. int i;
  29. for (i = 0; i < MAX_CPLBS; i++) {
  30. bfin_write32(ICPLB_ADDR0 + i * 4, icplb_tbl[i].addr);
  31. bfin_write32(ICPLB_DATA0 + i * 4, icplb_tbl[i].data);
  32. }
  33. ctrl = bfin_read_IMEM_CONTROL();
  34. ctrl |= IMC | ENICPLB;
  35. /* CSYNC to ensure load store ordering */
  36. CSYNC();
  37. bfin_write_IMEM_CONTROL(ctrl);
  38. SSYNC();
  39. }
  40. #endif
  41. #if defined(CONFIG_BFIN_DCACHE)
  42. void __cpuinit bfin_dcache_init(struct cplb_entry *dcplb_tbl)
  43. {
  44. unsigned long ctrl;
  45. int i;
  46. for (i = 0; i < MAX_CPLBS; i++) {
  47. bfin_write32(DCPLB_ADDR0 + i * 4, dcplb_tbl[i].addr);
  48. bfin_write32(DCPLB_DATA0 + i * 4, dcplb_tbl[i].data);
  49. }
  50. ctrl = bfin_read_DMEM_CONTROL();
  51. /*
  52. * Anomaly notes:
  53. * 05000287 - We implement workaround #2 - Change the DMEM_CONTROL
  54. * register, so that the port preferences for DAG0 and DAG1 are set
  55. * to port B
  56. */
  57. ctrl |= DMEM_CNTR | PORT_PREF0 | (ANOMALY_05000287 ? PORT_PREF1 : 0);
  58. /* CSYNC to ensure load store ordering */
  59. CSYNC();
  60. bfin_write_DMEM_CONTROL(ctrl);
  61. SSYNC();
  62. }
  63. #endif