iocon.c 5.3 KB

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