wdenk | 153d511 | 2002-08-30 11:07:04 +0000 | [diff] [blame] | 1 | /* |
stroese | 0191b3c | 2004-09-16 12:34:51 +0000 | [diff] [blame^] | 2 | * (C) Copyright 2001-2004 |
wdenk | 153d511 | 2002-08-30 11:07:04 +0000 | [diff] [blame] | 3 | * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com |
| 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | * |
| 13 | * This program is distributed in the hope that it will be useful, |
| 14 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 | * GNU General Public License for more details. |
| 17 | * |
| 18 | * You should have received a copy of the GNU General Public License |
| 19 | * along with this program; if not, write to the Free Software |
| 20 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 21 | * MA 02111-1307 USA |
| 22 | */ |
| 23 | |
| 24 | #include <common.h> |
| 25 | #include "ar405.h" |
| 26 | #include <asm/processor.h> |
| 27 | #include <command.h> |
wdenk | 153d511 | 2002-08-30 11:07:04 +0000 | [diff] [blame] | 28 | |
wdenk | 57b2d80 | 2003-06-27 21:31:46 +0000 | [diff] [blame] | 29 | /*cmd_boot.c*/ |
| 30 | extern int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[]); |
stroese | 0191b3c | 2004-09-16 12:34:51 +0000 | [diff] [blame^] | 31 | extern void lxt971_no_sleep(void); |
wdenk | 153d511 | 2002-08-30 11:07:04 +0000 | [diff] [blame] | 32 | |
| 33 | /* ------------------------------------------------------------------------- */ |
| 34 | |
| 35 | #if 0 |
| 36 | #define FPGA_DEBUG |
| 37 | #endif |
| 38 | |
| 39 | /* fpga configuration data - generated by bin2cc */ |
| 40 | const unsigned char fpgadata[] = { |
| 41 | #include "fpgadata.c" |
| 42 | }; |
| 43 | |
stroese | 0191b3c | 2004-09-16 12:34:51 +0000 | [diff] [blame^] | 44 | const unsigned char fpgadata_xl30[] = { |
| 45 | #include "fpgadata_xl30.c" |
| 46 | }; |
| 47 | |
wdenk | 153d511 | 2002-08-30 11:07:04 +0000 | [diff] [blame] | 48 | /* |
| 49 | * include common fpga code (for esd boards) |
| 50 | */ |
| 51 | #include "../common/fpga.c" |
| 52 | |
| 53 | |
wdenk | da55c6e | 2004-01-20 23:12:12 +0000 | [diff] [blame] | 54 | int board_early_init_f (void) |
wdenk | 153d511 | 2002-08-30 11:07:04 +0000 | [diff] [blame] | 55 | { |
| 56 | DECLARE_GLOBAL_DATA_PTR; |
| 57 | |
| 58 | int index, len, i; |
| 59 | int status; |
| 60 | |
| 61 | #ifdef FPGA_DEBUG |
| 62 | /* set up serial port with default baudrate */ |
| 63 | (void) get_clocks (); |
| 64 | gd->baudrate = CONFIG_BAUDRATE; |
| 65 | serial_init (); |
| 66 | console_init_f (); |
| 67 | #endif |
| 68 | |
| 69 | /* |
| 70 | * Boot onboard FPGA |
| 71 | */ |
stroese | 0191b3c | 2004-09-16 12:34:51 +0000 | [diff] [blame^] | 72 | /* first try 40er image */ |
| 73 | gd->board_type = 40; |
wdenk | 153d511 | 2002-08-30 11:07:04 +0000 | [diff] [blame] | 74 | status = fpga_boot ((unsigned char *) fpgadata, sizeof (fpgadata)); |
| 75 | if (status != 0) { |
stroese | 0191b3c | 2004-09-16 12:34:51 +0000 | [diff] [blame^] | 76 | /* try xl30er image */ |
| 77 | gd->board_type = 30; |
| 78 | status = fpga_boot ((unsigned char *) fpgadata_xl30, sizeof (fpgadata_xl30)); |
| 79 | if (status != 0) { |
| 80 | /* booting FPGA failed */ |
wdenk | 153d511 | 2002-08-30 11:07:04 +0000 | [diff] [blame] | 81 | #ifndef FPGA_DEBUG |
stroese | 0191b3c | 2004-09-16 12:34:51 +0000 | [diff] [blame^] | 82 | /* set up serial port with default baudrate */ |
| 83 | (void) get_clocks (); |
| 84 | gd->baudrate = CONFIG_BAUDRATE; |
| 85 | serial_init (); |
| 86 | console_init_f (); |
wdenk | 153d511 | 2002-08-30 11:07:04 +0000 | [diff] [blame] | 87 | #endif |
stroese | 0191b3c | 2004-09-16 12:34:51 +0000 | [diff] [blame^] | 88 | printf ("\nFPGA: Booting failed "); |
| 89 | switch (status) { |
| 90 | case ERROR_FPGA_PRG_INIT_LOW: |
| 91 | printf ("(Timeout: INIT not low after asserting PROGRAM*)\n "); |
| 92 | break; |
| 93 | case ERROR_FPGA_PRG_INIT_HIGH: |
| 94 | printf ("(Timeout: INIT not high after deasserting PROGRAM*)\n "); |
| 95 | break; |
| 96 | case ERROR_FPGA_PRG_DONE: |
| 97 | printf ("(Timeout: DONE not high after programming FPGA)\n "); |
| 98 | break; |
| 99 | } |
wdenk | 153d511 | 2002-08-30 11:07:04 +0000 | [diff] [blame] | 100 | |
stroese | 0191b3c | 2004-09-16 12:34:51 +0000 | [diff] [blame^] | 101 | /* display infos on fpgaimage */ |
| 102 | index = 15; |
| 103 | for (i = 0; i < 4; i++) { |
| 104 | len = fpgadata[index]; |
| 105 | printf ("FPGA: %s\n", &(fpgadata[index + 1])); |
| 106 | index += len + 3; |
| 107 | } |
| 108 | putc ('\n'); |
| 109 | /* delayed reboot */ |
| 110 | for (i = 20; i > 0; i--) { |
| 111 | printf ("Rebooting in %2d seconds \r", i); |
| 112 | for (index = 0; index < 1000; index++) |
| 113 | udelay (1000); |
| 114 | } |
| 115 | putc ('\n'); |
| 116 | do_reset (NULL, 0, 0, NULL); |
wdenk | 153d511 | 2002-08-30 11:07:04 +0000 | [diff] [blame] | 117 | } |
wdenk | 153d511 | 2002-08-30 11:07:04 +0000 | [diff] [blame] | 118 | } |
| 119 | |
| 120 | /* |
| 121 | * IRQ 0-15 405GP internally generated; active high; level sensitive |
| 122 | * IRQ 16 405GP internally generated; active low; level sensitive |
| 123 | * IRQ 17-24 RESERVED |
| 124 | * IRQ 25 (EXT IRQ 0) CAN0; active low; level sensitive |
| 125 | * IRQ 26 (EXT IRQ 1) CAN1; active low; level sensitive |
| 126 | * IRQ 27 (EXT IRQ 2) PCI SLOT 0; active low; level sensitive |
| 127 | * IRQ 28 (EXT IRQ 3) PCI SLOT 1; active low; level sensitive |
| 128 | * IRQ 29 (EXT IRQ 4) PCI SLOT 2; active low; level sensitive |
| 129 | * IRQ 30 (EXT IRQ 5) PCI SLOT 3; active low; level sensitive |
| 130 | * IRQ 31 (EXT IRQ 6) COMPACT FLASH; active high; level sensitive |
| 131 | */ |
| 132 | mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */ |
| 133 | mtdcr (uicer, 0x00000000); /* disable all ints */ |
| 134 | mtdcr (uiccr, 0x00000000); /* set all to be non-critical */ |
| 135 | mtdcr (uicpr, 0xFFFFFF81); /* set int polarities */ |
| 136 | mtdcr (uictr, 0x10000000); /* set int trigger levels */ |
| 137 | mtdcr (uicvcr, 0x00000001); /* set vect base=0,INT0 highest priority */ |
| 138 | mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */ |
| 139 | |
| 140 | *(ushort *) 0xf03000ec = 0x0fff; /* enable all interrupts in fpga */ |
| 141 | |
| 142 | return 0; |
| 143 | } |
| 144 | |
| 145 | |
| 146 | /* ------------------------------------------------------------------------- */ |
| 147 | |
| 148 | /* |
| 149 | * Check Board Identity: |
| 150 | */ |
| 151 | |
| 152 | int checkboard (void) |
| 153 | { |
stroese | 0191b3c | 2004-09-16 12:34:51 +0000 | [diff] [blame^] | 154 | DECLARE_GLOBAL_DATA_PTR; |
| 155 | |
wdenk | 153d511 | 2002-08-30 11:07:04 +0000 | [diff] [blame] | 156 | int index; |
| 157 | int len; |
| 158 | unsigned char str[64]; |
| 159 | int i = getenv_r ("serial#", str, sizeof (str)); |
stroese | 0191b3c | 2004-09-16 12:34:51 +0000 | [diff] [blame^] | 160 | const unsigned char *fpga; |
wdenk | 153d511 | 2002-08-30 11:07:04 +0000 | [diff] [blame] | 161 | |
| 162 | puts ("Board: "); |
| 163 | |
stroese | 0191b3c | 2004-09-16 12:34:51 +0000 | [diff] [blame^] | 164 | if (i == -1) { |
| 165 | puts ("### No HW ID - assuming AR405"); |
| 166 | } else { |
| 167 | puts(str); |
wdenk | 153d511 | 2002-08-30 11:07:04 +0000 | [diff] [blame] | 168 | } |
| 169 | |
wdenk | 153d511 | 2002-08-30 11:07:04 +0000 | [diff] [blame] | 170 | puts ("\nFPGA: "); |
| 171 | |
| 172 | /* display infos on fpgaimage */ |
stroese | 0191b3c | 2004-09-16 12:34:51 +0000 | [diff] [blame^] | 173 | if (gd->board_type == 30) { |
| 174 | fpga = fpgadata_xl30; |
| 175 | } else { |
| 176 | fpga = fpgadata; |
| 177 | } |
wdenk | 153d511 | 2002-08-30 11:07:04 +0000 | [diff] [blame] | 178 | index = 15; |
| 179 | for (i = 0; i < 4; i++) { |
stroese | 0191b3c | 2004-09-16 12:34:51 +0000 | [diff] [blame^] | 180 | len = fpga[index]; |
| 181 | printf ("%s ", &(fpga[index + 1])); |
wdenk | 153d511 | 2002-08-30 11:07:04 +0000 | [diff] [blame] | 182 | index += len + 3; |
| 183 | } |
| 184 | |
| 185 | putc ('\n'); |
| 186 | |
stroese | 0191b3c | 2004-09-16 12:34:51 +0000 | [diff] [blame^] | 187 | /* |
| 188 | * Disable sleep mode in LXT971 |
| 189 | */ |
| 190 | lxt971_no_sleep(); |
| 191 | |
wdenk | 153d511 | 2002-08-30 11:07:04 +0000 | [diff] [blame] | 192 | return 0; |
| 193 | } |
| 194 | |
| 195 | /* ------------------------------------------------------------------------- */ |
| 196 | |
| 197 | long int initdram (int board_type) |
| 198 | { |
| 199 | return (16 * 1024 * 1024); |
| 200 | } |
| 201 | |
| 202 | /* ------------------------------------------------------------------------- */ |
| 203 | |
| 204 | int testdram (void) |
| 205 | { |
| 206 | /* TODO: XXX XXX XXX */ |
| 207 | printf ("test: 16 MB - ok\n"); |
| 208 | |
| 209 | return (0); |
| 210 | } |
| 211 | |
| 212 | /* ------------------------------------------------------------------------- */ |