swift.h 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /* SPDX-License-Identifier: GPL-2.0 */
  2. /* swift.h: Specific definitions for the _broken_ Swift SRMMU
  3. * MMU module.
  4. *
  5. * Copyright (C) 1996 David S. Miller ([email protected])
  6. */
  7. #ifndef _SPARC_SWIFT_H
  8. #define _SPARC_SWIFT_H
  9. /* Swift is so brain damaged, here is the mmu control register. */
  10. #define SWIFT_ST 0x00800000 /* SW tablewalk enable */
  11. #define SWIFT_WP 0x00400000 /* Watchpoint enable */
  12. /* Branch folding (buggy, disable on production systems!) */
  13. #define SWIFT_BF 0x00200000
  14. #define SWIFT_PMC 0x00180000 /* Page mode control */
  15. #define SWIFT_PE 0x00040000 /* Parity enable */
  16. #define SWIFT_PC 0x00020000 /* Parity control */
  17. #define SWIFT_AP 0x00010000 /* Graphics page mode control (TCX/SX) */
  18. #define SWIFT_AC 0x00008000 /* Alternate Cacheability (see viking.h) */
  19. #define SWIFT_BM 0x00004000 /* Boot mode */
  20. #define SWIFT_RC 0x00003c00 /* DRAM refresh control */
  21. #define SWIFT_IE 0x00000200 /* Instruction cache enable */
  22. #define SWIFT_DE 0x00000100 /* Data cache enable */
  23. #define SWIFT_SA 0x00000080 /* Store Allocate */
  24. #define SWIFT_NF 0x00000002 /* No fault mode */
  25. #define SWIFT_EN 0x00000001 /* MMU enable */
  26. /* Bits [13:5] select one of 512 instruction cache tags */
  27. static inline void swift_inv_insn_tag(unsigned long addr)
  28. {
  29. __asm__ __volatile__("sta %%g0, [%0] %1\n\t"
  30. : /* no outputs */
  31. : "r" (addr), "i" (ASI_M_TXTC_TAG)
  32. : "memory");
  33. }
  34. /* Bits [12:4] select one of 512 data cache tags */
  35. static inline void swift_inv_data_tag(unsigned long addr)
  36. {
  37. __asm__ __volatile__("sta %%g0, [%0] %1\n\t"
  38. : /* no outputs */
  39. : "r" (addr), "i" (ASI_M_DATAC_TAG)
  40. : "memory");
  41. }
  42. static inline void swift_flush_dcache(void)
  43. {
  44. unsigned long addr;
  45. for (addr = 0; addr < 0x2000; addr += 0x10)
  46. swift_inv_data_tag(addr);
  47. }
  48. static inline void swift_flush_icache(void)
  49. {
  50. unsigned long addr;
  51. for (addr = 0; addr < 0x4000; addr += 0x20)
  52. swift_inv_insn_tag(addr);
  53. }
  54. static inline void swift_idflash_clear(void)
  55. {
  56. unsigned long addr;
  57. for (addr = 0; addr < 0x2000; addr += 0x10) {
  58. swift_inv_insn_tag(addr<<1);
  59. swift_inv_data_tag(addr);
  60. }
  61. }
  62. /* Swift is so broken, it isn't even safe to use the following. */
  63. static inline void swift_flush_page(unsigned long page)
  64. {
  65. __asm__ __volatile__("sta %%g0, [%0] %1\n\t"
  66. : /* no outputs */
  67. : "r" (page), "i" (ASI_M_FLUSH_PAGE)
  68. : "memory");
  69. }
  70. static inline void swift_flush_segment(unsigned long addr)
  71. {
  72. __asm__ __volatile__("sta %%g0, [%0] %1\n\t"
  73. : /* no outputs */
  74. : "r" (addr), "i" (ASI_M_FLUSH_SEG)
  75. : "memory");
  76. }
  77. static inline void swift_flush_region(unsigned long addr)
  78. {
  79. __asm__ __volatile__("sta %%g0, [%0] %1\n\t"
  80. : /* no outputs */
  81. : "r" (addr), "i" (ASI_M_FLUSH_REGION)
  82. : "memory");
  83. }
  84. static inline void swift_flush_context(void)
  85. {
  86. __asm__ __volatile__("sta %%g0, [%%g0] %0\n\t"
  87. : /* no outputs */
  88. : "i" (ASI_M_FLUSH_CTX)
  89. : "memory");
  90. }
  91. #endif /* !(_SPARC_SWIFT_H) */