]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
85xx: expose cpu identification
authorKumar Gala <galak@kernel.crashing.org>
Tue, 10 Jun 2008 21:53:46 +0000 (16:53 -0500)
committerAndrew Fleming-AFLEMING <afleming@freescale.com>
Tue, 10 Jun 2008 23:22:25 +0000 (18:22 -0500)
The current cpu identification code is used just to return the name
of the processor at boot.  There are some other locations that the name
is useful (device tree setup).  Expose the functionality to other bits
of code.

Also, drop the 'E' suffix and add it on by looking at the SVR version
when we print this out.  This is mainly to allow the most flexible use
of the name.  The device tree code tends to not care about the 'E' suffix.

Signed-off-by: Kumar Gala <galak@kernel.crashing.org>
cpu/mpc85xx/cpu.c
include/asm-ppc/processor.h

index 58d23f4cce8756cdb2a519c35f1166e78e87f793..d585e87995be9bbe3d2c2be07d3dbffab71081f8 100644 (file)
 
 DECLARE_GLOBAL_DATA_PTR;
 
-struct cpu_type {
-       char name[15];
-       u32 soc_ver;
+struct cpu_type cpu_type_list [] = {
+       CPU_TYPE_ENTRY(8533, 8533),
+       CPU_TYPE_ENTRY(8533, 8533_E),
+       CPU_TYPE_ENTRY(8540, 8540),
+       CPU_TYPE_ENTRY(8541, 8541),
+       CPU_TYPE_ENTRY(8541, 8541_E),
+       CPU_TYPE_ENTRY(8543, 8543),
+       CPU_TYPE_ENTRY(8543, 8543_E),
+       CPU_TYPE_ENTRY(8544, 8544),
+       CPU_TYPE_ENTRY(8544, 8544_E),
+       CPU_TYPE_ENTRY(8545, 8545),
+       CPU_TYPE_ENTRY(8545, 8545_E),
+       CPU_TYPE_ENTRY(8547, 8547_E),
+       CPU_TYPE_ENTRY(8548, 8548),
+       CPU_TYPE_ENTRY(8548, 8548_E),
+       CPU_TYPE_ENTRY(8555, 8555),
+       CPU_TYPE_ENTRY(8555, 8555_E),
+       CPU_TYPE_ENTRY(8560, 8560),
+       CPU_TYPE_ENTRY(8567, 8567),
+       CPU_TYPE_ENTRY(8567, 8567_E),
+       CPU_TYPE_ENTRY(8568, 8568),
+       CPU_TYPE_ENTRY(8568, 8568_E),
+       CPU_TYPE_ENTRY(8572, 8572),
+       CPU_TYPE_ENTRY(8572, 8572_E),
 };
 
-#define CPU_TYPE_ENTRY(x) {#x, SVR_##x}
+struct cpu_type *identify_cpu(uint ver)
+{
+       int i;
+       for (i = 0; i < ARRAY_SIZE(cpu_type_list); i++)
+               if (cpu_type_list[i].soc_ver == ver)
+                       return &cpu_type_list[i];
 
-struct cpu_type cpu_type_list [] = {
-       CPU_TYPE_ENTRY(8533),
-       CPU_TYPE_ENTRY(8533_E),
-       CPU_TYPE_ENTRY(8540),
-       CPU_TYPE_ENTRY(8541),
-       CPU_TYPE_ENTRY(8541_E),
-       CPU_TYPE_ENTRY(8543),
-       CPU_TYPE_ENTRY(8543_E),
-       CPU_TYPE_ENTRY(8544),
-       CPU_TYPE_ENTRY(8544_E),
-       CPU_TYPE_ENTRY(8545),
-       CPU_TYPE_ENTRY(8545_E),
-       CPU_TYPE_ENTRY(8547_E),
-       CPU_TYPE_ENTRY(8548),
-       CPU_TYPE_ENTRY(8548_E),
-       CPU_TYPE_ENTRY(8555),
-       CPU_TYPE_ENTRY(8555_E),
-       CPU_TYPE_ENTRY(8560),
-       CPU_TYPE_ENTRY(8567),
-       CPU_TYPE_ENTRY(8567_E),
-       CPU_TYPE_ENTRY(8568),
-       CPU_TYPE_ENTRY(8568_E),
-       CPU_TYPE_ENTRY(8572),
-       CPU_TYPE_ENTRY(8572_E),
-};
+       return NULL;
+}
 
 int checkcpu (void)
 {
@@ -74,7 +77,7 @@ int checkcpu (void)
        uint fam;
        uint ver;
        uint major, minor;
-       int i;
+       struct cpu_type *cpu;
 #ifdef CONFIG_DDR_CLK_FREQ
        volatile ccsr_gur_t *gur = (void *)(CFG_MPC85xx_GUTS_ADDR);
        u32 ddr_ratio = ((gur->porpllsr) & 0x00003e00) >> 9;
@@ -89,14 +92,15 @@ int checkcpu (void)
 
        puts("CPU:   ");
 
-       for (i = 0; i < ARRAY_SIZE(cpu_type_list); i++)
-               if (cpu_type_list[i].soc_ver == ver) {
-                       puts(cpu_type_list[i].name);
-                       break;
-               }
+       cpu = identify_cpu(ver);
+       if (cpu) {
+               puts(cpu->name);
 
-       if (i == ARRAY_SIZE(cpu_type_list))
+               if (svr & 0x80000)
+                       puts("E");
+       } else {
                puts("Unknown");
+       }
 
        printf(", Version: %d.%d, (0x%08x)\n", major, minor, svr);
 
index 8bdfb9ddf3938269f211b6f0c8f5db3741857b16..61a0d053e29bd1013b4efd5188474f4865a7a3e2 100644 (file)
@@ -960,6 +960,17 @@ n:
 #define SR15   15
 
 #ifndef __ASSEMBLY__
+
+struct cpu_type {
+       char name[15];
+       u32 soc_ver;
+};
+
+struct cpu_type *identify_cpu(uint ver);
+
+#define CPU_TYPE_ENTRY(n, v) \
+       { .name = #n, .soc_ver = SVR_##v, }
+
 #ifndef CONFIG_MACH_SPECIFIC
 extern int _machine;
 extern int have_of;