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 phys_size_t initdram(int board_type)
44 gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
45 gd->bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
46 return gd->bd->bi_memsize;
49 /* PF0 and PF1 are used to switch between the ethernet and flash:
54 void swap_to(int device_id)
56 bfin_write_FIO_DIR(bfin_read_FIO_DIR() | PF1 | PF0);
58 bfin_write_FIO_FLAG_C(PF1);
59 if (device_id == ETHERNET)
60 bfin_write_FIO_FLAG_S(PF0);
61 else if (device_id == FLASH)
62 bfin_write_FIO_FLAG_C(PF0);
64 printf("Unknown device to switch\n");
68 #if defined(CONFIG_MISC_INIT_R)
69 /* miscellaneous platform dependent initialisations */
75 /* Check whether CF card is inserted */
76 *pFIO_EDGE = FIO_EDGE_CF_BITS;
77 *pFIO_POLAR = FIO_POLAR_CF_BITS;
78 for (i = 0; i < 0x300; i++)
81 if ((*pFIO_FLAG_S) & CF_STAT_BITS) {
87 *pFIO_EDGE = FIO_EDGE_BITS;
88 *pFIO_POLAR = FIO_POLAR_BITS;
91 printf("Booting from COMPACT flash\n");
93 for (i = 0; i < 0x1000; i++)
95 for (i = 0; i < 0x1000; i++)
97 for (i = 0; i < 0x1000; i++)
103 setenv("bootargs", "");
105 "fatload ide 0:1 0x1000000 uImage-stamp;bootm 0x1000000;bootm 0x20100000");
107 printf("Booting from FLASH\n");
114 #ifdef CONFIG_STAMP_CF
116 void cf_outb(unsigned char val, volatile unsigned char *addr)
119 * Set PF1 PF0 respectively to 0 1 to divert address
120 * to the expansion memory banks
122 *pFIO_FLAG_S = CF_PF0;
123 *pFIO_FLAG_C = CF_PF1;
129 /* Setback PF1 PF0 to 0 0 to address external
131 *(volatile unsigned short *)pFIO_FLAG_C = CF_PF1_PF0;
135 unsigned char cf_inb(volatile unsigned char *addr)
137 volatile unsigned char c;
139 *pFIO_FLAG_S = CF_PF0;
140 *pFIO_FLAG_C = CF_PF1;
146 *pFIO_FLAG_C = CF_PF1_PF0;
152 void cf_insw(unsigned short *sect_buf, unsigned short *addr, int words)
156 *pFIO_FLAG_S = CF_PF0;
157 *pFIO_FLAG_C = CF_PF1;
160 for (i = 0; i < words; i++) {
161 *(sect_buf + i) = *(addr);
165 *pFIO_FLAG_C = CF_PF1_PF0;
169 void cf_outsw(unsigned short *addr, unsigned short *sect_buf, int words)
173 *pFIO_FLAG_S = CF_PF0;
174 *pFIO_FLAG_C = CF_PF1;
177 for (i = 0; i < words; i++) {
178 *(addr) = *(sect_buf + i);
182 *pFIO_FLAG_C = CF_PF1_PF0;
187 #ifdef CONFIG_SHOW_BOOT_PROGRESS
189 #define STATUS_LED_OFF 0
190 #define STATUS_LED_ON 1
192 static void stamp_led_set(int LED1, int LED2, int LED3)
194 bfin_write_FIO_INEN(bfin_read_FIO_INEN() & ~(PF2 | PF3 | PF4));
195 bfin_write_FIO_DIR(bfin_read_FIO_DIR() | (PF2 | PF3 | PF4));
197 if (LED1 == STATUS_LED_OFF)
201 if (LED2 == STATUS_LED_OFF)
205 if (LED3 == STATUS_LED_OFF)
212 void show_boot_progress(int status)
216 stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_ON);
219 stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_OFF);
222 stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_ON);
225 stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_OFF);
229 stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_ON);
233 stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_OFF);
242 stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_OFF);
245 stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_ON);
251 #ifdef CONFIG_STATUS_LED
252 #include <status_led.h>
254 static void set_led(int pf, int state)
257 case STATUS_LED_OFF: bfin_write_FIO_FLAG_S(pf); break;
258 case STATUS_LED_BLINKING: bfin_write_FIO_FLAG_T(pf); break;
259 case STATUS_LED_ON: bfin_write_FIO_FLAG_C(pf); break;
263 static void set_leds(led_id_t mask, int state)
265 if (mask & 0x1) set_led(PF2, state);
266 if (mask & 0x2) set_led(PF3, state);
267 if (mask & 0x4) set_led(PF4, state);
270 void __led_init(led_id_t mask, int state)
272 bfin_write_FIO_INEN(bfin_read_FIO_INEN() & ~(PF2 | PF3 | PF4));
273 bfin_write_FIO_DIR(bfin_read_FIO_DIR() | (PF2 | PF3 | PF4));
276 void __led_set(led_id_t mask, int state)
278 set_leds(mask, state);
281 void __led_toggle(led_id_t mask)
283 set_leds(mask, STATUS_LED_BLINKING);
288 #ifdef CONFIG_SMC91111
289 int board_eth_init(bd_t *bis)
291 return smc91111_initialize(0, CONFIG_SMC91111_BASE);