]>
Commit | Line | Data |
---|---|---|
cf959c7d SR |
1 | /* |
2 | * (C) Copyright 2007 | |
3 | * Stefan Roese, DENX Software Engineering, sr@denx.de. | |
4 | * | |
1a459660 | 5 | * SPDX-License-Identifier: GPL-2.0+ |
cf959c7d SR |
6 | */ |
7 | ||
8 | #include <common.h> | |
b36df561 | 9 | #include <asm/ppc4xx.h> |
cf959c7d SR |
10 | #include <asm/processor.h> |
11 | #include <asm/io.h> | |
12 | ||
13 | static void wait_init_complete(void) | |
14 | { | |
15 | u32 val; | |
16 | ||
17 | do { | |
95b602ba | 18 | mfsdram(SDRAM0_MCSTS, val); |
cf959c7d SR |
19 | } while (!(val & 0x80000000)); |
20 | } | |
21 | ||
22 | /* | |
9973e3c6 | 23 | * phys_size_t initdram(int board_type) |
cf959c7d SR |
24 | * |
25 | * As the name already indicates, this function is called very early | |
26 | * from start.S and configures the SDRAM with fixed values. This is needed, | |
27 | * since the 440EP has no internal SRAM and the 4kB NAND_SPL loader has | |
28 | * not enough free space to implement the complete I2C SPD DDR autodetection | |
29 | * routines. Therefore the Bamboo only supports the onboard 64MBytes of SDRAM | |
30 | * when booting from NAND flash. | |
9f798766 EB |
31 | * |
32 | * Note: | |
33 | * As found out by Eugene O'Brien <eugene.obrien@advantechamt.com>, the fixed | |
34 | * DDR setup has problems (U-Boot crashes randomly upon TFTP), when the DIMM | |
35 | * modules are still plugged in. So it is recommended to remove the DIMM | |
36 | * modules while using the NAND booting code with the fixed SDRAM setup! | |
cf959c7d | 37 | */ |
9973e3c6 | 38 | phys_size_t initdram(int board_type) |
cf959c7d SR |
39 | { |
40 | /* | |
41 | * Soft-reset SDRAM controller. | |
42 | */ | |
d1c3b275 SR |
43 | mtsdr(SDR0_SRST, SDR0_SRST_DMC); |
44 | mtsdr(SDR0_SRST, 0x00000000); | |
cf959c7d SR |
45 | |
46 | /* | |
47 | * Disable memory controller. | |
48 | */ | |
95b602ba | 49 | mtsdram(SDRAM0_CFG0, 0x00000000); |
cf959c7d SR |
50 | |
51 | /* | |
52 | * Setup some default | |
53 | */ | |
95b602ba SR |
54 | mtsdram(SDRAM0_UABBA, 0x00000000); /* ubba=0 (default) */ |
55 | mtsdram(SDRAM0_SLIO, 0x00000000); /* rdre=0 wrre=0 rarw=0 */ | |
56 | mtsdram(SDRAM0_DEVOPT, 0x00000000); /* dll=0 ds=0 (normal) */ | |
57 | mtsdram(SDRAM0_WDDCTR, 0x00000000); /* wrcp=0 dcd=0 */ | |
58 | mtsdram(SDRAM0_CLKTR, 0x40000000); /* clkp=1 (90 deg wr) dcdt=0 */ | |
cf959c7d SR |
59 | |
60 | /* | |
61 | * Following for CAS Latency = 2.5 @ 133 MHz PLB | |
62 | */ | |
95b602ba SR |
63 | mtsdram(SDRAM0_B0CR, 0x00082001); |
64 | mtsdram(SDRAM0_TR0, 0x41094012); | |
65 | mtsdram(SDRAM0_TR1, 0x8080083d); /* SS=T2 SL=STAGE 3 CD=1 CT=0x00*/ | |
fa82f871 | 66 | mtsdram(SDRAM0_RTR, 0x04100000); /* Interval 7.8µs @ 133MHz PLB */ |
95b602ba | 67 | mtsdram(SDRAM0_CFG1, 0x00000000); /* Self-refresh exit, disable PM*/ |
cf959c7d SR |
68 | |
69 | /* | |
70 | * Enable the controller, then wait for DCEN to complete | |
71 | */ | |
95b602ba | 72 | mtsdram(SDRAM0_CFG0, 0x80000000); /* DCEN=1, PMUD=0*/ |
cf959c7d | 73 | wait_init_complete(); |
cf959c7d | 74 | |
6d0f6bcf | 75 | return CONFIG_SYS_MBYTES_SDRAM << 20; |
cf959c7d | 76 | } |