2 * U-boot - stamp.c STAMP board specific routines
4 * Copyright (c) 2005 blackfin.uclinux.org
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., 59 Temple Place, Suite 330, Boston,
29 #include <asm/mem_init.h>
30 #include "bf533-stamp.h"
32 #define STATUS_LED_OFF 0
33 #define STATUS_LED_ON 1
35 #ifdef CONFIG_SHOW_BOOT_PROGRESS
36 # define SHOW_BOOT_PROGRESS(arg) show_boot_progress(arg)
38 # define SHOW_BOOT_PROGRESS(arg)
43 #if (BFIN_CPU == ADSP_BF531)
44 printf("CPU: ADSP BF531 Rev.: 0.%d\n", *pCHIPID >> 28);
45 #elif (BFIN_CPU == ADSP_BF532)
46 printf("CPU: ADSP BF532 Rev.: 0.%d\n", *pCHIPID >> 28);
48 printf("CPU: ADSP BF533 Rev.: 0.%d\n", *pCHIPID >> 28);
50 printf("Board: ADI BF533 Stamp board\n");
51 printf(" Support: http://blackfin.uclinux.org/\n");
55 long int initdram(int board_type)
57 DECLARE_GLOBAL_DATA_PTR;
59 printf("SDRAM attributes:\n");
61 (" tRCD:%d Cycles; tRP:%d Cycles; tRAS:%d Cycles; tWR:%d Cycles; "
62 "CAS Latency:%d cycles\n", (SDRAM_tRCD >> 15), (SDRAM_tRP >> 11),
63 (SDRAM_tRAS >> 6), (SDRAM_tWR >> 19), (SDRAM_CL >> 2));
64 printf("SDRAM Begin: 0x%x\n", CFG_SDRAM_BASE);
65 printf("Bank size = %d MB\n", 128);
67 gd->bd->bi_memstart = CFG_SDRAM_BASE;
68 gd->bd->bi_memsize = CFG_MAX_RAM_SIZE;
69 return (gd->bd->bi_memsize);
72 void swap_to(int device_id)
75 if (device_id == ETHERNET) {
77 __builtin_bfin_ssync();
79 __builtin_bfin_ssync();
80 } else if (device_id == FLASH) {
81 *pFIO_DIR = (PF4 | PF3 | PF2 | PF1 | PF0);
82 *pFIO_FLAG_S = (PF4 | PF3 | PF2);
83 *pFIO_MASKA_D = (PF8 | PF6 | PF5);
84 *pFIO_MASKB_D = (PF7);
85 *pFIO_POLAR = (PF8 | PF6 | PF5);
86 *pFIO_EDGE = (PF8 | PF7 | PF6 | PF5);
87 *pFIO_INEN = (PF8 | PF7 | PF6 | PF5);
88 *pFIO_FLAG_D = (PF4 | PF3 | PF2);
89 __builtin_bfin_ssync();
91 printf("Unknown bank to switch\n");
97 #if defined(CONFIG_MISC_INIT_R)
98 /* miscellaneous platform dependent initialisations */
104 /* Check whether CF card is inserted */
105 *pFIO_EDGE = FIO_EDGE_CF_BITS;
106 *pFIO_POLAR = FIO_POLAR_CF_BITS;
107 for (i = 0; i < 0x300; i++)
110 if ((*pFIO_FLAG_S) & CF_STAT_BITS) {
116 *pFIO_EDGE = FIO_EDGE_BITS;
117 *pFIO_POLAR = FIO_POLAR_BITS;
120 printf("Booting from COMPACT flash\n");
122 /* Set cycle time for CF */
123 *(volatile unsigned long *)ambctl1 = CF_AMBCTL1VAL;
125 for (i = 0; i < 0x1000; i++)
127 for (i = 0; i < 0x1000; i++)
129 for (i = 0; i < 0x1000; i++)
135 setenv("bootargs", "");
137 "fatload ide 0:1 0x1000000 uImage-stamp;bootm 0x1000000;bootm 0x20100000");
139 printf("Booting from FLASH\n");
146 #ifdef CONFIG_STAMP_CF
148 void cf_outb(unsigned char val, volatile unsigned char *addr)
151 * Set PF1 PF0 respectively to 0 1 to divert address
152 * to the expansion memory banks
154 *pFIO_FLAG_S = CF_PF0;
155 *pFIO_FLAG_C = CF_PF1;
156 __builtin_bfin_ssync();
159 __builtin_bfin_ssync();
161 /* Setback PF1 PF0 to 0 0 to address external
163 *(volatile unsigned short *)pFIO_FLAG_C = CF_PF1_PF0;
164 __builtin_bfin_ssync();
167 unsigned char cf_inb(volatile unsigned char *addr)
169 volatile unsigned char c;
171 *pFIO_FLAG_S = CF_PF0;
172 *pFIO_FLAG_C = CF_PF1;
173 __builtin_bfin_ssync();
176 __builtin_bfin_ssync();
178 *pFIO_FLAG_C = CF_PF1_PF0;
179 __builtin_bfin_ssync();
184 void cf_insw(unsigned short *sect_buf, unsigned short *addr, int words)
188 *pFIO_FLAG_S = CF_PF0;
189 *pFIO_FLAG_C = CF_PF1;
190 __builtin_bfin_ssync();
192 for (i = 0; i < words; i++) {
193 *(sect_buf + i) = *(addr);
194 __builtin_bfin_ssync();
197 *pFIO_FLAG_C = CF_PF1_PF0;
198 __builtin_bfin_ssync();
201 void cf_outsw(unsigned short *addr, unsigned short *sect_buf, int words)
205 *pFIO_FLAG_S = CF_PF0;
206 *pFIO_FLAG_C = CF_PF1;
207 __builtin_bfin_ssync();
209 for (i = 0; i < words; i++) {
210 *(addr) = *(sect_buf + i);
211 __builtin_bfin_ssync();
214 *pFIO_FLAG_C = CF_PF1_PF0;
215 __builtin_bfin_ssync();
219 void stamp_led_set(int LED1, int LED2, int LED3)
221 *pFIO_INEN &= ~(PF2 | PF3 | PF4);
222 *pFIO_DIR |= (PF2 | PF3 | PF4);
224 if (LED1 == STATUS_LED_OFF)
228 if (LED2 == STATUS_LED_OFF)
232 if (LED3 == STATUS_LED_OFF)
236 __builtin_bfin_ssync();
239 void show_boot_progress(int status)
243 stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_ON);
246 stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_OFF);
249 stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_ON);
252 stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_OFF);
256 stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_ON);
260 stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_OFF);
269 stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_OFF);
272 stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_ON);