dlvision-10g.c 6.1 KB

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