2 * U-boot - main board file
4 * Copyright (c) 2005-2008 Analog Devices Inc.
6 * (C) Copyright 2000-2004
7 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
9 * See file CREDITS for list of people who contributed to this
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.
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.
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,
31 #include "bf533-stamp.h"
33 DECLARE_GLOBAL_DATA_PTR;
37 printf("Board: ADI BF533 Stamp board\n");
38 printf(" Support: http://blackfin.uclinux.org/\n");
42 /* PF0 and PF1 are used to switch between the ethernet and flash:
47 void swap_to(int device_id)
49 bfin_write_FIO_DIR(bfin_read_FIO_DIR() | PF1 | PF0);
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);
57 printf("Unknown device to switch\n");
61 #if defined(CONFIG_MISC_INIT_R)
62 /* miscellaneous platform dependent initialisations */
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++)
74 if ((*pFIO_FLAG_S) & CF_STAT_BITS) {
80 *pFIO_EDGE = FIO_EDGE_BITS;
81 *pFIO_POLAR = FIO_POLAR_BITS;
84 printf("Booting from COMPACT flash\n");
86 for (i = 0; i < 0x1000; i++)
88 for (i = 0; i < 0x1000; i++)
90 for (i = 0; i < 0x1000; i++)
96 setenv("bootargs", "");
98 "fatload ide 0:1 0x1000000 uImage-stamp;bootm 0x1000000;bootm 0x20100000");
100 printf("Booting from FLASH\n");
107 #ifdef CONFIG_STAMP_CF
109 void cf_outb(unsigned char val, volatile unsigned char *addr)
112 * Set PF1 PF0 respectively to 0 1 to divert address
113 * to the expansion memory banks
115 *pFIO_FLAG_S = CF_PF0;
116 *pFIO_FLAG_C = CF_PF1;
122 /* Setback PF1 PF0 to 0 0 to address external
124 *(volatile unsigned short *)pFIO_FLAG_C = CF_PF1_PF0;
128 unsigned char cf_inb(volatile unsigned char *addr)
130 volatile unsigned char c;
132 *pFIO_FLAG_S = CF_PF0;
133 *pFIO_FLAG_C = CF_PF1;
139 *pFIO_FLAG_C = CF_PF1_PF0;
145 void cf_insw(unsigned short *sect_buf, unsigned short *addr, int words)
149 *pFIO_FLAG_S = CF_PF0;
150 *pFIO_FLAG_C = CF_PF1;
153 for (i = 0; i < words; i++) {
154 *(sect_buf + i) = *(addr);
158 *pFIO_FLAG_C = CF_PF1_PF0;
162 void cf_outsw(unsigned short *addr, unsigned short *sect_buf, int words)
166 *pFIO_FLAG_S = CF_PF0;
167 *pFIO_FLAG_C = CF_PF1;
170 for (i = 0; i < words; i++) {
171 *(addr) = *(sect_buf + i);
175 *pFIO_FLAG_C = CF_PF1_PF0;
180 #ifdef CONFIG_SHOW_BOOT_PROGRESS
182 #define STATUS_LED_OFF 0
183 #define STATUS_LED_ON 1
185 static void stamp_led_set(int LED1, int LED2, int LED3)
187 bfin_write_FIO_INEN(bfin_read_FIO_INEN() & ~(PF2 | PF3 | PF4));
188 bfin_write_FIO_DIR(bfin_read_FIO_DIR() | (PF2 | PF3 | PF4));
190 if (LED1 == STATUS_LED_OFF)
194 if (LED2 == STATUS_LED_OFF)
198 if (LED3 == STATUS_LED_OFF)
205 void show_boot_progress(int status)
209 stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_ON);
212 stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_OFF);
215 stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_ON);
218 stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_OFF);
222 stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_ON);
226 stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_OFF);
235 stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_OFF);
238 stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_ON);
244 #ifdef CONFIG_STATUS_LED
245 #include <status_led.h>
247 static void set_led(int pf, int 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;
256 static void set_leds(led_id_t mask, int state)
258 if (mask & 0x1) set_led(PF2, state);
259 if (mask & 0x2) set_led(PF3, state);
260 if (mask & 0x4) set_led(PF4, state);
263 void __led_init(led_id_t mask, int state)
265 bfin_write_FIO_INEN(bfin_read_FIO_INEN() & ~(PF2 | PF3 | PF4));
266 bfin_write_FIO_DIR(bfin_read_FIO_DIR() | (PF2 | PF3 | PF4));
269 void __led_set(led_id_t mask, int state)
271 set_leds(mask, state);
274 void __led_toggle(led_id_t mask)
276 set_leds(mask, STATUS_LED_BLINKING);
281 #ifdef CONFIG_SMC91111
282 int board_eth_init(bd_t *bis)
284 return smc91111_initialize(0, CONFIG_SMC91111_BASE);