mmu-arcv2.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (C) 2004, 2007-2010, 2011-2012, 2019-20 Synopsys, Inc. (www.synopsys.com)
  4. *
  5. * MMUv3 (arc700) / MMUv4 (archs) are software page walked and software managed.
  6. * This file contains the TLB access registers and commands
  7. */
  8. #ifndef _ASM_ARC_MMU_ARCV2_H
  9. #define _ASM_ARC_MMU_ARCV2_H
  10. #include <soc/arc/aux.h>
  11. /*
  12. * TLB Management regs
  13. */
  14. #define ARC_REG_MMU_BCR 0x06f
  15. #ifdef CONFIG_ARC_MMU_V3
  16. #define ARC_REG_TLBPD0 0x405
  17. #define ARC_REG_TLBPD1 0x406
  18. #define ARC_REG_TLBPD1HI 0 /* Dummy: allows common code */
  19. #define ARC_REG_TLBINDEX 0x407
  20. #define ARC_REG_TLBCOMMAND 0x408
  21. #define ARC_REG_PID 0x409
  22. #define ARC_REG_SCRATCH_DATA0 0x418
  23. #else
  24. #define ARC_REG_TLBPD0 0x460
  25. #define ARC_REG_TLBPD1 0x461
  26. #define ARC_REG_TLBPD1HI 0x463
  27. #define ARC_REG_TLBINDEX 0x464
  28. #define ARC_REG_TLBCOMMAND 0x465
  29. #define ARC_REG_PID 0x468
  30. #define ARC_REG_SCRATCH_DATA0 0x46c
  31. #endif
  32. /* Bits in MMU PID reg */
  33. #define __TLB_ENABLE (1 << 31)
  34. #define __PROG_ENABLE (1 << 30)
  35. #define MMU_ENABLE (__TLB_ENABLE | __PROG_ENABLE)
  36. /* Bits in TLB Index reg */
  37. #define TLB_LKUP_ERR 0x80000000
  38. #ifdef CONFIG_ARC_MMU_V3
  39. #define TLB_DUP_ERR (TLB_LKUP_ERR | 0x00000001)
  40. #else
  41. #define TLB_DUP_ERR (TLB_LKUP_ERR | 0x40000000)
  42. #endif
  43. /*
  44. * TLB Commands
  45. */
  46. #define TLBWrite 0x1
  47. #define TLBRead 0x2
  48. #define TLBGetIndex 0x3
  49. #define TLBProbe 0x4
  50. #define TLBWriteNI 0x5 /* write JTLB without inv uTLBs */
  51. #define TLBIVUTLB 0x6 /* explicitly inv uTLBs */
  52. #ifdef CONFIG_ARC_MMU_V4
  53. #define TLBInsertEntry 0x7
  54. #define TLBDeleteEntry 0x8
  55. #endif
  56. /* Masks for actual TLB "PD"s */
  57. #define PTE_BITS_IN_PD0 (_PAGE_GLOBAL | _PAGE_PRESENT | _PAGE_HW_SZ)
  58. #define PTE_BITS_RWX (_PAGE_EXECUTE | _PAGE_WRITE | _PAGE_READ)
  59. #define PTE_BITS_NON_RWX_IN_PD1 (PAGE_MASK_PHYS | _PAGE_CACHEABLE)
  60. #ifndef __ASSEMBLY__
  61. struct mm_struct;
  62. extern int pae40_exist_but_not_enab(void);
  63. static inline int is_pae40_enabled(void)
  64. {
  65. return IS_ENABLED(CONFIG_ARC_HAS_PAE40);
  66. }
  67. static inline void mmu_setup_asid(struct mm_struct *mm, unsigned long asid)
  68. {
  69. write_aux_reg(ARC_REG_PID, asid | MMU_ENABLE);
  70. }
  71. static inline void mmu_setup_pgd(struct mm_struct *mm, void *pgd)
  72. {
  73. /* PGD cached in MMU reg to avoid 3 mem lookups: task->mm->pgd */
  74. #ifdef CONFIG_ISA_ARCV2
  75. write_aux_reg(ARC_REG_SCRATCH_DATA0, (unsigned int)pgd);
  76. #endif
  77. }
  78. #else
  79. .macro ARC_MMU_REENABLE reg
  80. lr \reg, [ARC_REG_PID]
  81. or \reg, \reg, MMU_ENABLE
  82. sr \reg, [ARC_REG_PID]
  83. .endm
  84. #endif /* !__ASSEMBLY__ */
  85. #endif