2009-03-14 05:24:02 -06:00
|
|
|
#include <linux/bitops.h>
|
2005-04-16 16:20:36 -06:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/init.h>
|
2008-02-17 19:30:47 -07:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
#include <asm/processor.h>
|
|
|
|
#include <asm/e820.h>
|
2006-03-23 03:59:50 -07:00
|
|
|
#include <asm/mtrr.h>
|
2009-03-14 05:24:02 -06:00
|
|
|
#include <asm/msr.h>
|
2008-02-17 19:30:47 -07:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
#include "cpu.h"
|
|
|
|
|
|
|
|
#ifdef CONFIG_X86_OOSTORE
|
|
|
|
|
2006-09-26 02:52:36 -06:00
|
|
|
static u32 __cpuinit power2(u32 x)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2008-02-17 15:30:23 -07:00
|
|
|
u32 s = 1;
|
2008-02-17 19:30:47 -07:00
|
|
|
|
|
|
|
while (s <= x)
|
2008-02-17 15:30:23 -07:00
|
|
|
s <<= 1;
|
2008-02-17 19:30:47 -07:00
|
|
|
|
2008-02-17 15:30:23 -07:00
|
|
|
return s >>= 1;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
2008-02-17 19:30:47 -07:00
|
|
|
* Set up an actual MCR
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
2006-09-26 02:52:36 -06:00
|
|
|
static void __cpuinit centaur_mcr_insert(int reg, u32 base, u32 size, int key)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
u32 lo, hi;
|
2008-02-17 15:30:23 -07:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
hi = base & ~0xFFF;
|
|
|
|
lo = ~(size-1); /* Size is a power of 2 so this makes a mask */
|
|
|
|
lo &= ~0xFFF; /* Remove the ctrl value bits */
|
|
|
|
lo |= key; /* Attribute we wish to set */
|
|
|
|
wrmsr(reg+MSR_IDT_MCR0, lo, hi);
|
|
|
|
mtrr_centaur_report_mcr(reg, lo, hi); /* Tell the mtrr driver */
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2008-02-17 19:30:47 -07:00
|
|
|
* Figure what we can cover with MCR's
|
2005-04-16 16:20:36 -06:00
|
|
|
*
|
2008-02-17 19:30:47 -07:00
|
|
|
* Shortcut: We know you can't put 4Gig of RAM on a winchip
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
2008-02-17 19:30:47 -07:00
|
|
|
static u32 __cpuinit ramtop(void)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
u32 clip = 0xFFFFFFFFUL;
|
2008-02-17 19:30:47 -07:00
|
|
|
u32 top = 0;
|
|
|
|
int i;
|
2008-02-17 15:30:23 -07:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
for (i = 0; i < e820.nr_map; i++) {
|
|
|
|
unsigned long start, end;
|
|
|
|
|
|
|
|
if (e820.map[i].addr > 0xFFFFFFFFUL)
|
|
|
|
continue;
|
|
|
|
/*
|
2008-02-17 19:30:47 -07:00
|
|
|
* Don't MCR over reserved space. Ignore the ISA hole
|
|
|
|
* we frob around that catastrophe already
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
2008-02-17 19:30:47 -07:00
|
|
|
if (e820.map[i].type == E820_RESERVED) {
|
|
|
|
if (e820.map[i].addr >= 0x100000UL &&
|
|
|
|
e820.map[i].addr < clip)
|
2005-04-16 16:20:36 -06:00
|
|
|
clip = e820.map[i].addr;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
start = e820.map[i].addr;
|
|
|
|
end = e820.map[i].addr + e820.map[i].size;
|
|
|
|
if (start >= end)
|
|
|
|
continue;
|
|
|
|
if (end > top)
|
|
|
|
top = end;
|
|
|
|
}
|
2008-02-17 19:30:47 -07:00
|
|
|
/*
|
|
|
|
* Everything below 'top' should be RAM except for the ISA hole.
|
|
|
|
* Because of the limited MCR's we want to map NV/ACPI into our
|
|
|
|
* MCR range for gunk in RAM
|
|
|
|
*
|
|
|
|
* Clip might cause us to MCR insufficient RAM but that is an
|
|
|
|
* acceptable failure mode and should only bite obscure boxes with
|
|
|
|
* a VESA hole at 15Mb
|
|
|
|
*
|
|
|
|
* The second case Clip sometimes kicks in is when the EBDA is marked
|
|
|
|
* as reserved. Again we fail safe with reasonable results
|
|
|
|
*/
|
|
|
|
if (top > clip)
|
2008-02-17 15:30:23 -07:00
|
|
|
top = clip;
|
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
return top;
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2008-02-17 19:30:47 -07:00
|
|
|
* Compute a set of MCR's to give maximum coverage
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
2006-09-26 02:52:36 -06:00
|
|
|
static int __cpuinit centaur_mcr_compute(int nr, int key)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
u32 mem = ramtop();
|
|
|
|
u32 root = power2(mem);
|
|
|
|
u32 base = root;
|
|
|
|
u32 top = root;
|
|
|
|
u32 floor = 0;
|
|
|
|
int ct = 0;
|
2008-02-17 15:30:23 -07:00
|
|
|
|
2008-02-17 19:30:47 -07:00
|
|
|
while (ct < nr) {
|
2005-04-16 16:20:36 -06:00
|
|
|
u32 fspace = 0;
|
2008-02-17 19:30:47 -07:00
|
|
|
u32 high;
|
|
|
|
u32 low;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/*
|
2008-02-17 19:30:47 -07:00
|
|
|
* Find the largest block we will fill going upwards
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
2008-02-17 19:30:47 -07:00
|
|
|
high = power2(mem-top);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/*
|
2008-02-17 19:30:47 -07:00
|
|
|
* Find the largest block we will fill going downwards
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
2008-02-17 19:30:47 -07:00
|
|
|
low = base/2;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/*
|
2008-02-17 19:30:47 -07:00
|
|
|
* Don't fill below 1Mb going downwards as there
|
|
|
|
* is an ISA hole in the way.
|
2008-02-17 15:30:23 -07:00
|
|
|
*/
|
|
|
|
if (base <= 1024*1024)
|
2005-04-16 16:20:36 -06:00
|
|
|
low = 0;
|
2008-02-17 15:30:23 -07:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
2008-02-17 19:30:47 -07:00
|
|
|
* See how much space we could cover by filling below
|
|
|
|
* the ISA hole
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
2008-02-17 15:30:23 -07:00
|
|
|
|
|
|
|
if (floor == 0)
|
2005-04-16 16:20:36 -06:00
|
|
|
fspace = 512*1024;
|
2008-02-17 15:30:23 -07:00
|
|
|
else if (floor == 512*1024)
|
2005-04-16 16:20:36 -06:00
|
|
|
fspace = 128*1024;
|
|
|
|
|
|
|
|
/* And forget ROM space */
|
2008-02-17 15:30:23 -07:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
2008-02-17 19:30:47 -07:00
|
|
|
* Now install the largest coverage we get
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
2008-02-17 19:30:47 -07:00
|
|
|
if (fspace > high && fspace > low) {
|
2005-04-16 16:20:36 -06:00
|
|
|
centaur_mcr_insert(ct, floor, fspace, key);
|
|
|
|
floor += fspace;
|
2008-02-17 19:30:47 -07:00
|
|
|
} else if (high > low) {
|
2005-04-16 16:20:36 -06:00
|
|
|
centaur_mcr_insert(ct, top, high, key);
|
|
|
|
top += high;
|
2008-02-17 19:30:47 -07:00
|
|
|
} else if (low > 0) {
|
2005-04-16 16:20:36 -06:00
|
|
|
base -= low;
|
|
|
|
centaur_mcr_insert(ct, base, low, key);
|
2008-02-17 19:30:47 -07:00
|
|
|
} else
|
|
|
|
break;
|
2005-04-16 16:20:36 -06:00
|
|
|
ct++;
|
|
|
|
}
|
|
|
|
/*
|
2008-02-17 19:30:47 -07:00
|
|
|
* We loaded ct values. We now need to set the mask. The caller
|
|
|
|
* must do this bit.
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
|
|
|
return ct;
|
|
|
|
}
|
|
|
|
|
2006-09-26 02:52:36 -06:00
|
|
|
static void __cpuinit centaur_create_optimal_mcr(void)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2008-02-17 19:30:47 -07:00
|
|
|
int used;
|
2005-04-16 16:20:36 -06:00
|
|
|
int i;
|
2008-02-17 19:30:47 -07:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
2008-02-17 19:30:47 -07:00
|
|
|
* Allocate up to 6 mcrs to mark as much of ram as possible
|
|
|
|
* as write combining and weak write ordered.
|
2005-04-16 16:20:36 -06:00
|
|
|
*
|
2008-02-17 19:30:47 -07:00
|
|
|
* To experiment with: Linux never uses stack operations for
|
|
|
|
* mmio spaces so we could globally enable stack operation wc
|
2005-04-16 16:20:36 -06:00
|
|
|
*
|
2008-02-17 19:30:47 -07:00
|
|
|
* Load the registers with type 31 - full write combining, all
|
|
|
|
* writes weakly ordered.
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
2008-02-17 19:30:47 -07:00
|
|
|
used = centaur_mcr_compute(6, 31);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
|
|
|
/*
|
2008-02-17 19:30:47 -07:00
|
|
|
* Wipe unused MCRs
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
2008-02-17 15:30:23 -07:00
|
|
|
for (i = used; i < 8; i++)
|
2005-04-16 16:20:36 -06:00
|
|
|
wrmsr(MSR_IDT_MCR0+i, 0, 0);
|
|
|
|
}
|
|
|
|
|
2006-09-26 02:52:36 -06:00
|
|
|
static void __cpuinit winchip2_create_optimal_mcr(void)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
u32 lo, hi;
|
2008-02-17 19:30:47 -07:00
|
|
|
int used;
|
2005-04-16 16:20:36 -06:00
|
|
|
int i;
|
|
|
|
|
|
|
|
/*
|
2008-02-17 19:30:47 -07:00
|
|
|
* Allocate up to 6 mcrs to mark as much of ram as possible
|
|
|
|
* as write combining, weak store ordered.
|
2005-04-16 16:20:36 -06:00
|
|
|
*
|
2008-02-17 19:30:47 -07:00
|
|
|
* Load the registers with type 25
|
|
|
|
* 8 - weak write ordering
|
|
|
|
* 16 - weak read ordering
|
|
|
|
* 1 - write combining
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
2008-02-17 19:30:47 -07:00
|
|
|
used = centaur_mcr_compute(6, 25);
|
2008-02-17 15:30:23 -07:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
2008-02-17 19:30:47 -07:00
|
|
|
* Mark the registers we are using.
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
|
|
|
rdmsr(MSR_IDT_MCR_CTRL, lo, hi);
|
2008-02-17 15:30:23 -07:00
|
|
|
for (i = 0; i < used; i++)
|
|
|
|
lo |= 1<<(9+i);
|
2005-04-16 16:20:36 -06:00
|
|
|
wrmsr(MSR_IDT_MCR_CTRL, lo, hi);
|
2008-02-17 15:30:23 -07:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
/*
|
2008-02-17 19:30:47 -07:00
|
|
|
* Wipe unused MCRs
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
2008-02-17 15:30:23 -07:00
|
|
|
|
|
|
|
for (i = used; i < 8; i++)
|
2005-04-16 16:20:36 -06:00
|
|
|
wrmsr(MSR_IDT_MCR0+i, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
2008-02-17 19:30:47 -07:00
|
|
|
* Handle the MCR key on the Winchip 2.
|
2005-04-16 16:20:36 -06:00
|
|
|
*/
|
2006-09-26 02:52:36 -06:00
|
|
|
static void __cpuinit winchip2_unprotect_mcr(void)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
u32 lo, hi;
|
|
|
|
u32 key;
|
2008-02-17 15:30:23 -07:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
rdmsr(MSR_IDT_MCR_CTRL, lo, hi);
|
2008-02-17 15:30:23 -07:00
|
|
|
lo &= ~0x1C0; /* blank bits 8-6 */
|
2005-04-16 16:20:36 -06:00
|
|
|
key = (lo>>17) & 7;
|
|
|
|
lo |= key<<6; /* replace with unlock key */
|
|
|
|
wrmsr(MSR_IDT_MCR_CTRL, lo, hi);
|
|
|
|
}
|
|
|
|
|
2006-09-26 02:52:36 -06:00
|
|
|
static void __cpuinit winchip2_protect_mcr(void)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
u32 lo, hi;
|
2008-02-17 15:30:23 -07:00
|
|
|
|
2005-04-16 16:20:36 -06:00
|
|
|
rdmsr(MSR_IDT_MCR_CTRL, lo, hi);
|
2008-02-17 15:30:23 -07:00
|
|
|
lo &= ~0x1C0; /* blank bits 8-6 */
|
2005-04-16 16:20:36 -06:00
|
|
|
wrmsr(MSR_IDT_MCR_CTRL, lo, hi);
|
|
|
|
}
|
|
|
|
#endif /* CONFIG_X86_OOSTORE */
|
|
|
|
|
|
|
|
#define ACE_PRESENT (1 << 6)
|
|
|
|
#define ACE_ENABLED (1 << 7)
|
|
|
|
#define ACE_FCR (1 << 28) /* MSR_VIA_FCR */
|
|
|
|
|
|
|
|
#define RNG_PRESENT (1 << 2)
|
|
|
|
#define RNG_ENABLED (1 << 3)
|
|
|
|
#define RNG_ENABLE (1 << 6) /* MSR_VIA_RNG */
|
|
|
|
|
2006-09-26 02:52:36 -06:00
|
|
|
static void __cpuinit init_c3(struct cpuinfo_x86 *c)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
|
|
|
u32 lo, hi;
|
|
|
|
|
|
|
|
/* Test for Centaur Extended Feature Flags presence */
|
|
|
|
if (cpuid_eax(0xC0000000) >= 0xC0000001) {
|
|
|
|
u32 tmp = cpuid_edx(0xC0000001);
|
|
|
|
|
|
|
|
/* enable ACE unit, if present and disabled */
|
|
|
|
if ((tmp & (ACE_PRESENT | ACE_ENABLED)) == ACE_PRESENT) {
|
2008-02-17 15:30:23 -07:00
|
|
|
rdmsr(MSR_VIA_FCR, lo, hi);
|
2005-04-16 16:20:36 -06:00
|
|
|
lo |= ACE_FCR; /* enable ACE unit */
|
2008-02-17 15:30:23 -07:00
|
|
|
wrmsr(MSR_VIA_FCR, lo, hi);
|
2005-04-16 16:20:36 -06:00
|
|
|
printk(KERN_INFO "CPU: Enabled ACE h/w crypto\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* enable RNG unit, if present and disabled */
|
|
|
|
if ((tmp & (RNG_PRESENT | RNG_ENABLED)) == RNG_PRESENT) {
|
2008-02-17 15:30:23 -07:00
|
|
|
rdmsr(MSR_VIA_RNG, lo, hi);
|
2005-04-16 16:20:36 -06:00
|
|
|
lo |= RNG_ENABLE; /* enable RNG unit */
|
2008-02-17 15:30:23 -07:00
|
|
|
wrmsr(MSR_VIA_RNG, lo, hi);
|
2005-04-16 16:20:36 -06:00
|
|
|
printk(KERN_INFO "CPU: Enabled h/w RNG\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
/* store Centaur Extended Feature Flags as
|
|
|
|
* word 5 of the CPU capability bit array
|
|
|
|
*/
|
|
|
|
c->x86_capability[5] = cpuid_edx(0xC0000001);
|
|
|
|
}
|
2009-03-14 05:24:02 -06:00
|
|
|
#ifdef CONFIG_X86_32
|
2007-10-19 17:13:56 -06:00
|
|
|
/* Cyrix III family needs CX8 & PGE explicitly enabled. */
|
2011-12-15 08:11:28 -07:00
|
|
|
if (c->x86_model >= 6 && c->x86_model <= 13) {
|
2008-02-17 15:30:23 -07:00
|
|
|
rdmsr(MSR_VIA_FCR, lo, hi);
|
2005-04-16 16:20:36 -06:00
|
|
|
lo |= (1<<1 | 1<<7);
|
2008-02-17 15:30:23 -07:00
|
|
|
wrmsr(MSR_VIA_FCR, lo, hi);
|
2008-02-26 00:51:22 -07:00
|
|
|
set_cpu_cap(c, X86_FEATURE_CX8);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
|
|
|
/* Before Nehemiah, the C3's had 3dNOW! */
|
2008-02-17 15:30:23 -07:00
|
|
|
if (c->x86_model >= 6 && c->x86_model < 9)
|
2008-02-26 00:51:22 -07:00
|
|
|
set_cpu_cap(c, X86_FEATURE_3DNOW);
|
2009-03-14 05:24:02 -06:00
|
|
|
#endif
|
|
|
|
if (c->x86 == 0x6 && c->x86_model >= 0xf) {
|
|
|
|
c->x86_cache_alignment = c->x86_clflush_size * 2;
|
|
|
|
set_cpu_cap(c, X86_FEATURE_REP_GOOD);
|
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2009-11-21 06:01:45 -07:00
|
|
|
cpu_detect_cache_sizes(c);
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2008-02-17 19:30:47 -07:00
|
|
|
enum {
|
|
|
|
ECX8 = 1<<1,
|
|
|
|
EIERRINT = 1<<2,
|
|
|
|
DPM = 1<<3,
|
|
|
|
DMCE = 1<<4,
|
|
|
|
DSTPCLK = 1<<5,
|
|
|
|
ELINEAR = 1<<6,
|
|
|
|
DSMC = 1<<7,
|
|
|
|
DTLOCK = 1<<8,
|
|
|
|
EDCTLB = 1<<8,
|
|
|
|
EMMX = 1<<9,
|
|
|
|
DPDC = 1<<11,
|
|
|
|
EBRPRED = 1<<12,
|
|
|
|
DIC = 1<<13,
|
|
|
|
DDC = 1<<14,
|
|
|
|
DNA = 1<<15,
|
|
|
|
ERETSTK = 1<<16,
|
|
|
|
E2MMX = 1<<19,
|
|
|
|
EAMD3D = 1<<20,
|
|
|
|
};
|
|
|
|
|
2008-09-04 13:09:43 -06:00
|
|
|
static void __cpuinit early_init_centaur(struct cpuinfo_x86 *c)
|
|
|
|
{
|
|
|
|
switch (c->x86) {
|
2009-03-14 05:24:02 -06:00
|
|
|
#ifdef CONFIG_X86_32
|
2008-09-04 13:09:43 -06:00
|
|
|
case 5:
|
|
|
|
/* Emulate MTRRs using Centaur's MCR. */
|
|
|
|
set_cpu_cap(c, X86_FEATURE_CENTAUR_MCR);
|
|
|
|
break;
|
2009-03-14 05:24:02 -06:00
|
|
|
#endif
|
|
|
|
case 6:
|
|
|
|
if (c->x86_model >= 0xf)
|
|
|
|
set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
|
|
|
|
break;
|
2008-09-04 13:09:43 -06:00
|
|
|
}
|
2009-03-14 05:24:02 -06:00
|
|
|
#ifdef CONFIG_X86_64
|
|
|
|
set_cpu_cap(c, X86_FEATURE_SYSENTER32);
|
|
|
|
#endif
|
2008-09-04 13:09:43 -06:00
|
|
|
}
|
|
|
|
|
2006-09-26 02:52:36 -06:00
|
|
|
static void __cpuinit init_centaur(struct cpuinfo_x86 *c)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2009-03-14 05:24:02 -06:00
|
|
|
#ifdef CONFIG_X86_32
|
2005-04-16 16:20:36 -06:00
|
|
|
char *name;
|
2008-02-17 15:30:23 -07:00
|
|
|
u32 fcr_set = 0;
|
|
|
|
u32 fcr_clr = 0;
|
|
|
|
u32 lo, hi, newlo;
|
|
|
|
u32 aa, bb, cc, dd;
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2008-02-17 19:30:47 -07:00
|
|
|
/*
|
|
|
|
* Bit 31 in normal CPUID used for nonstandard 3DNow ID;
|
|
|
|
* 3DNow is IDd by bit 31 in extended CPUID (1*32+31) anyway
|
|
|
|
*/
|
2008-02-26 00:51:22 -07:00
|
|
|
clear_cpu_cap(c, 0*32+31);
|
2009-03-14 05:24:02 -06:00
|
|
|
#endif
|
|
|
|
early_init_centaur(c);
|
2005-04-16 16:20:36 -06:00
|
|
|
switch (c->x86) {
|
2009-03-14 05:24:02 -06:00
|
|
|
#ifdef CONFIG_X86_32
|
2008-02-17 15:30:23 -07:00
|
|
|
case 5:
|
2008-02-17 19:30:47 -07:00
|
|
|
switch (c->x86_model) {
|
|
|
|
case 4:
|
|
|
|
name = "C6";
|
|
|
|
fcr_set = ECX8|DSMC|EDCTLB|EMMX|ERETSTK;
|
|
|
|
fcr_clr = DPDC;
|
|
|
|
printk(KERN_NOTICE "Disabling bugged TSC.\n");
|
2008-02-26 00:51:22 -07:00
|
|
|
clear_cpu_cap(c, X86_FEATURE_TSC);
|
2005-04-16 16:20:36 -06:00
|
|
|
#ifdef CONFIG_X86_OOSTORE
|
2008-02-17 19:30:47 -07:00
|
|
|
centaur_create_optimal_mcr();
|
|
|
|
/*
|
|
|
|
* Enable:
|
|
|
|
* write combining on non-stack, non-string
|
|
|
|
* write combining on string, all types
|
|
|
|
* weak write ordering
|
|
|
|
*
|
|
|
|
* The C6 original lacks weak read order
|
|
|
|
*
|
|
|
|
* Note 0x120 is write only on Winchip 1
|
|
|
|
*/
|
|
|
|
wrmsr(MSR_IDT_MCR_CTRL, 0x01F0001F, 0);
|
2008-02-17 15:30:23 -07:00
|
|
|
#endif
|
2008-02-17 19:30:47 -07:00
|
|
|
break;
|
|
|
|
case 8:
|
|
|
|
switch (c->x86_mask) {
|
|
|
|
default:
|
|
|
|
name = "2";
|
2005-04-16 16:20:36 -06:00
|
|
|
break;
|
2008-02-17 19:30:47 -07:00
|
|
|
case 7 ... 9:
|
|
|
|
name = "2A";
|
|
|
|
break;
|
|
|
|
case 10 ... 15:
|
|
|
|
name = "2B";
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
fcr_set = ECX8|DSMC|DTLOCK|EMMX|EBRPRED|ERETSTK|
|
|
|
|
E2MMX|EAMD3D;
|
|
|
|
fcr_clr = DPDC;
|
2005-04-16 16:20:36 -06:00
|
|
|
#ifdef CONFIG_X86_OOSTORE
|
2008-02-17 19:30:47 -07:00
|
|
|
winchip2_unprotect_mcr();
|
|
|
|
winchip2_create_optimal_mcr();
|
|
|
|
rdmsr(MSR_IDT_MCR_CTRL, lo, hi);
|
|
|
|
/*
|
|
|
|
* Enable:
|
|
|
|
* write combining on non-stack, non-string
|
|
|
|
* write combining on string, all types
|
|
|
|
* weak write ordering
|
|
|
|
*/
|
|
|
|
lo |= 31;
|
|
|
|
wrmsr(MSR_IDT_MCR_CTRL, lo, hi);
|
|
|
|
winchip2_protect_mcr();
|
2005-04-16 16:20:36 -06:00
|
|
|
#endif
|
2008-02-17 19:30:47 -07:00
|
|
|
break;
|
|
|
|
case 9:
|
|
|
|
name = "3";
|
|
|
|
fcr_set = ECX8|DSMC|DTLOCK|EMMX|EBRPRED|ERETSTK|
|
|
|
|
E2MMX|EAMD3D;
|
|
|
|
fcr_clr = DPDC;
|
2005-04-16 16:20:36 -06:00
|
|
|
#ifdef CONFIG_X86_OOSTORE
|
2008-02-17 19:30:47 -07:00
|
|
|
winchip2_unprotect_mcr();
|
|
|
|
winchip2_create_optimal_mcr();
|
|
|
|
rdmsr(MSR_IDT_MCR_CTRL, lo, hi);
|
|
|
|
/*
|
|
|
|
* Enable:
|
|
|
|
* write combining on non-stack, non-string
|
|
|
|
* write combining on string, all types
|
|
|
|
* weak write ordering
|
|
|
|
*/
|
|
|
|
lo |= 31;
|
|
|
|
wrmsr(MSR_IDT_MCR_CTRL, lo, hi);
|
|
|
|
winchip2_protect_mcr();
|
2005-04-16 16:20:36 -06:00
|
|
|
#endif
|
2008-02-17 19:30:47 -07:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
name = "??";
|
|
|
|
}
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2008-02-17 19:30:47 -07:00
|
|
|
rdmsr(MSR_IDT_FCR1, lo, hi);
|
|
|
|
newlo = (lo|fcr_set) & (~fcr_clr);
|
2005-04-16 16:20:36 -06:00
|
|
|
|
2008-02-17 19:30:47 -07:00
|
|
|
if (newlo != lo) {
|
|
|
|
printk(KERN_INFO "Centaur FCR was 0x%X now 0x%X\n",
|
|
|
|
lo, newlo);
|
|
|
|
wrmsr(MSR_IDT_FCR1, newlo, hi);
|
|
|
|
} else {
|
|
|
|
printk(KERN_INFO "Centaur FCR is 0x%X\n", lo);
|
|
|
|
}
|
|
|
|
/* Emulate MTRRs using Centaur's MCR. */
|
2008-02-26 00:51:22 -07:00
|
|
|
set_cpu_cap(c, X86_FEATURE_CENTAUR_MCR);
|
2008-02-17 19:30:47 -07:00
|
|
|
/* Report CX8 */
|
2008-02-26 00:51:22 -07:00
|
|
|
set_cpu_cap(c, X86_FEATURE_CX8);
|
2008-02-17 19:30:47 -07:00
|
|
|
/* Set 3DNow! on Winchip 2 and above. */
|
|
|
|
if (c->x86_model >= 8)
|
2008-02-26 00:51:22 -07:00
|
|
|
set_cpu_cap(c, X86_FEATURE_3DNOW);
|
2008-02-17 19:30:47 -07:00
|
|
|
/* See if we can find out some more. */
|
|
|
|
if (cpuid_eax(0x80000000) >= 0x80000005) {
|
|
|
|
/* Yes, we can. */
|
|
|
|
cpuid(0x80000005, &aa, &bb, &cc, &dd);
|
|
|
|
/* Add L1 data and code cache sizes. */
|
|
|
|
c->x86_cache_size = (cc>>24)+(dd>>24);
|
|
|
|
}
|
|
|
|
sprintf(c->x86_model_id, "WinChip %s", name);
|
|
|
|
break;
|
2009-03-14 05:24:02 -06:00
|
|
|
#endif
|
2008-02-17 15:30:23 -07:00
|
|
|
case 6:
|
2008-02-17 19:30:47 -07:00
|
|
|
init_c3(c);
|
|
|
|
break;
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
2009-03-14 05:24:02 -06:00
|
|
|
#ifdef CONFIG_X86_64
|
|
|
|
set_cpu_cap(c, X86_FEATURE_LFENCE_RDTSC);
|
|
|
|
#endif
|
2005-04-16 16:20:36 -06:00
|
|
|
}
|
|
|
|
|
2008-02-17 19:30:47 -07:00
|
|
|
static unsigned int __cpuinit
|
|
|
|
centaur_size_cache(struct cpuinfo_x86 *c, unsigned int size)
|
2005-04-16 16:20:36 -06:00
|
|
|
{
|
2009-03-14 05:24:02 -06:00
|
|
|
#ifdef CONFIG_X86_32
|
2005-04-16 16:20:36 -06:00
|
|
|
/* VIA C3 CPUs (670-68F) need further shifting. */
|
|
|
|
if ((c->x86 == 6) && ((c->x86_model == 7) || (c->x86_model == 8)))
|
|
|
|
size >>= 8;
|
|
|
|
|
2008-02-17 19:30:47 -07:00
|
|
|
/*
|
|
|
|
* There's also an erratum in Nehemiah stepping 1, which
|
|
|
|
* returns '65KB' instead of '64KB'
|
|
|
|
* - Note, it seems this may only be in engineering samples.
|
|
|
|
*/
|
|
|
|
if ((c->x86 == 6) && (c->x86_model == 9) &&
|
|
|
|
(c->x86_mask == 1) && (size == 65))
|
2008-02-17 15:30:23 -07:00
|
|
|
size -= 1;
|
2009-03-14 05:24:02 -06:00
|
|
|
#endif
|
2005-04-16 16:20:36 -06:00
|
|
|
return size;
|
|
|
|
}
|
|
|
|
|
2009-03-12 06:08:49 -06:00
|
|
|
static const struct cpu_dev __cpuinitconst centaur_cpu_dev = {
|
2005-04-16 16:20:36 -06:00
|
|
|
.c_vendor = "Centaur",
|
|
|
|
.c_ident = { "CentaurHauls" },
|
2008-09-04 13:09:43 -06:00
|
|
|
.c_early_init = early_init_centaur,
|
2005-04-16 16:20:36 -06:00
|
|
|
.c_init = init_centaur,
|
|
|
|
.c_size_cache = centaur_size_cache,
|
2008-09-04 13:09:45 -06:00
|
|
|
.c_x86_vendor = X86_VENDOR_CENTAUR,
|
2005-04-16 16:20:36 -06:00
|
|
|
};
|
|
|
|
|
2008-09-04 13:09:45 -06:00
|
|
|
cpu_dev_register(centaur_cpu_dev);
|