Mike Frysinger | 59e4be9 | 2008-10-12 21:55:45 -0400 | [diff] [blame] | 1 | /* |
| 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 <net.h> |
| 12 | #include <netdev.h> |
| 13 | #include <asm/blackfin.h> |
Mike Frysinger | 59e4be9 | 2008-10-12 21:55:45 -0400 | [diff] [blame] | 14 | #include <asm/mach-common/bits/otp.h> |
Mike Frysinger | 71dcc2c | 2010-07-24 03:54:19 -0400 | [diff] [blame] | 15 | #include "../cm-bf537e/gpio_cfi_flash.h" |
Mike Frysinger | 59e4be9 | 2008-10-12 21:55:45 -0400 | [diff] [blame] | 16 | |
| 17 | DECLARE_GLOBAL_DATA_PTR; |
| 18 | |
| 19 | int checkboard(void) |
| 20 | { |
| 21 | printf("Board: Bluetechnix CM-BF527 board\n"); |
| 22 | printf(" Support: http://www.bluetechnix.at/\n"); |
| 23 | return 0; |
| 24 | } |
| 25 | |
Mike Frysinger | 59e4be9 | 2008-10-12 21:55:45 -0400 | [diff] [blame] | 26 | #ifdef CONFIG_BFIN_MAC |
| 27 | static void board_init_enetaddr(uchar *mac_addr) |
| 28 | { |
| 29 | bool valid_mac = false; |
| 30 | |
| 31 | /* the MAC is stored in OTP memory page 0xDF */ |
| 32 | uint32_t ret; |
| 33 | uint64_t otp_mac; |
| 34 | |
| 35 | ret = bfrom_OtpRead(0xDF, OTP_LOWER_HALF, &otp_mac); |
| 36 | if (!(ret & OTP_MASTER_ERROR)) { |
| 37 | uchar *otp_mac_p = (uchar *)&otp_mac; |
| 38 | |
| 39 | for (ret = 0; ret < 6; ++ret) |
| 40 | mac_addr[ret] = otp_mac_p[5 - ret]; |
| 41 | |
Joe Hershberger | 0adb5b7 | 2015-04-08 01:41:04 -0500 | [diff] [blame] | 42 | if (is_valid_ethaddr(mac_addr)) |
Mike Frysinger | 59e4be9 | 2008-10-12 21:55:45 -0400 | [diff] [blame] | 43 | valid_mac = true; |
| 44 | } |
| 45 | |
| 46 | if (!valid_mac) { |
| 47 | puts("Warning: Generating 'random' MAC address\n"); |
Joe Hershberger | 0adb5b7 | 2015-04-08 01:41:04 -0500 | [diff] [blame] | 48 | net_random_ethaddr(mac_addr); |
Mike Frysinger | 59e4be9 | 2008-10-12 21:55:45 -0400 | [diff] [blame] | 49 | } |
| 50 | |
| 51 | eth_setenv_enetaddr("ethaddr", mac_addr); |
| 52 | } |
| 53 | |
| 54 | int board_eth_init(bd_t *bis) |
| 55 | { |
| 56 | return bfin_EMAC_initialize(bis); |
| 57 | } |
| 58 | #endif |
| 59 | |
| 60 | int 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 | |
| 68 | gpio_cfi_flash_init(); |
| 69 | |
| 70 | return 0; |
| 71 | } |