]>
git.ipfire.org Git - people/ms/u-boot.git/blob - board/bf537-stamp/bf537-stamp.c
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,
31 #include <asm/blackfin.h>
33 #include "ether_bf537.h"
35 #define POST_WORD_ADDR 0xFF903FFC
38 * the bootldr command loads an address, checks to see if there
39 * is a Boot stream that the on-chip BOOTROM can understand,
40 * and loads it via the BOOTROM Callback. It is possible
41 * to also add booting from SPI, or TWI, but this function does
42 * not currently support that.
44 int do_bootldr(cmd_tbl_t
* cmdtp
, int flag
, int argc
, char *argv
[])
53 addr
= simple_strtoul(argv
[1], NULL
, 16);
56 /* Check if it is a LDR file */
57 data
= (ulong
*) addr
;
58 if (*data
== 0xFF800060 || *data
== 0xFF800040 || *data
== 0xFF800020) {
59 /* We want to boot from FLASH or SDRAM */
60 entry
= _BOOTROM_BOOT_DXE_FLASH
;
61 printf("## Booting ldr image at 0x%08lx ...\n", addr
);
67 __asm__("R7=%[a];\n" "P0=%[b];\n" "JUMP (P0);\n":
68 :[a
] "d"(addr
),[b
] "a"(entry
)
72 printf("## No ldr image at address 0x%08lx\n", addr
);
78 U_BOOT_CMD(bootldr
, 2, 0, do_bootldr
,
79 "bootldr - boot ldr image from memory\n",
80 "[addr]\n - boot ldr image stored in memory\n");
84 #if (BFIN_CPU == ADSP_BF534)
85 printf("CPU: ADSP BF534 Rev.: 0.%d\n", *pCHIPID
>> 28);
86 #elif (BFIN_CPU == ADSP_BF536)
87 printf("CPU: ADSP BF536 Rev.: 0.%d\n", *pCHIPID
>> 28);
89 printf("CPU: ADSP BF537 Rev.: 0.%d\n", *pCHIPID
>> 28);
91 printf("Board: ADI BF537 stamp board\n");
92 printf(" Support: http://blackfin.uclinux.org/\n");
96 #if defined(CONFIG_BFIN_IDE)
98 void cf_outb(unsigned char val
, volatile unsigned char *addr
)
104 unsigned char cf_inb(volatile unsigned char *addr
)
106 volatile unsigned char c
;
114 void cf_insw(unsigned short *sect_buf
, unsigned short *addr
, int words
)
118 for (i
= 0; i
< words
; i
++)
119 *(sect_buf
+ i
) = *(addr
);
123 void cf_outsw(unsigned short *addr
, unsigned short *sect_buf
, int words
)
127 for (i
= 0; i
< words
; i
++)
128 *(addr
) = *(sect_buf
+ i
);
131 #endif /* CONFIG_BFIN_IDE */
133 long int initdram(int board_type
)
135 DECLARE_GLOBAL_DATA_PTR
;
138 char *tmp
= getenv("baudrate");
139 brate
= simple_strtoul(tmp
, NULL
, 16);
140 printf("Serial Port initialized with Baud rate = %x\n", brate
);
141 printf("SDRAM attributes:\n");
142 printf("tRCD %d SCLK Cycles,tRP %d SCLK Cycles,tRAS %d SCLK Cycles"
143 "tWR %d SCLK Cycles,CAS Latency %d SCLK cycles \n",
145 printf("SDRAM Begin: 0x%x\n", CFG_SDRAM_BASE
);
146 printf("Bank size = %d MB\n", CFG_MAX_RAM_SIZE
>> 20);
148 gd
->bd
->bi_memstart
= CFG_SDRAM_BASE
;
149 gd
->bd
->bi_memsize
= CFG_MAX_RAM_SIZE
;
150 return CFG_MAX_RAM_SIZE
;
153 #if defined(CONFIG_MISC_INIT_R)
154 /* miscellaneous platform dependent initialisations */
155 int misc_init_r(void)
157 #if (BFIN_BOOT_MODE == BF537_BYPASS_BOOT)
159 unsigned char *pMACaddr
= (unsigned char *)0x203F0000;
160 u8 SrcAddr
[6] = { 0x02, 0x80, 0xAD, 0x20, 0x31, 0xB8 };
162 #if (CONFIG_COMMANDS & CFG_CMD_NET)
163 /* The 0xFF check here is to make sure we don't use the address
164 * in flash if it's simply been erased (aka all 0xFF values) */
165 if (getenv("ethaddr") == NULL
&& is_valid_ether_addr(pMACaddr
)) {
166 sprintf(nid
, "%02x:%02x:%02x:%02x:%02x:%02x",
167 pMACaddr
[0], pMACaddr
[1],
168 pMACaddr
[2], pMACaddr
[3], pMACaddr
[4], pMACaddr
[5]);
169 setenv("ethaddr", nid
);
171 if (getenv("ethaddr")) {
172 SetupMacAddr(SrcAddr
);
174 #endif /* CONFIG_COMMANDS & CFG_CMD_NET */
175 #endif /* BFIN_BOOT_MODE == BF537_BYPASS_BOOT */
177 #if defined(CONFIG_BFIN_IDE)
178 #if defined(CONFIG_BFIN_TRUE_IDE)
179 /* Enable ATASEL when in True IDE mode */
180 printf("Using CF True IDE Mode\n");
181 cf_outb(0, (unsigned char *)CONFIG_CF_ATASEL_ENA
);
183 #elif defined(CONFIG_BFIN_CF_IDE)
184 /* Disable ATASEL when we're in Common Memory Mode */
185 printf("Using CF Common Memory Mode\n");
186 cf_outb(0, (unsigned char *)CONFIG_CF_ATASEL_DIS
);
188 #elif defined(CONFIG_BFIN_HDD_IDE)
189 printf("Using HDD IDE Mode\n");
192 #endif /* CONFIG_BFIN_IDE */
195 #endif /* CONFIG_MISC_INIT_R */
198 #if (BFIN_BOOT_MODE != BF537_BYPASS_BOOT)
199 /* Using sw10-PF5 as the hotkey */
200 int post_hotkeys_pressed(void)
205 /* Using sw10-PF5 as the hotkey */
206 int post_hotkeys_pressed(void)
210 unsigned short value
;
213 *pPORTFIO_DIR
&= ~PF5
;
214 *pPORTFIO_INEN
|= PF5
;
216 printf("########Press SW10 to enter Memory POST########: %2d ", delay
);
218 for (i
= 0; i
< 100; i
++) {
219 value
= *pPORTFIO
& PF5
;
225 printf("\b\b\b%2d ", delay
);
232 printf("Hotkey has been pressed, Enter POST . . . . . .\n");
239 #if defined(CONFIG_POST) || defined(CONFIG_LOGBUFFER)
240 void post_word_store(ulong a
)
242 volatile ulong
*save_addr
= (volatile ulong
*)POST_WORD_ADDR
;
246 ulong
post_word_load(void)
248 volatile ulong
*save_addr
= (volatile ulong
*)POST_WORD_ADDR
;
254 int uart_post_test(int flags
)
259 #define BLOCK_SIZE 0x10000
260 #define VERIFY_ADDR 0x2000000
261 extern int erase_block_flash(int);
262 extern int write_data(long lStart
, long lCount
, uchar
* pnData
);
263 int flash_post_test(int flags
)
265 unsigned short *pbuf
, *temp
;
270 pbuf
= (unsigned short *)VERIFY_ADDR
;
272 for (n
= FLASH_START_POST_BLOCK
; n
< FLASH_END_POST_BLOCK
; n
++) {
273 offset
= (n
- 7) * BLOCK_SIZE
;
274 printf("--------Erase block:%2d..", n
);
275 erase_block_flash(n
);
277 printf("--------Program block:%2d...", n
);
278 write_data(CFG_FLASH_BASE
+ offset
, BLOCK_SIZE
, pbuf
);
280 printf("--------Verify block:%2d...", n
);
281 for (i
= 0; i
< BLOCK_SIZE
; i
+= 2) {
282 if (*(unsigned short *)(CFG_FLASH_BASE
+ offset
+ i
) !=
294 FLASH_START_POST_BLOCK
) *
295 100 / (FLASH_END_POST_BLOCK
-
296 FLASH_START_POST_BLOCK
)));
308 /****************************************************
309 * LED1 ---- PF6 LED2 ---- PF7 *
310 * LED3 ---- PF8 LED4 ---- PF9 *
311 * LED5 ---- PF10 LED6 ---- PF11 *
312 ****************************************************/
313 int led_post_test(int flags
)
315 *pPORTF_FER
&= ~(PF6
| PF7
| PF8
| PF9
| PF10
| PF11
);
316 *pPORTFIO_DIR
|= PF6
| PF7
| PF8
| PF9
| PF10
| PF11
;
317 *pPORTFIO_INEN
&= ~(PF6
| PF7
| PF8
| PF9
| PF10
| PF11
);
318 *pPORTFIO
&= ~(PF6
| PF7
| PF8
| PF9
| PF10
| PF11
);
323 printf("\b\b\b\b\b\b\b");
327 printf("\b\b\b\b\b\b\b");
331 printf("\b\b\b\b\b\b\b");
335 printf("\b\b\b\b\b\b\b");
339 printf("\b\b\b\b\b\b\b");
342 printf("\b\b\b\b\b\b\b ");
346 /************************************************
347 * SW10 ---- PF5 SW11 ---- PF4 *
348 * SW12 ---- PF3 SW13 ---- PF2 *
349 ************************************************/
350 int button_post_test(int flags
)
353 unsigned short value
= 0;
356 *pPORTF_FER
&= ~(PF5
| PF4
| PF3
| PF2
);
357 *pPORTFIO_DIR
&= ~(PF5
| PF4
| PF3
| PF2
);
358 *pPORTFIO_INEN
|= (PF5
| PF4
| PF3
| PF2
);
360 printf("\n--------Press SW10: %2d ", delay
);
362 for (i
= 0; i
< 100; i
++) {
363 value
= *pPORTFIO
& PF5
;
369 printf("\b\b\b%2d ", delay
);
375 printf("\b\bfailed");
379 printf("\n--------Press SW11: %2d ", delay
);
381 for (i
= 0; i
< 100; i
++) {
382 value
= *pPORTFIO
& PF4
;
388 printf("\b\b\b%2d ", delay
);
394 printf("\b\bfailed");
398 printf("\n--------Press SW12: %2d ", delay
);
400 for (i
= 0; i
< 100; i
++) {
401 value
= *pPORTFIO
& PF3
;
407 printf("\b\b\b%2d ", delay
);
413 printf("\b\bfailed");
417 printf("\n--------Press SW13: %2d ", delay
);
419 for (i
= 0; i
< 100; i
++) {
420 value
= *pPORTFIO
& PF2
;
426 printf("\b\b\b%2d ", delay
);
432 printf("\b\bfailed");