dlvision-10g.c 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. /*
  2. * (C) Copyright 2010
  3. * Dirk Eibach, Guntermann & Drunck GmbH, eibach@gdsys.de
  4. *
  5. * See file CREDITS for list of people who contributed to this
  6. * project.
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License as
  10. * published by the Free Software Foundation; either version 2 of
  11. * the License, or (at your option) any later version.
  12. *
  13. * This program is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program; if not, write to the Free Software
  20. * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
  21. * MA 02111-1307 USA
  22. */
  23. #include <common.h>
  24. #include <command.h>
  25. #include <asm/processor.h>
  26. #include <asm/io.h>
  27. #include <asm/ppc4xx-gpio.h>
  28. #include <gdsys_fpga.h>
  29. #include "../common/osd.h"
  30. #define LATCH2_BASE (CONFIG_SYS_LATCH_BASE + 0x200)
  31. #define LATCH2_MC2_PRESENT_N 0x0080
  32. #define LATCH3_BASE (CONFIG_SYS_LATCH_BASE + 0x300)
  33. enum {
  34. UNITTYPE_VIDEO_USER = 0,
  35. UNITTYPE_MAIN_USER = 1,
  36. UNITTYPE_VIDEO_SERVER = 2,
  37. UNITTYPE_MAIN_SERVER = 3,
  38. };
  39. enum {
  40. HWVER_101 = 0,
  41. HWVER_110 = 1,
  42. };
  43. enum {
  44. AUDIO_NONE = 0,
  45. AUDIO_TX = 1,
  46. AUDIO_RX = 2,
  47. AUDIO_RXTX = 3,
  48. };
  49. enum {
  50. SYSCLK_156250 = 2,
  51. };
  52. enum {
  53. RAM_NONE = 0,
  54. RAM_DDR2_32 = 1,
  55. RAM_DDR2_64 = 2,
  56. };
  57. static unsigned int get_hwver(void)
  58. {
  59. u16 latch3 = in_le16((void *)LATCH3_BASE);
  60. return latch3 & 0x0003;
  61. }
  62. static unsigned int get_mc2_present(void)
  63. {
  64. u16 latch2 = in_le16((void *)LATCH2_BASE);
  65. return !(latch2 & LATCH2_MC2_PRESENT_N);
  66. }
  67. static void print_fpga_info(unsigned dev)
  68. {
  69. ihs_fpga_t *fpga = (ihs_fpga_t *) CONFIG_SYS_FPGA_BASE(dev);
  70. u16 versions = in_le16(&fpga->versions);
  71. u16 fpga_version = in_le16(&fpga->fpga_version);
  72. u16 fpga_features = in_le16(&fpga->fpga_features);
  73. unsigned unit_type;
  74. unsigned hardware_version;
  75. unsigned feature_compression;
  76. unsigned feature_rs232;
  77. unsigned feature_audio;
  78. unsigned feature_sysclock;
  79. unsigned feature_ramconfig;
  80. unsigned feature_carrier_speed;
  81. unsigned feature_carriers;
  82. unsigned feature_video_channels;
  83. int fpga_state = get_fpga_state(dev);
  84. printf("FPGA%d: ", dev);
  85. hardware_version = versions & 0x000f;
  86. if (fpga_state
  87. && !((hardware_version == HWVER_101)
  88. && (fpga_state == FPGA_STATE_DONE_FAILED))) {
  89. puts("not available\n");
  90. print_fpga_state(dev);
  91. return;
  92. }
  93. unit_type = (versions >> 4) & 0x000f;
  94. hardware_version = versions & 0x000f;
  95. feature_compression = (fpga_features >> 13) & 0x0003;
  96. feature_rs232 = fpga_features & (1<<11);
  97. feature_audio = (fpga_features >> 9) & 0x0003;
  98. feature_sysclock = (fpga_features >> 7) & 0x0003;
  99. feature_ramconfig = (fpga_features >> 5) & 0x0003;
  100. feature_carrier_speed = fpga_features & (1<<4);
  101. feature_carriers = (fpga_features >> 2) & 0x0003;
  102. feature_video_channels = fpga_features & 0x0003;
  103. switch (unit_type) {
  104. case UNITTYPE_VIDEO_USER:
  105. printf("Videochannel Userside");
  106. break;
  107. case UNITTYPE_MAIN_USER:
  108. printf("Mainchannel Userside");
  109. break;
  110. case UNITTYPE_VIDEO_SERVER:
  111. printf("Videochannel Serverside");
  112. break;
  113. case UNITTYPE_MAIN_SERVER:
  114. printf("Mainchannel Serverside");
  115. break;
  116. default:
  117. printf("UnitType %d(not supported)", unit_type);
  118. break;
  119. }
  120. switch (hardware_version) {
  121. case HWVER_101:
  122. printf(" HW-Ver 1.01\n");
  123. break;
  124. case HWVER_110:
  125. printf(" HW-Ver 1.10\n");
  126. break;
  127. default:
  128. printf(" HW-Ver %d(not supported)\n",
  129. hardware_version);
  130. break;
  131. }
  132. printf(" FPGA V %d.%02d, features:",
  133. fpga_version / 100, fpga_version % 100);
  134. printf(" %sRS232", feature_rs232 ? "" : "no ");
  135. switch (feature_audio) {
  136. case AUDIO_NONE:
  137. printf(", no audio");
  138. break;
  139. case AUDIO_TX:
  140. printf(", audio tx");
  141. break;
  142. case AUDIO_RX:
  143. printf(", audio rx");
  144. break;
  145. case AUDIO_RXTX:
  146. printf(", audio rx+tx");
  147. break;
  148. default:
  149. printf(", audio %d(not supported)", feature_audio);
  150. break;
  151. }
  152. switch (feature_sysclock) {
  153. case SYSCLK_156250:
  154. printf(", clock 156.25 MHz");
  155. break;
  156. default:
  157. printf(", clock %d(not supported)", feature_sysclock);
  158. break;
  159. }
  160. puts(",\n ");
  161. switch (feature_ramconfig) {
  162. case RAM_NONE:
  163. printf("no RAM");
  164. break;
  165. case RAM_DDR2_32:
  166. printf("RAM 32 bit DDR2");
  167. break;
  168. case RAM_DDR2_64:
  169. printf("RAM 64 bit DDR2");
  170. break;
  171. default:
  172. printf("RAM %d(not supported)", feature_ramconfig);
  173. break;
  174. }
  175. printf(", %d carrier(s) %s", feature_carriers,
  176. feature_carrier_speed ? "10 Gbit/s" : "of unknown speed");
  177. printf(", %d video channel(s)\n", feature_video_channels);
  178. }
  179. /*
  180. * Check Board Identity:
  181. */
  182. int checkboard(void)
  183. {
  184. char buf[64];
  185. int i = getenv_f("serial#", buf, sizeof(buf));
  186. printf("Board: ");
  187. printf("DLVision 10G");
  188. if (i > 0) {
  189. puts(", serial# ");
  190. puts(buf);
  191. }
  192. puts("\n");
  193. print_fpga_info(0);
  194. if (get_mc2_present())
  195. print_fpga_info(1);
  196. return 0;
  197. }
  198. int last_stage_init(void)
  199. {
  200. ihs_fpga_t *fpga = (ihs_fpga_t *) CONFIG_SYS_FPGA_BASE(0);
  201. u16 versions = in_le16(&fpga->versions);
  202. if (((versions >> 4) & 0x000f) != UNITTYPE_MAIN_USER)
  203. return 0;
  204. if (!get_fpga_state(0) || (get_hwver() == HWVER_101))
  205. osd_probe(0);
  206. if (get_mc2_present() &&
  207. (!get_fpga_state(1) || (get_hwver() == HWVER_101)))
  208. osd_probe(1);
  209. return 0;
  210. }