[U-Boot-Users] [PATCH 2/4 V2] PPC: Change lib_ppc/bat_rw.c to use high bats

From: Becky Bruce becky.bruce@freescale.com
Currently, this code only deals with BATs 0-3, which makes it useless on systems that support BATs 4-7. Add the support for these registers.
Signed-off-by: Becky Bruce Becky.bruce@freescale.com --- include/asm-ppc/mmu.h | 4 ++ lib_ppc/bat_rw.c | 134 ++++++++++++++++++++++++++++++++++--------------- 2 files changed, 97 insertions(+), 41 deletions(-)
diff --git a/include/asm-ppc/mmu.h b/include/asm-ppc/mmu.h index 49d6860..f836270 100644 --- a/include/asm-ppc/mmu.h +++ b/include/asm-ppc/mmu.h @@ -141,6 +141,10 @@ extern void _tlbia(void); /* invalidate all TLB entries */ typedef enum { IBAT0 = 0, IBAT1, IBAT2, IBAT3, DBAT0, DBAT1, DBAT2, DBAT3 +#ifdef CONFIG_HIGH_BATS + , IBAT4, IBAT5, IBAT6, IBAT7, + DBAT4, DBAT5, DBAT6, DBAT7 +#endif } ppc_bat_t;
extern int read_bat(ppc_bat_t bat, unsigned long *upper, unsigned long *lower); diff --git a/lib_ppc/bat_rw.c b/lib_ppc/bat_rw.c index 912efa7..6288164 100644 --- a/lib_ppc/bat_rw.c +++ b/lib_ppc/bat_rw.c @@ -28,47 +28,73 @@
int write_bat (ppc_bat_t bat, unsigned long upper, unsigned long lower) { - switch (bat) { + switch(bat) { + case DBAT0: + mtspr (DBAT0L, lower); + mtspr (DBAT0U, upper); + break; case IBAT0: mtspr (IBAT0L, lower); mtspr (IBAT0U, upper); break; - + case DBAT1: + mtspr (DBAT1L, lower); + mtspr (DBAT1U, upper); + break; case IBAT1: mtspr (IBAT1L, lower); mtspr (IBAT1U, upper); break; - + case DBAT2: + mtspr (DBAT2L, lower); + mtspr (DBAT2U, upper); + break; case IBAT2: mtspr (IBAT2L, lower); mtspr (IBAT2U, upper); break; - + case DBAT3: + mtspr (DBAT3L, lower); + mtspr (DBAT3U, upper); + break; case IBAT3: mtspr (IBAT3L, lower); mtspr (IBAT3U, upper); break; - - case DBAT0: - mtspr (DBAT0L, lower); - mtspr (DBAT0U, upper); +#ifdef CONFIG_HIGH_BATS + case DBAT4: + mtspr (DBAT4L, lower); + mtspr (DBAT3U, upper); break; - - case DBAT1: - mtspr (DBAT1L, lower); - mtspr (DBAT1U, upper); + case IBAT4: + mtspr (IBAT4L, lower); + mtspr (IBAT4U, upper); break; - - case DBAT2: - mtspr (DBAT2L, lower); - mtspr (DBAT2U, upper); + case DBAT5: + mtspr (DBAT5L, lower); + mtspr (DBAT5U, upper); break; - - case DBAT3: - mtspr (DBAT3L, lower); - mtspr (DBAT3U, upper); + case IBAT5: + mtspr (IBAT5L, lower); + mtspr (IBAT5U, upper); break; - + case DBAT6: + mtspr (DBAT6L, lower); + mtspr (DBAT6U, upper); + break; + case IBAT6: + mtspr (IBAT6L, lower); + mtspr (IBAT6U, upper); + break; + case DBAT7: + mtspr (DBAT7L, lower); + mtspr (DBAT7U, upper); + break; + case IBAT7: + mtspr (IBAT7L, lower); + mtspr (IBAT7U, upper); + break; +#endif default: return (-1); } @@ -82,46 +108,72 @@ int read_bat (ppc_bat_t bat, unsigned long *upper, unsigned long *lower) unsigned long register l;
switch (bat) { + case DBAT0: + l = mfspr (DBAT0L); + u = mfspr (DBAT0U); + break; case IBAT0: l = mfspr (IBAT0L); u = mfspr (IBAT0U); break; - + case DBAT1: + l = mfspr (DBAT1L); + u = mfspr (DBAT1U); + break; case IBAT1: l = mfspr (IBAT1L); u = mfspr (IBAT1U); break; - + case DBAT2: + l = mfspr (DBAT2L); + u = mfspr (DBAT2U); + break; case IBAT2: l = mfspr (IBAT2L); u = mfspr (IBAT2U); break; - + case DBAT3: + l = mfspr (DBAT3L); + u = mfspr (DBAT3U); + break; case IBAT3: l = mfspr (IBAT3L); u = mfspr (IBAT3U); break; - - case DBAT0: - l = mfspr (DBAT0L); - u = mfspr (DBAT0U); +#ifdef CONFIG_HIGH_BATS + case DBAT4: + l = mfspr (DBAT4L); + u = mfspr (DBAT4U); break; - - case DBAT1: - l = mfspr (DBAT1L); - u = mfspr (DBAT1U); + case IBAT4: + l = mfspr (IBAT4L); + u = mfspr (IBAT4U); break; - - case DBAT2: - l = mfspr (DBAT2L); - u = mfspr (DBAT2U); + case DBAT5: + l = mfspr (DBAT5L); + u = mfspr (DBAT5U); break; - - case DBAT3: - l = mfspr (DBAT3L); - u = mfspr (DBAT3U); + case IBAT5: + l = mfspr (IBAT5L); + u = mfspr (IBAT5U); break; - + case DBAT6: + l = mfspr (DBAT6L); + u = mfspr (DBAT6U); + break; + case IBAT6: + l = mfspr (IBAT6L); + u = mfspr (IBAT6U); + break; + case DBAT7: + l = mfspr (DBAT7L); + u = mfspr (DBAT7U); + break; + case IBAT7: + l = mfspr (IBAT7L); + u = mfspr (IBAT7U); + break; +#endif default: return (-1); }

On Thu, May 08, 2008 at 07:02:23PM -0500, Becky.bruce@freescale.com wrote:
diff --git a/include/asm-ppc/mmu.h b/include/asm-ppc/mmu.h index 49d6860..f836270 100644 --- a/include/asm-ppc/mmu.h +++ b/include/asm-ppc/mmu.h @@ -141,6 +141,10 @@ extern void _tlbia(void); /* invalidate all TLB entries */ typedef enum { IBAT0 = 0, IBAT1, IBAT2, IBAT3, DBAT0, DBAT1, DBAT2, DBAT3 +#ifdef CONFIG_HIGH_BATS
- , IBAT4, IBAT5, IBAT6, IBAT7,
- DBAT4, DBAT5, DBAT6, DBAT7
+#endif
C allows trailing commas on such lists; no need to move it inside the ifdef.
-Scott

On May 9, 2008, at 10:28 AM, Scott Wood wrote:
On Thu, May 08, 2008 at 07:02:23PM -0500, Becky.bruce@freescale.com wrote:
diff --git a/include/asm-ppc/mmu.h b/include/asm-ppc/mmu.h index 49d6860..f836270 100644 --- a/include/asm-ppc/mmu.h +++ b/include/asm-ppc/mmu.h @@ -141,6 +141,10 @@ extern void _tlbia(void); /* invalidate all TLB entries */ typedef enum { IBAT0 = 0, IBAT1, IBAT2, IBAT3, DBAT0, DBAT1, DBAT2, DBAT3 +#ifdef CONFIG_HIGH_BATS
- , IBAT4, IBAT5, IBAT6, IBAT7,
- DBAT4, DBAT5, DBAT6, DBAT7
+#endif
C allows trailing commas on such lists; no need to move it inside the ifdef.
Dangling commas bother me in the extreme. If this is the concensus, I'll move it, but I prefer it where it is.
-B

Becky Bruce wrote:
On May 9, 2008, at 10:28 AM, Scott Wood wrote:
On Thu, May 08, 2008 at 07:02:23PM -0500, Becky.bruce@freescale.com wrote:
diff --git a/include/asm-ppc/mmu.h b/include/asm-ppc/mmu.h index 49d6860..f836270 100644 --- a/include/asm-ppc/mmu.h +++ b/include/asm-ppc/mmu.h @@ -141,6 +141,10 @@ extern void _tlbia(void); /* invalidate all TLB entries */ typedef enum { IBAT0 = 0, IBAT1, IBAT2, IBAT3, DBAT0, DBAT1, DBAT2, DBAT3 +#ifdef CONFIG_HIGH_BATS
- , IBAT4, IBAT5, IBAT6, IBAT7,
- DBAT4, DBAT5, DBAT6, DBAT7
+#endif
C allows trailing commas on such lists; no need to move it inside the ifdef.
Dangling commas bother me in the extreme. If this is the concensus, I'll move it, but I prefer it where it is.
-B
+1 for moving. Dangling commas is the second best thing in C. ;-)
Best regards, gvb

On 14:45 Fri 09 May , Jerry Van Baren wrote:
Becky Bruce wrote:
On May 9, 2008, at 10:28 AM, Scott Wood wrote:
On Thu, May 08, 2008 at 07:02:23PM -0500, Becky.bruce@freescale.com wrote:
diff --git a/include/asm-ppc/mmu.h b/include/asm-ppc/mmu.h index 49d6860..f836270 100644 --- a/include/asm-ppc/mmu.h +++ b/include/asm-ppc/mmu.h @@ -141,6 +141,10 @@ extern void _tlbia(void); /* invalidate all TLB entries */ typedef enum { IBAT0 = 0, IBAT1, IBAT2, IBAT3, DBAT0, DBAT1, DBAT2, DBAT3 +#ifdef CONFIG_HIGH_BATS
- , IBAT4, IBAT5, IBAT6, IBAT7,
- DBAT4, DBAT5, DBAT6, DBAT7
+#endif
C allows trailing commas on such lists; no need to move it inside the ifdef.
Dangling commas bother me in the extreme. If this is the concensus, I'll move it, but I prefer it where it is.
-B
+1 for moving. Dangling commas is the second best thing in C. ;-)
+1 for moving. Dangling commas is the second best thing in C. ;-)
Best Regards, J.

On May 9, 2008, at 2:14 PM, Jean-Christophe PLAGNIOL-VILLARD wrote:
On 14:45 Fri 09 May , Jerry Van Baren wrote:
Becky Bruce wrote:
On May 9, 2008, at 10:28 AM, Scott Wood wrote:
On Thu, May 08, 2008 at 07:02:23PM -0500, Becky.bruce@freescale.com wrote:
diff --git a/include/asm-ppc/mmu.h b/include/asm-ppc/mmu.h index 49d6860..f836270 100644 --- a/include/asm-ppc/mmu.h +++ b/include/asm-ppc/mmu.h @@ -141,6 +141,10 @@ extern void _tlbia(void); /* invalidate all TLB entries */ typedef enum { IBAT0 = 0, IBAT1, IBAT2, IBAT3, DBAT0, DBAT1, DBAT2, DBAT3 +#ifdef CONFIG_HIGH_BATS
- , IBAT4, IBAT5, IBAT6, IBAT7,
- DBAT4, DBAT5, DBAT6, DBAT7
+#endif
C allows trailing commas on such lists; no need to move it inside the ifdef.
Dangling commas bother me in the extreme. If this is the concensus, I'll move it, but I prefer it where it is.
-B
+1 for moving. Dangling commas is the second best thing in C. ;-)
+1 for moving. Dangling commas is the second best thing in C. ;-)
I also want to know what's the first best thing! I have to guess that the dangling comma is really the fifteenth-best thing, or something..... but I don't want this thread to degenerate into a holy war.
Ayway, point taken, and I'll move it. But I don't have to like it :)
Cheers, B

On Friday 09 May 2008, Jerry Van Baren wrote:
C allows trailing commas on such lists; no need to move it inside the ifdef.
Dangling commas bother me in the extreme. If this is the concensus, I'll move it, but I prefer it where it is.
-B
+1 for moving. Dangling commas is the second best thing in C. ;-)
Now I'm curious. :) And what's supposed to be "the best thing in C"?
Best regards, Stefan
===================================================================== DENX Software Engineering GmbH, MD: Wolfgang Denk & Detlev Zundel HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany Phone: +49-8142-66989-0 Fax: +49-8142-66989-80 Email: office@denx.de =====================================================================

Stefan Roese wrote:
On Friday 09 May 2008, Jerry Van Baren wrote:
C allows trailing commas on such lists; no need to move it inside the ifdef.
Dangling commas bother me in the extreme. If this is the concensus, I'll move it, but I prefer it where it is.
-B
+1 for moving. Dangling commas is the second best thing in C. ;-)
Now I'm curious. :) And what's supposed to be "the best thing in C"?
Best regards, Stefan
I figured everybody has a favorite feature of C, so by claiming *second best*, I wouldn't have to argue with everybody that it was the best. :-D Great conversation starter too, I use it in the bar all the time. ;-)
As Calvin says, "I try to make everyone's day a little more surreal." The Essential Calvin and Hobbes, p152-3 http://www.calvin-and-hobbes.org/information/quotes
gvb

In message 6514CE95-5C25-4C36-88DA-63E03DE87024@freescale.com you wrote:
TLB entries */ typedef enum { IBAT0 = 0, IBAT1, IBAT2, IBAT3, DBAT0, DBAT1, DBAT2, DBAT3 +#ifdef CONFIG_HIGH_BATS
- , IBAT4, IBAT5, IBAT6, IBAT7,
- DBAT4, DBAT5, DBAT6, DBAT7
+#endif
C allows trailing commas on such lists; no need to move it inside the ifdef.
Dangling commas bother me in the extreme. If this is the concensus, I'll move it, but I prefer it where it is.
Please move it. As is it looks irregular and ugly to me.
Best regards,
Wolfgang Denk
participants (7)
-
Becky Bruce
-
Becky.bruceļ¼ freescale.com
-
Jean-Christophe PLAGNIOL-VILLARD
-
Jerry Van Baren
-
Scott Wood
-
Stefan Roese
-
Wolfgang Denk