2 * U-boot - main board file
4 * Copyright (c) 2008-2009 Analog Devices Inc.
6 * Licensed under the GPL-2 or later.
15 #include <asm/blackfin.h>
17 #include <asm/mach-common/bits/otp.h>
19 DECLARE_GLOBAL_DATA_PTR;
23 printf("Board: ADI BF518F EZ-Board board\n");
24 printf(" Support: http://blackfin.uclinux.org/\n");
28 phys_size_t initdram(int board_type)
30 gd->bd->bi_memstart = CONFIG_SYS_SDRAM_BASE;
31 gd->bd->bi_memsize = CONFIG_SYS_MAX_RAM_SIZE;
32 return gd->bd->bi_memsize;
35 #if defined(CONFIG_BFIN_MAC)
36 static void board_init_enetaddr(uchar *mac_addr)
38 bool valid_mac = false;
41 /* the MAC is stored in OTP memory page 0xDF */
45 ret = bfrom_OtpRead(0xDF, OTP_LOWER_HALF, &otp_mac);
46 if (!(ret & OTP_MASTER_ERROR)) {
47 uchar *otp_mac_p = (uchar *)&otp_mac;
49 for (ret = 0; ret < 6; ++ret)
50 mac_addr[ret] = otp_mac_p[5 - ret];
52 if (is_valid_ether_addr(mac_addr))
58 puts("Warning: Generating 'random' MAC address\n");
59 bfin_gen_rand_mac(mac_addr);
62 eth_setenv_enetaddr("ethaddr", mac_addr);
65 int board_eth_init(bd_t *bis)
67 static bool switch_is_alive = false;
70 if (!switch_is_alive) {
71 struct spi_slave *slave = spi_setup_slave(0, 1, 5000000, SPI_MODE_3);
73 if (!spi_claim_bus(slave)) {
74 unsigned char dout[3] = { 2, 1, 1, };
76 ret = spi_xfer(slave, sizeof(dout) * 8, dout, din, SPI_XFER_BEGIN | SPI_XFER_END);
78 switch_is_alive = true;
79 spi_release_bus(slave);
81 spi_free_slave(slave);
86 return bfin_EMAC_initialize(bis);
94 #ifdef CONFIG_BFIN_MAC
96 if (!eth_getenv_enetaddr("ethaddr", enetaddr))
97 board_init_enetaddr(enetaddr);