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