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,
30 #include "bf533-stamp.h"
32 DECLARE_GLOBAL_DATA_PTR;
36 printf("Board: ADI BF533 Stamp board\n");
37 printf(" Support: http://blackfin.uclinux.org/\n");
41 phys_size_t initdram(int board_type)
43 gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
44 gd->bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
45 return gd->bd->bi_memsize;
48 /* PF0 and PF1 are used to switch between the ethernet and flash:
53 void swap_to(int device_id)
55 bfin_write_FIO_DIR(bfin_read_FIO_DIR() | PF1 | PF0);
57 bfin_write_FIO_FLAG_C(PF1);
58 if (device_id == ETHERNET)
59 bfin_write_FIO_FLAG_S(PF0);
60 else if (device_id == FLASH)
61 bfin_write_FIO_FLAG_C(PF0);
63 printf("Unknown device to switch\n");
67 #if defined(CONFIG_MISC_INIT_R)
68 /* miscellaneous platform dependent initialisations */
74 /* Check whether CF card is inserted */
75 *pFIO_EDGE = FIO_EDGE_CF_BITS;
76 *pFIO_POLAR = FIO_POLAR_CF_BITS;
77 for (i = 0; i < 0x300; i++)
80 if ((*pFIO_FLAG_S) & CF_STAT_BITS) {
86 *pFIO_EDGE = FIO_EDGE_BITS;
87 *pFIO_POLAR = FIO_POLAR_BITS;
90 printf("Booting from COMPACT flash\n");
92 for (i = 0; i < 0x1000; i++)
94 for (i = 0; i < 0x1000; i++)
96 for (i = 0; i < 0x1000; i++)
102 setenv("bootargs", "");
104 "fatload ide 0:1 0x1000000 uImage-stamp;bootm 0x1000000;bootm 0x20100000");
106 printf("Booting from FLASH\n");
113 #ifdef CONFIG_STAMP_CF
115 void cf_outb(unsigned char val, volatile unsigned char *addr)
118 * Set PF1 PF0 respectively to 0 1 to divert address
119 * to the expansion memory banks
121 *pFIO_FLAG_S = CF_PF0;
122 *pFIO_FLAG_C = CF_PF1;
128 /* Setback PF1 PF0 to 0 0 to address external
130 *(volatile unsigned short *)pFIO_FLAG_C = CF_PF1_PF0;
134 unsigned char cf_inb(volatile unsigned char *addr)
136 volatile unsigned char c;
138 *pFIO_FLAG_S = CF_PF0;
139 *pFIO_FLAG_C = CF_PF1;
145 *pFIO_FLAG_C = CF_PF1_PF0;
151 void cf_insw(unsigned short *sect_buf, unsigned short *addr, int words)
155 *pFIO_FLAG_S = CF_PF0;
156 *pFIO_FLAG_C = CF_PF1;
159 for (i = 0; i < words; i++) {
160 *(sect_buf + i) = *(addr);
164 *pFIO_FLAG_C = CF_PF1_PF0;
168 void cf_outsw(unsigned short *addr, unsigned short *sect_buf, int words)
172 *pFIO_FLAG_S = CF_PF0;
173 *pFIO_FLAG_C = CF_PF1;
176 for (i = 0; i < words; i++) {
177 *(addr) = *(sect_buf + i);
181 *pFIO_FLAG_C = CF_PF1_PF0;
186 #ifdef CONFIG_SHOW_BOOT_PROGRESS
188 #define STATUS_LED_OFF 0
189 #define STATUS_LED_ON 1
191 static void stamp_led_set(int LED1, int LED2, int LED3)
193 bfin_write_FIO_INEN(bfin_read_FIO_INEN() & ~(PF2 | PF3 | PF4));
194 bfin_write_FIO_DIR(bfin_read_FIO_DIR() | (PF2 | PF3 | PF4));
196 if (LED1 == STATUS_LED_OFF)
200 if (LED2 == STATUS_LED_OFF)
204 if (LED3 == STATUS_LED_OFF)
211 void show_boot_progress(int status)
215 stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_ON);
218 stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_OFF);
221 stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_ON);
224 stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_OFF);
228 stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_ON);
232 stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_OFF);
241 stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_OFF);
244 stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_ON);
250 #ifdef CONFIG_STATUS_LED
251 #include <status_led.h>
253 static void set_led(int pf, int state)
256 case STATUS_LED_OFF: bfin_write_FIO_FLAG_S(pf); break;
257 case STATUS_LED_BLINKING: bfin_write_FIO_FLAG_T(pf); break;
258 case STATUS_LED_ON: bfin_write_FIO_FLAG_C(pf); break;
262 static void set_leds(led_id_t mask, int state)
264 if (mask & 0x1) set_led(PF2, state);
265 if (mask & 0x2) set_led(PF3, state);
266 if (mask & 0x4) set_led(PF4, state);
269 void __led_init(led_id_t mask, int state)
271 bfin_write_FIO_INEN(bfin_read_FIO_INEN() & ~(PF2 | PF3 | PF4));
272 bfin_write_FIO_DIR(bfin_read_FIO_DIR() | (PF2 | PF3 | PF4));
275 void __led_set(led_id_t mask, int state)
277 set_leds(mask, state);
280 void __led_toggle(led_id_t mask)
282 set_leds(mask, STATUS_LED_BLINKING);