blob: 4695b1161a0d2624c9e660be5ff017731590f853 [file] [log] [blame]
Mike Frysinger03783552008-10-12 21:30:48 -04001/*
2 * U-boot - main board file
3 *
4 * Copyright (c) 2005-2009 Analog Devices Inc.
5 *
6 * Licensed under the GPL-2 or later.
7 */
8
9#include <common.h>
10#include <config.h>
11#include <command.h>
12#include <net.h>
13#include <netdev.h>
14#include <asm/blackfin.h>
15#include <asm/net.h>
16#include <asm/mach-common/bits/otp.h>
17
18DECLARE_GLOBAL_DATA_PTR;
19
20int checkboard(void)
21{
22 printf("Board: ADI BF526 EZ-Board board\n");
23 printf(" Support: http://blackfin.uclinux.org/\n");
24 return 0;
25}
26
Mike Frysinger03783552008-10-12 21:30:48 -040027#ifdef CONFIG_BFIN_MAC
28static void board_init_enetaddr(uchar *mac_addr)
29{
Mike Frysingerece0bfb2011-03-17 17:32:51 -040030#ifdef CONFIG_SYS_NO_FLASH
31# define USE_MAC_IN_FLASH 0
32#else
33# define USE_MAC_IN_FLASH 1
34#endif
Mike Frysinger03783552008-10-12 21:30:48 -040035 bool valid_mac = false;
36
Mike Frysingerece0bfb2011-03-17 17:32:51 -040037 if (USE_MAC_IN_FLASH) {
38 /* we cram the MAC in the last flash sector */
39 uchar *board_mac_addr = (uchar *)0x203F0096;
40 if (is_valid_ether_addr(board_mac_addr)) {
41 memcpy(mac_addr, board_mac_addr, 6);
Mike Frysinger03783552008-10-12 21:30:48 -040042 valid_mac = true;
Mike Frysingerece0bfb2011-03-17 17:32:51 -040043 }
Mike Frysinger03783552008-10-12 21:30:48 -040044 }
45
46 if (!valid_mac) {
47 puts("Warning: Generating 'random' MAC address\n");
48 bfin_gen_rand_mac(mac_addr);
49 }
50
51 eth_setenv_enetaddr("ethaddr", mac_addr);
52}
53
54int board_eth_init(bd_t *bis)
55{
56 return bfin_EMAC_initialize(bis);
57}
58#endif
59
60int misc_init_r(void)
61{
62#ifdef CONFIG_BFIN_MAC
63 uchar enetaddr[6];
64 if (!eth_getenv_enetaddr("ethaddr", enetaddr))
65 board_init_enetaddr(enetaddr);
66#endif
67
Mike Frysingerece0bfb2011-03-17 17:32:51 -040068#ifndef CONFIG_SYS_NO_FLASH
69 /* we use the last sector for the MAC address / POST LDR */
70 extern flash_info_t flash_info[];
71 flash_protect(FLAG_PROTECT_SET, 0x203F0000, 0x203FFFFF, &flash_info[0]);
72#endif
73
Mike Frysinger03783552008-10-12 21:30:48 -040074 return 0;
75}