turbosparc.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. /*
  2. * turbosparc.h: Defines specific to the TurboSparc module.
  3. * This is SRMMU stuff.
  4. *
  5. * Copyright (C) 1997 Jakub Jelinek ([email protected])
  6. */
  7. #ifndef _SPARC_TURBOSPARC_H
  8. #define _SPARC_TURBOSPARC_H
  9. #include <asm/asi.h>
  10. #include <asm/pgtsrmmu.h>
  11. /* Bits in the SRMMU control register for TurboSparc modules.
  12. *
  13. * -------------------------------------------------------------------
  14. * |impl-vers| RSV| PMC |PE|PC| RSV |BM| RFR |IC|DC|PSO|RSV|ICS|NF|ME|
  15. * -------------------------------------------------------------------
  16. * 31 24 23-21 20-19 18 17 16-15 14 13-10 9 8 7 6-3 2 1 0
  17. *
  18. * BM: Boot Mode -- 0 = not in boot mode, 1 = in boot mode
  19. *
  20. * This indicates whether the TurboSparc is in boot-mode or not.
  21. *
  22. * IC: Instruction Cache -- 0 = off, 1 = on
  23. * DC: Data Cache -- 0 = off, 1 = 0n
  24. *
  25. * These bits enable the on-cpu TurboSparc split I/D caches.
  26. *
  27. * ICS: ICache Snooping -- 0 = disable, 1 = enable snooping of icache
  28. * NF: No Fault -- 0 = faults generate traps, 1 = faults don't trap
  29. * ME: MMU enable -- 0 = mmu not translating, 1 = mmu translating
  30. *
  31. */
  32. #define TURBOSPARC_MMUENABLE 0x00000001
  33. #define TURBOSPARC_NOFAULT 0x00000002
  34. #define TURBOSPARC_ICSNOOP 0x00000004
  35. #define TURBOSPARC_PSO 0x00000080
  36. #define TURBOSPARC_DCENABLE 0x00000100 /* Enable data cache */
  37. #define TURBOSPARC_ICENABLE 0x00000200 /* Enable instruction cache */
  38. #define TURBOSPARC_BMODE 0x00004000
  39. #define TURBOSPARC_PARITYODD 0x00020000 /* Parity odd, if enabled */
  40. #define TURBOSPARC_PCENABLE 0x00040000 /* Enable parity checking */
  41. /* Bits in the CPU configuration register for TurboSparc modules.
  42. *
  43. * -------------------------------------------------------
  44. * |IOClk|SNP|AXClk| RAH | WS | RSV |SBC|WT|uS2|SE|SCC|
  45. * -------------------------------------------------------
  46. * 31 30 29-28 27-26 25-23 22-8 7-6 5 4 3 2-0
  47. *
  48. */
  49. #define TURBOSPARC_SCENABLE 0x00000008 /* Secondary cache enable */
  50. #define TURBOSPARC_uS2 0x00000010 /* Swift compatibility mode */
  51. #define TURBOSPARC_WTENABLE 0x00000020 /* Write thru for dcache */
  52. #define TURBOSPARC_SNENABLE 0x40000000 /* DVMA snoop enable */
  53. #ifndef __ASSEMBLY__
  54. /* Bits [13:5] select one of 512 instruction cache tags */
  55. static inline void turbosparc_inv_insn_tag(unsigned long addr)
  56. {
  57. __asm__ __volatile__("sta %%g0, [%0] %1\n\t"
  58. : /* no outputs */
  59. : "r" (addr), "i" (ASI_M_TXTC_TAG)
  60. : "memory");
  61. }
  62. /* Bits [13:5] select one of 512 data cache tags */
  63. static inline void turbosparc_inv_data_tag(unsigned long addr)
  64. {
  65. __asm__ __volatile__("sta %%g0, [%0] %1\n\t"
  66. : /* no outputs */
  67. : "r" (addr), "i" (ASI_M_DATAC_TAG)
  68. : "memory");
  69. }
  70. static inline void turbosparc_flush_icache(void)
  71. {
  72. unsigned long addr;
  73. for (addr = 0; addr < 0x4000; addr += 0x20)
  74. turbosparc_inv_insn_tag(addr);
  75. }
  76. static inline void turbosparc_flush_dcache(void)
  77. {
  78. unsigned long addr;
  79. for (addr = 0; addr < 0x4000; addr += 0x20)
  80. turbosparc_inv_data_tag(addr);
  81. }
  82. static inline void turbosparc_idflash_clear(void)
  83. {
  84. unsigned long addr;
  85. for (addr = 0; addr < 0x4000; addr += 0x20) {
  86. turbosparc_inv_insn_tag(addr);
  87. turbosparc_inv_data_tag(addr);
  88. }
  89. }
  90. static inline void turbosparc_set_ccreg(unsigned long regval)
  91. {
  92. __asm__ __volatile__("sta %0, [%1] %2\n\t"
  93. : /* no outputs */
  94. : "r" (regval), "r" (0x600), "i" (ASI_M_MMUREGS)
  95. : "memory");
  96. }
  97. static inline unsigned long turbosparc_get_ccreg(void)
  98. {
  99. unsigned long regval;
  100. __asm__ __volatile__("lda [%1] %2, %0\n\t"
  101. : "=r" (regval)
  102. : "r" (0x600), "i" (ASI_M_MMUREGS));
  103. return regval;
  104. }
  105. #endif /* !__ASSEMBLY__ */
  106. #endif /* !(_SPARC_TURBOSPARC_H) */