turbosparc.h 3.8 KB

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