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#include <common.h>
33#include <ioports.h>
34#include <mpc83xx.h>
35#include <asm/mpc8349_pci.h>
36#if defined(CONFIG_OF_LIBFDT)
37#include <libfdt.h>
38#endif
39#include <asm/io.h>
40#include <asm/mmu.h>
41#include <spd.h>
42#include <spd_sdram.h>
43#include <i2c.h>
44#include <netdev.h>
45
46void ddr_enable_ecc(unsigned int dram_size);
47
48phys_size_t initdram(int board_type)
49{
50 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
51 u32 msize = 0;
52
53 if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32)im)
54 return -1;
55
56
57 im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_BASE & LAWBAR_BAR;
58
59 msize = spd_sdram();
60
61#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
62
63
64
65 ddr_enable_ecc(msize * 1024 * 1024);
66#endif
67
68
69 msize = get_ram_size(0, msize);
70
71
72 return msize * 1024 * 1024;
73}
74
75int checkboard(void)
76{
77#ifdef VME_CADDY2
78 puts("Board: esd VME-CADDY/2\n");
79#else
80 puts("Board: esd VME-CPU/8349\n");
81#endif
82
83 return 0;
84}
85
86#ifdef VME_CADDY2
87int board_eth_init(bd_t *bis)
88{
89 return pci_eth_init(bis);
90}
91#endif
92
93#if defined(CONFIG_OF_BOARD_SETUP)
94void ft_board_setup(void *blob, bd_t *bd)
95{
96 ft_cpu_setup(blob, bd);
97
98#ifdef CONFIG_PCI
99 ft_pci_setup(blob, bd);
100#endif
101}
102#endif
103
104int misc_init_r()
105{
106 immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
107
108 clrsetbits_be32(&im->lbus.lcrr, LBCR_LDIS, 0);
109
110 return 0;
111}
112
113
114
115
116
117#ifdef VME_CADDY2
118#define SMALL_RAM 0xff
119#define LARGE_RAM 0x00
120#else
121#define SMALL_RAM 0x00
122#define LARGE_RAM 0xff
123#endif
124
125#define SPD_VAL(a, b) (((a) & SMALL_RAM) | ((b) & LARGE_RAM))
126
127static spd_eeprom_t default_spd_eeprom = {
128 SPD_VAL(0x80, 0x80),
129 SPD_VAL(0x07, 0x07),
130 SPD_MEMTYPE_DDR2,
131 SPD_VAL(0x0d, 0x0d),
132 SPD_VAL(0x09, 0x0a),
133 SPD_VAL(0x00, 0x00),
134 SPD_VAL(0x40, 0x40),
135 SPD_VAL(0x00, 0x00),
136 SPD_VAL(0x05, 0x05),
137 SPD_VAL(0x30, 0x30),
138 SPD_VAL(0x45, 0x45),
139 SPD_VAL(0x02, 0x02),
140 SPD_VAL(0x82, 0x82),
141 SPD_VAL(0x10, 0x10),
142 SPD_VAL(0x08, 0x08),
143 SPD_VAL(0x00, 0x00),
144 SPD_VAL(0x0c, 0x0c),
145 SPD_VAL(0x04, 0x08),
146 SPD_VAL(0x38, 0x38),
147 SPD_VAL(0x00, 0x00),
148 SPD_VAL(0x02, 0x02),
149 SPD_VAL(0x00, 0x00),
150 SPD_VAL(0x03, 0x03),
151 SPD_VAL(0x3d, 0x3d),
152 SPD_VAL(0x45, 0x45),
153 SPD_VAL(0x50, 0x50),
154 SPD_VAL(0x45, 0x45),
155 SPD_VAL(0x3c, 0x3c),
156 SPD_VAL(0x28, 0x28),
157 SPD_VAL(0x3c, 0x3c),
158 SPD_VAL(0x2d, 0x2d),
159 SPD_VAL(0x20, 0x80),
160 SPD_VAL(0x20, 0x20),
161 SPD_VAL(0x27, 0x27),
162 SPD_VAL(0x10, 0x10),
163 SPD_VAL(0x17, 0x17),
164 SPD_VAL(0x3c, 0x3c),
165 SPD_VAL(0x1e, 0x1e),
166 SPD_VAL(0x1e, 0x1e),
167 SPD_VAL(0x00, 0x00),
168 SPD_VAL(0x00, 0x06),
169 SPD_VAL(0x37, 0x37),
170 SPD_VAL(0x4b, 0x7f),
171 SPD_VAL(0x80, 0x80),
172 SPD_VAL(0x18, 0x18),
173 SPD_VAL(0x22, 0x22),
174 SPD_VAL(0x00, 0x00),
175 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
176 SPD_VAL(0x10, 0x10),
177 SPD_VAL(0x7e, 0x1d),
178 { 'e', 's', 'd', '-', 'g', 'm', 'b', 'h' },
179 SPD_VAL(0x00, 0x00),
180#ifdef VME_CADDY2
181 { "vme-caddy/2 ram " }
182#else
183 { "vme-cpu/2 ram " }
184#endif
185};
186
187int vme8349_read_spd(uchar chip, uint addr, int alen, uchar *buffer, int len)
188{
189 int old_bus = I2C_GET_BUS();
190 unsigned int l, sum;
191 int valid = 0;
192
193 I2C_SET_BUS(0);
194
195 if (i2c_read(chip, addr, alen, buffer, len) == 0)
196 if (memcmp(&buffer[64], &default_spd_eeprom.mid[0], 8) == 0) {
197 sum = 0;
198 for (l = 0; l < 63; l++)
199 sum = (sum + buffer[l]) & 0xff;
200 if (sum == buffer[63])
201 valid = 1;
202 else
203 printf("Invalid checksum in EEPROM %02x %02x\n",
204 sum, buffer[63]);
205 }
206
207 if (valid == 0) {
208 memcpy(buffer, (void *)&default_spd_eeprom, len);
209 sum = 0;
210 for (l = 0; l < 63; l++)
211 sum = (sum + buffer[l]) & 0xff;
212 if (sum != buffer[63])
213 printf("Invalid checksum in FLASH %02x %02x\n",
214 sum, buffer[63]);
215 buffer[63] = sum;
216 }
217
218 I2C_SET_BUS(old_bus);
219
220 return 0;
221}
222