blob: d30940d7c3e3fe4d294e33a9e5497ea4002528a6 [file] [log] [blame]
Tom Rini10e47792018-05-06 17:58:06 -04001// SPDX-License-Identifier: GPL-2.0+
Chris Zankel05d0c5d2016-08-10 18:36:48 +03002/*
3 * (C) Copyright 2007 - 2013 Tensilica Inc.
4 * (C) Copyright 2014 - 2016 Cadence Design Systems Inc.
Chris Zankel05d0c5d2016-08-10 18:36:48 +03005 */
6
7#include <common.h>
8#include <command.h>
Simon Glass11c89f32017-05-17 17:18:03 -06009#include <dm.h>
Simon Glassa7b51302019-11-14 12:57:46 -070010#include <init.h>
Chris Zankel05d0c5d2016-08-10 18:36:48 +030011#include <dm/platform_data/net_ethoc.h>
Simon Glass5e6201b2019-08-01 09:46:51 -060012#include <env.h>
Chris Zankel05d0c5d2016-08-10 18:36:48 +030013#include <linux/ctype.h>
14#include <linux/string.h>
15#include <linux/stringify.h>
16#include <asm/global_data.h>
17
18DECLARE_GLOBAL_DATA_PTR;
19
20/*
21 * Check board idendity.
22 * (Print information about the board to stdout.)
23 */
24
25
26#if defined(CONFIG_XTFPGA_LX60)
27const char *board = "XT_AV60";
28const char *description = "Avnet Xilinx LX60 FPGA Evaluation Board / ";
29#elif defined(CONFIG_XTFPGA_LX110)
30const char *board = "XT_AV110";
31const char *description = "Avnet Xilinx Virtex-5 LX110 Evaluation Kit / ";
32#elif defined(CONFIG_XTFPGA_LX200)
33const char *board = "XT_AV200";
34const char *description = "Avnet Xilinx Virtex-4 LX200 Evaluation Kit / ";
35#elif defined(CONFIG_XTFPGA_ML605)
36const char *board = "XT_ML605";
37const char *description = "Xilinx Virtex-6 FPGA ML605 Evaluation Kit / ";
38#elif defined(CONFIG_XTFPGA_KC705)
39const char *board = "XT_KC705";
40const char *description = "Xilinx Kintex-7 FPGA KC705 Evaluation Kit / ";
41#else
42const char *board = "<unknown>";
43const char *description = "";
44#endif
45
46int checkboard(void)
47{
48 printf("Board: %s: %sTensilica bitstream\n", board, description);
49 return 0;
50}
51
Tom Riniaea2a992021-12-14 13:36:39 -050052unsigned long get_board_sys_clk(void)
Chris Zankel05d0c5d2016-08-10 18:36:48 +030053{
54 /*
55 * Obtain CPU clock frequency from board and cache in global
56 * data structure (Hz). Return 0 on success (OK to continue),
57 * else non-zero (hang).
58 */
59
60#ifdef CONFIG_SYS_FPGAREG_FREQ
Tom Riniaea2a992021-12-14 13:36:39 -050061 return (*(volatile unsigned long *)CONFIG_SYS_FPGAREG_FREQ);
Chris Zankel05d0c5d2016-08-10 18:36:48 +030062#else
63 /* early Tensilica bitstreams lack this reg, but most run at 50 MHz */
Tom Riniaea2a992021-12-14 13:36:39 -050064 return 50000000;
Chris Zankel05d0c5d2016-08-10 18:36:48 +030065#endif
Tom Riniaea2a992021-12-14 13:36:39 -050066}
67
68int board_postclk_init(void)
69{
70 gd->cpu_clk = get_board_sys_clk();
71
Chris Zankel05d0c5d2016-08-10 18:36:48 +030072 return 0;
73}
74
75/*
76 * Miscellaneous late initializations.
77 * The environment has been set up, so we can set the Ethernet address.
78 */
79
80int misc_init_r(void)
81{
82#ifdef CONFIG_CMD_NET
83 /*
84 * Initialize ethernet environment variables and board info.
85 * Default MAC address comes from CONFIG_ETHADDR + DIP switches 1-6.
86 */
87
Simon Glass64b723f2017-08-03 12:22:12 -060088 char *s = env_get("ethaddr");
Chris Zankel05d0c5d2016-08-10 18:36:48 +030089 if (s == 0) {
90 unsigned int x;
91 char s[] = __stringify(CONFIG_ETHBASE);
92 x = (*(volatile u32 *)CONFIG_SYS_FPGAREG_DIPSW)
93 & FPGAREG_MAC_MASK;
94 sprintf(&s[15], "%02x", x);
Simon Glass6a38e412017-08-03 12:22:09 -060095 env_set("ethaddr", s);
Chris Zankel05d0c5d2016-08-10 18:36:48 +030096 }
97#endif /* CONFIG_CMD_NET */
98
99 return 0;
100}
101
Simon Glass1d8364a2020-12-28 20:34:54 -0700102U_BOOT_DRVINFO(sysreset) = {
Chris Zankel05d0c5d2016-08-10 18:36:48 +0300103 .name = "xtfpga_sysreset",
104};
105
106static struct ethoc_eth_pdata ethoc_pdata = {
107 .eth_pdata = {
108 .iobase = CONFIG_SYS_ETHOC_BASE,
109 },
110 .packet_base = CONFIG_SYS_ETHOC_BUFFER_ADDR,
111};
112
Simon Glass1d8364a2020-12-28 20:34:54 -0700113U_BOOT_DRVINFO(ethoc) = {
Chris Zankel05d0c5d2016-08-10 18:36:48 +0300114 .name = "ethoc",
Simon Glass71fa5b42020-12-03 16:55:18 -0700115 .plat = &ethoc_pdata,
Chris Zankel05d0c5d2016-08-10 18:36:48 +0300116};