Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 1 | /* |
Stefan Roese | c55fc7a | 2009-04-08 10:36:22 +0200 | [diff] [blame] | 2 | * (C) Copyright 2006-2009 |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 3 | * 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 Denk | 3595e61 | 2008-01-23 14:31:17 +0100 | [diff] [blame] | 7 | * Alain Saurel, AMCC/IBM, alain.saurel@fr.ibm.com |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 8 | * |
| 9 | * This program is free software; you can redistribute it and/or |
| 10 | * modify it under the terms of the GNU General Public License as |
| 11 | * published by the Free Software Foundation; either version 2 of |
| 12 | * the License, or (at your option) any later version. |
| 13 | * |
| 14 | * This program is distributed in the hope that it will be useful, |
| 15 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | * GNU General Public License for more details. |
| 18 | * |
| 19 | * You should have received a copy of the GNU General Public License |
| 20 | * along with this program; if not, write to the Free Software |
| 21 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 22 | * MA 02111-1307 USA |
| 23 | */ |
| 24 | |
| 25 | #include <common.h> |
Stefan Roese | fbcee00 | 2007-12-13 14:52:53 +0100 | [diff] [blame] | 26 | #include <libfdt.h> |
| 27 | #include <fdt_support.h> |
Stefan Roese | 247e9d7 | 2010-09-09 19:18:00 +0200 | [diff] [blame] | 28 | #include <asm/ppc4xx.h> |
Stefan Roese | de21eab | 2010-09-16 14:30:37 +0200 | [diff] [blame] | 29 | #include <asm/ppc4xx-gpio.h> |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 30 | #include <asm/processor.h> |
Stefan Roese | fa25747 | 2007-10-15 11:29:33 +0200 | [diff] [blame] | 31 | #include <asm/io.h> |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 32 | #include <asm/bitops.h> |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 33 | |
| 34 | DECLARE_GLOBAL_DATA_PTR; |
| 35 | |
Stefan Roese | c20ef32 | 2009-05-11 13:46:14 +0200 | [diff] [blame] | 36 | #if !defined(CONFIG_SYS_NO_FLASH) |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 37 | extern flash_info_t flash_info[CONFIG_SYS_MAX_FLASH_BANKS]; /* info for FLASH chips */ |
Stefan Roese | c20ef32 | 2009-05-11 13:46:14 +0200 | [diff] [blame] | 38 | #endif |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 39 | |
Stefan Roese | c55fc7a | 2009-04-08 10:36:22 +0200 | [diff] [blame] | 40 | extern void __ft_board_setup(void *blob, bd_t *bd); |
| 41 | ulong flash_get_size(ulong base, int banknum); |
Stefan Roese | ab8e99b | 2006-12-22 14:29:40 +0100 | [diff] [blame] | 42 | |
Stefan Roese | e7f3092 | 2009-10-19 14:10:50 +0200 | [diff] [blame] | 43 | static inline u32 get_async_pci_freq(void) |
| 44 | { |
| 45 | if (in_8((void *)(CONFIG_SYS_BCSR_BASE + 5)) & |
| 46 | CONFIG_SYS_BCSR5_PCI66EN) |
| 47 | return 66666666; |
| 48 | else |
| 49 | return 33333333; |
| 50 | } |
| 51 | |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 52 | int board_early_init_f(void) |
| 53 | { |
Stefan Roese | bc7057d | 2007-01-05 10:40:36 +0100 | [diff] [blame] | 54 | u32 sdr0_cust0; |
| 55 | u32 sdr0_pfc1, sdr0_pfc2; |
| 56 | u32 reg; |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 57 | |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 58 | mtdcr(EBC0_CFGADDR, EBC0_CFG); |
| 59 | mtdcr(EBC0_CFGDATA, 0xb8400000); |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 60 | |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 61 | /* |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 62 | * Setup the interrupt controller polarities, triggers, etc. |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 63 | */ |
Stefan Roese | 707fd36 | 2009-09-24 09:55:50 +0200 | [diff] [blame] | 64 | mtdcr(UIC0SR, 0xffffffff); /* clear all */ |
| 65 | mtdcr(UIC0ER, 0x00000000); /* disable all */ |
| 66 | mtdcr(UIC0CR, 0x00000005); /* ATI & UIC1 crit are critical */ |
| 67 | mtdcr(UIC0PR, 0xfffff7ff); /* per ref-board manual */ |
| 68 | mtdcr(UIC0TR, 0x00000000); /* per ref-board manual */ |
| 69 | mtdcr(UIC0VR, 0x00000000); /* int31 highest, base=0x000 */ |
| 70 | mtdcr(UIC0SR, 0xffffffff); /* clear all */ |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 71 | |
Stefan Roese | 707fd36 | 2009-09-24 09:55:50 +0200 | [diff] [blame] | 72 | mtdcr(UIC1SR, 0xffffffff); /* clear all */ |
| 73 | mtdcr(UIC1ER, 0x00000000); /* disable all */ |
| 74 | mtdcr(UIC1CR, 0x00000000); /* all non-critical */ |
| 75 | mtdcr(UIC1PR, 0xffffffff); /* per ref-board manual */ |
| 76 | mtdcr(UIC1TR, 0x00000000); /* per ref-board manual */ |
| 77 | mtdcr(UIC1VR, 0x00000000); /* int31 highest, base=0x000 */ |
| 78 | mtdcr(UIC1SR, 0xffffffff); /* clear all */ |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 79 | |
Stefan Roese | 707fd36 | 2009-09-24 09:55:50 +0200 | [diff] [blame] | 80 | mtdcr(UIC2SR, 0xffffffff); /* clear all */ |
| 81 | mtdcr(UIC2ER, 0x00000000); /* disable all */ |
| 82 | mtdcr(UIC2CR, 0x00000000); /* all non-critical */ |
| 83 | mtdcr(UIC2PR, 0xffffffff); /* per ref-board manual */ |
| 84 | mtdcr(UIC2TR, 0x00000000); /* per ref-board manual */ |
| 85 | mtdcr(UIC2VR, 0x00000000); /* int31 highest, base=0x000 */ |
| 86 | mtdcr(UIC2SR, 0xffffffff); /* clear all */ |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 87 | |
Stefan Roese | e7f3092 | 2009-10-19 14:10:50 +0200 | [diff] [blame] | 88 | /* Check and reconfigure the PCI sync clock if necessary */ |
| 89 | ppc4xx_pci_sync_clock_config(get_async_pci_freq()); |
| 90 | |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 91 | /* 50MHz tmrclk */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 92 | out_8((u8 *) CONFIG_SYS_BCSR_BASE + 0x04, 0x00); |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 93 | |
| 94 | /* clear write protects */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 95 | out_8((u8 *) CONFIG_SYS_BCSR_BASE + 0x07, 0x00); |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 96 | |
| 97 | /* enable Ethernet */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 98 | out_8((u8 *) CONFIG_SYS_BCSR_BASE + 0x08, 0x00); |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 99 | |
| 100 | /* enable USB device */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 101 | out_8((u8 *) CONFIG_SYS_BCSR_BASE + 0x09, 0x20); |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 102 | |
Mike Nuss | 383b145 | 2008-02-06 11:10:11 -0500 | [diff] [blame] | 103 | /* select Ethernet (and optionally IIC1) pins */ |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 104 | mfsdr(SDR0_PFC1, sdr0_pfc1); |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 105 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_SELECT_MASK) | |
| 106 | SDR0_PFC1_SELECT_CONFIG_4; |
Mike Nuss | 383b145 | 2008-02-06 11:10:11 -0500 | [diff] [blame] | 107 | #ifdef CONFIG_I2C_MULTI_BUS |
| 108 | sdr0_pfc1 |= ((sdr0_pfc1 & ~SDR0_PFC1_SIS_MASK) | SDR0_PFC1_SIS_IIC1_SEL); |
| 109 | #endif |
Steven A. Falco | 7bf9cc6 | 2008-08-06 15:42:52 -0400 | [diff] [blame] | 110 | /* Two UARTs, so we need 4-pin mode. Also, we want CTS/RTS mode. */ |
| 111 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0IM_MASK) | SDR0_PFC1_U0IM_4PINS; |
| 112 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U0ME_MASK) | SDR0_PFC1_U0ME_CTS_RTS; |
| 113 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_U1ME_MASK) | SDR0_PFC1_U1ME_CTS_RTS; |
| 114 | |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 115 | mfsdr(SDR0_PFC2, sdr0_pfc2); |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 116 | sdr0_pfc2 = (sdr0_pfc2 & ~SDR0_PFC2_SELECT_MASK) | |
| 117 | SDR0_PFC2_SELECT_CONFIG_4; |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 118 | mtsdr(SDR0_PFC2, sdr0_pfc2); |
| 119 | mtsdr(SDR0_PFC1, sdr0_pfc1); |
| 120 | |
| 121 | /* PCI arbiter enabled */ |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 122 | mfsdr(SDR0_PCI0, reg); |
| 123 | mtsdr(SDR0_PCI0, 0x80000000 | reg); |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 124 | |
| 125 | /* setup NAND FLASH */ |
| 126 | mfsdr(SDR0_CUST0, sdr0_cust0); |
Wolfgang Denk | 4df0da5 | 2006-10-09 00:42:01 +0200 | [diff] [blame] | 127 | sdr0_cust0 = SDR0_CUST0_MUX_NDFC_SEL | |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 128 | SDR0_CUST0_NDFC_ENABLE | |
| 129 | SDR0_CUST0_NDFC_BW_8_BIT | |
| 130 | SDR0_CUST0_NDFC_ARE_MASK | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 131 | (0x80000000 >> (28 + CONFIG_SYS_NAND_CS)); |
Wolfgang Denk | 4df0da5 | 2006-10-09 00:42:01 +0200 | [diff] [blame] | 132 | mtsdr(SDR0_CUST0, sdr0_cust0); |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 133 | |
| 134 | return 0; |
| 135 | } |
| 136 | |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 137 | int misc_init_r(void) |
| 138 | { |
Stefan Roese | c20ef32 | 2009-05-11 13:46:14 +0200 | [diff] [blame] | 139 | #if !defined(CONFIG_SYS_NO_FLASH) |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 140 | uint pbcr; |
| 141 | int size_val = 0; |
Stefan Roese | c20ef32 | 2009-05-11 13:46:14 +0200 | [diff] [blame] | 142 | #endif |
Stefan Roese | be6729c | 2006-09-13 13:51:58 +0200 | [diff] [blame] | 143 | #ifdef CONFIG_440EPX |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 144 | unsigned long usb2d0cr = 0; |
| 145 | unsigned long usb2phy0cr, usb2h0cr = 0; |
| 146 | unsigned long sdr0_pfc1; |
| 147 | char *act = getenv("usbact"); |
Stefan Roese | be6729c | 2006-09-13 13:51:58 +0200 | [diff] [blame] | 148 | #endif |
Stefan Roese | c20ef32 | 2009-05-11 13:46:14 +0200 | [diff] [blame] | 149 | u32 reg; |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 150 | |
Stefan Roese | c20ef32 | 2009-05-11 13:46:14 +0200 | [diff] [blame] | 151 | #if !defined(CONFIG_SYS_NO_FLASH) |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 152 | /* Re-do flash sizing to get full correct info */ |
Stefan Roese | ab8e99b | 2006-12-22 14:29:40 +0100 | [diff] [blame] | 153 | |
| 154 | /* adjust flash start and offset */ |
| 155 | gd->bd->bi_flashstart = 0 - gd->bd->bi_flashsize; |
| 156 | gd->bd->bi_flashoffset = 0; |
| 157 | |
Stefan Roese | 99c744f | 2010-10-11 15:50:10 +0200 | [diff] [blame] | 158 | #if defined(CONFIG_NAND_U_BOOT) || defined(CONFIG_NAND_SPL) || \ |
| 159 | defined(CONFIG_SYS_RAMBOOT) |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 160 | mtdcr(EBC0_CFGADDR, PB3CR); |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 161 | #else |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 162 | mtdcr(EBC0_CFGADDR, PB0CR); |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 163 | #endif |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 164 | pbcr = mfdcr(EBC0_CFGDATA); |
Wolfgang Denk | 3595e61 | 2008-01-23 14:31:17 +0100 | [diff] [blame] | 165 | size_val = ffs(gd->bd->bi_flashsize) - 21; |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 166 | pbcr = (pbcr & 0x0001ffff) | gd->bd->bi_flashstart | (size_val << 17); |
Stefan Roese | 99c744f | 2010-10-11 15:50:10 +0200 | [diff] [blame] | 167 | #if defined(CONFIG_NAND_U_BOOT) || defined(CONFIG_NAND_SPL) || \ |
| 168 | defined(CONFIG_SYS_RAMBOOT) |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 169 | mtdcr(EBC0_CFGADDR, PB3CR); |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 170 | #else |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 171 | mtdcr(EBC0_CFGADDR, PB0CR); |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 172 | #endif |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 173 | mtdcr(EBC0_CFGDATA, pbcr); |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 174 | |
Stefan Roese | ab8e99b | 2006-12-22 14:29:40 +0100 | [diff] [blame] | 175 | /* |
| 176 | * Re-check to get correct base address |
| 177 | */ |
| 178 | flash_get_size(gd->bd->bi_flashstart, 0); |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 179 | |
Jean-Christophe PLAGNIOL-VILLARD | 53db4cd | 2008-09-10 22:48:04 +0200 | [diff] [blame] | 180 | #ifdef CONFIG_ENV_IS_IN_FLASH |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 181 | /* Monitor protection ON by default */ |
| 182 | (void)flash_protect(FLAG_PROTECT_SET, |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 183 | -CONFIG_SYS_MONITOR_LEN, |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 184 | 0xffffffff, |
| 185 | &flash_info[0]); |
| 186 | |
| 187 | /* Env protection ON by default */ |
| 188 | (void)flash_protect(FLAG_PROTECT_SET, |
Jean-Christophe PLAGNIOL-VILLARD | 7e1cda6 | 2008-09-10 22:48:06 +0200 | [diff] [blame] | 189 | CONFIG_ENV_ADDR_REDUND, |
| 190 | CONFIG_ENV_ADDR_REDUND + 2*CONFIG_ENV_SECT_SIZE - 1, |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 191 | &flash_info[0]); |
| 192 | #endif |
Stefan Roese | c20ef32 | 2009-05-11 13:46:14 +0200 | [diff] [blame] | 193 | #endif /* CONFIG_SYS_NO_FLASH */ |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 194 | |
| 195 | /* |
| 196 | * USB suff... |
| 197 | */ |
Stefan Roese | be6729c | 2006-09-13 13:51:58 +0200 | [diff] [blame] | 198 | #ifdef CONFIG_440EPX |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 199 | if (act == NULL || strcmp(act, "hostdev") == 0) { |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 200 | /* SDR Setting */ |
Wolfgang Denk | 4df0da5 | 2006-10-09 00:42:01 +0200 | [diff] [blame] | 201 | mfsdr(SDR0_PFC1, sdr0_pfc1); |
Niklaus Giger | 77cad90 | 2007-06-27 18:11:38 +0200 | [diff] [blame] | 202 | mfsdr(SDR0_USB2D0CR, usb2d0cr); |
Wolfgang Denk | 4df0da5 | 2006-10-09 00:42:01 +0200 | [diff] [blame] | 203 | mfsdr(SDR0_USB2PHY0CR, usb2phy0cr); |
| 204 | mfsdr(SDR0_USB2H0CR, usb2h0cr); |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 205 | |
| 206 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_XOCLK_MASK; |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 207 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_XOCLK_EXTERNAL; |
Wolfgang Denk | 4df0da5 | 2006-10-09 00:42:01 +0200 | [diff] [blame] | 208 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_WDINT_MASK; |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 209 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_WDINT_16BIT_30MHZ; |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 210 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DVBUS_MASK; |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 211 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DVBUS_PURDIS; |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 212 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DWNSTR_MASK; |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 213 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DWNSTR_HOST; |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 214 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_UTMICN_MASK; |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 215 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_UTMICN_HOST; |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 216 | |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 217 | /* |
| 218 | * An 8-bit/60MHz interface is the only possible alternative |
| 219 | * when connecting the Device to the PHY |
| 220 | */ |
Wolfgang Denk | 4df0da5 | 2006-10-09 00:42:01 +0200 | [diff] [blame] | 221 | usb2h0cr = usb2h0cr &~SDR0_USB2H0CR_WDINT_MASK; |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 222 | usb2h0cr = usb2h0cr | SDR0_USB2H0CR_WDINT_16BIT_30MHZ; |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 223 | |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 224 | /* |
| 225 | * To enable the USB 2.0 Device function |
| 226 | * through the UTMI interface |
| 227 | */ |
Wolfgang Denk | 4df0da5 | 2006-10-09 00:42:01 +0200 | [diff] [blame] | 228 | usb2d0cr = usb2d0cr &~SDR0_USB2D0CR_USB2DEV_EBC_SEL_MASK; |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 229 | usb2d0cr = usb2d0cr | SDR0_USB2D0CR_USB2DEV_SELECTION; |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 230 | |
Wolfgang Denk | 4df0da5 | 2006-10-09 00:42:01 +0200 | [diff] [blame] | 231 | sdr0_pfc1 = sdr0_pfc1 &~SDR0_PFC1_UES_MASK; |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 232 | sdr0_pfc1 = sdr0_pfc1 | SDR0_PFC1_UES_USB2D_SEL; |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 233 | |
Wolfgang Denk | 4df0da5 | 2006-10-09 00:42:01 +0200 | [diff] [blame] | 234 | mtsdr(SDR0_PFC1, sdr0_pfc1); |
Niklaus Giger | 77cad90 | 2007-06-27 18:11:38 +0200 | [diff] [blame] | 235 | mtsdr(SDR0_USB2D0CR, usb2d0cr); |
Wolfgang Denk | 4df0da5 | 2006-10-09 00:42:01 +0200 | [diff] [blame] | 236 | mtsdr(SDR0_USB2PHY0CR, usb2phy0cr); |
| 237 | mtsdr(SDR0_USB2H0CR, usb2h0cr); |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 238 | |
| 239 | /*clear resets*/ |
| 240 | udelay (1000); |
| 241 | mtsdr(SDR0_SRST1, 0x00000000); |
| 242 | udelay (1000); |
| 243 | mtsdr(SDR0_SRST0, 0x00000000); |
| 244 | |
| 245 | printf("USB: Host(int phy) Device(ext phy)\n"); |
| 246 | |
| 247 | } else if (strcmp(act, "dev") == 0) { |
| 248 | /*-------------------PATCH-------------------------------*/ |
| 249 | mfsdr(SDR0_USB2PHY0CR, usb2phy0cr); |
| 250 | |
| 251 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_XOCLK_MASK; |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 252 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_XOCLK_EXTERNAL; |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 253 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DVBUS_MASK; |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 254 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DVBUS_PURDIS; |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 255 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DWNSTR_MASK; |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 256 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DWNSTR_HOST; |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 257 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_UTMICN_MASK; |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 258 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_UTMICN_HOST; |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 259 | mtsdr(SDR0_USB2PHY0CR, usb2phy0cr); |
| 260 | |
| 261 | udelay (1000); |
| 262 | mtsdr(SDR0_SRST1, 0x672c6000); |
| 263 | |
| 264 | udelay (1000); |
| 265 | mtsdr(SDR0_SRST0, 0x00000080); |
| 266 | |
| 267 | udelay (1000); |
| 268 | mtsdr(SDR0_SRST1, 0x60206000); |
| 269 | |
| 270 | *(unsigned int *)(0xe0000350) = 0x00000001; |
| 271 | |
| 272 | udelay (1000); |
| 273 | mtsdr(SDR0_SRST1, 0x60306000); |
| 274 | /*-------------------PATCH-------------------------------*/ |
| 275 | |
| 276 | /* SDR Setting */ |
Wolfgang Denk | 4df0da5 | 2006-10-09 00:42:01 +0200 | [diff] [blame] | 277 | mfsdr(SDR0_USB2PHY0CR, usb2phy0cr); |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 278 | mfsdr(SDR0_USB2H0CR, usb2h0cr); |
Niklaus Giger | 77cad90 | 2007-06-27 18:11:38 +0200 | [diff] [blame] | 279 | mfsdr(SDR0_USB2D0CR, usb2d0cr); |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 280 | mfsdr(SDR0_PFC1, sdr0_pfc1); |
| 281 | |
| 282 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_XOCLK_MASK; |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 283 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_XOCLK_EXTERNAL; |
Wolfgang Denk | 4df0da5 | 2006-10-09 00:42:01 +0200 | [diff] [blame] | 284 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_WDINT_MASK; |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 285 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_WDINT_8BIT_60MHZ; |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 286 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DVBUS_MASK; |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 287 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DVBUS_PUREN; |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 288 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_DWNSTR_MASK; |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 289 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_DWNSTR_DEV; |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 290 | usb2phy0cr = usb2phy0cr &~SDR0_USB2PHY0CR_UTMICN_MASK; |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 291 | usb2phy0cr = usb2phy0cr | SDR0_USB2PHY0CR_UTMICN_DEV; |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 292 | |
| 293 | usb2h0cr = usb2h0cr &~SDR0_USB2H0CR_WDINT_MASK; |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 294 | usb2h0cr = usb2h0cr | SDR0_USB2H0CR_WDINT_8BIT_60MHZ; |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 295 | |
| 296 | usb2d0cr = usb2d0cr &~SDR0_USB2D0CR_USB2DEV_EBC_SEL_MASK; |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 297 | usb2d0cr = usb2d0cr | SDR0_USB2D0CR_EBC_SELECTION; |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 298 | |
| 299 | sdr0_pfc1 = sdr0_pfc1 &~SDR0_PFC1_UES_MASK; |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 300 | sdr0_pfc1 = sdr0_pfc1 | SDR0_PFC1_UES_EBCHR_SEL; |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 301 | |
Wolfgang Denk | 4df0da5 | 2006-10-09 00:42:01 +0200 | [diff] [blame] | 302 | mtsdr(SDR0_USB2H0CR, usb2h0cr); |
| 303 | mtsdr(SDR0_USB2PHY0CR, usb2phy0cr); |
Niklaus Giger | 77cad90 | 2007-06-27 18:11:38 +0200 | [diff] [blame] | 304 | mtsdr(SDR0_USB2D0CR, usb2d0cr); |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 305 | mtsdr(SDR0_PFC1, sdr0_pfc1); |
| 306 | |
Matthias Fuchs | 6235770 | 2008-01-16 10:33:46 +0100 | [diff] [blame] | 307 | /* clear resets */ |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 308 | udelay (1000); |
| 309 | mtsdr(SDR0_SRST1, 0x00000000); |
| 310 | udelay (1000); |
| 311 | mtsdr(SDR0_SRST0, 0x00000000); |
| 312 | |
| 313 | printf("USB: Device(int phy)\n"); |
| 314 | } |
Stefan Roese | be6729c | 2006-09-13 13:51:58 +0200 | [diff] [blame] | 315 | #endif /* CONFIG_440EPX */ |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 316 | |
John Otken john@softadvances.com | a70d408 | 2007-03-08 09:39:48 -0600 | [diff] [blame] | 317 | mfsdr(SDR0_SRST1, reg); /* enable security/kasumi engines */ |
| 318 | reg &= ~(SDR0_SRST1_CRYP0 | SDR0_SRST1_KASU0); |
| 319 | mtsdr(SDR0_SRST1, reg); |
| 320 | |
Stefan Roese | bc7057d | 2007-01-05 10:40:36 +0100 | [diff] [blame] | 321 | /* |
| 322 | * Clear PLB4A0_ACR[WRP] |
| 323 | * This fix will make the MAL burst disabling patch for the Linux |
| 324 | * EMAC driver obsolete. |
| 325 | */ |
Stefan Roese | 95ca5fa | 2010-09-11 09:31:43 +0200 | [diff] [blame] | 326 | reg = mfdcr(PLB4A0_ACR) & ~PLB4Ax_ACR_WRP_MASK; |
| 327 | mtdcr(PLB4A0_ACR, reg); |
Stefan Roese | bc7057d | 2007-01-05 10:40:36 +0100 | [diff] [blame] | 328 | |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 329 | return 0; |
| 330 | } |
| 331 | |
| 332 | int checkboard(void) |
| 333 | { |
Wolfgang Denk | 5c1cfee | 2011-05-04 10:32:28 +0000 | [diff] [blame] | 334 | char buf[64]; |
| 335 | int i = getenv_f("serial#", buf, sizeof(buf)); |
Stefan Roese | eda436a | 2007-01-13 07:57:51 +0100 | [diff] [blame] | 336 | u8 rev; |
Stefan Roese | e7f3092 | 2009-10-19 14:10:50 +0200 | [diff] [blame] | 337 | u32 clock = get_async_pci_freq(); |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 338 | |
Stefan Roese | be6729c | 2006-09-13 13:51:58 +0200 | [diff] [blame] | 339 | #ifdef CONFIG_440EPX |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 340 | printf("Board: Sequoia - AMCC PPC440EPx Evaluation Board"); |
Stefan Roese | be6729c | 2006-09-13 13:51:58 +0200 | [diff] [blame] | 341 | #else |
| 342 | printf("Board: Rainier - AMCC PPC440GRx Evaluation Board"); |
| 343 | #endif |
Stefan Roese | eda436a | 2007-01-13 07:57:51 +0100 | [diff] [blame] | 344 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 345 | rev = in_8((void *)(CONFIG_SYS_BCSR_BASE + 0)); |
Stefan Roese | e7f3092 | 2009-10-19 14:10:50 +0200 | [diff] [blame] | 346 | printf(", Rev. %X, PCI-Async=%d MHz", rev, clock / 1000000); |
Stefan Roese | eda436a | 2007-01-13 07:57:51 +0100 | [diff] [blame] | 347 | |
Wolfgang Denk | 5c1cfee | 2011-05-04 10:32:28 +0000 | [diff] [blame] | 348 | if (i > 0) { |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 349 | puts(", serial# "); |
Wolfgang Denk | 5c1cfee | 2011-05-04 10:32:28 +0000 | [diff] [blame] | 350 | puts(buf); |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 351 | } |
| 352 | putc('\n'); |
| 353 | |
Stefan Roese | e7f3092 | 2009-10-19 14:10:50 +0200 | [diff] [blame] | 354 | /* |
| 355 | * Reconfiguration of the PCI sync clock is already done, |
| 356 | * now check again if everything is in range: |
| 357 | */ |
| 358 | if (ppc4xx_pci_sync_clock_config(clock)) { |
| 359 | printf("ERROR: PCI clocking incorrect (async=%d " |
| 360 | "sync=%ld)!\n", clock, get_PCI_freq()); |
| 361 | } |
| 362 | |
Stefan Roese | 42fbddd | 2006-09-07 11:51:23 +0200 | [diff] [blame] | 363 | return (0); |
| 364 | } |
| 365 | |
Matthias Fuchs | eb267ba | 2008-01-08 15:40:09 +0100 | [diff] [blame] | 366 | #if defined(CONFIG_PCI) && defined(CONFIG_PCI_PNP) |
| 367 | /* |
| 368 | * Assign interrupts to PCI devices. |
| 369 | */ |
Stefan Roese | 5d8033e | 2009-11-12 16:41:09 +0100 | [diff] [blame] | 370 | void board_pci_fixup_irq(struct pci_controller *hose, pci_dev_t dev) |
Matthias Fuchs | eb267ba | 2008-01-08 15:40:09 +0100 | [diff] [blame] | 371 | { |
Stefan Roese | 01edcea | 2008-06-26 13:40:57 +0200 | [diff] [blame] | 372 | pci_hose_write_config_byte(hose, dev, PCI_INTERRUPT_LINE, VECNUM_EIRQ2); |
Matthias Fuchs | eb267ba | 2008-01-08 15:40:09 +0100 | [diff] [blame] | 373 | } |
| 374 | #endif |
| 375 | |
Stefan Roese | c20ef32 | 2009-05-11 13:46:14 +0200 | [diff] [blame] | 376 | #if defined(CONFIG_NAND_U_BOOT) || defined(CONFIG_SYS_RAMBOOT) |
Stefan Roese | c55fc7a | 2009-04-08 10:36:22 +0200 | [diff] [blame] | 377 | /* |
| 378 | * On NAND-booting sequoia, we need to patch the chips select numbers |
| 379 | * in the dtb (CS0 - NAND, CS3 - NOR) |
| 380 | */ |
| 381 | void ft_board_setup(void *blob, bd_t *bd) |
| 382 | { |
| 383 | int rc; |
| 384 | int len; |
| 385 | int nodeoffset; |
| 386 | struct fdt_property *prop; |
| 387 | u32 *reg; |
| 388 | char path[32]; |
| 389 | |
| 390 | /* First do common fdt setup */ |
| 391 | __ft_board_setup(blob, bd); |
| 392 | |
| 393 | /* And now configure NOR chip select to 3 instead of 0 */ |
| 394 | strcpy(path, "/plb/opb/ebc/nor_flash@0,0"); |
| 395 | nodeoffset = fdt_path_offset(blob, path); |
| 396 | prop = fdt_get_property_w(blob, nodeoffset, "reg", &len); |
| 397 | if (prop == NULL) { |
| 398 | printf("Unable to update NOR chip select for NAND booting\n"); |
| 399 | return; |
| 400 | } |
| 401 | reg = (u32 *)&prop->data[0]; |
| 402 | reg[0] = 3; |
| 403 | rc = fdt_find_and_setprop(blob, path, "reg", reg, 3 * sizeof(u32), 1); |
| 404 | if (rc) { |
| 405 | printf("Unable to update property NOR mappings, err=%s\n", |
| 406 | fdt_strerror(rc)); |
| 407 | return; |
| 408 | } |
| 409 | |
| 410 | /* And now configure NAND chip select to 0 instead of 3 */ |
| 411 | strcpy(path, "/plb/opb/ebc/ndfc@3,0"); |
| 412 | nodeoffset = fdt_path_offset(blob, path); |
| 413 | prop = fdt_get_property_w(blob, nodeoffset, "reg", &len); |
| 414 | if (prop == NULL) { |
| 415 | printf("Unable to update NDFC chip select for NAND booting\n"); |
| 416 | return; |
| 417 | } |
| 418 | reg = (u32 *)&prop->data[0]; |
| 419 | reg[0] = 0; |
| 420 | rc = fdt_find_and_setprop(blob, path, "reg", reg, 3 * sizeof(u32), 1); |
| 421 | if (rc) { |
| 422 | printf("Unable to update property NDFC mappings, err=%s\n", |
| 423 | fdt_strerror(rc)); |
| 424 | return; |
| 425 | } |
| 426 | } |
| 427 | #endif /* CONFIG_NAND_U_BOOT */ |