blob: 5c8d9ec8f193fa6f2f398b97ee115c5b6e3a9902 [file] [log] [blame]
Stefan Roese5fb692c2007-01-18 10:25:34 +01001/*
2 * Copyright (C) 2004 PaulReynolds@lhsolutions.com
3 *
4 * (C) Copyright 2007
5 * Stefan Roese, DENX Software Engineering, sr@denx.de.
6 *
Wolfgang Denk3765b3e2013-10-07 13:07:26 +02007 * SPDX-License-Identifier: GPL-2.0+
Stefan Roese5fb692c2007-01-18 10:25:34 +01008 */
9
10#include <common.h>
11#include <asm/processor.h>
12#include <spd_sdram.h>
Stefan Roeseb36df562010-09-09 19:18:00 +020013#include <asm/ppc4xx-emac.h>
Ben Warren10efa022008-08-31 20:37:00 -070014#include <netdev.h>
Stefan Roese5fb692c2007-01-18 10:25:34 +010015
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020016#ifdef CONFIG_SYS_INIT_SHOW_RESET_REG
Stefan Roese5fb692c2007-01-18 10:25:34 +010017void show_reset_reg(void);
18#endif
19
Wolfgang Denk1218abf2007-09-15 20:48:41 +020020DECLARE_GLOBAL_DATA_PTR;
21
Stefan Roese5fb692c2007-01-18 10:25:34 +010022int lcd_init(void);
23
24int board_early_init_f (void)
25{
26 unsigned long reg;
27 volatile unsigned int *GpioOdr;
28 volatile unsigned int *GpioTcr;
29 volatile unsigned int *GpioOr;
30
31 /*-------------------------------------------------------------------------+
32 | Initialize EBC CONFIG
33 +-------------------------------------------------------------------------*/
Stefan Roesed1c3b272009-09-09 16:25:29 +020034 mtebc(EBC0_CFG, EBC_CFG_LE_UNLOCK |
Stefan Roese5fb692c2007-01-18 10:25:34 +010035 EBC_CFG_PTD_ENABLE | EBC_CFG_RTC_64PERCLK |
36 EBC_CFG_ATC_PREVIOUS | EBC_CFG_DTC_PREVIOUS |
37 EBC_CFG_CTC_PREVIOUS | EBC_CFG_EMC_DEFAULT |
38 EBC_CFG_PME_DISABLE | EBC_CFG_PR_32);
39
40 /*-------------------------------------------------------------------------+
41 | 64MB FLASH. Initialize bank 0 with default values.
42 +-------------------------------------------------------------------------*/
Stefan Roesed1c3b272009-09-09 16:25:29 +020043 mtebc(PB0AP, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(15) |
Stefan Roese5fb692c2007-01-18 10:25:34 +010044 EBC_BXAP_BCE_DISABLE |
45 EBC_BXAP_CSN_ENCODE(1) | EBC_BXAP_OEN_ENCODE(1) |
46 EBC_BXAP_WBN_ENCODE(1) | EBC_BXAP_WBF_ENCODE(1) |
47 EBC_BXAP_TH_ENCODE(3) | EBC_BXAP_RE_DISABLED |
48 EBC_BXAP_BEM_WRITEONLY |
49 EBC_BXAP_PEN_DISABLED);
Stefan Roesed1c3b272009-09-09 16:25:29 +020050 mtebc(PB0CR, EBC_BXCR_BAS_ENCODE(CONFIG_SYS_FLASH_BASE) |
Stefan Roese5fb692c2007-01-18 10:25:34 +010051 EBC_BXCR_BS_64MB | EBC_BXCR_BU_RW|EBC_BXCR_BW_32BIT);
52
53 /*-------------------------------------------------------------------------+
54 | FPGA. Initialize bank 1 with default values.
55 +-------------------------------------------------------------------------*/
Stefan Roesed1c3b272009-09-09 16:25:29 +020056 mtebc(PB1AP, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(5) |
Stefan Roese5fb692c2007-01-18 10:25:34 +010057 EBC_BXAP_BCE_DISABLE |
58 EBC_BXAP_CSN_ENCODE(1) | EBC_BXAP_OEN_ENCODE(1) |
59 EBC_BXAP_WBN_ENCODE(1) | EBC_BXAP_WBF_ENCODE(1) |
60 EBC_BXAP_TH_ENCODE(3) | EBC_BXAP_RE_DISABLED |
61 EBC_BXAP_BEM_WRITEONLY |
62 EBC_BXAP_PEN_DISABLED);
Stefan Roesed1c3b272009-09-09 16:25:29 +020063 mtebc(PB1CR, EBC_BXCR_BAS_ENCODE(0x41000000) |
Stefan Roese5fb692c2007-01-18 10:25:34 +010064 EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_8BIT);
65
66 /*-------------------------------------------------------------------------+
67 | LCM. Initialize bank 2 with default values.
68 +-------------------------------------------------------------------------*/
Stefan Roesed1c3b272009-09-09 16:25:29 +020069 mtebc(PB2AP, EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(64) |
Stefan Roese5fb692c2007-01-18 10:25:34 +010070 EBC_BXAP_BCE_DISABLE |
71 EBC_BXAP_CSN_ENCODE(3) | EBC_BXAP_OEN_ENCODE(3) |
72 EBC_BXAP_WBN_ENCODE(3) | EBC_BXAP_WBF_ENCODE(3) |
73 EBC_BXAP_TH_ENCODE(7) | EBC_BXAP_RE_DISABLED |
74 EBC_BXAP_BEM_WRITEONLY |
75 EBC_BXAP_PEN_DISABLED);
Stefan Roesed1c3b272009-09-09 16:25:29 +020076 mtebc(PB2CR, EBC_BXCR_BAS_ENCODE(0x42000000) |
Stefan Roese5fb692c2007-01-18 10:25:34 +010077 EBC_BXCR_BS_1MB | EBC_BXCR_BU_RW|EBC_BXCR_BW_8BIT);
78
79 /*-------------------------------------------------------------------------+
80 | TMP. Initialize bank 3 with default values.
81 +-------------------------------------------------------------------------*/
Stefan Roesed1c3b272009-09-09 16:25:29 +020082 mtebc(PB3AP, EBC_BXAP_BME_DISABLED | EBC_BXAP_TWT_ENCODE(128) |
Stefan Roese5fb692c2007-01-18 10:25:34 +010083 EBC_BXAP_BCE_DISABLE |
84 EBC_BXAP_CSN_ENCODE(3) | EBC_BXAP_OEN_ENCODE(3) |
85 EBC_BXAP_WBN_ENCODE(3) | EBC_BXAP_WBF_ENCODE(3) |
86 EBC_BXAP_TH_ENCODE(7) | EBC_BXAP_RE_DISABLED |
87 EBC_BXAP_BEM_WRITEONLY |
88 EBC_BXAP_PEN_DISABLED);
Stefan Roesed1c3b272009-09-09 16:25:29 +020089 mtebc(PB3CR, EBC_BXCR_BAS_ENCODE(0x48000000) |
Stefan Roese5fb692c2007-01-18 10:25:34 +010090 EBC_BXCR_BS_64MB | EBC_BXCR_BU_RW | EBC_BXCR_BW_32BIT);
91
92 /*-------------------------------------------------------------------------+
93 | Connector 4~7. Initialize bank 3~ 7 with default values.
94 +-------------------------------------------------------------------------*/
Stefan Roesed1c3b272009-09-09 16:25:29 +020095 mtebc(PB4AP,0);
96 mtebc(PB4CR,0);
97 mtebc(PB5AP,0);
98 mtebc(PB5CR,0);
99 mtebc(PB6AP,0);
100 mtebc(PB6CR,0);
101 mtebc(PB7AP,0);
102 mtebc(PB7CR,0);
Stefan Roese5fb692c2007-01-18 10:25:34 +0100103
104 /*--------------------------------------------------------------------
105 * Setup the interrupt controller polarities, triggers, etc.
106 *-------------------------------------------------------------------*/
Stefan Roese5de85142008-06-26 17:36:39 +0200107 /*
108 * Because of the interrupt handling rework to handle 440GX interrupts
109 * with the common code, we needed to change names of the UIC registers.
110 * Here the new relationship:
111 *
112 * U-Boot name 440GX name
113 * -----------------------
114 * UIC0 UICB0
115 * UIC1 UIC0
116 * UIC2 UIC1
117 * UIC3 UIC2
118 */
Stefan Roese952e7762009-09-24 09:55:50 +0200119 mtdcr (UIC1SR, 0xffffffff); /* clear all */
120 mtdcr (UIC1ER, 0x00000000); /* disable all */
121 mtdcr (UIC1CR, 0x00000009); /* SMI & UIC1 crit are critical */
122 mtdcr (UIC1PR, 0xfffffe13); /* per ref-board manual */
123 mtdcr (UIC1TR, 0x01c00008); /* per ref-board manual */
124 mtdcr (UIC1VR, 0x00000001); /* int31 highest, base=0x000 */
125 mtdcr (UIC1SR, 0xffffffff); /* clear all */
Stefan Roese5fb692c2007-01-18 10:25:34 +0100126
Stefan Roese952e7762009-09-24 09:55:50 +0200127 mtdcr (UIC2SR, 0xffffffff); /* clear all */
128 mtdcr (UIC2ER, 0x00000000); /* disable all */
129 mtdcr (UIC2CR, 0x00000000); /* all non-critical */
130 mtdcr (UIC2PR, 0xffffe0ff); /* per ref-board manual */
131 mtdcr (UIC2TR, 0x00ffc000); /* per ref-board manual */
132 mtdcr (UIC2VR, 0x00000001); /* int31 highest, base=0x000 */
133 mtdcr (UIC2SR, 0xffffffff); /* clear all */
Stefan Roese5fb692c2007-01-18 10:25:34 +0100134
Stefan Roese952e7762009-09-24 09:55:50 +0200135 mtdcr (UIC3SR, 0xffffffff); /* clear all */
136 mtdcr (UIC3ER, 0x00000000); /* disable all */
137 mtdcr (UIC3CR, 0x00000000); /* all non-critical */
138 mtdcr (UIC3PR, 0xffffffff); /* per ref-board manual */
139 mtdcr (UIC3TR, 0x00ff8c0f); /* per ref-board manual */
140 mtdcr (UIC3VR, 0x00000001); /* int31 highest, base=0x000 */
141 mtdcr (UIC3SR, 0xffffffff); /* clear all */
Stefan Roese5de85142008-06-26 17:36:39 +0200142
Stefan Roese952e7762009-09-24 09:55:50 +0200143 mtdcr (UIC0SR, 0xfc000000); /* clear all */
144 mtdcr (UIC0ER, 0x00000000); /* disable all */
145 mtdcr (UIC0CR, 0x00000000); /* all non-critical */
146 mtdcr (UIC0PR, 0xfc000000); /* */
147 mtdcr (UIC0TR, 0x00000000); /* */
148 mtdcr (UIC0VR, 0x00000001); /* */
Stefan Roese5fb692c2007-01-18 10:25:34 +0100149
150 /* Enable two GPIO 10~11 and TraceA signal */
Stefan Roesed1c3b272009-09-09 16:25:29 +0200151 mfsdr(SDR0_PFC0,reg);
Stefan Roese5fb692c2007-01-18 10:25:34 +0100152 reg |= 0x00300000;
Stefan Roesed1c3b272009-09-09 16:25:29 +0200153 mtsdr(SDR0_PFC0,reg);
Stefan Roese5fb692c2007-01-18 10:25:34 +0100154
Stefan Roesed1c3b272009-09-09 16:25:29 +0200155 mfsdr(SDR0_PFC1,reg);
Stefan Roese5fb692c2007-01-18 10:25:34 +0100156 reg |= 0x00100000;
Stefan Roesed1c3b272009-09-09 16:25:29 +0200157 mtsdr(SDR0_PFC1,reg);
Stefan Roese5fb692c2007-01-18 10:25:34 +0100158
159 /* Set GPIO 10 and 11 as output */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200160 GpioOdr = (volatile unsigned int*)(CONFIG_SYS_PERIPHERAL_BASE+0x718);
161 GpioTcr = (volatile unsigned int*)(CONFIG_SYS_PERIPHERAL_BASE+0x704);
162 GpioOr = (volatile unsigned int*)(CONFIG_SYS_PERIPHERAL_BASE+0x700);
Stefan Roese5fb692c2007-01-18 10:25:34 +0100163
164 *GpioOdr &= ~(0x00300000);
165 *GpioTcr |= 0x00300000;
Wolfgang Denka4012392007-01-19 23:08:39 +0100166 *GpioOr |= 0x00300000;
Stefan Roese5fb692c2007-01-18 10:25:34 +0100167
168 return 0;
169}
170
171int misc_init_r(void)
172{
173 lcd_init();
174
175 return 0;
176}
177
178int checkboard (void)
179{
Wolfgang Denkf0c0b3a2011-05-04 10:32:28 +0000180 char buf[64];
181 int i = getenv_f("serial#", buf, sizeof(buf));
Stefan Roese5fb692c2007-01-18 10:25:34 +0100182
183 printf ("Board: Taishan - AMCC PPC440GX Evaluation Board");
Wolfgang Denkf0c0b3a2011-05-04 10:32:28 +0000184 if (i > 0) {
185 puts(", serial# ");
186 puts(buf);
Stefan Roese5fb692c2007-01-18 10:25:34 +0100187 }
188 putc ('\n');
189
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200190#ifdef CONFIG_SYS_INIT_SHOW_RESET_REG
Stefan Roese5fb692c2007-01-18 10:25:34 +0100191 show_reset_reg();
192#endif
193
194 return (0);
195}
196
Ben Warren10efa022008-08-31 20:37:00 -0700197int board_eth_init(bd_t *bis)
198{
Stefan Roesecef0efa2009-02-11 09:29:33 +0100199 cpu_eth_init(bis);
Ben Warren10efa022008-08-31 20:37:00 -0700200 return pci_eth_init(bis);
201}