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