This patch unifies the use of config options in v2 to all start with CONFIG_
[coreboot.git] / src / include / cpu / amd / model_fxx_rev.h
1 #include <arch/cpu.h>
2
3 #if CONFIG_K8_REV_F_SUPPORT == 0
4 static inline int is_cpu_rev_a0(void)
5 {
6         return (cpuid_eax(1) & 0xfffef) == 0x0f00;
7 }
8 static inline int is_cpu_pre_c0(void)
9 {
10         return (cpuid_eax(1) & 0xfffef) < 0x0f48;
11 }
12
13 static inline int is_cpu_c0(void)
14 {
15         return (cpuid_eax(1) & 0xfffef) == 0x0f48;
16 }
17
18 static inline int is_cpu_pre_b3(void)
19 {
20         return (cpuid_eax(1) & 0xfffef) < 0x0f41;
21 }
22
23 static inline int is_cpu_b3(void)
24 {
25         return (cpuid_eax(1) & 0xfffef) == 0x0f41;
26 }
27 //AMD_D0_SUPPORT
28 static inline int is_cpu_pre_d0(void)
29 {
30         return (cpuid_eax(1) & 0xfff0f) < 0x10f00;
31 }
32
33 static inline int is_cpu_d0(void)
34 {
35         return (cpuid_eax(1) & 0xfff0f) == 0x10f00;
36 }
37
38 //AMD_E0_SUPPORT
39 static inline int is_cpu_pre_e0(void)
40 {
41         return (cpuid_eax(1) & 0xfff0f) < 0x20f00;
42 }
43
44 static inline int is_cpu_e0(void)
45 {
46         return (cpuid_eax(1) & 0xfff00) == 0x20f00;
47 }
48
49
50 #ifdef __ROMCC__
51 static int is_e0_later_in_bsp(int nodeid)
52 {
53         uint32_t val;
54         uint32_t val_old;
55         int e0_later;
56         if(nodeid==0) { // we don't need to do that for node 0 in core0/node0
57                 return !is_cpu_pre_e0();
58         }
59         // d0 will be treated as e0 with this methods, but the d0 nb_cfg_54 always 0
60         device_t dev;
61         dev = PCI_DEV(0, 0x18+nodeid,2);
62         val_old = pci_read_config32(dev, 0x80);
63         val = val_old;
64         val |= (1<<3);
65         pci_write_config32(dev, 0x80, val);
66         val = pci_read_config32(dev, 0x80);
67         e0_later = !!(val & (1<<3));
68         if(e0_later) { // pre_e0 bit 3 always be 0 and can not be changed
69                 pci_write_config32(dev, 0x80, val_old); // restore it
70         }
71
72         return e0_later;
73 }
74 #else
75 int is_e0_later_in_bsp(int nodeid); //defined model_fxx_init.c
76 #endif
77
78 #endif
79
80 #if CONFIG_K8_REV_F_SUPPORT == 1
81 //AMD_F0_SUPPORT
82 static inline int is_cpu_pre_f0(void)
83 {
84         return (cpuid_eax(1) & 0xfff0f) < 0x40f00;
85 }
86
87 static inline int is_cpu_f0(void)
88 {
89         return (cpuid_eax(1) & 0xfff00) ==  0x40f00;
90 }
91
92 static inline int is_cpu_pre_f2(void)
93 {
94         return (cpuid_eax(1) & 0xfff0f) <  0x40f02;
95 }
96
97 #ifdef __ROMCC__
98 //AMD_F0_SUPPORT
99 static int is_cpu_f0_in_bsp(int nodeid)
100 {
101         uint32_t dword;
102         device_t dev;
103         dev = PCI_DEV(0, 0x18+nodeid, 3);
104         dword = pci_read_config32(dev, 0xfc);
105         return (dword & 0xfff00) == 0x40f00;
106 }
107 static int is_cpu_pre_f2_in_bsp(int nodeid)
108 {
109         uint32_t dword;
110         device_t dev;
111         dev = PCI_DEV(0, 0x18+nodeid, 3);
112         dword = pci_read_config32(dev, 0xfc);
113         return (dword & 0xfff0f) < 0x40f02;
114 }
115 #else
116 int is_cpu_f0_in_bsp(int nodeid); // defined in model_fxx_init.c
117 #endif
118
119 #endif
120