dlvision-10g.c 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. /*
  2. * (C) Copyright 2010
  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 <asm/processor.h>
  10. #include <asm/io.h>
  11. #include <asm/ppc4xx-gpio.h>
  12. #include <dtt.h>
  13. #include "405ep.h"
  14. #include <gdsys_fpga.h>
  15. #include "../common/osd.h"
  16. #define LATCH0_BASE (CONFIG_SYS_LATCH_BASE)
  17. #define LATCH1_BASE (CONFIG_SYS_LATCH_BASE + 0x100)
  18. #define LATCH2_BASE (CONFIG_SYS_LATCH_BASE + 0x200)
  19. #define LATCH3_BASE (CONFIG_SYS_LATCH_BASE + 0x300)
  20. #define LATCH2_MC2_PRESENT_N 0x0080
  21. enum {
  22. UNITTYPE_MAIN = 1<<0,
  23. UNITTYPE_SERVER = 1<<1,
  24. UNITTYPE_DISPLAYPORT = 1<<2,
  25. };
  26. enum {
  27. HWVER_101 = 0,
  28. HWVER_110 = 1,
  29. HWVER_130 = 2,
  30. HWVER_140 = 3,
  31. HWVER_150 = 4,
  32. HWVER_160 = 5,
  33. HWVER_170 = 6,
  34. };
  35. enum {
  36. AUDIO_NONE = 0,
  37. AUDIO_TX = 1,
  38. AUDIO_RX = 2,
  39. AUDIO_RXTX = 3,
  40. };
  41. enum {
  42. SYSCLK_156250 = 2,
  43. };
  44. enum {
  45. RAM_NONE = 0,
  46. RAM_DDR2_32 = 1,
  47. RAM_DDR2_64 = 2,
  48. };
  49. struct ihs_fpga *fpga_ptr[] = CONFIG_SYS_FPGA_PTR;
  50. int misc_init_r(void)
  51. {
  52. /* startup fans */
  53. dtt_init();
  54. return 0;
  55. }
  56. static unsigned int get_hwver(void)
  57. {
  58. u16 latch3 = in_le16((void *)LATCH3_BASE);
  59. return latch3 & 0x0003;
  60. }
  61. static unsigned int get_mc2_present(void)
  62. {
  63. u16 latch2 = in_le16((void *)LATCH2_BASE);
  64. return !(latch2 & LATCH2_MC2_PRESENT_N);
  65. }
  66. static void print_fpga_info(unsigned dev)
  67. {
  68. u16 versions;
  69. u16 fpga_version;
  70. u16 fpga_features;
  71. unsigned unit_type;
  72. unsigned hardware_version;
  73. unsigned feature_rs232;
  74. unsigned feature_audio;
  75. unsigned feature_sysclock;
  76. unsigned feature_ramconfig;
  77. unsigned feature_carrier_speed;
  78. unsigned feature_carriers;
  79. unsigned feature_video_channels;
  80. int fpga_state = get_fpga_state(dev);
  81. printf("FPGA%d: ", dev);
  82. FPGA_GET_REG(dev, versions, &versions);
  83. FPGA_GET_REG(dev, fpga_version, &fpga_version);
  84. FPGA_GET_REG(dev, fpga_features, &fpga_features);
  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. if (fpga_state & FPGA_STATE_DONE_FAILED)
  91. puts(" Waiting for FPGA-DONE timed out.\n");
  92. if (fpga_state & FPGA_STATE_REFLECTION_FAILED)
  93. puts(" FPGA reflection test failed.\n");
  94. return;
  95. }
  96. unit_type = (versions >> 4) & 0x000f;
  97. hardware_version = versions & 0x000f;
  98. feature_rs232 = fpga_features & (1<<11);
  99. feature_audio = (fpga_features >> 9) & 0x0003;
  100. feature_sysclock = (fpga_features >> 7) & 0x0003;
  101. feature_ramconfig = (fpga_features >> 5) & 0x0003;
  102. feature_carrier_speed = fpga_features & (1<<4);
  103. feature_carriers = (fpga_features >> 2) & 0x0003;
  104. feature_video_channels = fpga_features & 0x0003;
  105. if (unit_type & UNITTYPE_MAIN)
  106. printf("Mainchannel ");
  107. else
  108. printf("Videochannel ");
  109. if (unit_type & UNITTYPE_SERVER)
  110. printf("Serverside ");
  111. else
  112. printf("Userside ");
  113. if (unit_type & UNITTYPE_DISPLAYPORT)
  114. printf("DisplayPort");
  115. else
  116. printf("DVI-DL");
  117. switch (hardware_version) {
  118. case HWVER_101:
  119. printf(" HW-Ver 1.01\n");
  120. break;
  121. case HWVER_110:
  122. printf(" HW-Ver 1.10-1.20\n");
  123. break;
  124. case HWVER_130:
  125. printf(" HW-Ver 1.30\n");
  126. break;
  127. case HWVER_140:
  128. printf(" HW-Ver 1.40-1.43\n");
  129. break;
  130. case HWVER_150:
  131. printf(" HW-Ver 1.50\n");
  132. break;
  133. case HWVER_160:
  134. printf(" HW-Ver 1.60-1.61\n");
  135. break;
  136. case HWVER_170:
  137. printf(" HW-Ver 1.70\n");
  138. break;
  139. default:
  140. printf(" HW-Ver %d(not supported)\n",
  141. hardware_version);
  142. break;
  143. }
  144. printf(" FPGA V %d.%02d, features:",
  145. fpga_version / 100, fpga_version % 100);
  146. printf(" %sRS232", feature_rs232 ? "" : "no ");
  147. switch (feature_audio) {
  148. case AUDIO_NONE:
  149. printf(", no audio");
  150. break;
  151. case AUDIO_TX:
  152. printf(", audio tx");
  153. break;
  154. case AUDIO_RX:
  155. printf(", audio rx");
  156. break;
  157. case AUDIO_RXTX:
  158. printf(", audio rx+tx");
  159. break;
  160. default:
  161. printf(", audio %d(not supported)", feature_audio);
  162. break;
  163. }
  164. switch (feature_sysclock) {
  165. case SYSCLK_156250:
  166. printf(", clock 156.25 MHz");
  167. break;
  168. default:
  169. printf(", clock %d(not supported)", feature_sysclock);
  170. break;
  171. }
  172. puts(",\n ");
  173. switch (feature_ramconfig) {
  174. case RAM_NONE:
  175. printf("no RAM");
  176. break;
  177. case RAM_DDR2_32:
  178. printf("RAM 32 bit DDR2");
  179. break;
  180. case RAM_DDR2_64:
  181. printf("RAM 64 bit DDR2");
  182. break;
  183. default:
  184. printf("RAM %d(not supported)", feature_ramconfig);
  185. break;
  186. }
  187. printf(", %d carrier(s) %s", feature_carriers,
  188. feature_carrier_speed ? "10 Gbit/s" : "of unknown speed");
  189. printf(", %d video channel(s)\n", feature_video_channels);
  190. }
  191. /*
  192. * Check Board Identity:
  193. */
  194. int checkboard(void)
  195. {
  196. char *s = getenv("serial#");
  197. puts("Board: ");
  198. puts("DLVision 10G");
  199. if (s != NULL) {
  200. puts(", serial# ");
  201. puts(s);
  202. }
  203. puts("\n");
  204. return 0;
  205. }
  206. int last_stage_init(void)
  207. {
  208. u16 versions;
  209. FPGA_GET_REG(0, versions, &versions);
  210. print_fpga_info(0);
  211. if (get_mc2_present())
  212. print_fpga_info(1);
  213. if (((versions >> 4) & 0x000f) & UNITTYPE_SERVER)
  214. return 0;
  215. if (!get_fpga_state(0) || (get_hwver() == HWVER_101))
  216. osd_probe(0);
  217. if (get_mc2_present() &&
  218. (!get_fpga_state(1) || (get_hwver() == HWVER_101)))
  219. osd_probe(1);
  220. return 0;
  221. }
  222. void gd405ep_init(void)
  223. {
  224. }
  225. void gd405ep_set_fpga_reset(unsigned state)
  226. {
  227. if (state) {
  228. out_le16((void *)LATCH0_BASE, CONFIG_SYS_LATCH0_RESET);
  229. out_le16((void *)LATCH1_BASE, CONFIG_SYS_LATCH1_RESET);
  230. } else {
  231. out_le16((void *)LATCH0_BASE, CONFIG_SYS_LATCH0_BOOT);
  232. out_le16((void *)LATCH1_BASE, CONFIG_SYS_LATCH1_BOOT);
  233. }
  234. }
  235. void gd405ep_setup_hw(void)
  236. {
  237. /*
  238. * set "startup-finished"-gpios
  239. */
  240. gpio_write_bit(21, 0);
  241. gpio_write_bit(22, 1);
  242. }
  243. int gd405ep_get_fpga_done(unsigned fpga)
  244. {
  245. return in_le16((void *)LATCH2_BASE) & CONFIG_SYS_FPGA_DONE(fpga);
  246. }