3 * Stefan Roese, esd gmbh germany, stefan.roese@esd-electronics.com
5 * See file CREDITS for list of people who contributed to this
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.
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.
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,
28 /* ------------------------------------------------------------------------- */
32 #define _NOT_USED_ 0xFFFFFFFF
34 /* ------------------------------------------------------------------------- */
36 /* fpga configuration data - generated by bit2inc */
37 static unsigned char fpgadata[] = {
41 #define FPGA_PRG_SLEEP 32 /* fpga program sleep-time */
42 #define LOAD_LONG(a) a
45 /******************************************************************************
47 * sysFpgaBoot - Load fpga-image into fpga
50 static int fpgaBoot (void)
56 imageSize = sizeof (fpgadata);
58 /* display infos on fpgaimage */
60 for (i = 0; i < 4; i++) {
61 len = fpgadata[index];
65 /* search for preamble 0xFF2X */
66 for (index = 0; index < imageSize - 1; index++) {
67 if ((fpgadata[index] == 0xff)
68 && ((fpgadata[index + 1] & 0xf0) == 0x20))
72 /* enable cs1 instead of user0... */
73 *(unsigned long *) 0x50000084 &= ~0x00000002;
77 ((in32 (0x50000084) & 0x00010000) == 0) ? "NOT DONE" : "DONE");
80 /* init fpga by asserting and deasserting PROGRAM* (USER2)... */
81 *(unsigned long *) 0x50000084 &= ~0x00000400;
82 udelay (FPGA_PRG_SLEEP * 1000);
84 *(unsigned long *) 0x50000084 |= 0x00000400;
85 udelay (FPGA_PRG_SLEEP * 1000);
89 ((in32 (0x50000084) & 0x00010000) == 0) ? "NOT DONE" : "DONE");
92 /* cs1: disable burst, disable ready */
93 *(unsigned long *) 0x50000114 &= ~0x00000300;
95 /* cs1: set write timing */
96 *(unsigned long *) 0x50000118 |= 0x00010900;
98 /* write configuration-data into fpga... */
99 for (i = index; i < imageSize; i++) {
101 for (j = 0; j < 8; j++) {
102 *(unsigned long *) 0x30000000 =
104 ? LOAD_LONG (0x03030101)
105 : LOAD_LONG (0x02020000);
112 ((in32 (0x50000084) & 0x00010000) == 0) ? "NOT DONE" : "DONE");
115 /* set cs1 to 32 bit data-width, disable burst, enable ready */
116 *(unsigned long *) 0x50000114 |= 0x00000202;
117 *(unsigned long *) 0x50000114 &= ~0x00000100;
119 /* cs1: set iop access to little endian */
120 *(unsigned long *) 0x50000114 &= ~0x00000010;
122 /* cs1: set read and write timing */
123 *(unsigned long *) 0x50000118 = 0x00010000;
124 *(unsigned long *) 0x5000011c = 0x00010001;
128 ((in32 (0x50000084) & 0x00010000) == 0) ? "NOT DONE" : "DONE");
131 /* wait for 30 ms... */
133 /* check if fpga's DONE signal - correctly booted ? */
134 if ((*(unsigned long *) 0x50000084 & 0x00010000) == 0)
141 int board_early_init_f (void)
146 *(unsigned long *) 0x50000304 = 0x02900007; /* enable mem/io/master bits */
147 *(unsigned long *) 0x500001b4 = 0x00000000; /* disable pci interrupt output enable */
148 *(unsigned long *) 0x50000354 = 0x00c05800; /* disable emun interrupt output enable */
149 *(unsigned long *) 0x50000344 = 0x00000000; /* disable pme interrupt output enable */
150 *(unsigned long *) 0x50000310 = 0x00000000; /* pcibar0 */
151 *(unsigned long *) 0x50000314 = 0x00000000; /* pcibar1 */
152 *(unsigned long *) 0x50000318 = 0x00000000; /* pcibar2 */
159 * Check Board Identity:
162 int checkboard (void)
167 int i = getenv_r ("serial#", str, sizeof (str));
178 if (!i || strncmp (str, "DASA_SIM", 8)) {
179 puts ("### No HW ID - assuming DASA_SIM");
185 val = *(unsigned short *) 0x30000202;
186 printf (" (Id=%d Version=%d Revision=%d)",
187 (val & 0x07f8) >> 3, val & 0x0001, (val & 0x0006) >> 1);
191 /* display infos on fpgaimage */
193 for (i = 0; i < 4; i++) {
194 len = fpgadata[index];
195 printf ("%s ", &(fpgadata[index + 1]));
199 puts ("\nFPGA: Booting failed!");
207 phys_size_t initdram (int board_type)
209 return (16 * 1024 * 1024);