pcippc2.c 4.7 KB

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