jse.c 4.5 KB

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