Tom Rini | 10e4779 | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
Chris Zankel | 05d0c5d | 2016-08-10 18:36:48 +0300 | [diff] [blame] | 2 | /* |
| 3 | * (C) Copyright 2007 - 2013 Tensilica Inc. |
| 4 | * (C) Copyright 2014 - 2016 Cadence Design Systems Inc. |
Chris Zankel | 05d0c5d | 2016-08-10 18:36:48 +0300 | [diff] [blame] | 5 | */ |
| 6 | |
Tom Rini | abb9a04 | 2024-05-18 20:20:43 -0600 | [diff] [blame] | 7 | #include <common.h> |
Tom Rini | 8c70baa | 2021-12-14 13:36:40 -0500 | [diff] [blame] | 8 | #include <clock_legacy.h> |
Chris Zankel | 05d0c5d | 2016-08-10 18:36:48 +0300 | [diff] [blame] | 9 | #include <command.h> |
Simon Glass | 11c89f3 | 2017-05-17 17:18:03 -0600 | [diff] [blame] | 10 | #include <dm.h> |
Simon Glass | a7b5130 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 11 | #include <init.h> |
Chris Zankel | 05d0c5d | 2016-08-10 18:36:48 +0300 | [diff] [blame] | 12 | #include <dm/platform_data/net_ethoc.h> |
Simon Glass | 5e6201b | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 13 | #include <env.h> |
Chris Zankel | 05d0c5d | 2016-08-10 18:36:48 +0300 | [diff] [blame] | 14 | #include <linux/ctype.h> |
| 15 | #include <linux/string.h> |
| 16 | #include <linux/stringify.h> |
| 17 | #include <asm/global_data.h> |
| 18 | |
| 19 | DECLARE_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) |
| 28 | const char *board = "XT_AV60"; |
| 29 | const char *description = "Avnet Xilinx LX60 FPGA Evaluation Board / "; |
| 30 | #elif defined(CONFIG_XTFPGA_LX110) |
| 31 | const char *board = "XT_AV110"; |
| 32 | const char *description = "Avnet Xilinx Virtex-5 LX110 Evaluation Kit / "; |
| 33 | #elif defined(CONFIG_XTFPGA_LX200) |
| 34 | const char *board = "XT_AV200"; |
| 35 | const char *description = "Avnet Xilinx Virtex-4 LX200 Evaluation Kit / "; |
| 36 | #elif defined(CONFIG_XTFPGA_ML605) |
| 37 | const char *board = "XT_ML605"; |
| 38 | const char *description = "Xilinx Virtex-6 FPGA ML605 Evaluation Kit / "; |
| 39 | #elif defined(CONFIG_XTFPGA_KC705) |
| 40 | const char *board = "XT_KC705"; |
| 41 | const char *description = "Xilinx Kintex-7 FPGA KC705 Evaluation Kit / "; |
| 42 | #else |
| 43 | const char *board = "<unknown>"; |
| 44 | const char *description = ""; |
| 45 | #endif |
| 46 | |
| 47 | int checkboard(void) |
| 48 | { |
| 49 | printf("Board: %s: %sTensilica bitstream\n", board, description); |
| 50 | return 0; |
| 51 | } |
| 52 | |
Tom Rini | aea2a99 | 2021-12-14 13:36:39 -0500 | [diff] [blame] | 53 | unsigned long get_board_sys_clk(void) |
Chris Zankel | 05d0c5d | 2016-08-10 18:36:48 +0300 | [diff] [blame] | 54 | { |
| 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 Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 61 | #ifdef CFG_SYS_FPGAREG_FREQ |
| 62 | return (*(volatile unsigned long *)CFG_SYS_FPGAREG_FREQ); |
Chris Zankel | 05d0c5d | 2016-08-10 18:36:48 +0300 | [diff] [blame] | 63 | #else |
| 64 | /* early Tensilica bitstreams lack this reg, but most run at 50 MHz */ |
Tom Rini | aea2a99 | 2021-12-14 13:36:39 -0500 | [diff] [blame] | 65 | return 50000000; |
Chris Zankel | 05d0c5d | 2016-08-10 18:36:48 +0300 | [diff] [blame] | 66 | #endif |
Tom Rini | aea2a99 | 2021-12-14 13:36:39 -0500 | [diff] [blame] | 67 | } |
| 68 | |
| 69 | int board_postclk_init(void) |
| 70 | { |
| 71 | gd->cpu_clk = get_board_sys_clk(); |
| 72 | |
Chris Zankel | 05d0c5d | 2016-08-10 18:36:48 +0300 | [diff] [blame] | 73 | return 0; |
| 74 | } |
| 75 | |
| 76 | /* |
| 77 | * Miscellaneous late initializations. |
| 78 | * The environment has been set up, so we can set the Ethernet address. |
| 79 | */ |
| 80 | |
| 81 | int misc_init_r(void) |
| 82 | { |
| 83 | #ifdef CONFIG_CMD_NET |
| 84 | /* |
| 85 | * Initialize ethernet environment variables and board info. |
| 86 | * Default MAC address comes from CONFIG_ETHADDR + DIP switches 1-6. |
| 87 | */ |
| 88 | |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 89 | char *s = env_get("ethaddr"); |
Chris Zankel | 05d0c5d | 2016-08-10 18:36:48 +0300 | [diff] [blame] | 90 | if (s == 0) { |
| 91 | unsigned int x; |
Tom Rini | 7d03ce6 | 2022-12-04 10:03:49 -0500 | [diff] [blame] | 92 | char s[] = __stringify(CFG_ETHBASE); |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 93 | x = (*(volatile u32 *)CFG_SYS_FPGAREG_DIPSW) |
Chris Zankel | 05d0c5d | 2016-08-10 18:36:48 +0300 | [diff] [blame] | 94 | & FPGAREG_MAC_MASK; |
| 95 | sprintf(&s[15], "%02x", x); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 96 | env_set("ethaddr", s); |
Chris Zankel | 05d0c5d | 2016-08-10 18:36:48 +0300 | [diff] [blame] | 97 | } |
| 98 | #endif /* CONFIG_CMD_NET */ |
| 99 | |
| 100 | return 0; |
| 101 | } |
| 102 | |
Simon Glass | 1d8364a | 2020-12-28 20:34:54 -0700 | [diff] [blame] | 103 | U_BOOT_DRVINFO(sysreset) = { |
Chris Zankel | 05d0c5d | 2016-08-10 18:36:48 +0300 | [diff] [blame] | 104 | .name = "xtfpga_sysreset", |
| 105 | }; |
| 106 | |
| 107 | static struct ethoc_eth_pdata ethoc_pdata = { |
| 108 | .eth_pdata = { |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 109 | .iobase = CFG_SYS_ETHOC_BASE, |
Chris Zankel | 05d0c5d | 2016-08-10 18:36:48 +0300 | [diff] [blame] | 110 | }, |
Tom Rini | 6a5dccc | 2022-11-16 13:10:41 -0500 | [diff] [blame] | 111 | .packet_base = CFG_SYS_ETHOC_BUFFER_ADDR, |
Chris Zankel | 05d0c5d | 2016-08-10 18:36:48 +0300 | [diff] [blame] | 112 | }; |
| 113 | |
Simon Glass | 1d8364a | 2020-12-28 20:34:54 -0700 | [diff] [blame] | 114 | U_BOOT_DRVINFO(ethoc) = { |
Chris Zankel | 05d0c5d | 2016-08-10 18:36:48 +0300 | [diff] [blame] | 115 | .name = "ethoc", |
Simon Glass | 71fa5b4 | 2020-12-03 16:55:18 -0700 | [diff] [blame] | 116 | .plat = ðoc_pdata, |
Chris Zankel | 05d0c5d | 2016-08-10 18:36:48 +0300 | [diff] [blame] | 117 | }; |