pcippc2.c 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  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. void do_reset (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
  60. {
  61. out32 (REG (CPC0, SPOR), 0);
  62. iobarrier_rw ();
  63. while (1);
  64. }
  65. int board_pre_init (void)
  66. {
  67. out32 (REG (CPC0, RSTR), 0xC0000000);
  68. iobarrier_rw ();
  69. out32 (REG (CPC0, RSTR), 0xF0000000);
  70. iobarrier_rw ();
  71. out32 (REG (CPC0, UCTL), 0x00F80000);
  72. out32 (REG (CPC0, SIOC0), 0x30000000);
  73. out32 (REG (CPC0, ABCNTL), 0x00000000);
  74. out32 (REG (CPC0, SESR), 0x00000000);
  75. out32 (REG (CPC0, SEAR), 0x00000000);
  76. /* Detect IBM Avignon CPC710 Revision */
  77. if ((in32 (REG (CPC0, UCTL)) & 0x000000F0) == CPC710_TYPE_100P)
  78. out32 (REG (CPC0, PGCHP), 0xA0000040);
  79. else
  80. out32 (REG (CPC0, PGCHP), 0x80800040);
  81. out32 (REG (CPC0, ATAS), 0x709C2508);
  82. iobarrier_rw ();
  83. return 0;
  84. }
  85. void after_reloc (ulong dest_addr)
  86. {
  87. DECLARE_GLOBAL_DATA_PTR;
  88. /* Jump to the main U-Boot board init code
  89. */
  90. board_init_r (gd, dest_addr);
  91. }
  92. int misc_init_r (void)
  93. {
  94. pcippc2_fpga_init ();
  95. pcippc2_cpci3264_init ();
  96. #if defined(CONFIG_WATCHDOG)
  97. pcippc2_wdt_init ();
  98. #endif
  99. fpga_serial_init (sconsole_get_baudrate ());
  100. sconsole_putc = fpga_serial_putc;
  101. sconsole_puts = fpga_serial_puts;
  102. sconsole_getc = fpga_serial_getc;
  103. sconsole_tstc = fpga_serial_tstc;
  104. sconsole_setbrg = fpga_serial_setbrg;
  105. sconsole_flush ();
  106. return (0);
  107. }
  108. void pci_init (void)
  109. {
  110. cpc710_pci_init ();
  111. /* FPGA requires no retry timeouts to be enabled
  112. */
  113. cpc710_pci_enable_timeout ();
  114. }
  115. void doc_init (void)
  116. {
  117. doc_probe (pcippc2_fpga1_phys + HW_FPGA1_DOC);
  118. }
  119. void pcippc2_cpci3264_init (void)
  120. {
  121. pci_dev_t bdf = pci_find_device(FPGA_VENDOR_ID, FPGA_DEVICE_ID, 0);
  122. if (bdf == -1)
  123. {
  124. puts("Unable to find FPGA !\n");
  125. hang();
  126. }
  127. if((in32(pcippc2_fpga0_phys + HW_FPGA0_BOARD) & 0x01000000) == 0x01000000)
  128. /* 32-bits Compact PCI bus - LSB bit */
  129. {
  130. iobarrier_rw();
  131. out32(BRIDGE(CPCI, PCIDG), 0x40000000); /* 32-bits bridge, Pipeline */
  132. iobarrier_rw();
  133. }
  134. }
  135. #if defined(CONFIG_WATCHDOG)
  136. void pcippc2_wdt_init (void)
  137. {
  138. out16r (FPGA (WDT, PROG), 0xffff);
  139. out8 (FPGA (WDT, CTRL), 0x1);
  140. pcippc2_wdt_init_done = 1;
  141. }
  142. void pcippc2_wdt_done (void)
  143. {
  144. out8 (FPGA (WDT, CTRL), 0x0);
  145. pcippc2_wdt_init_done = 0;
  146. }
  147. void pcippc2_wdt_reset (void)
  148. {
  149. if (pcippc2_wdt_init_done == 1)
  150. out8 (FPGA (WDT, REFRESH), 0x56);
  151. }
  152. void watchdog_reset (void)
  153. {
  154. int re_enable = disable_interrupts ();
  155. pcippc2_wdt_reset ();
  156. if (re_enable)
  157. enable_interrupts ();
  158. }
  159. #if (CONFIG_COMMANDS & CFG_CMD_BSP)
  160. int do_wd (cmd_tbl_t *cmdtp, bd_t *bd, int flag, int argc, char *argv[])
  161. {
  162. switch (argc) {
  163. case 1:
  164. printf ("Watchdog timer status is %s\n",
  165. pcippc2_wdt_init_done == 1 ? "on" : "off");
  166. return 0;
  167. case 2:
  168. if (!strcmp(argv[1],"on")) {
  169. pcippc2_wdt_init();
  170. printf("Watchdog timer now is on\n");
  171. return 0;
  172. } else if (!strcmp(argv[1],"off")) {
  173. pcippc2_wdt_done();
  174. printf("Watchdog timer now is off\n");
  175. return 0;
  176. } else
  177. break;
  178. default:
  179. break;
  180. }
  181. printf ("Usage:\n%s\n", cmdtp->usage);
  182. return 1;
  183. }
  184. #endif /* CFG_CMD_BSP */
  185. #endif /* CONFIG_WATCHDOG */