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 DECLARE_GLOBAL_DATA_PTR;
39 #define POST_WORD_ADDR 0xFF903FFC
43 printf("Board: ADI BF537 stamp board\n");
44 printf(" Support: http://blackfin.uclinux.org/\n");
48 #if defined(CONFIG_BFIN_IDE)
50 void cf_outb(unsigned char val, volatile unsigned char *addr)
56 unsigned char cf_inb(volatile unsigned char *addr)
58 volatile unsigned char c;
66 void cf_insw(unsigned short *sect_buf, unsigned short *addr, int words)
70 for (i = 0; i < words; i++)
71 *(sect_buf + i) = *(addr);
75 void cf_outsw(unsigned short *addr, unsigned short *sect_buf, int words)
79 for (i = 0; i < words; i++)
80 *(addr) = *(sect_buf + i);
83 #endif /* CONFIG_BFIN_IDE */
85 phys_size_t initdram(int board_type)
87 gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
88 gd->bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
89 return gd->bd->bi_memsize;
92 #if defined(CONFIG_MISC_INIT_R)
93 /* miscellaneous platform dependent initialisations */
96 #if defined(CONFIG_CMD_NET)
98 unsigned char *pMACaddr = (unsigned char *)0x203F0000;
100 /* The 0xFF check here is to make sure we don't use the address
101 * in flash if it's simply been erased (aka all 0xFF values) */
102 if (getenv("ethaddr") == NULL && is_valid_ether_addr(pMACaddr)) {
103 sprintf(nid, "%02x:%02x:%02x:%02x:%02x:%02x",
104 pMACaddr[0], pMACaddr[1],
105 pMACaddr[2], pMACaddr[3], pMACaddr[4], pMACaddr[5]);
106 setenv("ethaddr", nid);
110 #if defined(CONFIG_BFIN_IDE)
111 #if defined(CONFIG_BFIN_TRUE_IDE)
112 /* Enable ATASEL when in True IDE mode */
113 printf("Using CF True IDE Mode\n");
114 cf_outb(0, (unsigned char *)CONFIG_CF_ATASEL_ENA);
116 #elif defined(CONFIG_BFIN_CF_IDE)
117 /* Disable ATASEL when we're in Common Memory Mode */
118 printf("Using CF Common Memory Mode\n");
119 cf_outb(0, (unsigned char *)CONFIG_CF_ATASEL_DIS);
121 #elif defined(CONFIG_BFIN_HDD_IDE)
122 printf("Using HDD IDE Mode\n");
125 #endif /* CONFIG_BFIN_IDE */
128 #endif /* CONFIG_MISC_INIT_R */
130 #if defined(CONFIG_BFIN_MAC)
132 int board_eth_init(bd_t *bis)
134 return bfin_EMAC_initialize(bis);
139 /* Using sw10-PF5 as the hotkey */
140 int post_hotkeys_pressed(void)
144 unsigned short value;
147 *pPORTFIO_DIR &= ~PF5;
148 *pPORTFIO_INEN |= PF5;
150 printf("########Press SW10 to enter Memory POST########: %2d ", delay);
152 for (i = 0; i < 100; i++) {
153 value = *pPORTFIO & PF5;
159 printf("\b\b\b%2d ", delay);
166 printf("Hotkey has been pressed, Enter POST . . . . . .\n");
172 #if defined(CONFIG_POST) || defined(CONFIG_LOGBUFFER)
173 void post_word_store(ulong a)
175 volatile ulong *save_addr = (volatile ulong *)POST_WORD_ADDR;
179 ulong post_word_load(void)
181 volatile ulong *save_addr = (volatile ulong *)POST_WORD_ADDR;
187 int uart_post_test(int flags)
192 #define BLOCK_SIZE 0x10000
193 #define VERIFY_ADDR 0x2000000
194 extern int erase_block_flash(int);
195 extern int write_data(long lStart, long lCount, uchar * pnData);
196 int flash_post_test(int flags)
198 unsigned short *pbuf, *temp;
203 pbuf = (unsigned short *)VERIFY_ADDR;
205 for (n = FLASH_START_POST_BLOCK; n < FLASH_END_POST_BLOCK; n++) {
206 offset = (n - 7) * BLOCK_SIZE;
207 printf("--------Erase block:%2d..", n);
208 erase_block_flash(n);
210 printf("--------Program block:%2d...", n);
211 write_data(CONFIG_SYS_FLASH_BASE + offset, BLOCK_SIZE, pbuf);
213 printf("--------Verify block:%2d...", n);
214 for (i = 0; i < BLOCK_SIZE; i += 2) {
215 if (*(unsigned short *)(CONFIG_SYS_FLASH_BASE + offset + i) !=
227 FLASH_START_POST_BLOCK) *
228 100 / (FLASH_END_POST_BLOCK -
229 FLASH_START_POST_BLOCK)));
241 /****************************************************
242 * LED1 ---- PF6 LED2 ---- PF7 *
243 * LED3 ---- PF8 LED4 ---- PF9 *
244 * LED5 ---- PF10 LED6 ---- PF11 *
245 ****************************************************/
246 int led_post_test(int flags)
248 *pPORTF_FER &= ~(PF6 | PF7 | PF8 | PF9 | PF10 | PF11);
249 *pPORTFIO_DIR |= PF6 | PF7 | PF8 | PF9 | PF10 | PF11;
250 *pPORTFIO_INEN &= ~(PF6 | PF7 | PF8 | PF9 | PF10 | PF11);
251 *pPORTFIO &= ~(PF6 | PF7 | PF8 | PF9 | PF10 | PF11);
256 printf("\b\b\b\b\b\b\b");
260 printf("\b\b\b\b\b\b\b");
264 printf("\b\b\b\b\b\b\b");
268 printf("\b\b\b\b\b\b\b");
272 printf("\b\b\b\b\b\b\b");
275 printf("\b\b\b\b\b\b\b ");
279 /************************************************
280 * SW10 ---- PF5 SW11 ---- PF4 *
281 * SW12 ---- PF3 SW13 ---- PF2 *
282 ************************************************/
283 int button_post_test(int flags)
286 unsigned short value = 0;
289 *pPORTF_FER &= ~(PF5 | PF4 | PF3 | PF2);
290 *pPORTFIO_DIR &= ~(PF5 | PF4 | PF3 | PF2);
291 *pPORTFIO_INEN |= (PF5 | PF4 | PF3 | PF2);
293 printf("\n--------Press SW10: %2d ", delay);
295 for (i = 0; i < 100; i++) {
296 value = *pPORTFIO & PF5;
302 printf("\b\b\b%2d ", delay);
308 printf("\b\bfailed");
312 printf("\n--------Press SW11: %2d ", delay);
314 for (i = 0; i < 100; i++) {
315 value = *pPORTFIO & PF4;
321 printf("\b\b\b%2d ", delay);
327 printf("\b\bfailed");
331 printf("\n--------Press SW12: %2d ", delay);
333 for (i = 0; i < 100; i++) {
334 value = *pPORTFIO & PF3;
340 printf("\b\b\b%2d ", delay);
346 printf("\b\bfailed");
350 printf("\n--------Press SW13: %2d ", delay);
352 for (i = 0; i < 100; i++) {
353 value = *pPORTFIO & PF2;
359 printf("\b\b\b%2d ", delay);
365 printf("\b\bfailed");