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)
89 char *tmp = getenv("baudrate");
90 brate = simple_strtoul(tmp, NULL, 16);
91 printf("Serial Port initialized with Baud rate = %x\n", brate);
92 printf("SDRAM attributes:\n");
93 printf("tRCD %d SCLK Cycles,tRP %d SCLK Cycles,tRAS %d SCLK Cycles"
94 "tWR %d SCLK Cycles,CAS Latency %d SCLK cycles \n",
96 printf("SDRAM Begin: 0x%x\n", CONFIG_SYS_SDRAM_BASE);
97 printf("Bank size = %d MB\n", CONFIG_SYS_MAX_RAM_SIZE >> 20);
99 gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
100 gd->bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
101 return CONFIG_SYS_MAX_RAM_SIZE;
104 #if defined(CONFIG_MISC_INIT_R)
105 /* miscellaneous platform dependent initialisations */
106 int misc_init_r(void)
108 #if defined(CONFIG_CMD_NET)
110 unsigned char *pMACaddr = (unsigned char *)0x203F0000;
112 /* The 0xFF check here is to make sure we don't use the address
113 * in flash if it's simply been erased (aka all 0xFF values) */
114 if (getenv("ethaddr") == NULL && is_valid_ether_addr(pMACaddr)) {
115 sprintf(nid, "%02x:%02x:%02x:%02x:%02x:%02x",
116 pMACaddr[0], pMACaddr[1],
117 pMACaddr[2], pMACaddr[3], pMACaddr[4], pMACaddr[5]);
118 setenv("ethaddr", nid);
122 #if defined(CONFIG_BFIN_IDE)
123 #if defined(CONFIG_BFIN_TRUE_IDE)
124 /* Enable ATASEL when in True IDE mode */
125 printf("Using CF True IDE Mode\n");
126 cf_outb(0, (unsigned char *)CONFIG_CF_ATASEL_ENA);
128 #elif defined(CONFIG_BFIN_CF_IDE)
129 /* Disable ATASEL when we're in Common Memory Mode */
130 printf("Using CF Common Memory Mode\n");
131 cf_outb(0, (unsigned char *)CONFIG_CF_ATASEL_DIS);
133 #elif defined(CONFIG_BFIN_HDD_IDE)
134 printf("Using HDD IDE Mode\n");
137 #endif /* CONFIG_BFIN_IDE */
140 #endif /* CONFIG_MISC_INIT_R */
142 #if defined(CONFIG_BFIN_MAC)
144 int board_eth_init(bd_t *bis)
146 return bfin_EMAC_initialize(bis);
151 /* Using sw10-PF5 as the hotkey */
152 int post_hotkeys_pressed(void)
156 unsigned short value;
159 *pPORTFIO_DIR &= ~PF5;
160 *pPORTFIO_INEN |= PF5;
162 printf("########Press SW10 to enter Memory POST########: %2d ", delay);
164 for (i = 0; i < 100; i++) {
165 value = *pPORTFIO & PF5;
171 printf("\b\b\b%2d ", delay);
178 printf("Hotkey has been pressed, Enter POST . . . . . .\n");
184 #if defined(CONFIG_POST) || defined(CONFIG_LOGBUFFER)
185 void post_word_store(ulong a)
187 volatile ulong *save_addr = (volatile ulong *)POST_WORD_ADDR;
191 ulong post_word_load(void)
193 volatile ulong *save_addr = (volatile ulong *)POST_WORD_ADDR;
199 int uart_post_test(int flags)
204 #define BLOCK_SIZE 0x10000
205 #define VERIFY_ADDR 0x2000000
206 extern int erase_block_flash(int);
207 extern int write_data(long lStart, long lCount, uchar * pnData);
208 int flash_post_test(int flags)
210 unsigned short *pbuf, *temp;
215 pbuf = (unsigned short *)VERIFY_ADDR;
217 for (n = FLASH_START_POST_BLOCK; n < FLASH_END_POST_BLOCK; n++) {
218 offset = (n - 7) * BLOCK_SIZE;
219 printf("--------Erase block:%2d..", n);
220 erase_block_flash(n);
222 printf("--------Program block:%2d...", n);
223 write_data(CONFIG_SYS_FLASH_BASE + offset, BLOCK_SIZE, pbuf);
225 printf("--------Verify block:%2d...", n);
226 for (i = 0; i < BLOCK_SIZE; i += 2) {
227 if (*(unsigned short *)(CONFIG_SYS_FLASH_BASE + offset + i) !=
239 FLASH_START_POST_BLOCK) *
240 100 / (FLASH_END_POST_BLOCK -
241 FLASH_START_POST_BLOCK)));
253 /****************************************************
254 * LED1 ---- PF6 LED2 ---- PF7 *
255 * LED3 ---- PF8 LED4 ---- PF9 *
256 * LED5 ---- PF10 LED6 ---- PF11 *
257 ****************************************************/
258 int led_post_test(int flags)
260 *pPORTF_FER &= ~(PF6 | PF7 | PF8 | PF9 | PF10 | PF11);
261 *pPORTFIO_DIR |= PF6 | PF7 | PF8 | PF9 | PF10 | PF11;
262 *pPORTFIO_INEN &= ~(PF6 | PF7 | PF8 | PF9 | PF10 | PF11);
263 *pPORTFIO &= ~(PF6 | PF7 | PF8 | PF9 | PF10 | PF11);
268 printf("\b\b\b\b\b\b\b");
272 printf("\b\b\b\b\b\b\b");
276 printf("\b\b\b\b\b\b\b");
280 printf("\b\b\b\b\b\b\b");
284 printf("\b\b\b\b\b\b\b");
287 printf("\b\b\b\b\b\b\b ");
291 /************************************************
292 * SW10 ---- PF5 SW11 ---- PF4 *
293 * SW12 ---- PF3 SW13 ---- PF2 *
294 ************************************************/
295 int button_post_test(int flags)
298 unsigned short value = 0;
301 *pPORTF_FER &= ~(PF5 | PF4 | PF3 | PF2);
302 *pPORTFIO_DIR &= ~(PF5 | PF4 | PF3 | PF2);
303 *pPORTFIO_INEN |= (PF5 | PF4 | PF3 | PF2);
305 printf("\n--------Press SW10: %2d ", delay);
307 for (i = 0; i < 100; i++) {
308 value = *pPORTFIO & PF5;
314 printf("\b\b\b%2d ", delay);
320 printf("\b\bfailed");
324 printf("\n--------Press SW11: %2d ", delay);
326 for (i = 0; i < 100; i++) {
327 value = *pPORTFIO & PF4;
333 printf("\b\b\b%2d ", delay);
339 printf("\b\bfailed");
343 printf("\n--------Press SW12: %2d ", delay);
345 for (i = 0; i < 100; i++) {
346 value = *pPORTFIO & PF3;
352 printf("\b\b\b%2d ", delay);
358 printf("\b\bfailed");
362 printf("\n--------Press SW13: %2d ", delay);
364 for (i = 0; i < 100; i++) {
365 value = *pPORTFIO & PF2;
371 printf("\b\b\b%2d ", delay);
377 printf("\b\bfailed");