blob: 7c34c4445f3e867f2c30ae4aa03b66ebe480d9ed [file] [log] [blame]
Stefan Roese8a316c92005-08-01 16:49:12 +02001/*
Stefan Roesea471db02007-06-01 15:19:29 +02002 * (C) Copyright 2005-2007
Stefan Roese8a316c92005-08-01 16:49:12 +02003 * Stefan Roese, DENX Software Engineering, sr@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
Wolfgang Denkf901a832005-08-06 01:42:58 +020015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Stefan Roese8a316c92005-08-01 16:49:12 +020016 * 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
24#include <common.h>
25#include <asm/processor.h>
Stefan Roese0d974d52007-03-24 15:57:09 +010026#include <asm/gpio.h>
Stefan Roese8a316c92005-08-01 16:49:12 +020027#include <spd_sdram.h>
Stefan Roese17f50f222005-08-04 17:09:16 +020028#include <ppc440.h>
29#include "bamboo.h"
30
31void ext_bus_cntlr_init(void);
32void configure_ppc440ep_pins(void);
Stefan Roesec57c7982005-08-11 17:56:56 +020033int is_nand_selected(void);
Stefan Roese17f50f222005-08-04 17:09:16 +020034
Eugene OBriend2f68002007-07-31 10:24:56 +020035#if !(defined(CONFIG_NAND_U_BOOT) || defined(CONFIG_NAND_SPL))
36/*************************************************************************
37 *
38 * Bamboo has one bank onboard sdram (plus DIMM)
39 *
40 * Fixed memory is composed of :
41 * MT46V16M16TG-75 from Micron (x 2), 256Mb, 16 M x16, DDR266,
42 * 13 row add bits, 10 column add bits (but 12 row used only).
43 * ECC device: MT46V16M8TG-75 from Micron (x 1), 128Mb, x8, DDR266,
44 * 12 row add bits, 10 column add bits.
45 * Prepare a subset (only the used ones) of SPD data
46 *
47 * Note : if the ECC is enabled (SDRAM_ECC_ENABLE) the size of
48 * the corresponding bank is divided by 2 due to number of Row addresses
49 * 12 in the ECC module
50 *
51 * Assumes: 64 MB, ECC, non-registered
52 * PLB @ 133 MHz
53 *
54 ************************************************************************/
55const unsigned char cfg_simulate_spd_eeprom[128] = {
56 0x80, /* number of SPD bytes used: 128 */
57 0x08, /* total number bytes in SPD device = 256 */
58 0x07, /* DDR ram */
59#ifdef CONFIG_DDR_ECC
60 0x0C, /* num Row Addr: 12 */
61#else
62 0x0D, /* num Row Addr: 13 */
63#endif
64 0x09, /* numColAddr: 9 */
65 0x01, /* numBanks: 1 */
66 0x20, /* Module data width: 32 bits */
67 0x00, /* Module data width continued: +0 */
68 0x04, /* 2.5 Volt */
69 0x75, /* SDRAM Cycle Time (cas latency 2.5) = 7.5 ns */
Eugene O'Brien9f798762007-10-23 08:29:10 +020070 0x00, /* SDRAM Access from clock */
Eugene OBriend2f68002007-07-31 10:24:56 +020071#ifdef CONFIG_DDR_ECC
72 0x02, /* ECC ON : 02 OFF : 00 */
73#else
74 0x00, /* ECC ON : 02 OFF : 00 */
75#endif
Eugene O'Brien9f798762007-10-23 08:29:10 +020076 0x82, /* refresh Rate Type: Normal (7.8us) + Self refresh */
Eugene OBriend2f68002007-07-31 10:24:56 +020077 0,
78 0,
79 0x01, /* wcsbc = 1 */
80 0,
81 0,
82 0x0C, /* casBit (2,2.5) */
83 0,
84 0,
85 0x00, /* not registered: 0 registered : 0x02*/
86 0,
87 0xA0, /* SDRAM Cycle Time (cas latency 2) = 10 ns */
88 0,
89 0x00, /* SDRAM Cycle Time (cas latency 1.5) = N.A */
90 0,
91 0x50, /* tRpNs = 20 ns */
92 0,
93 0x50, /* tRcdNs = 20 ns */
94 45, /* tRasNs */
95#ifdef CONFIG_DDR_ECC
96 0x08, /* bankSizeID: 32MB */
97#else
98 0x10, /* bankSizeID: 64MB */
99#endif
100 0,
101 0,
102 0,
103 0,
104 0,
105 0,
106 0,
107 0,
108 0,
109 0,
110 0,
111 0,
112 0,
113 0,
114 0,
115 0,
116 0,
117 0,
118 0,
119 0,
120 0,
121 0,
122 0,
123 0,
124 0,
125 0,
126 0,
127 0,
128 0,
129 0,
130 0,
131 0,
132 0,
133 0,
134 0,
135 0,
136 0,
137 0,
138 0,
139 0,
140 0,
141 0,
142 0,
143 0,
144 0,
145 0,
146 0,
147 0,
148 0,
149 0,
150 0,
151 0,
152 0,
153 0,
154 0,
155 0,
156 0,
157 0,
158 0,
159 0,
160 0,
161 0,
162 0,
163 0,
164 0,
165 0,
166 0,
167 0,
168 0,
169 0,
170 0,
171 0,
172 0,
173 0,
174 0,
175 0,
176 0,
177 0,
178 0,
179 0,
180 0,
181 0,
182 0,
183 0,
184 0,
185 0,
186 0,
187 0,
188 0,
189 0,
190 0,
191 0,
192 0,
193 0,
194 0,
195 0
196};
197#endif
Stefan Roesefd49bf02005-11-15 16:04:58 +0100198
Stefan Roese17f50f222005-08-04 17:09:16 +0200199#if 0
Wolfgang Denkf901a832005-08-06 01:42:58 +0200200{ /* GPIO Alternate1 Alternate2 Alternate3 */
201 {
202 /* GPIO Core 0 */
203 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_0 -> EBC_ADDR(7) DMA_REQ(2) */
204 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_1 -> EBC_ADDR(6) DMA_ACK(2) */
205 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_2 -> EBC_ADDR(5) DMA_EOT/TC(2) */
206 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_3 -> EBC_ADDR(4) DMA_REQ(3) */
207 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_4 -> EBC_ADDR(3) DMA_ACK(3) */
208 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_5 ................. */
209 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_6 -> EBC_CS_N(1) */
210 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_7 -> EBC_CS_N(2) */
211 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_8 -> EBC_CS_N(3) */
212 { GPIO0_BASE, GPIO_DIS, GPIO_ALT1 }, /* GPIO0_9 -> EBC_CS_N(4) */
213 { GPIO0_BASE, GPIO_OUT, GPIO_ALT1 }, /* GPIO0_10 -> EBC_CS_N(5) */
214 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_11 -> EBC_BUS_ERR */
215 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_12 -> ZII_p0Rxd(0) */
216 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_13 -> ZII_p0Rxd(1) */
217 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_14 -> ZII_p0Rxd(2) */
218 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_15 -> ZII_p0Rxd(3) */
219 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_16 -> ZII_p0Txd(0) */
220 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_17 -> ZII_p0Txd(1) */
221 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_18 -> ZII_p0Txd(2) */
222 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_19 -> ZII_p0Txd(3) */
223 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_20 -> ZII_p0Rx_er */
224 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_21 -> ZII_p0Rx_dv */
225 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_22 -> ZII_p0RxCrs */
226 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_23 -> ZII_p0Tx_er */
227 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_24 -> ZII_p0Tx_en */
228 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_25 -> ZII_p0Col */
229 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_26 -> USB2D_RXVALID */
230 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_27 -> EXT_EBC_REQ USB2D_RXERROR */
231 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_28 -> USB2D_TXVALID */
232 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_29 -> EBC_EXT_HDLA USB2D_PAD_SUSPNDM */
233 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_30 -> EBC_EXT_ACK USB2D_XCVRSELECT */
234 { GPIO0_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO0_31 -> EBC_EXR_BUSREQ USB2D_TERMSELECT */
235 },
236 {
237 /* GPIO Core 1 */
238 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_0 -> USB2D_OPMODE0 */
239 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_1 -> USB2D_OPMODE1 */
240 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_2 -> UART0_DCD_N UART1_DSR_CTS_N UART2_SOUT */
241 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_3 -> UART0_8PIN_DSR_N UART1_RTS_DTR_N UART2_SIN */
242 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_4 -> UART0_8PIN_CTS_N UART3_SIN */
243 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_5 -> UART0_RTS_N */
244 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_6 -> UART0_DTR_N UART1_SOUT */
245 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_7 -> UART0_RI_N UART1_SIN */
246 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_8 -> UIC_IRQ(0) */
247 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_9 -> UIC_IRQ(1) */
248 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_10 -> UIC_IRQ(2) */
249 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_11 -> UIC_IRQ(3) */
250 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_12 -> UIC_IRQ(4) DMA_ACK(1) */
251 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_13 -> UIC_IRQ(6) DMA_EOT/TC(1) */
252 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_14 -> UIC_IRQ(7) DMA_REQ(0) */
253 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_15 -> UIC_IRQ(8) DMA_ACK(0) */
254 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_16 -> UIC_IRQ(9) DMA_EOT/TC(0) */
255 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_17 -> - */
256 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_18 -> | */
257 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_19 -> | */
258 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_20 -> | */
259 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_21 -> | */
260 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_22 -> | */
261 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_23 -> \ Can be unselected thru TraceSelect Bit */
262 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_24 -> / in PowerPC440EP Chip */
263 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_25 -> | */
264 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_26 -> | */
265 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_27 -> | */
266 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_28 -> | */
267 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_29 -> | */
268 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_30 -> | */
269 { GPIO1_BASE, GPIO_DIS, GPIO_SEL }, /* GPIO1_31 -> - */
270 }
Stefan Roese17f50f222005-08-04 17:09:16 +0200271};
272#endif
273
274/*----------------------------------------------------------------------------+
275 | EBC Devices Characteristics
Wolfgang Denkf901a832005-08-06 01:42:58 +0200276 | Peripheral Bank Access Parameters - EBC0_BnAP
277 | Peripheral Bank Configuration Register - EBC0_BnCR
Stefan Roese17f50f222005-08-04 17:09:16 +0200278 +----------------------------------------------------------------------------*/
279/* Small Flash */
Wolfgang Denkf901a832005-08-06 01:42:58 +0200280#define EBC0_BNAP_SMALL_FLASH \
281 EBC0_BNAP_BME_DISABLED | \
282 EBC0_BNAP_TWT_ENCODE(6) | \
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200283 EBC0_BNAP_CSN_ENCODE(0) | \
284 EBC0_BNAP_OEN_ENCODE(1) | \
285 EBC0_BNAP_WBN_ENCODE(1) | \
286 EBC0_BNAP_WBF_ENCODE(3) | \
287 EBC0_BNAP_TH_ENCODE(1) | \
288 EBC0_BNAP_RE_ENABLED | \
289 EBC0_BNAP_SOR_DELAYED | \
290 EBC0_BNAP_BEM_WRITEONLY | \
Stefan Roese17f50f222005-08-04 17:09:16 +0200291 EBC0_BNAP_PEN_DISABLED
292
Wolfgang Denkf901a832005-08-06 01:42:58 +0200293#define EBC0_BNCR_SMALL_FLASH_CS0 \
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200294 EBC0_BNCR_BAS_ENCODE(0xFFF00000) | \
295 EBC0_BNCR_BS_1MB | \
296 EBC0_BNCR_BU_RW | \
Stefan Roese17f50f222005-08-04 17:09:16 +0200297 EBC0_BNCR_BW_8BIT
298
Wolfgang Denkf901a832005-08-06 01:42:58 +0200299#define EBC0_BNCR_SMALL_FLASH_CS4 \
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200300 EBC0_BNCR_BAS_ENCODE(0x87F00000) | \
301 EBC0_BNCR_BS_1MB | \
302 EBC0_BNCR_BU_RW | \
Stefan Roesec57c7982005-08-11 17:56:56 +0200303 EBC0_BNCR_BW_8BIT
Stefan Roese17f50f222005-08-04 17:09:16 +0200304
305/* Large Flash or SRAM */
Wolfgang Denkf901a832005-08-06 01:42:58 +0200306#define EBC0_BNAP_LARGE_FLASH_OR_SRAM \
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200307 EBC0_BNAP_BME_DISABLED | \
308 EBC0_BNAP_TWT_ENCODE(8) | \
309 EBC0_BNAP_CSN_ENCODE(0) | \
310 EBC0_BNAP_OEN_ENCODE(1) | \
311 EBC0_BNAP_WBN_ENCODE(1) | \
312 EBC0_BNAP_WBF_ENCODE(1) | \
313 EBC0_BNAP_TH_ENCODE(2) | \
314 EBC0_BNAP_SOR_DELAYED | \
315 EBC0_BNAP_BEM_RW | \
Stefan Roese17f50f222005-08-04 17:09:16 +0200316 EBC0_BNAP_PEN_DISABLED
317
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200318#define EBC0_BNCR_LARGE_FLASH_OR_SRAM_CS0 \
319 EBC0_BNCR_BAS_ENCODE(0xFF800000) | \
320 EBC0_BNCR_BS_8MB | \
321 EBC0_BNCR_BU_RW | \
Stefan Roese17f50f222005-08-04 17:09:16 +0200322 EBC0_BNCR_BW_16BIT
323
324
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200325#define EBC0_BNCR_LARGE_FLASH_OR_SRAM_CS4 \
326 EBC0_BNCR_BAS_ENCODE(0x87800000) | \
327 EBC0_BNCR_BS_8MB | \
328 EBC0_BNCR_BU_RW | \
Stefan Roese17f50f222005-08-04 17:09:16 +0200329 EBC0_BNCR_BW_16BIT
330
331/* NVRAM - FPGA */
Wolfgang Denkf901a832005-08-06 01:42:58 +0200332#define EBC0_BNAP_NVRAM_FPGA \
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200333 EBC0_BNAP_BME_DISABLED | \
334 EBC0_BNAP_TWT_ENCODE(9) | \
335 EBC0_BNAP_CSN_ENCODE(0) | \
336 EBC0_BNAP_OEN_ENCODE(1) | \
337 EBC0_BNAP_WBN_ENCODE(1) | \
338 EBC0_BNAP_WBF_ENCODE(0) | \
339 EBC0_BNAP_TH_ENCODE(2) | \
340 EBC0_BNAP_RE_ENABLED | \
341 EBC0_BNAP_SOR_DELAYED | \
342 EBC0_BNAP_BEM_WRITEONLY | \
Stefan Roese17f50f222005-08-04 17:09:16 +0200343 EBC0_BNAP_PEN_DISABLED
344
Wolfgang Denkf901a832005-08-06 01:42:58 +0200345#define EBC0_BNCR_NVRAM_FPGA_CS5 \
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200346 EBC0_BNCR_BAS_ENCODE(0x80000000) | \
347 EBC0_BNCR_BS_1MB | \
348 EBC0_BNCR_BU_RW | \
Stefan Roese17f50f222005-08-04 17:09:16 +0200349 EBC0_BNCR_BW_8BIT
350
351/* Nand Flash */
Wolfgang Denkf901a832005-08-06 01:42:58 +0200352#define EBC0_BNAP_NAND_FLASH \
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200353 EBC0_BNAP_BME_DISABLED | \
354 EBC0_BNAP_TWT_ENCODE(3) | \
355 EBC0_BNAP_CSN_ENCODE(0) | \
356 EBC0_BNAP_OEN_ENCODE(0) | \
357 EBC0_BNAP_WBN_ENCODE(0) | \
358 EBC0_BNAP_WBF_ENCODE(0) | \
359 EBC0_BNAP_TH_ENCODE(1) | \
360 EBC0_BNAP_RE_ENABLED | \
361 EBC0_BNAP_SOR_NOT_DELAYED | \
362 EBC0_BNAP_BEM_RW | \
Stefan Roese17f50f222005-08-04 17:09:16 +0200363 EBC0_BNAP_PEN_DISABLED
364
365
Wolfgang Denkf901a832005-08-06 01:42:58 +0200366#define EBC0_BNCR_NAND_FLASH_CS0 0xB8400000
Stefan Roese17f50f222005-08-04 17:09:16 +0200367
368/* NAND0 */
Wolfgang Denkf901a832005-08-06 01:42:58 +0200369#define EBC0_BNCR_NAND_FLASH_CS1 \
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200370 EBC0_BNCR_BAS_ENCODE(0x90000000) | \
371 EBC0_BNCR_BS_1MB | \
372 EBC0_BNCR_BU_RW | \
Stefan Roese17f50f222005-08-04 17:09:16 +0200373 EBC0_BNCR_BW_32BIT
374/* NAND1 - Bank2 */
Wolfgang Denkf901a832005-08-06 01:42:58 +0200375#define EBC0_BNCR_NAND_FLASH_CS2 \
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200376 EBC0_BNCR_BAS_ENCODE(0x94000000) | \
377 EBC0_BNCR_BS_1MB | \
378 EBC0_BNCR_BU_RW | \
Stefan Roese17f50f222005-08-04 17:09:16 +0200379 EBC0_BNCR_BW_32BIT
380
381/* NAND1 - Bank3 */
Wolfgang Denkf901a832005-08-06 01:42:58 +0200382#define EBC0_BNCR_NAND_FLASH_CS3 \
Wolfgang Denk53677ef2008-05-20 16:00:29 +0200383 EBC0_BNCR_BAS_ENCODE(0x94000000) | \
384 EBC0_BNCR_BS_1MB | \
385 EBC0_BNCR_BU_RW | \
Stefan Roese17f50f222005-08-04 17:09:16 +0200386 EBC0_BNCR_BW_32BIT
Stefan Roese8a316c92005-08-01 16:49:12 +0200387
388int board_early_init_f(void)
389{
Stefan Roese17f50f222005-08-04 17:09:16 +0200390 ext_bus_cntlr_init();
Stefan Roese8a316c92005-08-01 16:49:12 +0200391
392 /*--------------------------------------------------------------------
393 * Setup the interrupt controller polarities, triggers, etc.
394 *-------------------------------------------------------------------*/
Stefan Roese952e7762009-09-24 09:55:50 +0200395 mtdcr(UIC0SR, 0xffffffff); /* clear all */
396 mtdcr(UIC0ER, 0x00000000); /* disable all */
397 mtdcr(UIC0CR, 0x00000009); /* ATI & UIC1 crit are critical */
398 mtdcr(UIC0PR, 0xfffffe13); /* per ref-board manual */
399 mtdcr(UIC0TR, 0x01c00008); /* per ref-board manual */
400 mtdcr(UIC0VR, 0x00000001); /* int31 highest, base=0x000 */
401 mtdcr(UIC0SR, 0xffffffff); /* clear all */
Stefan Roese8a316c92005-08-01 16:49:12 +0200402
Stefan Roese952e7762009-09-24 09:55:50 +0200403 mtdcr(UIC1SR, 0xffffffff); /* clear all */
404 mtdcr(UIC1ER, 0x00000000); /* disable all */
405 mtdcr(UIC1CR, 0x00000000); /* all non-critical */
406 mtdcr(UIC1PR, 0xffffe0ff); /* per ref-board manual */
407 mtdcr(UIC1TR, 0x00ffc000); /* per ref-board manual */
408 mtdcr(UIC1VR, 0x00000001); /* int31 highest, base=0x000 */
409 mtdcr(UIC1SR, 0xffffffff); /* clear all */
Stefan Roese8a316c92005-08-01 16:49:12 +0200410
411 /*--------------------------------------------------------------------
412 * Setup the GPIO pins
413 *-------------------------------------------------------------------*/
Stefan Roese17f50f222005-08-04 17:09:16 +0200414 out32(GPIO0_OSRL, 0x00000400);
415 out32(GPIO0_OSRH, 0x00000000);
416 out32(GPIO0_TSRL, 0x00000400);
417 out32(GPIO0_TSRH, 0x00000000);
418 out32(GPIO0_ISR1L, 0x00000000);
419 out32(GPIO0_ISR1H, 0x00000000);
420 out32(GPIO0_ISR2L, 0x00000000);
421 out32(GPIO0_ISR2H, 0x00000000);
422 out32(GPIO0_ISR3L, 0x00000000);
423 out32(GPIO0_ISR3H, 0x00000000);
Stefan Roese8a316c92005-08-01 16:49:12 +0200424
Stefan Roese17f50f222005-08-04 17:09:16 +0200425 out32(GPIO1_OSRL, 0x0C380000);
426 out32(GPIO1_OSRH, 0x00000000);
427 out32(GPIO1_TSRL, 0x0C380000);
428 out32(GPIO1_TSRH, 0x00000000);
429 out32(GPIO1_ISR1L, 0x0FC30000);
430 out32(GPIO1_ISR1H, 0x00000000);
431 out32(GPIO1_ISR2L, 0x0C010000);
432 out32(GPIO1_ISR2H, 0x00000000);
433 out32(GPIO1_ISR3L, 0x01400000);
434 out32(GPIO1_ISR3H, 0x00000000);
Stefan Roese8a316c92005-08-01 16:49:12 +0200435
Stefan Roese17f50f222005-08-04 17:09:16 +0200436 configure_ppc440ep_pins();
Stefan Roese8a316c92005-08-01 16:49:12 +0200437
438 return 0;
439}
440
441int checkboard(void)
442{
Stefan Roese3d9569b2005-11-27 19:36:26 +0100443 char *s = getenv("serial#");
Stefan Roese8a316c92005-08-01 16:49:12 +0200444
445 printf("Board: Bamboo - AMCC PPC440EP Evaluation Board");
446 if (s != NULL) {
447 puts(", serial# ");
448 puts(s);
449 }
450 putc('\n');
451
Stefan Roese8a316c92005-08-01 16:49:12 +0200452 return (0);
453}
454
Stefan Roese8a316c92005-08-01 16:49:12 +0200455
Becky Bruce9973e3c2008-06-09 16:03:40 -0500456phys_size_t initdram (int board_type)
Stefan Roese8a316c92005-08-01 16:49:12 +0200457{
Stefan Roesea471db02007-06-01 15:19:29 +0200458#if !(defined(CONFIG_NAND_U_BOOT) || defined(CONFIG_NAND_SPL))
459 long dram_size;
Stefan Roese17f50f222005-08-04 17:09:16 +0200460
Marian Balakowiczd19206b2006-07-04 01:27:46 +0200461 dram_size = spd_sdram();
Stefan Roese17f50f222005-08-04 17:09:16 +0200462
463 return dram_size;
Stefan Roesea471db02007-06-01 15:19:29 +0200464#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200465 return CONFIG_SYS_MBYTES_SDRAM << 20;
Stefan Roesea471db02007-06-01 15:19:29 +0200466#endif
Stefan Roese8a316c92005-08-01 16:49:12 +0200467}
468
Stefan Roese8a316c92005-08-01 16:49:12 +0200469/*************************************************************************
Stefan Roese8a316c92005-08-01 16:49:12 +0200470 * pci_master_init
471 *
472 ************************************************************************/
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200473#if defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT)
Stefan Roese8a316c92005-08-01 16:49:12 +0200474void pci_master_init(struct pci_controller *hose)
475{
476 unsigned short temp_short;
477
478 /*--------------------------------------------------------------------------+
479 | Write the PowerPC440 EP PCI Configuration regs.
480 | Enable PowerPC440 EP to be a master on the PCI bus (PMM).
481 | Enable PowerPC440 EP to act as a PCI memory target (PTM).
482 +--------------------------------------------------------------------------*/
483 pci_read_config_word(0, PCI_COMMAND, &temp_short);
484 pci_write_config_word(0, PCI_COMMAND,
485 temp_short | PCI_COMMAND_MASTER |
486 PCI_COMMAND_MEMORY);
487}
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200488#endif /* defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_MASTER_INIT) */
Stefan Roese8a316c92005-08-01 16:49:12 +0200489
Stefan Roese17f50f222005-08-04 17:09:16 +0200490/*----------------------------------------------------------------------------+
491 | is_powerpc440ep_pass1.
492 +----------------------------------------------------------------------------*/
493int is_powerpc440ep_pass1(void)
494{
495 unsigned long pvr;
496
497 pvr = get_pvr();
498
499 if (pvr == PVR_POWERPC_440EP_PASS1)
500 return TRUE;
501 else if (pvr == PVR_POWERPC_440EP_PASS2)
502 return FALSE;
503 else {
504 printf("brdutil error 3\n");
505 for (;;)
506 ;
507 }
508
509 return(FALSE);
510}
511
512/*----------------------------------------------------------------------------+
513 | is_nand_selected.
514 +----------------------------------------------------------------------------*/
515int is_nand_selected(void)
516{
Stefan Roesec57c7982005-08-11 17:56:56 +0200517#ifdef CONFIG_BAMBOO_NAND
518 return TRUE;
519#else
520 return FALSE;
521#endif
Stefan Roese17f50f222005-08-04 17:09:16 +0200522}
523
524/*----------------------------------------------------------------------------+
525 | config_on_ebc_cs4_is_small_flash => from EPLD
526 +----------------------------------------------------------------------------*/
527unsigned char config_on_ebc_cs4_is_small_flash(void)
528{
529 /* Not implemented yet => returns constant value */
530 return TRUE;
531}
532
533/*----------------------------------------------------------------------------+
534 | Ext_bus_cntlr_init.
535 | Initialize the external bus controller
536 +----------------------------------------------------------------------------*/
537void ext_bus_cntlr_init(void)
538{
539 unsigned long sdr0_pstrp0, sdr0_sdstp1;
540 unsigned long bootstrap_settings, boot_selection, ebc_boot_size;
Wolfgang Denkf901a832005-08-06 01:42:58 +0200541 int computed_boot_device = BOOT_DEVICE_UNKNOWN;
Stefan Roese17f50f222005-08-04 17:09:16 +0200542 unsigned long ebc0_cs0_bnap_value = 0, ebc0_cs0_bncr_value = 0;
543 unsigned long ebc0_cs1_bnap_value = 0, ebc0_cs1_bncr_value = 0;
544 unsigned long ebc0_cs2_bnap_value = 0, ebc0_cs2_bncr_value = 0;
545 unsigned long ebc0_cs3_bnap_value = 0, ebc0_cs3_bncr_value = 0;
546 unsigned long ebc0_cs4_bnap_value = 0, ebc0_cs4_bncr_value = 0;
547
548
549 /*-------------------------------------------------------------------------+
550 |
551 | PART 1 : Initialize EBC Bank 5
552 | ==============================
553 | Bank5 is always associated to the NVRAM/EPLD.
554 | It has to be initialized prior to other banks settings computation since
555 | some board registers values may be needed
556 |
557 +-------------------------------------------------------------------------*/
558 /* NVRAM - FPGA */
Stefan Roesed1c3b272009-09-09 16:25:29 +0200559 mtebc(PB5AP, EBC0_BNAP_NVRAM_FPGA);
560 mtebc(PB5CR, EBC0_BNCR_NVRAM_FPGA_CS5);
Stefan Roese17f50f222005-08-04 17:09:16 +0200561
562 /*-------------------------------------------------------------------------+
563 |
564 | PART 2 : Determine which boot device was selected
565 | =========================================
566 |
567 | Read Pin Strap Register in PPC440EP
568 | In case of boot from IIC, read Serial Device Strap Register1
569 |
570 | Result can either be :
571 | - Boot from EBC 8bits => SMALL FLASH
572 | - Boot from EBC 16bits => Large Flash or SRAM
573 | - Boot from NAND Flash
574 | - Boot from PCI
575 |
576 +-------------------------------------------------------------------------*/
577 /* Read Pin Strap Register in PPC440EP */
578 mfsdr(sdr_pstrp0, sdr0_pstrp0);
579 bootstrap_settings = sdr0_pstrp0 & SDR0_PSTRP0_BOOTSTRAP_MASK;
580
581 /*-------------------------------------------------------------------------+
582 | PPC440EP Pass1
583 +-------------------------------------------------------------------------*/
584 if (is_powerpc440ep_pass1() == TRUE) {
585 switch(bootstrap_settings) {
586 case SDR0_PSTRP0_BOOTSTRAP_SETTINGS0:
587 /* Default Strap Settings 0 : CPU 400 - PLB 133 - Boot EBC 8 bit 33MHz */
588 /* Boot from Small Flash */
589 computed_boot_device = BOOT_FROM_SMALL_FLASH;
590 break;
591 case SDR0_PSTRP0_BOOTSTRAP_SETTINGS1:
592 /* Default Strap Settings 1 : CPU 533 - PLB 133 - Boot PCI 66MHz */
593 /* Boot from PCI */
594 computed_boot_device = BOOT_FROM_PCI;
595 break;
596
597 case SDR0_PSTRP0_BOOTSTRAP_SETTINGS2:
598 /* Default Strap Settings 2 : CPU 500 - PLB 100 - Boot NDFC16 66MHz */
599 /* Boot from Nand Flash */
600 computed_boot_device = BOOT_FROM_NAND_FLASH0;
601 break;
602
603 case SDR0_PSTRP0_BOOTSTRAP_SETTINGS3:
604 /* Default Strap Settings 3 : CPU 333 - PLB 133 - Boot EBC 8 bit 66MHz */
605 /* Boot from Small Flash */
606 computed_boot_device = BOOT_FROM_SMALL_FLASH;
607 break;
608
609 case SDR0_PSTRP0_BOOTSTRAP_IIC_A8_EN:
610 case SDR0_PSTRP0_BOOTSTRAP_IIC_A4_EN:
611 /* Boot Settings in IIC EEprom address 0xA8 or 0xA4 */
612 /* Read Serial Device Strap Register1 in PPC440EP */
Stefan Roesed1c3b272009-09-09 16:25:29 +0200613 mfsdr(SDR0_SDSTP1, sdr0_sdstp1);
Wolfgang Denkf901a832005-08-06 01:42:58 +0200614 boot_selection = sdr0_sdstp1 & SDR0_SDSTP1_BOOT_SEL_MASK;
615 ebc_boot_size = sdr0_sdstp1 & SDR0_SDSTP1_EBC_ROM_BS_MASK;
Stefan Roese17f50f222005-08-04 17:09:16 +0200616
617 switch(boot_selection) {
618 case SDR0_SDSTP1_BOOT_SEL_EBC:
619 switch(ebc_boot_size) {
620 case SDR0_SDSTP1_EBC_ROM_BS_16BIT:
621 computed_boot_device = BOOT_FROM_LARGE_FLASH_OR_SRAM;
622 break;
623 case SDR0_SDSTP1_EBC_ROM_BS_8BIT:
624 computed_boot_device = BOOT_FROM_SMALL_FLASH;
625 break;
626 }
627 break;
628
629 case SDR0_SDSTP1_BOOT_SEL_PCI:
630 computed_boot_device = BOOT_FROM_PCI;
631 break;
632
633 case SDR0_SDSTP1_BOOT_SEL_NDFC:
634 computed_boot_device = BOOT_FROM_NAND_FLASH0;
635 break;
636 }
637 break;
638 }
639 }
640
641 /*-------------------------------------------------------------------------+
642 | PPC440EP Pass2
643 +-------------------------------------------------------------------------*/
644 else {
645 switch(bootstrap_settings) {
646 case SDR0_PSTRP0_BOOTSTRAP_SETTINGS0:
647 /* Default Strap Settings 0 : CPU 400 - PLB 133 - Boot EBC 8 bit 33MHz */
648 /* Boot from Small Flash */
649 computed_boot_device = BOOT_FROM_SMALL_FLASH;
650 break;
651 case SDR0_PSTRP0_BOOTSTRAP_SETTINGS1:
652 /* Default Strap Settings 1 : CPU 333 - PLB 133 - Boot PCI 66MHz */
653 /* Boot from PCI */
654 computed_boot_device = BOOT_FROM_PCI;
655 break;
656
657 case SDR0_PSTRP0_BOOTSTRAP_SETTINGS2:
658 /* Default Strap Settings 2 : CPU 400 - PLB 100 - Boot NDFC16 33MHz */
659 /* Boot from Nand Flash */
660 computed_boot_device = BOOT_FROM_NAND_FLASH0;
661 break;
662
663 case SDR0_PSTRP0_BOOTSTRAP_SETTINGS3:
664 /* Default Strap Settings 3 : CPU 400 - PLB 100 - Boot EBC 16 bit 33MHz */
665 /* Boot from Large Flash or SRAM */
666 computed_boot_device = BOOT_FROM_LARGE_FLASH_OR_SRAM;
667 break;
668
669 case SDR0_PSTRP0_BOOTSTRAP_SETTINGS4:
670 /* Default Strap Settings 4 : CPU 333 - PLB 133 - Boot EBC 16 bit 66MHz */
671 /* Boot from Large Flash or SRAM */
672 computed_boot_device = BOOT_FROM_LARGE_FLASH_OR_SRAM;
673 break;
674
675 case SDR0_PSTRP0_BOOTSTRAP_SETTINGS6:
676 /* Default Strap Settings 6 : CPU 400 - PLB 100 - Boot PCI 33MHz */
677 /* Boot from PCI */
678 computed_boot_device = BOOT_FROM_PCI;
679 break;
680
681 case SDR0_PSTRP0_BOOTSTRAP_IIC_A8_EN:
682 case SDR0_PSTRP0_BOOTSTRAP_IIC_A4_EN:
683 /* Default Strap Settings 5-7 */
684 /* Boot Settings in IIC EEprom address 0xA8 or 0xA4 */
685 /* Read Serial Device Strap Register1 in PPC440EP */
Stefan Roesed1c3b272009-09-09 16:25:29 +0200686 mfsdr(SDR0_SDSTP1, sdr0_sdstp1);
Wolfgang Denkf901a832005-08-06 01:42:58 +0200687 boot_selection = sdr0_sdstp1 & SDR0_SDSTP1_BOOT_SEL_MASK;
688 ebc_boot_size = sdr0_sdstp1 & SDR0_SDSTP1_EBC_ROM_BS_MASK;
Stefan Roese17f50f222005-08-04 17:09:16 +0200689
690 switch(boot_selection) {
691 case SDR0_SDSTP1_BOOT_SEL_EBC:
692 switch(ebc_boot_size) {
693 case SDR0_SDSTP1_EBC_ROM_BS_16BIT:
694 computed_boot_device = BOOT_FROM_LARGE_FLASH_OR_SRAM;
695 break;
696 case SDR0_SDSTP1_EBC_ROM_BS_8BIT:
697 computed_boot_device = BOOT_FROM_SMALL_FLASH;
698 break;
699 }
700 break;
701
702 case SDR0_SDSTP1_BOOT_SEL_PCI:
703 computed_boot_device = BOOT_FROM_PCI;
704 break;
705
706 case SDR0_SDSTP1_BOOT_SEL_NDFC:
707 computed_boot_device = BOOT_FROM_NAND_FLASH0;
708 break;
709 }
710 break;
711 }
712 }
713
714 /*-------------------------------------------------------------------------+
715 |
716 | PART 3 : Compute EBC settings depending on selected boot device
717 | ====== ======================================================
718 |
719 | Resulting EBC init will be among following configurations :
720 |
721 | - Boot from EBC 8bits => boot from SMALL FLASH selected
Wolfgang Denkf901a832005-08-06 01:42:58 +0200722 | EBC-CS0 = Small Flash
723 | EBC-CS1,2,3 = NAND Flash or
724 | Exp.Slot depending on Soft Config
725 | EBC-CS4 = SRAM/Large Flash or
726 | Large Flash/SRAM depending on jumpers
727 | EBC-CS5 = NVRAM / EPLD
Stefan Roese17f50f222005-08-04 17:09:16 +0200728 |
729 | - Boot from EBC 16bits => boot from Large Flash or SRAM selected
Wolfgang Denkf901a832005-08-06 01:42:58 +0200730 | EBC-CS0 = SRAM/Large Flash or
731 | Large Flash/SRAM depending on jumpers
732 | EBC-CS1,2,3 = NAND Flash or
733 | Exp.Slot depending on Software Configuration
734 | EBC-CS4 = Small Flash
735 | EBC-CS5 = NVRAM / EPLD
Stefan Roese17f50f222005-08-04 17:09:16 +0200736 |
737 | - Boot from NAND Flash
Wolfgang Denkf901a832005-08-06 01:42:58 +0200738 | EBC-CS0 = NAND Flash0
739 | EBC-CS1,2,3 = NAND Flash1
740 | EBC-CS4 = SRAM/Large Flash or
741 | Large Flash/SRAM depending on jumpers
742 | EBC-CS5 = NVRAM / EPLD
Stefan Roese17f50f222005-08-04 17:09:16 +0200743 |
744 | - Boot from PCI
Wolfgang Denkf901a832005-08-06 01:42:58 +0200745 | EBC-CS0 = ...
746 | EBC-CS1,2,3 = NAND Flash or
747 | Exp.Slot depending on Software Configuration
748 | EBC-CS4 = SRAM/Large Flash or
749 | Large Flash/SRAM or
750 | Small Flash depending on jumpers
751 | EBC-CS5 = NVRAM / EPLD
Stefan Roese17f50f222005-08-04 17:09:16 +0200752 |
753 +-------------------------------------------------------------------------*/
754
755 switch(computed_boot_device) {
756 /*------------------------------------------------------------------------- */
Wolfgang Denkf901a832005-08-06 01:42:58 +0200757 case BOOT_FROM_SMALL_FLASH:
Stefan Roese17f50f222005-08-04 17:09:16 +0200758 /*------------------------------------------------------------------------- */
759 ebc0_cs0_bnap_value = EBC0_BNAP_SMALL_FLASH;
760 ebc0_cs0_bncr_value = EBC0_BNCR_SMALL_FLASH_CS0;
761 if ((is_nand_selected()) == TRUE) {
762 /* NAND Flash */
763 ebc0_cs1_bnap_value = EBC0_BNAP_NAND_FLASH;
764 ebc0_cs1_bncr_value = EBC0_BNCR_NAND_FLASH_CS1;
Stefan Roesec57c7982005-08-11 17:56:56 +0200765 ebc0_cs2_bnap_value = EBC0_BNAP_NAND_FLASH;
766 ebc0_cs2_bncr_value = EBC0_BNCR_NAND_FLASH_CS2;
Stefan Roese17f50f222005-08-04 17:09:16 +0200767 ebc0_cs3_bnap_value = 0;
768 ebc0_cs3_bncr_value = 0;
769 } else {
770 /* Expansion Slot */
771 ebc0_cs1_bnap_value = 0;
772 ebc0_cs1_bncr_value = 0;
773 ebc0_cs2_bnap_value = 0;
774 ebc0_cs2_bncr_value = 0;
775 ebc0_cs3_bnap_value = 0;
776 ebc0_cs3_bncr_value = 0;
777 }
778 ebc0_cs4_bnap_value = EBC0_BNAP_LARGE_FLASH_OR_SRAM;
779 ebc0_cs4_bncr_value = EBC0_BNCR_LARGE_FLASH_OR_SRAM_CS4;
780
781 break;
782
783 /*------------------------------------------------------------------------- */
Wolfgang Denkf901a832005-08-06 01:42:58 +0200784 case BOOT_FROM_LARGE_FLASH_OR_SRAM:
Stefan Roese17f50f222005-08-04 17:09:16 +0200785 /*------------------------------------------------------------------------- */
786 ebc0_cs0_bnap_value = EBC0_BNAP_LARGE_FLASH_OR_SRAM;
787 ebc0_cs0_bncr_value = EBC0_BNCR_LARGE_FLASH_OR_SRAM_CS0;
788 if ((is_nand_selected()) == TRUE) {
789 /* NAND Flash */
790 ebc0_cs1_bnap_value = EBC0_BNAP_NAND_FLASH;
791 ebc0_cs1_bncr_value = EBC0_BNCR_NAND_FLASH_CS1;
792 ebc0_cs2_bnap_value = 0;
793 ebc0_cs2_bncr_value = 0;
794 ebc0_cs3_bnap_value = 0;
795 ebc0_cs3_bncr_value = 0;
796 } else {
797 /* Expansion Slot */
798 ebc0_cs1_bnap_value = 0;
799 ebc0_cs1_bncr_value = 0;
800 ebc0_cs2_bnap_value = 0;
801 ebc0_cs2_bncr_value = 0;
802 ebc0_cs3_bnap_value = 0;
803 ebc0_cs3_bncr_value = 0;
804 }
805 ebc0_cs4_bnap_value = EBC0_BNAP_SMALL_FLASH;
806 ebc0_cs4_bncr_value = EBC0_BNCR_SMALL_FLASH_CS4;
807
808 break;
809
810 /*------------------------------------------------------------------------- */
Wolfgang Denkf901a832005-08-06 01:42:58 +0200811 case BOOT_FROM_NAND_FLASH0:
Stefan Roese17f50f222005-08-04 17:09:16 +0200812 /*------------------------------------------------------------------------- */
Stefan Roesea471db02007-06-01 15:19:29 +0200813 ebc0_cs0_bnap_value = EBC0_BNAP_NAND_FLASH;
814 ebc0_cs0_bncr_value = EBC0_BNCR_NAND_FLASH_CS1;
Stefan Roese17f50f222005-08-04 17:09:16 +0200815
Stefan Roesea471db02007-06-01 15:19:29 +0200816 ebc0_cs1_bnap_value = 0;
817 ebc0_cs1_bncr_value = 0;
Stefan Roese17f50f222005-08-04 17:09:16 +0200818 ebc0_cs2_bnap_value = 0;
819 ebc0_cs2_bncr_value = 0;
820 ebc0_cs3_bnap_value = 0;
821 ebc0_cs3_bncr_value = 0;
822
823 /* Large Flash or SRAM */
824 ebc0_cs4_bnap_value = EBC0_BNAP_LARGE_FLASH_OR_SRAM;
825 ebc0_cs4_bncr_value = EBC0_BNCR_LARGE_FLASH_OR_SRAM_CS4;
826
827 break;
828
829 /*------------------------------------------------------------------------- */
Wolfgang Denkf901a832005-08-06 01:42:58 +0200830 case BOOT_FROM_PCI:
Stefan Roese17f50f222005-08-04 17:09:16 +0200831 /*------------------------------------------------------------------------- */
832 ebc0_cs0_bnap_value = 0;
833 ebc0_cs0_bncr_value = 0;
834
835 if ((is_nand_selected()) == TRUE) {
836 /* NAND Flash */
837 ebc0_cs1_bnap_value = EBC0_BNAP_NAND_FLASH;
838 ebc0_cs1_bncr_value = EBC0_BNCR_NAND_FLASH_CS1;
839 ebc0_cs2_bnap_value = 0;
840 ebc0_cs2_bncr_value = 0;
841 ebc0_cs3_bnap_value = 0;
842 ebc0_cs3_bncr_value = 0;
843 } else {
844 /* Expansion Slot */
845 ebc0_cs1_bnap_value = 0;
846 ebc0_cs1_bncr_value = 0;
847 ebc0_cs2_bnap_value = 0;
848 ebc0_cs2_bncr_value = 0;
849 ebc0_cs3_bnap_value = 0;
850 ebc0_cs3_bncr_value = 0;
851 }
852
853 if ((config_on_ebc_cs4_is_small_flash()) == TRUE) {
854 /* Small Flash */
855 ebc0_cs4_bnap_value = EBC0_BNAP_SMALL_FLASH;
856 ebc0_cs4_bncr_value = EBC0_BNCR_SMALL_FLASH_CS4;
857 } else {
858 /* Large Flash or SRAM */
859 ebc0_cs4_bnap_value = EBC0_BNAP_LARGE_FLASH_OR_SRAM;
860 ebc0_cs4_bncr_value = EBC0_BNCR_LARGE_FLASH_OR_SRAM_CS4;
861 }
862
863 break;
864
865 /*------------------------------------------------------------------------- */
Wolfgang Denkf901a832005-08-06 01:42:58 +0200866 case BOOT_DEVICE_UNKNOWN:
Stefan Roese17f50f222005-08-04 17:09:16 +0200867 /*------------------------------------------------------------------------- */
868 /* Error */
869 break;
870
871 }
872
873
874 /*-------------------------------------------------------------------------+
875 | Initialize EBC CONFIG
876 +-------------------------------------------------------------------------*/
Stefan Roesed1c3b272009-09-09 16:25:29 +0200877 mtdcr(EBC0_CFGADDR, EBC0_CFG);
878 mtdcr(EBC0_CFGDATA, EBC0_CFG_EBTC_DRIVEN |
Wolfgang Denkf901a832005-08-06 01:42:58 +0200879 EBC0_CFG_PTD_ENABLED |
880 EBC0_CFG_RTC_2048PERCLK |
881 EBC0_CFG_EMPL_LOW |
882 EBC0_CFG_EMPH_LOW |
883 EBC0_CFG_CSTC_DRIVEN |
884 EBC0_CFG_BPF_ONEDW |
885 EBC0_CFG_EMS_8BIT |
886 EBC0_CFG_PME_DISABLED |
887 EBC0_CFG_PMT_ENCODE(0) );
Stefan Roese17f50f222005-08-04 17:09:16 +0200888
889 /*-------------------------------------------------------------------------+
890 | Initialize EBC Bank 0-4
891 +-------------------------------------------------------------------------*/
892 /* EBC Bank0 */
Stefan Roesed1c3b272009-09-09 16:25:29 +0200893 mtebc(PB0AP, ebc0_cs0_bnap_value);
894 mtebc(PB0CR, ebc0_cs0_bncr_value);
Stefan Roese17f50f222005-08-04 17:09:16 +0200895 /* EBC Bank1 */
Stefan Roesed1c3b272009-09-09 16:25:29 +0200896 mtebc(PB1AP, ebc0_cs1_bnap_value);
897 mtebc(PB1CR, ebc0_cs1_bncr_value);
Stefan Roese17f50f222005-08-04 17:09:16 +0200898 /* EBC Bank2 */
Stefan Roesed1c3b272009-09-09 16:25:29 +0200899 mtebc(PB2AP, ebc0_cs2_bnap_value);
900 mtebc(PB2CR, ebc0_cs2_bncr_value);
Stefan Roese17f50f222005-08-04 17:09:16 +0200901 /* EBC Bank3 */
Stefan Roesed1c3b272009-09-09 16:25:29 +0200902 mtebc(PB3AP, ebc0_cs3_bnap_value);
903 mtebc(PB3CR, ebc0_cs3_bncr_value);
Stefan Roese17f50f222005-08-04 17:09:16 +0200904 /* EBC Bank4 */
Stefan Roesed1c3b272009-09-09 16:25:29 +0200905 mtebc(PB4AP, ebc0_cs4_bnap_value);
906 mtebc(PB4CR, ebc0_cs4_bncr_value);
Stefan Roese17f50f222005-08-04 17:09:16 +0200907
908 return;
909}
910
911
912/*----------------------------------------------------------------------------+
913 | get_uart_configuration.
914 +----------------------------------------------------------------------------*/
915uart_config_nb_t get_uart_configuration(void)
916{
Stefan Roesec57c7982005-08-11 17:56:56 +0200917 return (L4);
Stefan Roese17f50f222005-08-04 17:09:16 +0200918}
919
920/*----------------------------------------------------------------------------+
921 | set_phy_configuration_through_fpga => to EPLD
922 +----------------------------------------------------------------------------*/
923void set_phy_configuration_through_fpga(zmii_config_t config)
Stefan Roese8a316c92005-08-01 16:49:12 +0200924{
925
Stefan Roese17f50f222005-08-04 17:09:16 +0200926 unsigned long fpga_selection_reg;
927
928 fpga_selection_reg = in8(FPGA_SELECTION_1_REG) & ~FPGA_SEL_1_REG_PHY_MASK;
929
930 switch(config)
931 {
Wolfgang Denkf901a832005-08-06 01:42:58 +0200932 case ZMII_CONFIGURATION_IS_MII:
Stefan Roese17f50f222005-08-04 17:09:16 +0200933 fpga_selection_reg = fpga_selection_reg | FPGA_SEL_1_REG_MII;
934 break;
Wolfgang Denkf901a832005-08-06 01:42:58 +0200935 case ZMII_CONFIGURATION_IS_RMII:
Stefan Roese17f50f222005-08-04 17:09:16 +0200936 fpga_selection_reg = fpga_selection_reg | FPGA_SEL_1_REG_RMII;
937 break;
Wolfgang Denkf901a832005-08-06 01:42:58 +0200938 case ZMII_CONFIGURATION_IS_SMII:
Stefan Roese17f50f222005-08-04 17:09:16 +0200939 fpga_selection_reg = fpga_selection_reg | FPGA_SEL_1_REG_SMII;
940 break;
Wolfgang Denkf901a832005-08-06 01:42:58 +0200941 case ZMII_CONFIGURATION_UNKNOWN:
942 default:
Stefan Roese17f50f222005-08-04 17:09:16 +0200943 break;
944 }
945 out8(FPGA_SELECTION_1_REG,fpga_selection_reg);
946
Stefan Roese8a316c92005-08-01 16:49:12 +0200947}
Stefan Roese17f50f222005-08-04 17:09:16 +0200948
949/*----------------------------------------------------------------------------+
950 | scp_selection_in_fpga.
951 +----------------------------------------------------------------------------*/
952void scp_selection_in_fpga(void)
953{
954 unsigned long fpga_selection_2_reg;
955
956 fpga_selection_2_reg = in8(FPGA_SELECTION_2_REG) & ~FPGA_SEL2_REG_IIC1_SCP_SEL_MASK;
957 fpga_selection_2_reg |= FPGA_SEL2_REG_SEL_SCP;
958 out8(FPGA_SELECTION_2_REG,fpga_selection_2_reg);
959}
960
961/*----------------------------------------------------------------------------+
962 | iic1_selection_in_fpga.
963 +----------------------------------------------------------------------------*/
964void iic1_selection_in_fpga(void)
965{
966 unsigned long fpga_selection_2_reg;
967
968 fpga_selection_2_reg = in8(FPGA_SELECTION_2_REG) & ~FPGA_SEL2_REG_IIC1_SCP_SEL_MASK;
969 fpga_selection_2_reg |= FPGA_SEL2_REG_SEL_IIC1;
970 out8(FPGA_SELECTION_2_REG,fpga_selection_2_reg);
971}
972
973/*----------------------------------------------------------------------------+
974 | dma_a_b_selection_in_fpga.
975 +----------------------------------------------------------------------------*/
976void dma_a_b_selection_in_fpga(void)
977{
978 unsigned long fpga_selection_2_reg;
979
980 fpga_selection_2_reg = in8(FPGA_SELECTION_2_REG) | FPGA_SEL2_REG_SEL_DMA_A_B;
981 out8(FPGA_SELECTION_2_REG,fpga_selection_2_reg);
982}
983
984/*----------------------------------------------------------------------------+
985 | dma_a_b_unselect_in_fpga.
986 +----------------------------------------------------------------------------*/
987void dma_a_b_unselect_in_fpga(void)
988{
989 unsigned long fpga_selection_2_reg;
990
991 fpga_selection_2_reg = in8(FPGA_SELECTION_2_REG) & ~FPGA_SEL2_REG_SEL_DMA_A_B;
992 out8(FPGA_SELECTION_2_REG,fpga_selection_2_reg);
993}
994
995/*----------------------------------------------------------------------------+
996 | dma_c_d_selection_in_fpga.
997 +----------------------------------------------------------------------------*/
998void dma_c_d_selection_in_fpga(void)
999{
1000 unsigned long fpga_selection_2_reg;
1001
1002 fpga_selection_2_reg = in8(FPGA_SELECTION_2_REG) | FPGA_SEL2_REG_SEL_DMA_C_D;
1003 out8(FPGA_SELECTION_2_REG,fpga_selection_2_reg);
1004}
1005
1006/*----------------------------------------------------------------------------+
1007 | dma_c_d_unselect_in_fpga.
1008 +----------------------------------------------------------------------------*/
1009void dma_c_d_unselect_in_fpga(void)
1010{
1011 unsigned long fpga_selection_2_reg;
1012
1013 fpga_selection_2_reg = in8(FPGA_SELECTION_2_REG) & ~FPGA_SEL2_REG_SEL_DMA_C_D;
1014 out8(FPGA_SELECTION_2_REG,fpga_selection_2_reg);
1015}
1016
1017/*----------------------------------------------------------------------------+
1018 | usb2_device_selection_in_fpga.
1019 +----------------------------------------------------------------------------*/
1020void usb2_device_selection_in_fpga(void)
1021{
1022 unsigned long fpga_selection_1_reg;
1023
1024 fpga_selection_1_reg = in8(FPGA_SELECTION_1_REG) | FPGA_SEL_1_REG_USB2_DEV_SEL;
1025 out8(FPGA_SELECTION_1_REG,fpga_selection_1_reg);
1026}
1027
1028/*----------------------------------------------------------------------------+
1029 | usb2_device_reset_through_fpga.
1030 +----------------------------------------------------------------------------*/
1031void usb2_device_reset_through_fpga(void)
1032{
1033 /* Perform soft Reset pulse */
1034 unsigned long fpga_reset_reg;
1035 int i;
1036
1037 fpga_reset_reg = in8(FPGA_RESET_REG);
1038 out8(FPGA_RESET_REG,fpga_reset_reg | FPGA_RESET_REG_RESET_USB20_DEV);
1039 for (i=0; i<500; i++)
1040 udelay(1000);
1041 out8(FPGA_RESET_REG,fpga_reset_reg);
1042}
1043
1044/*----------------------------------------------------------------------------+
1045 | usb2_host_selection_in_fpga.
1046 +----------------------------------------------------------------------------*/
1047void usb2_host_selection_in_fpga(void)
1048{
1049 unsigned long fpga_selection_1_reg;
1050
1051 fpga_selection_1_reg = in8(FPGA_SELECTION_1_REG) | FPGA_SEL_1_REG_USB2_HOST_SEL;
1052 out8(FPGA_SELECTION_1_REG,fpga_selection_1_reg);
1053}
1054
1055/*----------------------------------------------------------------------------+
1056 | ndfc_selection_in_fpga.
1057 +----------------------------------------------------------------------------*/
1058void ndfc_selection_in_fpga(void)
1059{
1060 unsigned long fpga_selection_1_reg;
1061
1062 fpga_selection_1_reg = in8(FPGA_SELECTION_1_REG) &~FPGA_SEL_1_REG_NF_SELEC_MASK;
1063 fpga_selection_1_reg |= FPGA_SEL_1_REG_NF0_SEL_BY_NFCS1;
Stefan Roesec57c7982005-08-11 17:56:56 +02001064 fpga_selection_1_reg |= FPGA_SEL_1_REG_NF1_SEL_BY_NFCS2;
Stefan Roese17f50f222005-08-04 17:09:16 +02001065 out8(FPGA_SELECTION_1_REG,fpga_selection_1_reg);
1066}
1067
1068/*----------------------------------------------------------------------------+
1069 | uart_selection_in_fpga.
1070 +----------------------------------------------------------------------------*/
1071void uart_selection_in_fpga(uart_config_nb_t uart_config)
1072{
1073 /* FPGA register */
Wolfgang Denkf901a832005-08-06 01:42:58 +02001074 unsigned char fpga_selection_3_reg;
Stefan Roese17f50f222005-08-04 17:09:16 +02001075
1076 /* Read FPGA Reagister */
1077 fpga_selection_3_reg = in8(FPGA_SELECTION_3_REG);
1078
1079 switch (uart_config)
1080 {
1081 case L1:
1082 /* ----------------------------------------------------------------------- */
Wolfgang Denkf901a832005-08-06 01:42:58 +02001083 /* L1 configuration: UART0 = 8 pins */
Stefan Roese17f50f222005-08-04 17:09:16 +02001084 /* ----------------------------------------------------------------------- */
1085 /* Configure FPGA */
Wolfgang Denkf901a832005-08-06 01:42:58 +02001086 fpga_selection_3_reg = fpga_selection_3_reg & ~FPGA_SEL3_REG_SEL_UART_CONFIG_MASK;
1087 fpga_selection_3_reg = fpga_selection_3_reg | FPGA_SEL3_REG_SEL_UART_CONFIG1;
Stefan Roese17f50f222005-08-04 17:09:16 +02001088 out8(FPGA_SELECTION_3_REG, fpga_selection_3_reg);
1089
1090 break;
1091
1092 case L2:
1093 /* ----------------------------------------------------------------------- */
Wolfgang Denkf901a832005-08-06 01:42:58 +02001094 /* L2 configuration: UART0 = 4 pins */
1095 /* UART1 = 4 pins */
Stefan Roese17f50f222005-08-04 17:09:16 +02001096 /* ----------------------------------------------------------------------- */
1097 /* Configure FPGA */
Wolfgang Denkf901a832005-08-06 01:42:58 +02001098 fpga_selection_3_reg = fpga_selection_3_reg & ~FPGA_SEL3_REG_SEL_UART_CONFIG_MASK;
1099 fpga_selection_3_reg = fpga_selection_3_reg | FPGA_SEL3_REG_SEL_UART_CONFIG2;
Stefan Roese17f50f222005-08-04 17:09:16 +02001100 out8(FPGA_SELECTION_3_REG, fpga_selection_3_reg);
1101
1102 break;
1103
1104 case L3:
1105 /* ----------------------------------------------------------------------- */
Wolfgang Denkf901a832005-08-06 01:42:58 +02001106 /* L3 configuration: UART0 = 4 pins */
1107 /* UART1 = 2 pins */
1108 /* UART2 = 2 pins */
Stefan Roese17f50f222005-08-04 17:09:16 +02001109 /* ----------------------------------------------------------------------- */
1110 /* Configure FPGA */
Wolfgang Denkf901a832005-08-06 01:42:58 +02001111 fpga_selection_3_reg = fpga_selection_3_reg & ~FPGA_SEL3_REG_SEL_UART_CONFIG_MASK;
1112 fpga_selection_3_reg = fpga_selection_3_reg | FPGA_SEL3_REG_SEL_UART_CONFIG3;
Stefan Roese17f50f222005-08-04 17:09:16 +02001113 out8(FPGA_SELECTION_3_REG, fpga_selection_3_reg);
1114 break;
1115
1116 case L4:
1117 /* Configure FPGA */
Wolfgang Denkf901a832005-08-06 01:42:58 +02001118 fpga_selection_3_reg = fpga_selection_3_reg & ~FPGA_SEL3_REG_SEL_UART_CONFIG_MASK;
1119 fpga_selection_3_reg = fpga_selection_3_reg | FPGA_SEL3_REG_SEL_UART_CONFIG4;
Stefan Roese17f50f222005-08-04 17:09:16 +02001120 out8(FPGA_SELECTION_3_REG, fpga_selection_3_reg);
1121
1122 break;
1123
1124 default:
1125 /* Unsupported UART configuration number */
1126 for (;;)
1127 ;
1128 break;
1129
1130 }
1131}
1132
1133
1134/*----------------------------------------------------------------------------+
1135 | init_default_gpio
1136 +----------------------------------------------------------------------------*/
Eugene OBriend2f68002007-07-31 10:24:56 +02001137void init_default_gpio(gpio_param_s (*gpio_tab)[GPIO_MAX])
Stefan Roese17f50f222005-08-04 17:09:16 +02001138{
1139 int i;
1140
1141 /* Init GPIO0 */
1142 for(i=0; i<GPIO_MAX; i++)
1143 {
Wolfgang Denkf901a832005-08-06 01:42:58 +02001144 gpio_tab[GPIO0][i].add = GPIO0_BASE;
Stefan Roese17f50f222005-08-04 17:09:16 +02001145 gpio_tab[GPIO0][i].in_out = GPIO_DIS;
1146 gpio_tab[GPIO0][i].alt_nb = GPIO_SEL;
1147 }
1148
1149 /* Init GPIO1 */
1150 for(i=0; i<GPIO_MAX; i++)
1151 {
Wolfgang Denkf901a832005-08-06 01:42:58 +02001152 gpio_tab[GPIO1][i].add = GPIO1_BASE;
Stefan Roese17f50f222005-08-04 17:09:16 +02001153 gpio_tab[GPIO1][i].in_out = GPIO_DIS;
1154 gpio_tab[GPIO1][i].alt_nb = GPIO_SEL;
1155 }
1156
1157 /* EBC_CS_N(5) - GPIO0_10 */
1158 gpio_tab[GPIO0][10].in_out = GPIO_OUT;
1159 gpio_tab[GPIO0][10].alt_nb = GPIO_ALT1;
1160
1161 /* EBC_CS_N(4) - GPIO0_9 */
1162 gpio_tab[GPIO0][9].in_out = GPIO_OUT;
1163 gpio_tab[GPIO0][9].alt_nb = GPIO_ALT1;
1164}
1165
1166/*----------------------------------------------------------------------------+
1167 | update_uart_ios
1168 +------------------------------------------------------------------------------
1169 |
1170 | Set UART Configuration in PowerPC440EP
1171 |
1172 | +---------------------------------------------------------------------+
Wolfgang Denkf901a832005-08-06 01:42:58 +02001173 | | Configuartion | Connector | Nb of pins | Pins | Associated |
1174 | | Number | Port Name | available | naming | CORE |
Stefan Roese17f50f222005-08-04 17:09:16 +02001175 | +-----------------+---------------+------------+--------+-------------+
Wolfgang Denkf901a832005-08-06 01:42:58 +02001176 | | L1 | Port_A | 8 | UART | UART core 0 |
Stefan Roese17f50f222005-08-04 17:09:16 +02001177 | +-----------------+---------------+------------+--------+-------------+
Wolfgang Denkf901a832005-08-06 01:42:58 +02001178 | | L2 | Port_A | 4 | UART1 | UART core 0 |
1179 | | (L2D) | Port_B | 4 | UART2 | UART core 1 |
Stefan Roese17f50f222005-08-04 17:09:16 +02001180 | +-----------------+---------------+------------+--------+-------------+
Wolfgang Denkf901a832005-08-06 01:42:58 +02001181 | | L3 | Port_A | 4 | UART1 | UART core 0 |
1182 | | (L3D) | Port_B | 2 | UART2 | UART core 1 |
1183 | | | Port_C | 2 | UART3 | UART core 2 |
Stefan Roese17f50f222005-08-04 17:09:16 +02001184 | +-----------------+---------------+------------+--------+-------------+
Wolfgang Denkf901a832005-08-06 01:42:58 +02001185 | | | Port_A | 2 | UART1 | UART core 0 |
1186 | | L4 | Port_B | 2 | UART2 | UART core 1 |
1187 | | (L4D) | Port_C | 2 | UART3 | UART core 2 |
1188 | | | Port_D | 2 | UART4 | UART core 3 |
Stefan Roese17f50f222005-08-04 17:09:16 +02001189 | +-----------------+---------------+------------+--------+-------------+
1190 |
1191 | Involved GPIOs
1192 |
1193 | +------------------------------------------------------------------------------+
Wolfgang Denkf901a832005-08-06 01:42:58 +02001194 | | GPIO | Aternate 1 | I/O | Alternate 2 | I/O | Alternate 3 | I/O |
Stefan Roese17f50f222005-08-04 17:09:16 +02001195 | +---------+------------------+-----+-----------------+-----+-------------+-----+
Wolfgang Denkf901a832005-08-06 01:42:58 +02001196 | | GPIO1_2 | UART0_DCD_N | I | UART1_DSR_CTS_N | I | UART2_SOUT | O |
1197 | | GPIO1_3 | UART0_8PIN_DSR_N | I | UART1_RTS_DTR_N | O | UART2_SIN | I |
1198 | | GPIO1_4 | UART0_8PIN_CTS_N | I | NA | NA | UART3_SIN | I |
1199 | | GPIO1_5 | UART0_RTS_N | O | NA | NA | UART3_SOUT | O |
1200 | | GPIO1_6 | UART0_DTR_N | O | UART1_SOUT | O | NA | NA |
1201 | | GPIO1_7 | UART0_RI_N | I | UART1_SIN | I | NA | NA |
Stefan Roese17f50f222005-08-04 17:09:16 +02001202 | +------------------------------------------------------------------------------+
1203 |
1204 |
1205 +----------------------------------------------------------------------------*/
1206
Eugene OBriend2f68002007-07-31 10:24:56 +02001207void update_uart_ios(uart_config_nb_t uart_config, gpio_param_s (*gpio_tab)[GPIO_MAX])
Stefan Roese17f50f222005-08-04 17:09:16 +02001208{
1209 switch (uart_config)
1210 {
1211 case L1:
1212 /* ----------------------------------------------------------------------- */
Wolfgang Denkf901a832005-08-06 01:42:58 +02001213 /* L1 configuration: UART0 = 8 pins */
Stefan Roese17f50f222005-08-04 17:09:16 +02001214 /* ----------------------------------------------------------------------- */
1215 /* Update GPIO Configuration Table */
1216 gpio_tab[GPIO1][2].in_out = GPIO_IN;
1217 gpio_tab[GPIO1][2].alt_nb = GPIO_ALT1;
1218
1219 gpio_tab[GPIO1][3].in_out = GPIO_IN;
1220 gpio_tab[GPIO1][3].alt_nb = GPIO_ALT1;
1221
1222 gpio_tab[GPIO1][4].in_out = GPIO_IN;
1223 gpio_tab[GPIO1][4].alt_nb = GPIO_ALT1;
1224
1225 gpio_tab[GPIO1][5].in_out = GPIO_OUT;
1226 gpio_tab[GPIO1][5].alt_nb = GPIO_ALT1;
1227
1228 gpio_tab[GPIO1][6].in_out = GPIO_OUT;
1229 gpio_tab[GPIO1][6].alt_nb = GPIO_ALT1;
1230
1231 gpio_tab[GPIO1][7].in_out = GPIO_IN;
1232 gpio_tab[GPIO1][7].alt_nb = GPIO_ALT1;
1233
1234 break;
1235
1236 case L2:
1237 /* ----------------------------------------------------------------------- */
Wolfgang Denkf901a832005-08-06 01:42:58 +02001238 /* L2 configuration: UART0 = 4 pins */
1239 /* UART1 = 4 pins */
Stefan Roese17f50f222005-08-04 17:09:16 +02001240 /* ----------------------------------------------------------------------- */
1241 /* Update GPIO Configuration Table */
1242 gpio_tab[GPIO1][2].in_out = GPIO_IN;
1243 gpio_tab[GPIO1][2].alt_nb = GPIO_ALT2;
1244
1245 gpio_tab[GPIO1][3].in_out = GPIO_OUT;
1246 gpio_tab[GPIO1][3].alt_nb = GPIO_ALT2;
1247
1248 gpio_tab[GPIO1][4].in_out = GPIO_IN;
1249 gpio_tab[GPIO1][4].alt_nb = GPIO_ALT1;
1250
1251 gpio_tab[GPIO1][5].in_out = GPIO_OUT;
1252 gpio_tab[GPIO1][5].alt_nb = GPIO_ALT1;
1253
1254 gpio_tab[GPIO1][6].in_out = GPIO_OUT;
1255 gpio_tab[GPIO1][6].alt_nb = GPIO_ALT2;
1256
1257 gpio_tab[GPIO1][7].in_out = GPIO_IN;
1258 gpio_tab[GPIO1][7].alt_nb = GPIO_ALT2;
1259
1260 break;
1261
1262 case L3:
1263 /* ----------------------------------------------------------------------- */
Wolfgang Denkf901a832005-08-06 01:42:58 +02001264 /* L3 configuration: UART0 = 4 pins */
1265 /* UART1 = 2 pins */
1266 /* UART2 = 2 pins */
Stefan Roese17f50f222005-08-04 17:09:16 +02001267 /* ----------------------------------------------------------------------- */
1268 /* Update GPIO Configuration Table */
1269 gpio_tab[GPIO1][2].in_out = GPIO_OUT;
1270 gpio_tab[GPIO1][2].alt_nb = GPIO_ALT3;
1271
1272 gpio_tab[GPIO1][3].in_out = GPIO_IN;
1273 gpio_tab[GPIO1][3].alt_nb = GPIO_ALT3;
1274
1275 gpio_tab[GPIO1][4].in_out = GPIO_IN;
1276 gpio_tab[GPIO1][4].alt_nb = GPIO_ALT1;
1277
1278 gpio_tab[GPIO1][5].in_out = GPIO_OUT;
1279 gpio_tab[GPIO1][5].alt_nb = GPIO_ALT1;
1280
1281 gpio_tab[GPIO1][6].in_out = GPIO_OUT;
1282 gpio_tab[GPIO1][6].alt_nb = GPIO_ALT2;
1283
1284 gpio_tab[GPIO1][7].in_out = GPIO_IN;
1285 gpio_tab[GPIO1][7].alt_nb = GPIO_ALT2;
1286
1287 break;
1288
1289 case L4:
1290 /* ----------------------------------------------------------------------- */
Wolfgang Denkf901a832005-08-06 01:42:58 +02001291 /* L4 configuration: UART0 = 2 pins */
1292 /* UART1 = 2 pins */
1293 /* UART2 = 2 pins */
1294 /* UART3 = 2 pins */
Stefan Roese17f50f222005-08-04 17:09:16 +02001295 /* ----------------------------------------------------------------------- */
1296 /* Update GPIO Configuration Table */
1297 gpio_tab[GPIO1][2].in_out = GPIO_OUT;
1298 gpio_tab[GPIO1][2].alt_nb = GPIO_ALT3;
1299
1300 gpio_tab[GPIO1][3].in_out = GPIO_IN;
1301 gpio_tab[GPIO1][3].alt_nb = GPIO_ALT3;
1302
1303 gpio_tab[GPIO1][4].in_out = GPIO_IN;
1304 gpio_tab[GPIO1][4].alt_nb = GPIO_ALT3;
1305
1306 gpio_tab[GPIO1][5].in_out = GPIO_OUT;
1307 gpio_tab[GPIO1][5].alt_nb = GPIO_ALT3;
1308
1309 gpio_tab[GPIO1][6].in_out = GPIO_OUT;
1310 gpio_tab[GPIO1][6].alt_nb = GPIO_ALT2;
1311
1312 gpio_tab[GPIO1][7].in_out = GPIO_IN;
1313 gpio_tab[GPIO1][7].alt_nb = GPIO_ALT2;
1314
1315 break;
1316
1317 default:
1318 /* Unsupported UART configuration number */
1319 printf("ERROR - Unsupported UART configuration number.\n\n");
1320 for (;;)
1321 ;
1322 break;
1323
1324 }
1325
1326 /* Set input Selection Register on Alt_Receive for UART Input Core */
1327 out32(GPIO1_IS1L, (in32(GPIO1_IS1L) | 0x0FC30000));
1328 out32(GPIO1_IS2L, (in32(GPIO1_IS2L) | 0x0C030000));
1329 out32(GPIO1_IS3L, (in32(GPIO1_IS3L) | 0x03C00000));
1330}
1331
1332/*----------------------------------------------------------------------------+
1333 | update_ndfc_ios(void).
1334 +----------------------------------------------------------------------------*/
Eugene OBriend2f68002007-07-31 10:24:56 +02001335void update_ndfc_ios(gpio_param_s (*gpio_tab)[GPIO_MAX])
Stefan Roese17f50f222005-08-04 17:09:16 +02001336{
Wolfgang Denkf901a832005-08-06 01:42:58 +02001337 /* Update GPIO Configuration Table */
1338 gpio_tab[GPIO0][6].in_out = GPIO_OUT; /* EBC_CS_N(1) */
1339 gpio_tab[GPIO0][6].alt_nb = GPIO_ALT1;
Stefan Roese17f50f222005-08-04 17:09:16 +02001340
Wolfgang Denkf901a832005-08-06 01:42:58 +02001341 gpio_tab[GPIO0][7].in_out = GPIO_OUT; /* EBC_CS_N(2) */
Stefan Roese17f50f222005-08-04 17:09:16 +02001342 gpio_tab[GPIO0][7].alt_nb = GPIO_ALT1;
1343
Stefan Roesea471db02007-06-01 15:19:29 +02001344#if 0
Wolfgang Denkf901a832005-08-06 01:42:58 +02001345 gpio_tab[GPIO0][7].in_out = GPIO_OUT; /* EBC_CS_N(3) */
Stefan Roese17f50f222005-08-04 17:09:16 +02001346 gpio_tab[GPIO0][7].alt_nb = GPIO_ALT1;
Stefan Roese8a316c92005-08-01 16:49:12 +02001347#endif
Stefan Roese17f50f222005-08-04 17:09:16 +02001348}
1349
1350/*----------------------------------------------------------------------------+
1351 | update_zii_ios(void).
1352 +----------------------------------------------------------------------------*/
Eugene OBriend2f68002007-07-31 10:24:56 +02001353void update_zii_ios(gpio_param_s (*gpio_tab)[GPIO_MAX])
Stefan Roese17f50f222005-08-04 17:09:16 +02001354{
Wolfgang Denkf901a832005-08-06 01:42:58 +02001355 /* Update GPIO Configuration Table */
1356 gpio_tab[GPIO0][12].in_out = GPIO_IN; /* ZII_p0Rxd(0) */
1357 gpio_tab[GPIO0][12].alt_nb = GPIO_ALT1;
Stefan Roese17f50f222005-08-04 17:09:16 +02001358
Wolfgang Denkf901a832005-08-06 01:42:58 +02001359 gpio_tab[GPIO0][13].in_out = GPIO_IN; /* ZII_p0Rxd(1) */
1360 gpio_tab[GPIO0][13].alt_nb = GPIO_ALT1;
Stefan Roese17f50f222005-08-04 17:09:16 +02001361
Wolfgang Denkf901a832005-08-06 01:42:58 +02001362 gpio_tab[GPIO0][14].in_out = GPIO_IN; /* ZII_p0Rxd(2) */
1363 gpio_tab[GPIO0][14].alt_nb = GPIO_ALT1;
Stefan Roese17f50f222005-08-04 17:09:16 +02001364
Wolfgang Denkf901a832005-08-06 01:42:58 +02001365 gpio_tab[GPIO0][15].in_out = GPIO_IN; /* ZII_p0Rxd(3) */
1366 gpio_tab[GPIO0][15].alt_nb = GPIO_ALT1;
Stefan Roese17f50f222005-08-04 17:09:16 +02001367
Wolfgang Denkf901a832005-08-06 01:42:58 +02001368 gpio_tab[GPIO0][16].in_out = GPIO_OUT; /* ZII_p0Txd(0) */
1369 gpio_tab[GPIO0][16].alt_nb = GPIO_ALT1;
Stefan Roese17f50f222005-08-04 17:09:16 +02001370
Wolfgang Denkf901a832005-08-06 01:42:58 +02001371 gpio_tab[GPIO0][17].in_out = GPIO_OUT; /* ZII_p0Txd(1) */
1372 gpio_tab[GPIO0][17].alt_nb = GPIO_ALT1;
Stefan Roese17f50f222005-08-04 17:09:16 +02001373
Wolfgang Denkf901a832005-08-06 01:42:58 +02001374 gpio_tab[GPIO0][18].in_out = GPIO_OUT; /* ZII_p0Txd(2) */
1375 gpio_tab[GPIO0][18].alt_nb = GPIO_ALT1;
Stefan Roese17f50f222005-08-04 17:09:16 +02001376
Wolfgang Denkf901a832005-08-06 01:42:58 +02001377 gpio_tab[GPIO0][19].in_out = GPIO_OUT; /* ZII_p0Txd(3) */
1378 gpio_tab[GPIO0][19].alt_nb = GPIO_ALT1;
Stefan Roese17f50f222005-08-04 17:09:16 +02001379
Wolfgang Denkf901a832005-08-06 01:42:58 +02001380 gpio_tab[GPIO0][20].in_out = GPIO_IN; /* ZII_p0Rx_er */
1381 gpio_tab[GPIO0][20].alt_nb = GPIO_ALT1;
Stefan Roese17f50f222005-08-04 17:09:16 +02001382
Wolfgang Denkf901a832005-08-06 01:42:58 +02001383 gpio_tab[GPIO0][21].in_out = GPIO_IN; /* ZII_p0Rx_dv */
1384 gpio_tab[GPIO0][21].alt_nb = GPIO_ALT1;
Stefan Roese17f50f222005-08-04 17:09:16 +02001385
Wolfgang Denkf901a832005-08-06 01:42:58 +02001386 gpio_tab[GPIO0][22].in_out = GPIO_IN; /* ZII_p0Crs */
1387 gpio_tab[GPIO0][22].alt_nb = GPIO_ALT1;
Stefan Roese17f50f222005-08-04 17:09:16 +02001388
Wolfgang Denkf901a832005-08-06 01:42:58 +02001389 gpio_tab[GPIO0][23].in_out = GPIO_OUT; /* ZII_p0Tx_er */
1390 gpio_tab[GPIO0][23].alt_nb = GPIO_ALT1;
Stefan Roese17f50f222005-08-04 17:09:16 +02001391
Wolfgang Denkf901a832005-08-06 01:42:58 +02001392 gpio_tab[GPIO0][24].in_out = GPIO_OUT; /* ZII_p0Tx_en */
1393 gpio_tab[GPIO0][24].alt_nb = GPIO_ALT1;
Stefan Roese17f50f222005-08-04 17:09:16 +02001394
Wolfgang Denkf901a832005-08-06 01:42:58 +02001395 gpio_tab[GPIO0][25].in_out = GPIO_IN; /* ZII_p0Col */
1396 gpio_tab[GPIO0][25].alt_nb = GPIO_ALT1;
Stefan Roese17f50f222005-08-04 17:09:16 +02001397
1398}
1399
1400/*----------------------------------------------------------------------------+
1401 | update_uic_0_3_irq_ios().
1402 +----------------------------------------------------------------------------*/
Eugene OBriend2f68002007-07-31 10:24:56 +02001403void update_uic_0_3_irq_ios(gpio_param_s (*gpio_tab)[GPIO_MAX])
Stefan Roese17f50f222005-08-04 17:09:16 +02001404{
Wolfgang Denkf901a832005-08-06 01:42:58 +02001405 gpio_tab[GPIO1][8].in_out = GPIO_IN; /* UIC_IRQ(0) */
Stefan Roese17f50f222005-08-04 17:09:16 +02001406 gpio_tab[GPIO1][8].alt_nb = GPIO_ALT1;
1407
Wolfgang Denkf901a832005-08-06 01:42:58 +02001408 gpio_tab[GPIO1][9].in_out = GPIO_IN; /* UIC_IRQ(1) */
Stefan Roese17f50f222005-08-04 17:09:16 +02001409 gpio_tab[GPIO1][9].alt_nb = GPIO_ALT1;
1410
Wolfgang Denkf901a832005-08-06 01:42:58 +02001411 gpio_tab[GPIO1][10].in_out = GPIO_IN; /* UIC_IRQ(2) */
Stefan Roese17f50f222005-08-04 17:09:16 +02001412 gpio_tab[GPIO1][10].alt_nb = GPIO_ALT1;
1413
Wolfgang Denkf901a832005-08-06 01:42:58 +02001414 gpio_tab[GPIO1][11].in_out = GPIO_IN; /* UIC_IRQ(3) */
Stefan Roese17f50f222005-08-04 17:09:16 +02001415 gpio_tab[GPIO1][11].alt_nb = GPIO_ALT1;
1416}
1417
1418/*----------------------------------------------------------------------------+
1419 | update_uic_4_9_irq_ios().
1420 +----------------------------------------------------------------------------*/
Eugene OBriend2f68002007-07-31 10:24:56 +02001421void update_uic_4_9_irq_ios(gpio_param_s (*gpio_tab)[GPIO_MAX])
Stefan Roese17f50f222005-08-04 17:09:16 +02001422{
Wolfgang Denkf901a832005-08-06 01:42:58 +02001423 gpio_tab[GPIO1][12].in_out = GPIO_IN; /* UIC_IRQ(4) */
Stefan Roese17f50f222005-08-04 17:09:16 +02001424 gpio_tab[GPIO1][12].alt_nb = GPIO_ALT1;
1425
Wolfgang Denkf901a832005-08-06 01:42:58 +02001426 gpio_tab[GPIO1][13].in_out = GPIO_IN; /* UIC_IRQ(6) */
Stefan Roese17f50f222005-08-04 17:09:16 +02001427 gpio_tab[GPIO1][13].alt_nb = GPIO_ALT1;
1428
Wolfgang Denkf901a832005-08-06 01:42:58 +02001429 gpio_tab[GPIO1][14].in_out = GPIO_IN; /* UIC_IRQ(7) */
Stefan Roese17f50f222005-08-04 17:09:16 +02001430 gpio_tab[GPIO1][14].alt_nb = GPIO_ALT1;
1431
Wolfgang Denkf901a832005-08-06 01:42:58 +02001432 gpio_tab[GPIO1][15].in_out = GPIO_IN; /* UIC_IRQ(8) */
Stefan Roese17f50f222005-08-04 17:09:16 +02001433 gpio_tab[GPIO1][15].alt_nb = GPIO_ALT1;
1434
Wolfgang Denkf901a832005-08-06 01:42:58 +02001435 gpio_tab[GPIO1][16].in_out = GPIO_IN; /* UIC_IRQ(9) */
Stefan Roese17f50f222005-08-04 17:09:16 +02001436 gpio_tab[GPIO1][16].alt_nb = GPIO_ALT1;
1437}
1438
1439/*----------------------------------------------------------------------------+
1440 | update_dma_a_b_ios().
1441 +----------------------------------------------------------------------------*/
Eugene OBriend2f68002007-07-31 10:24:56 +02001442void update_dma_a_b_ios(gpio_param_s (*gpio_tab)[GPIO_MAX])
Stefan Roese17f50f222005-08-04 17:09:16 +02001443{
Wolfgang Denkf901a832005-08-06 01:42:58 +02001444 gpio_tab[GPIO1][12].in_out = GPIO_OUT; /* DMA_ACK(1) */
Stefan Roese17f50f222005-08-04 17:09:16 +02001445 gpio_tab[GPIO1][12].alt_nb = GPIO_ALT2;
1446
Wolfgang Denkf901a832005-08-06 01:42:58 +02001447 gpio_tab[GPIO1][13].in_out = GPIO_BI; /* DMA_EOT/TC(1) */
Stefan Roese17f50f222005-08-04 17:09:16 +02001448 gpio_tab[GPIO1][13].alt_nb = GPIO_ALT2;
1449
Wolfgang Denkf901a832005-08-06 01:42:58 +02001450 gpio_tab[GPIO1][14].in_out = GPIO_IN; /* DMA_REQ(0) */
Stefan Roese17f50f222005-08-04 17:09:16 +02001451 gpio_tab[GPIO1][14].alt_nb = GPIO_ALT2;
1452
Wolfgang Denkf901a832005-08-06 01:42:58 +02001453 gpio_tab[GPIO1][15].in_out = GPIO_OUT; /* DMA_ACK(0) */
Stefan Roese17f50f222005-08-04 17:09:16 +02001454 gpio_tab[GPIO1][15].alt_nb = GPIO_ALT2;
1455
Wolfgang Denkf901a832005-08-06 01:42:58 +02001456 gpio_tab[GPIO1][16].in_out = GPIO_BI; /* DMA_EOT/TC(0) */
Stefan Roese17f50f222005-08-04 17:09:16 +02001457 gpio_tab[GPIO1][16].alt_nb = GPIO_ALT2;
1458}
1459
1460/*----------------------------------------------------------------------------+
1461 | update_dma_c_d_ios().
1462 +----------------------------------------------------------------------------*/
Eugene OBriend2f68002007-07-31 10:24:56 +02001463void update_dma_c_d_ios(gpio_param_s (*gpio_tab)[GPIO_MAX])
Stefan Roese17f50f222005-08-04 17:09:16 +02001464{
Wolfgang Denkf901a832005-08-06 01:42:58 +02001465 gpio_tab[GPIO0][0].in_out = GPIO_IN; /* DMA_REQ(2) */
Stefan Roese17f50f222005-08-04 17:09:16 +02001466 gpio_tab[GPIO0][0].alt_nb = GPIO_ALT2;
1467
Wolfgang Denkf901a832005-08-06 01:42:58 +02001468 gpio_tab[GPIO0][1].in_out = GPIO_OUT; /* DMA_ACK(2) */
Stefan Roese17f50f222005-08-04 17:09:16 +02001469 gpio_tab[GPIO0][1].alt_nb = GPIO_ALT2;
1470
Wolfgang Denkf901a832005-08-06 01:42:58 +02001471 gpio_tab[GPIO0][2].in_out = GPIO_BI; /* DMA_EOT/TC(2) */
Stefan Roese17f50f222005-08-04 17:09:16 +02001472 gpio_tab[GPIO0][2].alt_nb = GPIO_ALT2;
1473
Wolfgang Denkf901a832005-08-06 01:42:58 +02001474 gpio_tab[GPIO0][3].in_out = GPIO_IN; /* DMA_REQ(3) */
Stefan Roese17f50f222005-08-04 17:09:16 +02001475 gpio_tab[GPIO0][3].alt_nb = GPIO_ALT2;
1476
Wolfgang Denkf901a832005-08-06 01:42:58 +02001477 gpio_tab[GPIO0][4].in_out = GPIO_OUT; /* DMA_ACK(3) */
Stefan Roese17f50f222005-08-04 17:09:16 +02001478 gpio_tab[GPIO0][4].alt_nb = GPIO_ALT2;
1479
Wolfgang Denkf901a832005-08-06 01:42:58 +02001480 gpio_tab[GPIO0][5].in_out = GPIO_BI; /* DMA_EOT/TC(3) */
Stefan Roese17f50f222005-08-04 17:09:16 +02001481 gpio_tab[GPIO0][5].alt_nb = GPIO_ALT2;
1482
1483}
1484
1485/*----------------------------------------------------------------------------+
1486 | update_ebc_master_ios().
1487 +----------------------------------------------------------------------------*/
Eugene OBriend2f68002007-07-31 10:24:56 +02001488void update_ebc_master_ios(gpio_param_s (*gpio_tab)[GPIO_MAX])
Stefan Roese17f50f222005-08-04 17:09:16 +02001489{
Wolfgang Denkf901a832005-08-06 01:42:58 +02001490 gpio_tab[GPIO0][27].in_out = GPIO_IN; /* EXT_EBC_REQ */
Stefan Roese17f50f222005-08-04 17:09:16 +02001491 gpio_tab[GPIO0][27].alt_nb = GPIO_ALT1;
1492
Wolfgang Denkf901a832005-08-06 01:42:58 +02001493 gpio_tab[GPIO0][29].in_out = GPIO_OUT; /* EBC_EXT_HDLA */
Stefan Roese17f50f222005-08-04 17:09:16 +02001494 gpio_tab[GPIO0][29].alt_nb = GPIO_ALT1;
1495
Wolfgang Denkf901a832005-08-06 01:42:58 +02001496 gpio_tab[GPIO0][30].in_out = GPIO_OUT; /* EBC_EXT_ACK */
Stefan Roese17f50f222005-08-04 17:09:16 +02001497 gpio_tab[GPIO0][30].alt_nb = GPIO_ALT1;
1498
Wolfgang Denkf901a832005-08-06 01:42:58 +02001499 gpio_tab[GPIO0][31].in_out = GPIO_OUT; /* EBC_EXR_BUSREQ */
Stefan Roese17f50f222005-08-04 17:09:16 +02001500 gpio_tab[GPIO0][31].alt_nb = GPIO_ALT1;
1501}
1502
1503/*----------------------------------------------------------------------------+
1504 | update_usb2_device_ios().
1505 +----------------------------------------------------------------------------*/
Eugene OBriend2f68002007-07-31 10:24:56 +02001506void update_usb2_device_ios(gpio_param_s (*gpio_tab)[GPIO_MAX])
Stefan Roese17f50f222005-08-04 17:09:16 +02001507{
Wolfgang Denkf901a832005-08-06 01:42:58 +02001508 gpio_tab[GPIO0][26].in_out = GPIO_IN; /* USB2D_RXVALID */
Stefan Roese17f50f222005-08-04 17:09:16 +02001509 gpio_tab[GPIO0][26].alt_nb = GPIO_ALT2;
1510
Wolfgang Denkf901a832005-08-06 01:42:58 +02001511 gpio_tab[GPIO0][27].in_out = GPIO_IN; /* USB2D_RXERROR */
Stefan Roese17f50f222005-08-04 17:09:16 +02001512 gpio_tab[GPIO0][27].alt_nb = GPIO_ALT2;
1513
Wolfgang Denkf901a832005-08-06 01:42:58 +02001514 gpio_tab[GPIO0][28].in_out = GPIO_OUT; /* USB2D_TXVALID */
Stefan Roese17f50f222005-08-04 17:09:16 +02001515 gpio_tab[GPIO0][28].alt_nb = GPIO_ALT2;
1516
Wolfgang Denkf901a832005-08-06 01:42:58 +02001517 gpio_tab[GPIO0][29].in_out = GPIO_OUT; /* USB2D_PAD_SUSPNDM */
Stefan Roese17f50f222005-08-04 17:09:16 +02001518 gpio_tab[GPIO0][29].alt_nb = GPIO_ALT2;
1519
Wolfgang Denkf901a832005-08-06 01:42:58 +02001520 gpio_tab[GPIO0][30].in_out = GPIO_OUT; /* USB2D_XCVRSELECT */
Stefan Roese17f50f222005-08-04 17:09:16 +02001521 gpio_tab[GPIO0][30].alt_nb = GPIO_ALT2;
1522
Wolfgang Denkf901a832005-08-06 01:42:58 +02001523 gpio_tab[GPIO0][31].in_out = GPIO_OUT; /* USB2D_TERMSELECT */
Stefan Roese17f50f222005-08-04 17:09:16 +02001524 gpio_tab[GPIO0][31].alt_nb = GPIO_ALT2;
1525
Wolfgang Denkf901a832005-08-06 01:42:58 +02001526 gpio_tab[GPIO1][0].in_out = GPIO_OUT; /* USB2D_OPMODE0 */
Stefan Roese17f50f222005-08-04 17:09:16 +02001527 gpio_tab[GPIO1][0].alt_nb = GPIO_ALT1;
1528
Wolfgang Denkf901a832005-08-06 01:42:58 +02001529 gpio_tab[GPIO1][1].in_out = GPIO_OUT; /* USB2D_OPMODE1 */
Stefan Roese17f50f222005-08-04 17:09:16 +02001530 gpio_tab[GPIO1][1].alt_nb = GPIO_ALT1;
1531
1532}
1533
1534/*----------------------------------------------------------------------------+
1535 | update_pci_patch_ios().
1536 +----------------------------------------------------------------------------*/
Eugene OBriend2f68002007-07-31 10:24:56 +02001537void update_pci_patch_ios(gpio_param_s (*gpio_tab)[GPIO_MAX])
Stefan Roese17f50f222005-08-04 17:09:16 +02001538{
Wolfgang Denkf901a832005-08-06 01:42:58 +02001539 gpio_tab[GPIO0][29].in_out = GPIO_OUT; /* EBC_EXT_HDLA */
Stefan Roese17f50f222005-08-04 17:09:16 +02001540 gpio_tab[GPIO0][29].alt_nb = GPIO_ALT1;
1541}
1542
1543/*----------------------------------------------------------------------------+
Eugene OBriend2f68002007-07-31 10:24:56 +02001544 | set_chip_gpio_configuration(unsigned char gpio_core,
1545 | gpio_param_s (*gpio_tab)[GPIO_MAX])
Stefan Roese17f50f222005-08-04 17:09:16 +02001546 | Put the core impacted by clock modification and sharing in reset.
1547 | Config the select registers to resolve the sharing depending of the config.
1548 | Configure the GPIO registers.
1549 |
1550 +----------------------------------------------------------------------------*/
Eugene OBriend2f68002007-07-31 10:24:56 +02001551void set_chip_gpio_configuration(unsigned char gpio_core, gpio_param_s (*gpio_tab)[GPIO_MAX])
Stefan Roese17f50f222005-08-04 17:09:16 +02001552{
1553 unsigned char i=0, j=0, reg_offset = 0;
1554 unsigned long gpio_reg, gpio_core_add;
1555
1556 /* GPIO config of the GPIOs 0 to 31 */
1557 for (i=0; i<GPIO_MAX; i++, j++)
1558 {
1559 if (i == GPIO_MAX/2)
1560 {
1561 reg_offset = 4;
1562 j = i-16;
1563 }
1564
1565 gpio_core_add = gpio_tab[gpio_core][i].add;
1566
1567 if ( (gpio_tab[gpio_core][i].in_out == GPIO_IN) ||
1568 (gpio_tab[gpio_core][i].in_out == GPIO_BI ))
1569 {
1570 switch (gpio_tab[gpio_core][i].alt_nb)
1571 {
1572 case GPIO_SEL:
1573 break;
1574
1575 case GPIO_ALT1:
1576 gpio_reg = in32(GPIO_IS1(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2));
1577 gpio_reg = gpio_reg | (GPIO_IN_SEL >> (j*2));
1578 out32(GPIO_IS1(gpio_core_add+reg_offset), gpio_reg);
1579 break;
1580
1581 case GPIO_ALT2:
1582 gpio_reg = in32(GPIO_IS2(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2));
1583 gpio_reg = gpio_reg | (GPIO_IN_SEL >> (j*2));
1584 out32(GPIO_IS2(gpio_core_add+reg_offset), gpio_reg);
1585 break;
1586
1587 case GPIO_ALT3:
1588 gpio_reg = in32(GPIO_IS3(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2));
1589 gpio_reg = gpio_reg | (GPIO_IN_SEL >> (j*2));
1590 out32(GPIO_IS3(gpio_core_add+reg_offset), gpio_reg);
1591 break;
1592 }
1593 }
1594 if ( (gpio_tab[gpio_core][i].in_out == GPIO_OUT) ||
1595 (gpio_tab[gpio_core][i].in_out == GPIO_BI ))
1596 {
1597
1598 switch (gpio_tab[gpio_core][i].alt_nb)
1599 {
1600 case GPIO_SEL:
1601 break;
1602 case GPIO_ALT1:
1603 gpio_reg = in32(GPIO_OS(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2));
1604 gpio_reg = gpio_reg | (GPIO_ALT1_SEL >> (j*2));
1605 out32(GPIO_OS(gpio_core_add+reg_offset), gpio_reg);
1606 gpio_reg = in32(GPIO_TS(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2));
1607 gpio_reg = gpio_reg | (GPIO_ALT1_SEL >> (j*2));
1608 out32(GPIO_TS(gpio_core_add+reg_offset), gpio_reg);
1609 break;
1610 case GPIO_ALT2:
1611 gpio_reg = in32(GPIO_OS(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2));
1612 gpio_reg = gpio_reg | (GPIO_ALT2_SEL >> (j*2));
1613 out32(GPIO_OS(gpio_core_add+reg_offset), gpio_reg);
1614 gpio_reg = in32(GPIO_TS(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2));
1615 gpio_reg = gpio_reg | (GPIO_ALT2_SEL >> (j*2));
1616 out32(GPIO_TS(gpio_core_add+reg_offset), gpio_reg);
1617 break;
1618 case GPIO_ALT3:
1619 gpio_reg = in32(GPIO_OS(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2));
1620 gpio_reg = gpio_reg | (GPIO_ALT3_SEL >> (j*2));
1621 out32(GPIO_OS(gpio_core_add+reg_offset), gpio_reg);
1622 gpio_reg = in32(GPIO_TS(gpio_core_add+reg_offset)) & ~(GPIO_MASK >> (j*2));
1623 gpio_reg = gpio_reg | (GPIO_ALT3_SEL >> (j*2));
1624 out32(GPIO_TS(gpio_core_add+reg_offset), gpio_reg);
1625 break;
1626 }
1627 }
1628 }
1629}
1630
1631/*----------------------------------------------------------------------------+
1632 | force_bup_core_selection.
1633 +----------------------------------------------------------------------------*/
1634void force_bup_core_selection(core_selection_t *core_select_P, config_validity_t *config_val_P)
1635{
1636 /* Pointer invalid */
1637 if (core_select_P == NULL)
1638 {
1639 printf("Configuration invalid pointer 1\n");
1640 for (;;)
1641 ;
1642 }
1643
1644 /* L4 Selection */
Wolfgang Denkf901a832005-08-06 01:42:58 +02001645 *(core_select_P+UART_CORE0) = CORE_SELECTED;
1646 *(core_select_P+UART_CORE1) = CORE_SELECTED;
1647 *(core_select_P+UART_CORE2) = CORE_SELECTED;
1648 *(core_select_P+UART_CORE3) = CORE_SELECTED;
Stefan Roese17f50f222005-08-04 17:09:16 +02001649
1650 /* RMII Selection */
Wolfgang Denkf901a832005-08-06 01:42:58 +02001651 *(core_select_P+RMII_SEL) = CORE_SELECTED;
Stefan Roese17f50f222005-08-04 17:09:16 +02001652
1653 /* External Interrupt 0-9 selection */
Wolfgang Denkf901a832005-08-06 01:42:58 +02001654 *(core_select_P+UIC_0_3) = CORE_SELECTED;
1655 *(core_select_P+UIC_4_9) = CORE_SELECTED;
Stefan Roese17f50f222005-08-04 17:09:16 +02001656
Stefan Roesec57c7982005-08-11 17:56:56 +02001657 *(core_select_P+SCP_CORE) = CORE_SELECTED;
1658 *(core_select_P+DMA_CHANNEL_CD) = CORE_SELECTED;
1659 *(core_select_P+PACKET_REJ_FUNC_AVAIL) = CORE_SELECTED;
Wolfgang Denkf901a832005-08-06 01:42:58 +02001660 *(core_select_P+USB1_DEVICE) = CORE_SELECTED;
Stefan Roese17f50f222005-08-04 17:09:16 +02001661
Stefan Roesec57c7982005-08-11 17:56:56 +02001662 if (is_nand_selected()) {
1663 *(core_select_P+NAND_FLASH) = CORE_SELECTED;
1664 }
1665
Stefan Roese17f50f222005-08-04 17:09:16 +02001666 *config_val_P = CONFIG_IS_VALID;
1667
1668}
1669
1670/*----------------------------------------------------------------------------+
1671 | configure_ppc440ep_pins.
1672 +----------------------------------------------------------------------------*/
1673void configure_ppc440ep_pins(void)
1674{
1675 uart_config_nb_t uart_configuration;
1676 config_validity_t config_val = CONFIG_IS_INVALID;
1677
1678 /* Create Core Selection Table */
1679 core_selection_t ppc440ep_core_selection[MAX_CORE_SELECT_NB] =
1680 {
Wolfgang Denkf901a832005-08-06 01:42:58 +02001681 CORE_NOT_SELECTED, /* IIC_CORE, */
1682 CORE_NOT_SELECTED, /* SPC_CORE, */
1683 CORE_NOT_SELECTED, /* DMA_CHANNEL_AB, */
1684 CORE_NOT_SELECTED, /* UIC_4_9, */
1685 CORE_NOT_SELECTED, /* USB2_HOST, */
1686 CORE_NOT_SELECTED, /* DMA_CHANNEL_CD, */
1687 CORE_NOT_SELECTED, /* USB2_DEVICE, */
1688 CORE_NOT_SELECTED, /* PACKET_REJ_FUNC_AVAIL, */
1689 CORE_NOT_SELECTED, /* USB1_DEVICE, */
1690 CORE_NOT_SELECTED, /* EBC_MASTER, */
1691 CORE_NOT_SELECTED, /* NAND_FLASH, */
1692 CORE_NOT_SELECTED, /* UART_CORE0, */
1693 CORE_NOT_SELECTED, /* UART_CORE1, */
1694 CORE_NOT_SELECTED, /* UART_CORE2, */
1695 CORE_NOT_SELECTED, /* UART_CORE3, */
1696 CORE_NOT_SELECTED, /* MII_SEL, */
1697 CORE_NOT_SELECTED, /* RMII_SEL, */
1698 CORE_NOT_SELECTED, /* SMII_SEL, */
1699 CORE_NOT_SELECTED, /* PACKET_REJ_FUNC_EN */
1700 CORE_NOT_SELECTED, /* UIC_0_3 */
1701 CORE_NOT_SELECTED, /* USB1_HOST */
1702 CORE_NOT_SELECTED /* PCI_PATCH */
Stefan Roese17f50f222005-08-04 17:09:16 +02001703 };
1704
Eugene OBriend2f68002007-07-31 10:24:56 +02001705 gpio_param_s gpio_tab[GPIO_GROUP_MAX][GPIO_MAX];
Stefan Roese17f50f222005-08-04 17:09:16 +02001706
1707 /* Table Default Initialisation + FPGA Access */
Eugene OBriend2f68002007-07-31 10:24:56 +02001708 init_default_gpio(gpio_tab);
1709 set_chip_gpio_configuration(GPIO0, gpio_tab);
1710 set_chip_gpio_configuration(GPIO1, gpio_tab);
Stefan Roese17f50f222005-08-04 17:09:16 +02001711
1712 /* Update Table */
1713 force_bup_core_selection(ppc440ep_core_selection, &config_val);
1714#if 0 /* test-only */
1715 /* If we are running PIBS 1, force known configuration */
1716 update_core_selection_table(ppc440ep_core_selection, &config_val);
1717#endif
1718
1719 /*----------------------------------------------------------------------------+
1720 | SDR + ios table update + fpga initialization
1721 +----------------------------------------------------------------------------*/
Wolfgang Denkf901a832005-08-06 01:42:58 +02001722 unsigned long sdr0_pfc1 = 0;
1723 unsigned long sdr0_usb0 = 0;
1724 unsigned long sdr0_mfr = 0;
Stefan Roese17f50f222005-08-04 17:09:16 +02001725
1726 /* PCI Always selected */
1727
1728 /* I2C Selection */
1729 if (ppc440ep_core_selection[IIC_CORE] == CORE_SELECTED)
1730 {
1731 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_SIS_MASK) | SDR0_PFC1_SIS_IIC1_SEL;
1732 iic1_selection_in_fpga();
1733 }
1734
1735 /* SCP Selection */
1736 if (ppc440ep_core_selection[SCP_CORE] == CORE_SELECTED)
1737 {
1738 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_SIS_MASK) | SDR0_PFC1_SIS_SCP_SEL;
1739 scp_selection_in_fpga();
1740 }
1741
1742 /* UIC 0:3 Selection */
1743 if (ppc440ep_core_selection[UIC_0_3] == CORE_SELECTED)
1744 {
Eugene OBriend2f68002007-07-31 10:24:56 +02001745 update_uic_0_3_irq_ios(gpio_tab);
Stefan Roese17f50f222005-08-04 17:09:16 +02001746 dma_a_b_unselect_in_fpga();
1747 }
1748
1749 /* UIC 4:9 Selection */
1750 if (ppc440ep_core_selection[UIC_4_9] == CORE_SELECTED)
1751 {
1752 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_DIS_MASK) | SDR0_PFC1_DIS_UICIRQ5_SEL;
Eugene OBriend2f68002007-07-31 10:24:56 +02001753 update_uic_4_9_irq_ios(gpio_tab);
Stefan Roese17f50f222005-08-04 17:09:16 +02001754 }
1755
1756 /* DMA AB Selection */
1757 if (ppc440ep_core_selection[DMA_CHANNEL_AB] == CORE_SELECTED)
1758 {
1759 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_DIS_MASK) | SDR0_PFC1_DIS_DMAR_SEL;
Eugene OBriend2f68002007-07-31 10:24:56 +02001760 update_dma_a_b_ios(gpio_tab);
Stefan Roese17f50f222005-08-04 17:09:16 +02001761 dma_a_b_selection_in_fpga();
1762 }
1763
1764 /* DMA CD Selection */
1765 if (ppc440ep_core_selection[DMA_CHANNEL_CD] == CORE_SELECTED)
1766 {
Eugene OBriend2f68002007-07-31 10:24:56 +02001767 update_dma_c_d_ios(gpio_tab);
Stefan Roese17f50f222005-08-04 17:09:16 +02001768 dma_c_d_selection_in_fpga();
1769 }
1770
1771 /* EBC Master Selection */
1772 if (ppc440ep_core_selection[EBC_MASTER] == CORE_SELECTED)
1773 {
1774 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_ERE_MASK) | SDR0_PFC1_ERE_EXTR_SEL;
1775 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_UES_MASK) | SDR0_PFC1_UES_EBCHR_SEL;
Eugene OBriend2f68002007-07-31 10:24:56 +02001776 update_ebc_master_ios(gpio_tab);
Stefan Roese17f50f222005-08-04 17:09:16 +02001777 }
1778
1779 /* PCI Patch Enable */
1780 if (ppc440ep_core_selection[PCI_PATCH] == CORE_SELECTED)
1781 {
1782 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_UES_MASK) | SDR0_PFC1_UES_EBCHR_SEL;
Eugene OBriend2f68002007-07-31 10:24:56 +02001783 update_pci_patch_ios(gpio_tab);
Stefan Roese17f50f222005-08-04 17:09:16 +02001784 }
1785
1786 /* USB2 Host Selection - Not Implemented in PowerPC 440EP Pass1 */
1787 if (ppc440ep_core_selection[USB2_HOST] == CORE_SELECTED)
1788 {
1789 /* Not Implemented in PowerPC 440EP Pass1-Pass2 */
1790 printf("Invalid configuration => USB2 Host selected\n");
1791 for (;;)
1792 ;
1793 /*usb2_host_selection_in_fpga(); */
1794 }
1795
1796 /* USB2.0 Device Selection */
1797 if (ppc440ep_core_selection[USB2_DEVICE] == CORE_SELECTED)
1798 {
Eugene OBriend2f68002007-07-31 10:24:56 +02001799 update_usb2_device_ios(gpio_tab);
Stefan Roese17f50f222005-08-04 17:09:16 +02001800 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_UES_MASK) | SDR0_PFC1_UES_USB2D_SEL;
1801 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_UPR_MASK) | SDR0_PFC1_UPR_DISABLE;
1802
Stefan Roesed1c3b272009-09-09 16:25:29 +02001803 mfsdr(SDR0_USB0, sdr0_usb0);
Stefan Roese17f50f222005-08-04 17:09:16 +02001804 sdr0_usb0 = sdr0_usb0 &~SDR0_USB0_USB_DEVSEL_MASK;
1805 sdr0_usb0 = sdr0_usb0 | SDR0_USB0_USB20D_DEVSEL;
Stefan Roesed1c3b272009-09-09 16:25:29 +02001806 mtsdr(SDR0_USB0, sdr0_usb0);
Stefan Roese17f50f222005-08-04 17:09:16 +02001807
1808 usb2_device_selection_in_fpga();
1809 }
1810
1811 /* USB1.1 Device Selection */
1812 if (ppc440ep_core_selection[USB1_DEVICE] == CORE_SELECTED)
1813 {
Stefan Roesed1c3b272009-09-09 16:25:29 +02001814 mfsdr(SDR0_USB0, sdr0_usb0);
Stefan Roese17f50f222005-08-04 17:09:16 +02001815 sdr0_usb0 = sdr0_usb0 &~SDR0_USB0_USB_DEVSEL_MASK;
1816 sdr0_usb0 = sdr0_usb0 | SDR0_USB0_USB11D_DEVSEL;
Stefan Roesed1c3b272009-09-09 16:25:29 +02001817 mtsdr(SDR0_USB0, sdr0_usb0);
Stefan Roese17f50f222005-08-04 17:09:16 +02001818 }
1819
1820 /* USB1.1 Host Selection */
1821 if (ppc440ep_core_selection[USB1_HOST] == CORE_SELECTED)
1822 {
Stefan Roesed1c3b272009-09-09 16:25:29 +02001823 mfsdr(SDR0_USB0, sdr0_usb0);
Stefan Roese17f50f222005-08-04 17:09:16 +02001824 sdr0_usb0 = sdr0_usb0 &~SDR0_USB0_LEEN_MASK;
1825 sdr0_usb0 = sdr0_usb0 | SDR0_USB0_LEEN_ENABLE;
Stefan Roesed1c3b272009-09-09 16:25:29 +02001826 mtsdr(SDR0_USB0, sdr0_usb0);
Stefan Roese17f50f222005-08-04 17:09:16 +02001827 }
1828
1829 /* NAND Flash Selection */
1830 if (ppc440ep_core_selection[NAND_FLASH] == CORE_SELECTED)
1831 {
Eugene OBriend2f68002007-07-31 10:24:56 +02001832 update_ndfc_ios(gpio_tab);
Stefan Roese17f50f222005-08-04 17:09:16 +02001833
Stefan Roesea471db02007-06-01 15:19:29 +02001834#if !(defined(CONFIG_NAND_U_BOOT) || defined(CONFIG_NAND_SPL))
Stefan Roesed1c3b272009-09-09 16:25:29 +02001835 mtsdr(SDR0_CUST0, SDR0_CUST0_MUX_NDFC_SEL |
Wolfgang Denkf901a832005-08-06 01:42:58 +02001836 SDR0_CUST0_NDFC_ENABLE |
1837 SDR0_CUST0_NDFC_BW_8_BIT |
1838 SDR0_CUST0_NDFC_ARE_MASK |
Stefan Roesec57c7982005-08-11 17:56:56 +02001839 SDR0_CUST0_CHIPSELGAT_EN1 |
1840 SDR0_CUST0_CHIPSELGAT_EN2);
Stefan Roesea471db02007-06-01 15:19:29 +02001841#else
Stefan Roesed1c3b272009-09-09 16:25:29 +02001842 mtsdr(SDR0_CUST0, SDR0_CUST0_MUX_NDFC_SEL |
Stefan Roesea471db02007-06-01 15:19:29 +02001843 SDR0_CUST0_NDFC_ENABLE |
1844 SDR0_CUST0_NDFC_BW_8_BIT |
1845 SDR0_CUST0_NDFC_ARE_MASK |
1846 SDR0_CUST0_CHIPSELGAT_EN0 |
1847 SDR0_CUST0_CHIPSELGAT_EN2);
1848#endif
Stefan Roese17f50f222005-08-04 17:09:16 +02001849
1850 ndfc_selection_in_fpga();
1851 }
1852 else
1853 {
1854 /* Set Mux on EMAC */
Stefan Roesed1c3b272009-09-09 16:25:29 +02001855 mtsdr(SDR0_CUST0, SDR0_CUST0_MUX_EMAC_SEL);
Stefan Roese17f50f222005-08-04 17:09:16 +02001856 }
1857
1858 /* MII Selection */
1859 if (ppc440ep_core_selection[MII_SEL] == CORE_SELECTED)
1860 {
Eugene OBriend2f68002007-07-31 10:24:56 +02001861 update_zii_ios(gpio_tab);
Stefan Roesed1c3b272009-09-09 16:25:29 +02001862 mfsdr(SDR0_MFR, sdr0_mfr);
Stefan Roese17f50f222005-08-04 17:09:16 +02001863 sdr0_mfr = (sdr0_mfr & ~SDR0_MFR_ZMII_MODE_MASK) | SDR0_MFR_ZMII_MODE_MII;
Stefan Roesed1c3b272009-09-09 16:25:29 +02001864 mtsdr(SDR0_MFR, sdr0_mfr);
Stefan Roese17f50f222005-08-04 17:09:16 +02001865
1866 set_phy_configuration_through_fpga(ZMII_CONFIGURATION_IS_MII);
1867 }
1868
1869 /* RMII Selection */
1870 if (ppc440ep_core_selection[RMII_SEL] == CORE_SELECTED)
1871 {
Eugene OBriend2f68002007-07-31 10:24:56 +02001872 update_zii_ios(gpio_tab);
Stefan Roesed1c3b272009-09-09 16:25:29 +02001873 mfsdr(SDR0_MFR, sdr0_mfr);
Stefan Roese17f50f222005-08-04 17:09:16 +02001874 sdr0_mfr = (sdr0_mfr & ~SDR0_MFR_ZMII_MODE_MASK) | SDR0_MFR_ZMII_MODE_RMII_10M;
Stefan Roesed1c3b272009-09-09 16:25:29 +02001875 mtsdr(SDR0_MFR, sdr0_mfr);
Stefan Roese17f50f222005-08-04 17:09:16 +02001876
1877 set_phy_configuration_through_fpga(ZMII_CONFIGURATION_IS_RMII);
1878 }
1879
1880 /* SMII Selection */
1881 if (ppc440ep_core_selection[SMII_SEL] == CORE_SELECTED)
1882 {
Eugene OBriend2f68002007-07-31 10:24:56 +02001883 update_zii_ios(gpio_tab);
Stefan Roesed1c3b272009-09-09 16:25:29 +02001884 mfsdr(SDR0_MFR, sdr0_mfr);
Stefan Roese17f50f222005-08-04 17:09:16 +02001885 sdr0_mfr = (sdr0_mfr & ~SDR0_MFR_ZMII_MODE_MASK) | SDR0_MFR_ZMII_MODE_SMII;
Stefan Roesed1c3b272009-09-09 16:25:29 +02001886 mtsdr(SDR0_MFR, sdr0_mfr);
Stefan Roese17f50f222005-08-04 17:09:16 +02001887
1888 set_phy_configuration_through_fpga(ZMII_CONFIGURATION_IS_SMII);
1889 }
1890
1891 /* UART Selection */
1892 uart_configuration = get_uart_configuration();
1893 switch (uart_configuration)
1894 {
Wolfgang Denkf901a832005-08-06 01:42:58 +02001895 case L1: /* L1 Selection */
Stefan Roese17f50f222005-08-04 17:09:16 +02001896 /* UART0 8 pins Only */
1897 /*sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0ME_MASK) | SDR0_PFC1_U0ME_DSR_DTR; */
Wolfgang Denkf901a832005-08-06 01:42:58 +02001898 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0ME_MASK) |SDR0_PFC1_U0ME_CTS_RTS; /* Chip Pb */
Stefan Roese17f50f222005-08-04 17:09:16 +02001899 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0IM_MASK) | SDR0_PFC1_U0IM_8PINS;
1900 break;
Wolfgang Denkf901a832005-08-06 01:42:58 +02001901 case L2: /* L2 Selection */
Stefan Roese17f50f222005-08-04 17:09:16 +02001902 /* UART0 and UART1 4 pins */
1903 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0ME_MASK) | SDR0_PFC1_U1ME_DSR_DTR;
1904 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0IM_MASK) | SDR0_PFC1_U0IM_4PINS;
1905 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U1ME_MASK) | SDR0_PFC1_U1ME_DSR_DTR;
1906 break;
Wolfgang Denkf901a832005-08-06 01:42:58 +02001907 case L3: /* L3 Selection */
Stefan Roese17f50f222005-08-04 17:09:16 +02001908 /* UART0 4 pins, UART1 and UART2 2 pins */
1909 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0ME_MASK) | SDR0_PFC1_U1ME_DSR_DTR;
1910 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0IM_MASK) | SDR0_PFC1_U0IM_4PINS;
1911 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U1ME_MASK) | SDR0_PFC1_U1ME_DSR_DTR;
1912 break;
Wolfgang Denkf901a832005-08-06 01:42:58 +02001913 case L4: /* L4 Selection */
Stefan Roese17f50f222005-08-04 17:09:16 +02001914 /* UART0, UART1, UART2 and UART3 2 pins */
1915 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0ME_MASK) | SDR0_PFC1_U0ME_DSR_DTR;
1916 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0IM_MASK) | SDR0_PFC1_U0IM_4PINS;
1917 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U1ME_MASK) | SDR0_PFC1_U1ME_DSR_DTR;
1918 break;
1919 }
Eugene OBriend2f68002007-07-31 10:24:56 +02001920 update_uart_ios(uart_configuration, gpio_tab);
Stefan Roese17f50f222005-08-04 17:09:16 +02001921
1922 /* UART Selection in all cases */
1923 uart_selection_in_fpga(uart_configuration);
1924
1925 /* Packet Reject Function Available */
1926 if (ppc440ep_core_selection[PACKET_REJ_FUNC_AVAIL] == CORE_SELECTED)
1927 {
1928 /* Set UPR Bit in SDR0_PFC1 Register */
1929 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_UPR_MASK) | SDR0_PFC1_UPR_ENABLE;
1930 }
1931
1932 /* Packet Reject Function Enable */
1933 if (ppc440ep_core_selection[PACKET_REJ_FUNC_EN] == CORE_SELECTED)
1934 {
Stefan Roesed1c3b272009-09-09 16:25:29 +02001935 mfsdr(SDR0_MFR, sdr0_mfr);
Stefan Roese17f50f222005-08-04 17:09:16 +02001936 sdr0_mfr = (sdr0_mfr & ~SDR0_MFR_PKT_REJ_MASK) | SDR0_MFR_PKT_REJ_EN;;
Stefan Roesed1c3b272009-09-09 16:25:29 +02001937 mtsdr(SDR0_MFR, sdr0_mfr);
Stefan Roese17f50f222005-08-04 17:09:16 +02001938 }
1939
1940 /* Perform effective access to hardware */
Stefan Roesed1c3b272009-09-09 16:25:29 +02001941 mtsdr(SDR0_PFC1, sdr0_pfc1);
Eugene OBriend2f68002007-07-31 10:24:56 +02001942 set_chip_gpio_configuration(GPIO0, gpio_tab);
1943 set_chip_gpio_configuration(GPIO1, gpio_tab);
Stefan Roese17f50f222005-08-04 17:09:16 +02001944
1945 /* USB2.0 Device Reset must be done after GPIO setting */
1946 if (ppc440ep_core_selection[USB2_DEVICE] == CORE_SELECTED)
1947 usb2_device_reset_through_fpga();
1948
1949}