blob: 91c6cbf7aa80d95e2d351940774e9df9f03b7187 [file] [log] [blame]
Stefan Roese42fbddd2006-09-07 11:51:23 +02001/*
Stefan Roesec55fc7a2009-04-08 10:36:22 +02002 * (C) Copyright 2006-2009
Stefan Roese42fbddd2006-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 Denk3595e612008-01-23 14:31:17 +01007 * Alain Saurel, AMCC/IBM, alain.saurel@fr.ibm.com
Stefan Roese42fbddd2006-09-07 11:51:23 +02008 *
Wolfgang Denkd79de1d2013-07-08 09:37:19 +02009 * SPDX-License-Identifier: GPL-2.0+
Stefan Roese42fbddd2006-09-07 11:51:23 +020010 */
11
12#include <common.h>
Simon Glass2aec3cc2014-10-23 18:58:47 -060013#include <errno.h>
Stefan Roesefbcee002007-12-13 14:52:53 +010014#include <libfdt.h>
15#include <fdt_support.h>
Stefan Roese247e9d72010-09-09 19:18:00 +020016#include <asm/ppc4xx.h>
Stefan Roesede21eab2010-09-16 14:30:37 +020017#include <asm/ppc4xx-gpio.h>
Stefan Roese42fbddd2006-09-07 11:51:23 +020018#include <asm/processor.h>
Stefan Roesefa257472007-10-15 11:29:33 +020019#include <asm/io.h>
Matthias Fuchs62357702008-01-16 10:33:46 +010020#include <asm/bitops.h>
Stefan Roese42fbddd2006-09-07 11:51:23 +020021
22DECLARE_GLOBAL_DATA_PTR;
23
Stefan Roesec20ef322009-05-11 13:46:14 +020024#if !defined(CONFIG_SYS_NO_FLASH)
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020025extern flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* info for FLASH chips */
Stefan Roesec20ef322009-05-11 13:46:14 +020026#endif
Stefan Roese42fbddd2006-09-07 11:51:23 +020027
Stefan Roesec55fc7a2009-04-08 10:36:22 +020028extern void __ft_board_setup(void *blob, bd_t *bd);
29ulong flash_get_size(ulong base, int banknum);
Stefan Roeseab8e99b2006-12-22 14:29:40 +010030
Stefan Roesee7f30922009-10-19 14:10:50 +020031static inline u32 get_async_pci_freq(void)
32{
33 if (in_8((void *)(CONFIG_SYS_BCSR_BASE + 5)) &
34 CONFIG_SYS_BCSR5_PCI66EN)
35 return 66666666;
36 else
37 return 33333333;
38}
39
Stefan Roese42fbddd2006-09-07 11:51:23 +020040int board_early_init_f(void)
41{
Stefan Roesebc7057d2007-01-05 10:40:36 +010042 u32 sdr0_cust0;
43 u32 sdr0_pfc1, sdr0_pfc2;
44 u32 reg;
Stefan Roese42fbddd2006-09-07 11:51:23 +020045
Stefan Roese918010a2009-09-09 16:25:29 +020046 mtdcr(EBC0_CFGADDR, EBC0_CFG);
47 mtdcr(EBC0_CFGDATA, 0xb8400000);
Stefan Roese42fbddd2006-09-07 11:51:23 +020048
Matthias Fuchs62357702008-01-16 10:33:46 +010049 /*
Stefan Roese42fbddd2006-09-07 11:51:23 +020050 * Setup the interrupt controller polarities, triggers, etc.
Matthias Fuchs62357702008-01-16 10:33:46 +010051 */
Stefan Roese707fd362009-09-24 09:55:50 +020052 mtdcr(UIC0SR, 0xffffffff); /* clear all */
53 mtdcr(UIC0ER, 0x00000000); /* disable all */
54 mtdcr(UIC0CR, 0x00000005); /* ATI & UIC1 crit are critical */
55 mtdcr(UIC0PR, 0xfffff7ff); /* per ref-board manual */
56 mtdcr(UIC0TR, 0x00000000); /* per ref-board manual */
57 mtdcr(UIC0VR, 0x00000000); /* int31 highest, base=0x000 */
58 mtdcr(UIC0SR, 0xffffffff); /* clear all */
Stefan Roese42fbddd2006-09-07 11:51:23 +020059
Stefan Roese707fd362009-09-24 09:55:50 +020060 mtdcr(UIC1SR, 0xffffffff); /* clear all */
61 mtdcr(UIC1ER, 0x00000000); /* disable all */
62 mtdcr(UIC1CR, 0x00000000); /* all non-critical */
63 mtdcr(UIC1PR, 0xffffffff); /* per ref-board manual */
64 mtdcr(UIC1TR, 0x00000000); /* per ref-board manual */
65 mtdcr(UIC1VR, 0x00000000); /* int31 highest, base=0x000 */
66 mtdcr(UIC1SR, 0xffffffff); /* clear all */
Stefan Roese42fbddd2006-09-07 11:51:23 +020067
Stefan Roese707fd362009-09-24 09:55:50 +020068 mtdcr(UIC2SR, 0xffffffff); /* clear all */
69 mtdcr(UIC2ER, 0x00000000); /* disable all */
70 mtdcr(UIC2CR, 0x00000000); /* all non-critical */
71 mtdcr(UIC2PR, 0xffffffff); /* per ref-board manual */
72 mtdcr(UIC2TR, 0x00000000); /* per ref-board manual */
73 mtdcr(UIC2VR, 0x00000000); /* int31 highest, base=0x000 */
74 mtdcr(UIC2SR, 0xffffffff); /* clear all */
Stefan Roese42fbddd2006-09-07 11:51:23 +020075
Stefan Roesee7f30922009-10-19 14:10:50 +020076 /* Check and reconfigure the PCI sync clock if necessary */
77 ppc4xx_pci_sync_clock_config(get_async_pci_freq());
78
Stefan Roese42fbddd2006-09-07 11:51:23 +020079 /* 50MHz tmrclk */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020080 out_8((u8 *) CONFIG_SYS_BCSR_BASE + 0x04, 0x00);
Stefan Roese42fbddd2006-09-07 11:51:23 +020081
82 /* clear write protects */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020083 out_8((u8 *) CONFIG_SYS_BCSR_BASE + 0x07, 0x00);
Stefan Roese42fbddd2006-09-07 11:51:23 +020084
85 /* enable Ethernet */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020086 out_8((u8 *) CONFIG_SYS_BCSR_BASE + 0x08, 0x00);
Stefan Roese42fbddd2006-09-07 11:51:23 +020087
88 /* enable USB device */
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +020089 out_8((u8 *) CONFIG_SYS_BCSR_BASE + 0x09, 0x20);
Stefan Roese42fbddd2006-09-07 11:51:23 +020090
Mike Nuss383b1452008-02-06 11:10:11 -050091 /* select Ethernet (and optionally IIC1) pins */
Stefan Roese42fbddd2006-09-07 11:51:23 +020092 mfsdr(SDR0_PFC1, sdr0_pfc1);
Matthias Fuchs62357702008-01-16 10:33:46 +010093 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_SELECT_MASK) |
94 SDR0_PFC1_SELECT_CONFIG_4;
Mike Nuss383b1452008-02-06 11:10:11 -050095#ifdef CONFIG_I2C_MULTI_BUS
96 sdr0_pfc1 |= ((sdr0_pfc1 & ~SDR0_PFC1_SIS_MASK) | SDR0_PFC1_SIS_IIC1_SEL);
97#endif
Steven A. Falco7bf9cc62008-08-06 15:42:52 -040098 /* Two UARTs, so we need 4-pin mode. Also, we want CTS/RTS mode. */
99 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0IM_MASK) | SDR0_PFC1_U0IM_4PINS;
100 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0ME_MASK) | SDR0_PFC1_U0ME_CTS_RTS;
101 sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U1ME_MASK) | SDR0_PFC1_U1ME_CTS_RTS;
102
Stefan Roese42fbddd2006-09-07 11:51:23 +0200103 mfsdr(SDR0_PFC2, sdr0_pfc2);
Matthias Fuchs62357702008-01-16 10:33:46 +0100104 sdr0_pfc2 = (sdr0_pfc2 & ~SDR0_PFC2_SELECT_MASK) |
105 SDR0_PFC2_SELECT_CONFIG_4;
Stefan Roese42fbddd2006-09-07 11:51:23 +0200106 mtsdr(SDR0_PFC2, sdr0_pfc2);
107 mtsdr(SDR0_PFC1, sdr0_pfc1);
108
109 /* PCI arbiter enabled */
Stefan Roese918010a2009-09-09 16:25:29 +0200110 mfsdr(SDR0_PCI0, reg);
111 mtsdr(SDR0_PCI0, 0x80000000 | reg);
Stefan Roese42fbddd2006-09-07 11:51:23 +0200112
113 /* setup NAND FLASH */
114 mfsdr(SDR0_CUST0, sdr0_cust0);
Wolfgang Denk4df0da52006-10-09 00:42:01 +0200115 sdr0_cust0 = SDR0_CUST0_MUX_NDFC_SEL |
Stefan Roese42fbddd2006-09-07 11:51:23 +0200116 SDR0_CUST0_NDFC_ENABLE |
117 SDR0_CUST0_NDFC_BW_8_BIT |
118 SDR0_CUST0_NDFC_ARE_MASK |
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200119 (0x80000000 >> (28 + CONFIG_SYS_NAND_CS));
Wolfgang Denk4df0da52006-10-09 00:42:01 +0200120 mtsdr(SDR0_CUST0, sdr0_cust0);
Stefan Roese42fbddd2006-09-07 11:51:23 +0200121
122 return 0;
123}
124
Stefan Roese42fbddd2006-09-07 11:51:23 +0200125int misc_init_r(void)
126{
Stefan Roesec20ef322009-05-11 13:46:14 +0200127#if !defined(CONFIG_SYS_NO_FLASH)
Stefan Roese42fbddd2006-09-07 11:51:23 +0200128 uint pbcr;
129 int size_val = 0;
Stefan Roesec20ef322009-05-11 13:46:14 +0200130#endif
Stefan Roesebe6729c2006-09-13 13:51:58 +0200131#ifdef CONFIG_440EPX
Stefan Roese42fbddd2006-09-07 11:51:23 +0200132 unsigned long usb2d0cr = 0;
133 unsigned long usb2phy0cr, usb2h0cr = 0;
134 unsigned long sdr0_pfc1;
135 char *act = getenv("usbact");
Stefan Roesebe6729c2006-09-13 13:51:58 +0200136#endif
Stefan Roesec20ef322009-05-11 13:46:14 +0200137 u32 reg;
Stefan Roese42fbddd2006-09-07 11:51:23 +0200138
Stefan Roesec20ef322009-05-11 13:46:14 +0200139#if !defined(CONFIG_SYS_NO_FLASH)
Matthias Fuchs62357702008-01-16 10:33:46 +0100140 /* Re-do flash sizing to get full correct info */
Stefan Roeseab8e99b2006-12-22 14:29:40 +0100141
142 /* adjust flash start and offset */
143 gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize;
144 gd->bd->bi_flashoffset = 0;
145
Stefan Roeseb3859f22014-03-04 15:34:35 +0100146#if defined(CONFIG_SYS_RAMBOOT)
Stefan Roese918010a2009-09-09 16:25:29 +0200147 mtdcr(EBC0_CFGADDR, PB3CR);
Stefan Roese42fbddd2006-09-07 11:51:23 +0200148#else
Stefan Roese918010a2009-09-09 16:25:29 +0200149 mtdcr(EBC0_CFGADDR, PB0CR);
Stefan Roese42fbddd2006-09-07 11:51:23 +0200150#endif
Stefan Roese918010a2009-09-09 16:25:29 +0200151 pbcr = mfdcr(EBC0_CFGDATA);
Wolfgang Denk3595e612008-01-23 14:31:17 +0100152 size_val = ffs(gd->bd->bi_flashsize) - 21;
Stefan Roese42fbddd2006-09-07 11:51:23 +0200153 pbcr = (pbcr & 0x0001ffff) | gd->bd->bi_flashstart | (size_val << 17);
Stefan Roeseb3859f22014-03-04 15:34:35 +0100154#if defined(CONFIG_SYS_RAMBOOT)
Stefan Roese918010a2009-09-09 16:25:29 +0200155 mtdcr(EBC0_CFGADDR, PB3CR);
Stefan Roese42fbddd2006-09-07 11:51:23 +0200156#else
Stefan Roese918010a2009-09-09 16:25:29 +0200157 mtdcr(EBC0_CFGADDR, PB0CR);
Stefan Roese42fbddd2006-09-07 11:51:23 +0200158#endif
Stefan Roese918010a2009-09-09 16:25:29 +0200159 mtdcr(EBC0_CFGDATA, pbcr);
Stefan Roese42fbddd2006-09-07 11:51:23 +0200160
Stefan Roeseab8e99b2006-12-22 14:29:40 +0100161 /*
162 * Re-check to get correct base address
163 */
164 flash_get_size(gd->bd->bi_flashstart, 0);
Stefan Roese42fbddd2006-09-07 11:51:23 +0200165
Jean-Christophe PLAGNIOL-VILLARD53db4cd2008-09-10 22:48:04 +0200166#ifdef CONFIG_ENV_IS_IN_FLASH
Stefan Roese42fbddd2006-09-07 11:51:23 +0200167 /* Monitor protection ON by default */
168 (void)flash_protect(FLAG_PROTECT_SET,
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200169 -CONFIG_SYS_MONITOR_LEN,
Stefan Roese42fbddd2006-09-07 11:51:23 +0200170 0xffffffff,
171 &flash_info[0]);
172
173 /* Env protection ON by default */
174 (void)flash_protect(FLAG_PROTECT_SET,
Jean-Christophe PLAGNIOL-VILLARD7e1cda62008-09-10 22:48:06 +0200175 CONFIG_ENV_ADDR_REDUND,
176 CONFIG_ENV_ADDR_REDUND + 2*CONFIG_ENV_SECT_SIZE - 1,
Stefan Roese42fbddd2006-09-07 11:51:23 +0200177 &flash_info[0]);
178#endif
Stefan Roesec20ef322009-05-11 13:46:14 +0200179#endif /* CONFIG_SYS_NO_FLASH */
Stefan Roese42fbddd2006-09-07 11:51:23 +0200180
181 /*
182 * USB suff...
183 */
Stefan Roesebe6729c2006-09-13 13:51:58 +0200184#ifdef CONFIG_440EPX
Matthias Fuchs62357702008-01-16 10:33:46 +0100185 if (act == NULL || strcmp(act, "hostdev") == 0) {
Stefan Roese42fbddd2006-09-07 11:51:23 +0200186 /* SDR Setting */
Wolfgang Denk4df0da52006-10-09 00:42:01 +0200187 mfsdr(SDR0_PFC1, sdr0_pfc1);
Niklaus Giger77cad902007-06-27 18:11:38 +0200188 mfsdr(SDR0_USB2D0CR, usb2d0cr);
Wolfgang Denk4df0da52006-10-09 00:42:01 +0200189 mfsdr(SDR0_USB2PHY0CR, usb2phy0cr);
190 mfsdr(SDR0_USB2H0CR, usb2h0cr);
Stefan Roese42fbddd2006-09-07 11:51:23 +0200191
192 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_XOCLK_MASK;
Matthias Fuchs62357702008-01-16 10:33:46 +0100193 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_XOCLK_EXTERNAL;
Wolfgang Denk4df0da52006-10-09 00:42:01 +0200194 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_WDINT_MASK;
Matthias Fuchs62357702008-01-16 10:33:46 +0100195 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_WDINT_16BIT_30MHZ;
Stefan Roese42fbddd2006-09-07 11:51:23 +0200196 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DVBUS_MASK;
Matthias Fuchs62357702008-01-16 10:33:46 +0100197 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DVBUS_PURDIS;
Stefan Roese42fbddd2006-09-07 11:51:23 +0200198 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DWNSTR_MASK;
Matthias Fuchs62357702008-01-16 10:33:46 +0100199 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DWNSTR_HOST;
Stefan Roese42fbddd2006-09-07 11:51:23 +0200200 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_UTMICN_MASK;
Matthias Fuchs62357702008-01-16 10:33:46 +0100201 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_UTMICN_HOST;
Stefan Roese42fbddd2006-09-07 11:51:23 +0200202
Matthias Fuchs62357702008-01-16 10:33:46 +0100203 /*
204 * An 8-bit/60MHz interface is the only possible alternative
205 * when connecting the Device to the PHY
206 */
Wolfgang Denk4df0da52006-10-09 00:42:01 +0200207 usb2h0cr = usb2h0cr &~SDR0_USB2H0CR_WDINT_MASK;
Matthias Fuchs62357702008-01-16 10:33:46 +0100208 usb2h0cr = usb2h0cr | SDR0_USB2H0CR_WDINT_16BIT_30MHZ;
Stefan Roese42fbddd2006-09-07 11:51:23 +0200209
Matthias Fuchs62357702008-01-16 10:33:46 +0100210 /*
211 * To enable the USB 2.0 Device function
212 * through the UTMI interface
213 */
Wolfgang Denk4df0da52006-10-09 00:42:01 +0200214 usb2d0cr = usb2d0cr &~SDR0_USB2D0CR_USB2DEV_EBC_SEL_MASK;
Matthias Fuchs62357702008-01-16 10:33:46 +0100215 usb2d0cr = usb2d0cr | SDR0_USB2D0CR_USB2DEV_SELECTION;
Stefan Roese42fbddd2006-09-07 11:51:23 +0200216
Wolfgang Denk4df0da52006-10-09 00:42:01 +0200217 sdr0_pfc1 = sdr0_pfc1 &~SDR0_PFC1_UES_MASK;
Matthias Fuchs62357702008-01-16 10:33:46 +0100218 sdr0_pfc1 = sdr0_pfc1 | SDR0_PFC1_UES_USB2D_SEL;
Stefan Roese42fbddd2006-09-07 11:51:23 +0200219
Wolfgang Denk4df0da52006-10-09 00:42:01 +0200220 mtsdr(SDR0_PFC1, sdr0_pfc1);
Niklaus Giger77cad902007-06-27 18:11:38 +0200221 mtsdr(SDR0_USB2D0CR, usb2d0cr);
Wolfgang Denk4df0da52006-10-09 00:42:01 +0200222 mtsdr(SDR0_USB2PHY0CR, usb2phy0cr);
223 mtsdr(SDR0_USB2H0CR, usb2h0cr);
Stefan Roese42fbddd2006-09-07 11:51:23 +0200224
225 /*clear resets*/
226 udelay (1000);
227 mtsdr(SDR0_SRST1, 0x00000000);
228 udelay (1000);
229 mtsdr(SDR0_SRST0, 0x00000000);
230
231 printf("USB: Host(int phy) Device(ext phy)\n");
232
233 } else if (strcmp(act, "dev") == 0) {
234 /*-------------------PATCH-------------------------------*/
235 mfsdr(SDR0_USB2PHY0CR, usb2phy0cr);
236
237 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_XOCLK_MASK;
Matthias Fuchs62357702008-01-16 10:33:46 +0100238 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_XOCLK_EXTERNAL;
Stefan Roese42fbddd2006-09-07 11:51:23 +0200239 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DVBUS_MASK;
Matthias Fuchs62357702008-01-16 10:33:46 +0100240 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DVBUS_PURDIS;
Stefan Roese42fbddd2006-09-07 11:51:23 +0200241 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DWNSTR_MASK;
Matthias Fuchs62357702008-01-16 10:33:46 +0100242 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DWNSTR_HOST;
Stefan Roese42fbddd2006-09-07 11:51:23 +0200243 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_UTMICN_MASK;
Matthias Fuchs62357702008-01-16 10:33:46 +0100244 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_UTMICN_HOST;
Stefan Roese42fbddd2006-09-07 11:51:23 +0200245 mtsdr(SDR0_USB2PHY0CR, usb2phy0cr);
246
247 udelay (1000);
248 mtsdr(SDR0_SRST1, 0x672c6000);
249
250 udelay (1000);
251 mtsdr(SDR0_SRST0, 0x00000080);
252
253 udelay (1000);
254 mtsdr(SDR0_SRST1, 0x60206000);
255
256 *(unsigned int *)(0xe0000350) = 0x00000001;
257
258 udelay (1000);
259 mtsdr(SDR0_SRST1, 0x60306000);
260 /*-------------------PATCH-------------------------------*/
261
262 /* SDR Setting */
Wolfgang Denk4df0da52006-10-09 00:42:01 +0200263 mfsdr(SDR0_USB2PHY0CR, usb2phy0cr);
Stefan Roese42fbddd2006-09-07 11:51:23 +0200264 mfsdr(SDR0_USB2H0CR, usb2h0cr);
Niklaus Giger77cad902007-06-27 18:11:38 +0200265 mfsdr(SDR0_USB2D0CR, usb2d0cr);
Stefan Roese42fbddd2006-09-07 11:51:23 +0200266 mfsdr(SDR0_PFC1, sdr0_pfc1);
267
268 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_XOCLK_MASK;
Matthias Fuchs62357702008-01-16 10:33:46 +0100269 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_XOCLK_EXTERNAL;
Wolfgang Denk4df0da52006-10-09 00:42:01 +0200270 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_WDINT_MASK;
Matthias Fuchs62357702008-01-16 10:33:46 +0100271 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_WDINT_8BIT_60MHZ;
Stefan Roese42fbddd2006-09-07 11:51:23 +0200272 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DVBUS_MASK;
Matthias Fuchs62357702008-01-16 10:33:46 +0100273 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DVBUS_PUREN;
Stefan Roese42fbddd2006-09-07 11:51:23 +0200274 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DWNSTR_MASK;
Matthias Fuchs62357702008-01-16 10:33:46 +0100275 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DWNSTR_DEV;
Stefan Roese42fbddd2006-09-07 11:51:23 +0200276 usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_UTMICN_MASK;
Matthias Fuchs62357702008-01-16 10:33:46 +0100277 usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_UTMICN_DEV;
Stefan Roese42fbddd2006-09-07 11:51:23 +0200278
279 usb2h0cr = usb2h0cr &~SDR0_USB2H0CR_WDINT_MASK;
Matthias Fuchs62357702008-01-16 10:33:46 +0100280 usb2h0cr = usb2h0cr | SDR0_USB2H0CR_WDINT_8BIT_60MHZ;
Stefan Roese42fbddd2006-09-07 11:51:23 +0200281
282 usb2d0cr = usb2d0cr &~SDR0_USB2D0CR_USB2DEV_EBC_SEL_MASK;
Matthias Fuchs62357702008-01-16 10:33:46 +0100283 usb2d0cr = usb2d0cr | SDR0_USB2D0CR_EBC_SELECTION;
Stefan Roese42fbddd2006-09-07 11:51:23 +0200284
285 sdr0_pfc1 = sdr0_pfc1 &~SDR0_PFC1_UES_MASK;
Matthias Fuchs62357702008-01-16 10:33:46 +0100286 sdr0_pfc1 = sdr0_pfc1 | SDR0_PFC1_UES_EBCHR_SEL;
Stefan Roese42fbddd2006-09-07 11:51:23 +0200287
Wolfgang Denk4df0da52006-10-09 00:42:01 +0200288 mtsdr(SDR0_USB2H0CR, usb2h0cr);
289 mtsdr(SDR0_USB2PHY0CR, usb2phy0cr);
Niklaus Giger77cad902007-06-27 18:11:38 +0200290 mtsdr(SDR0_USB2D0CR, usb2d0cr);
Stefan Roese42fbddd2006-09-07 11:51:23 +0200291 mtsdr(SDR0_PFC1, sdr0_pfc1);
292
Matthias Fuchs62357702008-01-16 10:33:46 +0100293 /* clear resets */
Stefan Roese42fbddd2006-09-07 11:51:23 +0200294 udelay (1000);
295 mtsdr(SDR0_SRST1, 0x00000000);
296 udelay (1000);
297 mtsdr(SDR0_SRST0, 0x00000000);
298
299 printf("USB: Device(int phy)\n");
300 }
Stefan Roesebe6729c2006-09-13 13:51:58 +0200301#endif /* CONFIG_440EPX */
Stefan Roese42fbddd2006-09-07 11:51:23 +0200302
John Otken john@softadvances.coma70d4082007-03-08 09:39:48 -0600303 mfsdr(SDR0_SRST1, reg); /* enable security/kasumi engines */
304 reg &= ~(SDR0_SRST1_CRYP0 | SDR0_SRST1_KASU0);
305 mtsdr(SDR0_SRST1, reg);
306
Stefan Roesebc7057d2007-01-05 10:40:36 +0100307 /*
308 * Clear PLB4A0_ACR[WRP]
309 * This fix will make the MAL burst disabling patch for the Linux
310 * EMAC driver obsolete.
311 */
Stefan Roese95ca5fa2010-09-11 09:31:43 +0200312 reg = mfdcr(PLB4A0_ACR) & ~PLB4Ax_ACR_WRP_MASK;
313 mtdcr(PLB4A0_ACR, reg);
Stefan Roesebc7057d2007-01-05 10:40:36 +0100314
Stefan Roese42fbddd2006-09-07 11:51:23 +0200315 return 0;
316}
317
318int checkboard(void)
319{
Wolfgang Denk5c1cfee2011-05-04 10:32:28 +0000320 char buf[64];
321 int i = getenv_f("serial#", buf, sizeof(buf));
Stefan Roeseeda436a2007-01-13 07:57:51 +0100322 u8 rev;
Stefan Roesee7f30922009-10-19 14:10:50 +0200323 u32 clock = get_async_pci_freq();
Stefan Roese42fbddd2006-09-07 11:51:23 +0200324
Stefan Roesebe6729c2006-09-13 13:51:58 +0200325#ifdef CONFIG_440EPX
Stefan Roese42fbddd2006-09-07 11:51:23 +0200326 printf("Board: Sequoia - AMCC PPC440EPx Evaluation Board");
Stefan Roesebe6729c2006-09-13 13:51:58 +0200327#else
328 printf("Board: Rainier - AMCC PPC440GRx Evaluation Board");
329#endif
Stefan Roeseeda436a2007-01-13 07:57:51 +0100330
Jean-Christophe PLAGNIOL-VILLARD03836942008-10-16 15:01:15 +0200331 rev = in_8((void *)(CONFIG_SYS_BCSR_BASE + 0));
Stefan Roesee7f30922009-10-19 14:10:50 +0200332 printf(", Rev. %X, PCI-Async=%d MHz", rev, clock / 1000000);
Stefan Roeseeda436a2007-01-13 07:57:51 +0100333
Wolfgang Denk5c1cfee2011-05-04 10:32:28 +0000334 if (i > 0) {
Stefan Roese42fbddd2006-09-07 11:51:23 +0200335 puts(", serial# ");
Wolfgang Denk5c1cfee2011-05-04 10:32:28 +0000336 puts(buf);
Stefan Roese42fbddd2006-09-07 11:51:23 +0200337 }
338 putc('\n');
339
Stefan Roesee7f30922009-10-19 14:10:50 +0200340 /*
341 * Reconfiguration of the PCI sync clock is already done,
342 * now check again if everything is in range:
343 */
344 if (ppc4xx_pci_sync_clock_config(clock)) {
345 printf("ERROR: PCI clocking incorrect (async=%d "
346 "sync=%ld)!\n", clock, get_PCI_freq());
347 }
348
Stefan Roese42fbddd2006-09-07 11:51:23 +0200349 return (0);
350}
351
Matthias Fuchseb267ba2008-01-08 15:40:09 +0100352#if defined(CONFIG_PCI) && defined(CONFIG_PCI_PNP)
353/*
354 * Assign interrupts to PCI devices.
355 */
Stefan Roese5d8033e2009-11-12 16:41:09 +0100356void board_pci_fixup_irq(struct pci_controller *hose, pci_dev_t dev)
Matthias Fuchseb267ba2008-01-08 15:40:09 +0100357{
Stefan Roese01edcea2008-06-26 13:40:57 +0200358 pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, VECNUM_EIRQ2);
Matthias Fuchseb267ba2008-01-08 15:40:09 +0100359}
360#endif
361
Stefan Roeseb3859f22014-03-04 15:34:35 +0100362#if defined(CONFIG_SYS_RAMBOOT)
Stefan Roesec55fc7a2009-04-08 10:36:22 +0200363/*
364 * On NAND-booting sequoia, we need to patch the chips select numbers
365 * in the dtb (CS0 - NAND, CS3 - NOR)
366 */
Simon Glass2aec3cc2014-10-23 18:58:47 -0600367int ft_board_setup(void *blob, bd_t *bd)
Stefan Roesec55fc7a2009-04-08 10:36:22 +0200368{
369 int rc;
370 int len;
371 int nodeoffset;
372 struct fdt_property *prop;
373 u32 *reg;
374 char path[32];
375
376 /* First do common fdt setup */
377 __ft_board_setup(blob, bd);
378
379 /* And now configure NOR chip select to 3 instead of 0 */
380 strcpy(path, "/plb/opb/ebc/nor_flash@0,0");
381 nodeoffset = fdt_path_offset(blob, path);
382 prop = fdt_get_property_w(blob, nodeoffset, "reg", &len);
383 if (prop == NULL) {
384 printf("Unable to update NOR chip select for NAND booting\n");
Simon Glass2aec3cc2014-10-23 18:58:47 -0600385 return -FDT_ERR_NOTFOUND;
Stefan Roesec55fc7a2009-04-08 10:36:22 +0200386 }
387 reg = (u32 *)&prop->data[0];
388 reg[0] = 3;
389 rc = fdt_find_and_setprop(blob, path, "reg", reg, 3 * sizeof(u32), 1);
390 if (rc) {
Simon Glass2aec3cc2014-10-23 18:58:47 -0600391 printf("Unable to update property NOR mappings\n");
392 return rc;
Stefan Roesec55fc7a2009-04-08 10:36:22 +0200393 }
394
395 /* And now configure NAND chip select to 0 instead of 3 */
396 strcpy(path, "/plb/opb/ebc/ndfc@3,0");
397 nodeoffset = fdt_path_offset(blob, path);
398 prop = fdt_get_property_w(blob, nodeoffset, "reg", &len);
399 if (prop == NULL) {
400 printf("Unable to update NDFC chip select for NAND booting\n");
Simon Glass2aec3cc2014-10-23 18:58:47 -0600401 return len;
Stefan Roesec55fc7a2009-04-08 10:36:22 +0200402 }
403 reg = (u32 *)&prop->data[0];
404 reg[0] = 0;
405 rc = fdt_find_and_setprop(blob, path, "reg", reg, 3 * sizeof(u32), 1);
406 if (rc) {
Simon Glass2aec3cc2014-10-23 18:58:47 -0600407 printf("Unable to update property NDFC mapping\n");
408 return rc;
Stefan Roesec55fc7a2009-04-08 10:36:22 +0200409 }
Simon Glass2aec3cc2014-10-23 18:58:47 -0600410
411 return 0;
Stefan Roesec55fc7a2009-04-08 10:36:22 +0200412}
Stefan Roeseb3859f22014-03-04 15:34:35 +0100413#endif /* CONFIG_SYS_RAMBOOT */