blob: ec888d44d9a4a80994fbaa0d843abb8d1c582b72 [file] [log] [blame]
Aubrey Li10ebdd92007-03-19 01:24:52 +08001/*
Mike Frysinger606ed322008-10-11 22:44:14 -04002 * U-boot - main board file
Aubrey Li10ebdd92007-03-19 01:24:52 +08003 *
Mike Frysinger606ed322008-10-11 22:44:14 -04004 * Copyright (c) 2005-2008 Analog Devices Inc.
Aubrey Li10ebdd92007-03-19 01:24:52 +08005 *
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 Li314d22f2007-04-05 18:31:18 +080024 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,
25 * MA 02110-1301 USA
Aubrey Li10ebdd92007-03-19 01:24:52 +080026 */
27
28#include <common.h>
29#include <config.h>
30#include <command.h>
31#include <asm/blackfin.h>
Mike Frysinger606ed322008-10-11 22:44:14 -040032#include <asm/net.h>
Jean-Christophe PLAGNIOL-VILLARDb9d57872007-12-10 22:32:14 +010033#include <net.h>
Mike Frysinger66c4cf42008-02-04 19:26:55 -050034#include <asm/mach-common/bits/bootrom.h>
Ben Warren2f2b6b62008-08-31 22:22:04 -070035#include <netdev.h>
Aubrey Li10ebdd92007-03-19 01:24:52 +080036
Wolfgang Denkd112a2c2007-09-15 20:48:41 +020037DECLARE_GLOBAL_DATA_PTR;
38
Aubrey Li10ebdd92007-03-19 01:24:52 +080039int checkboard(void)
40{
Aubrey Li10ebdd92007-03-19 01:24:52 +080041 printf("Board: ADI BF537 stamp board\n");
42 printf(" Support: http://blackfin.uclinux.org/\n");
43 return 0;
44}
45
Mike Frysinger606ed322008-10-11 22:44:14 -040046void board_reset(void)
47{
48 /* workaround for weak pull ups on ssel */
Mike Frysinger78624cf2010-06-02 05:20:18 -040049 if (CONFIG_BFIN_BOOT_MODE == BFIN_BOOT_SPI_MASTER)
50 bfin_reset_boot_spi_cs(GPIO_PF10);
Mike Frysinger606ed322008-10-11 22:44:14 -040051}
52
53#ifdef CONFIG_BFIN_MAC
54static void board_init_enetaddr(uchar *mac_addr)
55{
56#ifdef CONFIG_SYS_NO_FLASH
57# define USE_MAC_IN_FLASH 0
58#else
59# define USE_MAC_IN_FLASH 1
60#endif
61 bool valid_mac = false;
62
63 if (USE_MAC_IN_FLASH) {
64 /* we cram the MAC in the last flash sector */
65 uchar *board_mac_addr = (uchar *)0x203F0000;
66 if (is_valid_ether_addr(board_mac_addr)) {
67 memcpy(mac_addr, board_mac_addr, 6);
68 valid_mac = true;
69 }
70 }
71
72 if (!valid_mac) {
73 puts("Warning: Generating 'random' MAC address\n");
74 bfin_gen_rand_mac(mac_addr);
75 }
76
77 eth_setenv_enetaddr("ethaddr", mac_addr);
78}
79
80int board_eth_init(bd_t *bis)
81{
82 return bfin_EMAC_initialize(bis);
83}
84#endif
85
Aubrey Li10ebdd92007-03-19 01:24:52 +080086/* miscellaneous platform dependent initialisations */
87int misc_init_r(void)
88{
Mike Frysinger606ed322008-10-11 22:44:14 -040089#ifdef CONFIG_BFIN_MAC
90 uchar enetaddr[6];
91 if (!eth_getenv_enetaddr("ethaddr", enetaddr))
92 board_init_enetaddr(enetaddr);
93#endif
Aubrey Li10ebdd92007-03-19 01:24:52 +080094
Mike Frysinger606ed322008-10-11 22:44:14 -040095#ifndef CONFIG_SYS_NO_FLASH
96 /* we use the last sector for the MAC address / POST LDR */
97 extern flash_info_t flash_info[];
98 flash_protect(FLAG_PROTECT_SET, 0x203F0000, 0x203FFFFF, &flash_info[0]);
Jon Loeligerd299abc2007-07-09 18:19:09 -050099#endif
Aubrey Li10ebdd92007-03-19 01:24:52 +0800100
Mike Frysinger41d51612009-02-22 16:30:38 -0500101#ifdef CONFIG_BFIN_IDE
102 cf_ide_init();
Aubrey Li10ebdd92007-03-19 01:24:52 +0800103#endif
Mike Frysinger41d51612009-02-22 16:30:38 -0500104
Aubrey Li10ebdd92007-03-19 01:24:52 +0800105 return 0;
106}