jse.c 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. * Copyright (c) 2004 Picture Elements, Inc.
  3. * Stephen Williams (steve@icarus.com)
  4. *
  5. * This source code is free software; you can redistribute it
  6. * and/or modify it in source code form under the terms of the GNU
  7. * General Public License as published by the Free Software
  8. * Foundation; either version 2 of the License, or (at your option)
  9. * any later version.
  10. *
  11. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program; if not, write to the Free Software
  18. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
  19. */
  20. # include <common.h>
  21. # include <ppc4xx.h>
  22. # include <asm/processor.h>
  23. # include <asm/io.h>
  24. # include "jse_priv.h"
  25. /*
  26. * This function is run very early, out of flash, and before devices are
  27. * initialized. It is called by lib_ppc/board.c:board_init_f by virtue
  28. * of being in the init_sequence array.
  29. *
  30. * The SDRAM has been initialized already -- start.S:start called
  31. * init.S:init_sdram early on -- but it is not yet being used for
  32. * anything, not even stack. So be careful.
  33. */
  34. int board_early_init_f (void)
  35. {
  36. /*-------------------------------------------------------------------------+
  37. | Interrupt controller setup for the JSE board.
  38. | Note: IRQ 0-15 405GP internally generated; active high; level sensitive
  39. | IRQ 16 405GP internally generated; active low; level sensitive
  40. | IRQ 17-24 RESERVED/UNUSED
  41. | IRQ 25 (EXT IRQ 0) PCI SLOT 0; active low; level sensitive
  42. | IRQ 26 (EXT IRQ 1) PCI SLOT 1; active low; level sensitive
  43. | IRQ 27 (EXT IRQ 2) JP2C CHIP ; active low; level sensitive
  44. | IRQ 28 (EXT IRQ 3) PCI bridge; active low; level sensitive
  45. | IRQ 29 (EXT IRQ 4) SystemACE IRQ; active high
  46. | IRQ 30 (EXT IRQ 5) SystemACE BRdy (unused)
  47. | IRQ 31 (EXT IRQ 6) (unused)
  48. +-------------------------------------------------------------------------*/
  49. mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */
  50. mtdcr (uicer, 0x00000000); /* disable all ints */
  51. mtdcr (uiccr, 0x00000000); /* set all to be non-critical */
  52. mtdcr (uicpr, 0xFFFFFF87); /* set int polarities */
  53. mtdcr (uictr, 0x10000000); /* set int trigger levels */
  54. mtdcr (uicsr, 0xFFFFFFFF); /* clear all ints */
  55. /* Configure the interface to the SystemACE MCU port.
  56. The SystemACE is fast, but there is no reason to have
  57. excessivly tight timings. So the settings are slightly
  58. generous. */
  59. /* EBC0_B1AP: BME=1, TWT=2, CSN=0, OEN=1,
  60. WBN=0, WBF=1, TH=0, RE=0, SOR=0, BEM=0, PEN=0 */
  61. mtdcr (ebccfga, pb1ap);
  62. mtdcr (ebccfgd, 0x01011000);
  63. /* EBC0_B1CR: BAS=x, BS=0(1MB), BU=3(R/W), BW=0(8bits) */
  64. mtdcr (ebccfga, pb1cr);
  65. mtdcr (ebccfgd, CONFIG_SYS_SYSTEMACE_BASE | 0x00018000);
  66. /* Enable the /PerWE output as /PerWE, instead of /PCIINT. */
  67. /* CPC0_CR1 |= PCIPW */
  68. mtdcr (0xb2, mfdcr (0xb2) | 0x00004000);
  69. return 0;
  70. }
  71. #ifdef CONFIG_BOARD_PRE_INIT
  72. int board_pre_init (void)
  73. {
  74. return board_early_init_f ();
  75. }
  76. #endif
  77. /*
  78. * This function is also called by lib_ppc/board.c:board_init_f (it is
  79. * also in the init_sequence array) but later. Many more things are
  80. * configured, but we are still running from flash.
  81. */
  82. int checkboard (void)
  83. {
  84. unsigned vers, status;
  85. /* check that the SystemACE chip is alive. */
  86. printf ("ACE: ");
  87. vers = readw (CONFIG_SYS_SYSTEMACE_BASE + 0x16);
  88. printf ("SystemACE %u.%u (build %u)",
  89. (vers >> 12) & 0x0f, (vers >> 8) & 0x0f, vers & 0xff);
  90. status = readl (CONFIG_SYS_SYSTEMACE_BASE + 0x04);
  91. #ifdef DEBUG
  92. printf (" STATUS=0x%08x", status);
  93. #endif
  94. /* If the flash card is present and there is an initial error,
  95. then force a restart of the program. */
  96. if (status & 0x00000010) {
  97. printf (" CFDETECT");
  98. if (status & 0x04) {
  99. /* CONTROLREG = CFGPROG */
  100. writew (0x1000, CONFIG_SYS_SYSTEMACE_BASE + 0x18);
  101. udelay (500);
  102. /* CONTROLREG = CFGRESET */
  103. writew (0x0080, CONFIG_SYS_SYSTEMACE_BASE + 0x18);
  104. udelay (500);
  105. writew (0x0000, CONFIG_SYS_SYSTEMACE_BASE + 0x18);
  106. /* CONTROLREG = CFGSTART */
  107. writew (0x0020, CONFIG_SYS_SYSTEMACE_BASE + 0x18);
  108. status = readl (CONFIG_SYS_SYSTEMACE_BASE + 0x04);
  109. }
  110. }
  111. /* Wait for the SystemACE to program its chain of devices. */
  112. while ((status & 0x84) == 0x00) {
  113. udelay (500);
  114. status = readl (CONFIG_SYS_SYSTEMACE_BASE + 0x04);
  115. }
  116. if (status & 0x04)
  117. printf (" CFG-ERROR");
  118. if (status & 0x80)
  119. printf (" CFGDONE");
  120. printf ("\n");
  121. /* Force /RTS to active. The board it not wired quite
  122. correctly to use cts/rtc flow control, so just force the
  123. /RST active and forget about it. */
  124. writeb (readb (0xef600404) | 0x03, 0xef600404);
  125. printf ("JSE: ready\n");
  126. return 0;
  127. }
  128. /* **** No more functions called by board_init_f. **** */
  129. /*
  130. * This function is called by lib_ppc/board.c:board_init_r. At this
  131. * point, basic setup is done, U-Boot has been moved into SDRAM and
  132. * PCI has been set up. From here we done late setup.
  133. */
  134. int misc_init_r (void)
  135. {
  136. host_bridge_init ();
  137. return 0;
  138. }