Skip to contentSkip to conversation

ppc/85xx: Introduce low level write_tlb function

PATCH New Kumar Gala 1 participant 2 messages Sep 11, 2009

lore
Share & tools
lore

Kumar Gala

author
#0 lore raw

PATCH 1/2 ppc/85xx: Introduce low level write_tlb function

Factor out the code we use to actually write a tlb entry.

set_tlb is a logical view of the TLB while write_tlb is a low level matching the MAS registers.

---
 cpu/mpc85xx/start.S   |   19 +++++++++++++++++++
 cpu/mpc85xx/tlb.c     |   12 +-----------
 include/asm-ppc/mmu.h |    2 ++
 3 files changed, 22 insertions(+), 11 deletions(-)
cpu/mpc85xx/start.S +19 -0
index 7a23b4f..ea32659 100644
@@ -1127,6 +1127,25 @@ flush_dcache:
 
 	blr
 
+	.globl	write_tlb
+write_tlb:
+	mtspr	MAS0,r3
+	mtspr	MAS1,r4
+	mtspr	MAS2,r5
+	mtspr	MAS3,r6
+#ifdef CONFIG_ENABLE_36BIT_PHYS
+	mtspr	MAS7,r7
+#endif
+	li	r3,0
+#ifdef CONFIG_SYS_BOOK3E_HV
+	mtspr	MAS8,r3
+#endif
+	isync
+	tlbwe
+	msync
+	isync
+	blr
+
 .globl setup_ivors
 setup_ivors:
 
cpu/mpc85xx/tlb.c +1 -11
index 03c2449..3e502ac 100644
@@ -44,17 +44,7 @@ void set_tlb(u8 tlb, u32 epn, u64 rpn,
 	_mas3 = FSL_BOOKE_MAS3(rpn, 0, perms);
 	_mas7 = rpn >> 32;
 
-	mtspr(MAS0, _mas0);
-	mtspr(MAS1, _mas1);
-	mtspr(MAS2, _mas2);
-	mtspr(MAS3, _mas3);
-#ifdef CONFIG_ENABLE_36BIT_PHYS
-	mtspr(MAS7, _mas7);
-#endif
-#ifdef CONFIG_SYS_BOOK3E_HV
-	mtspr(MAS8, 0);
-#endif
-	asm volatile("isync;msync;tlbwe;isync");
+	write_tlb(_mas0, _mas1, _mas2, _mas3, _mas7);
 
 #ifdef CONFIG_ADDR_MAP
 	if ((tlb == 1) && (gd->flags & GD_FLG_RELOC))
include/asm-ppc/mmu.h +2 -0
index eda2959..d311ba2 100644
@@ -480,6 +480,8 @@ extern int find_tlb_idx(void *addr, u8 tlbsel);
 
 extern unsigned int setup_ddr_tlbs(unsigned int memsize_in_meg);
 
+extern void write_tlb(u32 _mas0, u32 _mas1, u32 _mas2, u32 _mas3, u32 _mas7);
+
 #define SET_TLB_ENTRY(_tlb, _epn, _rpn, _perms, _wimge, _ts, _esel, _sz, _iprot) \
 	{ .tlb = _tlb, .epn = _epn, .rpn = _rpn, .perms = _perms, \
 	  .wimge = _wimge, .ts = _ts, .esel = _esel, .tsize = _sz, .iprot = _iprot }
Signature · 1 line
1.6.0.6
author
#1 lore raw

PATCH 2/2 ppc/85xx: Repack tlb_table to save space

We can pack the initial tlb_table in MAS register format and use write_tlb to set things up. This savings can be helpful for NAND style first stage boot loaders.

---
 cpu/mpc85xx/tlb.c     |    9 +++++----
 include/asm-ppc/mmu.h |   21 ++++++++++-----------
 2 files changed, 15 insertions(+), 15 deletions(-)
cpu/mpc85xx/tlb.c +5 -4
index 3e502ac..857908e 100644
@@ -90,10 +90,11 @@ void init_tlbs(void)
 	int i;
 
 	for (i = 0; i < num_tlb_entries; i++) {
-		set_tlb(tlb_table[i].tlb, tlb_table[i].epn, tlb_table[i].rpn,
-			tlb_table[i].perms, tlb_table[i].wimge,
-			tlb_table[i].ts, tlb_table[i].esel, tlb_table[i].tsize,
-			tlb_table[i].iprot);
+ 		write_tlb(tlb_table[i].mas0,
+ 			  tlb_table[i].mas1,
+ 			  tlb_table[i].mas2,
+ 			  tlb_table[i].mas3,
+			  tlb_table[i].mas7);
 	}
 
 	return ;
include/asm-ppc/mmu.h +10 -11
index d311ba2..3fa98fa 100644
@@ -483,19 +483,18 @@ extern unsigned int setup_ddr_tlbs(unsigned int memsize_in_meg);
 extern void write_tlb(u32 _mas0, u32 _mas1, u32 _mas2, u32 _mas3, u32 _mas7);
 
 #define SET_TLB_ENTRY(_tlb, _epn, _rpn, _perms, _wimge, _ts, _esel, _sz, _iprot) \
-	{ .tlb = _tlb, .epn = _epn, .rpn = _rpn, .perms = _perms, \
-	  .wimge = _wimge, .ts = _ts, .esel = _esel, .tsize = _sz, .iprot = _iprot }
+	{ .mas0 = FSL_BOOKE_MAS0(_tlb, _esel, 0), \
+	  .mas1 = FSL_BOOKE_MAS1(1, _iprot, 0, _ts, _sz), \
+	  .mas2 = FSL_BOOKE_MAS2(_epn, _wimge), \
+	  .mas3 = FSL_BOOKE_MAS3(_rpn, 0, _perms), \
+	  .mas7 = ((u64)_rpn) >> 32, }
 
 struct fsl_e_tlb_entry {
-	u8	tlb;
-	u32	epn;
-	u64	rpn;
-	u8	perms;
-	u8	wimge;
-	u8	ts;
-	u8	esel;
-	u8	tsize;
-	u8	iprot;
+	u32	mas0;
+	u32	mas1;
+	u32	mas2;
+	u32	mas3;
+	u32	mas7;
 };
 
 extern struct fsl_e_tlb_entry tlb_table[];
Signature · 1 line
1.6.0.6