iocon.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  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 "../common/fpga.h"
  29. #include "../common/osd.h"
  30. enum {
  31. REG_VERSIONS = 0x0002,
  32. REG_FPGA_VERSION = 0x0004,
  33. REG_FPGA_FEATURES = 0x0006,
  34. };
  35. enum {
  36. UNITTYPE_MAIN_SERVER = 0,
  37. UNITTYPE_MAIN_USER = 1,
  38. UNITTYPE_VIDEO_SERVER = 2,
  39. UNITTYPE_VIDEO_USER = 3,
  40. };
  41. enum {
  42. HWVER_100 = 0,
  43. HWVER_104 = 1,
  44. HWVER_110 = 2,
  45. };
  46. enum {
  47. COMPRESSION_NONE = 0,
  48. COMPRESSION_TYPE1_DELTA,
  49. };
  50. enum {
  51. AUDIO_NONE = 0,
  52. AUDIO_TX = 1,
  53. AUDIO_RX = 2,
  54. AUDIO_RXTX = 3,
  55. };
  56. enum {
  57. SYSCLK_147456 = 0,
  58. };
  59. enum {
  60. RAM_DDR2_32 = 0,
  61. };
  62. /*
  63. * Check Board Identity:
  64. */
  65. int checkboard(void)
  66. {
  67. char *s = getenv("serial#");
  68. u16 versions = fpga_get_reg(REG_VERSIONS);
  69. u16 fpga_version = fpga_get_reg(REG_FPGA_VERSION);
  70. u16 fpga_features = fpga_get_reg(REG_FPGA_FEATURES);
  71. unsigned unit_type;
  72. unsigned hardware_version;
  73. unsigned feature_compression;
  74. unsigned feature_osd;
  75. unsigned feature_audio;
  76. unsigned feature_sysclock;
  77. unsigned feature_ramconfig;
  78. unsigned feature_carriers;
  79. unsigned feature_video_channels;
  80. unit_type = (versions & 0xf000) >> 12;
  81. hardware_version = versions & 0x000f;
  82. feature_compression = (fpga_features & 0xe000) >> 13;
  83. feature_osd = fpga_features & (1<<11);
  84. feature_audio = (fpga_features & 0x0600) >> 9;
  85. feature_sysclock = (fpga_features & 0x0180) >> 7;
  86. feature_ramconfig = (fpga_features & 0x0060) >> 5;
  87. feature_carriers = (fpga_features & 0x000c) >> 2;
  88. feature_video_channels = fpga_features & 0x0003;
  89. printf("Board: ");
  90. printf("IoCon");
  91. if (s != NULL) {
  92. puts(", serial# ");
  93. puts(s);
  94. }
  95. puts("\n ");
  96. switch (unit_type) {
  97. case UNITTYPE_MAIN_USER:
  98. printf("Mainchannel");
  99. break;
  100. case UNITTYPE_VIDEO_USER:
  101. printf("Videochannel");
  102. break;
  103. default:
  104. printf("UnitType %d(not supported)", unit_type);
  105. break;
  106. }
  107. switch (hardware_version) {
  108. case HWVER_100:
  109. printf(" HW-Ver 1.00\n");
  110. break;
  111. case HWVER_104:
  112. printf(" HW-Ver 1.04\n");
  113. break;
  114. case HWVER_110:
  115. printf(" HW-Ver 1.10\n");
  116. break;
  117. default:
  118. printf(" HW-Ver %d(not supported)\n",
  119. hardware_version);
  120. break;
  121. }
  122. printf(" FPGA V %d.%02d, features:",
  123. fpga_version / 100, fpga_version % 100);
  124. switch (feature_compression) {
  125. case COMPRESSION_NONE:
  126. printf(" no compression");
  127. break;
  128. case COMPRESSION_TYPE1_DELTA:
  129. printf(" type1-deltacompression");
  130. break;
  131. default:
  132. printf(" compression %d(not supported)", feature_compression);
  133. break;
  134. }
  135. printf(", %sosd", feature_osd ? "" : "no ");
  136. switch (feature_audio) {
  137. case AUDIO_NONE:
  138. printf(", no audio");
  139. break;
  140. case AUDIO_TX:
  141. printf(", audio tx");
  142. break;
  143. case AUDIO_RX:
  144. printf(", audio rx");
  145. break;
  146. case AUDIO_RXTX:
  147. printf(", audio rx+tx");
  148. break;
  149. default:
  150. printf(", audio %d(not supported)", feature_audio);
  151. break;
  152. }
  153. puts(",\n ");
  154. switch (feature_sysclock) {
  155. case SYSCLK_147456:
  156. printf("clock 147.456 MHz");
  157. break;
  158. default:
  159. printf("clock %d(not supported)", feature_sysclock);
  160. break;
  161. }
  162. switch (feature_ramconfig) {
  163. case RAM_DDR2_32:
  164. printf(", RAM 32 bit DDR2");
  165. break;
  166. default:
  167. printf(", RAM %d(not supported)", feature_ramconfig);
  168. break;
  169. }
  170. printf(", %d carrier(s)", feature_carriers);
  171. printf(", %d video channel(s)\n", feature_video_channels);
  172. return 0;
  173. }
  174. int last_stage_init(void)
  175. {
  176. return osd_probe();
  177. }
  178. /*
  179. * provide access to fpga gpios (for I2C bitbang)
  180. */
  181. void fpga_gpio_set(int pin)
  182. {
  183. out_le16((void *)(CONFIG_SYS_FPGA_BASE + 0x18), pin);
  184. }
  185. void fpga_gpio_clear(int pin)
  186. {
  187. out_le16((void *)(CONFIG_SYS_FPGA_BASE + 0x16), pin);
  188. }
  189. int fpga_gpio_get(int pin)
  190. {
  191. return in_le16((void *)(CONFIG_SYS_FPGA_BASE + 0x14)) & pin;
  192. }