2 * vme8349.c -- esd VME8349 board support
4 * Copyright (c) 2008-2009 esd gmbh.
7 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
9 * Reinhard Arlt <reinhard.arlt@esd-electronics.com>
10 * Based on board/mpc8349emds/mpc8349emds.c (and previous 834x releases.)
12 * See file CREDITS for list of people who contributed to this
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License as
17 * published by the Free Software Foundation; either version 2 of
18 * the License, or (at your option) any later version.
20 * This program is distributed in the hope that it will be useful,
21 * but WITHOUT ANY WARRANTY; without even the implied warranty of
22 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
23 * GNU General Public License for more details.
25 * You should have received a copy of the GNU General Public License
26 * along with this program; if not, write to the Free Software
27 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
35 #include <asm/mpc8349_pci.h>
36 #if defined(CONFIG_OF_LIBFDT)
42 #include <spd_sdram.h>
46 void ddr_enable_ecc(unsigned int dram_size);
48 phys_size_t initdram(int board_type)
50 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
53 if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32)im)
56 /* DDR SDRAM - Main memory */
57 im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_BASE & LAWBAR_BAR;
61 #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
63 * Initialize and enable DDR ECC.
65 ddr_enable_ecc(msize * 1024 * 1024);
68 /* Now check memory size (after ECC is initialized) */
69 msize = get_ram_size(0, msize);
71 /* return total bus SDRAM size(bytes) -- DDR */
72 return msize * 1024 * 1024;
78 puts("Board: esd VME-CADDY/2\n");
80 puts("Board: esd VME-CPU/8349\n");
87 int board_eth_init(bd_t *bis)
89 return pci_eth_init(bis);
93 #if defined(CONFIG_OF_BOARD_SETUP)
94 void ft_board_setup(void *blob, bd_t *bd)
96 ft_cpu_setup(blob, bd);
99 ft_pci_setup(blob, bd);
106 immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
108 clrsetbits_be32(&im->lbus.lcrr, LBCR_LDIS, 0);
114 * Provide SPD values for spd_sdram(). Both boards (VME-CADDY/2
115 * and VME-CADDY/2) have different SDRAM configurations.
118 #define SMALL_RAM 0xff
119 #define LARGE_RAM 0x00
121 #define SMALL_RAM 0x00
122 #define LARGE_RAM 0xff
125 #define SPD_VAL(a, b) (((a) & SMALL_RAM) | ((b) & LARGE_RAM))
127 static spd_eeprom_t default_spd_eeprom = {
128 SPD_VAL(0x80, 0x80), /* 00 use 128 Bytes */
129 SPD_VAL(0x07, 0x07), /* 01 use 128 Bytes */
130 SPD_MEMTYPE_DDR2, /* 02 type is DDR2 */
131 SPD_VAL(0x0d, 0x0d), /* 03 rows: 13 */
132 SPD_VAL(0x09, 0x0a), /* 04 cols: 9 / 10 */
133 SPD_VAL(0x00, 0x00), /* 05 */
134 SPD_VAL(0x40, 0x40), /* 06 */
135 SPD_VAL(0x00, 0x00), /* 07 */
136 SPD_VAL(0x05, 0x05), /* 08 */
137 SPD_VAL(0x30, 0x30), /* 09 */
138 SPD_VAL(0x45, 0x45), /* 10 */
139 SPD_VAL(0x02, 0x02), /* 11 ecc used */
140 SPD_VAL(0x82, 0x82), /* 12 */
141 SPD_VAL(0x10, 0x10), /* 13 */
142 SPD_VAL(0x08, 0x08), /* 14 */
143 SPD_VAL(0x00, 0x00), /* 15 */
144 SPD_VAL(0x0c, 0x0c), /* 16 */
145 SPD_VAL(0x04, 0x08), /* 17 banks: 4 / 8 */
146 SPD_VAL(0x38, 0x38), /* 18 */
147 SPD_VAL(0x00, 0x00), /* 19 */
148 SPD_VAL(0x02, 0x02), /* 20 */
149 SPD_VAL(0x00, 0x00), /* 21 */
150 SPD_VAL(0x03, 0x03), /* 22 */
151 SPD_VAL(0x3d, 0x3d), /* 23 */
152 SPD_VAL(0x45, 0x45), /* 24 */
153 SPD_VAL(0x50, 0x50), /* 25 */
154 SPD_VAL(0x45, 0x45), /* 26 */
155 SPD_VAL(0x3c, 0x3c), /* 27 */
156 SPD_VAL(0x28, 0x28), /* 28 */
157 SPD_VAL(0x3c, 0x3c), /* 29 */
158 SPD_VAL(0x2d, 0x2d), /* 30 */
159 SPD_VAL(0x20, 0x80), /* 31 */
160 SPD_VAL(0x20, 0x20), /* 32 */
161 SPD_VAL(0x27, 0x27), /* 33 */
162 SPD_VAL(0x10, 0x10), /* 34 */
163 SPD_VAL(0x17, 0x17), /* 35 */
164 SPD_VAL(0x3c, 0x3c), /* 36 */
165 SPD_VAL(0x1e, 0x1e), /* 37 */
166 SPD_VAL(0x1e, 0x1e), /* 38 */
167 SPD_VAL(0x00, 0x00), /* 39 */
168 SPD_VAL(0x00, 0x06), /* 40 */
169 SPD_VAL(0x37, 0x37), /* 41 */
170 SPD_VAL(0x4b, 0x7f), /* 42 */
171 SPD_VAL(0x80, 0x80), /* 43 */
172 SPD_VAL(0x18, 0x18), /* 44 */
173 SPD_VAL(0x22, 0x22), /* 45 */
174 SPD_VAL(0x00, 0x00), /* 46 */
175 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
176 SPD_VAL(0x10, 0x10), /* 62 */
177 SPD_VAL(0x7e, 0x1d), /* 63 */
178 { 'e', 's', 'd', '-', 'g', 'm', 'b', 'h' },
179 SPD_VAL(0x00, 0x00), /* 72 */
181 { "vme-caddy/2 ram " }
187 int vme8349_read_spd(uchar chip, uint addr, int alen, uchar *buffer, int len)
189 int old_bus = I2C_GET_BUS();
195 if (i2c_read(chip, addr, alen, buffer, len) == 0)
196 if (memcmp(&buffer[64], &default_spd_eeprom.mid[0], 8) == 0) {
198 for (l = 0; l < 63; l++)
199 sum = (sum + buffer[l]) & 0xff;
200 if (sum == buffer[63])
203 printf("Invalid checksum in EEPROM %02x %02x\n",
208 memcpy(buffer, (void *)&default_spd_eeprom, len);
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",
218 I2C_SET_BUS(old_bus);