1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21#define _MAINOBJECT
22
23#include <types.h>
24#include <lib.h>
25#include <console.h>
26#include <device/device.h>
27#include <device/pci.h>
28#include <string.h>
29#include <msr.h>
30#include <io.h>
31#include <amd_geodelx.h>
32#include <northbridge/amd/geodelx/raminit.h>
33#include <spd.h>
34
35#define MANUALCONF 0
36#define PLLMSRHI 0x00001490
37#define PLLMSRLO 0x02000030
38#define DIMM0 ((u8) 0xA0)
39#define DIMM1 ((u8) 0xA2)
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59struct spd_entry {
60 u8 address;
61 u8 data;
62};
63
64
65static const struct spd_entry spd_table[] = {
66 {SPD_ACCEPTABLE_CAS_LATENCIES, 0x10},
67 {SPD_BANK_DENSITY, 0x40},
68 {SPD_DEVICE_ATTRIBUTES_GENERAL, 0xff},
69 {SPD_MEMORY_TYPE, 7},
70 {SPD_MIN_CYCLE_TIME_AT_CAS_MAX, 10},
71 {SPD_MODULE_ATTRIBUTES, 0xff},
72 {SPD_NUM_BANKS_PER_SDRAM, 4},
73 {SPD_PRIMARY_SDRAM_WIDTH, 8},
74 {SPD_NUM_DIMM_BANKS, 1},
75 {SPD_NUM_COLUMNS, 0xa},
76 {SPD_NUM_ROWS, 3},
77 {SPD_REFRESH, 0x3a},
78 {SPD_SDRAM_CYCLE_TIME_2ND, 60},
79 {SPD_SDRAM_CYCLE_TIME_3RD, 75},
80 {SPD_tRAS, 40},
81 {SPD_tRCD, 15},
82 {SPD_tRFC, 70},
83 {SPD_tRP, 15},
84 {SPD_tRRD, 10},
85};
86
87
88
89
90
91
92
93
94u8 spd_read_byte(u16 device, u8 address)
95{
96 int i;
97
98 u8 ret = 0xff;
99
100 printk(BIOS_DEBUG, "spd_read_byte dev %04x", device);
101 if (device == DIMM0) {
102 for (i = 0; i < ARRAY_SIZE(spd_table); i++) {
103 if (spd_table[i].address == address) {
104 ret = spd_table[i].data;
105 break;
106 }
107 }
108 if (i == ARRAY_SIZE(spd_table))
109 printk(BIOS_DEBUG, " addr %02x does not exist in SPD table",
110 address);
111 }
112
113 printk(BIOS_DEBUG, " addr %02x returns %02x\n", address, ret);
114 return ret;
115}
116
117
118
119
120
121
122
123static void mb_gpio_init(void)
124{
125
126}
127
128
129
130
131
132
133
134int main(void)
135{
136 printk(BIOS_DEBUG, "Hi there from stage1\n");
137 post_code(POST_START_OF_MAIN);
138
139 system_preinit();
140 printk(BIOS_DEBUG, "done preinit\n");
141
142 mb_gpio_init();
143 printk(BIOS_DEBUG, "done gpio init\n");
144
145 pll_reset(MANUALCONF, PLLMSRHI, PLLMSRLO);
146 printk(BIOS_DEBUG, "done pll reset\n");
147
148 cpu_reg_init(0, DIMM0, DIMM1, DRAM_TERMINATED);
149 printk(BIOS_DEBUG, "done cpu reg init\n");
150
151 sdram_set_registers();
152 printk(BIOS_DEBUG, "done sdram set registers\n");
153
154 sdram_set_spd_registers(DIMM0, DIMM1);
155 printk(BIOS_DEBUG, "done sdram set spd registers\n");
156
157 sdram_enable(DIMM0, DIMM1);
158 printk(BIOS_DEBUG, "done sdram enable\n");
159
160
161
162
163 printk(BIOS_DEBUG, "stage1 returns\n");
164 return 0;
165}
166