xtfpga.c 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  1. // SPDX-License-Identifier: GPL-2.0+
  2. /*
  3. * (C) Copyright 2007 - 2013 Tensilica Inc.
  4. * (C) Copyright 2014 - 2016 Cadence Design Systems Inc.
  5. */
  6. #include <common.h>
  7. #include <command.h>
  8. #include <dm.h>
  9. #include <init.h>
  10. #include <dm/platform_data/net_ethoc.h>
  11. #include <env.h>
  12. #include <linux/ctype.h>
  13. #include <linux/string.h>
  14. #include <linux/stringify.h>
  15. #include <asm/global_data.h>
  16. DECLARE_GLOBAL_DATA_PTR;
  17. /*
  18. * Check board idendity.
  19. * (Print information about the board to stdout.)
  20. */
  21. #if defined(CONFIG_XTFPGA_LX60)
  22. const char *board = "XT_AV60";
  23. const char *description = "Avnet Xilinx LX60 FPGA Evaluation Board / ";
  24. #elif defined(CONFIG_XTFPGA_LX110)
  25. const char *board = "XT_AV110";
  26. const char *description = "Avnet Xilinx Virtex-5 LX110 Evaluation Kit / ";
  27. #elif defined(CONFIG_XTFPGA_LX200)
  28. const char *board = "XT_AV200";
  29. const char *description = "Avnet Xilinx Virtex-4 LX200 Evaluation Kit / ";
  30. #elif defined(CONFIG_XTFPGA_ML605)
  31. const char *board = "XT_ML605";
  32. const char *description = "Xilinx Virtex-6 FPGA ML605 Evaluation Kit / ";
  33. #elif defined(CONFIG_XTFPGA_KC705)
  34. const char *board = "XT_KC705";
  35. const char *description = "Xilinx Kintex-7 FPGA KC705 Evaluation Kit / ";
  36. #else
  37. const char *board = "<unknown>";
  38. const char *description = "";
  39. #endif
  40. int checkboard(void)
  41. {
  42. printf("Board: %s: %sTensilica bitstream\n", board, description);
  43. return 0;
  44. }
  45. int board_postclk_init(void)
  46. {
  47. /*
  48. * Obtain CPU clock frequency from board and cache in global
  49. * data structure (Hz). Return 0 on success (OK to continue),
  50. * else non-zero (hang).
  51. */
  52. #ifdef CONFIG_SYS_FPGAREG_FREQ
  53. gd->cpu_clk = (*(volatile unsigned long *)CONFIG_SYS_FPGAREG_FREQ);
  54. #else
  55. /* early Tensilica bitstreams lack this reg, but most run at 50 MHz */
  56. gd->cpu_clk = 50000000UL;
  57. #endif
  58. return 0;
  59. }
  60. /*
  61. * Miscellaneous late initializations.
  62. * The environment has been set up, so we can set the Ethernet address.
  63. */
  64. int misc_init_r(void)
  65. {
  66. #ifdef CONFIG_CMD_NET
  67. /*
  68. * Initialize ethernet environment variables and board info.
  69. * Default MAC address comes from CONFIG_ETHADDR + DIP switches 1-6.
  70. */
  71. char *s = env_get("ethaddr");
  72. if (s == 0) {
  73. unsigned int x;
  74. char s[] = __stringify(CONFIG_ETHBASE);
  75. x = (*(volatile u32 *)CONFIG_SYS_FPGAREG_DIPSW)
  76. & FPGAREG_MAC_MASK;
  77. sprintf(&s[15], "%02x", x);
  78. env_set("ethaddr", s);
  79. }
  80. #endif /* CONFIG_CMD_NET */
  81. return 0;
  82. }
  83. U_BOOT_DEVICE(sysreset) = {
  84. .name = "xtfpga_sysreset",
  85. };
  86. static struct ethoc_eth_pdata ethoc_pdata = {
  87. .eth_pdata = {
  88. .iobase = CONFIG_SYS_ETHOC_BASE,
  89. },
  90. .packet_base = CONFIG_SYS_ETHOC_BUFFER_ADDR,
  91. };
  92. U_BOOT_DEVICE(ethoc) = {
  93. .name = "ethoc",
  94. .plat = &ethoc_pdata,
  95. };