summaryrefslogtreecommitdiff
path: root/src/include/cpu/amd/model_fxx_rev.h
blob: 7640f6711a0c8206cf76d7688cb63f6dbb415b1e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include <arch/cpu.h>

int init_processor_name(void);

static inline int is_cpu_rev_a0(void)
{
	return (cpuid_eax(1) & 0xfffef) == 0x0f00;
}
static inline int is_cpu_pre_c0(void)
{
	return (cpuid_eax(1) & 0xfffef) < 0x0f48;
}

static inline int is_cpu_c0(void)
{
	return (cpuid_eax(1) & 0xfffef) == 0x0f48;
}

static inline int is_cpu_pre_b3(void)
{
	return (cpuid_eax(1) & 0xfffef) < 0x0f41;
}

static inline int is_cpu_b3(void)
{
	return (cpuid_eax(1) & 0xfffef) == 0x0f41;
}
//AMD_D0_SUPPORT
static inline int is_cpu_pre_d0(void)
{
	return (cpuid_eax(1) & 0xfff0f) < 0x10f00;
}

static inline int is_cpu_d0(void)
{
	return (cpuid_eax(1) & 0xfff0f) == 0x10f00;
}

//AMD_E0_SUPPORT
static inline int is_cpu_pre_e0(void)
{
	return (cpuid_eax(1) & 0xfff0f) < 0x20f00;
}

static inline int is_cpu_e0(void)
{
	return (cpuid_eax(1) & 0xfff00) == 0x20f00;
}

//AMD_F0_SUPPORT
static inline int is_cpu_pre_f0(void)
{
	return (cpuid_eax(1) & 0xfff0f) < 0x40f00;
}

static inline int is_cpu_f0(void)
{
	return (cpuid_eax(1) & 0xfff00) ==  0x40f00;
}

static inline int is_cpu_pre_f2(void)
{
	return (cpuid_eax(1) & 0xfff0f) <  0x40f02;
}

#ifdef __PRE_RAM__
static inline int is_e0_later_in_bsp(int nodeid)
{
	uint32_t val;
	uint32_t val_old;
	int e0_later;

	if (IS_ENABLED(CONFIG_K8_REV_F_SUPPORT))
		return 1;

	// we don't need to do that for node 0 in core0/node0
	if (nodeid == 0)
		return !is_cpu_pre_e0();

	// d0 will be treated as e0 with this methods, but the d0 nb_cfg_54
	// always 0
	pci_devfn_t dev;
	dev = PCI_DEV(0, 0x18+nodeid, 2);
	val_old = pci_read_config32(dev, 0x80);
	val = val_old;
	val |= (1<<3);
	pci_write_config32(dev, 0x80, val);
	val = pci_read_config32(dev, 0x80);
	e0_later = !!(val & (1<<3));

	// pre_e0 bit 3 always be 0 and can not be changed
	if (e0_later)
		pci_write_config32(dev, 0x80, val_old); // restore it

	return e0_later;
}

static inline int is_cpu_f0_in_bsp(int nodeid)
{
	uint32_t dword;
	pci_devfn_t dev;
	if (!IS_ENABLED(CONFIG_K8_REV_F_SUPPORT))
		return 0;
	dev = PCI_DEV(0, 0x18+nodeid, 3);
	dword = pci_read_config32(dev, 0xfc);
	return (dword & 0xfff00) == 0x40f00;
}

static inline int is_cpu_pre_f2_in_bsp(int nodeid)
{
	uint32_t dword;
	pci_devfn_t dev;

	if (!IS_ENABLED(CONFIG_K8_REV_F_SUPPORT))
		return 1;
	dev = PCI_DEV(0, 0x18+nodeid, 3);
	dword = pci_read_config32(dev, 0xfc);
	return (dword & 0xfff0f) < 0x40f02;
}

#else

int is_e0_later_in_bsp(int nodeid);
int is_cpu_f0_in_bsp(int nodeid);

#endif