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