blob: 4b3873bd4f36445e398d3ffc1213f39328375462 [file] [log] [blame]
Andreas Schallenberg93306a32010-11-17 13:51:33 -05001/*
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 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +020011 * SPDX-License-Identifier: GPL-2.0+
Andreas Schallenberg93306a32010-11-17 13:51:33 -050012 */
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
22static 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
31int checkboard(void)
32{
33 printf("Board: SSV DilNet DNP5370\n");
34 return 0;
35}
36
37#ifdef CONFIG_BFIN_MAC
38static 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
64int board_eth_init(bd_t *bis)
65{
66 return bfin_EMAC_initialize(bis);
67}
68#endif
69
70/* miscellaneous platform dependent initialisations */
71int 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}