dlvision-10g.c 6.0 KB

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