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 * SPDX-License-Identifier: GPL-2.0+
18 #include <asm/mpc8349_pci.h>
19 #if defined(CONFIG_OF_LIBFDT)
25 #include <spd_sdram.h>
29 void ddr_enable_ecc(unsigned int dram_size);
31 phys_size_t initdram(int board_type)
33 volatile immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
36 if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32)im)
39 /* DDR SDRAM - Main memory */
40 im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_BASE & LAWBAR_BAR;
44 #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
46 * Initialize and enable DDR ECC.
48 ddr_enable_ecc(msize * 1024 * 1024);
51 /* Now check memory size (after ECC is initialized) */
52 msize = get_ram_size(0, msize);
54 /* return total bus SDRAM size(bytes) -- DDR */
55 return msize * 1024 * 1024;
61 puts("Board: esd VME-CADDY/2\n");
63 puts("Board: esd VME-CPU/8349\n");
70 int board_eth_init(bd_t *bis)
72 return pci_eth_init(bis);
76 #if defined(CONFIG_OF_BOARD_SETUP)
77 int ft_board_setup(void *blob, bd_t *bd)
79 ft_cpu_setup(blob, bd);
82 ft_pci_setup(blob, bd);
91 immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
93 clrsetbits_be32(&im->im_lbc.lcrr, LBCR_LDIS, 0);
99 * Provide SPD values for spd_sdram(). Both boards (VME-CADDY/2
100 * and VME-CADDY/2) have different SDRAM configurations.
103 #define SMALL_RAM 0xff
104 #define LARGE_RAM 0x00
106 #define SMALL_RAM 0x00
107 #define LARGE_RAM 0xff
110 #define SPD_VAL(a, b) (((a) & SMALL_RAM) | ((b) & LARGE_RAM))
112 static spd_eeprom_t default_spd_eeprom = {
113 SPD_VAL(0x80, 0x80), /* 00 use 128 Bytes */
114 SPD_VAL(0x07, 0x07), /* 01 use 128 Bytes */
115 SPD_MEMTYPE_DDR2, /* 02 type is DDR2 */
116 SPD_VAL(0x0d, 0x0d), /* 03 rows: 13 */
117 SPD_VAL(0x09, 0x0a), /* 04 cols: 9 / 10 */
118 SPD_VAL(0x00, 0x00), /* 05 */
119 SPD_VAL(0x40, 0x40), /* 06 */
120 SPD_VAL(0x00, 0x00), /* 07 */
121 SPD_VAL(0x05, 0x05), /* 08 */
122 SPD_VAL(0x30, 0x30), /* 09 */
123 SPD_VAL(0x45, 0x45), /* 10 */
124 SPD_VAL(0x02, 0x02), /* 11 ecc used */
125 SPD_VAL(0x82, 0x82), /* 12 */
126 SPD_VAL(0x10, 0x10), /* 13 */
127 SPD_VAL(0x08, 0x08), /* 14 */
128 SPD_VAL(0x00, 0x00), /* 15 */
129 SPD_VAL(0x0c, 0x0c), /* 16 */
130 SPD_VAL(0x04, 0x08), /* 17 banks: 4 / 8 */
131 SPD_VAL(0x38, 0x38), /* 18 */
132 SPD_VAL(0x00, 0x00), /* 19 */
133 SPD_VAL(0x02, 0x02), /* 20 */
134 SPD_VAL(0x00, 0x00), /* 21 */
135 SPD_VAL(0x03, 0x03), /* 22 */
136 SPD_VAL(0x3d, 0x3d), /* 23 */
137 SPD_VAL(0x45, 0x45), /* 24 */
138 SPD_VAL(0x50, 0x50), /* 25 */
139 SPD_VAL(0x45, 0x45), /* 26 */
140 SPD_VAL(0x3c, 0x3c), /* 27 */
141 SPD_VAL(0x28, 0x28), /* 28 */
142 SPD_VAL(0x3c, 0x3c), /* 29 */
143 SPD_VAL(0x2d, 0x2d), /* 30 */
144 SPD_VAL(0x20, 0x80), /* 31 */
145 SPD_VAL(0x20, 0x20), /* 32 */
146 SPD_VAL(0x27, 0x27), /* 33 */
147 SPD_VAL(0x10, 0x10), /* 34 */
148 SPD_VAL(0x17, 0x17), /* 35 */
149 SPD_VAL(0x3c, 0x3c), /* 36 */
150 SPD_VAL(0x1e, 0x1e), /* 37 */
151 SPD_VAL(0x1e, 0x1e), /* 38 */
152 SPD_VAL(0x00, 0x00), /* 39 */
153 SPD_VAL(0x00, 0x06), /* 40 */
154 SPD_VAL(0x37, 0x37), /* 41 */
155 SPD_VAL(0x4b, 0x7f), /* 42 */
156 SPD_VAL(0x80, 0x80), /* 43 */
157 SPD_VAL(0x18, 0x18), /* 44 */
158 SPD_VAL(0x22, 0x22), /* 45 */
159 SPD_VAL(0x00, 0x00), /* 46 */
160 { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
161 SPD_VAL(0x10, 0x10), /* 62 */
162 SPD_VAL(0x7e, 0x1d), /* 63 */
163 { 'e', 's', 'd', '-', 'g', 'm', 'b', 'h' },
164 SPD_VAL(0x00, 0x00), /* 72 */
166 { "vme-caddy/2 ram " }
172 int vme8349_read_spd(uchar chip, uint addr, int alen, uchar *buffer, int len)
174 int old_bus = i2c_get_bus_num();
180 if (i2c_read(chip, addr, alen, buffer, len) == 0)
181 if (memcmp(&buffer[64], &default_spd_eeprom.mid[0], 8) == 0) {
183 for (l = 0; l < 63; l++)
184 sum = (sum + buffer[l]) & 0xff;
185 if (sum == buffer[63])
188 printf("Invalid checksum in EEPROM %02x %02x\n",
193 memcpy(buffer, (void *)&default_spd_eeprom, len);
195 for (l = 0; l < 63; l++)
196 sum = (sum + buffer[l]) & 0xff;
197 if (sum != buffer[63])
198 printf("Invalid checksum in FLASH %02x %02x\n",
203 i2c_set_bus_num(old_bus);