gazerbeam.c 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182
  1. /*
  2. * (C) Copyright 2015
  3. * Dirk Eibach, Guntermann & Drunck GmbH, eibach@gdsys.de
  4. *
  5. * SPDX-License-Identifier: GPL-2.0+
  6. */
  7. #include <common.h>
  8. #include <board.h>
  9. #include <command.h>
  10. #include <dm.h>
  11. #include <env.h>
  12. #include <fdt_support.h>
  13. #include <fsl_esdhc.h>
  14. #include <init.h>
  15. #include <miiphy.h>
  16. #include <misc.h>
  17. #include <tpm-v1.h>
  18. #include <video_osd.h>
  19. #include "../common/ihs_mdio.h"
  20. #include "../../../drivers/board/gazerbeam.h"
  21. DECLARE_GLOBAL_DATA_PTR;
  22. struct ihs_mdio_info ihs_mdio_info[] = {
  23. { .fpga = NULL, .name = "ihs0", .base = 0x58 },
  24. { .fpga = NULL, .name = "ihs1", .base = 0x58 },
  25. };
  26. static int get_tpm(struct udevice **devp)
  27. {
  28. int rc;
  29. rc = uclass_first_device_err(UCLASS_TPM, devp);
  30. if (rc) {
  31. printf("Could not find TPM (ret=%d)\n", rc);
  32. return CMD_RET_FAILURE;
  33. }
  34. return 0;
  35. }
  36. int board_early_init_r(void)
  37. {
  38. struct udevice *board;
  39. struct udevice *serdes;
  40. int mc = 0;
  41. int con = 0;
  42. if (board_get(&board))
  43. puts("Could not find board information device.\n");
  44. /* Initialize serdes */
  45. uclass_get_device_by_phandle(UCLASS_MISC, board, "serdes", &serdes);
  46. if (board_detect(board))
  47. puts("Device information detection failed.\n");
  48. board_get_int(board, BOARD_MULTICHANNEL, &mc);
  49. board_get_int(board, BOARD_VARIANT, &con);
  50. if (mc == 2 || mc == 1)
  51. dev_disable_by_path("/immr@e0000000/i2c@3100/pca9698@22");
  52. if (mc == 4) {
  53. dev_disable_by_path("/immr@e0000000/i2c@3100/pca9698@20");
  54. dev_enable_by_path("/localbus@e0005000/iocon_uart@2,0");
  55. dev_enable_by_path("/fpga1bus");
  56. }
  57. if (mc == 2 || con == VAR_CON) {
  58. dev_enable_by_path("/fpga0bus/fpga0_video1");
  59. dev_enable_by_path("/fpga0bus/fpga0_iic_video1");
  60. dev_enable_by_path("/fpga0bus/fpga0_axi_video1");
  61. }
  62. if (con == VAR_CON) {
  63. dev_enable_by_path("/fpga0bus/fpga0_video0");
  64. dev_enable_by_path("/fpga0bus/fpga0_iic_video0");
  65. dev_enable_by_path("/fpga0bus/fpga0_axi_video0");
  66. }
  67. return 0;
  68. }
  69. int checkboard(void)
  70. {
  71. struct udevice *board;
  72. char *s = env_get("serial#");
  73. int mc = 0;
  74. int con = 0;
  75. if (board_get(&board))
  76. puts("Could not find board information device.\n");
  77. board_get_int(board, BOARD_MULTICHANNEL, &mc);
  78. board_get_int(board, BOARD_VARIANT, &con);
  79. puts("Board: Gazerbeam ");
  80. printf("%s ", mc == 4 ? "MC4" : mc == 2 ? "MC2" : "SC");
  81. printf("%s", con == VAR_CON ? "CON" : "CPU");
  82. if (s) {
  83. puts(", serial# ");
  84. puts(s);
  85. }
  86. puts("\n");
  87. return 0;
  88. }
  89. static void display_osd_info(struct udevice *osd,
  90. struct video_osd_info *osd_info)
  91. {
  92. printf("OSD-%s: Digital-OSD version %01d.%02d, %d x %d characters\n",
  93. osd->name, osd_info->major_version, osd_info->minor_version,
  94. osd_info->width, osd_info->height);
  95. }
  96. int last_stage_init(void)
  97. {
  98. int fpga_hw_rev = 0;
  99. int i;
  100. struct udevice *board;
  101. struct udevice *osd;
  102. struct video_osd_info osd_info;
  103. struct udevice *tpm;
  104. int ret;
  105. if (board_get(&board))
  106. puts("Could not find board information device.\n");
  107. if (board) {
  108. int res = board_get_int(board, BOARD_HWVERSION, &fpga_hw_rev);
  109. if (res)
  110. printf("Could not determind FPGA HW revision (res = %d)\n", res);
  111. }
  112. env_set_ulong("fpga_hw_rev", fpga_hw_rev);
  113. ret = get_tpm(&tpm);
  114. if (ret || tpm_init(tpm) || tpm_startup(tpm, TPM_ST_CLEAR) ||
  115. tpm_continue_self_test(tpm)) {
  116. printf("TPM init failed\n");
  117. }
  118. if (fpga_hw_rev >= 4) {
  119. for (i = 0; i < 4; i++) {
  120. struct udevice *rxaui;
  121. char name[8];
  122. snprintf(name, sizeof(name), "rxaui%d", i);
  123. /* Disable RXAUI polarity inversion */
  124. ret = uclass_get_device_by_phandle(UCLASS_MISC, board, name, &rxaui);
  125. if (!ret)
  126. misc_set_enabled(rxaui, false);
  127. }
  128. }
  129. for (uclass_first_device(UCLASS_VIDEO_OSD, &osd);
  130. osd;
  131. uclass_next_device(&osd)) {
  132. video_osd_get_info(osd, &osd_info);
  133. display_osd_info(osd, &osd_info);
  134. }
  135. return 0;
  136. }
  137. #if defined(CONFIG_OF_BOARD_SETUP)
  138. int ft_board_setup(void *blob, struct bd_info *bd)
  139. {
  140. ft_cpu_setup(blob, bd);
  141. fsl_fdt_fixup_dr_usb(blob, bd);
  142. fdt_fixup_esdhc(blob, bd);
  143. return 0;
  144. }
  145. #endif