2 * U-boot - stamp.c STAMP board specific routines
4 * Copyright (c) 2005-2007 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;
34 #define STATUS_LED_OFF 0
35 #define STATUS_LED_ON 1
37 #ifdef CONFIG_SHOW_BOOT_PROGRESS
38 # define SHOW_BOOT_PROGRESS(arg) show_boot_progress(arg)
40 # define SHOW_BOOT_PROGRESS(arg)
45 printf("Board: ADI BF533 Stamp board\n");
46 printf(" Support: http://blackfin.uclinux.org/\n");
50 phys_size_t initdram(int board_type)
52 gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
53 gd->bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
54 return gd->bd->bi_memsize;
57 void swap_to(int device_id)
60 if (device_id == ETHERNET) {
65 } else if (device_id == FLASH) {
66 *pFIO_DIR = (PF4 | PF3 | PF2 | PF1 | PF0);
67 *pFIO_FLAG_S = (PF4 | PF3 | PF2);
68 *pFIO_MASKA_D = (PF8 | PF6 | PF5);
69 *pFIO_MASKB_D = (PF7);
70 *pFIO_POLAR = (PF8 | PF6 | PF5);
71 *pFIO_EDGE = (PF8 | PF7 | PF6 | PF5);
72 *pFIO_INEN = (PF8 | PF7 | PF6 | PF5);
73 *pFIO_FLAG_D = (PF4 | PF3 | PF2);
76 printf("Unknown bank to switch\n");
82 #if defined(CONFIG_MISC_INIT_R)
83 /* miscellaneous platform dependent initialisations */
89 /* Check whether CF card is inserted */
90 *pFIO_EDGE = FIO_EDGE_CF_BITS;
91 *pFIO_POLAR = FIO_POLAR_CF_BITS;
92 for (i = 0; i < 0x300; i++)
95 if ((*pFIO_FLAG_S) & CF_STAT_BITS) {
101 *pFIO_EDGE = FIO_EDGE_BITS;
102 *pFIO_POLAR = FIO_POLAR_BITS;
105 printf("Booting from COMPACT flash\n");
107 /* Set cycle time for CF */
108 *(volatile unsigned long *)ambctl1 = CF_AMBCTL1VAL;
110 for (i = 0; i < 0x1000; i++)
112 for (i = 0; i < 0x1000; i++)
114 for (i = 0; i < 0x1000; i++)
120 setenv("bootargs", "");
122 "fatload ide 0:1 0x1000000 uImage-stamp;bootm 0x1000000;bootm 0x20100000");
124 printf("Booting from FLASH\n");
131 #ifdef CONFIG_STAMP_CF
133 void cf_outb(unsigned char val, volatile unsigned char *addr)
136 * Set PF1 PF0 respectively to 0 1 to divert address
137 * to the expansion memory banks
139 *pFIO_FLAG_S = CF_PF0;
140 *pFIO_FLAG_C = CF_PF1;
146 /* Setback PF1 PF0 to 0 0 to address external
148 *(volatile unsigned short *)pFIO_FLAG_C = CF_PF1_PF0;
152 unsigned char cf_inb(volatile unsigned char *addr)
154 volatile unsigned char c;
156 *pFIO_FLAG_S = CF_PF0;
157 *pFIO_FLAG_C = CF_PF1;
163 *pFIO_FLAG_C = CF_PF1_PF0;
169 void cf_insw(unsigned short *sect_buf, unsigned short *addr, int words)
173 *pFIO_FLAG_S = CF_PF0;
174 *pFIO_FLAG_C = CF_PF1;
177 for (i = 0; i < words; i++) {
178 *(sect_buf + i) = *(addr);
182 *pFIO_FLAG_C = CF_PF1_PF0;
186 void cf_outsw(unsigned short *addr, unsigned short *sect_buf, int words)
190 *pFIO_FLAG_S = CF_PF0;
191 *pFIO_FLAG_C = CF_PF1;
194 for (i = 0; i < words; i++) {
195 *(addr) = *(sect_buf + i);
199 *pFIO_FLAG_C = CF_PF1_PF0;
204 void stamp_led_set(int LED1, int LED2, int LED3)
206 *pFIO_INEN &= ~(PF2 | PF3 | PF4);
207 *pFIO_DIR |= (PF2 | PF3 | PF4);
209 if (LED1 == STATUS_LED_OFF)
213 if (LED2 == STATUS_LED_OFF)
217 if (LED3 == STATUS_LED_OFF)
224 void show_boot_progress(int status)
228 stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_ON);
231 stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_OFF);
234 stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_ON);
237 stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_OFF);
241 stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_ON);
245 stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_OFF);
254 stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_OFF);
257 stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_ON);