gazerbeam.c 3.9 KB

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