]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/stamp/stamp.c
GCC-4.x fixes: clean up global data pointer initialization for all boards.
[karo-tx-uboot.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 DECLARE_GLOBAL_DATA_PTR;
33
34 #define STATUS_LED_OFF 0
35 #define STATUS_LED_ON  1
36
37 #ifdef CONFIG_SHOW_BOOT_PROGRESS
38 # define SHOW_BOOT_PROGRESS(arg)        show_boot_progress(arg)
39 #else
40 # define SHOW_BOOT_PROGRESS(arg)
41 #endif
42
43 int checkboard (void)
44 {
45         printf ("CPU:   ADSP BF533 Rev.: 0.%d\n", *pCHIPID >> 28);
46         printf ("Board: ADI BF533 Stamp board\n");
47         printf ("       Support: http://blackfin.uclinux.org/\n");
48         printf ("       Richard Klingler <richard@uclinux.net>\n");
49         return 0;
50 }
51
52 long int initdram (int board_type)
53 {
54 #ifdef DEBUG
55         printf ("SDRAM attributes:\n");
56         printf ("  tRCD:%d Cycles; tRP:%d Cycles; tRAS:%d Cycles; tWR:%d Cycles; "
57                 "CAS Latency:%d cycles\n",
58                 (SDRAM_tRCD >> 15),
59                 (SDRAM_tRP >> 11),
60                 (SDRAM_tRAS >> 6),
61                 (SDRAM_tWR >> 19),
62                 (SDRAM_CL >> 2));
63         printf ("SDRAM Begin: 0x%x\n", CFG_SDRAM_BASE);
64         printf ("Bank size = %d MB\n", 128);
65 #endif
66         gd->bd->bi_memstart = CFG_SDRAM_BASE;
67         gd->bd->bi_memsize = CFG_MAX_RAM_SIZE;
68         return (gd->bd->bi_memsize);
69 }
70
71 void swap_to (int device_id)
72 {
73
74         if (device_id == ETHERNET) {
75                 *pFIO_DIR = PF0;
76                 asm ("ssync;");
77                 *pFIO_FLAG_S = PF0;
78                 asm ("ssync;");
79         } else if (device_id == FLASH) {
80                 *pFIO_DIR = (PF4 | PF3 | PF2 | PF1 | PF0);
81                 *pFIO_FLAG_S = (PF4 | PF3 | PF2);
82                 *pFIO_MASKA_D = (PF8 | PF6 | PF5);
83                 *pFIO_MASKB_D = (PF7);
84                 *pFIO_POLAR = (PF8 | PF6 | PF5);
85                 *pFIO_EDGE = (PF8 | PF7 | PF6 | PF5);
86                 *pFIO_INEN = (PF8 | PF7 | PF6 | PF5);
87                 *pFIO_FLAG_D = (PF4 | PF3 | PF2);
88                 asm ("ssync;");
89         } else {
90                 printf ("Unknown bank to switch\n");
91         }
92
93         return;
94 }
95
96 #if defined(CONFIG_MISC_INIT_R)
97 /* miscellaneous platform dependent initialisations */
98 int misc_init_r (void)
99 {
100         int i;
101         int cf_stat = 0;
102
103         /* Check whether CF card is inserted */
104         *pFIO_EDGE = FIO_EDGE_CF_BITS;
105         *pFIO_POLAR = FIO_POLAR_CF_BITS;
106         for (i = 0; i < 0x300; i++)
107                 asm ("nop;");
108
109         if ((*pFIO_FLAG_S) & CF_STAT_BITS) {
110                 cf_stat = 0;
111         } else {
112                 cf_stat = 1;
113         }
114
115         *pFIO_EDGE = FIO_EDGE_BITS;
116         *pFIO_POLAR = FIO_POLAR_BITS;
117
118
119         if (cf_stat) {
120                 printf ("Booting from COMPACT flash\n");
121
122                 /* Set cycle time for CF */
123                 *(volatile unsigned long *) ambctl1 = CF_AMBCTL1VAL;
124
125                 for (i = 0; i < 0x1000; i++)
126                         asm ("nop;");
127                 for (i = 0; i < 0x1000; i++)
128                         asm ("nop;");
129                 for (i = 0; i < 0x1000; i++)
130                         asm ("nop;");
131
132                 serial_setbrg ();
133                 ide_init ();
134
135                 setenv ("bootargs", "");
136                 setenv ("bootcmd",
137                         "fatload ide 0:1 0x1000000 uImage-stamp;bootm 0x1000000;bootm 0x20100000");
138         } else {
139                 printf ("Booting from FLASH\n");
140         }
141
142         return 1;
143 }
144 #endif
145
146 #ifdef CONFIG_STAMP_CF
147
148 void cf_outb (unsigned char val, volatile unsigned char *addr)
149 {
150         /*
151          * Set PF1 PF0 respectively to 0 1 to divert address
152          * to the expansion memory banks
153          */
154         *pFIO_FLAG_S = CF_PF0;
155         *pFIO_FLAG_C = CF_PF1;
156         asm ("ssync;");
157
158         *(addr) = val;
159         asm ("ssync;");
160
161         /* Setback PF1 PF0 to 0 0 to address external
162          * memory banks  */
163         *(volatile unsigned short *) pFIO_FLAG_C = CF_PF1_PF0;
164         asm ("ssync;");
165 }
166
167 unsigned char cf_inb (volatile unsigned char *addr)
168 {
169         volatile unsigned char c;
170
171         *pFIO_FLAG_S = CF_PF0;
172         *pFIO_FLAG_C = CF_PF1;
173         asm ("ssync;");
174
175         c = *(addr);
176         asm ("ssync;");
177
178         *pFIO_FLAG_C = CF_PF1_PF0;
179         asm ("ssync;");
180
181         return c;
182 }
183
184 void cf_insw (unsigned short *sect_buf, unsigned short *addr, int words)
185 {
186         int i;
187
188         *pFIO_FLAG_S = CF_PF0;
189         *pFIO_FLAG_C = CF_PF1;
190         asm ("ssync;");
191
192         for (i = 0; i < words; i++) {
193                 *(sect_buf + i) = *(addr);
194                 asm ("ssync;");
195         }
196
197         *pFIO_FLAG_C = CF_PF1_PF0;
198         asm ("ssync;");
199 }
200
201 void cf_outsw (unsigned short *addr, unsigned short *sect_buf, int words)
202 {
203         int i;
204
205         *pFIO_FLAG_S = CF_PF0;
206         *pFIO_FLAG_C = CF_PF1;
207         asm ("ssync;");
208
209         for (i = 0; i < words; i++) {
210                 *(addr) = *(sect_buf + i);
211                 asm ("ssync;");
212         }
213
214         *pFIO_FLAG_C = CF_PF1_PF0;
215         asm ("ssync;");
216 }
217 #endif
218
219 void stamp_led_set (int LED1, int LED2, int LED3)
220 {
221         *pFIO_INEN &= ~(PF2 | PF3 | PF4);
222         *pFIO_DIR |= (PF2 | PF3 | PF4);
223
224         if (LED1 == STATUS_LED_OFF)
225                 *pFIO_FLAG_S = PF2;
226         else
227                 *pFIO_FLAG_C = PF2;
228         if (LED2 == STATUS_LED_OFF)
229                 *pFIO_FLAG_S = PF3;
230         else
231                 *pFIO_FLAG_C = PF3;
232         if (LED3 == STATUS_LED_OFF)
233                 *pFIO_FLAG_S = PF4;
234         else
235                 *pFIO_FLAG_C = PF4;
236         asm ("ssync;");
237 }
238
239 void show_boot_progress (int status)
240 {
241         switch (status) {
242         case 1:
243                 stamp_led_set (STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_ON);
244                 break;
245         case 2:
246                 stamp_led_set (STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_OFF);
247                 break;
248         case 3:
249                 stamp_led_set (STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_ON);
250                 break;
251         case 4:
252                 stamp_led_set (STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_OFF);
253                 break;
254         case 5:
255         case 6:
256                 stamp_led_set (STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_ON);
257                 break;
258         case 7:
259         case 8:
260                 stamp_led_set (STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_OFF);
261                 break;
262         case 9:
263         case 10:
264         case 11:
265         case 12:
266         case 13:
267         case 14:
268         case 15:
269                 stamp_led_set (STATUS_LED_OFF, STATUS_LED_OFF,
270                                STATUS_LED_OFF);
271                 break;
272         default:
273                 stamp_led_set (STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_ON);
274                 break;
275         }
276 }