tlb.c 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /*
  2. * Copyright 2008 Freescale Semiconductor, Inc.
  3. *
  4. * (C) Copyright 2000
  5. * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
  6. *
  7. * See file CREDITS for list of people who contributed to this
  8. * project.
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License as
  12. * published by the Free Software Foundation; either version 2 of
  13. * the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  23. * MA 02111-1307 USA
  24. */
  25. #include <common.h>
  26. #include <asm/processor.h>
  27. #include <asm/mmu.h>
  28. void set_tlb(u8 tlb, u32 epn, u64 rpn,
  29. u8 perms, u8 wimge,
  30. u8 ts, u8 esel, u8 tsize, u8 iprot)
  31. {
  32. u32 _mas0, _mas1, _mas2, _mas3, _mas7;
  33. _mas0 = FSL_BOOKE_MAS0(tlb, esel, 0);
  34. _mas1 = FSL_BOOKE_MAS1(1, iprot, 0, ts, tsize);
  35. _mas2 = FSL_BOOKE_MAS2(epn, wimge);
  36. _mas3 = FSL_BOOKE_MAS3(rpn, 0, perms);
  37. _mas7 = rpn >> 32;
  38. mtspr(MAS0, _mas0);
  39. mtspr(MAS1, _mas1);
  40. mtspr(MAS2, _mas2);
  41. mtspr(MAS3, _mas3);
  42. #ifdef CONFIG_ENABLE_36BIT_PHYS
  43. mtspr(MAS7, _mas7);
  44. #endif
  45. asm volatile("isync;msync;tlbwe;isync");
  46. }
  47. void disable_tlb(u8 esel)
  48. {
  49. u32 _mas0, _mas1, _mas2, _mas3, _mas7;
  50. _mas0 = FSL_BOOKE_MAS0(1, esel, 0);
  51. _mas1 = 0;
  52. _mas2 = 0;
  53. _mas3 = 0;
  54. _mas7 = 0;
  55. mtspr(MAS0, _mas0);
  56. mtspr(MAS1, _mas1);
  57. mtspr(MAS2, _mas2);
  58. mtspr(MAS3, _mas3);
  59. #ifdef CONFIG_ENABLE_36BIT_PHYS
  60. mtspr(MAS7, _mas7);
  61. #endif
  62. asm volatile("isync;msync;tlbwe;isync");
  63. }
  64. void invalidate_tlb(u8 tlb)
  65. {
  66. if (tlb == 0)
  67. mtspr(MMUCSR0, 0x4);
  68. if (tlb == 1)
  69. mtspr(MMUCSR0, 0x2);
  70. }
  71. void init_tlbs(void)
  72. {
  73. int i;
  74. for (i = 0; i < num_tlb_entries; i++) {
  75. set_tlb(tlb_table[i].tlb, tlb_table[i].epn, tlb_table[i].rpn,
  76. tlb_table[i].perms, tlb_table[i].wimge,
  77. tlb_table[i].ts, tlb_table[i].esel, tlb_table[i].tsize,
  78. tlb_table[i].iprot);
  79. }
  80. return ;
  81. }