blob: 5d5e1c134123b7edef8d4e1cf318c253f36401da [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#include <linux/kernel.h>
2#include <linux/init.h>
3#include <linux/string.h>
4#include <asm/processor.h>
5
6#include "cpu.h"
7
8/*
9 * Detect a NexGen CPU running without BIOS hypercode new enough
10 * to have CPUID. (Thanks to Herbert Oppmann)
11 */
Paolo Ciarrocchic99aa382008-02-20 00:18:05 +010012
Magnus Damm5f0f1c12006-09-26 10:52:36 +020013static int __cpuinit deep_magic_nexgen_probe(void)
Linus Torvalds1da177e2005-04-16 15:20:36 -070014{
15 int ret;
Paolo Ciarrocchic99aa382008-02-20 00:18:05 +010016
Linus Torvalds1da177e2005-04-16 15:20:36 -070017 __asm__ __volatile__ (
18 " movw $0x5555, %%ax\n"
19 " xorw %%dx,%%dx\n"
20 " movw $2, %%cx\n"
21 " divw %%cx\n"
22 " movl $0, %%eax\n"
23 " jnz 1f\n"
24 " movl $1, %%eax\n"
Paolo Ciarrocchic99aa382008-02-20 00:18:05 +010025 "1:\n"
26 : "=a" (ret) : : "cx", "dx");
Linus Torvalds1da177e2005-04-16 15:20:36 -070027 return ret;
28}
29
Paolo Ciarrocchic99aa382008-02-20 00:18:05 +010030static void __cpuinit init_nexgen(struct cpuinfo_x86 *c)
Linus Torvalds1da177e2005-04-16 15:20:36 -070031{
32 c->x86_cache_size = 256; /* A few had 1 MB... */
33}
34
Paolo Ciarrocchic99aa382008-02-20 00:18:05 +010035static void __cpuinit nexgen_identify(struct cpuinfo_x86 *c)
Linus Torvalds1da177e2005-04-16 15:20:36 -070036{
37 /* Detect NexGen with old hypercode */
Paolo Ciarrocchic99aa382008-02-20 00:18:05 +010038 if (deep_magic_nexgen_probe())
Linus Torvalds1da177e2005-04-16 15:20:36 -070039 strcpy(c->x86_vendor_id, "NexGenDriven");
Linus Torvalds1da177e2005-04-16 15:20:36 -070040}
41
Magnus Damm95414932006-09-26 10:52:36 +020042static struct cpu_dev nexgen_cpu_dev __cpuinitdata = {
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 .c_vendor = "Nexgen",
44 .c_ident = { "NexGenDriven" },
45 .c_models = {
46 { .vendor = X86_VENDOR_NEXGEN,
47 .family = 5,
48 .model_names = { [1] = "Nx586" }
49 },
50 },
51 .c_init = init_nexgen,
52 .c_identify = nexgen_identify,
53};
54
55int __init nexgen_init_cpu(void)
56{
57 cpu_devs[X86_VENDOR_NEXGEN] = &nexgen_cpu_dev;
58 return 0;
59}