1 #include <linux/init.h>
14 static u8 centaur_mcr_reserved
;
15 static u8 centaur_mcr_type
; /* 0 for winchip, 1 for winchip2 */
18 * centaur_get_free_region - Get a free MTRR.
20 * @base: The starting (base) address of the region.
21 * @size: The size (in bytes) of the region.
23 * Returns: the index of the region on success, else -1 on error.
26 centaur_get_free_region(unsigned long base
, unsigned long size
, int replace_reg
)
28 unsigned long lbase
, lsize
;
33 if (replace_reg
>= 0 && replace_reg
< max
)
36 for (i
= 0; i
< max
; ++i
) {
37 if (centaur_mcr_reserved
& (1 << i
))
39 mtrr_if
->get(i
, &lbase
, &lsize
, <ype
);
48 * Report boot time MCR setups
50 void mtrr_centaur_report_mcr(int mcr
, u32 lo
, u32 hi
)
52 centaur_mcr
[mcr
].low
= lo
;
53 centaur_mcr
[mcr
].high
= hi
;
57 centaur_get_mcr(unsigned int reg
, unsigned long *base
,
58 unsigned long *size
, mtrr_type
* type
)
60 *base
= centaur_mcr
[reg
].high
>> PAGE_SHIFT
;
61 *size
= -(centaur_mcr
[reg
].low
& 0xfffff000) >> PAGE_SHIFT
;
62 *type
= MTRR_TYPE_WRCOMB
; /* write-combining */
64 if (centaur_mcr_type
== 1 && ((centaur_mcr
[reg
].low
& 31) & 2))
65 *type
= MTRR_TYPE_UNCACHABLE
;
66 if (centaur_mcr_type
== 1 && (centaur_mcr
[reg
].low
& 31) == 25)
67 *type
= MTRR_TYPE_WRBACK
;
68 if (centaur_mcr_type
== 0 && (centaur_mcr
[reg
].low
& 31) == 31)
69 *type
= MTRR_TYPE_WRBACK
;
73 centaur_set_mcr(unsigned int reg
, unsigned long base
,
74 unsigned long size
, mtrr_type type
)
76 unsigned long low
, high
;
82 high
= base
<< PAGE_SHIFT
;
83 if (centaur_mcr_type
== 0) {
84 /* Only support write-combining... */
85 low
= -size
<< PAGE_SHIFT
| 0x1f;
87 if (type
== MTRR_TYPE_UNCACHABLE
)
88 low
= -size
<< PAGE_SHIFT
| 0x02; /* NC */
90 low
= -size
<< PAGE_SHIFT
| 0x09; /* WWO, WC */
93 centaur_mcr
[reg
].high
= high
;
94 centaur_mcr
[reg
].low
= low
;
95 wrmsr(MSR_IDT_MCR0
+ reg
, low
, high
);
99 centaur_validate_add_page(unsigned long base
, unsigned long size
, unsigned int type
)
102 * FIXME: Winchip2 supports uncached
104 if (type
!= MTRR_TYPE_WRCOMB
&&
105 (centaur_mcr_type
== 0 || type
!= MTRR_TYPE_UNCACHABLE
)) {
106 pr_warning("mtrr: only write-combining%s supported\n",
107 centaur_mcr_type
? " and uncacheable are" : " is");
113 static const struct mtrr_ops centaur_mtrr_ops
= {
114 .vendor
= X86_VENDOR_CENTAUR
,
115 .set
= centaur_set_mcr
,
116 .get
= centaur_get_mcr
,
117 .get_free_region
= centaur_get_free_region
,
118 .validate_add_page
= centaur_validate_add_page
,
119 .have_wrcomb
= positive_have_wrcomb
,
122 int __init
centaur_init_mtrr(void)
124 set_mtrr_ops(¢aur_mtrr_ops
);