mcfmmu.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115
  1. /*
  2. * mcfmmu.h -- definitions for the ColdFire v4e MMU
  3. *
  4. * (C) Copyright 2011, Greg Ungerer <gerg@uclinux.org>
  5. *
  6. * This file is subject to the terms and conditions of the GNU General Public
  7. * License. See the file COPYING in the main directory of this archive
  8. * for more details.
  9. */
  10. #ifndef MCFMMU_H
  11. #define MCFMMU_H
  12. /*
  13. * The MMU support registers are mapped into the address space using
  14. * the processor MMUBASE register. We used a fixed address for mapping,
  15. * there doesn't seem any need to make this configurable yet.
  16. */
  17. #define MMUBASE 0xfe000000
  18. /*
  19. * The support registers of the MMU. Names are the sames as those
  20. * used in the Freescale v4e documentation.
  21. */
  22. #define MMUCR (MMUBASE + 0x00) /* Control register */
  23. #define MMUOR (MMUBASE + 0x04) /* Operation register */
  24. #define MMUSR (MMUBASE + 0x08) /* Status register */
  25. #define MMUAR (MMUBASE + 0x10) /* TLB Address register */
  26. #define MMUTR (MMUBASE + 0x14) /* TLB Tag register */
  27. #define MMUDR (MMUBASE + 0x18) /* TLB Data register */
  28. /*
  29. * MMU Control register bit flags
  30. */
  31. #define MMUCR_EN 0x00000001 /* Virtual mode enable */
  32. #define MMUCR_ASM 0x00000002 /* Address space mode */
  33. /*
  34. * MMU Operation register.
  35. */
  36. #define MMUOR_UAA 0x00000001 /* Update allocation address */
  37. #define MMUOR_ACC 0x00000002 /* TLB access */
  38. #define MMUOR_RD 0x00000004 /* TLB access read */
  39. #define MMUOR_WR 0x00000000 /* TLB access write */
  40. #define MMUOR_ADR 0x00000008 /* TLB address select */
  41. #define MMUOR_ITLB 0x00000010 /* ITLB operation */
  42. #define MMUOR_CAS 0x00000020 /* Clear non-locked ASID TLBs */
  43. #define MMUOR_CNL 0x00000040 /* Clear non-locked TLBs */
  44. #define MMUOR_CA 0x00000080 /* Clear all TLBs */
  45. #define MMUOR_STLB 0x00000100 /* Search TLBs */
  46. #define MMUOR_AAN 16 /* TLB allocation address */
  47. #define MMUOR_AAMASK 0xffff0000 /* AA mask */
  48. /*
  49. * MMU Status register.
  50. */
  51. #define MMUSR_HIT 0x00000002 /* Search TLB hit */
  52. #define MMUSR_WF 0x00000008 /* Write access fault */
  53. #define MMUSR_RF 0x00000010 /* Read access fault */
  54. #define MMUSR_SPF 0x00000020 /* Supervisor protect fault */
  55. /*
  56. * MMU Read/Write Tag register.
  57. */
  58. #define MMUTR_V 0x00000001 /* Valid */
  59. #define MMUTR_SG 0x00000002 /* Shared global */
  60. #define MMUTR_IDN 2 /* Address Space ID */
  61. #define MMUTR_IDMASK 0x000003fc /* ASID mask */
  62. #define MMUTR_VAN 10 /* Virtual Address */
  63. #define MMUTR_VAMASK 0xfffffc00 /* VA mask */
  64. /*
  65. * MMU Read/Write Data register.
  66. */
  67. #define MMUDR_LK 0x00000002 /* Lock entry */
  68. #define MMUDR_X 0x00000004 /* Execute access enable */
  69. #define MMUDR_W 0x00000008 /* Write access enable */
  70. #define MMUDR_R 0x00000010 /* Read access enable */
  71. #define MMUDR_SP 0x00000020 /* Supervisor access enable */
  72. #define MMUDR_CM_CWT 0x00000000 /* Cachable write thru */
  73. #define MMUDR_CM_CCB 0x00000040 /* Cachable copy back */
  74. #define MMUDR_CM_NCP 0x00000080 /* Non-cachable precise */
  75. #define MMUDR_CM_NCI 0x000000c0 /* Non-cachable imprecise */
  76. #define MMUDR_SZ_1MB 0x00000000 /* 1MB page size */
  77. #define MMUDR_SZ_4KB 0x00000100 /* 4kB page size */
  78. #define MMUDR_SZ_8KB 0x00000200 /* 8kB page size */
  79. #define MMUDR_SZ_1KB 0x00000300 /* 1kB page size */
  80. #define MMUDR_PAN 10 /* Physical address */
  81. #define MMUDR_PAMASK 0xfffffc00 /* PA mask */
  82. #ifndef __ASSEMBLY__
  83. /*
  84. * Simple access functions for the MMU registers. Nothing fancy
  85. * currently required, just simple 32bit access.
  86. */
  87. static inline u32 mmu_read(u32 a)
  88. {
  89. return *((volatile u32 *) a);
  90. }
  91. static inline void mmu_write(u32 a, u32 v)
  92. {
  93. *((volatile u32 *) a) = v;
  94. __asm__ __volatile__ ("nop");
  95. }
  96. void cf_bootmem_alloc(void);
  97. void cf_mmu_context_init(void);
  98. int cf_tlb_miss(struct pt_regs *regs, int write, int dtlb, int extension_word);
  99. #endif
  100. #endif /* MCFMMU_H */