pcippc2.c 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. /*
  2. * (C) Copyright 2002
  3. * Wolfgang Denk, DENX Software Engineering, wd@denx.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 <config.h>
  24. #include <common.h>
  25. #include <command.h>
  26. #include <asm/io.h>
  27. #include <linux/mtd/doc2000.h>
  28. #include <watchdog.h>
  29. #include <pci.h>
  30. #include <netdev.h>
  31. #include "hardware.h"
  32. #include "pcippc2.h"
  33. #include "sconsole.h"
  34. #include "fpga_serial.h"
  35. DECLARE_GLOBAL_DATA_PTR;
  36. #if defined(CONFIG_WATCHDOG)
  37. static int pcippc2_wdt_init_done = 0;
  38. void pcippc2_wdt_init (void);
  39. #endif
  40. /* Check board identity
  41. */
  42. int checkboard (void)
  43. {
  44. #ifdef CONFIG_PCIPPC2
  45. puts ("Board: Gespac PCIPPC-2\n");
  46. #else
  47. puts ("Board: Gespac PCIPPC-6\n");
  48. #endif
  49. return 0;
  50. }
  51. /* RAM size is stored in CPC0_RGBAN1
  52. */
  53. u32 pcippc2_sdram_size (void)
  54. {
  55. return in32 (REG (CPC0, RGBAN1));
  56. }
  57. phys_size_t initdram (int board_type)
  58. {
  59. return cpc710_ram_init ();
  60. }
  61. int do_reset (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  62. {
  63. out32 (REG (CPC0, SPOR), 0);
  64. iobarrier_rw ();
  65. while (1);
  66. /* notreached */
  67. return (-1);
  68. }
  69. int board_early_init_f (void)
  70. {
  71. out32 (REG (CPC0, RSTR), 0xC0000000);
  72. iobarrier_rw ();
  73. out32 (REG (CPC0, RSTR), 0xF0000000);
  74. iobarrier_rw ();
  75. out32 (REG (CPC0, UCTL), 0x00F80000);
  76. out32 (REG (CPC0, SIOC0), 0x30000000);
  77. out32 (REG (CPC0, ABCNTL), 0x00000000);
  78. out32 (REG (CPC0, SESR), 0x00000000);
  79. out32 (REG (CPC0, SEAR), 0x00000000);
  80. /* Detect IBM Avignon CPC710 Revision */
  81. if ((in32 (REG (CPC0, UCTL)) & 0x000000F0) == CPC710_TYPE_100P)
  82. out32 (REG (CPC0, PGCHP), 0xA0000040);
  83. else
  84. out32 (REG (CPC0, PGCHP), 0x80800040);
  85. out32 (REG (CPC0, ATAS), 0x709C2508);
  86. iobarrier_rw ();
  87. return 0;
  88. }
  89. void after_reloc (ulong dest_addr)
  90. {
  91. /* Jump to the main U-Boot board init code
  92. */
  93. board_init_r ((gd_t *)gd, dest_addr);
  94. }
  95. int misc_init_r (void)
  96. {
  97. pcippc2_fpga_init ();
  98. pcippc2_cpci3264_init ();
  99. #if defined(CONFIG_WATCHDOG)
  100. pcippc2_wdt_init ();
  101. #endif
  102. fpga_serial_init (sconsole_get_baudrate ());
  103. sconsole_putc = fpga_serial_putc;
  104. sconsole_puts = fpga_serial_puts;
  105. sconsole_getc = fpga_serial_getc;
  106. sconsole_tstc = fpga_serial_tstc;
  107. sconsole_setbrg = fpga_serial_setbrg;
  108. sconsole_flush ();
  109. return (0);
  110. }
  111. void pci_init_board (void)
  112. {
  113. cpc710_pci_init ();
  114. /* FPGA requires no retry timeouts to be enabled
  115. */
  116. cpc710_pci_enable_timeout ();
  117. }
  118. void doc_init (void)
  119. {
  120. doc_probe (pcippc2_fpga1_phys + HW_FPGA1_DOC);
  121. }
  122. void pcippc2_cpci3264_init (void)
  123. {
  124. pci_dev_t bdf = pci_find_device(FPGA_VENDOR_ID, FPGA_DEVICE_ID, 0);
  125. if (bdf == -1)
  126. {
  127. puts("Unable to find FPGA !\n");
  128. hang();
  129. }
  130. if((in32(pcippc2_fpga0_phys + HW_FPGA0_BOARD) & 0x01000000) == 0x01000000)
  131. /* 32-bits Compact PCI bus - LSB bit */
  132. {
  133. iobarrier_rw();
  134. out32(BRIDGE(CPCI, PCIDG), 0x40000000); /* 32-bits bridge, Pipeline */
  135. iobarrier_rw();
  136. }
  137. }
  138. #if defined(CONFIG_WATCHDOG)
  139. void pcippc2_wdt_init (void)
  140. {
  141. out16r (FPGA (WDT, PROG), 0xffff);
  142. out8 (FPGA (WDT, CTRL), 0x1);
  143. pcippc2_wdt_init_done = 1;
  144. }
  145. void pcippc2_wdt_done (void)
  146. {
  147. out8 (FPGA (WDT, CTRL), 0x0);
  148. pcippc2_wdt_init_done = 0;
  149. }
  150. void pcippc2_wdt_reset (void)
  151. {
  152. if (pcippc2_wdt_init_done == 1)
  153. out8 (FPGA (WDT, REFRESH), 0x56);
  154. }
  155. void watchdog_reset (void)
  156. {
  157. int re_enable = disable_interrupts ();
  158. pcippc2_wdt_reset ();
  159. if (re_enable)
  160. enable_interrupts ();
  161. }
  162. #if defined(CONFIG_CMD_BSP)
  163. int do_wd (cmd_tbl_t *cmdtp, int flag, int argc, char *argv[])
  164. {
  165. switch (argc) {
  166. case 1:
  167. printf ("Watchdog timer status is %s\n",
  168. pcippc2_wdt_init_done == 1 ? "on" : "off");
  169. return 0;
  170. case 2:
  171. if (!strcmp(argv[1],"on")) {
  172. pcippc2_wdt_init();
  173. printf("Watchdog timer now is on\n");
  174. return 0;
  175. } else if (!strcmp(argv[1],"off")) {
  176. pcippc2_wdt_done();
  177. printf("Watchdog timer now is off\n");
  178. return 0;
  179. } else
  180. break;
  181. default:
  182. break;
  183. }
  184. cmd_usage(cmdtp);
  185. return 1;
  186. }
  187. U_BOOT_CMD(
  188. wd, 2, 1, do_wd,
  189. "wd - check and set watchdog\n",
  190. "on - switch watchDog on\n"
  191. "wd off - switch watchdog off\n"
  192. "wd - print current status\n"
  193. );
  194. #endif
  195. #endif /* CONFIG_WATCHDOG */
  196. int board_eth_init(bd_t *bis)
  197. {
  198. return pci_eth_init(bis);
  199. }