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
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 <amd_geodelx.h>
33#include <northbridge/amd/geodelx/raminit.h>
34#include <spd.h>
35
36#define MANUALCONF 0
37#define PLLMSRHI 0x000003d9
38#define PLLMSRLO 0x07de0080
39#define DIMM0 ((u8) 0xA0)
40#define DIMM1 ((u8) 0xA2)
41
42
43
44
45
46
47
48
49struct spd_entry {
50 u8 address;
51 u8 data;
52};
53
54
55static const struct spd_entry spd_table[] = {
56 {SPD_MEMORY_TYPE, 7},
57 {SPD_NUM_ROWS, 13},
58 {SPD_tRFC, 0x4b},
59 {SPD_ACCEPTABLE_CAS_LATENCIES, 0x10},
60 {SPD_DENSITY_OF_EACH_ROW_ON_MODULE, 0x40},
61 {SPD_tRAS, 0x2d},
62 {SPD_MIN_CYCLE_TIME_AT_CAS_MAX, 0x7},
63 {SPD_MIN_RAS_TO_CAS_DELAY, 0x58},
64 {SPD_tRRD, 0x3c},
65 {SPD_tRP, 0x58},
66 {SPD_PRIMARY_SDRAM_WIDTH, 8},
67 {SPD_NUM_BANKS_PER_SDRAM, 0x4},
68 {SPD_NUM_COLUMNS, 0xa},
69 {SPD_NUM_DIMM_BANKS, 0x1},
70 {SPD_REFRESH, 0x82},
71 {SPD_SDRAM_CYCLE_TIME_2ND, 0x0},
72 {SPD_SDRAM_CYCLE_TIME_3RD, 0x0},
73};
74
75
76
77
78
79
80
81
82u8 spd_read_byte(u16 device, u8 address)
83{
84 int i;
85
86 u8 ret = 0xff;
87
88 printk(BIOS_DEBUG, "spd_read_byte dev %04x", device);
89 if (device == DIMM0) {
90 for (i = 0; i < ARRAY_SIZE(spd_table); i++) {
91 if (spd_table[i].address == address) {
92 ret = spd_table[i].data;
93 break;
94 }
95 }
96
97 if (i == ARRAY_SIZE(spd_table))
98 printk(BIOS_DEBUG, " addr %02x does not exist in SPD table",
99 address);
100 }
101
102 printk(BIOS_DEBUG, " addr %02x returns %02x\n", address, ret);
103 return ret;
104}
105
106
107
108
109
110
111
112static void mb_gpio_init(void)
113{
114
115}
116
117
118
119
120
121
122
123int main(void)
124{
125 printk(BIOS_DEBUG, "Hi there from stage1\n");
126 post_code(POST_START_OF_MAIN);
127
128 system_preinit();
129 printk(BIOS_DEBUG, "done preinit\n");
130
131 mb_gpio_init();
132 printk(BIOS_DEBUG, "done gpio init\n");
133
134 pll_reset(MANUALCONF, PLLMSRHI, PLLMSRLO);
135 printk(BIOS_DEBUG, "done pll reset\n");
136
137 cpu_reg_init(0, DIMM0, DIMM1, DRAM_UNTERMINATED);
138 printk(BIOS_DEBUG, "done cpu reg init\n");
139
140 sdram_set_registers();
141 printk(BIOS_DEBUG, "done sdram set registers\n");
142
143 sdram_set_spd_registers(DIMM0, DIMM1);
144 printk(BIOS_DEBUG, "done sdram set spd registers\n");
145
146 sdram_enable(DIMM0, DIMM1);
147 printk(BIOS_DEBUG, "done sdram enable\n");
148
149 printk(BIOS_DEBUG, "stage1 returns\n");
150 return 0;
151}
152