diff options
| author | David S. Miller <davem@davemloft.net> | 2008-09-01 00:48:12 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2008-09-01 00:48:12 -0400 |
| commit | ba4962d7a6a10c82e55c14589d4ec635bef8446f (patch) | |
| tree | 9fde59562290d73157d7b8bcfcfd5015a6ecd276 | |
| parent | 5110bd21b8af4199b8332c0ab0b23367556653d3 (diff) | |
sparc64: Clean up CPU chip type probing code.
Three main things:
1) Make prober an arch initcall instead of using hard-coded invocation
from paging_init()
2) Shrink table size, the fpu ident stuff was never used.
3) Use named struct initialized in table.
Signed-off-by: David S. Miller <davem@davemloft.net>
| -rw-r--r-- | arch/sparc/include/asm/cpudata_64.h | 1 | ||||
| -rw-r--r-- | arch/sparc64/kernel/cpu.c | 208 | ||||
| -rw-r--r-- | arch/sparc64/kernel/entry.h | 4 | ||||
| -rw-r--r-- | arch/sparc64/mm/init.c | 2 |
4 files changed, 111 insertions, 104 deletions
diff --git a/arch/sparc/include/asm/cpudata_64.h b/arch/sparc/include/asm/cpudata_64.h index 532975ecfe10..7da7c13d23c4 100644 --- a/arch/sparc/include/asm/cpudata_64.h +++ b/arch/sparc/include/asm/cpudata_64.h | |||
| @@ -86,7 +86,6 @@ extern struct trap_per_cpu trap_block[NR_CPUS]; | |||
| 86 | extern void init_cur_cpu_trap(struct thread_info *); | 86 | extern void init_cur_cpu_trap(struct thread_info *); |
| 87 | extern void setup_tba(void); | 87 | extern void setup_tba(void); |
| 88 | extern int ncpus_probed; | 88 | extern int ncpus_probed; |
| 89 | extern void __init cpu_probe(void); | ||
| 90 | extern const struct seq_operations cpuinfo_op; | 89 | extern const struct seq_operations cpuinfo_op; |
| 91 | 90 | ||
| 92 | extern unsigned long real_hard_smp_processor_id(void); | 91 | extern unsigned long real_hard_smp_processor_id(void); |
diff --git a/arch/sparc64/kernel/cpu.c b/arch/sparc64/kernel/cpu.c index 0097c08dc600..0c9ac83ed0a8 100644 --- a/arch/sparc64/kernel/cpu.c +++ b/arch/sparc64/kernel/cpu.c | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | /* cpu.c: Dinky routines to look for the kind of Sparc cpu | 1 | /* cpu.c: Dinky routines to look for the kind of Sparc cpu |
| 2 | * we are on. | 2 | * we are on. |
| 3 | * | 3 | * |
| 4 | * Copyright (C) 1996, 2007 David S. Miller (davem@davemloft.net) | 4 | * Copyright (C) 1996, 2007, 2008 David S. Miller (davem@davemloft.net) |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #include <linux/kernel.h> | 7 | #include <linux/kernel.h> |
| @@ -19,53 +19,86 @@ | |||
| 19 | 19 | ||
| 20 | DEFINE_PER_CPU(cpuinfo_sparc, __cpu_data) = { 0 }; | 20 | DEFINE_PER_CPU(cpuinfo_sparc, __cpu_data) = { 0 }; |
| 21 | 21 | ||
| 22 | struct cpu_iu_info { | 22 | struct cpu_chip_info { |
| 23 | short manuf; | 23 | unsigned short manuf; |
| 24 | short impl; | 24 | unsigned short impl; |
| 25 | char* cpu_name; /* should be enough I hope... */ | 25 | const char *cpu_name; |
| 26 | const char *fp_name; | ||
| 26 | }; | 27 | }; |
| 27 | 28 | ||
| 28 | struct cpu_fp_info { | 29 | static const struct cpu_chip_info cpu_chips[] = { |
| 29 | short manuf; | 30 | { |
| 30 | short impl; | 31 | .manuf = 0x17, |
| 31 | char fpu_vers; | 32 | .impl = 0x10, |
| 32 | char* fp_name; | 33 | .cpu_name = "TI UltraSparc I (SpitFire)", |
| 34 | .fp_name = "UltraSparc I integrated FPU", | ||
| 35 | }, | ||
| 36 | { | ||
| 37 | .manuf = 0x22, | ||
| 38 | .impl = 0x10, | ||
| 39 | .cpu_name = "TI UltraSparc I (SpitFire)", | ||
| 40 | .fp_name = "UltraSparc I integrated FPU", | ||
| 41 | }, | ||
| 42 | { | ||
| 43 | .manuf = 0x17, | ||
| 44 | .impl = 0x11, | ||
| 45 | .cpu_name = "TI UltraSparc II (BlackBird)", | ||
| 46 | .fp_name = "UltraSparc II integrated FPU", | ||
| 47 | }, | ||
| 48 | { | ||
| 49 | .manuf = 0x17, | ||
| 50 | .impl = 0x12, | ||
| 51 | .cpu_name = "TI UltraSparc IIi (Sabre)", | ||
| 52 | .fp_name = "UltraSparc IIi integrated FPU", | ||
| 53 | }, | ||
| 54 | { | ||
| 55 | .manuf = 0x17, | ||
| 56 | .impl = 0x13, | ||
| 57 | .cpu_name = "TI UltraSparc IIe (Hummingbird)", | ||
| 58 | .fp_name = "UltraSparc IIe integrated FPU", | ||
| 59 | }, | ||
| 60 | { | ||
| 61 | .manuf = 0x3e, | ||
| 62 | .impl = 0x14, | ||
| 63 | .cpu_name = "TI UltraSparc III (Cheetah)", | ||
| 64 | .fp_name = "UltraSparc III integrated FPU", | ||
| 65 | }, | ||
| 66 | { | ||
| 67 | .manuf = 0x3e, | ||
| 68 | .impl = 0x15, | ||
| 69 | .cpu_name = "TI UltraSparc III+ (Cheetah+)", | ||
| 70 | .fp_name = "UltraSparc III+ integrated FPU", | ||
| 71 | }, | ||
| 72 | { | ||
| 73 | .manuf = 0x3e, | ||
| 74 | .impl = 0x16, | ||
| 75 | .cpu_name = "TI UltraSparc IIIi (Jalapeno)", | ||
| 76 | .fp_name = "UltraSparc IIIi integrated FPU", | ||
| 77 | }, | ||
| 78 | { | ||
| 79 | .manuf = 0x3e, | ||
| 80 | .impl = 0x18, | ||
| 81 | .cpu_name = "TI UltraSparc IV (Jaguar)", | ||
| 82 | .fp_name = "UltraSparc IV integrated FPU", | ||
| 83 | }, | ||
| 84 | { | ||
| 85 | .manuf = 0x3e, | ||
| 86 | .impl = 0x19, | ||
| 87 | .cpu_name = "TI UltraSparc IV+ (Panther)", | ||
| 88 | .fp_name = "UltraSparc IV+ integrated FPU", | ||
| 89 | }, | ||
| 90 | { | ||
| 91 | .manuf = 0x3e, | ||
| 92 | .impl = 0x22, | ||
| 93 | .cpu_name = "TI UltraSparc IIIi+ (Serrano)", | ||
| 94 | .fp_name = "UltraSparc IIIi+ integrated FPU", | ||
| 95 | }, | ||
| 33 | }; | 96 | }; |
| 34 | 97 | ||
| 35 | static struct cpu_fp_info linux_sparc_fpu[] = { | 98 | #define NSPARCCHIPS ARRAY_SIZE(linux_sparc_chips) |
| 36 | { 0x17, 0x10, 0, "UltraSparc I integrated FPU"}, | ||
| 37 | { 0x22, 0x10, 0, "UltraSparc I integrated FPU"}, | ||
| 38 | { 0x17, 0x11, 0, "UltraSparc II integrated FPU"}, | ||
| 39 | { 0x17, 0x12, 0, "UltraSparc IIi integrated FPU"}, | ||
| 40 | { 0x17, 0x13, 0, "UltraSparc IIe integrated FPU"}, | ||
| 41 | { 0x3e, 0x14, 0, "UltraSparc III integrated FPU"}, | ||
| 42 | { 0x3e, 0x15, 0, "UltraSparc III+ integrated FPU"}, | ||
| 43 | { 0x3e, 0x16, 0, "UltraSparc IIIi integrated FPU"}, | ||
| 44 | { 0x3e, 0x18, 0, "UltraSparc IV integrated FPU"}, | ||
| 45 | { 0x3e, 0x19, 0, "UltraSparc IV+ integrated FPU"}, | ||
| 46 | { 0x3e, 0x22, 0, "UltraSparc IIIi+ integrated FPU"}, | ||
| 47 | }; | ||
| 48 | |||
| 49 | #define NSPARCFPU ARRAY_SIZE(linux_sparc_fpu) | ||
| 50 | |||
| 51 | static struct cpu_iu_info linux_sparc_chips[] = { | ||
| 52 | { 0x17, 0x10, "TI UltraSparc I (SpitFire)"}, | ||
| 53 | { 0x22, 0x10, "TI UltraSparc I (SpitFire)"}, | ||
| 54 | { 0x17, 0x11, "TI UltraSparc II (BlackBird)"}, | ||
| 55 | { 0x17, 0x12, "TI UltraSparc IIi (Sabre)"}, | ||
| 56 | { 0x17, 0x13, "TI UltraSparc IIe (Hummingbird)"}, | ||
| 57 | { 0x3e, 0x14, "TI UltraSparc III (Cheetah)"}, | ||
| 58 | { 0x3e, 0x15, "TI UltraSparc III+ (Cheetah+)"}, | ||
| 59 | { 0x3e, 0x16, "TI UltraSparc IIIi (Jalapeno)"}, | ||
| 60 | { 0x3e, 0x18, "TI UltraSparc IV (Jaguar)"}, | ||
| 61 | { 0x3e, 0x19, "TI UltraSparc IV+ (Panther)"}, | ||
| 62 | { 0x3e, 0x22, "TI UltraSparc IIIi+ (Serrano)"}, | ||
| 63 | }; | ||
| 64 | 99 | ||
| 65 | #define NSPARCCHIPS ARRAY_SIZE(linux_sparc_chips) | 100 | const char *sparc_cpu_type; |
| 66 | 101 | const char *sparc_fpu_type; | |
| 67 | char *sparc_cpu_type; | ||
| 68 | char *sparc_fpu_type; | ||
| 69 | 102 | ||
| 70 | static void __init sun4v_cpu_probe(void) | 103 | static void __init sun4v_cpu_probe(void) |
| 71 | { | 104 | { |
| @@ -89,68 +122,45 @@ static void __init sun4v_cpu_probe(void) | |||
| 89 | } | 122 | } |
| 90 | } | 123 | } |
| 91 | 124 | ||
| 92 | void __init cpu_probe(void) | 125 | static const struct cpu_chip_info * __init find_cpu_chip(unsigned short manuf, |
| 126 | unsigned short impl) | ||
| 93 | { | 127 | { |
| 94 | unsigned long ver, fpu_vers, manuf, impl, fprs; | ||
| 95 | int i; | 128 | int i; |
| 96 | |||
| 97 | if (tlb_type == hypervisor) { | ||
| 98 | sun4v_cpu_probe(); | ||
| 99 | return; | ||
| 100 | } | ||
| 101 | 129 | ||
| 102 | fprs = fprs_read(); | 130 | for (i = 0; i < ARRAY_SIZE(cpu_chips); i++) { |
| 103 | fprs_write(FPRS_FEF); | 131 | const struct cpu_chip_info *p = &cpu_chips[i]; |
| 104 | __asm__ __volatile__ ("rdpr %%ver, %0; stx %%fsr, [%1]" | ||
| 105 | : "=&r" (ver) | ||
| 106 | : "r" (&fpu_vers)); | ||
| 107 | fprs_write(fprs); | ||
| 108 | |||
| 109 | manuf = ((ver >> 48) & 0xffff); | ||
| 110 | impl = ((ver >> 32) & 0xffff); | ||
| 111 | |||
| 112 | fpu_vers = ((fpu_vers >> 17) & 0x7); | ||
| 113 | |||
| 114 | retry: | ||
| 115 | for (i = 0; i < NSPARCCHIPS; i++) { | ||
| 116 | if (linux_sparc_chips[i].manuf == manuf) { | ||
| 117 | if (linux_sparc_chips[i].impl == impl) { | ||
| 118 | sparc_cpu_type = | ||
| 119 | linux_sparc_chips[i].cpu_name; | ||
| 120 | break; | ||
| 121 | } | ||
| 122 | } | ||
| 123 | } | ||
| 124 | 132 | ||
| 125 | if (i == NSPARCCHIPS) { | 133 | if (p->manuf == manuf && p->impl == impl) |
| 126 | /* Maybe it is a cheetah+ derivative, report it as cheetah+ | 134 | return p; |
| 127 | * in that case until we learn the real names. | ||
| 128 | */ | ||
| 129 | if (manuf == 0x3e && | ||
| 130 | impl > 0x15) { | ||
| 131 | impl = 0x15; | ||
| 132 | goto retry; | ||
| 133 | } else { | ||
| 134 | printk("DEBUG: manuf[%lx] impl[%lx]\n", | ||
| 135 | manuf, impl); | ||
| 136 | } | ||
| 137 | sparc_cpu_type = "Unknown CPU"; | ||
| 138 | } | 135 | } |
| 136 | return NULL; | ||
| 137 | } | ||
| 139 | 138 | ||
| 140 | for (i = 0; i < NSPARCFPU; i++) { | 139 | static int __init cpu_type_probe(void) |
| 141 | if (linux_sparc_fpu[i].manuf == manuf && | 140 | { |
| 142 | linux_sparc_fpu[i].impl == impl) { | 141 | if (tlb_type == hypervisor) { |
| 143 | if (linux_sparc_fpu[i].fpu_vers == fpu_vers) { | 142 | sun4v_cpu_probe(); |
| 144 | sparc_fpu_type = | 143 | } else { |
| 145 | linux_sparc_fpu[i].fp_name; | 144 | unsigned long ver, manuf, impl; |
| 146 | break; | 145 | const struct cpu_chip_info *p; |
| 147 | } | 146 | |
| 147 | __asm__ __volatile__("rdpr %%ver, %0" : "=r" (ver)); | ||
| 148 | |||
| 149 | manuf = ((ver >> 48) & 0xffff); | ||
| 150 | impl = ((ver >> 32) & 0xffff); | ||
| 151 | |||
| 152 | p = find_cpu_chip(manuf, impl); | ||
| 153 | if (p) { | ||
| 154 | sparc_cpu_type = p->cpu_name; | ||
| 155 | sparc_fpu_type = p->fp_name; | ||
| 156 | } else { | ||
| 157 | printk(KERN_ERR "CPU: Unknown chip, manuf[%lx] impl[%lx]\n", | ||
| 158 | manuf, impl); | ||
| 159 | sparc_cpu_type = "Unknown CPU"; | ||
| 160 | sparc_fpu_type = "Unknown FPU"; | ||
| 148 | } | 161 | } |
| 149 | } | 162 | } |
| 150 | 163 | return 0; | |
| 151 | if (i == NSPARCFPU) { | ||
| 152 | printk("DEBUG: manuf[%lx] impl[%lx] fsr.vers[%lx]\n", | ||
| 153 | manuf, impl, fpu_vers); | ||
| 154 | sparc_fpu_type = "Unknown FPU"; | ||
| 155 | } | ||
| 156 | } | 164 | } |
| 165 | |||
| 166 | arch_initcall(cpu_type_probe); | ||
diff --git a/arch/sparc64/kernel/entry.h b/arch/sparc64/kernel/entry.h index 2255244442f8..34d7ab5e10d2 100644 --- a/arch/sparc64/kernel/entry.h +++ b/arch/sparc64/kernel/entry.h | |||
| @@ -5,8 +5,8 @@ | |||
| 5 | #include <linux/types.h> | 5 | #include <linux/types.h> |
| 6 | #include <linux/init.h> | 6 | #include <linux/init.h> |
| 7 | 7 | ||
| 8 | extern char *sparc_cpu_type; | 8 | extern const char *sparc_cpu_type; |
| 9 | extern char *sparc_fpu_type; | 9 | extern const char *sparc_fpu_type; |
| 10 | 10 | ||
| 11 | extern void __init per_cpu_patch(void); | 11 | extern void __init per_cpu_patch(void); |
| 12 | extern void __init sun4v_patch(void); | 12 | extern void __init sun4v_patch(void); |
diff --git a/arch/sparc64/mm/init.c b/arch/sparc64/mm/init.c index 8cc1892c5540..54193f2d0ab7 100644 --- a/arch/sparc64/mm/init.c +++ b/arch/sparc64/mm/init.c | |||
| @@ -1841,8 +1841,6 @@ void __init paging_init(void) | |||
| 1841 | } | 1841 | } |
| 1842 | 1842 | ||
| 1843 | printk("Booting Linux...\n"); | 1843 | printk("Booting Linux...\n"); |
| 1844 | |||
| 1845 | cpu_probe(); | ||
| 1846 | } | 1844 | } |
| 1847 | 1845 | ||
| 1848 | int __init page_in_phys_avail(unsigned long paddr) | 1846 | int __init page_in_phys_avail(unsigned long paddr) |
