]> git.ipfire.org Git - people/ms/u-boot.git/blob - board/dnp5370/dnp5370.c
Add GPL-2.0+ SPDX-License-Identifier to source files
[people/ms/u-boot.git] / board / dnp5370 / dnp5370.c
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 * SPDX-License-Identifier: GPL-2.0+
12 */
13
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>
21
22 static void disable_external_watchdog(void)
23 {
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
29 }
30
31 int checkboard(void)
32 {
33 printf("Board: SSV DilNet DNP5370\n");
34 return 0;
35 }
36
37 #ifdef CONFIG_BFIN_MAC
38 static void board_init_enetaddr(uchar *mac_addr)
39 {
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;
46
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;
53 }
54 }
55
56 if (!valid_mac) {
57 puts("Warning: Generating 'random' MAC address\n");
58 bfin_gen_rand_mac(mac_addr);
59 }
60
61 eth_setenv_enetaddr("ethaddr", mac_addr);
62 }
63
64 int board_eth_init(bd_t *bis)
65 {
66 return bfin_EMAC_initialize(bis);
67 }
68 #endif
69
70 /* miscellaneous platform dependent initialisations */
71 int misc_init_r(void)
72 {
73 disable_external_watchdog();
74
75 #ifdef CONFIG_BFIN_MAC
76 uchar enetaddr[6];
77 if (!eth_getenv_enetaddr("ethaddr", enetaddr))
78 board_init_enetaddr(enetaddr);
79 #endif
80
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
86
87 return 0;
88 }