From: Becky Bruce <beckyb@kernel.crashing.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH V5 04/10] mpc85xx: tlb.c cleanups
Date: Mon, 14 Jun 2010 19:56:14 -0500 [thread overview]
Message-ID: <1276563380-24592-5-git-send-email-beckyb@kernel.crashing.org> (raw)
In-Reply-To: <1276563380-24592-4-git-send-email-beckyb@kernel.crashing.org>
Extract the operation to read a tlb into a function - we will need
this later to print out the tlbs, and there's no point in duplicating
the code. Create a TSIZE_TO_BYTES macro to deal with the conversion
from the MAS field to an actual size instead of duplicating this in code.
There are a few misc other minor cleanups.
Signed-off-by: Becky Bruce <beckyb@kernel.crashing.org>
---
arch/powerpc/cpu/mpc85xx/tlb.c | 50 +++++++++++++++++++--------------------
arch/powerpc/include/asm/mmu.h | 1 +
2 files changed, 25 insertions(+), 26 deletions(-)
diff --git a/arch/powerpc/cpu/mpc85xx/tlb.c b/arch/powerpc/cpu/mpc85xx/tlb.c
index b3037ac..eebb6ae 100644
--- a/arch/powerpc/cpu/mpc85xx/tlb.c
+++ b/arch/powerpc/cpu/mpc85xx/tlb.c
@@ -55,6 +55,24 @@ void init_tlbs(void)
return ;
}
+void read_tlbcam_entry(int idx, u32 *valid, u32 *tsize, unsigned long *epn,
+ phys_addr_t *rpn)
+{
+ u32 _mas1;
+
+ mtspr(MAS0, FSL_BOOKE_MAS0(1, idx, 0));
+ asm volatile("tlbre;isync");
+ _mas1 = mfspr(MAS1);
+
+ *valid = (_mas1 & MAS1_VALID);
+ *tsize = (_mas1 >> 8) & 0xf;
+ *epn = mfspr(MAS2) & MAS2_EPN;
+ *rpn = mfspr(MAS3) & MAS3_RPN;
+#ifdef CONFIG_ENABLE_36BIT_PHYS
+ *rpn |= ((u64)mfspr(MAS7)) << 32;
+#endif
+}
+
#ifndef CONFIG_NAND_SPL
static inline void use_tlb_cam(u8 idx)
{
@@ -82,15 +100,9 @@ void init_used_tlb_cams(void)
/* walk all the entries */
for (i = 0; i < num_cam; i++) {
- u32 _mas1;
-
mtspr(MAS0, FSL_BOOKE_MAS0(1, i, 0));
-
asm volatile("tlbre;isync");
- _mas1 = mfspr(MAS1);
-
- /* if the entry isn't valid skip it */
- if ((_mas1 & MAS1_VALID))
+ if (mfspr(MAS1) & MAS1_VALID)
use_tlb_cam(i);
}
}
@@ -134,7 +146,7 @@ void set_tlb(u8 tlb, u32 epn, u64 rpn,
#ifdef CONFIG_ADDR_MAP
if ((tlb == 1) && (gd->flags & GD_FLG_RELOC))
- addrmap_set_entry(epn, rpn, (1UL << ((tsize * 2) + 10)), esel);
+ addrmap_set_entry(epn, rpn, TSIZE_TO_BYTES(tsize), esel);
#endif
}
@@ -201,26 +213,12 @@ void init_addr_map(void)
/* walk all the entries */
for (i = 0; i < num_cam; i++) {
unsigned long epn;
- u32 tsize, _mas1;
+ u32 tsize, valid;
phys_addr_t rpn;
- mtspr(MAS0, FSL_BOOKE_MAS0(1, i, 0));
-
- asm volatile("tlbre;isync");
- _mas1 = mfspr(MAS1);
-
- /* if the entry isn't valid skip it */
- if (!(_mas1 & MAS1_VALID))
- continue;
-
- tsize = (_mas1 >> 8) & 0xf;
- epn = mfspr(MAS2) & MAS2_EPN;
- rpn = mfspr(MAS3) & MAS3_RPN;
-#ifdef CONFIG_ENABLE_36BIT_PHYS
- rpn |= ((phys_addr_t)mfspr(MAS7)) << 32;
-#endif
-
- addrmap_set_entry(epn, rpn, (1UL << ((tsize * 2) + 10)), i);
+ read_tlbcam_entry(i, &valid, &tsize, &epn, &rpn);
+ if (valid & MAS1_VALID)
+ addrmap_set_entry(epn, rpn, TSIZE_TO_BYTES(tsize), i);
}
return ;
diff --git a/arch/powerpc/include/asm/mmu.h b/arch/powerpc/include/asm/mmu.h
index 5166507..d4c7b75 100644
--- a/arch/powerpc/include/asm/mmu.h
+++ b/arch/powerpc/include/asm/mmu.h
@@ -402,6 +402,7 @@ extern void print_bats(void);
#define MAS1_TID(x) ((x << 16) & 0x3FFF0000)
#define MAS1_TS 0x00001000
#define MAS1_TSIZE(x) ((x << 8) & 0x00000F00)
+#define TSIZE_TO_BYTES(x) ((phys_addr_t)(1UL << ((tsize * 2) + 10)))
#define MAS2_EPN 0xFFFFF000
#define MAS2_X0 0x00000040
--
1.6.0.6
next prev parent reply other threads:[~2010-06-15 0:56 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2010-06-15 0:56 [U-Boot] [PATCH V5] PPC LBC/TLB cleanups; reginfo command for 85xx Becky Bruce
2010-06-15 0:56 ` [U-Boot] [PATCH V5 01/10] powerpc: Update configs to properly set FSL_ELBC Becky Bruce
2010-06-15 0:56 ` [U-Boot] [PATCH V5 02/10] drivers/usb/host/ohci-hcd: undef readl/writel before redefining Becky Bruce
2010-06-15 0:56 ` [U-Boot] [PATCH V5 03/10] 83xx/85xx/86xx: LBC register cleanup Becky Bruce
2010-06-15 0:56 ` Becky Bruce [this message]
2010-06-15 0:56 ` [U-Boot] [PATCH V5 05/10] mpc85xx: Add print_tlbcam() function Becky Bruce
2010-06-15 0:56 ` [U-Boot] [PATCH V5 06/10] drivers/misc/fsl_law.c: Rearrange code to avoid duplication Becky Bruce
2010-06-15 0:56 ` [U-Boot] [PATCH V5 07/10] fsl_law.c: Add print_laws() for FSL_CORENET platforms Becky Bruce
2010-06-15 0:56 ` [U-Boot] [PATCH V5 08/10] mpc85xx: Add reginfo command Becky Bruce
2010-06-15 0:56 ` [U-Boot] [PATCH V5 09/10] powerpc 83xx/85xx: Merge lbc upmconfig code Becky Bruce
2010-06-15 0:56 ` [U-Boot] [PATCH V5 10/10] MAKEALL: Add missing powerpc 36-bit targets Becky Bruce
2010-06-16 1:31 ` [U-Boot] [PATCH V5 09/10] powerpc 83xx/85xx: Merge lbc upmconfig code Kim Phillips
2010-06-16 22:03 ` Becky Bruce
2010-06-16 1:31 ` [U-Boot] [PATCH V5 03/10] 83xx/85xx/86xx: LBC register cleanup Kim Phillips
2010-06-16 21:59 ` Becky Bruce
2010-06-16 1:30 ` [U-Boot] [PATCH V5 01/10] powerpc: Update configs to properly set FSL_ELBC Kim Phillips
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1276563380-24592-5-git-send-email-beckyb@kernel.crashing.org \
--to=beckyb@kernel.crashing.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox