blob: cfc1023f4fcb5d267c8d80b3e6159057cde323df [file] [log] [blame]
Stefan Roese8e1a3fe2008-03-11 16:51:17 +01001/*
2 * (C) Copyright 2008
3 * Stefan Roese, DENX Software Engineering, sr@denx.de.
4 *
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
18 * MA 02111-1307 USA
19 */
20
21#include <common.h>
22#include <ppc440.h>
23#include <libfdt.h>
24#include <fdt_support.h>
Stefan Roese212ed902008-06-10 15:34:11 +020025#include <i2c.h>
Stefan Roese8e1a3fe2008-03-11 16:51:17 +010026#include <asm/processor.h>
27#include <asm/io.h>
28#include <asm/mmu.h>
29#include <asm/4xx_pcie.h>
Stefan Roese41712b42008-03-05 12:31:53 +010030#include <asm/gpio.h>
Stefan Roese8e1a3fe2008-03-11 16:51:17 +010031
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020032extern flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* info for FLASH chips */
Stefan Roese8e1a3fe2008-03-11 16:51:17 +010033
34DECLARE_GLOBAL_DATA_PTR;
35
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020036#define CONFIG_SYS_BCSR3_PCIE 0x10
Stefan Roesecc8e8392008-03-28 14:09:04 +010037
38#define BOARD_CANYONLANDS_PCIE 1
39#define BOARD_CANYONLANDS_SATA 2
40#define BOARD_GLACIER 3
Adam Grahamf09f09d2008-10-08 10:12:53 -070041#define BOARD_ARCHES 4
42
43#if defined(CONFIG_ARCHES)
44/*
45 * FPGA read/write helper macros
46 */
47static inline int board_fpga_read(int offset)
48{
49 int data;
50
51 data = in_8((void *)(CONFIG_SYS_FPGA_BASE + offset));
52
53 return data;
54}
55
56static inline void board_fpga_write(int offset, int data)
57{
58 out_8((void *)(CONFIG_SYS_FPGA_BASE + offset), data);
59}
60
61/*
62 * CPLD read/write helper macros
63 */
64static inline int board_cpld_read(int offset)
65{
66 int data;
67
68 out_8((void *)(CONFIG_SYS_CPLD_ADDR), offset);
69 data = in_8((void *)(CONFIG_SYS_CPLD_DATA));
70
71 return data;
72}
73
74static inline void board_cpld_write(int offset, int data)
75{
76 out_8((void *)(CONFIG_SYS_CPLD_ADDR), offset);
77 out_8((void *)(CONFIG_SYS_CPLD_DATA), data);
78}
79#endif /* defined(CONFIG_ARCHES) */
Stefan Roesecc8e8392008-03-28 14:09:04 +010080
Stefan Roese8e1a3fe2008-03-11 16:51:17 +010081int board_early_init_f(void)
82{
Adam Grahamf09f09d2008-10-08 10:12:53 -070083#if !defined(CONFIG_ARCHES)
Stefan Roese8e1a3fe2008-03-11 16:51:17 +010084 u32 sdr0_cust0;
Stefan Roese4c9e8552008-03-19 16:20:49 +010085 u32 pvr = get_pvr();
Adam Grahamf09f09d2008-10-08 10:12:53 -070086#endif
Stefan Roese8e1a3fe2008-03-11 16:51:17 +010087
Stefan Roese1c2926a2008-04-02 08:39:33 +020088 /*
Stefan Roese8e1a3fe2008-03-11 16:51:17 +010089 * Setup the interrupt controller polarities, triggers, etc.
Stefan Roese1c2926a2008-04-02 08:39:33 +020090 */
Stefan Roese8e1a3fe2008-03-11 16:51:17 +010091 mtdcr(uic0sr, 0xffffffff); /* clear all */
92 mtdcr(uic0er, 0x00000000); /* disable all */
93 mtdcr(uic0cr, 0x00000005); /* ATI & UIC1 crit are critical */
94 mtdcr(uic0pr, 0xffffffff); /* per ref-board manual */
95 mtdcr(uic0tr, 0x00000000); /* per ref-board manual */
96 mtdcr(uic0vr, 0x00000000); /* int31 highest, base=0x000 */
97 mtdcr(uic0sr, 0xffffffff); /* clear all */
98
99 mtdcr(uic1sr, 0xffffffff); /* clear all */
100 mtdcr(uic1er, 0x00000000); /* disable all */
101 mtdcr(uic1cr, 0x00000000); /* all non-critical */
102 mtdcr(uic1pr, 0xffffffff); /* per ref-board manual */
103 mtdcr(uic1tr, 0x00000000); /* per ref-board manual */
104 mtdcr(uic1vr, 0x00000000); /* int31 highest, base=0x000 */
105 mtdcr(uic1sr, 0xffffffff); /* clear all */
106
107 mtdcr(uic2sr, 0xffffffff); /* clear all */
108 mtdcr(uic2er, 0x00000000); /* disable all */
109 mtdcr(uic2cr, 0x00000000); /* all non-critical */
110 mtdcr(uic2pr, 0xffffffff); /* per ref-board manual */
111 mtdcr(uic2tr, 0x00000000); /* per ref-board manual */
112 mtdcr(uic2vr, 0x00000000); /* int31 highest, base=0x000 */
113 mtdcr(uic2sr, 0xffffffff); /* clear all */
114
115 mtdcr(uic3sr, 0xffffffff); /* clear all */
116 mtdcr(uic3er, 0x00000000); /* disable all */
117 mtdcr(uic3cr, 0x00000000); /* all non-critical */
118 mtdcr(uic3pr, 0xffffffff); /* per ref-board manual */
119 mtdcr(uic3tr, 0x00000000); /* per ref-board manual */
120 mtdcr(uic3vr, 0x00000000); /* int31 highest, base=0x000 */
121 mtdcr(uic3sr, 0xffffffff); /* clear all */
122
Adam Grahamf09f09d2008-10-08 10:12:53 -0700123#if !defined(CONFIG_ARCHES)
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100124 /* SDR Setting - enable NDFC */
125 mfsdr(SDR0_CUST0, sdr0_cust0);
126 sdr0_cust0 = SDR0_CUST0_MUX_NDFC_SEL |
127 SDR0_CUST0_NDFC_ENABLE |
128 SDR0_CUST0_NDFC_BW_8_BIT |
129 SDR0_CUST0_NDFC_ARE_MASK |
130 SDR0_CUST0_NDFC_BAC_ENCODE(3) |
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200131 (0x80000000 >> (28 + CONFIG_SYS_NAND_CS));
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100132 mtsdr(SDR0_CUST0, sdr0_cust0);
Adam Grahamf09f09d2008-10-08 10:12:53 -0700133#endif
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100134
135 /*
136 * Configure PFC (Pin Function Control) registers
137 * UART0: 4 pins
138 */
139 mtsdr(SDR0_PFC1, 0x00040000);
140
141 /* Enable PCI host functionality in SDR0_PCI0 */
142 mtsdr(SDR0_PCI0, 0xe0000000);
143
Adam Grahamf09f09d2008-10-08 10:12:53 -0700144#if !defined(CONFIG_ARCHES)
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100145 /* Enable ethernet and take out of reset */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200146 out_8((void *)CONFIG_SYS_BCSR_BASE + 6, 0);
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100147
148 /* Remove NOR-FLASH, NAND-FLASH & EEPROM hardware write protection */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200149 out_8((void *)CONFIG_SYS_BCSR_BASE + 5, 0);
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100150
151 /* Enable USB host & USB-OTG */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200152 out_8((void *)CONFIG_SYS_BCSR_BASE + 7, 0);
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100153
154 mtsdr(SDR0_SRST1, 0); /* Pull AHB out of reset default=1 */
155
Stefan Roese41712b42008-03-05 12:31:53 +0100156 /* Setup PLB4-AHB bridge based on the system address map */
157 mtdcr(AHB_TOP, 0x8000004B);
158 mtdcr(AHB_BOT, 0x8000004B);
159
Stefan Roese4c9e8552008-03-19 16:20:49 +0100160 if ((pvr == PVR_460EX_RA) || (pvr == PVR_460EX_SE_RA)) {
161 /*
162 * Configure USB-STP pins as alternate and not GPIO
163 * It seems to be neccessary to configure the STP pins as GPIO
164 * input at powerup (perhaps while USB reset is asserted). So
165 * we configure those pins to their "real" function now.
166 */
167 gpio_config(16, GPIO_OUT, GPIO_ALT1, GPIO_OUT_1);
168 gpio_config(19, GPIO_OUT, GPIO_ALT1, GPIO_OUT_1);
169 }
Adam Grahamf09f09d2008-10-08 10:12:53 -0700170#endif
Stefan Roese41712b42008-03-05 12:31:53 +0100171
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100172 return 0;
173}
174
Adam Grahamf09f09d2008-10-08 10:12:53 -0700175#if !defined(CONFIG_ARCHES)
Stefan Roese1c2926a2008-04-02 08:39:33 +0200176static void canyonlands_sata_init(int board_type)
177{
178 u32 reg;
179
180 if (board_type == BOARD_CANYONLANDS_SATA) {
181 /* Put SATA in reset */
182 SDR_WRITE(SDR0_SRST1, 0x00020001);
183
184 /* Set the phy for SATA, not PCI-E port 0 */
185 reg = SDR_READ(PESDR0_PHY_CTL_RST);
186 SDR_WRITE(PESDR0_PHY_CTL_RST, (reg & 0xeffffffc) | 0x00000001);
187 reg = SDR_READ(PESDR0_L0CLK);
188 SDR_WRITE(PESDR0_L0CLK, (reg & 0xfffffff8) | 0x00000007);
189 SDR_WRITE(PESDR0_L0CDRCTL, 0x00003111);
190 SDR_WRITE(PESDR0_L0DRV, 0x00000104);
191
192 /* Bring SATA out of reset */
193 SDR_WRITE(SDR0_SRST1, 0x00000000);
194 }
195}
Adam Grahamf09f09d2008-10-08 10:12:53 -0700196#endif /* !defined(CONFIG_ARCHES) */
Stefan Roese1c2926a2008-04-02 08:39:33 +0200197
Adam Grahamf09f09d2008-10-08 10:12:53 -0700198int get_cpu_num(void)
199{
200 int cpu = NA_OR_UNKNOWN_CPU;
201
202#if defined(CONFIG_ARCHES)
203 int cpu_num;
204
205 cpu_num = board_fpga_read(0x3);
206
207 /* sanity check; assume cpu numbering starts and increments from 0 */
208 if ((cpu_num >= 0) && (cpu_num < CONFIG_BD_NUM_CPUS))
209 cpu = cpu_num;
210#endif
211
212 return cpu;
213}
214
215#if !defined(CONFIG_ARCHES)
Stefan Roese1c2926a2008-04-02 08:39:33 +0200216int checkboard(void)
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100217{
218 char *s = getenv("serial#");
219 u32 pvr = get_pvr();
220
Stefan Roesecc8e8392008-03-28 14:09:04 +0100221 if ((pvr == PVR_460GT_RA) || (pvr == PVR_460GT_SE_RA)) {
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100222 printf("Board: Glacier - AMCC PPC460GT Evaluation Board");
Stefan Roesecc8e8392008-03-28 14:09:04 +0100223 gd->board_type = BOARD_GLACIER;
224 } else {
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100225 printf("Board: Canyonlands - AMCC PPC460EX Evaluation Board");
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200226 if (in_8((void *)(CONFIG_SYS_BCSR_BASE + 3)) & CONFIG_SYS_BCSR3_PCIE)
Stefan Roesecc8e8392008-03-28 14:09:04 +0100227 gd->board_type = BOARD_CANYONLANDS_PCIE;
228 else
229 gd->board_type = BOARD_CANYONLANDS_SATA;
230 }
231
232 switch (gd->board_type) {
233 case BOARD_CANYONLANDS_PCIE:
234 case BOARD_GLACIER:
235 puts(", 2*PCIe");
236 break;
237
238 case BOARD_CANYONLANDS_SATA:
239 puts(", 1*PCIe/1*SATA");
240 break;
241 }
242
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200243 printf(", Rev. %X", in_8((void *)(CONFIG_SYS_BCSR_BASE + 0)));
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100244
245 if (s != NULL) {
246 puts(", serial# ");
247 puts(s);
248 }
249 putc('\n');
250
Stefan Roese1c2926a2008-04-02 08:39:33 +0200251 canyonlands_sata_init(gd->board_type);
252
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100253 return (0);
254}
255
Adam Grahamf09f09d2008-10-08 10:12:53 -0700256#else /* defined(CONFIG_ARCHES) */
257
258int checkboard(void)
259{
260 char *s = getenv("serial#");
261
262 printf("Board: Arches - AMCC DUAL PPC460GT Reference Design\n");
263 printf(" Revision %02x.%02x ",
264 board_fpga_read(0x0), board_fpga_read(0x1));
265
266 gd->board_type = BOARD_ARCHES;
267
268 /* Only CPU0 has access to CPLD registers */
269 if (get_cpu_num() == 0) {
270 u8 cfg_sw = board_cpld_read(0x1);
271 printf("(FPGA=%02x, CPLD=%02x)\n",
272 board_fpga_read(0x2), board_cpld_read(0x0));
273 printf(" Configuration Switch %d%d%d%d\n",
274 ((cfg_sw >> 3) & 0x01),
275 ((cfg_sw >> 2) & 0x01),
276 ((cfg_sw >> 1) & 0x01),
277 ((cfg_sw >> 0) & 0x01));
278 } else
279 printf("(FPGA=%02x, CPLD=xx)\n", board_fpga_read(0x2));
280
281
282 if (s != NULL)
283 printf(" Serial# %s\n", s);
284
285 return 0;
286}
287#endif /* !defined(CONFIG_ARCHES) */
288
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100289/*
290 * Override the default functions in cpu/ppc4xx/44x_spd_ddr2.c with
291 * board specific values.
292 */
293u32 ddr_wrdtr(u32 default_val) {
294 return (SDRAM_WRDTR_LLWP_1_CYC | SDRAM_WRDTR_WTR_180_DEG_ADV | 0x823);
295}
296
297u32 ddr_clktr(u32 default_val) {
298 return (SDRAM_CLKTR_CLKP_90_DEG_ADV);
299}
300
Stefan Roese71665eb2008-03-03 17:27:02 +0100301#if defined(CONFIG_NAND_U_BOOT)
302/*
303 * NAND booting U-Boot version uses a fixed initialization, since the whole
304 * I2C SPD DIMM autodetection/calibration doesn't fit into the 4k of boot
305 * code.
306 */
Becky Bruce9973e3c2008-06-09 16:03:40 -0500307phys_size_t initdram(int board_type)
Stefan Roese71665eb2008-03-03 17:27:02 +0100308{
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200309 return CONFIG_SYS_MBYTES_SDRAM << 20;
Stefan Roese71665eb2008-03-03 17:27:02 +0100310}
311#endif
312
Stefan Roese1c2926a2008-04-02 08:39:33 +0200313/*
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100314 * pci_target_init
315 *
316 * The bootstrap configuration provides default settings for the pci
317 * inbound map (PIM). But the bootstrap config choices are limited and
318 * may not be sufficient for a given board.
Stefan Roese1c2926a2008-04-02 08:39:33 +0200319 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200320#if defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_TARGET_INIT)
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100321void pci_target_init(struct pci_controller * hose )
322{
Stefan Roese1c2926a2008-04-02 08:39:33 +0200323 /*
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100324 * Disable everything
Stefan Roese1c2926a2008-04-02 08:39:33 +0200325 */
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100326 out_le32((void *)PCIX0_PIM0SA, 0); /* disable */
327 out_le32((void *)PCIX0_PIM1SA, 0); /* disable */
328 out_le32((void *)PCIX0_PIM2SA, 0); /* disable */
329 out_le32((void *)PCIX0_EROMBA, 0); /* disable expansion rom */
330
Stefan Roese1c2926a2008-04-02 08:39:33 +0200331 /*
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100332 * Map all of SDRAM to PCI address 0x0000_0000. Note that the 440
333 * strapping options to not support sizes such as 128/256 MB.
Stefan Roese1c2926a2008-04-02 08:39:33 +0200334 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200335 out_le32((void *)PCIX0_PIM0LAL, CONFIG_SYS_SDRAM_BASE);
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100336 out_le32((void *)PCIX0_PIM0LAH, 0);
337 out_le32((void *)PCIX0_PIM0SA, ~(gd->ram_size - 1) | 1);
338 out_le32((void *)PCIX0_BAR0, 0);
339
Stefan Roese1c2926a2008-04-02 08:39:33 +0200340 /*
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100341 * Program the board's subsystem id/vendor id
Stefan Roese1c2926a2008-04-02 08:39:33 +0200342 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200343 out_le16((void *)PCIX0_SBSYSVID, CONFIG_SYS_PCI_SUBSYS_VENDORID);
344 out_le16((void *)PCIX0_SBSYSID, CONFIG_SYS_PCI_SUBSYS_DEVICEID);
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100345
346 out_le16((void *)PCIX0_CMD, in16r(PCIX0_CMD) | PCI_COMMAND_MEMORY);
347}
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200348#endif /* defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_TARGET_INIT) */
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100349
350#if defined(CONFIG_PCI)
351/*
352 * is_pci_host
353 *
354 * This routine is called to determine if a pci scan should be
355 * performed. With various hardware environments (especially cPCI and
356 * PPMC) it's insufficient to depend on the state of the arbiter enable
357 * bit in the strap register, or generic host/adapter assumptions.
358 *
359 * Rather than hard-code a bad assumption in the general 440 code, the
360 * 440 pci code requires the board to decide at runtime.
361 *
362 * Return 0 for adapter mode, non-zero for host (monarch) mode.
363 */
364int is_pci_host(struct pci_controller *hose)
365{
366 /* Board is always configured as host. */
367 return (1);
368}
369
370static struct pci_controller pcie_hose[2] = {{0},{0}};
371
372void pcie_setup_hoses(int busno)
373{
374 struct pci_controller *hose;
375 int i, bus;
376 int ret = 0;
377 char *env;
378 unsigned int delay;
Stefan Roesecc8e8392008-03-28 14:09:04 +0100379 int start;
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100380
381 /*
382 * assume we're called after the PCIX hose is initialized, which takes
383 * bus ID 0 and therefore start numbering PCIe's from 1.
384 */
385 bus = busno;
Stefan Roesecc8e8392008-03-28 14:09:04 +0100386
387 /*
388 * Canyonlands with SATA enabled has only one PCIe slot
389 * (2nd one).
390 */
391 if (gd->board_type == BOARD_CANYONLANDS_SATA)
392 start = 1;
393 else
394 start = 0;
395
396 for (i = start; i <= 1; i++) {
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100397
398 if (is_end_point(i))
399 ret = ppc4xx_init_pcie_endport(i);
400 else
401 ret = ppc4xx_init_pcie_rootport(i);
402 if (ret) {
403 printf("PCIE%d: initialization as %s failed\n", i,
404 is_end_point(i) ? "endpoint" : "root-complex");
405 continue;
406 }
407
408 hose = &pcie_hose[i];
409 hose->first_busno = bus;
410 hose->last_busno = bus;
411 hose->current_busno = bus;
412
413 /* setup mem resource */
414 pci_set_region(hose->regions + 0,
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200415 CONFIG_SYS_PCIE_MEMBASE + i * CONFIG_SYS_PCIE_MEMSIZE,
416 CONFIG_SYS_PCIE_MEMBASE + i * CONFIG_SYS_PCIE_MEMSIZE,
417 CONFIG_SYS_PCIE_MEMSIZE,
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100418 PCI_REGION_MEM);
419 hose->region_count = 1;
420 pci_register_hose(hose);
421
422 if (is_end_point(i)) {
423 ppc4xx_setup_pcie_endpoint(hose, i);
424 /*
425 * Reson for no scanning is endpoint can not generate
426 * upstream configuration accesses.
427 */
428 } else {
429 ppc4xx_setup_pcie_rootpoint(hose, i);
430 env = getenv ("pciscandelay");
431 if (env != NULL) {
432 delay = simple_strtoul(env, NULL, 10);
433 if (delay > 5)
434 printf("Warning, expect noticable delay before "
435 "PCIe scan due to 'pciscandelay' value!\n");
436 mdelay(delay * 1000);
437 }
438
439 /*
440 * Config access can only go down stream
441 */
442 hose->last_busno = pci_hose_scan(hose);
443 bus = hose->last_busno + 1;
444 }
445 }
446}
447#endif /* CONFIG_PCI */
448
449int board_early_init_r (void)
450{
451 /*
452 * Canyonlands has 64MBytes of NOR FLASH (Spansion 29GL512), but the
453 * boot EBC mapping only supports a maximum of 16MBytes
454 * (4.ff00.0000 - 4.ffff.ffff).
455 * To solve this problem, the FLASH has to get remapped to another
456 * EBC address which accepts bigger regions:
457 *
458 * 0xfc00.0000 -> 4.cc00.0000
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100459 */
460
461 /* Remap the NOR FLASH to 0xcc00.0000 ... 0xcfff.ffff */
Stefan Roese71665eb2008-03-03 17:27:02 +0100462#if defined(CONFIG_NAND_U_BOOT) || defined(CONFIG_NAND_SPL)
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200463 mtebc(pb3cr, CONFIG_SYS_FLASH_BASE_PHYS_L | 0xda000);
Stefan Roese71665eb2008-03-03 17:27:02 +0100464#else
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200465 mtebc(pb0cr, CONFIG_SYS_FLASH_BASE_PHYS_L | 0xda000);
Stefan Roese71665eb2008-03-03 17:27:02 +0100466#endif
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100467
468 /* Remove TLB entry of boot EBC mapping */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200469 remove_tlb(CONFIG_SYS_BOOT_BASE_ADDR, 16 << 20);
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100470
471 /* Add TLB entry for 0xfc00.0000 -> 0x4.cc00.0000 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200472 program_tlb(CONFIG_SYS_FLASH_BASE_PHYS, CONFIG_SYS_FLASH_BASE, CONFIG_SYS_FLASH_SIZE,
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100473 TLB_WORD2_I_ENABLE);
474
475 /*
476 * Now accessing of the whole 64Mbytes of NOR FLASH at virtual address
477 * 0xfc00.0000 is possible
478 */
479
Stefan Roese71665eb2008-03-03 17:27:02 +0100480 /*
481 * Clear potential errors resulting from auto-calibration.
482 * If not done, then we could get an interrupt later on when
483 * exceptions are enabled.
484 */
485 set_mcsr(get_mcsr());
486
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100487 return 0;
488}
489
Adam Grahamf09f09d2008-10-08 10:12:53 -0700490#if !defined(CONFIG_ARCHES)
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100491int misc_init_r(void)
492{
493 u32 sdr0_srst1 = 0;
494 u32 eth_cfg;
Stefan Roese4c9e8552008-03-19 16:20:49 +0100495 u32 pvr = get_pvr();
Stefan Roese212ed902008-06-10 15:34:11 +0200496 u8 val;
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100497
498 /*
499 * Set EMAC mode/configuration (GMII, SGMII, RGMII...).
500 * This is board specific, so let's do it here.
501 */
502 mfsdr(SDR0_ETH_CFG, eth_cfg);
503 /* disable SGMII mode */
504 eth_cfg &= ~(SDR0_ETH_CFG_SGMII2_ENABLE |
505 SDR0_ETH_CFG_SGMII1_ENABLE |
506 SDR0_ETH_CFG_SGMII0_ENABLE);
507 /* Set the for 2 RGMII mode */
508 /* GMC0 EMAC4_0, GMC0 EMAC4_1, RGMII Bridge 0 */
509 eth_cfg &= ~SDR0_ETH_CFG_GMC0_BRIDGE_SEL;
Stefan Roese4c9e8552008-03-19 16:20:49 +0100510 if ((pvr == PVR_460EX_RA) || (pvr == PVR_460EX_SE_RA))
511 eth_cfg |= SDR0_ETH_CFG_GMC1_BRIDGE_SEL;
512 else
513 eth_cfg &= ~SDR0_ETH_CFG_GMC1_BRIDGE_SEL;
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100514 mtsdr(SDR0_ETH_CFG, eth_cfg);
515
516 /*
517 * The AHB Bridge core is held in reset after power-on or reset
518 * so enable it now
519 */
520 mfsdr(SDR0_SRST1, sdr0_srst1);
521 sdr0_srst1 &= ~SDR0_SRST1_AHB;
522 mtsdr(SDR0_SRST1, sdr0_srst1);
523
Stefan Roese212ed902008-06-10 15:34:11 +0200524 /*
525 * RTC/M41T62:
526 * Disable square wave output: Batterie will be drained
527 * quickly, when this output is not disabled
528 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200529 val = i2c_reg_read(CONFIG_SYS_I2C_RTC_ADDR, 0xa);
Stefan Roese212ed902008-06-10 15:34:11 +0200530 val &= ~0x40;
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200531 i2c_reg_write(CONFIG_SYS_I2C_RTC_ADDR, 0xa, val);
Stefan Roese212ed902008-06-10 15:34:11 +0200532
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100533 return 0;
534}
535
Adam Grahamf09f09d2008-10-08 10:12:53 -0700536#else /* defined(CONFIG_ARCHES) */
537
538int misc_init_r(void)
539{
540 u32 eth_cfg = 0;
541 u32 eth_pll;
542 u32 reg;
543
544 /*
545 * Set EMAC mode/configuration (GMII, SGMII, RGMII...).
546 * This is board specific, so let's do it here.
547 */
548
549 /* enable SGMII mode */
550 eth_cfg |= (SDR0_ETH_CFG_SGMII0_ENABLE |
551 SDR0_ETH_CFG_SGMII1_ENABLE |
552 SDR0_ETH_CFG_SGMII2_ENABLE);
553
554 /* Set EMAC for MDIO */
555 eth_cfg |= SDR0_ETH_CFG_MDIO_SEL_EMAC0;
556
557 /* bypass the TAHOE0/TAHOE1 cores for U-Boot */
558 eth_cfg |= (SDR0_ETH_CFG_TAHOE0_BYPASS | SDR0_ETH_CFG_TAHOE1_BYPASS);
559
560 mtsdr(SDR0_ETH_CFG, eth_cfg);
561
562 /* reset all SGMII interfaces */
563 mfsdr(SDR0_SRST1, reg);
564 reg |= (SDR0_SRST1_SGMII0 | SDR0_SRST1_SGMII1 | SDR0_SRST1_SGMII2);
565 mtsdr(SDR0_SRST1, reg);
566 mtsdr(SDR0_ETH_STS, 0xFFFFFFFF);
567 mtsdr(SDR0_SRST1, 0x00000000);
568
569 do {
570 mfsdr(SDR0_ETH_PLL, eth_pll);
571 } while (!(eth_pll & SDR0_ETH_PLL_PLLLOCK));
572
573 return 0;
574}
575#endif /* !defined(CONFIG_ARCHES) */
576
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100577#if defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP)
Felix Radensky26d37f02009-06-22 15:30:42 +0300578extern void __ft_board_setup(void *blob, bd_t *bd);
579
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100580void ft_board_setup(void *blob, bd_t *bd)
581{
582 u32 val[4];
583 int rc;
584
Felix Radensky26d37f02009-06-22 15:30:42 +0300585 __ft_board_setup(blob, bd);
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100586
587 /* Fixup NOR mapping */
Felix Radensky26d37f02009-06-22 15:30:42 +0300588 val[0] = CONFIG_SYS_NOR_CS; /* chip select number */
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100589 val[1] = 0; /* always 0 */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200590 val[2] = CONFIG_SYS_FLASH_BASE_PHYS_L; /* we fixed up this address */
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100591 val[3] = gd->bd->bi_flashsize;
592 rc = fdt_find_and_setprop(blob, "/plb/opb/ebc", "ranges",
593 val, sizeof(val), 1);
Stefan Roese16bedc62008-05-19 07:14:38 +0200594 if (rc) {
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100595 printf("Unable to update property NOR mapping, err=%s\n",
596 fdt_strerror(rc));
Stefan Roese16bedc62008-05-19 07:14:38 +0200597 }
598
599 if (gd->board_type == BOARD_CANYONLANDS_SATA) {
600 /*
601 * When SATA is selected we need to disable the first PCIe
602 * node in the device tree, so that Linux doesn't initialize
603 * it.
604 */
Stefan Roese8fd41662008-09-22 16:10:43 +0200605 fdt_find_and_setprop(blob, "/plb/pciex@d00000000", "status",
606 "disabled", sizeof("disabled"), 1);
Stefan Roese16bedc62008-05-19 07:14:38 +0200607 }
608
609 if (gd->board_type == BOARD_CANYONLANDS_PCIE) {
610 /*
611 * When PCIe is selected we need to disable the SATA
612 * node in the device tree, so that Linux doesn't initialize
613 * it.
614 */
Stefan Roese8fd41662008-09-22 16:10:43 +0200615 fdt_find_and_setprop(blob, "/plb/sata@bffd1000", "status",
616 "disabled", sizeof("disabled"), 1);
Stefan Roese16bedc62008-05-19 07:14:38 +0200617 }
Stefan Roese8e1a3fe2008-03-11 16:51:17 +0100618}
619#endif /* defined(CONFIG_OF_LIBFDT) && defined(CONFIG_OF_BOARD_SETUP) */