Andreas Schallenberg | 2fc32de | 2010-11-17 13:51:33 -0500 | [diff] [blame] | 1 | /* |
| 2 | * U-boot - main board file |
| 3 | * |
| 4 | * (C) Copyright 2010 3ality Digital Systems |
| 5 | * |
| 6 | * Copyright (c) 2005-2008 Analog Devices Inc. |
| 7 | * |
| 8 | * (C) Copyright 2000-2004 |
| 9 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 10 | * |
| 11 | * See file CREDITS for list of people who contributed to this |
| 12 | * project. |
| 13 | * |
| 14 | * This program is free software; you can redistribute it and/or |
| 15 | * modify it under the terms of the GNU General Public License as |
| 16 | * published by the Free Software Foundation; either version 2 of |
| 17 | * the License, or (at your option) any later version. |
| 18 | * |
| 19 | * This program is distributed in the hope that it will be useful, |
| 20 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 21 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 22 | * GNU General Public License for more details. |
| 23 | * |
| 24 | * You should have received a copy of the GNU General Public License |
| 25 | * along with this program; if not, write to the Free Software |
| 26 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, |
| 27 | * MA 02110-1301 USA |
| 28 | */ |
| 29 | |
| 30 | #include <common.h> |
| 31 | #include <config.h> |
| 32 | #include <asm/blackfin.h> |
| 33 | #include <asm/net.h> |
| 34 | #include <net.h> |
| 35 | #include <netdev.h> |
| 36 | #include <asm/gpio.h> |
| 37 | |
| 38 | static void disable_external_watchdog(void) |
| 39 | { |
| 40 | #ifdef CONFIG_DNP5370_EXT_WD_DISABLE |
| 41 | /* disable external HW watchdog with PH13 = WD1 = 1 */ |
| 42 | gpio_request(GPIO_PH13, "ext_wd"); |
| 43 | gpio_direction_output(GPIO_PH13, 1); |
| 44 | #endif |
| 45 | } |
| 46 | |
| 47 | int checkboard(void) |
| 48 | { |
| 49 | printf("Board: SSV DilNet DNP5370\n"); |
| 50 | return 0; |
| 51 | } |
| 52 | |
| 53 | #ifdef CONFIG_BFIN_MAC |
| 54 | static 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 *)0x202F0000; |
| 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 | |
| 80 | int board_eth_init(bd_t *bis) |
| 81 | { |
| 82 | return bfin_EMAC_initialize(bis); |
| 83 | } |
| 84 | #endif |
| 85 | |
| 86 | /* miscellaneous platform dependent initialisations */ |
| 87 | int misc_init_r(void) |
| 88 | { |
| 89 | disable_external_watchdog(); |
| 90 | |
| 91 | #ifdef CONFIG_BFIN_MAC |
| 92 | uchar enetaddr[6]; |
| 93 | if (!eth_getenv_enetaddr("ethaddr", enetaddr)) |
| 94 | board_init_enetaddr(enetaddr); |
| 95 | #endif |
| 96 | |
| 97 | #ifndef CONFIG_SYS_NO_FLASH |
| 98 | /* we use the last sector for the MAC address / POST LDR */ |
| 99 | extern flash_info_t flash_info[]; |
| 100 | flash_protect(FLAG_PROTECT_SET, 0x202F0000, 0x202FFFFF, &flash_info[0]); |
| 101 | #endif |
| 102 | |
| 103 | return 0; |
| 104 | } |