stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) Copyright 2004 |
| 3 | * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com |
| 4 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 5 | * SPDX-License-Identifier: GPL-2.0+ |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
| 8 | #include <common.h> |
| 9 | #include <asm/processor.h> |
| 10 | #include <command.h> |
| 11 | |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 12 | #define MEM_MCOPT1_INIT_VAL 0x00800000 |
| 13 | #define MEM_RTR_INIT_VAL 0x04070000 |
| 14 | #define MEM_PMIT_INIT_VAL 0x07c00000 |
| 15 | #define MEM_MB0CF_INIT_VAL 0x00082001 |
| 16 | #define MEM_MB1CF_INIT_VAL 0x04082000 |
| 17 | #define MEM_SDTR1_INIT_VAL 0x00854005 |
| 18 | #define SDRAM0_CFG_ENABLE 0x80000000 |
| 19 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 20 | #define CONFIG_SYS_SDRAM_SIZE 0x04000000 /* 64 MB */ |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 21 | |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 22 | int board_early_init_f (void) |
| 23 | { |
| 24 | #if 0 /* test-only */ |
Stefan Roese | 707fd36 | 2009-09-24 09:55:50 +0200 | [diff] [blame] | 25 | mtdcr (UIC0SR, 0xFFFFFFFF); /* clear all ints */ |
| 26 | mtdcr (UIC0ER, 0x00000000); /* disable all ints */ |
| 27 | mtdcr (UIC0CR, 0x00000010); |
| 28 | mtdcr (UIC0PR, 0xFFFF7FF0); /* set int polarities */ |
| 29 | mtdcr (UIC0TR, 0x00000010); /* set int trigger levels */ |
| 30 | mtdcr (UIC0SR, 0xFFFFFFFF); /* clear all ints */ |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 31 | #else |
Stefan Roese | 707fd36 | 2009-09-24 09:55:50 +0200 | [diff] [blame] | 32 | mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */ |
| 33 | mtdcr(UIC0ER, 0x00000000); /* disable all ints */ |
| 34 | mtdcr(UIC0CR, 0x00000000); /* set all to be non-critical*/ |
| 35 | mtdcr(UIC0PR, 0xFFFFFFF0); /* set int polarities */ |
| 36 | mtdcr(UIC0TR, 0x10000000); /* set int trigger levels */ |
| 37 | mtdcr(UIC0VCR, 0x00000001); /* set vect base=0,INT0 highest priority*/ |
| 38 | mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */ |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 39 | #endif |
| 40 | |
| 41 | #if 1 /* test-only */ |
| 42 | /* |
| 43 | * EBC Configuration Register: set ready timeout to 512 ebc-clks -> ca. 15 us |
| 44 | */ |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 45 | mtebc (EBC0_CFG, 0xa8400000); /* ebc always driven */ |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 46 | #endif |
| 47 | |
| 48 | return 0; |
| 49 | } |
| 50 | |
| 51 | |
| 52 | int misc_init_f (void) |
| 53 | { |
| 54 | return 0; /* dummy implementation */ |
| 55 | } |
| 56 | |
| 57 | |
| 58 | int misc_init_r (void) |
| 59 | { |
Jon Loeliger | 96892a9 | 2007-07-09 18:31:28 -0500 | [diff] [blame] | 60 | #if defined(CONFIG_CMD_NAND) |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 61 | /* |
| 62 | * Set NAND-FLASH GPIO signals to default |
| 63 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 64 | out32(GPIO0_OR, in32(GPIO0_OR) & ~(CONFIG_SYS_NAND_CLE | CONFIG_SYS_NAND_ALE)); |
| 65 | out32(GPIO0_OR, in32(GPIO0_OR) | CONFIG_SYS_NAND_CE); |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 66 | #endif |
| 67 | |
| 68 | return (0); |
| 69 | } |
| 70 | |
| 71 | |
| 72 | /* |
| 73 | * Check Board Identity: |
| 74 | */ |
| 75 | int checkboard (void) |
| 76 | { |
Wolfgang Denk | 7fb5266 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 77 | char str[64]; |
Wolfgang Denk | 76af278 | 2010-07-24 21:55:43 +0200 | [diff] [blame] | 78 | int i = getenv_f("serial#", str, sizeof(str)); |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 79 | |
| 80 | puts ("Board: "); |
| 81 | |
| 82 | if (i == -1) { |
| 83 | puts ("### No HW ID - assuming G2000"); |
| 84 | } else { |
| 85 | puts(str); |
| 86 | } |
| 87 | |
| 88 | putc ('\n'); |
| 89 | |
| 90 | return 0; |
| 91 | } |
| 92 | |
| 93 | |
| 94 | /* ------------------------------------------------------------------------- |
| 95 | G2000 rev B is an embeded design. we don't read for spd of this version. |
| 96 | Doing static SDRAM controller configuration in the following section. |
| 97 | ------------------------------------------------------------------------- */ |
| 98 | |
| 99 | long int init_sdram_static_settings(void) |
| 100 | { |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 101 | /* disable memcontroller so updates work */ |
Stefan Roese | 8f9cdda | 2009-09-24 14:10:30 +0200 | [diff] [blame] | 102 | mtsdram(SDRAM0_CFG, MEM_MCOPT1_INIT_VAL); |
| 103 | mtsdram(SDRAM0_RTR, MEM_RTR_INIT_VAL); |
| 104 | mtsdram(SDRAM0_PMIT, MEM_PMIT_INIT_VAL); |
| 105 | mtsdram(SDRAM0_B0CR, MEM_MB0CF_INIT_VAL); |
| 106 | mtsdram(SDRAM0_B1CR, MEM_MB1CF_INIT_VAL); |
| 107 | mtsdram(SDRAM0_TR, MEM_SDTR1_INIT_VAL); |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 108 | |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 109 | /* SDRAM have a power on delay, 500 micro should do */ |
| 110 | udelay(500); |
Stefan Roese | 8f9cdda | 2009-09-24 14:10:30 +0200 | [diff] [blame] | 111 | mtsdram(SDRAM0_CFG, MEM_MCOPT1_INIT_VAL|SDRAM0_CFG_ENABLE); |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 112 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 113 | return (CONFIG_SYS_SDRAM_SIZE); /* CONFIG_SYS_SDRAM_SIZE is in G2000.h */ |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 114 | } |
| 115 | |
| 116 | |
Becky Bruce | bd99ae7 | 2008-06-09 16:03:40 -0500 | [diff] [blame] | 117 | phys_size_t initdram (int board_type) |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 118 | { |
| 119 | long int ret; |
| 120 | |
| 121 | /* flzt, we can still turn this on in the future */ |
| 122 | /* #ifdef CONFIG_SPD_EEPROM |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 123 | ret = spd_sdram (); |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 124 | #else |
wdenk | 07d7e6b | 2004-12-16 21:44:03 +0000 | [diff] [blame] | 125 | ret = init_sdram_static_settings(); |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 126 | #endif |
| 127 | */ |
| 128 | |
| 129 | ret = init_sdram_static_settings(); |
| 130 | |
| 131 | return ret; |
| 132 | } |
| 133 | |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 134 | #if 0 /* test-only !!! */ |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 135 | int do_dumpebc(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 136 | { |
| 137 | ulong ap, cr; |
| 138 | |
| 139 | printf("\nEBC registers for PPC405GP:\n"); |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 140 | mfebc(PB0AP, ap); mfebc(PB0CR, cr); |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 141 | printf("0: AP=%08lx CP=%08lx\n", ap, cr); |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 142 | mfebc(PB1AP, ap); mfebc(PB1CR, cr); |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 143 | printf("1: AP=%08lx CP=%08lx\n", ap, cr); |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 144 | mfebc(PB2AP, ap); mfebc(PB2CR, cr); |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 145 | printf("2: AP=%08lx CP=%08lx\n", ap, cr); |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 146 | mfebc(PB3AP, ap); mfebc(PB3CR, cr); |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 147 | printf("3: AP=%08lx CP=%08lx\n", ap, cr); |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 148 | mfebc(PB4AP, ap); mfebc(PB4CR, cr); |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 149 | printf("4: AP=%08lx CP=%08lx\n", ap, cr); |
| 150 | printf("\n"); |
| 151 | |
| 152 | return 0; |
| 153 | } |
| 154 | U_BOOT_CMD( |
| 155 | dumpebc, 1, 1, do_dumpebc, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 156 | "Dump all EBC registers", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 157 | "" |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 158 | ); |
| 159 | |
| 160 | |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 161 | int do_dumpdcr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 162 | { |
| 163 | int i; |
| 164 | |
| 165 | printf("\nDevice Configuration Registers (DCR's) for PPC405GP:"); |
| 166 | for (i=0; i<=0x1e0; i++) { |
| 167 | if (!(i % 0x8)) { |
| 168 | printf("\n%04x ", i); |
| 169 | } |
| 170 | printf("%08lx ", get_dcr(i)); |
| 171 | } |
| 172 | printf("\n"); |
| 173 | |
| 174 | return 0; |
| 175 | } |
| 176 | U_BOOT_CMD( |
| 177 | dumpdcr, 1, 1, do_dumpdcr, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 178 | "Dump all DCR registers", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 179 | "" |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 180 | ); |
| 181 | |
| 182 | |
Wolfgang Denk | 6262d021 | 2010-06-28 22:00:46 +0200 | [diff] [blame] | 183 | int do_dumpspr(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 184 | { |
| 185 | printf("\nSpecial Purpose Registers (SPR's) for PPC405GP:"); |
| 186 | printf("\n%04x %08x ", 947, mfspr(947)); |
| 187 | printf("\n%04x %08x ", 9, mfspr(9)); |
| 188 | printf("\n%04x %08x ", 1014, mfspr(1014)); |
| 189 | printf("\n%04x %08x ", 1015, mfspr(1015)); |
| 190 | printf("\n%04x %08x ", 1010, mfspr(1010)); |
| 191 | printf("\n%04x %08x ", 957, mfspr(957)); |
| 192 | printf("\n%04x %08x ", 1008, mfspr(1008)); |
| 193 | printf("\n%04x %08x ", 1018, mfspr(1018)); |
| 194 | printf("\n%04x %08x ", 954, mfspr(954)); |
| 195 | printf("\n%04x %08x ", 950, mfspr(950)); |
| 196 | printf("\n%04x %08x ", 951, mfspr(951)); |
| 197 | printf("\n%04x %08x ", 981, mfspr(981)); |
| 198 | printf("\n%04x %08x ", 980, mfspr(980)); |
| 199 | printf("\n%04x %08x ", 982, mfspr(982)); |
| 200 | printf("\n%04x %08x ", 1012, mfspr(1012)); |
| 201 | printf("\n%04x %08x ", 1013, mfspr(1013)); |
| 202 | printf("\n%04x %08x ", 948, mfspr(948)); |
| 203 | printf("\n%04x %08x ", 949, mfspr(949)); |
| 204 | printf("\n%04x %08x ", 1019, mfspr(1019)); |
| 205 | printf("\n%04x %08x ", 979, mfspr(979)); |
| 206 | printf("\n%04x %08x ", 8, mfspr(8)); |
| 207 | printf("\n%04x %08x ", 945, mfspr(945)); |
| 208 | printf("\n%04x %08x ", 987, mfspr(987)); |
| 209 | printf("\n%04x %08x ", 287, mfspr(287)); |
| 210 | printf("\n%04x %08x ", 953, mfspr(953)); |
| 211 | printf("\n%04x %08x ", 955, mfspr(955)); |
| 212 | printf("\n%04x %08x ", 272, mfspr(272)); |
| 213 | printf("\n%04x %08x ", 273, mfspr(273)); |
| 214 | printf("\n%04x %08x ", 274, mfspr(274)); |
| 215 | printf("\n%04x %08x ", 275, mfspr(275)); |
| 216 | printf("\n%04x %08x ", 260, mfspr(260)); |
| 217 | printf("\n%04x %08x ", 276, mfspr(276)); |
| 218 | printf("\n%04x %08x ", 261, mfspr(261)); |
| 219 | printf("\n%04x %08x ", 277, mfspr(277)); |
| 220 | printf("\n%04x %08x ", 262, mfspr(262)); |
| 221 | printf("\n%04x %08x ", 278, mfspr(278)); |
| 222 | printf("\n%04x %08x ", 263, mfspr(263)); |
| 223 | printf("\n%04x %08x ", 279, mfspr(279)); |
| 224 | printf("\n%04x %08x ", 26, mfspr(26)); |
| 225 | printf("\n%04x %08x ", 27, mfspr(27)); |
| 226 | printf("\n%04x %08x ", 990, mfspr(990)); |
| 227 | printf("\n%04x %08x ", 991, mfspr(991)); |
| 228 | printf("\n%04x %08x ", 956, mfspr(956)); |
| 229 | printf("\n%04x %08x ", 284, mfspr(284)); |
| 230 | printf("\n%04x %08x ", 285, mfspr(285)); |
| 231 | printf("\n%04x %08x ", 986, mfspr(986)); |
| 232 | printf("\n%04x %08x ", 984, mfspr(984)); |
| 233 | printf("\n%04x %08x ", 256, mfspr(256)); |
| 234 | printf("\n%04x %08x ", 1, mfspr(1)); |
| 235 | printf("\n%04x %08x ", 944, mfspr(944)); |
| 236 | printf("\n"); |
| 237 | |
| 238 | return 0; |
| 239 | } |
| 240 | U_BOOT_CMD( |
| 241 | dumpspr, 1, 1, do_dumpspr, |
Peter Tyser | dfb72b8 | 2009-01-27 18:03:12 -0600 | [diff] [blame] | 242 | "Dump all SPR registers", |
Wolfgang Denk | c54781c | 2009-05-24 17:06:54 +0200 | [diff] [blame] | 243 | "" |
stroese | 842053a | 2004-12-16 18:17:50 +0000 | [diff] [blame] | 244 | ); |
| 245 | #endif |