1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20#include <common.h>
21#include <ioports.h>
22#include <mpc83xx.h>
23#include <i2c.h>
24#include <miiphy.h>
25#include <asm/io.h>
26#include <asm/mmu.h>
27#include <asm/processor.h>
28#include <pci.h>
29#include <libfdt.h>
30
31#include "../common/common.h"
32
33const qe_iop_conf_t qe_iop_conf_tab[] = {
34
35#if defined(CONFIG_KMETER1)
36
37 {0, 1, 3, 0, 2},
38 {0, 2, 1, 0, 1},
39
40
41 {1, 14, 1, 0, 1},
42 {1, 15, 1, 0, 1},
43 {1, 20, 2, 0, 1},
44 {1, 21, 2, 0, 1},
45 {1, 18, 1, 0, 1},
46 {1, 26, 2, 0, 1},
47 {1, 27, 2, 0, 1},
48 {1, 24, 2, 0, 1},
49 {1, 25, 2, 0, 1},
50 {2, 15, 2, 0, 1},
51 {2, 16, 2, 0, 1},
52
53
54 {5, 0, 1, 0, 2},
55 {5, 2, 1, 0, 1},
56 {5, 3, 2, 0, 2},
57 {5, 1, 2, 0, 3},
58#else
59
60 {0, 16, 1, 0, 3},
61 {0, 17, 1, 0, 3},
62 {0, 18, 1, 0, 3},
63 {0, 19, 1, 0, 3},
64 {0, 20, 1, 0, 3},
65 {0, 21, 1, 0, 3},
66 {0, 22, 1, 0, 3},
67 {0, 23, 1, 0, 3},
68 {0, 24, 1, 0, 3},
69 {0, 25, 1, 0, 3},
70 {0, 26, 1, 0, 3},
71 {0, 27, 1, 0, 3},
72 {0, 28, 1, 0, 3},
73 {0, 29, 1, 0, 3},
74 {0, 30, 1, 0, 3},
75 {0, 31, 1, 0, 3},
76
77
78 {3, 4, 3, 0, 2},
79 {3, 5, 1, 0, 2},
80
81
82 {1, 18, 1, 0, 1},
83 {1, 19, 1, 0, 1},
84 {1, 22, 2, 0, 1},
85 {1, 23, 2, 0, 1},
86 {1, 26, 2, 0, 1},
87 {1, 28, 2, 0, 1},
88 {1, 30, 1, 0, 1},
89 {1, 31, 2, 0, 1},
90 {3, 10, 2, 0, 3},
91#endif
92
93
94 {0, 0, 0, 0, QE_IOP_TAB_END},
95};
96
97static int board_init_i2c_busses(void)
98{
99 I2C_MUX_DEVICE *dev = NULL;
100 uchar *buf;
101
102
103 buf = (unsigned char *) getenv("dtt_bus");
104 if (buf != NULL)
105 dev = i2c_mux_ident_muxstring(buf);
106 if (dev == NULL) {
107 printf("Error couldn't add Bus for DTT\n");
108 printf("please setup dtt_bus to where your\n");
109 printf("DTT is found.\n");
110 }
111 return 0;
112}
113
114#if defined(CONFIG_SUVD3)
115const uint upma_table[] = {
116 0x1ffedc00, 0x0ffcdc80, 0x0ffcdc80, 0x0ffcdc04,
117 0x0ffcdc00, 0xffffcc00, 0xffffcc01, 0xfffffc01,
118 0xfffffc01, 0xfffffc01, 0xfffffc01, 0xfffffc01,
119 0xfffffc01, 0xfffffc01, 0xfffffc01, 0xfffffc01,
120 0xfffffc01, 0xfffffc01, 0xfffffc01, 0xfffffc01,
121 0xfffffc01, 0xfffffc01, 0xfffffc01, 0xfffffc01,
122 0x9cfffc00, 0x00fffc80, 0x00fffc80, 0x00fffc00,
123 0xffffec04, 0xffffec01, 0xfffffc01, 0xfffffc01,
124 0xfffffc01, 0xfffffc01, 0xfffffc01, 0xfffffc01,
125 0xfffffc01, 0xfffffc01, 0xfffffc01, 0xfffffc01,
126 0xfffffc01, 0xfffffc01, 0xfffffc01, 0xfffffc01,
127 0xfffffc01, 0xfffffc01, 0xfffffc01, 0xfffffc01,
128 0xfffffc01, 0xfffffc01, 0xfffffc01, 0xfffffc01,
129 0xfffffc01, 0xfffffc01, 0xfffffc01, 0xfffffc01,
130 0xfffffc01, 0xfffffc01, 0xfffffc01, 0xfffffc01,
131 0xfffffc01, 0xfffffc01, 0xfffffc01, 0xfffffc01
132};
133#endif
134
135int board_early_init_r(void)
136{
137 struct km_bec_fpga *base =
138 (struct km_bec_fpga *)CONFIG_SYS_KMBEC_FPGA_BASE;
139#if defined(CONFIG_SUVD3)
140 immap_t *immap = (immap_t *) CONFIG_SYS_IMMR;
141 fsl_lbc_t *lbc = &immap->im_lbc;
142 u32 *mxmr = &lbc->mamr;
143#endif
144
145#if defined(CONFIG_MPC8360)
146 unsigned short svid;
147
148
149
150
151 svid = SVR_REV(mfspr(SVR));
152 switch (svid) {
153 case 0x0020:
154
155
156
157
158
159 setbits_be32((void *)(CONFIG_SYS_IMMR + 0x14a8), 0x0c003000);
160 break;
161 case 0x0021:
162
163
164
165
166 clrsetbits_be32((void *)(CONFIG_SYS_IMMR + 0x14ac),
167 0x00000050, 0x000000a0);
168 break;
169 }
170#endif
171
172
173 setbits_8(&base->pgy_eth, 0x01);
174
175 setbits_8(&base->oprth, WRL_BOOT);
176
177#if defined(CONFIG_SUVD3)
178
179 upmconfig(UPMA, (uint *) upma_table,
180 sizeof(upma_table) / sizeof(uint));
181 out_be32(mxmr, CONFIG_SYS_MAMR);
182#endif
183 return 0;
184}
185
186int misc_init_r(void)
187{
188
189 board_init_i2c_busses();
190 return 0;
191}
192
193int last_stage_init(void)
194{
195 set_km_env();
196 return 0;
197}
198
199int fixed_sdram(void)
200{
201 immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
202 u32 msize = 0;
203 u32 ddr_size;
204 u32 ddr_size_log2;
205
206 out_be32(&im->sysconf.ddrlaw[0].ar, (LAWAR_EN | 0x1e));
207 out_be32(&im->ddr.csbnds[0].csbnds, CONFIG_SYS_DDR_CS0_BNDS);
208 out_be32(&im->ddr.cs_config[0], CONFIG_SYS_DDR_CS0_CONFIG);
209 out_be32(&im->ddr.timing_cfg_0, CONFIG_SYS_DDR_TIMING_0);
210 out_be32(&im->ddr.timing_cfg_1, CONFIG_SYS_DDR_TIMING_1);
211 out_be32(&im->ddr.timing_cfg_2, CONFIG_SYS_DDR_TIMING_2);
212 out_be32(&im->ddr.timing_cfg_3, CONFIG_SYS_DDR_TIMING_3);
213 out_be32(&im->ddr.sdram_cfg, CONFIG_SYS_DDR_SDRAM_CFG);
214 out_be32(&im->ddr.sdram_cfg2, CONFIG_SYS_DDR_SDRAM_CFG2);
215 out_be32(&im->ddr.sdram_mode, CONFIG_SYS_DDR_MODE);
216 out_be32(&im->ddr.sdram_mode2, CONFIG_SYS_DDR_MODE2);
217 out_be32(&im->ddr.sdram_interval, CONFIG_SYS_DDR_INTERVAL);
218 out_be32(&im->ddr.sdram_clk_cntl, CONFIG_SYS_DDR_CLK_CNTL);
219 udelay(200);
220 setbits_be32(&im->ddr.sdram_cfg, SDRAM_CFG_MEM_EN);
221
222 msize = CONFIG_SYS_DDR_SIZE << 20;
223 disable_addr_trans();
224 msize = get_ram_size(CONFIG_SYS_DDR_BASE, msize);
225 enable_addr_trans();
226 msize /= (1024 * 1024);
227 if (CONFIG_SYS_DDR_SIZE != msize) {
228 for (ddr_size = msize << 20, ddr_size_log2 = 0;
229 (ddr_size > 1);
230 ddr_size = ddr_size >> 1, ddr_size_log2++)
231 if (ddr_size & 1)
232 return -1;
233 out_be32(&im->sysconf.ddrlaw[0].ar,
234 (LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE)));
235 out_be32(&im->ddr.csbnds[0].csbnds,
236 (((msize / 16) - 1) & 0xff));
237 }
238
239 return msize;
240}
241
242phys_size_t initdram(int board_type)
243{
244 immap_t *im = (immap_t *)CONFIG_SYS_IMMR;
245 u32 msize = 0;
246
247 if ((in_be32(&im->sysconf.immrbar) & IMMRBAR_BASE_ADDR) != (u32)im)
248 return -1;
249
250 out_be32(&im->sysconf.ddrlaw[0].bar,
251 CONFIG_SYS_DDR_BASE & LAWBAR_BAR);
252 msize = fixed_sdram();
253
254#if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER)
255
256
257
258 ddr_enable_ecc(msize * 1024 * 1024);
259#endif
260
261
262 return msize * 1024 * 1024;
263}
264
265int checkboard(void)
266{
267 puts("Board: Keymile " CONFIG_KM_BOARD_NAME);
268
269 if (ethernet_present())
270 puts(" with PIGGY.");
271 puts("\n");
272 return 0;
273}
274
275#if defined(CONFIG_OF_BOARD_SETUP)
276void ft_board_setup(void *blob, bd_t *bd)
277{
278 ft_cpu_setup(blob, bd);
279}
280#endif
281
282#if defined(CONFIG_HUSH_INIT_VAR)
283int hush_init_var(void)
284{
285 ivm_read_eeprom();
286 return 0;
287}
288#endif
289