pcippc2.c 4.8 KB

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