]> git.ipfire.org Git - people/ms/u-boot.git/blame - board/bf533-stamp/bf533-stamp.c
rename CFG_ macros to CONFIG_SYS
[people/ms/u-boot.git] / board / bf533-stamp / bf533-stamp.c
CommitLineData
6cb142fa
WD
1/*
2 * U-boot - stamp.c STAMP board specific routines
3 *
155fd766 4 * Copyright (c) 2005-2007 Analog Devices Inc.
6cb142fa
WD
5 *
6 * (C) Copyright 2000-2004
7 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
8 *
9 * See file CREDITS for list of people who contributed to this
10 * project.
11 *
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.
16 *
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.
21 *
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
155fd766
AL
24 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
25 * MA 02110-1301 USA
6cb142fa
WD
26 */
27
28#include <common.h>
29#include <asm/mem_init.h>
8440bb14 30#include <asm/io.h>
3f0606ad 31#include "bf533-stamp.h"
d87080b7 32
1218abf1
WD
33DECLARE_GLOBAL_DATA_PTR;
34
6cb142fa 35#define STATUS_LED_OFF 0
8e7b703a 36#define STATUS_LED_ON 1
6cb142fa
WD
37
38#ifdef CONFIG_SHOW_BOOT_PROGRESS
39# define SHOW_BOOT_PROGRESS(arg) show_boot_progress(arg)
40#else
8e7b703a 41# define SHOW_BOOT_PROGRESS(arg)
6cb142fa
WD
42#endif
43
3f0606ad 44int checkboard(void)
6cb142fa 45{
3f0606ad
AL
46 printf("Board: ADI BF533 Stamp board\n");
47 printf(" Support: http://blackfin.uclinux.org/\n");
6cb142fa
WD
48 return 0;
49}
50
9973e3c6 51phys_size_t initdram(int board_type)
6cb142fa 52{
6cb142fa 53#ifdef DEBUG
3f0606ad
AL
54 printf("SDRAM attributes:\n");
55 printf
56 (" tRCD:%d Cycles; tRP:%d Cycles; tRAS:%d Cycles; tWR:%d Cycles; "
57 "CAS Latency:%d cycles\n", (SDRAM_tRCD >> 15), (SDRAM_tRP >> 11),
58 (SDRAM_tRAS >> 6), (SDRAM_tWR >> 19), (SDRAM_CL >> 2));
6d0f6bcf 59 printf("SDRAM Begin: 0x%x\n", CONFIG_SYS_SDRAM_BASE);
3f0606ad 60 printf("Bank size = %d MB\n", 128);
6cb142fa 61#endif
6d0f6bcf
JCPV
62 gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
63 gd->bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
6cb142fa
WD
64 return (gd->bd->bi_memsize);
65}
66
3f0606ad 67void swap_to(int device_id)
6cb142fa
WD
68{
69
8e7b703a 70 if (device_id == ETHERNET) {
6cb142fa 71 *pFIO_DIR = PF0;
d4d77308 72 SSYNC();
6cb142fa 73 *pFIO_FLAG_S = PF0;
d4d77308 74 SSYNC();
8e7b703a 75 } else if (device_id == FLASH) {
6cb142fa 76 *pFIO_DIR = (PF4 | PF3 | PF2 | PF1 | PF0);
8e7b703a 77 *pFIO_FLAG_S = (PF4 | PF3 | PF2);
6cb142fa
WD
78 *pFIO_MASKA_D = (PF8 | PF6 | PF5);
79 *pFIO_MASKB_D = (PF7);
8e7b703a 80 *pFIO_POLAR = (PF8 | PF6 | PF5);
6cb142fa
WD
81 *pFIO_EDGE = (PF8 | PF7 | PF6 | PF5);
82 *pFIO_INEN = (PF8 | PF7 | PF6 | PF5);
8e7b703a 83 *pFIO_FLAG_D = (PF4 | PF3 | PF2);
d4d77308 84 SSYNC();
8e7b703a 85 } else {
3f0606ad 86 printf("Unknown bank to switch\n");
6cb142fa 87 }
8e7b703a 88
6cb142fa
WD
89 return;
90}
91
92#if defined(CONFIG_MISC_INIT_R)
93/* miscellaneous platform dependent initialisations */
3f0606ad 94int misc_init_r(void)
6cb142fa
WD
95{
96 int i;
97 int cf_stat = 0;
98
99 /* Check whether CF card is inserted */
100 *pFIO_EDGE = FIO_EDGE_CF_BITS;
101 *pFIO_POLAR = FIO_POLAR_CF_BITS;
8e7b703a 102 for (i = 0; i < 0x300; i++)
3f0606ad 103 asm("nop;");
8e7b703a
WD
104
105 if ((*pFIO_FLAG_S) & CF_STAT_BITS) {
6cb142fa 106 cf_stat = 0;
8e7b703a 107 } else {
6cb142fa
WD
108 cf_stat = 1;
109 }
110
8e7b703a 111 *pFIO_EDGE = FIO_EDGE_BITS;
6cb142fa 112 *pFIO_POLAR = FIO_POLAR_BITS;
6cb142fa 113
8e7b703a 114 if (cf_stat) {
3f0606ad 115 printf("Booting from COMPACT flash\n");
6cb142fa
WD
116
117 /* Set cycle time for CF */
3f0606ad 118 *(volatile unsigned long *)ambctl1 = CF_AMBCTL1VAL;
6cb142fa 119
8e7b703a 120 for (i = 0; i < 0x1000; i++)
3f0606ad 121 asm("nop;");
8e7b703a 122 for (i = 0; i < 0x1000; i++)
3f0606ad 123 asm("nop;");
8e7b703a 124 for (i = 0; i < 0x1000; i++)
3f0606ad 125 asm("nop;");
6cb142fa 126
3f0606ad
AL
127 serial_setbrg();
128 ide_init();
6cb142fa 129
3f0606ad
AL
130 setenv("bootargs", "");
131 setenv("bootcmd",
132 "fatload ide 0:1 0x1000000 uImage-stamp;bootm 0x1000000;bootm 0x20100000");
8e7b703a 133 } else {
3f0606ad 134 printf("Booting from FLASH\n");
6cb142fa
WD
135 }
136
3f0606ad 137 return 0;
6cb142fa
WD
138}
139#endif
140
141#ifdef CONFIG_STAMP_CF
142
3f0606ad 143void cf_outb(unsigned char val, volatile unsigned char *addr)
6cb142fa 144{
8e7b703a 145 /*
6cb142fa 146 * Set PF1 PF0 respectively to 0 1 to divert address
8e7b703a 147 * to the expansion memory banks
6cb142fa
WD
148 */
149 *pFIO_FLAG_S = CF_PF0;
150 *pFIO_FLAG_C = CF_PF1;
d4d77308 151 SSYNC();
6cb142fa
WD
152
153 *(addr) = val;
d4d77308 154 SSYNC();
6cb142fa 155
8e7b703a 156 /* Setback PF1 PF0 to 0 0 to address external
6cb142fa 157 * memory banks */
3f0606ad 158 *(volatile unsigned short *)pFIO_FLAG_C = CF_PF1_PF0;
d4d77308 159 SSYNC();
6cb142fa
WD
160}
161
3f0606ad 162unsigned char cf_inb(volatile unsigned char *addr)
6cb142fa
WD
163{
164 volatile unsigned char c;
165
166 *pFIO_FLAG_S = CF_PF0;
167 *pFIO_FLAG_C = CF_PF1;
d4d77308 168 SSYNC();
6cb142fa
WD
169
170 c = *(addr);
d4d77308 171 SSYNC();
6cb142fa
WD
172
173 *pFIO_FLAG_C = CF_PF1_PF0;
d4d77308 174 SSYNC();
6cb142fa
WD
175
176 return c;
177}
178
3f0606ad 179void cf_insw(unsigned short *sect_buf, unsigned short *addr, int words)
6cb142fa
WD
180{
181 int i;
182
183 *pFIO_FLAG_S = CF_PF0;
184 *pFIO_FLAG_C = CF_PF1;
d4d77308 185 SSYNC();
6cb142fa 186
8e7b703a 187 for (i = 0; i < words; i++) {
6cb142fa 188 *(sect_buf + i) = *(addr);
d4d77308 189 SSYNC();
6cb142fa
WD
190 }
191
192 *pFIO_FLAG_C = CF_PF1_PF0;
d4d77308 193 SSYNC();
6cb142fa
WD
194}
195
3f0606ad 196void cf_outsw(unsigned short *addr, unsigned short *sect_buf, int words)
6cb142fa
WD
197{
198 int i;
199
200 *pFIO_FLAG_S = CF_PF0;
201 *pFIO_FLAG_C = CF_PF1;
d4d77308 202 SSYNC();
6cb142fa 203
8e7b703a 204 for (i = 0; i < words; i++) {
6cb142fa 205 *(addr) = *(sect_buf + i);
d4d77308 206 SSYNC();
6cb142fa
WD
207 }
208
209 *pFIO_FLAG_C = CF_PF1_PF0;
d4d77308 210 SSYNC();
6cb142fa
WD
211}
212#endif
213
3f0606ad 214void stamp_led_set(int LED1, int LED2, int LED3)
6cb142fa 215{
8e7b703a
WD
216 *pFIO_INEN &= ~(PF2 | PF3 | PF4);
217 *pFIO_DIR |= (PF2 | PF3 | PF4);
218
219 if (LED1 == STATUS_LED_OFF)
6cb142fa
WD
220 *pFIO_FLAG_S = PF2;
221 else
222 *pFIO_FLAG_C = PF2;
8e7b703a 223 if (LED2 == STATUS_LED_OFF)
6cb142fa
WD
224 *pFIO_FLAG_S = PF3;
225 else
226 *pFIO_FLAG_C = PF3;
8e7b703a 227 if (LED3 == STATUS_LED_OFF)
6cb142fa
WD
228 *pFIO_FLAG_S = PF4;
229 else
230 *pFIO_FLAG_C = PF4;
d4d77308 231 SSYNC();
6cb142fa
WD
232}
233
3f0606ad 234void show_boot_progress(int status)
6cb142fa 235{
8e7b703a
WD
236 switch (status) {
237 case 1:
3f0606ad 238 stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_ON);
8e7b703a
WD
239 break;
240 case 2:
3f0606ad 241 stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_OFF);
8e7b703a
WD
242 break;
243 case 3:
3f0606ad 244 stamp_led_set(STATUS_LED_OFF, STATUS_LED_ON, STATUS_LED_ON);
8e7b703a
WD
245 break;
246 case 4:
3f0606ad 247 stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_OFF);
8e7b703a
WD
248 break;
249 case 5:
250 case 6:
3f0606ad 251 stamp_led_set(STATUS_LED_ON, STATUS_LED_OFF, STATUS_LED_ON);
8e7b703a
WD
252 break;
253 case 7:
254 case 8:
3f0606ad 255 stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_OFF);
8e7b703a
WD
256 break;
257 case 9:
258 case 10:
259 case 11:
260 case 12:
261 case 13:
262 case 14:
263 case 15:
3f0606ad 264 stamp_led_set(STATUS_LED_OFF, STATUS_LED_OFF, STATUS_LED_OFF);
8e7b703a
WD
265 break;
266 default:
3f0606ad 267 stamp_led_set(STATUS_LED_ON, STATUS_LED_ON, STATUS_LED_ON);
8e7b703a 268 break;
6cb142fa
WD
269 }
270}