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 | * |
Wolfgang Denk | d79de1d | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 9 | * SPDX-License-Identifier: GPL-2.0+ |
Aubrey Li | 10ebdd9 | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 10 | */ |
| 11 | |
| 12 | #include <common.h> |
| 13 | #include <config.h> |
| 14 | #include <command.h> |
| 15 | #include <asm/blackfin.h> |
Mike Frysinger | 606ed32 | 2008-10-11 22:44:14 -0400 | [diff] [blame] | 16 | #include <asm/net.h> |
Jean-Christophe PLAGNIOL-VILLARD | b9d5787 | 2007-12-10 22:32:14 +0100 | [diff] [blame] | 17 | #include <net.h> |
Mike Frysinger | 66c4cf4 | 2008-02-04 19:26:55 -0500 | [diff] [blame] | 18 | #include <asm/mach-common/bits/bootrom.h> |
Ben Warren | 2f2b6b6 | 2008-08-31 22:22:04 -0700 | [diff] [blame] | 19 | #include <netdev.h> |
Aubrey Li | 10ebdd9 | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 20 | |
Wolfgang Denk | d112a2c | 2007-09-15 20:48:41 +0200 | [diff] [blame] | 21 | DECLARE_GLOBAL_DATA_PTR; |
| 22 | |
Aubrey Li | 10ebdd9 | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 23 | int checkboard(void) |
| 24 | { |
Aubrey Li | 10ebdd9 | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 25 | printf("Board: ADI BF537 stamp board\n"); |
| 26 | printf(" Support: http://blackfin.uclinux.org/\n"); |
| 27 | return 0; |
| 28 | } |
| 29 | |
Mike Frysinger | 606ed32 | 2008-10-11 22:44:14 -0400 | [diff] [blame] | 30 | #ifdef CONFIG_BFIN_MAC |
| 31 | static void board_init_enetaddr(uchar *mac_addr) |
| 32 | { |
| 33 | #ifdef CONFIG_SYS_NO_FLASH |
| 34 | # define USE_MAC_IN_FLASH 0 |
| 35 | #else |
| 36 | # define USE_MAC_IN_FLASH 1 |
| 37 | #endif |
| 38 | bool valid_mac = false; |
| 39 | |
| 40 | if (USE_MAC_IN_FLASH) { |
| 41 | /* we cram the MAC in the last flash sector */ |
| 42 | uchar *board_mac_addr = (uchar *)0x203F0000; |
| 43 | if (is_valid_ether_addr(board_mac_addr)) { |
| 44 | memcpy(mac_addr, board_mac_addr, 6); |
| 45 | valid_mac = true; |
| 46 | } |
| 47 | } |
| 48 | |
| 49 | if (!valid_mac) { |
| 50 | puts("Warning: Generating 'random' MAC address\n"); |
| 51 | bfin_gen_rand_mac(mac_addr); |
| 52 | } |
| 53 | |
| 54 | eth_setenv_enetaddr("ethaddr", mac_addr); |
| 55 | } |
| 56 | |
| 57 | int board_eth_init(bd_t *bis) |
| 58 | { |
| 59 | return bfin_EMAC_initialize(bis); |
| 60 | } |
| 61 | #endif |
| 62 | |
Aubrey Li | 10ebdd9 | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 63 | /* miscellaneous platform dependent initialisations */ |
| 64 | int misc_init_r(void) |
| 65 | { |
Mike Frysinger | 606ed32 | 2008-10-11 22:44:14 -0400 | [diff] [blame] | 66 | #ifdef CONFIG_BFIN_MAC |
| 67 | uchar enetaddr[6]; |
| 68 | if (!eth_getenv_enetaddr("ethaddr", enetaddr)) |
| 69 | board_init_enetaddr(enetaddr); |
| 70 | #endif |
Aubrey Li | 10ebdd9 | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 71 | |
Mike Frysinger | 606ed32 | 2008-10-11 22:44:14 -0400 | [diff] [blame] | 72 | #ifndef CONFIG_SYS_NO_FLASH |
| 73 | /* we use the last sector for the MAC address / POST LDR */ |
| 74 | extern flash_info_t flash_info[]; |
| 75 | flash_protect(FLAG_PROTECT_SET, 0x203F0000, 0x203FFFFF, &flash_info[0]); |
Jon Loeliger | d299abc | 2007-07-09 18:19:09 -0500 | [diff] [blame] | 76 | #endif |
Aubrey Li | 10ebdd9 | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 77 | |
Mike Frysinger | 41d5161 | 2009-02-22 16:30:38 -0500 | [diff] [blame] | 78 | #ifdef CONFIG_BFIN_IDE |
| 79 | cf_ide_init(); |
Aubrey Li | 10ebdd9 | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 80 | #endif |
Mike Frysinger | 41d5161 | 2009-02-22 16:30:38 -0500 | [diff] [blame] | 81 | |
Aubrey Li | 10ebdd9 | 2007-03-19 01:24:52 +0800 | [diff] [blame] | 82 | return 0; |
| 83 | } |