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#include <common.h>
27#include <netdev.h>
28#include <asm/arch/omap2420.h>
29#include <asm/io.h>
30#include <asm/arch/bits.h>
31#include <asm/arch/mux.h>
32#include <asm/arch/sys_proto.h>
33#include <asm/arch/sys_info.h>
34#include <asm/arch/mem.h>
35#include <asm/mach-types.h>
36
37void wait_for_command_complete(unsigned int wd_base);
38
39DECLARE_GLOBAL_DATA_PTR;
40
41#define write_config_reg(reg, value) \
42do { \
43 writeb(value, reg); \
44} while (0)
45
46#define mask_config_reg(reg, mask) \
47do { \
48 char value = readb(reg) & ~(mask); \
49 writeb(value, reg); \
50} while (0)
51
52
53
54
55
56static inline void delay(unsigned long loops)
57{
58 __asm__("1:\n" "subs %0, %1, #1\n"
59 "bne 1b":"=r" (loops):"0"(loops));
60}
61
62
63
64
65
66int board_init(void)
67{
68 gpmc_init();
69
70 gd->bd->bi_arch_number = 919;
71
72 gd->bd->bi_boot_params = (OMAP2420_SDRC_CS0 + 0x100);
73
74 return 0;
75}
76
77
78
79
80
81
82void s_init(void)
83{
84 watchdog_init();
85 set_muxconf_regs();
86 delay(100);
87
88 peripheral_enable();
89 icache_enable();
90}
91
92
93
94
95
96int misc_init_r(void)
97{
98 return (0);
99}
100
101
102
103
104
105void watchdog_init(void)
106{
107
108
109
110
111 __raw_writel(WD_UNLOCK1, WD2_BASE + WSPR);
112 wait_for_command_complete(WD2_BASE);
113 __raw_writel(WD_UNLOCK2, WD2_BASE + WSPR);
114
115#define MPU_WD_CLOCKED 1
116#if MPU_WD_CLOCKED
117
118 __raw_writel(WD_UNLOCK1, WD3_BASE + WSPR);
119 wait_for_command_complete(WD3_BASE);
120 __raw_writel(WD_UNLOCK2, WD3_BASE + WSPR);
121
122 __raw_writel(WD_UNLOCK1, WD4_BASE + WSPR);
123 wait_for_command_complete(WD4_BASE);
124 __raw_writel(WD_UNLOCK2, WD4_BASE + WSPR);
125#endif
126}
127
128
129
130
131
132void wait_for_command_complete(unsigned int wd_base)
133{
134 int pending = 1;
135 do {
136 pending = __raw_readl(wd_base + WWPS);
137 } while (pending);
138}
139
140
141
142
143
144
145int board_eth_init(bd_t *bis)
146{
147 int rc = 0;
148#ifdef CONFIG_LAN91C96
149 int cnt = 20;
150
151 __raw_writeb(0x03, OMAP2420_CTRL_BASE + 0x0f2);
152
153 __raw_writew(0x0, LAN_RESET_REGISTER);
154 do {
155 __raw_writew(0x1, LAN_RESET_REGISTER);
156 udelay(100);
157 if (cnt == 0)
158 goto eth_reset_err_out;
159 --cnt;
160 } while (__raw_readw(LAN_RESET_REGISTER) != 0x1);
161
162 cnt = 20;
163
164 do {
165 __raw_writew(0x0, LAN_RESET_REGISTER);
166 udelay(100);
167 if (cnt == 0)
168 goto eth_reset_err_out;
169 --cnt;
170 } while (__raw_readw(LAN_RESET_REGISTER) != 0x0000);
171 udelay(1000);
172
173 mask_config_reg(ETH_CONTROL_REG, 0x01);
174 udelay(1000);
175 rc = lan91c96_initialize(0, CONFIG_LAN91C96_BASE);
176eth_reset_err_out:
177#endif
178 return rc;
179}
180
181
182
183
184
185int dram_init(void)
186{
187 unsigned int size0 = 0, size1 = 0;
188 u32 mtype, btype, rev = 0, cpu = 0;
189#define NOT_EARLY 0
190
191 btype = get_board_type();
192 mtype = get_mem_type();
193 rev = get_cpu_rev();
194 cpu = get_cpu_type();
195
196 display_board_info(btype);
197
198 if ((mtype == DDR_COMBO) || (mtype == DDR_STACKED)) {
199
200 do_sdrc_init(SDRC_CS1_OSET, NOT_EARLY);
201 }
202
203 size0 = get_sdr_cs_size(SDRC_CS0_OSET);
204 size1 = get_sdr_cs_size(SDRC_CS1_OSET);
205
206 gd->bd->bi_dram[0].start = PHYS_SDRAM_1;
207 gd->bd->bi_dram[0].size = size0;
208#if CONFIG_NR_DRAM_BANKS > 1
209 gd->bd->bi_dram[1].start = PHYS_SDRAM_1 + size0;
210 gd->bd->bi_dram[1].size = size1;
211#endif
212
213 return 0;
214}
215
216
217
218
219
220
221void set_muxconf_regs(void)
222{
223 muxSetupSDRC();
224 muxSetupGPMC();
225 muxSetupUsb0();
226 muxSetupUsbHost();
227 muxSetupUART1();
228 muxSetupLCD();
229 muxSetupMMCSD();
230 muxSetupTouchScreen();
231}
232
233
234
235
236
237void peripheral_enable(void)
238{
239 unsigned int v, if_clks = 0, func_clks = 0;
240
241
242 if_clks |= BIT4 | BIT3;
243 func_clks |= BIT4 | BIT3;
244
245 v = __raw_readl(CM_CLKSEL2_CORE) | 0x4 | 0x2;
246 __raw_writel(v, CM_CLKSEL2_CORE);
247 __raw_writel(0x1, CM_CLKSEL_WKUP);
248
249#ifdef CONFIG_SYS_NS16550
250
251 func_clks |= BIT21;
252 if_clks |= BIT21;
253#endif
254
255 v = __raw_readl(CM_ICLKEN1_CORE) | if_clks;
256 __raw_writel(v, CM_ICLKEN1_CORE);
257
258 v = __raw_readl(CM_FCLKEN1_CORE) | func_clks;
259 __raw_writel(v, CM_FCLKEN1_CORE);
260 delay(1000);
261
262#ifndef KERNEL_UPDATED
263 {
264#define V1 0xffffffff
265#define V2 0x00000007
266
267 __raw_writel(V1, CM_FCLKEN1_CORE);
268 __raw_writel(V2, CM_FCLKEN2_CORE);
269 __raw_writel(V1, CM_ICLKEN1_CORE);
270 __raw_writel(V1, CM_ICLKEN2_CORE);
271 }
272#endif
273}
274
275
276
277
278
279void muxSetupUsb0(void)
280{
281 mask_config_reg(CONTROL_PADCONF_USB0_PUEN, 0x1f);
282 mask_config_reg(CONTROL_PADCONF_USB0_VP, 0x1f);
283 mask_config_reg(CONTROL_PADCONF_USB0_VM, 0x1f);
284 mask_config_reg(CONTROL_PADCONF_USB0_RCV, 0x1f);
285 mask_config_reg(CONTROL_PADCONF_USB0_TXEN, 0x1f);
286 mask_config_reg(CONTROL_PADCONF_USB0_SE0, 0x1f);
287 mask_config_reg(CONTROL_PADCONF_USB0_DAT, 0x1f);
288}
289
290
291
292
293
294void muxSetupUsbHost(void)
295{
296
297 write_config_reg(CONTROL_PADCONF_USB1_RCV, 1);
298
299 write_config_reg(CONTROL_PADCONF_USB1_TXEN, 1);
300
301 write_config_reg(CONTROL_PADCONF_GPIO69, 3);
302
303 write_config_reg(CONTROL_PADCONF_GPIO70, 3);
304
305 write_config_reg(CONTROL_PADCONF_GPIO102, 3);
306
307 write_config_reg(CONTROL_PADCONF_GPIO103, 3);
308
309 write_config_reg(CONTROL_PADCONF_GPIO104, 3);
310
311 write_config_reg(CONTROL_PADCONF_GPIO105, 3);
312}
313
314
315
316
317
318void muxSetupUART1(void)
319{
320
321 write_config_reg(CONTROL_PADCONF_UART1_CTS, 0);
322
323 write_config_reg(CONTROL_PADCONF_UART1_RTS, 0);
324
325 write_config_reg(CONTROL_PADCONF_UART1_TX, 0);
326
327 write_config_reg(CONTROL_PADCONF_UART1_RX, 0);
328}
329
330
331
332
333
334void muxSetupLCD(void)
335{
336
337 write_config_reg(CONTROL_PADCONF_DSS_D0, 0);
338
339 write_config_reg(CONTROL_PADCONF_DSS_D1, 0);
340
341 write_config_reg(CONTROL_PADCONF_DSS_D2, 0);
342
343 write_config_reg(CONTROL_PADCONF_DSS_D3, 0);
344
345 write_config_reg(CONTROL_PADCONF_DSS_D4, 0);
346
347 write_config_reg(CONTROL_PADCONF_DSS_D5, 0);
348
349 write_config_reg(CONTROL_PADCONF_DSS_D6, 0);
350
351 write_config_reg(CONTROL_PADCONF_DSS_D7, 0);
352
353 write_config_reg(CONTROL_PADCONF_DSS_D8, 0);
354
355 write_config_reg(CONTROL_PADCONF_DSS_D9, 0);
356
357 write_config_reg(CONTROL_PADCONF_DSS_D10, 0);
358
359 write_config_reg(CONTROL_PADCONF_DSS_D11, 0);
360
361 write_config_reg(CONTROL_PADCONF_DSS_D12, 0);
362
363 write_config_reg(CONTROL_PADCONF_DSS_D13, 0);
364
365 write_config_reg(CONTROL_PADCONF_DSS_D14, 0);
366
367 write_config_reg(CONTROL_PADCONF_DSS_D15, 0);
368
369 write_config_reg(CONTROL_PADCONF_DSS_D16, 0);
370
371 write_config_reg(CONTROL_PADCONF_DSS_D17, 0);
372
373 write_config_reg(CONTROL_PADCONF_DSS_PCLK, 0);
374
375 write_config_reg(CONTROL_PADCONF_DSS_VSYNC, 0);
376
377 write_config_reg(CONTROL_PADCONF_DSS_HSYNC, 0);
378
379 write_config_reg(CONTROL_PADCONF_DSS_ACBIAS, 0);
380}
381
382
383
384
385
386void muxSetupMMCSD(void)
387{
388
389 write_config_reg(CONTROL_PADCONF_MMC_CLKI, 0);
390
391 write_config_reg(CONTROL_PADCONF_MMC_CLKO, 0);
392
393 write_config_reg(CONTROL_PADCONF_MMC_CMD, 0);
394
395 write_config_reg(CONTROL_PADCONF_MMC_DAT0, 0);
396
397 write_config_reg(CONTROL_PADCONF_MMC_DAT1, 0);
398
399 write_config_reg(CONTROL_PADCONF_MMC_DAT2, 0);
400
401 write_config_reg(CONTROL_PADCONF_MMC_DAT3, 0);
402
403 write_config_reg(CONTROL_PADCONF_MMC_DAT_DIR0, 0);
404
405 write_config_reg(CONTROL_PADCONF_MMC_DAT_DIR1, 0);
406
407 write_config_reg(CONTROL_PADCONF_MMC_DAT_DIR2, 0);
408
409 write_config_reg(CONTROL_PADCONF_MMC_DAT_DIR3, 0);
410
411 write_config_reg(CONTROL_PADCONF_MMC_CMD_DIR, 0);
412}
413
414
415
416
417
418void muxSetupTouchScreen(void)
419{
420
421 write_config_reg(CONTROL_PADCONF_SPI1_CLK, 0);
422
423 write_config_reg(CONTROL_PADCONF_SPI1_SIMO, 0);
424
425 write_config_reg(CONTROL_PADCONF_SPI1_SOMI, 0);
426
427 write_config_reg(CONTROL_PADCONF_SPI1_NCS0, 0);
428#define CONTROL_PADCONF_GPIO85 CONTROL_PADCONF_SPI1_NCS1
429
430 write_config_reg(CONTROL_PADCONF_GPIO85, 3);
431}
432
433
434
435
436
437void muxSetupGPMC(void)
438{
439
440 volatile unsigned int *MCR = (unsigned int *) 0x4800008C;
441 *MCR = 0x19000000;
442
443
444
445 write_config_reg(CONTROL_PADCONF_GPMC_D2_BYTE3, 0);
446
447
448 write_config_reg(CONTROL_PADCONF_GPMC_NCS0_BYTE1, 0);
449
450 write_config_reg(CONTROL_PADCONF_GPMC_NCS0_BYTE2, 0);
451
452 write_config_reg(CONTROL_PADCONF_GPMC_NCS0_BYTE3, 0);
453
454 write_config_reg(CONTROL_PADCONF_GPMC_NCS0_BYTE4, 0);
455
456 write_config_reg(CONTROL_PADCONF_GPMC_NCS0_BYTE5, 0);
457
458 write_config_reg(CONTROL_PADCONF_GPMC_NCS0_BYTE6, 0);
459
460 write_config_reg(CONTROL_PADCONF_GPMC_NCS0_BYTE7, 0);
461}
462
463
464
465
466
467void muxSetupSDRC(void)
468{
469
470}
471