wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 1 | /* |
wdenk | 180d3f7 | 2004-01-04 16:28:35 +0000 | [diff] [blame] | 2 | * (C) Copyright 2003 |
| 3 | * DAVE Srl |
| 4 | * http://www.dave-tech.it |
| 5 | * http://www.wawnet.biz |
| 6 | * mailto:info@wawnet.biz |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 7 | * |
| 8 | * See file CREDITS for list of people who contributed to this |
| 9 | * project. |
| 10 | * |
| 11 | * This program is free software; you can redistribute it and/or |
| 12 | * modify it under the terms of the GNU General Public License as |
| 13 | * published by the Free Software Foundation; either version 2 of |
| 14 | * the License, or (at your option) any later version. |
| 15 | * |
| 16 | * This program is distributed in the hope that it will be useful, |
| 17 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 18 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 19 | * GNU General Public License for more details. |
| 20 | * |
| 21 | * You should have received a copy of the GNU General Public License |
| 22 | * along with this program; if not, write to the Free Software |
| 23 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 24 | * MA 02111-1307 USA |
| 25 | */ |
| 26 | |
| 27 | #include <common.h> |
| 28 | #include <asm/processor.h> |
| 29 | #include <command.h> |
| 30 | #include <malloc.h> |
| 31 | |
Wolfgang Denk | d87080b | 2006-03-31 18:32:53 +0200 | [diff] [blame^] | 32 | DECLARE_GLOBAL_DATA_PTR; |
| 33 | |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 34 | /* ------------------------------------------------------------------------- */ |
| 35 | |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 36 | /* Prototypes */ |
wdenk | eedcd07 | 2004-09-08 22:03:11 +0000 | [diff] [blame] | 37 | int gunzip(void *, int, unsigned char *, unsigned long *); |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 38 | |
wdenk | c837dcb | 2004-01-20 23:12:12 +0000 | [diff] [blame] | 39 | int board_early_init_f (void) |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 40 | { |
| 41 | out32(GPIO0_OR, CFG_NAND0_CE); /* set initial outputs */ |
wdenk | 42d1f03 | 2003-10-15 23:53:47 +0000 | [diff] [blame] | 42 | out32(GPIO0_OR, CFG_NAND1_CE); /* set initial outputs */ |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 43 | |
| 44 | /* |
| 45 | * IRQ 0-15 405GP internally generated; active high; level sensitive |
| 46 | * IRQ 16 405GP internally generated; active low; level sensitive |
| 47 | * IRQ 17-24 RESERVED |
wdenk | e55ca7e | 2004-07-01 21:40:08 +0000 | [diff] [blame] | 48 | * IRQ 25 (EXT IRQ 0) |
| 49 | * IRQ 26 (EXT IRQ 1) |
| 50 | * IRQ 27 (EXT IRQ 2) |
| 51 | * IRQ 28 (EXT IRQ 3) |
| 52 | * IRQ 29 (EXT IRQ 4) |
| 53 | * IRQ 30 (EXT IRQ 5) |
| 54 | * IRQ 31 (EXT IRQ 6) |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 55 | */ |
| 56 | mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */ |
| 57 | mtdcr(uicer, 0x00000000); /* disable all ints */ |
| 58 | mtdcr(uiccr, 0x00000000); /* set all to be non-critical*/ |
wdenk | 4654af2 | 2003-10-22 09:00:28 +0000 | [diff] [blame] | 59 | mtdcr(uicpr, 0xFFFFFF80); /* set int polarities */ |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 60 | mtdcr(uictr, 0x10000000); /* set int trigger levels */ |
| 61 | mtdcr(uicvcr, 0x00000001); /* set vect base=0,INT0 highest priority*/ |
| 62 | mtdcr(uicsr, 0xFFFFFFFF); /* clear all ints */ |
| 63 | |
| 64 | /* |
| 65 | * EBC Configuration Register: set ready timeout to 512 ebc-clks -> ca. 15 us |
| 66 | */ |
| 67 | #if 1 /* test-only */ |
| 68 | mtebc (epcr, 0xa8400000); /* ebc always driven */ |
| 69 | #else |
| 70 | mtebc (epcr, 0x28400000); /* ebc in high-z */ |
| 71 | #endif |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 72 | return 0; |
| 73 | } |
| 74 | |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 75 | /* ------------------------------------------------------------------------- */ |
| 76 | |
| 77 | int misc_init_f (void) |
| 78 | { |
| 79 | return 0; /* dummy implementation */ |
| 80 | } |
| 81 | |
wdenk | 46a414d | 2004-06-17 18:50:45 +0000 | [diff] [blame] | 82 | extern flash_info_t flash_info[]; /* info for FLASH chips */ |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 83 | |
| 84 | int misc_init_r (void) |
| 85 | { |
wdenk | 46a414d | 2004-06-17 18:50:45 +0000 | [diff] [blame] | 86 | /* adjust flash start and size as well as the offset */ |
| 87 | gd->bd->bi_flashstart = 0 - flash_info[0].size; |
| 88 | gd->bd->bi_flashoffset= flash_info[0].size - CFG_MONITOR_LEN; |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 89 | #if 0 |
| 90 | volatile unsigned short *fpga_mode = |
| 91 | (unsigned short *)((ulong)CFG_FPGA_BASE_ADDR + CFG_FPGA_CTRL); |
| 92 | volatile unsigned char *duart0_mcr = |
| 93 | (unsigned char *)((ulong)DUART0_BA + 4); |
| 94 | volatile unsigned char *duart1_mcr = |
| 95 | (unsigned char *)((ulong)DUART1_BA + 4); |
| 96 | |
| 97 | bd_t *bd = gd->bd; |
| 98 | char * tmp; /* Temporary char pointer */ |
| 99 | unsigned char *dst; |
| 100 | ulong len = sizeof(fpgadata); |
| 101 | int status; |
| 102 | int index; |
| 103 | int i; |
| 104 | unsigned long cntrl0Reg; |
| 105 | |
| 106 | dst = malloc(CFG_FPGA_MAX_SIZE); |
wdenk | eedcd07 | 2004-09-08 22:03:11 +0000 | [diff] [blame] | 107 | if (gunzip (dst, CFG_FPGA_MAX_SIZE, (uchar *)fpgadata, &len) != 0) { |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 108 | printf ("GUNZIP ERROR - must RESET board to recover\n"); |
| 109 | do_reset (NULL, 0, 0, NULL); |
| 110 | } |
| 111 | |
| 112 | status = fpga_boot(dst, len); |
| 113 | if (status != 0) { |
| 114 | printf("\nFPGA: Booting failed "); |
| 115 | switch (status) { |
| 116 | case ERROR_FPGA_PRG_INIT_LOW: |
| 117 | printf("(Timeout: INIT not low after asserting PROGRAM*)\n "); |
| 118 | break; |
| 119 | case ERROR_FPGA_PRG_INIT_HIGH: |
| 120 | printf("(Timeout: INIT not high after deasserting PROGRAM*)\n "); |
| 121 | break; |
| 122 | case ERROR_FPGA_PRG_DONE: |
| 123 | printf("(Timeout: DONE not high after programming FPGA)\n "); |
| 124 | break; |
| 125 | } |
| 126 | |
| 127 | /* display infos on fpgaimage */ |
| 128 | index = 15; |
| 129 | for (i=0; i<4; i++) { |
| 130 | len = dst[index]; |
| 131 | printf("FPGA: %s\n", &(dst[index+1])); |
| 132 | index += len+3; |
| 133 | } |
| 134 | putc ('\n'); |
| 135 | /* delayed reboot */ |
| 136 | for (i=20; i>0; i--) { |
| 137 | printf("Rebooting in %2d seconds \r",i); |
| 138 | for (index=0;index<1000;index++) |
| 139 | udelay(1000); |
| 140 | } |
| 141 | putc ('\n'); |
| 142 | do_reset(NULL, 0, 0, NULL); |
| 143 | } |
| 144 | |
| 145 | puts("FPGA: "); |
| 146 | |
| 147 | /* display infos on fpgaimage */ |
| 148 | index = 15; |
| 149 | for (i=0; i<4; i++) { |
| 150 | len = dst[index]; |
| 151 | printf("%s ", &(dst[index+1])); |
| 152 | index += len+3; |
| 153 | } |
| 154 | putc ('\n'); |
| 155 | |
| 156 | free(dst); |
| 157 | |
| 158 | /* |
| 159 | * Reset FPGA via FPGA_DATA pin |
| 160 | */ |
| 161 | SET_FPGA(FPGA_PRG | FPGA_CLK); |
| 162 | udelay(1000); /* wait 1ms */ |
| 163 | SET_FPGA(FPGA_PRG | FPGA_CLK | FPGA_DATA); |
| 164 | udelay(1000); /* wait 1ms */ |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 165 | #endif |
| 166 | |
| 167 | #if 0 |
| 168 | /* |
| 169 | * Enable power on PS/2 interface |
| 170 | */ |
| 171 | *fpga_mode |= CFG_FPGA_CTRL_PS2_RESET; |
| 172 | |
| 173 | /* |
| 174 | * Enable interrupts in exar duart mcr[3] |
| 175 | */ |
| 176 | *duart0_mcr = 0x08; |
| 177 | *duart1_mcr = 0x08; |
| 178 | #endif |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 179 | return (0); |
| 180 | } |
| 181 | |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 182 | /* |
| 183 | * Check Board Identity: |
| 184 | */ |
| 185 | |
| 186 | int checkboard (void) |
| 187 | { |
Wolfgang Denk | 77ddac9 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 188 | char str[64]; |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 189 | int i = getenv_r ("serial#", str, sizeof(str)); |
| 190 | |
| 191 | puts ("Board: "); |
| 192 | |
| 193 | if (i == -1) { |
| 194 | puts ("### No HW ID - assuming PPChameleonEVB"); |
| 195 | } else { |
| 196 | puts(str); |
| 197 | } |
| 198 | |
| 199 | putc ('\n'); |
| 200 | |
| 201 | return 0; |
| 202 | } |
| 203 | |
| 204 | /* ------------------------------------------------------------------------- */ |
| 205 | |
| 206 | long int initdram (int board_type) |
| 207 | { |
| 208 | unsigned long val; |
| 209 | |
| 210 | mtdcr(memcfga, mem_mb0cf); |
| 211 | val = mfdcr(memcfgd); |
| 212 | |
| 213 | #if 0 /* test-only */ |
| 214 | for (;;) { |
| 215 | NAND_DISABLE_CE(1); |
| 216 | udelay(100); |
| 217 | NAND_ENABLE_CE(1); |
| 218 | udelay(100); |
| 219 | } |
| 220 | #endif |
| 221 | #if 0 |
| 222 | printf("\nmb0cf=%x\n", val); /* test-only */ |
| 223 | printf("strap=%x\n", mfdcr(strap)); /* test-only */ |
| 224 | #endif |
| 225 | |
| 226 | return (4*1024*1024 << ((val & 0x000e0000) >> 17)); |
| 227 | } |
| 228 | |
| 229 | /* ------------------------------------------------------------------------- */ |
| 230 | |
| 231 | int testdram (void) |
| 232 | { |
| 233 | /* TODO: XXX XXX XXX */ |
| 234 | printf ("test: 16 MB - ok\n"); |
| 235 | |
| 236 | return (0); |
| 237 | } |
| 238 | |
| 239 | /* ------------------------------------------------------------------------- */ |
| 240 | |
wdenk | e55ca7e | 2004-07-01 21:40:08 +0000 | [diff] [blame] | 241 | #ifdef CONFIG_CFB_CONSOLE |
| 242 | # ifdef CONFIG_CONSOLE_EXTRA_INFO |
| 243 | # include <video_fb.h> |
| 244 | extern GraphicDevice smi; |
| 245 | |
| 246 | void video_get_info_str (int line_number, char *info) |
| 247 | { |
| 248 | uint pvr = get_pvr (); |
| 249 | |
| 250 | /* init video info strings for graphic console */ |
| 251 | switch (line_number) { |
| 252 | case 1: |
| 253 | switch (pvr) { |
| 254 | case PVR_405EP_RB: |
Wolfgang Denk | 0c8721a | 2005-09-23 11:05:55 +0200 | [diff] [blame] | 255 | sprintf (info, " AMCC PowerPC 405EP Rev. B"); |
wdenk | e55ca7e | 2004-07-01 21:40:08 +0000 | [diff] [blame] | 256 | break; |
| 257 | default: |
Wolfgang Denk | 0c8721a | 2005-09-23 11:05:55 +0200 | [diff] [blame] | 258 | sprintf (info, " AMCC PowerPC 405EP Rev. <unknown>"); |
wdenk | e55ca7e | 2004-07-01 21:40:08 +0000 | [diff] [blame] | 259 | break; |
| 260 | } |
| 261 | return; |
| 262 | case 2: |
| 263 | sprintf (info, " DAVE Srl PPChameleonEVB - www.dave-tech.it"); |
| 264 | return; |
| 265 | case 3: |
| 266 | sprintf (info, " %s", smi.modeIdent); |
| 267 | return; |
| 268 | } |
| 269 | |
| 270 | /* no more info lines */ |
| 271 | *info = 0; |
| 272 | return; |
| 273 | } |
| 274 | # endif /* CONFIG_CONSOLE_EXTRA_INFO */ |
| 275 | #endif /* CONFIG_CFB_CONSOLE */ |