~pmdj/ubuntu/trusty/qemu/2.9+applesmc+fadtv3

« back to all changes in this revision

Viewing changes to roms/u-boot/board/dnp5370/dnp5370.c

  • Committer: Phil Dennis-Jordan
  • Date: 2017-07-21 08:03:43 UTC
  • mfrom: (1.1.1)
  • Revision ID: phil@philjordan.eu-20170721080343-2yr2vdj7713czahv
New upstream release 2.9.0.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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 <net.h>
 
18
#include <netdev.h>
 
19
#include <asm/gpio.h>
 
20
 
 
21
static void disable_external_watchdog(void)
 
22
{
 
23
#ifdef CONFIG_DNP5370_EXT_WD_DISABLE
 
24
        /* disable external HW watchdog with PH13 = WD1 = 1 */
 
25
        gpio_request(GPIO_PH13, "ext_wd");
 
26
        gpio_direction_output(GPIO_PH13, 1);
 
27
#endif
 
28
}
 
29
 
 
30
int checkboard(void)
 
31
{
 
32
        printf("Board: SSV DilNet DNP5370\n");
 
33
        return 0;
 
34
}
 
35
 
 
36
#ifdef CONFIG_BFIN_MAC
 
37
static void board_init_enetaddr(uchar *mac_addr)
 
38
{
 
39
#ifdef CONFIG_SYS_NO_FLASH
 
40
# define USE_MAC_IN_FLASH 0
 
41
#else
 
42
# define USE_MAC_IN_FLASH 1
 
43
#endif
 
44
        bool valid_mac = false;
 
45
 
 
46
        if (USE_MAC_IN_FLASH) {
 
47
                /* we cram the MAC in the last flash sector */
 
48
                uchar *board_mac_addr = (uchar *)0x202F0000;
 
49
                if (is_valid_ether_addr(board_mac_addr)) {
 
50
                        memcpy(mac_addr, board_mac_addr, 6);
 
51
                        valid_mac = true;
 
52
                }
 
53
        }
 
54
 
 
55
        if (!valid_mac) {
 
56
                puts("Warning: Generating 'random' MAC address\n");
 
57
                eth_random_addr(mac_addr);
 
58
        }
 
59
 
 
60
        eth_setenv_enetaddr("ethaddr", mac_addr);
 
61
}
 
62
 
 
63
int board_eth_init(bd_t *bis)
 
64
{
 
65
        return bfin_EMAC_initialize(bis);
 
66
}
 
67
#endif
 
68
 
 
69
/* miscellaneous platform dependent initialisations */
 
70
int misc_init_r(void)
 
71
{
 
72
        disable_external_watchdog();
 
73
 
 
74
#ifdef CONFIG_BFIN_MAC
 
75
        uchar enetaddr[6];
 
76
        if (!eth_getenv_enetaddr("ethaddr", enetaddr))
 
77
                board_init_enetaddr(enetaddr);
 
78
#endif
 
79
 
 
80
#ifndef CONFIG_SYS_NO_FLASH
 
81
        /* we use the last sector for the MAC address / POST LDR */
 
82
        extern flash_info_t flash_info[];
 
83
        flash_protect(FLAG_PROTECT_SET, 0x202F0000, 0x202FFFFF, &flash_info[0]);
 
84
#endif
 
85
 
 
86
        return 0;
 
87
}