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 | |
| 7 | #include <common.h> |
| 8 | #include <command.h> |
Simon Glass | 11c89f3 | 2017-05-17 17:18:03 -0600 | [diff] [blame] | 9 | #include <dm.h> |
Simon Glass | a7b5130 | 2019-11-14 12:57:46 -0700 | [diff] [blame] | 10 | #include <init.h> |
Chris Zankel | 05d0c5d | 2016-08-10 18:36:48 +0300 | [diff] [blame] | 11 | #include <dm/platform_data/net_ethoc.h> |
Simon Glass | 5e6201b | 2019-08-01 09:46:51 -0600 | [diff] [blame] | 12 | #include <env.h> |
Chris Zankel | 05d0c5d | 2016-08-10 18:36:48 +0300 | [diff] [blame] | 13 | #include <linux/ctype.h> |
| 14 | #include <linux/string.h> |
| 15 | #include <linux/stringify.h> |
| 16 | #include <asm/global_data.h> |
| 17 | |
| 18 | DECLARE_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) |
| 27 | const char *board = "XT_AV60"; |
| 28 | const char *description = "Avnet Xilinx LX60 FPGA Evaluation Board / "; |
| 29 | #elif defined(CONFIG_XTFPGA_LX110) |
| 30 | const char *board = "XT_AV110"; |
| 31 | const char *description = "Avnet Xilinx Virtex-5 LX110 Evaluation Kit / "; |
| 32 | #elif defined(CONFIG_XTFPGA_LX200) |
| 33 | const char *board = "XT_AV200"; |
| 34 | const char *description = "Avnet Xilinx Virtex-4 LX200 Evaluation Kit / "; |
| 35 | #elif defined(CONFIG_XTFPGA_ML605) |
| 36 | const char *board = "XT_ML605"; |
| 37 | const char *description = "Xilinx Virtex-6 FPGA ML605 Evaluation Kit / "; |
| 38 | #elif defined(CONFIG_XTFPGA_KC705) |
| 39 | const char *board = "XT_KC705"; |
| 40 | const char *description = "Xilinx Kintex-7 FPGA KC705 Evaluation Kit / "; |
| 41 | #else |
| 42 | const char *board = "<unknown>"; |
| 43 | const char *description = ""; |
| 44 | #endif |
| 45 | |
| 46 | int checkboard(void) |
| 47 | { |
| 48 | printf("Board: %s: %sTensilica bitstream\n", board, description); |
| 49 | return 0; |
| 50 | } |
| 51 | |
Simon Glass | 2f949c3 | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 52 | int dram_init_banksize(void) |
Chris Zankel | 05d0c5d | 2016-08-10 18:36:48 +0300 | [diff] [blame] | 53 | { |
| 54 | gd->bd->bi_memstart = PHYSADDR(CONFIG_SYS_SDRAM_BASE); |
| 55 | gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE; |
Simon Glass | 2f949c3 | 2017-03-31 08:40:32 -0600 | [diff] [blame] | 56 | |
| 57 | return 0; |
Chris Zankel | 05d0c5d | 2016-08-10 18:36:48 +0300 | [diff] [blame] | 58 | } |
| 59 | |
| 60 | int board_postclk_init(void) |
| 61 | { |
| 62 | /* |
| 63 | * Obtain CPU clock frequency from board and cache in global |
| 64 | * data structure (Hz). Return 0 on success (OK to continue), |
| 65 | * else non-zero (hang). |
| 66 | */ |
| 67 | |
| 68 | #ifdef CONFIG_SYS_FPGAREG_FREQ |
| 69 | gd->cpu_clk = (*(volatile unsigned long *)CONFIG_SYS_FPGAREG_FREQ); |
| 70 | #else |
| 71 | /* early Tensilica bitstreams lack this reg, but most run at 50 MHz */ |
| 72 | gd->cpu_clk = 50000000UL; |
| 73 | #endif |
| 74 | return 0; |
| 75 | } |
| 76 | |
| 77 | /* |
| 78 | * Miscellaneous late initializations. |
| 79 | * The environment has been set up, so we can set the Ethernet address. |
| 80 | */ |
| 81 | |
| 82 | int misc_init_r(void) |
| 83 | { |
| 84 | #ifdef CONFIG_CMD_NET |
| 85 | /* |
| 86 | * Initialize ethernet environment variables and board info. |
| 87 | * Default MAC address comes from CONFIG_ETHADDR + DIP switches 1-6. |
| 88 | */ |
| 89 | |
Simon Glass | 64b723f | 2017-08-03 12:22:12 -0600 | [diff] [blame] | 90 | char *s = env_get("ethaddr"); |
Chris Zankel | 05d0c5d | 2016-08-10 18:36:48 +0300 | [diff] [blame] | 91 | if (s == 0) { |
| 92 | unsigned int x; |
| 93 | char s[] = __stringify(CONFIG_ETHBASE); |
| 94 | x = (*(volatile u32 *)CONFIG_SYS_FPGAREG_DIPSW) |
| 95 | & FPGAREG_MAC_MASK; |
| 96 | sprintf(&s[15], "%02x", x); |
Simon Glass | 6a38e41 | 2017-08-03 12:22:09 -0600 | [diff] [blame] | 97 | env_set("ethaddr", s); |
Chris Zankel | 05d0c5d | 2016-08-10 18:36:48 +0300 | [diff] [blame] | 98 | } |
| 99 | #endif /* CONFIG_CMD_NET */ |
| 100 | |
| 101 | return 0; |
| 102 | } |
| 103 | |
| 104 | U_BOOT_DEVICE(sysreset) = { |
| 105 | .name = "xtfpga_sysreset", |
| 106 | }; |
| 107 | |
| 108 | static struct ethoc_eth_pdata ethoc_pdata = { |
| 109 | .eth_pdata = { |
| 110 | .iobase = CONFIG_SYS_ETHOC_BASE, |
| 111 | }, |
| 112 | .packet_base = CONFIG_SYS_ETHOC_BUFFER_ADDR, |
| 113 | }; |
| 114 | |
| 115 | U_BOOT_DEVICE(ethoc) = { |
| 116 | .name = "ethoc", |
| 117 | .platdata = ðoc_pdata, |
| 118 | }; |