Merge branch 'next'
[u-boot/qq2440-u-boot.git] / board / dnp5370 / dnp5370.c
blob4b3873bd4f36445e398d3ffc1213f39328375462
1 /*
2 * U-boot - main board file
4 * (C) Copyright 2010 3ality Digital Systems
6 * Copyright (c) 2005-2008 Analog Devices Inc.
8 * (C) Copyright 2000-2004
9 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
11 * SPDX-License-Identifier: GPL-2.0+
14 #include <common.h>
15 #include <config.h>
16 #include <asm/blackfin.h>
17 #include <asm/net.h>
18 #include <net.h>
19 #include <netdev.h>
20 #include <asm/gpio.h>
22 static void disable_external_watchdog(void)
24 #ifdef CONFIG_DNP5370_EXT_WD_DISABLE
25 /* disable external HW watchdog with PH13 = WD1 = 1 */
26 gpio_request(GPIO_PH13, "ext_wd");
27 gpio_direction_output(GPIO_PH13, 1);
28 #endif
31 int checkboard(void)
33 printf("Board: SSV DilNet DNP5370\n");
34 return 0;
37 #ifdef CONFIG_BFIN_MAC
38 static void board_init_enetaddr(uchar *mac_addr)
40 #ifdef CONFIG_SYS_NO_FLASH
41 # define USE_MAC_IN_FLASH 0
42 #else
43 # define USE_MAC_IN_FLASH 1
44 #endif
45 bool valid_mac = false;
47 if (USE_MAC_IN_FLASH) {
48 /* we cram the MAC in the last flash sector */
49 uchar *board_mac_addr = (uchar *)0x202F0000;
50 if (is_valid_ether_addr(board_mac_addr)) {
51 memcpy(mac_addr, board_mac_addr, 6);
52 valid_mac = true;
56 if (!valid_mac) {
57 puts("Warning: Generating 'random' MAC address\n");
58 bfin_gen_rand_mac(mac_addr);
61 eth_setenv_enetaddr("ethaddr", mac_addr);
64 int board_eth_init(bd_t *bis)
66 return bfin_EMAC_initialize(bis);
68 #endif
70 /* miscellaneous platform dependent initialisations */
71 int misc_init_r(void)
73 disable_external_watchdog();
75 #ifdef CONFIG_BFIN_MAC
76 uchar enetaddr[6];
77 if (!eth_getenv_enetaddr("ethaddr", enetaddr))
78 board_init_enetaddr(enetaddr);
79 #endif
81 #ifndef CONFIG_SYS_NO_FLASH
82 /* we use the last sector for the MAC address / POST LDR */
83 extern flash_info_t flash_info[];
84 flash_protect(FLAG_PROTECT_SET, 0x202F0000, 0x202FFFFF, &flash_info[0]);
85 #endif
87 return 0;