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 | c837dcb | 2004-01-20 23:12:12 +0000 | [diff] [blame] | 36 | int board_early_init_f (void) |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 37 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 38 | out32(GPIO0_OR, CONFIG_SYS_NAND0_CE); /* set initial outputs */ |
| 39 | out32(GPIO0_OR, CONFIG_SYS_NAND1_CE); /* set initial outputs */ |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 40 | |
| 41 | /* |
| 42 | * IRQ 0-15 405GP internally generated; active high; level sensitive |
| 43 | * IRQ 16 405GP internally generated; active low; level sensitive |
| 44 | * IRQ 17-24 RESERVED |
wdenk | e55ca7e | 2004-07-01 21:40:08 +0000 | [diff] [blame] | 45 | * IRQ 25 (EXT IRQ 0) |
| 46 | * IRQ 26 (EXT IRQ 1) |
| 47 | * IRQ 27 (EXT IRQ 2) |
| 48 | * IRQ 28 (EXT IRQ 3) |
| 49 | * IRQ 29 (EXT IRQ 4) |
| 50 | * IRQ 30 (EXT IRQ 5) |
| 51 | * IRQ 31 (EXT IRQ 6) |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 52 | */ |
Stefan Roese | 952e776 | 2009-09-24 09:55:50 +0200 | [diff] [blame] | 53 | mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */ |
| 54 | mtdcr(UIC0ER, 0x00000000); /* disable all ints */ |
| 55 | mtdcr(UIC0CR, 0x00000000); /* set all to be non-critical*/ |
| 56 | mtdcr(UIC0PR, 0xFFFFFF80); /* set int polarities */ |
| 57 | mtdcr(UIC0TR, 0x10000000); /* set int trigger levels */ |
| 58 | mtdcr(UIC0VCR, 0x00000001); /* set vect base=0,INT0 highest priority*/ |
| 59 | mtdcr(UIC0SR, 0xFFFFFFFF); /* clear all ints */ |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 60 | |
| 61 | /* |
| 62 | * EBC Configuration Register: set ready timeout to 512 ebc-clks -> ca. 15 us |
| 63 | */ |
| 64 | #if 1 /* test-only */ |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 65 | mtebc (EBC0_CFG, 0xa8400000); /* ebc always driven */ |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 66 | #else |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 67 | mtebc (EBC0_CFG, 0x28400000); /* ebc in high-z */ |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 68 | #endif |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 69 | return 0; |
| 70 | } |
| 71 | |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 72 | /* ------------------------------------------------------------------------- */ |
| 73 | |
| 74 | int misc_init_f (void) |
| 75 | { |
| 76 | return 0; /* dummy implementation */ |
| 77 | } |
| 78 | |
wdenk | 46a414d | 2004-06-17 18:50:45 +0000 | [diff] [blame] | 79 | extern flash_info_t flash_info[]; /* info for FLASH chips */ |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 80 | |
| 81 | int misc_init_r (void) |
| 82 | { |
wdenk | 46a414d | 2004-06-17 18:50:45 +0000 | [diff] [blame] | 83 | /* adjust flash start and size as well as the offset */ |
| 84 | gd->bd->bi_flashstart = 0 - flash_info[0].size; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 85 | gd->bd->bi_flashoffset= flash_info[0].size - CONFIG_SYS_MONITOR_LEN; |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 86 | #if 0 |
| 87 | volatile unsigned short *fpga_mode = |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 88 | (unsigned short *)((ulong)CONFIG_SYS_FPGA_BASE_ADDR + CONFIG_SYS_FPGA_CTRL); |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 89 | volatile unsigned char *duart0_mcr = |
| 90 | (unsigned char *)((ulong)DUART0_BA + 4); |
| 91 | volatile unsigned char *duart1_mcr = |
| 92 | (unsigned char *)((ulong)DUART1_BA + 4); |
| 93 | |
| 94 | bd_t *bd = gd->bd; |
| 95 | char * tmp; /* Temporary char pointer */ |
| 96 | unsigned char *dst; |
| 97 | ulong len = sizeof(fpgadata); |
| 98 | int status; |
| 99 | int index; |
| 100 | int i; |
Stefan Roese | d1c3b27 | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 101 | unsigned long CPC0_CR0Reg; |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 102 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 103 | dst = malloc(CONFIG_SYS_FPGA_MAX_SIZE); |
| 104 | if (gunzip (dst, CONFIG_SYS_FPGA_MAX_SIZE, (uchar *)fpgadata, &len) != 0) { |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 105 | printf ("GUNZIP ERROR - must RESET board to recover\n"); |
| 106 | do_reset (NULL, 0, 0, NULL); |
| 107 | } |
| 108 | |
| 109 | status = fpga_boot(dst, len); |
| 110 | if (status != 0) { |
| 111 | printf("\nFPGA: Booting failed "); |
| 112 | switch (status) { |
| 113 | case ERROR_FPGA_PRG_INIT_LOW: |
| 114 | printf("(Timeout: INIT not low after asserting PROGRAM*)\n "); |
| 115 | break; |
| 116 | case ERROR_FPGA_PRG_INIT_HIGH: |
| 117 | printf("(Timeout: INIT not high after deasserting PROGRAM*)\n "); |
| 118 | break; |
| 119 | case ERROR_FPGA_PRG_DONE: |
| 120 | printf("(Timeout: DONE not high after programming FPGA)\n "); |
| 121 | break; |
| 122 | } |
| 123 | |
| 124 | /* display infos on fpgaimage */ |
| 125 | index = 15; |
| 126 | for (i=0; i<4; i++) { |
| 127 | len = dst[index]; |
| 128 | printf("FPGA: %s\n", &(dst[index+1])); |
| 129 | index += len+3; |
| 130 | } |
| 131 | putc ('\n'); |
| 132 | /* delayed reboot */ |
| 133 | for (i=20; i>0; i--) { |
| 134 | printf("Rebooting in %2d seconds \r",i); |
| 135 | for (index=0;index<1000;index++) |
| 136 | udelay(1000); |
| 137 | } |
| 138 | putc ('\n'); |
| 139 | do_reset(NULL, 0, 0, NULL); |
| 140 | } |
| 141 | |
| 142 | puts("FPGA: "); |
| 143 | |
| 144 | /* display infos on fpgaimage */ |
| 145 | index = 15; |
| 146 | for (i=0; i<4; i++) { |
| 147 | len = dst[index]; |
| 148 | printf("%s ", &(dst[index+1])); |
| 149 | index += len+3; |
| 150 | } |
| 151 | putc ('\n'); |
| 152 | |
| 153 | free(dst); |
| 154 | |
| 155 | /* |
| 156 | * Reset FPGA via FPGA_DATA pin |
| 157 | */ |
| 158 | SET_FPGA(FPGA_PRG | FPGA_CLK); |
| 159 | udelay(1000); /* wait 1ms */ |
| 160 | SET_FPGA(FPGA_PRG | FPGA_CLK | FPGA_DATA); |
| 161 | udelay(1000); /* wait 1ms */ |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 162 | #endif |
| 163 | |
| 164 | #if 0 |
| 165 | /* |
| 166 | * Enable power on PS/2 interface |
| 167 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 168 | *fpga_mode |= CONFIG_SYS_FPGA_CTRL_PS2_RESET; |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 169 | |
| 170 | /* |
| 171 | * Enable interrupts in exar duart mcr[3] |
| 172 | */ |
| 173 | *duart0_mcr = 0x08; |
| 174 | *duart1_mcr = 0x08; |
| 175 | #endif |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 176 | return (0); |
| 177 | } |
| 178 | |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 179 | /* |
| 180 | * Check Board Identity: |
| 181 | */ |
| 182 | |
| 183 | int checkboard (void) |
| 184 | { |
Wolfgang Denk | 77ddac9 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 185 | char str[64]; |
Wolfgang Denk | cdb7497 | 2010-07-24 21:55:43 +0200 | [diff] [blame] | 186 | int i = getenv_f("serial#", str, sizeof(str)); |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 187 | |
| 188 | puts ("Board: "); |
| 189 | |
| 190 | if (i == -1) { |
| 191 | puts ("### No HW ID - assuming PPChameleonEVB"); |
| 192 | } else { |
| 193 | puts(str); |
| 194 | } |
| 195 | |
| 196 | putc ('\n'); |
| 197 | |
| 198 | return 0; |
| 199 | } |
| 200 | |
| 201 | /* ------------------------------------------------------------------------- */ |
| 202 | |
wdenk | 12f3424 | 2003-09-02 22:48:03 +0000 | [diff] [blame] | 203 | int testdram (void) |
| 204 | { |
| 205 | /* TODO: XXX XXX XXX */ |
| 206 | printf ("test: 16 MB - ok\n"); |
| 207 | |
| 208 | return (0); |
| 209 | } |
| 210 | |
| 211 | /* ------------------------------------------------------------------------- */ |
| 212 | |
wdenk | e55ca7e | 2004-07-01 21:40:08 +0000 | [diff] [blame] | 213 | #ifdef CONFIG_CFB_CONSOLE |
| 214 | # ifdef CONFIG_CONSOLE_EXTRA_INFO |
| 215 | # include <video_fb.h> |
| 216 | extern GraphicDevice smi; |
| 217 | |
| 218 | void video_get_info_str (int line_number, char *info) |
| 219 | { |
| 220 | uint pvr = get_pvr (); |
| 221 | |
| 222 | /* init video info strings for graphic console */ |
| 223 | switch (line_number) { |
| 224 | case 1: |
| 225 | switch (pvr) { |
| 226 | case PVR_405EP_RB: |
Wolfgang Denk | 0c8721a | 2005-09-23 11:05:55 +0200 | [diff] [blame] | 227 | sprintf (info, " AMCC PowerPC 405EP Rev. B"); |
wdenk | e55ca7e | 2004-07-01 21:40:08 +0000 | [diff] [blame] | 228 | break; |
| 229 | default: |
Wolfgang Denk | 0c8721a | 2005-09-23 11:05:55 +0200 | [diff] [blame] | 230 | sprintf (info, " AMCC PowerPC 405EP Rev. <unknown>"); |
wdenk | e55ca7e | 2004-07-01 21:40:08 +0000 | [diff] [blame] | 231 | break; |
| 232 | } |
| 233 | return; |
| 234 | case 2: |
| 235 | sprintf (info, " DAVE Srl PPChameleonEVB - www.dave-tech.it"); |
| 236 | return; |
| 237 | case 3: |
| 238 | sprintf (info, " %s", smi.modeIdent); |
| 239 | return; |
| 240 | } |
| 241 | |
| 242 | /* no more info lines */ |
| 243 | *info = 0; |
| 244 | return; |
| 245 | } |
| 246 | # endif /* CONFIG_CONSOLE_EXTRA_INFO */ |
| 247 | #endif /* CONFIG_CFB_CONSOLE */ |