1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22#define _MAINOBJECT
23#include <mainboard.h>
24#include <types.h>
25#include <lib.h>
26#include <console.h>
27#include <device/device.h>
28#include <device/pci.h>
29#include <string.h>
30#include <msr.h>
31#include <io.h>
32#include <cpu.h>
33#include <globalvars.h>
34#include <amd/k8/k8.h>
35#include <southbridge/nvidia/mcp55/mcp55_smbus.h>
36#include <mc146818rtc.h>
37#include <spd.h>
38
39void hard_reset(void);
40
41void memreset_setup(void)
42{
43}
44
45void memreset(int controllers, const struct mem_controller *ctrl)
46{
47}
48
49void activate_spd_rom(const struct mem_controller *ctrl)
50{
51
52}
53
54
55
56
57
58int main(void)
59{
60 void enable_smbus(void);
61 void enable_fid_change_on_sb(u16 sbbusn, u16 sbdn);
62 void soft_reset_x(unsigned sbbusn, unsigned sbdn);
63 int cpu_init_detected(unsigned int nodeid);
64 void start_all_cores(void);
65 void set_sysinfo_in_ram(unsigned val);
66 int mcp55_early_setup_x(void);
67 void soft_reset(void);
68
69 struct msr msr;
70 static const u16 spd_addr[] = {
71 (0xa << 3) | 0, (0xa << 3) | 2, 0, 0,
72 (0xa << 3) | 1, (0xa << 3) | 3, 0, 0,
73#if CONFIG_MAX_PHYSICAL_CPUS > 1
74 (0xa << 3) | 4, (0xa << 3) | 6, 0, 0,
75 (0xa << 3) | 5, (0xa << 3) | 7, 0, 0,
76#endif
77 };
78 struct sys_info *sysinfo = &(global_vars()->sys_info);
79
80 int needs_reset = 0;
81 unsigned bsp_apicid = 0;
82 int init_detected;
83 struct node_core_id me;
84
85 me = get_node_core_id();
86 printk(BIOS_DEBUG, "Hi there from stage1, cpu%d, core%d\n", me.nodeid, me.coreid);
87
88 init_detected = cpu_init_detected(me.nodeid);
89 printk(BIOS_DEBUG, "init_detected: %d\n", init_detected);
90
91
92
93 bsp_apicid = init_cpus(init_detected, sysinfo);
94
95 printk(BIOS_DEBUG, "bsp_apicid=%02x\n", bsp_apicid);
96
97 set_sysinfo_in_ram(0);
98 setup_coherent_ht_domain();
99
100 wait_all_core0_started();
101#if CONFIG_LOGICAL_CPUS==1
102
103
104
105
106
107 start_all_cores();
108 wait_all_other_cores_started(bsp_apicid);
109#endif
110
111
112 ht_setup_chains_x(sysinfo);
113
114 msr = rdmsr(FIDVID_STATUS);
115 printk(BIOS_DEBUG, "begin msr fid, vid %08x:%08x\n", msr.hi, msr.lo);
116
117
118 enable_fid_change();
119
120 enable_fid_change_on_sb(sysinfo->sbbusn, sysinfo->sbdn);
121
122 init_fidvid_bsp(bsp_apicid);
123
124 msr = rdmsr(FIDVID_STATUS);
125 printk(BIOS_DEBUG, "end msr fid, vid %08x:%08x\n", msr.hi, msr.lo);
126
127
128 needs_reset |= optimize_link_coherent_ht();
129 needs_reset |= optimize_link_incoherent_ht(sysinfo);
130 needs_reset |= mcp55_early_setup_x();
131
132
133 if (needs_reset) {
134 printk(BIOS_INFO, "ht reset -\n");
135 soft_reset();
136 }
137
138
139 fill_mem_ctrl(sysinfo->nodes, sysinfo->ctrl, spd_addr);
140
141 enable_smbus();
142
143 memreset_setup();
144
145 sdram_initialize(sysinfo->nodes, sysinfo->ctrl, sysinfo);
146
147
148 allow_all_aps_stop(bsp_apicid);
149
150 printk(BIOS_DEBUG, "initram returns\n");
151 return 0;
152}
153
154