gazerbeam.c 4.0 KB

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