Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* cpu.c: Dinky routines to look for the kind of Sparc cpu |
| 2 | * we are on. |
| 3 | * |
David S. Miller | 68c9f9f | 2007-08-07 19:09:29 -0700 | [diff] [blame] | 4 | * Copyright (C) 1996, 2007 David S. Miller (davem@davemloft.net) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 5 | */ |
| 6 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 7 | #include <linux/kernel.h> |
| 8 | #include <linux/init.h> |
| 9 | #include <linux/sched.h> |
| 10 | #include <linux/smp.h> |
| 11 | #include <asm/asi.h> |
| 12 | #include <asm/system.h> |
| 13 | #include <asm/fpumacro.h> |
| 14 | #include <asm/cpudata.h> |
David S. Miller | 12816ab | 2006-02-09 03:00:00 -0800 | [diff] [blame] | 15 | #include <asm/spitfire.h> |
David S. Miller | 6c70b6f | 2007-08-08 17:11:39 -0700 | [diff] [blame] | 16 | #include <asm/oplib.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 17 | |
| 18 | DEFINE_PER_CPU(cpuinfo_sparc, __cpu_data) = { 0 }; |
| 19 | |
| 20 | struct cpu_iu_info { |
| 21 | short manuf; |
| 22 | short impl; |
| 23 | char* cpu_name; /* should be enough I hope... */ |
| 24 | }; |
| 25 | |
| 26 | struct cpu_fp_info { |
| 27 | short manuf; |
| 28 | short impl; |
| 29 | char fpu_vers; |
| 30 | char* fp_name; |
| 31 | }; |
| 32 | |
| 33 | struct cpu_fp_info linux_sparc_fpu[] = { |
| 34 | { 0x17, 0x10, 0, "UltraSparc I integrated FPU"}, |
| 35 | { 0x22, 0x10, 0, "UltraSparc I integrated FPU"}, |
| 36 | { 0x17, 0x11, 0, "UltraSparc II integrated FPU"}, |
| 37 | { 0x17, 0x12, 0, "UltraSparc IIi integrated FPU"}, |
| 38 | { 0x17, 0x13, 0, "UltraSparc IIe integrated FPU"}, |
| 39 | { 0x3e, 0x14, 0, "UltraSparc III integrated FPU"}, |
| 40 | { 0x3e, 0x15, 0, "UltraSparc III+ integrated FPU"}, |
| 41 | { 0x3e, 0x16, 0, "UltraSparc IIIi integrated FPU"}, |
| 42 | { 0x3e, 0x18, 0, "UltraSparc IV integrated FPU"}, |
David S. Miller | d2212bc | 2005-09-27 22:50:06 -0700 | [diff] [blame] | 43 | { 0x3e, 0x19, 0, "UltraSparc IV+ integrated FPU"}, |
| 44 | { 0x3e, 0x22, 0, "UltraSparc IIIi+ integrated FPU"}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 45 | }; |
| 46 | |
Tobias Klauser | 84c1a13 | 2005-11-09 12:03:42 -0800 | [diff] [blame] | 47 | #define NSPARCFPU ARRAY_SIZE(linux_sparc_fpu) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 48 | |
| 49 | struct cpu_iu_info linux_sparc_chips[] = { |
| 50 | { 0x17, 0x10, "TI UltraSparc I (SpitFire)"}, |
| 51 | { 0x22, 0x10, "TI UltraSparc I (SpitFire)"}, |
| 52 | { 0x17, 0x11, "TI UltraSparc II (BlackBird)"}, |
| 53 | { 0x17, 0x12, "TI UltraSparc IIi (Sabre)"}, |
| 54 | { 0x17, 0x13, "TI UltraSparc IIe (Hummingbird)"}, |
| 55 | { 0x3e, 0x14, "TI UltraSparc III (Cheetah)"}, |
| 56 | { 0x3e, 0x15, "TI UltraSparc III+ (Cheetah+)"}, |
| 57 | { 0x3e, 0x16, "TI UltraSparc IIIi (Jalapeno)"}, |
| 58 | { 0x3e, 0x18, "TI UltraSparc IV (Jaguar)"}, |
David S. Miller | d2212bc | 2005-09-27 22:50:06 -0700 | [diff] [blame] | 59 | { 0x3e, 0x19, "TI UltraSparc IV+ (Panther)"}, |
| 60 | { 0x3e, 0x22, "TI UltraSparc IIIi+ (Serrano)"}, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 61 | }; |
| 62 | |
Tobias Klauser | 84c1a13 | 2005-11-09 12:03:42 -0800 | [diff] [blame] | 63 | #define NSPARCCHIPS ARRAY_SIZE(linux_sparc_chips) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | |
David S. Miller | 68c9f9f | 2007-08-07 19:09:29 -0700 | [diff] [blame] | 65 | char *sparc_cpu_type; |
| 66 | char *sparc_fpu_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 67 | |
| 68 | unsigned int fsr_storage; |
| 69 | |
David S. Miller | 68c9f9f | 2007-08-07 19:09:29 -0700 | [diff] [blame] | 70 | static void __init sun4v_cpu_probe(void) |
| 71 | { |
David S. Miller | 6c70b6f | 2007-08-08 17:11:39 -0700 | [diff] [blame] | 72 | switch (sun4v_chip_type) { |
| 73 | case SUN4V_CHIP_NIAGARA1: |
David S. Miller | 68c9f9f | 2007-08-07 19:09:29 -0700 | [diff] [blame] | 74 | sparc_cpu_type = "UltraSparc T1 (Niagara)"; |
| 75 | sparc_fpu_type = "UltraSparc T1 integrated FPU"; |
David S. Miller | 6c70b6f | 2007-08-08 17:11:39 -0700 | [diff] [blame] | 76 | break; |
| 77 | |
| 78 | case SUN4V_CHIP_NIAGARA2: |
David S. Miller | 68c9f9f | 2007-08-07 19:09:29 -0700 | [diff] [blame] | 79 | sparc_cpu_type = "UltraSparc T2 (Niagara2)"; |
| 80 | sparc_fpu_type = "UltraSparc T2 integrated FPU"; |
David S. Miller | 6c70b6f | 2007-08-08 17:11:39 -0700 | [diff] [blame] | 81 | break; |
David S. Miller | 68c9f9f | 2007-08-07 19:09:29 -0700 | [diff] [blame] | 82 | |
David S. Miller | 6c70b6f | 2007-08-08 17:11:39 -0700 | [diff] [blame] | 83 | default: |
| 84 | printk(KERN_WARNING "CPU: Unknown sun4v cpu type [%s]\n", |
| 85 | prom_cpu_compatible); |
| 86 | sparc_cpu_type = "Unknown SUN4V CPU"; |
| 87 | sparc_fpu_type = "Unknown SUN4V FPU"; |
| 88 | break; |
| 89 | } |
David S. Miller | 68c9f9f | 2007-08-07 19:09:29 -0700 | [diff] [blame] | 90 | } |
| 91 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 92 | void __init cpu_probe(void) |
| 93 | { |
| 94 | unsigned long ver, fpu_vers, manuf, impl, fprs; |
| 95 | int i; |
| 96 | |
David S. Miller | 68c9f9f | 2007-08-07 19:09:29 -0700 | [diff] [blame] | 97 | if (tlb_type == hypervisor) |
| 98 | return sun4v_cpu_probe(); |
David S. Miller | d82ace7 | 2006-02-09 02:52:44 -0800 | [diff] [blame] | 99 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 100 | fprs = fprs_read(); |
| 101 | fprs_write(FPRS_FEF); |
| 102 | __asm__ __volatile__ ("rdpr %%ver, %0; stx %%fsr, [%1]" |
| 103 | : "=&r" (ver) |
| 104 | : "r" (&fpu_vers)); |
| 105 | fprs_write(fprs); |
| 106 | |
| 107 | manuf = ((ver >> 48) & 0xffff); |
| 108 | impl = ((ver >> 32) & 0xffff); |
| 109 | |
| 110 | fpu_vers = ((fpu_vers >> 17) & 0x7); |
| 111 | |
| 112 | retry: |
| 113 | for (i = 0; i < NSPARCCHIPS; i++) { |
| 114 | if (linux_sparc_chips[i].manuf == manuf) { |
| 115 | if (linux_sparc_chips[i].impl == impl) { |
| 116 | sparc_cpu_type = |
| 117 | linux_sparc_chips[i].cpu_name; |
| 118 | break; |
| 119 | } |
| 120 | } |
| 121 | } |
| 122 | |
| 123 | if (i == NSPARCCHIPS) { |
| 124 | /* Maybe it is a cheetah+ derivative, report it as cheetah+ |
| 125 | * in that case until we learn the real names. |
| 126 | */ |
| 127 | if (manuf == 0x3e && |
| 128 | impl > 0x15) { |
| 129 | impl = 0x15; |
| 130 | goto retry; |
| 131 | } else { |
| 132 | printk("DEBUG: manuf[%lx] impl[%lx]\n", |
| 133 | manuf, impl); |
| 134 | } |
| 135 | sparc_cpu_type = "Unknown CPU"; |
| 136 | } |
| 137 | |
| 138 | for (i = 0; i < NSPARCFPU; i++) { |
| 139 | if (linux_sparc_fpu[i].manuf == manuf && |
| 140 | linux_sparc_fpu[i].impl == impl) { |
| 141 | if (linux_sparc_fpu[i].fpu_vers == fpu_vers) { |
| 142 | sparc_fpu_type = |
| 143 | linux_sparc_fpu[i].fp_name; |
| 144 | break; |
| 145 | } |
| 146 | } |
| 147 | } |
| 148 | |
| 149 | if (i == NSPARCFPU) { |
| 150 | printk("DEBUG: manuf[%lx] impl[%lx] fsr.vers[%lx]\n", |
| 151 | manuf, impl, fpu_vers); |
| 152 | sparc_fpu_type = "Unknown FPU"; |
| 153 | } |
| 154 | } |