blob: 0a88491e902f8ffcfc360e7ca77931efc7e8e864 [file] [log] [blame]
Mike Frysinger0c31ddf2008-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>
Mike Frysinger0c31ddf2008-10-12 21:30:48 -040015#include <asm/mach-common/bits/otp.h>
16
17DECLARE_GLOBAL_DATA_PTR;
18
19int checkboard(void)
20{
21 printf("Board: ADI BF526 EZ-Board board\n");
22 printf(" Support: http://blackfin.uclinux.org/\n");
23 return 0;
24}
25
Mike Frysinger0c31ddf2008-10-12 21:30:48 -040026#ifdef CONFIG_BFIN_MAC
27static void board_init_enetaddr(uchar *mac_addr)
28{
Mike Frysingerd1f3ac92011-03-17 17:32:51 -040029#ifdef CONFIG_SYS_NO_FLASH
30# define USE_MAC_IN_FLASH 0
31#else
32# define USE_MAC_IN_FLASH 1
33#endif
Mike Frysinger0c31ddf2008-10-12 21:30:48 -040034 bool valid_mac = false;
35
Mike Frysingerd1f3ac92011-03-17 17:32:51 -040036 if (USE_MAC_IN_FLASH) {
37 /* we cram the MAC in the last flash sector */
38 uchar *board_mac_addr = (uchar *)0x203F0096;
Joe Hershberger0adb5b72015-04-08 01:41:04 -050039 if (is_valid_ethaddr(board_mac_addr)) {
Mike Frysingerd1f3ac92011-03-17 17:32:51 -040040 memcpy(mac_addr, board_mac_addr, 6);
Mike Frysinger0c31ddf2008-10-12 21:30:48 -040041 valid_mac = true;
Mike Frysingerd1f3ac92011-03-17 17:32:51 -040042 }
Mike Frysinger0c31ddf2008-10-12 21:30:48 -040043 }
44
45 if (!valid_mac) {
46 puts("Warning: Generating 'random' MAC address\n");
Joe Hershberger0adb5b72015-04-08 01:41:04 -050047 net_random_ethaddr(mac_addr);
Mike Frysinger0c31ddf2008-10-12 21:30:48 -040048 }
49
50 eth_setenv_enetaddr("ethaddr", mac_addr);
51}
52
53int board_eth_init(bd_t *bis)
54{
55 return bfin_EMAC_initialize(bis);
56}
57#endif
58
59int misc_init_r(void)
60{
61#ifdef CONFIG_BFIN_MAC
62 uchar enetaddr[6];
63 if (!eth_getenv_enetaddr("ethaddr", enetaddr))
64 board_init_enetaddr(enetaddr);
65#endif
66
Mike Frysingerd1f3ac92011-03-17 17:32:51 -040067#ifndef CONFIG_SYS_NO_FLASH
68 /* we use the last sector for the MAC address / POST LDR */
69 extern flash_info_t flash_info[];
70 flash_protect(FLAG_PROTECT_SET, 0x203F0000, 0x203FFFFF, &flash_info[0]);
71#endif
72
Mike Frysinger0c31ddf2008-10-12 21:30:48 -040073 return 0;
74}