]>
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>
34 #include <asm/mach-common/bits/bootrom.h>
37 * is_valid_ether_addr - Determine if the given Ethernet address is valid
38 * @addr: Pointer to a six-byte array containing the Ethernet address
40 * Check that the Ethernet address (MAC) is not 00:00:00:00:00:00, is not
41 * a multicast address, and is not FF:FF:FF:FF:FF:FF.
43 * Return true if the address is valid.
45 static inline int is_valid_ether_addr(const u8
* addr
)
47 /* FF:FF:FF:FF:FF:FF is a multicast address so we don't need to
48 * explicitly check for it here. */
49 return !is_multicast_ether_addr(addr
) && !is_zero_ether_addr(addr
);
52 DECLARE_GLOBAL_DATA_PTR
;
54 #define POST_WORD_ADDR 0xFF903FFC
58 printf("Board: ADI BF537 stamp board\n");
59 printf(" Support: http://blackfin.uclinux.org/\n");
63 #if defined(CONFIG_BFIN_IDE)
65 void cf_outb(unsigned char val
, volatile unsigned char *addr
)
71 unsigned char cf_inb(volatile unsigned char *addr
)
73 volatile unsigned char c
;
81 void cf_insw(unsigned short *sect_buf
, unsigned short *addr
, int words
)
85 for (i
= 0; i
< words
; i
++)
86 *(sect_buf
+ i
) = *(addr
);
90 void cf_outsw(unsigned short *addr
, unsigned short *sect_buf
, int words
)
94 for (i
= 0; i
< words
; i
++)
95 *(addr
) = *(sect_buf
+ i
);
98 #endif /* CONFIG_BFIN_IDE */
100 phys_size_t
initdram(int board_type
)
104 char *tmp
= getenv("baudrate");
105 brate
= simple_strtoul(tmp
, NULL
, 16);
106 printf("Serial Port initialized with Baud rate = %x\n", brate
);
107 printf("SDRAM attributes:\n");
108 printf("tRCD %d SCLK Cycles,tRP %d SCLK Cycles,tRAS %d SCLK Cycles"
109 "tWR %d SCLK Cycles,CAS Latency %d SCLK cycles \n",
111 printf("SDRAM Begin: 0x%x\n", CFG_SDRAM_BASE
);
112 printf("Bank size = %d MB\n", CFG_MAX_RAM_SIZE
>> 20);
114 gd
->bd
->bi_memstart
= CFG_SDRAM_BASE
;
115 gd
->bd
->bi_memsize
= CFG_MAX_RAM_SIZE
;
116 return CFG_MAX_RAM_SIZE
;
119 #if defined(CONFIG_MISC_INIT_R)
120 /* miscellaneous platform dependent initialisations */
121 int misc_init_r(void)
123 #if defined(CONFIG_CMD_NET)
125 unsigned char *pMACaddr
= (unsigned char *)0x203F0000;
127 /* The 0xFF check here is to make sure we don't use the address
128 * in flash if it's simply been erased (aka all 0xFF values) */
129 if (getenv("ethaddr") == NULL
&& is_valid_ether_addr(pMACaddr
)) {
130 sprintf(nid
, "%02x:%02x:%02x:%02x:%02x:%02x",
131 pMACaddr
[0], pMACaddr
[1],
132 pMACaddr
[2], pMACaddr
[3], pMACaddr
[4], pMACaddr
[5]);
133 setenv("ethaddr", nid
);
137 #if defined(CONFIG_BFIN_IDE)
138 #if defined(CONFIG_BFIN_TRUE_IDE)
139 /* Enable ATASEL when in True IDE mode */
140 printf("Using CF True IDE Mode\n");
141 cf_outb(0, (unsigned char *)CONFIG_CF_ATASEL_ENA
);
143 #elif defined(CONFIG_BFIN_CF_IDE)
144 /* Disable ATASEL when we're in Common Memory Mode */
145 printf("Using CF Common Memory Mode\n");
146 cf_outb(0, (unsigned char *)CONFIG_CF_ATASEL_DIS
);
148 #elif defined(CONFIG_BFIN_HDD_IDE)
149 printf("Using HDD IDE Mode\n");
152 #endif /* CONFIG_BFIN_IDE */
155 #endif /* CONFIG_MISC_INIT_R */
157 #if defined(CONFIG_BFIN_MAC)
159 extern int bfin_EMAC_initialize(bd_t
*bis
);
161 int board_eth_init(bd_t
*bis
)
163 return bfin_EMAC_initialize(bis
);
168 /* Using sw10-PF5 as the hotkey */
169 int post_hotkeys_pressed(void)
173 unsigned short value
;
176 *pPORTFIO_DIR
&= ~PF5
;
177 *pPORTFIO_INEN
|= PF5
;
179 printf("########Press SW10 to enter Memory POST########: %2d ", delay
);
181 for (i
= 0; i
< 100; i
++) {
182 value
= *pPORTFIO
& PF5
;
188 printf("\b\b\b%2d ", delay
);
195 printf("Hotkey has been pressed, Enter POST . . . . . .\n");
201 #if defined(CONFIG_POST) || defined(CONFIG_LOGBUFFER)
202 void post_word_store(ulong a
)
204 volatile ulong
*save_addr
= (volatile ulong
*)POST_WORD_ADDR
;
208 ulong
post_word_load(void)
210 volatile ulong
*save_addr
= (volatile ulong
*)POST_WORD_ADDR
;
216 int uart_post_test(int flags
)
221 #define BLOCK_SIZE 0x10000
222 #define VERIFY_ADDR 0x2000000
223 extern int erase_block_flash(int);
224 extern int write_data(long lStart
, long lCount
, uchar
* pnData
);
225 int flash_post_test(int flags
)
227 unsigned short *pbuf
, *temp
;
232 pbuf
= (unsigned short *)VERIFY_ADDR
;
234 for (n
= FLASH_START_POST_BLOCK
; n
< FLASH_END_POST_BLOCK
; n
++) {
235 offset
= (n
- 7) * BLOCK_SIZE
;
236 printf("--------Erase block:%2d..", n
);
237 erase_block_flash(n
);
239 printf("--------Program block:%2d...", n
);
240 write_data(CFG_FLASH_BASE
+ offset
, BLOCK_SIZE
, pbuf
);
242 printf("--------Verify block:%2d...", n
);
243 for (i
= 0; i
< BLOCK_SIZE
; i
+= 2) {
244 if (*(unsigned short *)(CFG_FLASH_BASE
+ offset
+ i
) !=
256 FLASH_START_POST_BLOCK
) *
257 100 / (FLASH_END_POST_BLOCK
-
258 FLASH_START_POST_BLOCK
)));
270 /****************************************************
271 * LED1 ---- PF6 LED2 ---- PF7 *
272 * LED3 ---- PF8 LED4 ---- PF9 *
273 * LED5 ---- PF10 LED6 ---- PF11 *
274 ****************************************************/
275 int led_post_test(int flags
)
277 *pPORTF_FER
&= ~(PF6
| PF7
| PF8
| PF9
| PF10
| PF11
);
278 *pPORTFIO_DIR
|= PF6
| PF7
| PF8
| PF9
| PF10
| PF11
;
279 *pPORTFIO_INEN
&= ~(PF6
| PF7
| PF8
| PF9
| PF10
| PF11
);
280 *pPORTFIO
&= ~(PF6
| PF7
| PF8
| PF9
| PF10
| PF11
);
285 printf("\b\b\b\b\b\b\b");
289 printf("\b\b\b\b\b\b\b");
293 printf("\b\b\b\b\b\b\b");
297 printf("\b\b\b\b\b\b\b");
301 printf("\b\b\b\b\b\b\b");
304 printf("\b\b\b\b\b\b\b ");
308 /************************************************
309 * SW10 ---- PF5 SW11 ---- PF4 *
310 * SW12 ---- PF3 SW13 ---- PF2 *
311 ************************************************/
312 int button_post_test(int flags
)
315 unsigned short value
= 0;
318 *pPORTF_FER
&= ~(PF5
| PF4
| PF3
| PF2
);
319 *pPORTFIO_DIR
&= ~(PF5
| PF4
| PF3
| PF2
);
320 *pPORTFIO_INEN
|= (PF5
| PF4
| PF3
| PF2
);
322 printf("\n--------Press SW10: %2d ", delay
);
324 for (i
= 0; i
< 100; i
++) {
325 value
= *pPORTFIO
& PF5
;
331 printf("\b\b\b%2d ", delay
);
337 printf("\b\bfailed");
341 printf("\n--------Press SW11: %2d ", delay
);
343 for (i
= 0; i
< 100; i
++) {
344 value
= *pPORTFIO
& PF4
;
350 printf("\b\b\b%2d ", delay
);
356 printf("\b\bfailed");
360 printf("\n--------Press SW12: %2d ", delay
);
362 for (i
= 0; i
< 100; i
++) {
363 value
= *pPORTFIO
& PF3
;
369 printf("\b\b\b%2d ", delay
);
375 printf("\b\bfailed");
379 printf("\n--------Press SW13: %2d ", delay
);
381 for (i
= 0; i
< 100; i
++) {
382 value
= *pPORTFIO
& PF2
;
388 printf("\b\b\b%2d ", delay
);
394 printf("\b\bfailed");