blob: 6b92fe31c0e05cc0e984de6fb82d211bfaafd7c2 [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
Tom Rinice927c02024-04-30 20:41:20 -06007#include <config.h>
Tom Rini8c70baa2021-12-14 13:36:40 -05008#include <clock_legacy.h>
Chris Zankel05d0c5d2016-08-10 18:36:48 +03009#include <command.h>
Simon Glass11c89f32017-05-17 17:18:03 -060010#include <dm.h>
Simon Glassa7b51302019-11-14 12:57:46 -070011#include <init.h>
Chris Zankel05d0c5d2016-08-10 18:36:48 +030012#include <dm/platform_data/net_ethoc.h>
Simon Glass5e6201b2019-08-01 09:46:51 -060013#include <env.h>
Chris Zankel05d0c5d2016-08-10 18:36:48 +030014#include <linux/ctype.h>
15#include <linux/string.h>
16#include <linux/stringify.h>
17#include <asm/global_data.h>
18
19DECLARE_GLOBAL_DATA_PTR;
20
21/*
22 * Check board idendity.
23 * (Print information about the board to stdout.)
24 */
25
26
27#if defined(CONFIG_XTFPGA_LX60)
28const char *board = "XT_AV60";
29const char *description = "Avnet Xilinx LX60 FPGA Evaluation Board / ";
30#elif defined(CONFIG_XTFPGA_LX110)
31const char *board = "XT_AV110";
32const char *description = "Avnet Xilinx Virtex-5 LX110 Evaluation Kit / ";
33#elif defined(CONFIG_XTFPGA_LX200)
34const char *board = "XT_AV200";
35const char *description = "Avnet Xilinx Virtex-4 LX200 Evaluation Kit / ";
36#elif defined(CONFIG_XTFPGA_ML605)
37const char *board = "XT_ML605";
38const char *description = "Xilinx Virtex-6 FPGA ML605 Evaluation Kit / ";
39#elif defined(CONFIG_XTFPGA_KC705)
40const char *board = "XT_KC705";
41const char *description = "Xilinx Kintex-7 FPGA KC705 Evaluation Kit / ";
42#else
43const char *board = "<unknown>";
44const char *description = "";
45#endif
46
47int checkboard(void)
48{
49 printf("Board: %s: %sTensilica bitstream\n", board, description);
50 return 0;
51}
52
Tom Riniaea2a992021-12-14 13:36:39 -050053unsigned long get_board_sys_clk(void)
Chris Zankel05d0c5d2016-08-10 18:36:48 +030054{
55 /*
56 * Obtain CPU clock frequency from board and cache in global
57 * data structure (Hz). Return 0 on success (OK to continue),
58 * else non-zero (hang).
59 */
60
Tom Rini6a5dccc2022-11-16 13:10:41 -050061#ifdef CFG_SYS_FPGAREG_FREQ
62 return (*(volatile unsigned long *)CFG_SYS_FPGAREG_FREQ);
Chris Zankel05d0c5d2016-08-10 18:36:48 +030063#else
64 /* early Tensilica bitstreams lack this reg, but most run at 50 MHz */
Tom Riniaea2a992021-12-14 13:36:39 -050065 return 50000000;
Chris Zankel05d0c5d2016-08-10 18:36:48 +030066#endif
Tom Riniaea2a992021-12-14 13:36:39 -050067}
68
Jiaxun Yang71018682024-06-18 14:56:01 +010069int dram_init(void)
70{
71 return 0;
72}
73
Tom Riniaea2a992021-12-14 13:36:39 -050074int board_postclk_init(void)
75{
76 gd->cpu_clk = get_board_sys_clk();
77
Chris Zankel05d0c5d2016-08-10 18:36:48 +030078 return 0;
79}
80
81/*
82 * Miscellaneous late initializations.
83 * The environment has been set up, so we can set the Ethernet address.
84 */
85
86int misc_init_r(void)
87{
88#ifdef CONFIG_CMD_NET
89 /*
90 * Initialize ethernet environment variables and board info.
91 * Default MAC address comes from CONFIG_ETHADDR + DIP switches 1-6.
92 */
93
Simon Glass64b723f2017-08-03 12:22:12 -060094 char *s = env_get("ethaddr");
Chris Zankel05d0c5d2016-08-10 18:36:48 +030095 if (s == 0) {
96 unsigned int x;
Tom Rini7d03ce62022-12-04 10:03:49 -050097 char s[] = __stringify(CFG_ETHBASE);
Tom Rini6a5dccc2022-11-16 13:10:41 -050098 x = (*(volatile u32 *)CFG_SYS_FPGAREG_DIPSW)
Chris Zankel05d0c5d2016-08-10 18:36:48 +030099 & FPGAREG_MAC_MASK;
100 sprintf(&s[15], "%02x", x);
Simon Glass6a38e412017-08-03 12:22:09 -0600101 env_set("ethaddr", s);
Chris Zankel05d0c5d2016-08-10 18:36:48 +0300102 }
103#endif /* CONFIG_CMD_NET */
104
105 return 0;
106}
107
Simon Glass1d8364a2020-12-28 20:34:54 -0700108U_BOOT_DRVINFO(sysreset) = {
Chris Zankel05d0c5d2016-08-10 18:36:48 +0300109 .name = "xtfpga_sysreset",
110};
111
112static struct ethoc_eth_pdata ethoc_pdata = {
113 .eth_pdata = {
Tom Rini6a5dccc2022-11-16 13:10:41 -0500114 .iobase = CFG_SYS_ETHOC_BASE,
Chris Zankel05d0c5d2016-08-10 18:36:48 +0300115 },
Tom Rini6a5dccc2022-11-16 13:10:41 -0500116 .packet_base = CFG_SYS_ETHOC_BUFFER_ADDR,
Chris Zankel05d0c5d2016-08-10 18:36:48 +0300117};
118
Simon Glass1d8364a2020-12-28 20:34:54 -0700119U_BOOT_DRVINFO(ethoc) = {
Chris Zankel05d0c5d2016-08-10 18:36:48 +0300120 .name = "ethoc",
Simon Glass71fa5b42020-12-03 16:55:18 -0700121 .plat = &ethoc_pdata,
Chris Zankel05d0c5d2016-08-10 18:36:48 +0300122};