blob: c3b3e222f90eba54600692fadb6a62e3d1b8c25b [file] [log] [blame]
Eric Biedermanc84c1902004-10-14 20:13:01 +00001#ifndef CPU_X86_MTRR_H
2#define CPU_X86_MTRR_H
3
Eric Biedermanc84c1902004-10-14 20:13:01 +00004/* These are the region types */
5#define MTRR_TYPE_UNCACHEABLE 0
6#define MTRR_TYPE_WRCOMB 1
7/*#define MTRR_TYPE_ 2*/
8/*#define MTRR_TYPE_ 3*/
9#define MTRR_TYPE_WRTHROUGH 4
10#define MTRR_TYPE_WRPROT 5
11#define MTRR_TYPE_WRBACK 6
12#define MTRR_NUM_TYPES 7
13
14#define MTRRcap_MSR 0x0fe
15#define MTRRdefType_MSR 0x2ff
16
Uwe Hermann66d16872010-10-01 07:27:51 +000017#define MTRRdefTypeEn (1 << 11)
18#define MTRRdefTypeFixEn (1 << 10)
19
Eric Biedermanc84c1902004-10-14 20:13:01 +000020#define MTRRphysBase_MSR(reg) (0x200 + 2 * (reg))
21#define MTRRphysMask_MSR(reg) (0x200 + 2 * (reg) + 1)
22
Kevin O'Connor5bb9fd62011-01-19 06:32:35 +000023#define MTRRphysMaskValid (1 << 11)
24
Eric Biedermanc84c1902004-10-14 20:13:01 +000025#define NUM_FIXED_RANGES 88
26#define MTRRfix64K_00000_MSR 0x250
27#define MTRRfix16K_80000_MSR 0x258
28#define MTRRfix16K_A0000_MSR 0x259
29#define MTRRfix4K_C0000_MSR 0x268
30#define MTRRfix4K_C8000_MSR 0x269
31#define MTRRfix4K_D0000_MSR 0x26a
32#define MTRRfix4K_D8000_MSR 0x26b
33#define MTRRfix4K_E0000_MSR 0x26c
34#define MTRRfix4K_E8000_MSR 0x26d
35#define MTRRfix4K_F0000_MSR 0x26e
36#define MTRRfix4K_F8000_MSR 0x26f
37
Stefan Reinauer61aee5f2011-04-10 04:15:23 +000038#if !defined (__ASSEMBLER__) && !defined(__PRE_RAM__)
Maciej Pijankaea921852009-10-27 14:29:29 +000039#include <device/device.h>
Maciej Pijankaea921852009-10-27 14:29:29 +000040void enable_fixed_mtrr(void);
Scott Duplichanf3cce2f2010-11-13 19:07:59 +000041void x86_setup_var_mtrrs(unsigned int address_bits, unsigned int above4gb);
Yinghai Lu13f1c2a2005-07-08 02:49:49 +000042void x86_setup_mtrrs(unsigned address_bits);
Eric Biedermanc84c1902004-10-14 20:13:01 +000043int x86_mtrr_check(void);
Maciej Pijankaea921852009-10-27 14:29:29 +000044void set_var_mtrr_resource(void *gp, struct device *dev, struct resource *res);
45void x86_setup_fixed_mtrrs(void);
Stefan Reinauer35b6bbb2010-03-28 21:26:54 +000046#endif
Eric Biedermanc84c1902004-10-14 20:13:01 +000047
Stefan Reinauer8f2c6162010-04-06 21:50:21 +000048#if !defined(CONFIG_RAMTOP)
49# error "CONFIG_RAMTOP not defined"
50#endif
51
Patrick Georgi784544b2011-10-31 17:07:52 +010052#if ((CONFIG_XIP_ROM_SIZE & (CONFIG_XIP_ROM_SIZE -1)) != 0)
Stefan Reinauer8f2c6162010-04-06 21:50:21 +000053# error "CONFIG_XIP_ROM_SIZE is not a power of 2"
54#endif
Stefan Reinauer8f2c6162010-04-06 21:50:21 +000055
Stefan Reinauer1d888a92011-04-21 20:24:43 +000056#if (CONFIG_RAMTOP & (CONFIG_RAMTOP - 1)) != 0
Stefan Reinauer8f2c6162010-04-06 21:50:21 +000057# error "CONFIG_RAMTOP must be a power of 2"
58#endif
59
Eric Biedermanc84c1902004-10-14 20:13:01 +000060#endif /* CPU_X86_MTRR_H */