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