blob: 73c65c56aa3c0ff48038bb15e9eda1a705dd5eb9 [file] [log] [blame]
Stefan Roese887e2ec2006-09-07 11:51:23 +02001/*
Stefan Roese51321062009-04-08 10:36:22 +02002 * (C) Copyright 2006-2009
Stefan Roese887e2ec2006-09-07 11:51:23 +02003 * Stefan Roese, DENX Software Engineering, sr@denx.de.
4 *
5 * (C) Copyright 2006
6 * Jacqueline Pira-Ferriol, AMCC/IBM, jpira-ferriol@fr.ibm.com
Wolfgang Denk865f0f92008-01-23 14:31:17 +01007 * Alain Saurel, AMCC/IBM, alain.saurel@fr.ibm.com
Stefan Roese887e2ec2006-09-07 11:51:23 +02008 *
Wolfgang Denk1a459662013-07-08 09:37:19 +02009 * SPDX-License-Identifier: GPL-2.0+
Stefan Roese887e2ec2006-09-07 11:51:23 +020010 */
11
12#include <common.h>
Stefan Roese13628882007-12-13 14:52:53 +010013#include <libfdt.h>
14#include <fdt_support.h>
Stefan Roeseb36df562010-09-09 19:18:00 +020015#include <asm/ppc4xx.h>
Stefan Roese09887762010-09-16 14:30:37 +020016#include <asm/ppc4xx-gpio.h>
Stefan Roese887e2ec2006-09-07 11:51:23 +020017#include <asm/processor.h>
Stefan Roese5a5958b2007-10-15 11:29:33 +020018#include <asm/io.h>
Matthias Fuchs83a49c82008-01-16 10:33:46 +010019#include <asm/bitops.h>
Stefan Roese887e2ec2006-09-07 11:51:23 +020020
21DECLARE_GLOBAL_DATA_PTR;
22
Stefan Roesed8731332009-05-11 13:46:14 +020023#if !defined(CONFIG_SYS_NO_FLASH)
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020024extern flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* info for FLASH chips */
Stefan Roesed8731332009-05-11 13:46:14 +020025#endif
Stefan Roese887e2ec2006-09-07 11:51:23 +020026
Stefan Roese51321062009-04-08 10:36:22 +020027extern void __ft_board_setup(void *blob, bd_t *bd);
28ulong flash_get_size(ulong base, int banknum);
Stefan Roese1b3c3602006-12-22 14:29:40 +010029
Stefan Roese23c51a22009-10-19 14:10:50 +020030static inline u32 get_async_pci_freq(void)
31{
32 if (in_8((void *)(CONFIG_SYS_BCSR_BASE + 5)) &
33 CONFIG_SYS_BCSR5_PCI66EN)
34 return 66666666;
35 else
36 return 33333333;
37}
38
Stefan Roese887e2ec2006-09-07 11:51:23 +020039int board_early_init_f(void)
40{
Stefan Roesea78bc442007-01-05 10:40:36 +010041 u32 sdr0_cust0;
42 u32 sdr0_pfc1, sdr0_pfc2;
43 u32 reg;
Stefan Roese887e2ec2006-09-07 11:51:23 +020044
Stefan Roesed1c3b272009-09-09 16:25:29 +020045 mtdcr(EBC0_CFGADDR, EBC0_CFG);
46 mtdcr(EBC0_CFGDATA, 0xb8400000);
Stefan Roese887e2ec2006-09-07 11:51:23 +020047
Matthias Fuchs83a49c82008-01-16 10:33:46 +010048 /*
Stefan Roese887e2ec2006-09-07 11:51:23 +020049 * Setup the interrupt controller polarities, triggers, etc.
Matthias Fuchs83a49c82008-01-16 10:33:46 +010050 */
Stefan Roese952e7762009-09-24 09:55:50 +020051 mtdcr(UIC0SR, 0xffffffff); /* clear all */
52 mtdcr(UIC0ER, 0x00000000); /* disable all */
53 mtdcr(UIC0CR, 0x00000005); /* ATI & UIC1 crit are critical */
54 mtdcr(UIC0PR, 0xfffff7ff); /* per ref-board manual */
55 mtdcr(UIC0TR, 0x00000000); /* per ref-board manual */
56 mtdcr(UIC0VR, 0x00000000); /* int31 highest, base=0x000 */
57 mtdcr(UIC0SR, 0xffffffff); /* clear all */
Stefan Roese887e2ec2006-09-07 11:51:23 +020058
Stefan Roese952e7762009-09-24 09:55:50 +020059 mtdcr(UIC1SR, 0xffffffff); /* clear all */
60 mtdcr(UIC1ER, 0x00000000); /* disable all */
61 mtdcr(UIC1CR, 0x00000000); /* all non-critical */
62 mtdcr(UIC1PR, 0xffffffff); /* per ref-board manual */
63 mtdcr(UIC1TR, 0x00000000); /* per ref-board manual */
64 mtdcr(UIC1VR, 0x00000000); /* int31 highest, base=0x000 */
65 mtdcr(UIC1SR, 0xffffffff); /* clear all */
Stefan Roese887e2ec2006-09-07 11:51:23 +020066
Stefan Roese952e7762009-09-24 09:55:50 +020067 mtdcr(UIC2SR, 0xffffffff); /* clear all */
68 mtdcr(UIC2ER, 0x00000000); /* disable all */
69 mtdcr(UIC2CR, 0x00000000); /* all non-critical */
70 mtdcr(UIC2PR, 0xffffffff); /* per ref-board manual */
71 mtdcr(UIC2TR, 0x00000000); /* per ref-board manual */
72 mtdcr(UIC2VR, 0x00000000); /* int31 highest, base=0x000 */
73 mtdcr(UIC2SR, 0xffffffff); /* clear all */
Stefan Roese887e2ec2006-09-07 11:51:23 +020074
Stefan Roese23c51a22009-10-19 14:10:50 +020075 /* Check and reconfigure the PCI sync clock if necessary */
76 ppc4xx_pci_sync_clock_config(get_async_pci_freq());
77
Stefan Roese887e2ec2006-09-07 11:51:23 +020078 /* 50MHz tmrclk */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020079 out_8((u8 *) CONFIG_SYS_BCSR_BASE + 0x04, 0x00);
Stefan Roese887e2ec2006-09-07 11:51:23 +020080
81 /* clear write protects */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020082 out_8((u8 *) CONFIG_SYS_BCSR_BASE + 0x07, 0x00);
Stefan Roese887e2ec2006-09-07 11:51:23 +020083
84 /* enable Ethernet */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020085 out_8((u8 *) CONFIG_SYS_BCSR_BASE + 0x08, 0x00);
Stefan Roese887e2ec2006-09-07 11:51:23 +020086
87 /* enable USB device */
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +020088 out_8((u8 *) CONFIG_SYS_BCSR_BASE + 0x09, 0x20);
Stefan Roese887e2ec2006-09-07 11:51:23 +020089
Mike Nussb7386542008-02-06 11:10:11 -050090 /* select Ethernet (and optionally IIC1) pins */
Stefan Roese887e2ec2006-09-07 11:51:23 +020091 mfsdr(SDR0_PFC1, sdr0_pfc1);
Matthias Fuchs83a49c82008-01-16 10:33:46 +010092 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_SELECT_MASK) |
93 SDR0_PFC1_SELECT_CONFIG_4;
Mike Nussb7386542008-02-06 11:10:11 -050094#ifdef CONFIG_I2C_MULTI_BUS
95 sdr0_pfc1 |= ((sdr0_pfc1 & ~SDR0_PFC1_SIS_MASK) | SDR0_PFC1_SIS_IIC1_SEL);
96#endif
Steven A. Falcoeab10072008-08-06 15:42:52 -040097 /* Two UARTs, so we need 4-pin mode. Also, we want CTS/RTS mode. */
98 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0IM_MASK) | SDR0_PFC1_U0IM_4PINS;
99 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0ME_MASK) | SDR0_PFC1_U0ME_CTS_RTS;
100 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U1ME_MASK) | SDR0_PFC1_U1ME_CTS_RTS;
101
Stefan Roese887e2ec2006-09-07 11:51:23 +0200102 mfsdr(SDR0_PFC2, sdr0_pfc2);
Matthias Fuchs83a49c82008-01-16 10:33:46 +0100103 sdr0_pfc2 = (sdr0_pfc2 & ~SDR0_PFC2_SELECT_MASK) |
104 SDR0_PFC2_SELECT_CONFIG_4;
Stefan Roese887e2ec2006-09-07 11:51:23 +0200105 mtsdr(SDR0_PFC2, sdr0_pfc2);
106 mtsdr(SDR0_PFC1, sdr0_pfc1);
107
108 /* PCI arbiter enabled */
Stefan Roesed1c3b272009-09-09 16:25:29 +0200109 mfsdr(SDR0_PCI0, reg);
110 mtsdr(SDR0_PCI0, 0x80000000 | reg);
Stefan Roese887e2ec2006-09-07 11:51:23 +0200111
112 /* setup NAND FLASH */
113 mfsdr(SDR0_CUST0, sdr0_cust0);
Wolfgang Denk511d0c72006-10-09 00:42:01 +0200114 sdr0_cust0 = SDR0_CUST0_MUX_NDFC_SEL |
Stefan Roese887e2ec2006-09-07 11:51:23 +0200115 SDR0_CUST0_NDFC_ENABLE |
116 SDR0_CUST0_NDFC_BW_8_BIT |
117 SDR0_CUST0_NDFC_ARE_MASK |
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200118 (0x80000000 >> (28 + CONFIG_SYS_NAND_CS));
Wolfgang Denk511d0c72006-10-09 00:42:01 +0200119 mtsdr(SDR0_CUST0, sdr0_cust0);
Stefan Roese887e2ec2006-09-07 11:51:23 +0200120
121 return 0;
122}
123
Stefan Roese887e2ec2006-09-07 11:51:23 +0200124int misc_init_r(void)
125{
Stefan Roesed8731332009-05-11 13:46:14 +0200126#if !defined(CONFIG_SYS_NO_FLASH)
Stefan Roese887e2ec2006-09-07 11:51:23 +0200127 uint pbcr;
128 int size_val = 0;
Stefan Roesed8731332009-05-11 13:46:14 +0200129#endif
Stefan Roese854bc8d2006-09-13 13:51:58 +0200130#ifdef CONFIG_440EPX
Stefan Roese887e2ec2006-09-07 11:51:23 +0200131 unsigned long usb2d0cr = 0;
132 unsigned long usb2phy0cr, usb2h0cr = 0;
133 unsigned long sdr0_pfc1;
134 char *act = getenv("usbact");
Stefan Roese854bc8d2006-09-13 13:51:58 +0200135#endif
Stefan Roesed8731332009-05-11 13:46:14 +0200136 u32 reg;
Stefan Roese887e2ec2006-09-07 11:51:23 +0200137
Stefan Roesed8731332009-05-11 13:46:14 +0200138#if !defined(CONFIG_SYS_NO_FLASH)
Matthias Fuchs83a49c82008-01-16 10:33:46 +0100139 /* Re-do flash sizing to get full correct info */
Stefan Roese1b3c3602006-12-22 14:29:40 +0100140
141 /* adjust flash start and offset */
142 gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
143 gd->bd->bi_flashoffset = 0;
144
Stefan Roese4adcbdc2010-10-11 15:50:10 +0200145#if defined(CONFIG_NAND_U_BOOT) || defined(CONFIG_NAND_SPL) || \
146 defined(CONFIG_SYS_RAMBOOT)
Stefan Roesed1c3b272009-09-09 16:25:29 +0200147 mtdcr(EBC0_CFGADDR, PB3CR);
Stefan Roese887e2ec2006-09-07 11:51:23 +0200148#else
Stefan Roesed1c3b272009-09-09 16:25:29 +0200149 mtdcr(EBC0_CFGADDR, PB0CR);
Stefan Roese887e2ec2006-09-07 11:51:23 +0200150#endif
Stefan Roesed1c3b272009-09-09 16:25:29 +0200151 pbcr = mfdcr(EBC0_CFGDATA);
Wolfgang Denk865f0f92008-01-23 14:31:17 +0100152 size_val = ffs(gd->bd->bi_flashsize) - 21;
Stefan Roese887e2ec2006-09-07 11:51:23 +0200153 pbcr = (pbcr & 0x0001ffff) | gd->bd->bi_flashstart | (size_val << 17);
Stefan Roese4adcbdc2010-10-11 15:50:10 +0200154#if defined(CONFIG_NAND_U_BOOT) || defined(CONFIG_NAND_SPL) || \
155 defined(CONFIG_SYS_RAMBOOT)
Stefan Roesed1c3b272009-09-09 16:25:29 +0200156 mtdcr(EBC0_CFGADDR, PB3CR);
Stefan Roese887e2ec2006-09-07 11:51:23 +0200157#else
Stefan Roesed1c3b272009-09-09 16:25:29 +0200158 mtdcr(EBC0_CFGADDR, PB0CR);
Stefan Roese887e2ec2006-09-07 11:51:23 +0200159#endif
Stefan Roesed1c3b272009-09-09 16:25:29 +0200160 mtdcr(EBC0_CFGDATA, pbcr);
Stefan Roese887e2ec2006-09-07 11:51:23 +0200161
Stefan Roese1b3c3602006-12-22 14:29:40 +0100162 /*
163 * Re-check to get correct base address
164 */
165 flash_get_size(gd->bd->bi_flashstart, 0);
Stefan Roese887e2ec2006-09-07 11:51:23 +0200166
Jean-Christophe PLAGNIOL-VILLARD5a1aceb2008-09-10 22:48:04 +0200167#ifdef CONFIG_ENV_IS_IN_FLASH
Stefan Roese887e2ec2006-09-07 11:51:23 +0200168 /* Monitor protection ON by default */
169 (void)flash_protect(FLAG_PROTECT_SET,
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200170 -CONFIG_SYS_MONITOR_LEN,
Stefan Roese887e2ec2006-09-07 11:51:23 +0200171 0xffffffff,
172 &flash_info[0]);
173
174 /* Env protection ON by default */
175 (void)flash_protect(FLAG_PROTECT_SET,
Jean-Christophe PLAGNIOL-VILLARD0e8d1582008-09-10 22:48:06 +0200176 CONFIG_ENV_ADDR_REDUND,
177 CONFIG_ENV_ADDR_REDUND + 2*CONFIG_ENV_SECT_SIZE - 1,
Stefan Roese887e2ec2006-09-07 11:51:23 +0200178 &flash_info[0]);
179#endif
Stefan Roesed8731332009-05-11 13:46:14 +0200180#endif /* CONFIG_SYS_NO_FLASH */
Stefan Roese887e2ec2006-09-07 11:51:23 +0200181
182 /*
183 * USB suff...
184 */
Stefan Roese854bc8d2006-09-13 13:51:58 +0200185#ifdef CONFIG_440EPX
Matthias Fuchs83a49c82008-01-16 10:33:46 +0100186 if (act == NULL || strcmp(act, "hostdev") == 0) {
Stefan Roese887e2ec2006-09-07 11:51:23 +0200187 /* SDR Setting */
Wolfgang Denk511d0c72006-10-09 00:42:01 +0200188 mfsdr(SDR0_PFC1, sdr0_pfc1);
Niklaus Gigerf780b832007-06-27 18:11:38 +0200189 mfsdr(SDR0_USB2D0CR, usb2d0cr);
Wolfgang Denk511d0c72006-10-09 00:42:01 +0200190 mfsdr(SDR0_USB2PHY0CR, usb2phy0cr);
191 mfsdr(SDR0_USB2H0CR, usb2h0cr);
Stefan Roese887e2ec2006-09-07 11:51:23 +0200192
193 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_XOCLK_MASK;
Matthias Fuchs83a49c82008-01-16 10:33:46 +0100194 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_XOCLK_EXTERNAL;
Wolfgang Denk511d0c72006-10-09 00:42:01 +0200195 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_WDINT_MASK;
Matthias Fuchs83a49c82008-01-16 10:33:46 +0100196 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_WDINT_16BIT_30MHZ;
Stefan Roese887e2ec2006-09-07 11:51:23 +0200197 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DVBUS_MASK;
Matthias Fuchs83a49c82008-01-16 10:33:46 +0100198 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DVBUS_PURDIS;
Stefan Roese887e2ec2006-09-07 11:51:23 +0200199 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DWNSTR_MASK;
Matthias Fuchs83a49c82008-01-16 10:33:46 +0100200 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DWNSTR_HOST;
Stefan Roese887e2ec2006-09-07 11:51:23 +0200201 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_UTMICN_MASK;
Matthias Fuchs83a49c82008-01-16 10:33:46 +0100202 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_UTMICN_HOST;
Stefan Roese887e2ec2006-09-07 11:51:23 +0200203
Matthias Fuchs83a49c82008-01-16 10:33:46 +0100204 /*
205 * An 8-bit/60MHz interface is the only possible alternative
206 * when connecting the Device to the PHY
207 */
Wolfgang Denk511d0c72006-10-09 00:42:01 +0200208 usb2h0cr = usb2h0cr &~SDR0_USB2H0CR_WDINT_MASK;
Matthias Fuchs83a49c82008-01-16 10:33:46 +0100209 usb2h0cr = usb2h0cr | SDR0_USB2H0CR_WDINT_16BIT_30MHZ;
Stefan Roese887e2ec2006-09-07 11:51:23 +0200210
Matthias Fuchs83a49c82008-01-16 10:33:46 +0100211 /*
212 * To enable the USB 2.0 Device function
213 * through the UTMI interface
214 */
Wolfgang Denk511d0c72006-10-09 00:42:01 +0200215 usb2d0cr = usb2d0cr &~SDR0_USB2D0CR_USB2DEV_EBC_SEL_MASK;
Matthias Fuchs83a49c82008-01-16 10:33:46 +0100216 usb2d0cr = usb2d0cr | SDR0_USB2D0CR_USB2DEV_SELECTION;
Stefan Roese887e2ec2006-09-07 11:51:23 +0200217
Wolfgang Denk511d0c72006-10-09 00:42:01 +0200218 sdr0_pfc1 = sdr0_pfc1 &~SDR0_PFC1_UES_MASK;
Matthias Fuchs83a49c82008-01-16 10:33:46 +0100219 sdr0_pfc1 = sdr0_pfc1 | SDR0_PFC1_UES_USB2D_SEL;
Stefan Roese887e2ec2006-09-07 11:51:23 +0200220
Wolfgang Denk511d0c72006-10-09 00:42:01 +0200221 mtsdr(SDR0_PFC1, sdr0_pfc1);
Niklaus Gigerf780b832007-06-27 18:11:38 +0200222 mtsdr(SDR0_USB2D0CR, usb2d0cr);
Wolfgang Denk511d0c72006-10-09 00:42:01 +0200223 mtsdr(SDR0_USB2PHY0CR, usb2phy0cr);
224 mtsdr(SDR0_USB2H0CR, usb2h0cr);
Stefan Roese887e2ec2006-09-07 11:51:23 +0200225
226 /*clear resets*/
227 udelay (1000);
228 mtsdr(SDR0_SRST1, 0x00000000);
229 udelay (1000);
230 mtsdr(SDR0_SRST0, 0x00000000);
231
232 printf("USB: Host(int phy) Device(ext phy)\n");
233
234 } else if (strcmp(act, "dev") == 0) {
235 /*-------------------PATCH-------------------------------*/
236 mfsdr(SDR0_USB2PHY0CR, usb2phy0cr);
237
238 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_XOCLK_MASK;
Matthias Fuchs83a49c82008-01-16 10:33:46 +0100239 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_XOCLK_EXTERNAL;
Stefan Roese887e2ec2006-09-07 11:51:23 +0200240 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DVBUS_MASK;
Matthias Fuchs83a49c82008-01-16 10:33:46 +0100241 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DVBUS_PURDIS;
Stefan Roese887e2ec2006-09-07 11:51:23 +0200242 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DWNSTR_MASK;
Matthias Fuchs83a49c82008-01-16 10:33:46 +0100243 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DWNSTR_HOST;
Stefan Roese887e2ec2006-09-07 11:51:23 +0200244 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_UTMICN_MASK;
Matthias Fuchs83a49c82008-01-16 10:33:46 +0100245 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_UTMICN_HOST;
Stefan Roese887e2ec2006-09-07 11:51:23 +0200246 mtsdr(SDR0_USB2PHY0CR, usb2phy0cr);
247
248 udelay (1000);
249 mtsdr(SDR0_SRST1, 0x672c6000);
250
251 udelay (1000);
252 mtsdr(SDR0_SRST0, 0x00000080);
253
254 udelay (1000);
255 mtsdr(SDR0_SRST1, 0x60206000);
256
257 *(unsigned int *)(0xe0000350) = 0x00000001;
258
259 udelay (1000);
260 mtsdr(SDR0_SRST1, 0x60306000);
261 /*-------------------PATCH-------------------------------*/
262
263 /* SDR Setting */
Wolfgang Denk511d0c72006-10-09 00:42:01 +0200264 mfsdr(SDR0_USB2PHY0CR, usb2phy0cr);
Stefan Roese887e2ec2006-09-07 11:51:23 +0200265 mfsdr(SDR0_USB2H0CR, usb2h0cr);
Niklaus Gigerf780b832007-06-27 18:11:38 +0200266 mfsdr(SDR0_USB2D0CR, usb2d0cr);
Stefan Roese887e2ec2006-09-07 11:51:23 +0200267 mfsdr(SDR0_PFC1, sdr0_pfc1);
268
269 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_XOCLK_MASK;
Matthias Fuchs83a49c82008-01-16 10:33:46 +0100270 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_XOCLK_EXTERNAL;
Wolfgang Denk511d0c72006-10-09 00:42:01 +0200271 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_WDINT_MASK;
Matthias Fuchs83a49c82008-01-16 10:33:46 +0100272 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_WDINT_8BIT_60MHZ;
Stefan Roese887e2ec2006-09-07 11:51:23 +0200273 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DVBUS_MASK;
Matthias Fuchs83a49c82008-01-16 10:33:46 +0100274 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DVBUS_PUREN;
Stefan Roese887e2ec2006-09-07 11:51:23 +0200275 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DWNSTR_MASK;
Matthias Fuchs83a49c82008-01-16 10:33:46 +0100276 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DWNSTR_DEV;
Stefan Roese887e2ec2006-09-07 11:51:23 +0200277 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_UTMICN_MASK;
Matthias Fuchs83a49c82008-01-16 10:33:46 +0100278 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_UTMICN_DEV;
Stefan Roese887e2ec2006-09-07 11:51:23 +0200279
280 usb2h0cr = usb2h0cr &~SDR0_USB2H0CR_WDINT_MASK;
Matthias Fuchs83a49c82008-01-16 10:33:46 +0100281 usb2h0cr = usb2h0cr | SDR0_USB2H0CR_WDINT_8BIT_60MHZ;
Stefan Roese887e2ec2006-09-07 11:51:23 +0200282
283 usb2d0cr = usb2d0cr &~SDR0_USB2D0CR_USB2DEV_EBC_SEL_MASK;
Matthias Fuchs83a49c82008-01-16 10:33:46 +0100284 usb2d0cr = usb2d0cr | SDR0_USB2D0CR_EBC_SELECTION;
Stefan Roese887e2ec2006-09-07 11:51:23 +0200285
286 sdr0_pfc1 = sdr0_pfc1 &~SDR0_PFC1_UES_MASK;
Matthias Fuchs83a49c82008-01-16 10:33:46 +0100287 sdr0_pfc1 = sdr0_pfc1 | SDR0_PFC1_UES_EBCHR_SEL;
Stefan Roese887e2ec2006-09-07 11:51:23 +0200288
Wolfgang Denk511d0c72006-10-09 00:42:01 +0200289 mtsdr(SDR0_USB2H0CR, usb2h0cr);
290 mtsdr(SDR0_USB2PHY0CR, usb2phy0cr);
Niklaus Gigerf780b832007-06-27 18:11:38 +0200291 mtsdr(SDR0_USB2D0CR, usb2d0cr);
Stefan Roese887e2ec2006-09-07 11:51:23 +0200292 mtsdr(SDR0_PFC1, sdr0_pfc1);
293
Matthias Fuchs83a49c82008-01-16 10:33:46 +0100294 /* clear resets */
Stefan Roese887e2ec2006-09-07 11:51:23 +0200295 udelay (1000);
296 mtsdr(SDR0_SRST1, 0x00000000);
297 udelay (1000);
298 mtsdr(SDR0_SRST0, 0x00000000);
299
300 printf("USB: Device(int phy)\n");
301 }
Stefan Roese854bc8d2006-09-13 13:51:58 +0200302#endif /* CONFIG_440EPX */
Stefan Roese887e2ec2006-09-07 11:51:23 +0200303
John Otken john@softadvances.com8ce16f52007-03-08 09:39:48 -0600304 mfsdr(SDR0_SRST1, reg); /* enable security/kasumi engines */
305 reg &= ~(SDR0_SRST1_CRYP0 | SDR0_SRST1_KASU0);
306 mtsdr(SDR0_SRST1, reg);
307
Stefan Roesea78bc442007-01-05 10:40:36 +0100308 /*
309 * Clear PLB4A0_ACR[WRP]
310 * This fix will make the MAL burst disabling patch for the Linux
311 * EMAC driver obsolete.
312 */
Stefan Roese5e7abce2010-09-11 09:31:43 +0200313 reg = mfdcr(PLB4A0_ACR) & ~PLB4Ax_ACR_WRP_MASK;
314 mtdcr(PLB4A0_ACR, reg);
Stefan Roesea78bc442007-01-05 10:40:36 +0100315
Stefan Roese887e2ec2006-09-07 11:51:23 +0200316 return 0;
317}
318
319int checkboard(void)
320{
Wolfgang Denkf0c0b3a2011-05-04 10:32:28 +0000321 char buf[64];
322 int i = getenv_f("serial#", buf, sizeof(buf));
Stefan Roesee0b9ea82007-01-13 07:57:51 +0100323 u8 rev;
Stefan Roese23c51a22009-10-19 14:10:50 +0200324 u32 clock = get_async_pci_freq();
Stefan Roese887e2ec2006-09-07 11:51:23 +0200325
Stefan Roese854bc8d2006-09-13 13:51:58 +0200326#ifdef CONFIG_440EPX
Stefan Roese887e2ec2006-09-07 11:51:23 +0200327 printf("Board: Sequoia - AMCC PPC440EPx Evaluation Board");
Stefan Roese854bc8d2006-09-13 13:51:58 +0200328#else
329 printf("Board: Rainier - AMCC PPC440GRx Evaluation Board");
330#endif
Stefan Roesee0b9ea82007-01-13 07:57:51 +0100331
Jean-Christophe PLAGNIOL-VILLARD6d0f6bc2008-10-16 15:01:15 +0200332 rev = in_8((void *)(CONFIG_SYS_BCSR_BASE + 0));
Stefan Roese23c51a22009-10-19 14:10:50 +0200333 printf(", Rev. %X, PCI-Async=%d MHz", rev, clock / 1000000);
Stefan Roesee0b9ea82007-01-13 07:57:51 +0100334
Wolfgang Denkf0c0b3a2011-05-04 10:32:28 +0000335 if (i > 0) {
Stefan Roese887e2ec2006-09-07 11:51:23 +0200336 puts(", serial# ");
Wolfgang Denkf0c0b3a2011-05-04 10:32:28 +0000337 puts(buf);
Stefan Roese887e2ec2006-09-07 11:51:23 +0200338 }
339 putc('\n');
340
Stefan Roese23c51a22009-10-19 14:10:50 +0200341 /*
342 * Reconfiguration of the PCI sync clock is already done,
343 * now check again if everything is in range:
344 */
345 if (ppc4xx_pci_sync_clock_config(clock)) {
346 printf("ERROR: PCI clocking incorrect (async=%d "
347 "sync=%ld)!\n", clock, get_PCI_freq());
348 }
349
Stefan Roese887e2ec2006-09-07 11:51:23 +0200350 return (0);
351}
352
Matthias Fuchs1f840212008-01-08 15:40:09 +0100353#if defined(CONFIG_PCI) && defined(CONFIG_PCI_PNP)
354/*
355 * Assign interrupts to PCI devices.
356 */
Stefan Roesea760b022009-11-12 16:41:09 +0100357void board_pci_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
Matthias Fuchs1f840212008-01-08 15:40:09 +0100358{
Stefan Roesed1631fe2008-06-26 13:40:57 +0200359 pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, VECNUM_EIRQ2);
Matthias Fuchs1f840212008-01-08 15:40:09 +0100360}
361#endif
362
Stefan Roesed8731332009-05-11 13:46:14 +0200363#if defined(CONFIG_NAND_U_BOOT) || defined(CONFIG_SYS_RAMBOOT)
Stefan Roese51321062009-04-08 10:36:22 +0200364/*
365 * On NAND-booting sequoia, we need to patch the chips select numbers
366 * in the dtb (CS0 - NAND, CS3 - NOR)
367 */
368void ft_board_setup(void *blob, bd_t *bd)
369{
370 int rc;
371 int len;
372 int nodeoffset;
373 struct fdt_property *prop;
374 u32 *reg;
375 char path[32];
376
377 /* First do common fdt setup */
378 __ft_board_setup(blob, bd);
379
380 /* And now configure NOR chip select to 3 instead of 0 */
381 strcpy(path, "/plb/opb/ebc/nor_flash@0,0");
382 nodeoffset = fdt_path_offset(blob, path);
383 prop = fdt_get_property_w(blob, nodeoffset, "reg", &len);
384 if (prop == NULL) {
385 printf("Unable to update NOR chip select for NAND booting\n");
386 return;
387 }
388 reg = (u32 *)&prop->data[0];
389 reg[0] = 3;
390 rc = fdt_find_and_setprop(blob, path, "reg", reg, 3 * sizeof(u32), 1);
391 if (rc) {
392 printf("Unable to update property NOR mappings, err=%s\n",
393 fdt_strerror(rc));
394 return;
395 }
396
397 /* And now configure NAND chip select to 0 instead of 3 */
398 strcpy(path, "/plb/opb/ebc/ndfc@3,0");
399 nodeoffset = fdt_path_offset(blob, path);
400 prop = fdt_get_property_w(blob, nodeoffset, "reg", &len);
401 if (prop == NULL) {
402 printf("Unable to update NDFC chip select for NAND booting\n");
403 return;
404 }
405 reg = (u32 *)&prop->data[0];
406 reg[0] = 0;
407 rc = fdt_find_and_setprop(blob, path, "reg", reg, 3 * sizeof(u32), 1);
408 if (rc) {
409 printf("Unable to update property NDFC mappings, err=%s\n",
410 fdt_strerror(rc));
411 return;
412 }
413}
414#endif /* CONFIG_NAND_U_BOOT */