Aubrey Li | 10ebdd9 | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 1 | /* |
Mike Frysinger | 606ed32 | 2008-10-11 22:44:14 -0400 | [diff] [blame] | 2 | * U-boot - main board file |
Aubrey Li | 10ebdd9 | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 3 | * |
Mike Frysinger | 606ed32 | 2008-10-11 22:44:14 -0400 | [diff] [blame] | 4 | * Copyright (c) 2005-2008 Analog Devices Inc. |
Aubrey Li | 10ebdd9 | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 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 |
Aubrey Li | 314d22f | 2007-04-05 18:31:18 +0800 | [diff] [blame] | 24 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, |
| 25 | * MA 02110-1301 USA |
Aubrey Li | 10ebdd9 | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 26 | */ |
| 27 | |
| 28 | #include <common.h> |
| 29 | #include <config.h> |
| 30 | #include <command.h> |
| 31 | #include <asm/blackfin.h> |
Mike Frysinger | 606ed32 | 2008-10-11 22:44:14 -0400 | [diff] [blame] | 32 | #include <asm/net.h> |
Jean-Christophe PLAGNIOL-VILLARD | b9d5787 | 2007-12-10 22:32:14 +0100 | [diff] [blame] | 33 | #include <net.h> |
Mike Frysinger | 66c4cf4 | 2008-02-04 19:26:55 -0500 | [diff] [blame] | 34 | #include <asm/mach-common/bits/bootrom.h> |
Ben Warren | 2f2b6b6 | 2008-08-31 22:22:04 -0700 | [diff] [blame] | 35 | #include <netdev.h> |
Aubrey Li | 10ebdd9 | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 36 | |
Wolfgang Denk | d112a2c | 2007-09-15 20:48:41 +0200 | [diff] [blame] | 37 | DECLARE_GLOBAL_DATA_PTR; |
| 38 | |
Aubrey Li | 10ebdd9 | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 39 | int checkboard(void) |
| 40 | { |
Aubrey Li | 10ebdd9 | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 41 | printf("Board: ADI BF537 stamp board\n"); |
| 42 | printf(" Support: http://blackfin.uclinux.org/\n"); |
| 43 | return 0; |
| 44 | } |
| 45 | |
Mike Frysinger | 606ed32 | 2008-10-11 22:44:14 -0400 | [diff] [blame] | 46 | void board_reset(void) |
| 47 | { |
| 48 | /* workaround for weak pull ups on ssel */ |
| 49 | if (CONFIG_BFIN_BOOT_MODE == BFIN_BOOT_SPI_MASTER) { |
| 50 | bfin_write_PORTF_FER(bfin_read_PORTF_FER() & ~PF10); |
| 51 | bfin_write_PORTFIO_SET(PF10); |
| 52 | udelay(1); |
| 53 | } |
| 54 | } |
| 55 | |
| 56 | #ifdef CONFIG_BFIN_MAC |
| 57 | static void board_init_enetaddr(uchar *mac_addr) |
| 58 | { |
| 59 | #ifdef CONFIG_SYS_NO_FLASH |
| 60 | # define USE_MAC_IN_FLASH 0 |
| 61 | #else |
| 62 | # define USE_MAC_IN_FLASH 1 |
| 63 | #endif |
| 64 | bool valid_mac = false; |
| 65 | |
| 66 | if (USE_MAC_IN_FLASH) { |
| 67 | /* we cram the MAC in the last flash sector */ |
| 68 | uchar *board_mac_addr = (uchar *)0x203F0000; |
| 69 | if (is_valid_ether_addr(board_mac_addr)) { |
| 70 | memcpy(mac_addr, board_mac_addr, 6); |
| 71 | valid_mac = true; |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | if (!valid_mac) { |
| 76 | puts("Warning: Generating 'random' MAC address\n"); |
| 77 | bfin_gen_rand_mac(mac_addr); |
| 78 | } |
| 79 | |
| 80 | eth_setenv_enetaddr("ethaddr", mac_addr); |
| 81 | } |
| 82 | |
| 83 | int board_eth_init(bd_t *bis) |
| 84 | { |
| 85 | return bfin_EMAC_initialize(bis); |
| 86 | } |
| 87 | #endif |
| 88 | |
Aubrey Li | 10ebdd9 | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 89 | /* miscellaneous platform dependent initialisations */ |
| 90 | int misc_init_r(void) |
| 91 | { |
Mike Frysinger | 606ed32 | 2008-10-11 22:44:14 -0400 | [diff] [blame] | 92 | #ifdef CONFIG_BFIN_MAC |
| 93 | uchar enetaddr[6]; |
| 94 | if (!eth_getenv_enetaddr("ethaddr", enetaddr)) |
| 95 | board_init_enetaddr(enetaddr); |
| 96 | #endif |
Aubrey Li | 10ebdd9 | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 97 | |
Mike Frysinger | 606ed32 | 2008-10-11 22:44:14 -0400 | [diff] [blame] | 98 | #ifndef CONFIG_SYS_NO_FLASH |
| 99 | /* we use the last sector for the MAC address / POST LDR */ |
| 100 | extern flash_info_t flash_info[]; |
| 101 | flash_protect(FLAG_PROTECT_SET, 0x203F0000, 0x203FFFFF, &flash_info[0]); |
Jon Loeliger | d299abc | 2007-07-09 18:19:09 -0500 | [diff] [blame] | 102 | #endif |
Aubrey Li | 10ebdd9 | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 103 | |
Mike Frysinger | 41d5161 | 2009-02-22 16:30:38 -0500 | [diff] [blame] | 104 | #ifdef CONFIG_BFIN_IDE |
| 105 | cf_ide_init(); |
Aubrey Li | 10ebdd9 | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 106 | #endif |
Mike Frysinger | 41d5161 | 2009-02-22 16:30:38 -0500 | [diff] [blame] | 107 | |
Aubrey Li | 10ebdd9 | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 108 | return 0; |
| 109 | } |