]> git.ipfire.org Git - people/ms/u-boot.git/blobdiff - post/cpu/ppc4xx/spr.c
post: use ARRAY_SIZE
[people/ms/u-boot.git] / post / cpu / ppc4xx / spr.c
index be5a701f317dbd90264a24f5c0a634177081e4f1..3f5e96593a47a75afd95e13ae21dd19c325337e7 100644 (file)
  * corresponding table value.
  */
 
-#ifdef CONFIG_POST
-
 #include <post.h>
 
-#if CONFIG_POST & CFG_POST_SPR
+#if CONFIG_POST & CONFIG_SYS_POST_SPR
 
 #include <asm/processor.h>
 
-static struct
-{
-    int number;
-    char * name;
-    unsigned long mask;
-    unsigned long value;
+#ifdef CONFIG_4xx_DCACHE
+#include <asm/mmu.h>
+
+DECLARE_GLOBAL_DATA_PTR;
+#endif
+
+static struct {
+       int number;
+       char * name;
+       unsigned long mask;
+       unsigned long value;
 } spr_test_list [] = {
        /* Standard Special-Purpose Registers */
 
@@ -65,15 +68,17 @@ static struct
        {0x11f, "PVR",          0x00000000,     0x00000000},
 
        /* Additional Special-Purpose Registers.
-        * The values must match the initialization 
-        * values from cpu/ppc4xx/start.S
+        * The values must match the initialization
+        * values from arch/powerpc/cpu/ppc4xx/start.S
         */
        {0x30,  "PID",          0x00000000,     0x00000000},
        {0x3a,  "CSRR0",        0x00000000,     0x00000000},
        {0x3b,  "CSRR1",        0x00000000,     0x00000000},
        {0x3d,  "DEAR",         0x00000000,     0x00000000},
        {0x3e,  "ESR",          0x00000000,     0x00000000},
+#ifdef CONFIG_440
        {0x3f,  "IVPR",         0xffff0000,     0x00000000},
+#endif
        {0x100, "USPRG0",       0x00000000,     0x00000000},
        {0x104, "SPRG4",        0x00000000,     0x00000000},
        {0x105, "SPRG5",        0x00000000,     0x00000000},
@@ -81,7 +86,9 @@ static struct
        {0x107, "SPRG7",        0x00000000,     0x00000000},
        {0x10c, "TBL",          0x00000000,     0x00000000},
        {0x10d, "TBU",          0x00000000,     0x00000000},
+#ifdef CONFIG_440
        {0x11e, "PIR",          0x0000000f,     0x00000000},
+#endif
        {0x130, "DBSR",         0x00000000,     0x00000000},
        {0x134, "DBCR0",        0x00000000,     0x00000000},
        {0x135, "DBCR1",        0x00000000,     0x00000000},
@@ -96,6 +103,7 @@ static struct
        {0x13f, "DVC2",         0x00000000,     0x00000000},
        {0x150, "TSR",          0x00000000,     0x00000000},
        {0x154, "TCR",          0x00000000,     0x00000000},
+#ifdef CONFIG_440
        {0x190, "IVOR0",        0x0000fff0,     0x00000100},
        {0x191, "IVOR1",        0x0000fff0,     0x00000200},
        {0x192, "IVOR2",        0x0000fff0,     0x00000300},
@@ -112,6 +120,7 @@ static struct
        {0x19d, "IVOR13",       0x0000fff0,     0x00001300},
        {0x19e, "IVOR14",       0x0000fff0,     0x00001400},
        {0x19f, "IVOR15",       0x0000fff0,     0x00002000},
+#endif
        {0x23a, "MCSRR0",       0x00000000,     0x00000000},
        {0x23b, "MCSRR1",       0x00000000,     0x00000000},
        {0x23c, "MCSR",         0x00000000,     0x00000000},
@@ -132,8 +141,10 @@ static struct
        {0x395, "DTV1",         0x00000000,     0x00000000},
        {0x396, "DTV2",         0x00000000,     0x00000000},
        {0x397, "DTV3",         0x00000000,     0x00000000},
+#ifdef CONFIG_440
        {0x398, "DVLIM",        0x0fc1f83f,     0x0001f800},
        {0x399, "IVLIM",        0x0fc1f83f,     0x0001f800},
+#endif
        {0x39b, "RSTCFG",       0x00000000,     0x00000000},
        {0x39c, "DCDBTRL",      0x00000000,     0x00000000},
        {0x39d, "DCDBTRH",      0x00000000,     0x00000000},
@@ -145,8 +156,7 @@ static struct
        {0x3f3, "DBDR",         0x00000000,     0x00000000},
 };
 
-static int spr_test_list_size =
-               sizeof (spr_test_list) / sizeof (spr_test_list[0]);
+static int spr_test_list_size = ARRAY_SIZE(spr_test_list);
 
 int spr_post_test (int flags)
 {
@@ -159,6 +169,10 @@ int spr_post_test (int flags)
        };
        unsigned long (*get_spr) (void) = (void *) code;
 
+#ifdef CONFIG_4xx_DCACHE
+       /* disable cache */
+       change_tlb(gd->bd->bi_memstart, gd->bd->bi_memsize, TLB_WORD2_I_ENABLE);
+#endif
        for (i = 0; i < spr_test_list_size; i++) {
                int num = spr_test_list[i].number;
 
@@ -175,9 +189,12 @@ int spr_post_test (int flags)
                        ret = -1;
                }
        }
+#ifdef CONFIG_4xx_DCACHE
+       /* enable cache */
+       change_tlb(gd->bd->bi_memstart, gd->bd->bi_memsize, 0);
+#endif
 
        return ret;
 }
 
-#endif /* CONFIG_POST & CFG_POST_SPR */
-#endif /* CONFIG_POST */
+#endif /* CONFIG_POST & CONFIG_SYS_POST_SPR */