mmu-arcv2.h 2.4 KB

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