3 * Stefan Roese, DENX Software Engineering, sr@denx.de.
5 * Copyright (C) 2002 Scott McNutt <smcnutt@artesyncp.com>
7 * See file CREDITS for list of people who contributed to this
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License as
12 * published by the Free Software Foundation; either version 2 of
13 * the License, or (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
27 #include <asm/processor.h>
32 DECLARE_GLOBAL_DATA_PTR;
34 void set_led(int color)
38 out32(GPIO0_OR, in32(GPIO0_OR) & ~CFG_LED_GREEN & ~CFG_LED_RED);
42 out32(GPIO0_OR, (in32(GPIO0_OR) | CFG_LED_GREEN) & ~CFG_LED_RED);
46 out32(GPIO0_OR, (in32(GPIO0_OR) | CFG_LED_RED) & ~CFG_LED_GREEN);
50 out32(GPIO0_OR, in32(GPIO0_OR) | CFG_LED_GREEN | CFG_LED_RED);
55 static int is_monarch(void)
57 out32(GPIO0_OR, in32(GPIO0_OR) & ~CFG_GPIO_RDY);
60 if (in32(GPIO0_IR) & CFG_MONARCH_IO)
66 static void wait_for_pci_ready(void)
69 * Configure EREADY_IO as input
71 out32(GPIO0_TCR, in32(GPIO0_TCR) & ~CFG_EREADY_IO);
75 if (in32(GPIO0_IR) & CFG_EREADY_IO)
81 int board_early_init_f(void)
85 /*--------------------------------------------------------------------
86 * Setup the external bus controller/chip selects
87 *-------------------------------------------------------------------*/
88 mtdcr(ebccfga, xbcfg);
90 mtdcr(ebccfgd, reg | 0x04000000); /* Set ATC */
92 /*--------------------------------------------------------------------
93 * Setup pin multiplexing (GPIO/IRQ...)
94 *-------------------------------------------------------------------*/
95 mtdcr(cpc0_gpio, 0x03F01F80);
97 out32(GPIO0_ODR, 0x00000000); /* no open drain pins */
98 out32(GPIO0_TCR, CFG_GPIO_RDY | CFG_EREADY_IO | CFG_LED_RED | CFG_LED_GREEN);
99 out32(GPIO0_OR, CFG_GPIO_RDY);
101 /*--------------------------------------------------------------------
102 * Setup the interrupt controller polarities, triggers, etc.
103 *-------------------------------------------------------------------*/
104 mtdcr(uic0sr, 0xffffffff); /* clear all */
105 mtdcr(uic0er, 0x00000000); /* disable all */
106 mtdcr(uic0cr, 0x00000001); /* UIC1 crit is critical */
107 mtdcr(uic0pr, 0xfffffe13); /* per ref-board manual */
108 mtdcr(uic0tr, 0x01c00008); /* per ref-board manual */
109 mtdcr(uic0vr, 0x00000001); /* int31 highest, base=0x000 */
110 mtdcr(uic0sr, 0xffffffff); /* clear all */
112 mtdcr(uic1sr, 0xffffffff); /* clear all */
113 mtdcr(uic1er, 0x00000000); /* disable all */
114 mtdcr(uic1cr, 0x00000000); /* all non-critical */
115 mtdcr(uic1pr, 0xffffe0ff); /* per ref-board manual */
116 mtdcr(uic1tr, 0x00ffc000); /* per ref-board manual */
117 mtdcr(uic1vr, 0x00000001); /* int31 highest, base=0x000 */
118 mtdcr(uic1sr, 0xffffffff); /* clear all */
125 char *s = getenv("serial#");
127 printf("Board: P3P440");
136 puts(", None-Monarch");
144 int misc_init_r (void)
147 * Adjust flash start and offset to detected values
149 gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
150 gd->bd->bi_flashoffset = 0;
153 * Check if only one FLASH bank is available
155 if (gd->bd->bi_flashsize != CFG_MAX_FLASH_BANKS * (0 - CFG_FLASH0)) {
156 mtebc(pb1cr, 0); /* disable cs */
158 mtebc(pb2cr, 0); /* disable cs */
160 mtebc(pb3cr, 0); /* disable cs */
167 /*************************************************************************
170 * This routine is called just prior to registering the hose and gives
171 * the board the opportunity to check things. Returning a value of zero
172 * indicates that things are bad & PCI initialization should be aborted.
174 * Different boards may wish to customize the pci controller structure
175 * (add regions, override default access routines, etc) or perform
176 * certain pre-initialization actions.
178 ************************************************************************/
179 #if defined(CONFIG_PCI) && defined(CFG_PCI_PRE_INIT)
180 int pci_pre_init(struct pci_controller *hose)
184 /*--------------------------------------------------------------------------+
185 * The P3P440 board is always configured as the host & requires the
186 * PCI arbiter to be disabled because it's an PMC module.
187 *--------------------------------------------------------------------------*/
188 strap = mfdcr(cpc0_strp1);
189 if (strap & 0x00100000) {
190 printf("PCI: CPC0_STRP1[PAE] set.\n");
196 #endif /* defined(CONFIG_PCI) && defined(CFG_PCI_PRE_INIT) */
198 /*************************************************************************
201 * The bootstrap configuration provides default settings for the pci
202 * inbound map (PIM). But the bootstrap config choices are limited and
203 * may not be sufficient for a given board.
205 ************************************************************************/
206 #if defined(CONFIG_PCI) && defined(CFG_PCI_TARGET_INIT)
207 void pci_target_init(struct pci_controller *hose)
209 /*--------------------------------------------------------------------------+
211 *--------------------------------------------------------------------------*/
212 out32r(PCIX0_PIM0SA, 0); /* disable */
213 out32r(PCIX0_PIM1SA, 0); /* disable */
214 out32r(PCIX0_PIM2SA, 0); /* disable */
215 out32r(PCIX0_EROMBA, 0); /* disable expansion rom */
217 /*--------------------------------------------------------------------------+
218 * Map all of SDRAM to PCI address 0x0000_0000. Note that the 440 strapping
219 * options to not support sizes such as 128/256 MB.
220 *--------------------------------------------------------------------------*/
221 out32r(PCIX0_PIM0LAL, CFG_SDRAM_BASE);
222 out32r(PCIX0_PIM0LAH, 0);
223 out32r(PCIX0_PIM0SA, ~(gd->ram_size - 1) | 1);
225 out32r(PCIX0_BAR0, 0);
227 /*--------------------------------------------------------------------------+
228 * Program the board's subsystem id/vendor id
229 *--------------------------------------------------------------------------*/
230 out16r(PCIX0_SBSYSVID, CFG_PCI_SUBSYS_VENDORID);
231 out16r(PCIX0_SBSYSID, CFG_PCI_SUBSYS_DEVICEID);
233 out16r(PCIX0_CMD, in16r(PCIX0_CMD) | PCI_COMMAND_MEMORY);
235 #endif /* defined(CONFIG_PCI) && defined(CFG_PCI_TARGET_INIT) */
237 /*************************************************************************
240 * This routine is called to determine if a pci scan should be
241 * performed. With various hardware environments (especially cPCI and
242 * PPMC) it's insufficient to depend on the state of the arbiter enable
243 * bit in the strap register, or generic host/adapter assumptions.
245 * Rather than hard-code a bad assumption in the general 440 code, the
246 * 440 pci code requires the board to decide at runtime.
248 * Return 0 for adapter mode, non-zero for host (monarch) mode.
251 ************************************************************************/
252 #if defined(CONFIG_PCI)
253 int is_pci_host(struct pci_controller *hose)
256 wait_for_pci_ready();
257 return 1; /* return 1 for host controller */
259 return 0; /* return 0 for adapter controller */
262 #endif /* defined(CONFIG_PCI) */