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)
53 printf("SDRAM attributes:\n");
55 (" tRCD:%d Cycles; tRP:%d Cycles; tRAS:%d Cycles; tWR:%d Cycles; "
56 "CAS Latency:%d cycles\n", (SDRAM_tRCD >> 15), (SDRAM_tRP >> 11),
57 (SDRAM_tRAS >> 6), (SDRAM_tWR >> 19), (SDRAM_CL >> 2));
58 printf("SDRAM Begin: 0x%x\n", CONFIG_SYS_SDRAM_BASE);
59 printf("Bank size = %d MB\n", 128);
61 gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
62 gd->bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
63 return (gd->bd->bi_memsize);
66 void swap_to(int device_id)
69 if (device_id == ETHERNET) {
74 } else if (device_id == FLASH) {
75 *pFIO_DIR = (PF4 | PF3 | PF2 | PF1 | PF0);
76 *pFIO_FLAG_S = (PF4 | PF3 | PF2);
77 *pFIO_MASKA_D = (PF8 | PF6 | PF5);
78 *pFIO_MASKB_D = (PF7);
79 *pFIO_POLAR = (PF8 | PF6 | PF5);
80 *pFIO_EDGE = (PF8 | PF7 | PF6 | PF5);
81 *pFIO_INEN = (PF8 | PF7 | PF6 | PF5);
82 *pFIO_FLAG_D = (PF4 | PF3 | PF2);
85 printf("Unknown bank to switch\n");
91 #if defined(CONFIG_MISC_INIT_R)
92 /* miscellaneous platform dependent initialisations */
98 /* Check whether CF card is inserted */
99 *pFIO_EDGE = FIO_EDGE_CF_BITS;
100 *pFIO_POLAR = FIO_POLAR_CF_BITS;
101 for (i = 0; i < 0x300; i++)
104 if ((*pFIO_FLAG_S) & CF_STAT_BITS) {
110 *pFIO_EDGE = FIO_EDGE_BITS;
111 *pFIO_POLAR = FIO_POLAR_BITS;
114 printf("Booting from COMPACT flash\n");
116 /* Set cycle time for CF */
117 *(volatile unsigned long *)ambctl1 = CF_AMBCTL1VAL;
119 for (i = 0; i < 0x1000; i++)
121 for (i = 0; i < 0x1000; i++)
123 for (i = 0; i < 0x1000; i++)
129 setenv("bootargs", "");
131 "fatload ide 0:1 0x1000000 uImage-stamp;bootm 0x1000000;bootm 0x20100000");
133 printf("Booting from FLASH\n");
140 #ifdef CONFIG_STAMP_CF
142 void cf_outb(unsigned char val, volatile unsigned char *addr)
145 * Set PF1 PF0 respectively to 0 1 to divert address
146 * to the expansion memory banks
148 *pFIO_FLAG_S = CF_PF0;
149 *pFIO_FLAG_C = CF_PF1;
155 /* Setback PF1 PF0 to 0 0 to address external
157 *(volatile unsigned short *)pFIO_FLAG_C = CF_PF1_PF0;
161 unsigned char cf_inb(volatile unsigned char *addr)
163 volatile unsigned char c;
165 *pFIO_FLAG_S = CF_PF0;
166 *pFIO_FLAG_C = CF_PF1;
172 *pFIO_FLAG_C = CF_PF1_PF0;
178 void cf_insw(unsigned short *sect_buf, unsigned short *addr, int words)
182 *pFIO_FLAG_S = CF_PF0;
183 *pFIO_FLAG_C = CF_PF1;
186 for (i = 0; i < words; i++) {
187 *(sect_buf + i) = *(addr);
191 *pFIO_FLAG_C = CF_PF1_PF0;
195 void cf_outsw(unsigned short *addr, unsigned short *sect_buf, int words)
199 *pFIO_FLAG_S = CF_PF0;
200 *pFIO_FLAG_C = CF_PF1;
203 for (i = 0; i < words; i++) {
204 *(addr) = *(sect_buf + i);
208 *pFIO_FLAG_C = CF_PF1_PF0;
213 void stamp_led_set(int LED1, int LED2, int LED3)
215 *pFIO_INEN &= ~(PF2 | PF3 | PF4);
216 *pFIO_DIR |= (PF2 | PF3 | PF4);
218 if (LED1 == STATUS_LED_OFF)
222 if (LED2 == STATUS_LED_OFF)
226 if (LED3 == STATUS_LED_OFF)
233 void show_boot_progress(int status)
237 stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_ON);
240 stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_OFF);
243 stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_ON);
246 stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_OFF);
250 stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_ON);
254 stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_OFF);
263 stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_OFF);
266 stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_ON);