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 | * |
| 4 | * Copyright (C) 1996 David S. Miller (davem@caip.rutgers.edu) |
| 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/smp.h> |
| 10 | #include <linux/threads.h> |
| 11 | #include <asm/oplib.h> |
| 12 | #include <asm/page.h> |
| 13 | #include <asm/head.h> |
| 14 | #include <asm/psr.h> |
| 15 | #include <asm/mbus.h> |
| 16 | #include <asm/cpudata.h> |
| 17 | |
Sam Ravnborg | 53ae341 | 2008-12-07 00:02:08 -0800 | [diff] [blame^] | 18 | #include "kernel.h" |
| 19 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | DEFINE_PER_CPU(cpuinfo_sparc, __cpu_data) = { 0 }; |
| 21 | |
| 22 | struct cpu_iu_info { |
Sam Ravnborg | 8a563f0 | 2008-12-05 19:07:35 -0800 | [diff] [blame] | 23 | int psr_impl; |
| 24 | int psr_vers; |
| 25 | char *cpu_name; /* should be enough I hope... */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 26 | }; |
| 27 | |
| 28 | struct cpu_fp_info { |
Sam Ravnborg | 8a563f0 | 2008-12-05 19:07:35 -0800 | [diff] [blame] | 29 | int psr_impl; |
| 30 | int fp_vers; |
| 31 | char *fp_name; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 32 | }; |
| 33 | |
| 34 | /* In order to get the fpu type correct, you need to take the IDPROM's |
| 35 | * machine type value into consideration too. I will fix this. |
| 36 | */ |
Sam Ravnborg | 8a563f0 | 2008-12-05 19:07:35 -0800 | [diff] [blame] | 37 | #define CPU_FP(psr, ver, name) \ |
| 38 | { .psr_impl = (psr), .fp_vers = (ver), .fp_name = (name) } |
David S. Miller | c8edc89 | 2008-02-28 21:46:59 -0800 | [diff] [blame] | 39 | static struct cpu_fp_info linux_sparc_fpu[] = { |
Sam Ravnborg | 8a563f0 | 2008-12-05 19:07:35 -0800 | [diff] [blame] | 40 | CPU_FP(0, 0, "Fujitsu MB86910 or Weitek WTL1164/5"), |
| 41 | CPU_FP(0, 1, "Fujitsu MB86911 or Weitek WTL1164/5 or LSI L64831"), |
| 42 | CPU_FP(0, 2, "LSI Logic L64802 or Texas Instruments ACT8847"), |
| 43 | /* SparcStation SLC, SparcStation1 */ |
| 44 | CPU_FP(0, 3, "Weitek WTL3170/2"), |
| 45 | /* SPARCstation-5 */ |
| 46 | CPU_FP(0, 4, "Lsi Logic/Meiko L64804 or compatible"), |
| 47 | CPU_FP(0, 5, "reserved"), |
| 48 | CPU_FP(0, 6, "reserved"), |
| 49 | CPU_FP(0, 7, "No FPU"), |
| 50 | CPU_FP(1, 0, "ROSS HyperSparc combined IU/FPU"), |
| 51 | CPU_FP(1, 1, "Lsi Logic L64814"), |
| 52 | CPU_FP(1, 2, "Texas Instruments TMS390-C602A"), |
| 53 | CPU_FP(1, 3, "Cypress CY7C602 FPU"), |
| 54 | CPU_FP(1, 4, "reserved"), |
| 55 | CPU_FP(1, 5, "reserved"), |
| 56 | CPU_FP(1, 6, "reserved"), |
| 57 | CPU_FP(1, 7, "No FPU"), |
| 58 | CPU_FP(2, 0, "BIT B5010 or B5110/20 or B5210"), |
| 59 | CPU_FP(2, 1, "reserved"), |
| 60 | CPU_FP(2, 2, "reserved"), |
| 61 | CPU_FP(2, 3, "reserved"), |
| 62 | CPU_FP(2, 4, "reserved"), |
| 63 | CPU_FP(2, 5, "reserved"), |
| 64 | CPU_FP(2, 6, "reserved"), |
| 65 | CPU_FP(2, 7, "No FPU"), |
| 66 | /* SuperSparc 50 module */ |
| 67 | CPU_FP(4, 0, "SuperSparc on-chip FPU"), |
| 68 | /* SparcClassic */ |
| 69 | CPU_FP(4, 4, "TI MicroSparc on chip FPU"), |
| 70 | CPU_FP(5, 0, "Matsushita MN10501"), |
| 71 | CPU_FP(5, 1, "reserved"), |
| 72 | CPU_FP(5, 2, "reserved"), |
| 73 | CPU_FP(5, 3, "reserved"), |
| 74 | CPU_FP(5, 4, "reserved"), |
| 75 | CPU_FP(5, 5, "reserved"), |
| 76 | CPU_FP(5, 6, "reserved"), |
| 77 | CPU_FP(5, 7, "No FPU"), |
| 78 | CPU_FP(9, 3, "Fujitsu or Weitek on-chip FPU"), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 79 | }; |
| 80 | |
Tobias Klauser | 940fdc6 | 2005-11-09 12:03:05 -0800 | [diff] [blame] | 81 | #define NSPARCFPU ARRAY_SIZE(linux_sparc_fpu) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 82 | |
Sam Ravnborg | 8a563f0 | 2008-12-05 19:07:35 -0800 | [diff] [blame] | 83 | #define CPU_INFO(psr, ver, name) \ |
| 84 | { .psr_impl = (psr), .psr_vers = (ver), .cpu_name = (name) } |
David S. Miller | c8edc89 | 2008-02-28 21:46:59 -0800 | [diff] [blame] | 85 | static struct cpu_iu_info linux_sparc_chips[] = { |
Sam Ravnborg | 8a563f0 | 2008-12-05 19:07:35 -0800 | [diff] [blame] | 86 | /* Sun4/100, 4/200, SLC */ |
| 87 | CPU_INFO(0, 0, "Fujitsu MB86900/1A or LSI L64831 SparcKIT-40"), |
| 88 | /* borned STP1012PGA */ |
| 89 | CPU_INFO(0, 4, "Fujitsu MB86904"), |
| 90 | CPU_INFO(0, 5, "Fujitsu TurboSparc MB86907"), |
| 91 | /* SparcStation2, SparcServer 490 & 690 */ |
| 92 | CPU_INFO(1, 0, "LSI Logic Corporation - L64811"), |
| 93 | /* SparcStation2 */ |
| 94 | CPU_INFO(1, 1, "Cypress/ROSS CY7C601"), |
| 95 | /* Embedded controller */ |
| 96 | CPU_INFO(1, 3, "Cypress/ROSS CY7C611"), |
| 97 | /* Ross Technologies HyperSparc */ |
| 98 | CPU_INFO(1, 0xf, "ROSS HyperSparc RT620"), |
| 99 | CPU_INFO(1, 0xe, "ROSS HyperSparc RT625 or RT626"), |
| 100 | /* ECL Implementation, CRAY S-MP Supercomputer... AIEEE! */ |
| 101 | /* Someone please write the code to support this beast! ;) */ |
| 102 | CPU_INFO(2, 0, "Bipolar Integrated Technology - B5010"), |
| 103 | CPU_INFO(3, 0, "LSI Logic Corporation - unknown-type"), |
| 104 | CPU_INFO(4, 0, "Texas Instruments, Inc. - SuperSparc-(II)"), |
| 105 | /* SparcClassic -- borned STP1010TAB-50*/ |
| 106 | CPU_INFO(4, 1, "Texas Instruments, Inc. - MicroSparc"), |
| 107 | CPU_INFO(4, 2, "Texas Instruments, Inc. - MicroSparc II"), |
| 108 | CPU_INFO(4, 3, "Texas Instruments, Inc. - SuperSparc 51"), |
| 109 | CPU_INFO(4, 4, "Texas Instruments, Inc. - SuperSparc 61"), |
| 110 | CPU_INFO(4, 5, "Texas Instruments, Inc. - unknown"), |
| 111 | CPU_INFO(5, 0, "Matsushita - MN10501"), |
| 112 | CPU_INFO(6, 0, "Philips Corporation - unknown"), |
| 113 | CPU_INFO(7, 0, "Harvest VLSI Design Center, Inc. - unknown"), |
| 114 | /* Gallium arsenide 200MHz, BOOOOGOOOOMIPS!!! */ |
| 115 | CPU_INFO(8, 0, "Systems and Processes Engineering Corporation (SPEC)"), |
| 116 | CPU_INFO(9, 0, "Fujitsu or Weitek Power-UP"), |
| 117 | CPU_INFO(9, 1, "Fujitsu or Weitek Power-UP"), |
| 118 | CPU_INFO(9, 2, "Fujitsu or Weitek Power-UP"), |
| 119 | CPU_INFO(9, 3, "Fujitsu or Weitek Power-UP"), |
| 120 | CPU_INFO(0xa, 0, "UNKNOWN CPU-VENDOR/TYPE"), |
| 121 | CPU_INFO(0xb, 0, "UNKNOWN CPU-VENDOR/TYPE"), |
| 122 | CPU_INFO(0xc, 0, "UNKNOWN CPU-VENDOR/TYPE"), |
| 123 | CPU_INFO(0xd, 0, "UNKNOWN CPU-VENDOR/TYPE"), |
| 124 | CPU_INFO(0xe, 0, "UNKNOWN CPU-VENDOR/TYPE"), |
| 125 | CPU_INFO(0xf, 0, "UNKNOWN CPU-VENDOR/TYPE"), |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | }; |
| 127 | |
Tobias Klauser | 940fdc6 | 2005-11-09 12:03:05 -0800 | [diff] [blame] | 128 | #define NSPARCCHIPS ARRAY_SIZE(linux_sparc_chips) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 129 | |
Sam Ravnborg | 53ae341 | 2008-12-07 00:02:08 -0800 | [diff] [blame^] | 130 | const char *sparc_cpu_type; |
| 131 | const char *sparc_fpu_type; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | |
| 133 | unsigned int fsr_storage; |
| 134 | |
Al Viro | 409832f | 2008-11-22 17:33:54 +0000 | [diff] [blame] | 135 | void __cpuinit cpu_probe(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 136 | { |
| 137 | int psr_impl, psr_vers, fpu_vers; |
| 138 | int i, psr; |
| 139 | |
Sam Ravnborg | 8a563f0 | 2008-12-05 19:07:35 -0800 | [diff] [blame] | 140 | psr_impl = ((get_psr() >> 28) & 0xf); |
| 141 | psr_vers = ((get_psr() >> 24) & 0xf); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | |
| 143 | psr = get_psr(); |
| 144 | put_psr(psr | PSR_EF); |
Sam Ravnborg | 8a563f0 | 2008-12-05 19:07:35 -0800 | [diff] [blame] | 145 | fpu_vers = ((get_fsr() >> 17) & 0x7); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 146 | put_psr(psr); |
| 147 | |
Sam Ravnborg | 8a563f0 | 2008-12-05 19:07:35 -0800 | [diff] [blame] | 148 | for (i = 0; i < NSPARCCHIPS; i++) { |
| 149 | if (linux_sparc_chips[i].psr_impl == psr_impl) |
| 150 | if (linux_sparc_chips[i].psr_vers == psr_vers) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 151 | sparc_cpu_type = linux_sparc_chips[i].cpu_name; |
| 152 | break; |
| 153 | } |
| 154 | } |
| 155 | |
Sam Ravnborg | 8a563f0 | 2008-12-05 19:07:35 -0800 | [diff] [blame] | 156 | if (i == NSPARCCHIPS) |
Sam Ravnborg | 6c6bd8b | 2008-12-05 19:08:22 -0800 | [diff] [blame] | 157 | { |
| 158 | printk(KERN_ERR "CPU: Unknown chip, impl[0x%x] vers[0x%x]\n", |
Sam Ravnborg | 8a563f0 | 2008-12-05 19:07:35 -0800 | [diff] [blame] | 159 | psr_impl, psr_vers); |
Sam Ravnborg | 6c6bd8b | 2008-12-05 19:08:22 -0800 | [diff] [blame] | 160 | sparc_cpu_type = "Unknown CPU"; |
| 161 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 162 | |
Sam Ravnborg | 8a563f0 | 2008-12-05 19:07:35 -0800 | [diff] [blame] | 163 | for (i = 0; i < NSPARCFPU; i++) { |
| 164 | if (linux_sparc_fpu[i].psr_impl == psr_impl) |
| 165 | if (linux_sparc_fpu[i].fp_vers == fpu_vers) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | sparc_fpu_type = linux_sparc_fpu[i].fp_name; |
| 167 | break; |
| 168 | } |
| 169 | } |
| 170 | |
Sam Ravnborg | 8a563f0 | 2008-12-05 19:07:35 -0800 | [diff] [blame] | 171 | if (i == NSPARCFPU) { |
Sam Ravnborg | 6c6bd8b | 2008-12-05 19:08:22 -0800 | [diff] [blame] | 172 | printk(KERN_ERR "FPU: Unknown chip, impl[0x%x] vers[0x%x]\n", |
Sam Ravnborg | 8a563f0 | 2008-12-05 19:07:35 -0800 | [diff] [blame] | 173 | psr_impl, fpu_vers); |
Sam Ravnborg | 6c6bd8b | 2008-12-05 19:08:22 -0800 | [diff] [blame] | 174 | sparc_fpu_type = "Unknown FPU"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 175 | } |
| 176 | } |