]> git.ipfire.org Git - people/ms/u-boot.git/blob - board/stamp/stamp.c
3fe0134d6816842d28eb93516d7efbff14888116
[people/ms/u-boot.git] / board / stamp / stamp.c
1 /*
2 * U-boot - stamp.c STAMP board specific routines
3 *
4 * Copyright (c) 2005 blackfin.uclinux.org
5 *
6 * (C) Copyright 2000-2004
7 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
8 *
9 * See file CREDITS for list of people who contributed to this
10 * project.
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License as
14 * published by the Free Software Foundation; either version 2 of
15 * the License, or (at your option) any later version.
16 *
17 * This program is distributed in the hope that it will be useful,
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 * GNU General Public License for more details.
21 *
22 * You should have received a copy of the GNU General Public License
23 * along with this program; if not, write to the Free Software
24 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 * MA 02111-1307 USA
26 */
27
28 #include <common.h>
29 #include <asm/mem_init.h>
30 #include "stamp.h"
31
32 #define STATUS_LED_OFF 0
33 #define STATUS_LED_ON 1
34
35 #ifdef CONFIG_SHOW_BOOT_PROGRESS
36 # define SHOW_BOOT_PROGRESS(arg) show_boot_progress(arg)
37 #else
38 # define SHOW_BOOT_PROGRESS(arg)
39 #endif
40
41 int checkboard (void)
42 {
43 printf ("CPU: ADSP BF533 Rev.: 0.%d\n", *pCHIPID >> 28);
44 printf ("Board: ADI BF533 Stamp board\n");
45 printf (" Support: http://blackfin.uclinux.org/\n");
46 printf (" Richard Klingler <richard@uclinux.net>\n");
47 return 0;
48 }
49
50 long int initdram (int board_type)
51 {
52 DECLARE_GLOBAL_DATA_PTR;
53 #ifdef DEBUG
54 printf ("SDRAM attributes:\n");
55 printf (" tRCD:%d Cycles; tRP:%d Cycles; tRAS:%d Cycles; tWR:%d Cycles; "
56 "CAS Latency:%d cycles\n",
57 (SDRAM_tRCD >> 15),
58 (SDRAM_tRP >> 11),
59 (SDRAM_tRAS >> 6),
60 (SDRAM_tWR >> 19),
61 (SDRAM_CL >> 2));
62 printf ("SDRAM Begin: 0x%x\n", CFG_SDRAM_BASE);
63 printf ("Bank size = %d MB\n", 128);
64 #endif
65 gd->bd->bi_memstart = CFG_SDRAM_BASE;
66 gd->bd->bi_memsize = CFG_MAX_RAM_SIZE;
67 return (gd->bd->bi_memsize);
68 }
69
70 void swap_to (int device_id)
71 {
72
73 if (device_id == ETHERNET) {
74 *pFIO_DIR = PF0;
75 asm ("ssync;");
76 *pFIO_FLAG_S = PF0;
77 asm ("ssync;");
78 } else if (device_id == FLASH) {
79 *pFIO_DIR = (PF4 | PF3 | PF2 | PF1 | PF0);
80 *pFIO_FLAG_S = (PF4 | PF3 | PF2);
81 *pFIO_MASKA_D = (PF8 | PF6 | PF5);
82 *pFIO_MASKB_D = (PF7);
83 *pFIO_POLAR = (PF8 | PF6 | PF5);
84 *pFIO_EDGE = (PF8 | PF7 | PF6 | PF5);
85 *pFIO_INEN = (PF8 | PF7 | PF6 | PF5);
86 *pFIO_FLAG_D = (PF4 | PF3 | PF2);
87 asm ("ssync;");
88 } else {
89 printf ("Unknown bank to switch\n");
90 }
91
92 return;
93 }
94
95 #if defined(CONFIG_MISC_INIT_R)
96 /* miscellaneous platform dependent initialisations */
97 int misc_init_r (void)
98 {
99 int i;
100 int cf_stat = 0;
101
102 /* Check whether CF card is inserted */
103 *pFIO_EDGE = FIO_EDGE_CF_BITS;
104 *pFIO_POLAR = FIO_POLAR_CF_BITS;
105 for (i = 0; i < 0x300; i++)
106 asm ("nop;");
107
108 if ((*pFIO_FLAG_S) & CF_STAT_BITS) {
109 cf_stat = 0;
110 } else {
111 cf_stat = 1;
112 }
113
114 *pFIO_EDGE = FIO_EDGE_BITS;
115 *pFIO_POLAR = FIO_POLAR_BITS;
116
117
118 if (cf_stat) {
119 printf ("Booting from COMPACT flash\n");
120
121 /* Set cycle time for CF */
122 *(volatile unsigned long *) ambctl1 = CF_AMBCTL1VAL;
123
124 for (i = 0; i < 0x1000; i++)
125 asm ("nop;");
126 for (i = 0; i < 0x1000; i++)
127 asm ("nop;");
128 for (i = 0; i < 0x1000; i++)
129 asm ("nop;");
130
131 serial_setbrg ();
132 ide_init ();
133
134 setenv ("bootargs", "");
135 setenv ("bootcmd",
136 "fatload ide 0:1 0x1000000 uImage-stamp;bootm 0x1000000;bootm 0x20100000");
137 } else {
138 printf ("Booting from FLASH\n");
139 }
140
141 return 1;
142 }
143 #endif
144
145 #ifdef CONFIG_STAMP_CF
146
147 void cf_outb (unsigned char val, volatile unsigned char *addr)
148 {
149 /*
150 * Set PF1 PF0 respectively to 0 1 to divert address
151 * to the expansion memory banks
152 */
153 *pFIO_FLAG_S = CF_PF0;
154 *pFIO_FLAG_C = CF_PF1;
155 asm ("ssync;");
156
157 *(addr) = val;
158 asm ("ssync;");
159
160 /* Setback PF1 PF0 to 0 0 to address external
161 * memory banks */
162 *(volatile unsigned short *) pFIO_FLAG_C = CF_PF1_PF0;
163 asm ("ssync;");
164 }
165
166 unsigned char cf_inb (volatile unsigned char *addr)
167 {
168 volatile unsigned char c;
169
170 *pFIO_FLAG_S = CF_PF0;
171 *pFIO_FLAG_C = CF_PF1;
172 asm ("ssync;");
173
174 c = *(addr);
175 asm ("ssync;");
176
177 *pFIO_FLAG_C = CF_PF1_PF0;
178 asm ("ssync;");
179
180 return c;
181 }
182
183 void cf_insw (unsigned short *sect_buf, unsigned short *addr, int words)
184 {
185 int i;
186
187 *pFIO_FLAG_S = CF_PF0;
188 *pFIO_FLAG_C = CF_PF1;
189 asm ("ssync;");
190
191 for (i = 0; i < words; i++) {
192 *(sect_buf + i) = *(addr);
193 asm ("ssync;");
194 }
195
196 *pFIO_FLAG_C = CF_PF1_PF0;
197 asm ("ssync;");
198 }
199
200 void cf_outsw (unsigned short *addr, unsigned short *sect_buf, int words)
201 {
202 int i;
203
204 *pFIO_FLAG_S = CF_PF0;
205 *pFIO_FLAG_C = CF_PF1;
206 asm ("ssync;");
207
208 for (i = 0; i < words; i++) {
209 *(addr) = *(sect_buf + i);
210 asm ("ssync;");
211 }
212
213 *pFIO_FLAG_C = CF_PF1_PF0;
214 asm ("ssync;");
215 }
216 #endif
217
218 void stamp_led_set (int LED1, int LED2, int LED3)
219 {
220 *pFIO_INEN &= ~(PF2 | PF3 | PF4);
221 *pFIO_DIR |= (PF2 | PF3 | PF4);
222
223 if (LED1 == STATUS_LED_OFF)
224 *pFIO_FLAG_S = PF2;
225 else
226 *pFIO_FLAG_C = PF2;
227 if (LED2 == STATUS_LED_OFF)
228 *pFIO_FLAG_S = PF3;
229 else
230 *pFIO_FLAG_C = PF3;
231 if (LED3 == STATUS_LED_OFF)
232 *pFIO_FLAG_S = PF4;
233 else
234 *pFIO_FLAG_C = PF4;
235 asm ("ssync;");
236 }
237
238 void show_boot_progress (int status)
239 {
240 switch (status) {
241 case 1:
242 stamp_led_set (STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_ON);
243 break;
244 case 2:
245 stamp_led_set (STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_OFF);
246 break;
247 case 3:
248 stamp_led_set (STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_ON);
249 break;
250 case 4:
251 stamp_led_set (STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_OFF);
252 break;
253 case 5:
254 case 6:
255 stamp_led_set (STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_ON);
256 break;
257 case 7:
258 case 8:
259 stamp_led_set (STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_OFF);
260 break;
261 case 9:
262 case 10:
263 case 11:
264 case 12:
265 case 13:
266 case 14:
267 case 15:
268 stamp_led_set (STATUS_LED_OFF, STATUS_LED_OFF,
269 STATUS_LED_OFF);
270 break;
271 default:
272 stamp_led_set (STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_ON);
273 break;
274 }
275 }