xref: /rk3399_rockchip-uboot/board/cadence/xtfpga/xtfpga.c (revision 00caae6d47645e68d6e5277aceb69592b49381a6)
17e270ec3SChris Zankel /*
27e270ec3SChris Zankel  * (C) Copyright 2007 - 2013 Tensilica Inc.
37e270ec3SChris Zankel  * (C) Copyright 2014 - 2016 Cadence Design Systems Inc.
47e270ec3SChris Zankel  *
57e270ec3SChris Zankel  * SPDX-License-Identifier:	GPL-2.0+
67e270ec3SChris Zankel  */
77e270ec3SChris Zankel 
87e270ec3SChris Zankel #include <common.h>
97e270ec3SChris Zankel #include <command.h>
109d922450SSimon Glass #include <dm.h>
117e270ec3SChris Zankel #include <dm/platform_data/net_ethoc.h>
127e270ec3SChris Zankel #include <linux/ctype.h>
137e270ec3SChris Zankel #include <linux/string.h>
147e270ec3SChris Zankel #include <linux/stringify.h>
157e270ec3SChris Zankel #include <asm/global_data.h>
167e270ec3SChris Zankel 
177e270ec3SChris Zankel DECLARE_GLOBAL_DATA_PTR;
187e270ec3SChris Zankel 
197e270ec3SChris Zankel /*
207e270ec3SChris Zankel  * Check board idendity.
217e270ec3SChris Zankel  * (Print information about the board to stdout.)
227e270ec3SChris Zankel  */
237e270ec3SChris Zankel 
247e270ec3SChris Zankel 
257e270ec3SChris Zankel #if defined(CONFIG_XTFPGA_LX60)
267e270ec3SChris Zankel const char *board = "XT_AV60";
277e270ec3SChris Zankel const char *description = "Avnet Xilinx LX60 FPGA Evaluation Board / ";
287e270ec3SChris Zankel #elif defined(CONFIG_XTFPGA_LX110)
297e270ec3SChris Zankel const char *board = "XT_AV110";
307e270ec3SChris Zankel const char *description = "Avnet Xilinx Virtex-5 LX110 Evaluation Kit / ";
317e270ec3SChris Zankel #elif defined(CONFIG_XTFPGA_LX200)
327e270ec3SChris Zankel const char *board = "XT_AV200";
337e270ec3SChris Zankel const char *description = "Avnet Xilinx Virtex-4 LX200 Evaluation Kit / ";
347e270ec3SChris Zankel #elif defined(CONFIG_XTFPGA_ML605)
357e270ec3SChris Zankel const char *board = "XT_ML605";
367e270ec3SChris Zankel const char *description = "Xilinx Virtex-6 FPGA ML605 Evaluation Kit / ";
377e270ec3SChris Zankel #elif defined(CONFIG_XTFPGA_KC705)
387e270ec3SChris Zankel const char *board = "XT_KC705";
397e270ec3SChris Zankel const char *description = "Xilinx Kintex-7 FPGA KC705 Evaluation Kit / ";
407e270ec3SChris Zankel #else
417e270ec3SChris Zankel const char *board = "<unknown>";
427e270ec3SChris Zankel const char *description = "";
437e270ec3SChris Zankel #endif
447e270ec3SChris Zankel 
checkboard(void)457e270ec3SChris Zankel int checkboard(void)
467e270ec3SChris Zankel {
477e270ec3SChris Zankel 	printf("Board: %s: %sTensilica bitstream\n", board, description);
487e270ec3SChris Zankel 	return 0;
497e270ec3SChris Zankel }
507e270ec3SChris Zankel 
dram_init_banksize(void)5176b00acaSSimon Glass int dram_init_banksize(void)
527e270ec3SChris Zankel {
537e270ec3SChris Zankel 	gd->bd->bi_memstart = PHYSADDR(CONFIG_SYS_SDRAM_BASE);
547e270ec3SChris Zankel 	gd->bd->bi_memsize = CONFIG_SYS_SDRAM_SIZE;
5576b00acaSSimon Glass 
5676b00acaSSimon Glass 	return 0;
577e270ec3SChris Zankel }
587e270ec3SChris Zankel 
board_postclk_init(void)597e270ec3SChris Zankel int board_postclk_init(void)
607e270ec3SChris Zankel {
617e270ec3SChris Zankel 	/*
627e270ec3SChris Zankel 	 * Obtain CPU clock frequency from board and cache in global
637e270ec3SChris Zankel 	 * data structure (Hz). Return 0 on success (OK to continue),
647e270ec3SChris Zankel 	 * else non-zero (hang).
657e270ec3SChris Zankel 	 */
667e270ec3SChris Zankel 
677e270ec3SChris Zankel #ifdef CONFIG_SYS_FPGAREG_FREQ
687e270ec3SChris Zankel 	gd->cpu_clk = (*(volatile unsigned long *)CONFIG_SYS_FPGAREG_FREQ);
697e270ec3SChris Zankel #else
707e270ec3SChris Zankel 	/* early Tensilica bitstreams lack this reg, but most run at 50 MHz */
717e270ec3SChris Zankel 	gd->cpu_clk = 50000000UL;
727e270ec3SChris Zankel #endif
737e270ec3SChris Zankel 	return 0;
747e270ec3SChris Zankel }
757e270ec3SChris Zankel 
767e270ec3SChris Zankel /*
777e270ec3SChris Zankel  *  Miscellaneous late initializations.
787e270ec3SChris Zankel  *  The environment has been set up, so we can set the Ethernet address.
797e270ec3SChris Zankel  */
807e270ec3SChris Zankel 
misc_init_r(void)817e270ec3SChris Zankel int misc_init_r(void)
827e270ec3SChris Zankel {
837e270ec3SChris Zankel #ifdef CONFIG_CMD_NET
847e270ec3SChris Zankel 	/*
857e270ec3SChris Zankel 	 * Initialize ethernet environment variables and board info.
867e270ec3SChris Zankel 	 * Default MAC address comes from CONFIG_ETHADDR + DIP switches 1-6.
877e270ec3SChris Zankel 	 */
887e270ec3SChris Zankel 
89*00caae6dSSimon Glass 	char *s = env_get("ethaddr");
907e270ec3SChris Zankel 	if (s == 0) {
917e270ec3SChris Zankel 		unsigned int x;
927e270ec3SChris Zankel 		char s[] = __stringify(CONFIG_ETHBASE);
937e270ec3SChris Zankel 		x = (*(volatile u32 *)CONFIG_SYS_FPGAREG_DIPSW)
947e270ec3SChris Zankel 			& FPGAREG_MAC_MASK;
957e270ec3SChris Zankel 		sprintf(&s[15], "%02x", x);
96382bee57SSimon Glass 		env_set("ethaddr", s);
977e270ec3SChris Zankel 	}
987e270ec3SChris Zankel #endif /* CONFIG_CMD_NET */
997e270ec3SChris Zankel 
1007e270ec3SChris Zankel 	return 0;
1017e270ec3SChris Zankel }
1027e270ec3SChris Zankel 
1037e270ec3SChris Zankel U_BOOT_DEVICE(sysreset) = {
1047e270ec3SChris Zankel 	.name = "xtfpga_sysreset",
1057e270ec3SChris Zankel };
1067e270ec3SChris Zankel 
1077e270ec3SChris Zankel static struct ethoc_eth_pdata ethoc_pdata = {
1087e270ec3SChris Zankel 	.eth_pdata = {
1097e270ec3SChris Zankel 		.iobase = CONFIG_SYS_ETHOC_BASE,
1107e270ec3SChris Zankel 	},
1117e270ec3SChris Zankel 	.packet_base = CONFIG_SYS_ETHOC_BUFFER_ADDR,
1127e270ec3SChris Zankel };
1137e270ec3SChris Zankel 
1147e270ec3SChris Zankel U_BOOT_DEVICE(ethoc) = {
1157e270ec3SChris Zankel 	.name = "ethoc",
1167e270ec3SChris Zankel 	.platdata = &ethoc_pdata,
1177e270ec3SChris Zankel };
118