Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | #include <linux/init.h> |
| 2 | #include <linux/bitops.h> |
| 3 | #include <linux/delay.h> |
| 4 | #include <linux/pci.h> |
| 5 | #include <asm/dma.h> |
| 6 | #include <asm/io.h> |
Juergen Beisert | f25f64e | 2007-07-22 11:12:38 +0200 | [diff] [blame] | 7 | #include <asm/processor-cyrix.h> |
Dave Jones | 7ebad70 | 2008-01-30 13:30:39 +0100 | [diff] [blame] | 8 | #include <asm/processor-flags.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | #include <asm/timer.h> |
Alan | 120fad7 | 2007-02-13 13:26:26 +0100 | [diff] [blame] | 10 | #include <asm/pci-direct.h> |
Alexey Dobriyan | e8edc6e | 2007-05-21 01:22:52 +0400 | [diff] [blame] | 11 | #include <asm/tsc.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | |
| 13 | #include "cpu.h" |
| 14 | |
| 15 | /* |
| 16 | * Read NSC/Cyrix DEVID registers (DIR) to get more detailed info. about the CPU |
| 17 | */ |
Magnus Damm | 5f0f1c1 | 2006-09-26 10:52:36 +0200 | [diff] [blame] | 18 | static void __cpuinit do_cyrix_devid(unsigned char *dir0, unsigned char *dir1) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 19 | { |
| 20 | unsigned char ccr2, ccr3; |
| 21 | unsigned long flags; |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 22 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | /* we test for DEVID by checking whether CCR3 is writable */ |
| 24 | local_irq_save(flags); |
| 25 | ccr3 = getCx86(CX86_CCR3); |
| 26 | setCx86(CX86_CCR3, ccr3 ^ 0x80); |
| 27 | getCx86(0xc0); /* dummy to change bus */ |
| 28 | |
| 29 | if (getCx86(CX86_CCR3) == ccr3) { /* no DEVID regs. */ |
| 30 | ccr2 = getCx86(CX86_CCR2); |
| 31 | setCx86(CX86_CCR2, ccr2 ^ 0x04); |
| 32 | getCx86(0xc0); /* dummy */ |
| 33 | |
| 34 | if (getCx86(CX86_CCR2) == ccr2) /* old Cx486SLC/DLC */ |
| 35 | *dir0 = 0xfd; |
| 36 | else { /* Cx486S A step */ |
| 37 | setCx86(CX86_CCR2, ccr2); |
| 38 | *dir0 = 0xfe; |
| 39 | } |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 40 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 41 | setCx86(CX86_CCR3, ccr3); /* restore CCR3 */ |
| 42 | |
| 43 | /* read DIR0 and DIR1 CPU registers */ |
| 44 | *dir0 = getCx86(CX86_DIR0); |
| 45 | *dir1 = getCx86(CX86_DIR1); |
| 46 | } |
| 47 | local_irq_restore(flags); |
| 48 | } |
| 49 | |
| 50 | /* |
| 51 | * Cx86_dir0_msb is a HACK needed by check_cx686_cpuid/slop in bugs.h in |
| 52 | * order to identify the Cyrix CPU model after we're out of setup.c |
| 53 | * |
| 54 | * Actually since bugs.h doesn't even reference this perhaps someone should |
| 55 | * fix the documentation ??? |
| 56 | */ |
Magnus Damm | b4af3f7 | 2006-09-26 10:52:36 +0200 | [diff] [blame] | 57 | static unsigned char Cx86_dir0_msb __cpuinitdata = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 58 | |
Magnus Damm | b4af3f7 | 2006-09-26 10:52:36 +0200 | [diff] [blame] | 59 | static char Cx86_model[][9] __cpuinitdata = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 60 | "Cx486", "Cx486", "5x86 ", "6x86", "MediaGX ", "6x86MX ", |
| 61 | "M II ", "Unknown" |
| 62 | }; |
Magnus Damm | b4af3f7 | 2006-09-26 10:52:36 +0200 | [diff] [blame] | 63 | static char Cx486_name[][5] __cpuinitdata = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 64 | "SLC", "DLC", "SLC2", "DLC2", "SRx", "DRx", |
| 65 | "SRx2", "DRx2" |
| 66 | }; |
Magnus Damm | b4af3f7 | 2006-09-26 10:52:36 +0200 | [diff] [blame] | 67 | static char Cx486S_name[][4] __cpuinitdata = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | "S", "S2", "Se", "S2e" |
| 69 | }; |
Magnus Damm | b4af3f7 | 2006-09-26 10:52:36 +0200 | [diff] [blame] | 70 | static char Cx486D_name[][4] __cpuinitdata = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 71 | "DX", "DX2", "?", "?", "?", "DX4" |
| 72 | }; |
Magnus Damm | b4af3f7 | 2006-09-26 10:52:36 +0200 | [diff] [blame] | 73 | static char Cx86_cb[] __cpuinitdata = "?.5x Core/Bus Clock"; |
| 74 | static char cyrix_model_mult1[] __cpuinitdata = "12??43"; |
| 75 | static char cyrix_model_mult2[] __cpuinitdata = "12233445"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 76 | |
| 77 | /* |
| 78 | * Reset the slow-loop (SLOP) bit on the 686(L) which is set by some old |
| 79 | * BIOSes for compatibility with DOS games. This makes the udelay loop |
| 80 | * work correctly, and improves performance. |
| 81 | * |
| 82 | * FIXME: our newer udelay uses the tsc. We don't need to frob with SLOP |
| 83 | */ |
| 84 | |
Magnus Damm | b4af3f7 | 2006-09-26 10:52:36 +0200 | [diff] [blame] | 85 | static void __cpuinit check_cx686_slop(struct cpuinfo_x86 *c) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 86 | { |
| 87 | unsigned long flags; |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 88 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 89 | if (Cx86_dir0_msb == 3) { |
| 90 | unsigned char ccr3, ccr5; |
| 91 | |
| 92 | local_irq_save(flags); |
| 93 | ccr3 = getCx86(CX86_CCR3); |
Marcin Garski | db95517 | 2007-10-19 23:22:11 +0200 | [diff] [blame] | 94 | setCx86(CX86_CCR3, (ccr3 & 0x0f) | 0x10); /* enable MAPEN */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 95 | ccr5 = getCx86(CX86_CCR5); |
| 96 | if (ccr5 & 2) |
| 97 | setCx86(CX86_CCR5, ccr5 & 0xfd); /* reset SLOP */ |
| 98 | setCx86(CX86_CCR3, ccr3); /* disable MAPEN */ |
| 99 | local_irq_restore(flags); |
| 100 | |
| 101 | if (ccr5 & 2) { /* possible wrong calibration done */ |
| 102 | printk(KERN_INFO "Recalibrating delay loop with SLOP bit reset\n"); |
| 103 | calibrate_delay(); |
| 104 | c->loops_per_jiffy = loops_per_jiffy; |
| 105 | } |
| 106 | } |
| 107 | } |
| 108 | |
| 109 | |
Magnus Damm | b4af3f7 | 2006-09-26 10:52:36 +0200 | [diff] [blame] | 110 | static void __cpuinit set_cx86_reorder(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 111 | { |
| 112 | u8 ccr3; |
| 113 | |
| 114 | printk(KERN_INFO "Enable Memory access reorder on Cyrix/NSC processor.\n"); |
| 115 | ccr3 = getCx86(CX86_CCR3); |
Jan Engelhardt | 96de0e2 | 2007-10-19 23:21:04 +0200 | [diff] [blame] | 116 | setCx86(CX86_CCR3, (ccr3 & 0x0f) | 0x10); /* enable MAPEN */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 117 | |
Jan Engelhardt | 96de0e2 | 2007-10-19 23:21:04 +0200 | [diff] [blame] | 118 | /* Load/Store Serialize to mem access disable (=reorder it) */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 119 | setCx86(CX86_PCR0, getCx86(CX86_PCR0) & ~0x80); |
| 120 | /* set load/store serialize from 1GB to 4GB */ |
| 121 | ccr3 |= 0xe0; |
| 122 | setCx86(CX86_CCR3, ccr3); |
| 123 | } |
| 124 | |
Magnus Damm | b4af3f7 | 2006-09-26 10:52:36 +0200 | [diff] [blame] | 125 | static void __cpuinit set_cx86_memwb(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 126 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | printk(KERN_INFO "Enable Memory-Write-back mode on Cyrix/NSC processor.\n"); |
| 128 | |
| 129 | /* CCR2 bit 2: unlock NW bit */ |
| 130 | setCx86(CX86_CCR2, getCx86(CX86_CCR2) & ~0x04); |
| 131 | /* set 'Not Write-through' */ |
Dave Jones | 7ebad70 | 2008-01-30 13:30:39 +0100 | [diff] [blame] | 132 | write_cr0(read_cr0() | X86_CR0_NW); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 133 | /* CCR2 bit 2: lock NW bit and set WT1 */ |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 134 | setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x14); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 135 | } |
| 136 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 137 | /* |
| 138 | * Configure later MediaGX and/or Geode processor. |
| 139 | */ |
| 140 | |
Magnus Damm | b4af3f7 | 2006-09-26 10:52:36 +0200 | [diff] [blame] | 141 | static void __cpuinit geode_configure(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 142 | { |
| 143 | unsigned long flags; |
TAKADA Yoshihito | bcde1eb | 2007-02-13 13:26:25 +0100 | [diff] [blame] | 144 | u8 ccr3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 145 | local_irq_save(flags); |
| 146 | |
| 147 | /* Suspend on halt power saving and enable #SUSP pin */ |
| 148 | setCx86(CX86_CCR2, getCx86(CX86_CCR2) | 0x88); |
| 149 | |
| 150 | ccr3 = getCx86(CX86_CCR3); |
TAKADA Yoshihito | bcde1eb | 2007-02-13 13:26:25 +0100 | [diff] [blame] | 151 | setCx86(CX86_CCR3, (ccr3 & 0x0f) | 0x10); /* enable MAPEN */ |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 152 | |
TAKADA Yoshihito | bcde1eb | 2007-02-13 13:26:25 +0100 | [diff] [blame] | 153 | |
| 154 | /* FPU fast, DTE cache, Mem bypass */ |
| 155 | setCx86(CX86_CCR4, getCx86(CX86_CCR4) | 0x38); |
| 156 | setCx86(CX86_CCR3, ccr3); /* disable MAPEN */ |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 157 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 158 | set_cx86_memwb(); |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 159 | set_cx86_reorder(); |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 160 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | local_irq_restore(flags); |
| 162 | } |
| 163 | |
| 164 | |
Magnus Damm | b4af3f7 | 2006-09-26 10:52:36 +0200 | [diff] [blame] | 165 | static void __cpuinit init_cyrix(struct cpuinfo_x86 *c) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | { |
| 167 | unsigned char dir0, dir0_msn, dir0_lsn, dir1 = 0; |
| 168 | char *buf = c->x86_model_id; |
| 169 | const char *p = NULL; |
| 170 | |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 171 | /* |
| 172 | * Bit 31 in normal CPUID used for nonstandard 3DNow ID; |
| 173 | * 3DNow is IDd by bit 31 in extended CPUID (1*32+31) anyway |
| 174 | */ |
Ingo Molnar | 1d007cd | 2008-02-26 08:52:27 +0100 | [diff] [blame] | 175 | clear_cpu_cap(c, 0*32+31); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | |
| 177 | /* Cyrix used bit 24 in extended (AMD) CPUID for Cyrix MMX extensions */ |
Ingo Molnar | 1d007cd | 2008-02-26 08:52:27 +0100 | [diff] [blame] | 178 | if (test_cpu_cap(c, 1*32+24)) { |
| 179 | clear_cpu_cap(c, 1*32+24); |
| 180 | set_cpu_cap(c, X86_FEATURE_CXMMX); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 181 | } |
| 182 | |
| 183 | do_cyrix_devid(&dir0, &dir1); |
| 184 | |
| 185 | check_cx686_slop(c); |
| 186 | |
| 187 | Cx86_dir0_msb = dir0_msn = dir0 >> 4; /* identifies CPU "family" */ |
| 188 | dir0_lsn = dir0 & 0xf; /* model or clock multiplier */ |
| 189 | |
| 190 | /* common case step number/rev -- exceptions handled below */ |
| 191 | c->x86_model = (dir1 >> 4) + 1; |
| 192 | c->x86_mask = dir1 & 0xf; |
| 193 | |
| 194 | /* Now cook; the original recipe is by Channing Corn, from Cyrix. |
| 195 | * We do the same thing for each generation: we work out |
| 196 | * the model, multiplier and stepping. Black magic included, |
| 197 | * to make the silicon step/rev numbers match the printed ones. |
| 198 | */ |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 199 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 200 | switch (dir0_msn) { |
| 201 | unsigned char tmp; |
| 202 | |
| 203 | case 0: /* Cx486SLC/DLC/SRx/DRx */ |
| 204 | p = Cx486_name[dir0_lsn & 7]; |
| 205 | break; |
| 206 | |
| 207 | case 1: /* Cx486S/DX/DX2/DX4 */ |
| 208 | p = (dir0_lsn & 8) ? Cx486D_name[dir0_lsn & 5] |
| 209 | : Cx486S_name[dir0_lsn & 3]; |
| 210 | break; |
| 211 | |
| 212 | case 2: /* 5x86 */ |
| 213 | Cx86_cb[2] = cyrix_model_mult1[dir0_lsn & 5]; |
| 214 | p = Cx86_cb+2; |
| 215 | break; |
| 216 | |
| 217 | case 3: /* 6x86/6x86L */ |
| 218 | Cx86_cb[1] = ' '; |
| 219 | Cx86_cb[2] = cyrix_model_mult1[dir0_lsn & 5]; |
| 220 | if (dir1 > 0x21) { /* 686L */ |
| 221 | Cx86_cb[0] = 'L'; |
| 222 | p = Cx86_cb; |
| 223 | (c->x86_model)++; |
| 224 | } else /* 686 */ |
| 225 | p = Cx86_cb+1; |
| 226 | /* Emulate MTRRs using Cyrix's ARRs. */ |
Ingo Molnar | 1d007cd | 2008-02-26 08:52:27 +0100 | [diff] [blame] | 227 | set_cpu_cap(c, X86_FEATURE_CYRIX_ARR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 228 | /* 6x86's contain this bug */ |
| 229 | c->coma_bug = 1; |
| 230 | break; |
| 231 | |
| 232 | case 4: /* MediaGX/GXm or Geode GXM/GXLV/GX1 */ |
| 233 | #ifdef CONFIG_PCI |
Alan | 120fad7 | 2007-02-13 13:26:26 +0100 | [diff] [blame] | 234 | { |
| 235 | u32 vendor, device; |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 236 | /* |
| 237 | * It isn't really a PCI quirk directly, but the cure is the |
| 238 | * same. The MediaGX has deep magic SMM stuff that handles the |
| 239 | * SB emulation. It throws away the fifo on disable_dma() which |
| 240 | * is wrong and ruins the audio. |
| 241 | * |
| 242 | * Bug2: VSA1 has a wrap bug so that using maximum sized DMA |
| 243 | * causes bad things. According to NatSemi VSA2 has another |
| 244 | * bug to do with 'hlt'. I've not seen any boards using VSA2 |
| 245 | * and X doesn't seem to support it either so who cares 8). |
| 246 | * VSA1 we work around however. |
| 247 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 248 | |
| 249 | printk(KERN_INFO "Working around Cyrix MediaGX virtual DMA bugs.\n"); |
| 250 | isa_dma_bridge_buggy = 2; |
Andreas Mohr | cefc011 | 2006-06-23 02:04:26 -0700 | [diff] [blame] | 251 | |
Alan | 120fad7 | 2007-02-13 13:26:26 +0100 | [diff] [blame] | 252 | /* We do this before the PCI layer is running. However we |
| 253 | are safe here as we know the bridge must be a Cyrix |
| 254 | companion and must be present */ |
| 255 | vendor = read_pci_config_16(0, 0, 0x12, PCI_VENDOR_ID); |
| 256 | device = read_pci_config_16(0, 0, 0x12, PCI_DEVICE_ID); |
Andreas Mohr | cefc011 | 2006-06-23 02:04:26 -0700 | [diff] [blame] | 257 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 258 | /* |
| 259 | * The 5510/5520 companion chips have a funky PIT. |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 260 | */ |
Alan | 120fad7 | 2007-02-13 13:26:26 +0100 | [diff] [blame] | 261 | if (vendor == PCI_VENDOR_ID_CYRIX && |
| 262 | (device == PCI_DEVICE_ID_CYRIX_5510 || device == PCI_DEVICE_ID_CYRIX_5520)) |
john stultz | 5a90cf2 | 2007-05-02 19:27:08 +0200 | [diff] [blame] | 263 | mark_tsc_unstable("cyrix 5510/5520 detected"); |
Alan | 120fad7 | 2007-02-13 13:26:26 +0100 | [diff] [blame] | 264 | } |
Andreas Mohr | cefc011 | 2006-06-23 02:04:26 -0700 | [diff] [blame] | 265 | #endif |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 266 | c->x86_cache_size = 16; /* Yep 16K integrated cache thats it */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 267 | |
| 268 | /* GXm supports extended cpuid levels 'ala' AMD */ |
| 269 | if (c->cpuid_level == 2) { |
| 270 | /* Enable cxMMX extensions (GX1 Datasheet 54) */ |
takada | 2632f01 | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 271 | setCx86(CX86_CCR7, getCx86(CX86_CCR7) | 1); |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 272 | |
takada | 2632f01 | 2007-02-13 13:26:24 +0100 | [diff] [blame] | 273 | /* |
| 274 | * GXm : 0x30 ... 0x5f GXm datasheet 51 |
| 275 | * GXlv: 0x6x GXlv datasheet 54 |
| 276 | * ? : 0x7x |
| 277 | * GX1 : 0x8x GX1 datasheet 56 |
| 278 | */ |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 279 | if ((0x30 <= dir1 && dir1 <= 0x6f) || (0x80 <= dir1 && dir1 <= 0x8f)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 280 | geode_configure(); |
| 281 | get_model_name(c); /* get CPU marketing name */ |
| 282 | return; |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 283 | } else { /* MediaGX */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 284 | Cx86_cb[2] = (dir0_lsn & 1) ? '3' : '4'; |
| 285 | p = Cx86_cb+2; |
| 286 | c->x86_model = (dir1 & 0x20) ? 1 : 2; |
| 287 | } |
| 288 | break; |
| 289 | |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 290 | case 5: /* 6x86MX/M II */ |
| 291 | if (dir1 > 7) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 292 | dir0_msn++; /* M II */ |
| 293 | /* Enable MMX extensions (App note 108) */ |
| 294 | setCx86(CX86_CCR7, getCx86(CX86_CCR7)|1); |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 295 | } else { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 296 | c->coma_bug = 1; /* 6x86MX, it has the bug. */ |
| 297 | } |
| 298 | tmp = (!(dir0_lsn & 7) || dir0_lsn & 1) ? 2 : 0; |
| 299 | Cx86_cb[tmp] = cyrix_model_mult2[dir0_lsn & 7]; |
| 300 | p = Cx86_cb+tmp; |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 301 | if (((dir1 & 0x0f) > 4) || ((dir1 & 0xf0) == 0x20)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 302 | (c->x86_model)++; |
| 303 | /* Emulate MTRRs using Cyrix's ARRs. */ |
Ingo Molnar | 1d007cd | 2008-02-26 08:52:27 +0100 | [diff] [blame] | 304 | set_cpu_cap(c, X86_FEATURE_CYRIX_ARR); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 305 | break; |
| 306 | |
| 307 | case 0xf: /* Cyrix 486 without DEVID registers */ |
| 308 | switch (dir0_lsn) { |
| 309 | case 0xd: /* either a 486SLC or DLC w/o DEVID */ |
| 310 | dir0_msn = 0; |
| 311 | p = Cx486_name[(c->hard_math) ? 1 : 0]; |
| 312 | break; |
| 313 | |
| 314 | case 0xe: /* a 486S A step */ |
| 315 | dir0_msn = 0; |
| 316 | p = Cx486S_name[0]; |
| 317 | break; |
| 318 | } |
| 319 | break; |
| 320 | |
| 321 | default: /* unknown (shouldn't happen, we know everyone ;-) */ |
| 322 | dir0_msn = 7; |
| 323 | break; |
| 324 | } |
| 325 | strcpy(buf, Cx86_model[dir0_msn & 7]); |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 326 | if (p) |
| 327 | strcat(buf, p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 328 | return; |
| 329 | } |
| 330 | |
| 331 | /* |
Jordan Crouse | f90b811 | 2006-01-06 00:12:14 -0800 | [diff] [blame] | 332 | * Handle National Semiconductor branded processors |
| 333 | */ |
Magnus Damm | b4af3f7 | 2006-09-26 10:52:36 +0200 | [diff] [blame] | 334 | static void __cpuinit init_nsc(struct cpuinfo_x86 *c) |
Jordan Crouse | f90b811 | 2006-01-06 00:12:14 -0800 | [diff] [blame] | 335 | { |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 336 | /* |
| 337 | * There may be GX1 processors in the wild that are branded |
Jordan Crouse | f90b811 | 2006-01-06 00:12:14 -0800 | [diff] [blame] | 338 | * NSC and not Cyrix. |
| 339 | * |
| 340 | * This function only handles the GX processor, and kicks every |
| 341 | * thing else to the Cyrix init function above - that should |
| 342 | * cover any processors that might have been branded differently |
Andreas Mohr | d6e05ed | 2006-06-26 18:35:02 +0200 | [diff] [blame] | 343 | * after NSC acquired Cyrix. |
Jordan Crouse | f90b811 | 2006-01-06 00:12:14 -0800 | [diff] [blame] | 344 | * |
| 345 | * If this breaks your GX1 horribly, please e-mail |
| 346 | * info-linux@ldcmail.amd.com to tell us. |
| 347 | */ |
| 348 | |
| 349 | /* Handle the GX (Formally known as the GX2) */ |
| 350 | |
| 351 | if (c->x86 == 5 && c->x86_model == 5) |
| 352 | display_cacheinfo(c); |
| 353 | else |
| 354 | init_cyrix(c); |
| 355 | } |
| 356 | |
| 357 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 358 | * Cyrix CPUs without cpuid or with cpuid not yet enabled can be detected |
| 359 | * by the fact that they preserve the flags across the division of 5/2. |
| 360 | * PII and PPro exhibit this behavior too, but they have cpuid available. |
| 361 | */ |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 362 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 363 | /* |
| 364 | * Perform the Cyrix 5/2 test. A Cyrix won't change |
| 365 | * the flags, while other 486 chips will. |
| 366 | */ |
| 367 | static inline int test_cyrix_52div(void) |
| 368 | { |
| 369 | unsigned int test; |
| 370 | |
| 371 | __asm__ __volatile__( |
| 372 | "sahf\n\t" /* clear flags (%eax = 0x0005) */ |
| 373 | "div %b2\n\t" /* divide 5 by 2 */ |
| 374 | "lahf" /* store flags into %ah */ |
| 375 | : "=a" (test) |
| 376 | : "0" (5), "q" (2) |
| 377 | : "cc"); |
| 378 | |
| 379 | /* AH is 0x02 on Cyrix after the divide.. */ |
| 380 | return (unsigned char) (test >> 8) == 0x02; |
| 381 | } |
| 382 | |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 383 | static void __cpuinit cyrix_identify(struct cpuinfo_x86 *c) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 384 | { |
| 385 | /* Detect Cyrix with disabled CPUID */ |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 386 | if (c->x86 == 4 && test_cyrix_52div()) { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 387 | unsigned char dir0, dir1; |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 388 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 389 | strcpy(c->x86_vendor_id, "CyrixInstead"); |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 390 | c->x86_vendor = X86_VENDOR_CYRIX; |
| 391 | |
| 392 | /* Actually enable cpuid on the older cyrix */ |
| 393 | |
| 394 | /* Retrieve CPU revisions */ |
| 395 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 396 | do_cyrix_devid(&dir0, &dir1); |
| 397 | |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 398 | dir0 >>= 4; |
| 399 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 400 | /* Check it is an affected model */ |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 401 | |
| 402 | if (dir0 == 5 || dir0 == 3) { |
TAKADA Yoshihito | bcde1eb | 2007-02-13 13:26:25 +0100 | [diff] [blame] | 403 | unsigned char ccr3; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 404 | unsigned long flags; |
| 405 | printk(KERN_INFO "Enabling CPUID on Cyrix processor.\n"); |
| 406 | local_irq_save(flags); |
| 407 | ccr3 = getCx86(CX86_CCR3); |
TAKADA Yoshihito | bcde1eb | 2007-02-13 13:26:25 +0100 | [diff] [blame] | 408 | setCx86(CX86_CCR3, (ccr3 & 0x0f) | 0x10); /* enable MAPEN */ |
| 409 | setCx86(CX86_CCR4, getCx86(CX86_CCR4) | 0x80); /* enable cpuid */ |
| 410 | setCx86(CX86_CCR3, ccr3); /* disable MAPEN */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 411 | local_irq_restore(flags); |
| 412 | } |
| 413 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 414 | } |
| 415 | |
Magnus Damm | 9541493 | 2006-09-26 10:52:36 +0200 | [diff] [blame] | 416 | static struct cpu_dev cyrix_cpu_dev __cpuinitdata = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 417 | .c_vendor = "Cyrix", |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 418 | .c_ident = { "CyrixInstead" }, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 419 | .c_init = init_cyrix, |
| 420 | .c_identify = cyrix_identify, |
| 421 | }; |
| 422 | |
Thomas Petazzoni | 03ae576 | 2008-02-15 12:00:23 +0100 | [diff] [blame] | 423 | cpu_vendor_dev_register(X86_VENDOR_CYRIX, &cyrix_cpu_dev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 424 | |
Magnus Damm | 9541493 | 2006-09-26 10:52:36 +0200 | [diff] [blame] | 425 | static struct cpu_dev nsc_cpu_dev __cpuinitdata = { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 426 | .c_vendor = "NSC", |
Paolo Ciarrocchi | adf8526 | 2008-02-22 23:11:23 +0100 | [diff] [blame] | 427 | .c_ident = { "Geode by NSC" }, |
Jordan Crouse | f90b811 | 2006-01-06 00:12:14 -0800 | [diff] [blame] | 428 | .c_init = init_nsc, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 429 | }; |
| 430 | |
Thomas Petazzoni | 03ae576 | 2008-02-15 12:00:23 +0100 | [diff] [blame] | 431 | cpu_vendor_dev_register(X86_VENDOR_NSC, &nsc_cpu_dev); |