]> git.kernelconcepts.de Git - karo-tx-uboot.git/blob - board/bf533-stamp/bf533-stamp.c
Blackfin: kill off useless initdram() usage
[karo-tx-uboot.git] / board / bf533-stamp / bf533-stamp.c
1 /*
2  * U-boot - main board file
3  *
4  * Copyright (c) 2005-2008 Analog Devices Inc.
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., 51 Franklin St, Fifth Floor, Boston,
25  * MA 02110-1301 USA
26  */
27
28 #include <common.h>
29 #include <netdev.h>
30 #include <asm/io.h>
31 #include "bf533-stamp.h"
32
33 DECLARE_GLOBAL_DATA_PTR;
34
35 int checkboard(void)
36 {
37         printf("Board: ADI BF533 Stamp board\n");
38         printf("       Support: http://blackfin.uclinux.org/\n");
39         return 0;
40 }
41
42 /* PF0 and PF1 are used to switch between the ethernet and flash:
43  *         PF0  PF1
44  *  flash:  0    0
45  *  ether:  1    0
46  */
47 void swap_to(int device_id)
48 {
49         bfin_write_FIO_DIR(bfin_read_FIO_DIR() | PF1 | PF0);
50         SSYNC();
51         bfin_write_FIO_FLAG_C(PF1);
52         if (device_id == ETHERNET)
53                 bfin_write_FIO_FLAG_S(PF0);
54         else if (device_id == FLASH)
55                 bfin_write_FIO_FLAG_C(PF0);
56         else
57                 printf("Unknown device to switch\n");
58         SSYNC();
59 }
60
61 #if defined(CONFIG_MISC_INIT_R)
62 /* miscellaneous platform dependent initialisations */
63 int misc_init_r(void)
64 {
65         int i;
66         int cf_stat = 0;
67
68         /* Check whether CF card is inserted */
69         *pFIO_EDGE = FIO_EDGE_CF_BITS;
70         *pFIO_POLAR = FIO_POLAR_CF_BITS;
71         for (i = 0; i < 0x300; i++)
72                 asm("nop;");
73
74         if ((*pFIO_FLAG_S) & CF_STAT_BITS) {
75                 cf_stat = 0;
76         } else {
77                 cf_stat = 1;
78         }
79
80         *pFIO_EDGE = FIO_EDGE_BITS;
81         *pFIO_POLAR = FIO_POLAR_BITS;
82
83         if (cf_stat) {
84                 printf("Booting from COMPACT flash\n");
85
86                 for (i = 0; i < 0x1000; i++)
87                         asm("nop;");
88                 for (i = 0; i < 0x1000; i++)
89                         asm("nop;");
90                 for (i = 0; i < 0x1000; i++)
91                         asm("nop;");
92
93                 serial_setbrg();
94                 ide_init();
95
96                 setenv("bootargs", "");
97                 setenv("bootcmd",
98                        "fatload ide 0:1 0x1000000 uImage-stamp;bootm 0x1000000;bootm 0x20100000");
99         } else {
100                 printf("Booting from FLASH\n");
101         }
102
103         return 0;
104 }
105 #endif
106
107 #ifdef CONFIG_STAMP_CF
108
109 void cf_outb(unsigned char val, volatile unsigned char *addr)
110 {
111         /*
112          * Set PF1 PF0 respectively to 0 1 to divert address
113          * to the expansion memory banks
114          */
115         *pFIO_FLAG_S = CF_PF0;
116         *pFIO_FLAG_C = CF_PF1;
117         SSYNC();
118
119         *(addr) = val;
120         SSYNC();
121
122         /* Setback PF1 PF0 to 0 0 to address external
123          * memory banks  */
124         *(volatile unsigned short *)pFIO_FLAG_C = CF_PF1_PF0;
125         SSYNC();
126 }
127
128 unsigned char cf_inb(volatile unsigned char *addr)
129 {
130         volatile unsigned char c;
131
132         *pFIO_FLAG_S = CF_PF0;
133         *pFIO_FLAG_C = CF_PF1;
134         SSYNC();
135
136         c = *(addr);
137         SSYNC();
138
139         *pFIO_FLAG_C = CF_PF1_PF0;
140         SSYNC();
141
142         return c;
143 }
144
145 void cf_insw(unsigned short *sect_buf, unsigned short *addr, int words)
146 {
147         int i;
148
149         *pFIO_FLAG_S = CF_PF0;
150         *pFIO_FLAG_C = CF_PF1;
151         SSYNC();
152
153         for (i = 0; i < words; i++) {
154                 *(sect_buf + i) = *(addr);
155                 SSYNC();
156         }
157
158         *pFIO_FLAG_C = CF_PF1_PF0;
159         SSYNC();
160 }
161
162 void cf_outsw(unsigned short *addr, unsigned short *sect_buf, int words)
163 {
164         int i;
165
166         *pFIO_FLAG_S = CF_PF0;
167         *pFIO_FLAG_C = CF_PF1;
168         SSYNC();
169
170         for (i = 0; i < words; i++) {
171                 *(addr) = *(sect_buf + i);
172                 SSYNC();
173         }
174
175         *pFIO_FLAG_C = CF_PF1_PF0;
176         SSYNC();
177 }
178 #endif
179
180 #ifdef CONFIG_SHOW_BOOT_PROGRESS
181
182 #define STATUS_LED_OFF 0
183 #define STATUS_LED_ON  1
184
185 static void stamp_led_set(int LED1, int LED2, int LED3)
186 {
187         bfin_write_FIO_INEN(bfin_read_FIO_INEN() & ~(PF2 | PF3 | PF4));
188         bfin_write_FIO_DIR(bfin_read_FIO_DIR() | (PF2 | PF3 | PF4));
189
190         if (LED1 == STATUS_LED_OFF)
191                 *pFIO_FLAG_S = PF2;
192         else
193                 *pFIO_FLAG_C = PF2;
194         if (LED2 == STATUS_LED_OFF)
195                 *pFIO_FLAG_S = PF3;
196         else
197                 *pFIO_FLAG_C = PF3;
198         if (LED3 == STATUS_LED_OFF)
199                 *pFIO_FLAG_S = PF4;
200         else
201                 *pFIO_FLAG_C = PF4;
202         SSYNC();
203 }
204
205 void show_boot_progress(int status)
206 {
207         switch (status) {
208         case 1:
209                 stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_ON);
210                 break;
211         case 2:
212                 stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_OFF);
213                 break;
214         case 3:
215                 stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_ON);
216                 break;
217         case 4:
218                 stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_OFF);
219                 break;
220         case 5:
221         case 6:
222                 stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_ON);
223                 break;
224         case 7:
225         case 8:
226                 stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_OFF);
227                 break;
228         case 9:
229         case 10:
230         case 11:
231         case 12:
232         case 13:
233         case 14:
234         case 15:
235                 stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_OFF);
236                 break;
237         default:
238                 stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_ON);
239                 break;
240         }
241 }
242 #endif
243
244 #ifdef CONFIG_STATUS_LED
245 #include <status_led.h>
246
247 static void set_led(int pf, int state)
248 {
249         switch (state) {
250                 case STATUS_LED_OFF:      bfin_write_FIO_FLAG_S(pf); break;
251                 case STATUS_LED_BLINKING: bfin_write_FIO_FLAG_T(pf); break;
252                 case STATUS_LED_ON:       bfin_write_FIO_FLAG_C(pf); break;
253         }
254 }
255
256 static void set_leds(led_id_t mask, int state)
257 {
258         if (mask & 0x1) set_led(PF2, state);
259         if (mask & 0x2) set_led(PF3, state);
260         if (mask & 0x4) set_led(PF4, state);
261 }
262
263 void __led_init(led_id_t mask, int state)
264 {
265         bfin_write_FIO_INEN(bfin_read_FIO_INEN() & ~(PF2 | PF3 | PF4));
266         bfin_write_FIO_DIR(bfin_read_FIO_DIR() | (PF2 | PF3 | PF4));
267 }
268
269 void __led_set(led_id_t mask, int state)
270 {
271         set_leds(mask, state);
272 }
273
274 void __led_toggle(led_id_t mask)
275 {
276         set_leds(mask, STATUS_LED_BLINKING);
277 }
278
279 #endif
280
281 #ifdef CONFIG_SMC91111
282 int board_eth_init(bd_t *bis)
283 {
284         return smc91111_initialize(0, CONFIG_SMC91111_BASE);
285 }
286 #endif