]> git.kernelconcepts.de Git - karo-tx-linux.git/commitdiff
powerpc/fsl-booke: Fixup calc_cam_sz to support MMU v2
authorKumar Gala <galak@kernel.crashing.org>
Thu, 5 Jan 2012 18:37:16 +0000 (12:37 -0600)
committergalak <galak@spiff.(none)>
Thu, 15 Mar 2012 17:12:19 +0000 (12:12 -0500)
The registers that describe size supported by TLB are different on MMU
v2 as well as we support power of two page sizes.  For now we continue
to assume that FSL variable size array supports all page sizes up to the
maximum one reported in TLB1PS.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
arch/powerpc/include/asm/reg_booke.h
arch/powerpc/mm/fsl_booke_mmu.c

index 500fe1dc43e6de21023672b68ac477450a610663..8a97aa7289d36b155a1e01df4211a261a7a110e8 100644 (file)
@@ -62,6 +62,7 @@
 #define SPRN_DVC2      0x13F   /* Data Value Compare Register 2 */
 #define SPRN_MAS8      0x155   /* MMU Assist Register 8 */
 #define SPRN_TLB0PS    0x158   /* TLB 0 Page Size Register */
+#define SPRN_TLB1PS    0x159   /* TLB 1 Page Size Register */
 #define SPRN_MAS5_MAS6 0x15c   /* MMU Assist Register 5 || 6 */
 #define SPRN_MAS8_MAS1 0x15d   /* MMU Assist Register 8 || 1 */
 #define SPRN_EPTCFG    0x15e   /* Embedded Page Table Config */
index 66a6fd38e9cdb9df35d8dbb6206c581b7f5b550e..07ba45b0f07c8ed311313c14fdf4422613639e0e 100644 (file)
@@ -149,12 +149,19 @@ static void settlbcam(int index, unsigned long virt, phys_addr_t phys,
 unsigned long calc_cam_sz(unsigned long ram, unsigned long virt,
                          phys_addr_t phys)
 {
-       unsigned int camsize = __ilog2(ram) & ~1U;
-       unsigned int align = __ffs(virt | phys) & ~1U;
-       unsigned long max_cam = (mfspr(SPRN_TLB1CFG) >> 16) & 0xf;
-
-       /* Convert (4^max) kB to (2^max) bytes */
-       max_cam = max_cam * 2 + 10;
+       unsigned int camsize = __ilog2(ram);
+       unsigned int align = __ffs(virt | phys);
+       unsigned long max_cam;
+
+       if ((mfspr(SPRN_MMUCFG) & MMUCFG_MAVN) == MMUCFG_MAVN_V1) {
+               /* Convert (4^max) kB to (2^max) bytes */
+               max_cam = ((mfspr(SPRN_TLB1CFG) >> 16) & 0xf) * 2 + 10;
+               camsize &= ~1U;
+               align &= ~1U;
+       } else {
+               /* Convert (2^max) kB to (2^max) bytes */
+               max_cam = __ilog2(mfspr(SPRN_TLB1PS)) + 10;
+       }
 
        if (camsize > align)
                camsize = align;