wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2004 PaulReynolds@lhsolutions.com |
| 3 | * |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 4 | * (C) Copyright 2005 |
| 5 | * Stefan Roese, DENX Software Engineering, sr@denx.de. |
| 6 | * |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 7 | * See file CREDITS for list of people who contributed to this |
| 8 | * project. |
| 9 | * |
| 10 | * This program is free software; you can redistribute it and/or |
| 11 | * modify it under the terms of the GNU General Public License as |
| 12 | * published by the Free Software Foundation; either version 2 of |
| 13 | * the License, or (at your option) any later version. |
| 14 | * |
| 15 | * This program is distributed in the hope that it will be useful, |
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 18 | * GNU General Public License for more details. |
| 19 | * |
| 20 | * You should have received a copy of the GNU General Public License |
| 21 | * along with this program; if not, write to the Free Software |
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 23 | * MA 02111-1307 USA |
| 24 | */ |
| 25 | |
| 26 | |
| 27 | #include <common.h> |
| 28 | #include "ocotea.h" |
| 29 | #include <asm/processor.h> |
| 30 | #include <spd_sdram.h> |
Stefan Roese | 0c7ffc0 | 2005-08-16 18:18:00 +0200 | [diff] [blame] | 31 | #include <ppc4xx_enet.h> |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 32 | |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 33 | DECLARE_GLOBAL_DATA_PTR; |
| 34 | |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 35 | #define BOOT_SMALL_FLASH 32 /* 00100000 */ |
| 36 | #define FLASH_ONBD_N 2 /* 00000010 */ |
| 37 | #define FLASH_SRAM_SEL 1 /* 00000001 */ |
| 38 | |
| 39 | long int fixed_sdram (void); |
| 40 | void fpga_init (void); |
| 41 | |
| 42 | int board_early_init_f (void) |
| 43 | { |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 44 | unsigned long mfr; |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 45 | unsigned char *fpga_base = (unsigned char *) CONFIG_SYS_FPGA_BASE; |
stroese | 180e6f1 | 2005-04-07 05:35:12 +0000 | [diff] [blame] | 46 | unsigned char switch_status; |
| 47 | unsigned long cs0_base; |
| 48 | unsigned long cs0_size; |
| 49 | unsigned long cs0_twt; |
| 50 | unsigned long cs2_base; |
| 51 | unsigned long cs2_size; |
| 52 | unsigned long cs2_twt; |
| 53 | |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 54 | /*-------------------------------------------------------------------------+ |
| 55 | | Initialize EBC CONFIG |
| 56 | +-------------------------------------------------------------------------*/ |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 57 | mtebc(EBC0_CFG, EBC_CFG_LE_UNLOCK | |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 58 | EBC_CFG_PTD_ENABLE | EBC_CFG_RTC_64PERCLK | |
| 59 | EBC_CFG_ATC_PREVIOUS | EBC_CFG_DTC_PREVIOUS | |
| 60 | EBC_CFG_CTC_PREVIOUS | EBC_CFG_EMC_NONDEFAULT | |
| 61 | EBC_CFG_PME_DISABLE | EBC_CFG_PR_32); |
| 62 | |
| 63 | /*-------------------------------------------------------------------------+ |
stroese | 180e6f1 | 2005-04-07 05:35:12 +0000 | [diff] [blame] | 64 | | FPGA. Initialize bank 7 with default values. |
| 65 | +-------------------------------------------------------------------------*/ |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 66 | mtebc(PB7AP, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(7)| |
stroese | 180e6f1 | 2005-04-07 05:35:12 +0000 | [diff] [blame] | 67 | EBC_BXAP_BCE_DISABLE| |
| 68 | EBC_BXAP_CSN_ENCODE(1)|EBC_BXAP_OEN_ENCODE(1)| |
| 69 | EBC_BXAP_WBN_ENCODE(1)|EBC_BXAP_WBF_ENCODE(1)| |
| 70 | EBC_BXAP_TH_ENCODE(1)|EBC_BXAP_RE_DISABLED| |
| 71 | EBC_BXAP_BEM_WRITEONLY| |
| 72 | EBC_BXAP_PEN_DISABLED); |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 73 | mtebc(PB7CR, EBC_BXCR_BAS_ENCODE(0x48300000)| |
stroese | 180e6f1 | 2005-04-07 05:35:12 +0000 | [diff] [blame] | 74 | EBC_BXCR_BS_1MB|EBC_BXCR_BU_RW|EBC_BXCR_BW_8BIT); |
| 75 | |
| 76 | /* read FPGA base register FPGA_REG0 */ |
| 77 | switch_status = *fpga_base; |
| 78 | |
| 79 | if (switch_status & 0x40) { |
| 80 | cs0_base = 0xFFE00000; |
| 81 | cs0_size = EBC_BXCR_BS_2MB; |
| 82 | cs0_twt = 8; |
| 83 | cs2_base = 0xFF800000; |
| 84 | cs2_size = EBC_BXCR_BS_4MB; |
| 85 | cs2_twt = 10; |
| 86 | } else { |
| 87 | cs0_base = 0xFFC00000; |
| 88 | cs0_size = EBC_BXCR_BS_4MB; |
| 89 | cs0_twt = 10; |
| 90 | cs2_base = 0xFF800000; |
| 91 | cs2_size = EBC_BXCR_BS_2MB; |
| 92 | cs2_twt = 8; |
| 93 | } |
| 94 | |
| 95 | /*-------------------------------------------------------------------------+ |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 96 | | 1 MB FLASH / 1 MB SRAM. Initialize bank 0 with default values. |
| 97 | +-------------------------------------------------------------------------*/ |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 98 | mtebc(PB0AP, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(cs0_twt)| |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 99 | EBC_BXAP_BCE_DISABLE| |
| 100 | EBC_BXAP_CSN_ENCODE(1)|EBC_BXAP_OEN_ENCODE(1)| |
| 101 | EBC_BXAP_WBN_ENCODE(1)|EBC_BXAP_WBF_ENCODE(1)| |
| 102 | EBC_BXAP_TH_ENCODE(1)|EBC_BXAP_RE_DISABLED| |
| 103 | EBC_BXAP_BEM_WRITEONLY| |
| 104 | EBC_BXAP_PEN_DISABLED); |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 105 | mtebc(PB0CR, EBC_BXCR_BAS_ENCODE(cs0_base)| |
stroese | 180e6f1 | 2005-04-07 05:35:12 +0000 | [diff] [blame] | 106 | cs0_size|EBC_BXCR_BU_RW|EBC_BXCR_BW_8BIT); |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 107 | |
| 108 | /*-------------------------------------------------------------------------+ |
| 109 | | 8KB NVRAM/RTC. Initialize bank 1 with default values. |
| 110 | +-------------------------------------------------------------------------*/ |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 111 | mtebc(PB1AP, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(10)| |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 112 | EBC_BXAP_BCE_DISABLE| |
| 113 | EBC_BXAP_CSN_ENCODE(1)|EBC_BXAP_OEN_ENCODE(1)| |
| 114 | EBC_BXAP_WBN_ENCODE(1)|EBC_BXAP_WBF_ENCODE(1)| |
| 115 | EBC_BXAP_TH_ENCODE(1)|EBC_BXAP_RE_DISABLED| |
| 116 | EBC_BXAP_BEM_WRITEONLY| |
| 117 | EBC_BXAP_PEN_DISABLED); |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 118 | mtebc(PB1CR, EBC_BXCR_BAS_ENCODE(0x48000000)| |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 119 | EBC_BXCR_BS_1MB|EBC_BXCR_BU_RW|EBC_BXCR_BW_8BIT); |
| 120 | |
| 121 | /*-------------------------------------------------------------------------+ |
| 122 | | 4 MB FLASH. Initialize bank 2 with default values. |
| 123 | +-------------------------------------------------------------------------*/ |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 124 | mtebc(PB2AP, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(cs2_twt)| |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 125 | EBC_BXAP_BCE_DISABLE| |
| 126 | EBC_BXAP_CSN_ENCODE(1)|EBC_BXAP_OEN_ENCODE(1)| |
| 127 | EBC_BXAP_WBN_ENCODE(1)|EBC_BXAP_WBF_ENCODE(1)| |
| 128 | EBC_BXAP_TH_ENCODE(1)|EBC_BXAP_RE_DISABLED| |
| 129 | EBC_BXAP_BEM_WRITEONLY| |
| 130 | EBC_BXAP_PEN_DISABLED); |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 131 | mtebc(PB2CR, EBC_BXCR_BAS_ENCODE(cs2_base)| |
stroese | 180e6f1 | 2005-04-07 05:35:12 +0000 | [diff] [blame] | 132 | cs2_size|EBC_BXCR_BU_RW|EBC_BXCR_BW_8BIT); |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 133 | |
| 134 | /*-------------------------------------------------------------------------+ |
| 135 | | FPGA. Initialize bank 7 with default values. |
| 136 | +-------------------------------------------------------------------------*/ |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 137 | mtebc(PB7AP, EBC_BXAP_BME_DISABLED|EBC_BXAP_TWT_ENCODE(7)| |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 138 | EBC_BXAP_BCE_DISABLE| |
| 139 | EBC_BXAP_CSN_ENCODE(1)|EBC_BXAP_OEN_ENCODE(1)| |
| 140 | EBC_BXAP_WBN_ENCODE(1)|EBC_BXAP_WBF_ENCODE(1)| |
| 141 | EBC_BXAP_TH_ENCODE(1)|EBC_BXAP_RE_DISABLED| |
| 142 | EBC_BXAP_BEM_WRITEONLY| |
| 143 | EBC_BXAP_PEN_DISABLED); |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 144 | mtebc(PB7CR, EBC_BXCR_BAS_ENCODE(0x48300000)| |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 145 | EBC_BXCR_BS_1MB|EBC_BXCR_BU_RW|EBC_BXCR_BW_8BIT); |
| 146 | |
| 147 | /*-------------------------------------------------------------------- |
| 148 | * Setup the interrupt controller polarities, triggers, etc. |
| 149 | *-------------------------------------------------------------------*/ |
Stefan Roese | 51d6d5d | 2008-06-26 17:36:39 +0200 | [diff] [blame] | 150 | /* |
| 151 | * Because of the interrupt handling rework to handle 440GX interrupts |
| 152 | * with the common code, we needed to change names of the UIC registers. |
| 153 | * Here the new relationship: |
| 154 | * |
| 155 | * U-Boot name 440GX name |
| 156 | * ----------------------- |
| 157 | * UIC0 UICB0 |
| 158 | * UIC1 UIC0 |
| 159 | * UIC2 UIC1 |
| 160 | * UIC3 UIC2 |
| 161 | */ |
Stefan Roese | 707fd36 | 2009-09-24 09:55:50 +0200 | [diff] [blame] | 162 | mtdcr (UIC1SR, 0xffffffff); /* clear all */ |
| 163 | mtdcr (UIC1ER, 0x00000000); /* disable all */ |
| 164 | mtdcr (UIC1CR, 0x00000009); /* SMI & UIC1 crit are critical */ |
| 165 | mtdcr (UIC1PR, 0xfffffe13); /* per ref-board manual */ |
| 166 | mtdcr (UIC1TR, 0x01c00008); /* per ref-board manual */ |
| 167 | mtdcr (UIC1VR, 0x00000001); /* int31 highest, base=0x000 */ |
| 168 | mtdcr (UIC1SR, 0xffffffff); /* clear all */ |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 169 | |
Stefan Roese | 707fd36 | 2009-09-24 09:55:50 +0200 | [diff] [blame] | 170 | mtdcr (UIC2SR, 0xffffffff); /* clear all */ |
| 171 | mtdcr (UIC2ER, 0x00000000); /* disable all */ |
| 172 | mtdcr (UIC2CR, 0x00000000); /* all non-critical */ |
| 173 | mtdcr (UIC2PR, 0xffffe0ff); /* per ref-board manual */ |
| 174 | mtdcr (UIC2TR, 0x00ffc000); /* per ref-board manual */ |
| 175 | mtdcr (UIC2VR, 0x00000001); /* int31 highest, base=0x000 */ |
| 176 | mtdcr (UIC2SR, 0xffffffff); /* clear all */ |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 177 | |
Stefan Roese | 707fd36 | 2009-09-24 09:55:50 +0200 | [diff] [blame] | 178 | mtdcr (UIC3SR, 0xffffffff); /* clear all */ |
| 179 | mtdcr (UIC3ER, 0x00000000); /* disable all */ |
| 180 | mtdcr (UIC3CR, 0x00000000); /* all non-critical */ |
| 181 | mtdcr (UIC3PR, 0xffffffff); /* per ref-board manual */ |
| 182 | mtdcr (UIC3TR, 0x00ff8c0f); /* per ref-board manual */ |
| 183 | mtdcr (UIC3VR, 0x00000001); /* int31 highest, base=0x000 */ |
| 184 | mtdcr (UIC3SR, 0xffffffff); /* clear all */ |
Stefan Roese | 51d6d5d | 2008-06-26 17:36:39 +0200 | [diff] [blame] | 185 | |
Stefan Roese | 707fd36 | 2009-09-24 09:55:50 +0200 | [diff] [blame] | 186 | mtdcr (UIC0SR, 0xfc000000); /* clear all */ |
| 187 | mtdcr (UIC0ER, 0x00000000); /* disable all */ |
| 188 | mtdcr (UIC0CR, 0x00000000); /* all non-critical */ |
| 189 | mtdcr (UIC0PR, 0xfc000000); /* */ |
| 190 | mtdcr (UIC0TR, 0x00000000); /* */ |
| 191 | mtdcr (UIC0VR, 0x00000001); /* */ |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 192 | mfsdr (SDR0_MFR, mfr); |
wdenk | e55402c | 2004-03-14 16:51:43 +0000 | [diff] [blame] | 193 | mfr &= ~SDR0_MFR_ECS_MASK; |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 194 | /* mtsdr(SDR0_MFR, mfr); */ |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 195 | fpga_init(); |
| 196 | |
| 197 | return 0; |
| 198 | } |
| 199 | |
| 200 | |
| 201 | int checkboard (void) |
| 202 | { |
Wolfgang Denk | 7fb5266 | 2005-10-13 16:45:02 +0200 | [diff] [blame] | 203 | char *s = getenv ("serial#"); |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 204 | |
Stefan Roese | 3e1f1b3 | 2005-08-01 16:49:12 +0200 | [diff] [blame] | 205 | printf ("Board: Ocotea - AMCC PPC440GX Evaluation Board"); |
| 206 | if (s != NULL) { |
| 207 | puts (", serial# "); |
| 208 | puts (s); |
| 209 | } |
| 210 | putc ('\n'); |
| 211 | |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 212 | return (0); |
| 213 | } |
| 214 | |
| 215 | |
Becky Bruce | bd99ae7 | 2008-06-09 16:03:40 -0500 | [diff] [blame] | 216 | phys_size_t initdram (int board_type) |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 217 | { |
| 218 | long dram_size = 0; |
| 219 | |
| 220 | #if defined(CONFIG_SPD_EEPROM) |
Wolfgang Denk | 6405a15 | 2006-03-31 18:32:53 +0200 | [diff] [blame] | 221 | dram_size = spd_sdram (); |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 222 | #else |
| 223 | dram_size = fixed_sdram (); |
| 224 | #endif |
| 225 | return dram_size; |
| 226 | } |
| 227 | |
| 228 | |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 229 | #if !defined(CONFIG_SPD_EEPROM) |
| 230 | /************************************************************************* |
| 231 | * fixed sdram init -- doesn't use serial presence detect. |
| 232 | * |
| 233 | * Assumes: 128 MB, non-ECC, non-registered |
| 234 | * PLB @ 133 MHz |
| 235 | * |
| 236 | ************************************************************************/ |
| 237 | long int fixed_sdram (void) |
| 238 | { |
| 239 | uint reg; |
| 240 | |
| 241 | /*-------------------------------------------------------------------- |
| 242 | * Setup some default |
| 243 | *------------------------------------------------------------------*/ |
Stefan Roese | 6987e65 | 2009-09-24 13:59:57 +0200 | [diff] [blame] | 244 | mtsdram (SDRAM0_UABBA, 0x00000000); /* ubba=0 (default) */ |
| 245 | mtsdram (SDRAM0_SLIO, 0x00000000); /* rdre=0 wrre=0 rarw=0 */ |
| 246 | mtsdram (SDRAM0_DEVOPT, 0x00000000); /* dll=0 ds=0 (normal) */ |
| 247 | mtsdram (SDRAM0_WDDCTR, 0x00000000); /* wrcp=0 dcd=0 */ |
| 248 | mtsdram (SDRAM0_CLKTR, 0x40000000); /* clkp=1 (90 deg wr) dcdt=0 */ |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 249 | |
| 250 | /*-------------------------------------------------------------------- |
| 251 | * Setup for board-specific specific mem |
| 252 | *------------------------------------------------------------------*/ |
| 253 | /* |
| 254 | * Following for CAS Latency = 2.5 @ 133 MHz PLB |
| 255 | */ |
Stefan Roese | 6987e65 | 2009-09-24 13:59:57 +0200 | [diff] [blame] | 256 | mtsdram (SDRAM0_B0CR, 0x000a4001); /* SDBA=0x000 128MB, Mode 3, enabled */ |
| 257 | mtsdram (SDRAM0_TR0, 0x410a4012); /* WR=2 WD=1 CL=2.5 PA=3 CP=4 LD=2 */ |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 258 | /* RA=10 RD=3 */ |
Stefan Roese | 6987e65 | 2009-09-24 13:59:57 +0200 | [diff] [blame] | 259 | mtsdram (SDRAM0_TR1, 0x8080082f); /* SS=T2 SL=STAGE 3 CD=1 CT=0x02f */ |
| 260 | mtsdram (SDRAM0_RTR, 0x08200000); /* Rate 15.625 ns @ 133 MHz PLB */ |
| 261 | mtsdram (SDRAM0_CFG1, 0x00000000); /* Self-refresh exit, disable PM */ |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 262 | udelay (400); /* Delay 200 usecs (min) */ |
| 263 | |
| 264 | /*-------------------------------------------------------------------- |
| 265 | * Enable the controller, then wait for DCEN to complete |
| 266 | *------------------------------------------------------------------*/ |
Stefan Roese | 6987e65 | 2009-09-24 13:59:57 +0200 | [diff] [blame] | 267 | mtsdram (SDRAM0_CFG0, 0x86000000); /* DCEN=1, PMUD=1, 64-bit */ |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 268 | for (;;) { |
Stefan Roese | 6987e65 | 2009-09-24 13:59:57 +0200 | [diff] [blame] | 269 | mfsdram (SDRAM0_MCSTS, reg); |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 270 | if (reg & 0x80000000) |
| 271 | break; |
| 272 | } |
| 273 | |
| 274 | return (128 * 1024 * 1024); /* 128 MB */ |
| 275 | } |
| 276 | #endif /* !defined(CONFIG_SPD_EEPROM) */ |
| 277 | |
| 278 | |
| 279 | /************************************************************************* |
| 280 | * pci_pre_init |
| 281 | * |
| 282 | * This routine is called just prior to registering the hose and gives |
| 283 | * the board the opportunity to check things. Returning a value of zero |
| 284 | * indicates that things are bad & PCI initialization should be aborted. |
| 285 | * |
| 286 | * Different boards may wish to customize the pci controller structure |
| 287 | * (add regions, override default access routines, etc) or perform |
| 288 | * certain pre-initialization actions. |
| 289 | * |
| 290 | ************************************************************************/ |
Stefan Roese | 54ef7fd | 2007-06-25 15:57:39 +0200 | [diff] [blame] | 291 | #if defined(CONFIG_PCI) |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 292 | int pci_pre_init(struct pci_controller * hose ) |
| 293 | { |
| 294 | unsigned long strap; |
| 295 | |
| 296 | /*--------------------------------------------------------------------------+ |
| 297 | * The ocotea board is always configured as the host & requires the |
| 298 | * PCI arbiter to be enabled. |
| 299 | *--------------------------------------------------------------------------*/ |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 300 | mfsdr(SDR0_SDSTP1, strap); |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 301 | if( (strap & SDR0_SDSTP1_PAE_MASK) == 0 ){ |
| 302 | printf("PCI: SDR0_STRP1[%08lX] - PCI Arbiter disabled.\n",strap); |
| 303 | return 0; |
| 304 | } |
| 305 | |
| 306 | return 1; |
| 307 | } |
Stefan Roese | 54ef7fd | 2007-06-25 15:57:39 +0200 | [diff] [blame] | 308 | #endif /* defined(CONFIG_PCI) */ |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 309 | |
| 310 | /************************************************************************* |
| 311 | * pci_target_init |
| 312 | * |
| 313 | * The bootstrap configuration provides default settings for the pci |
| 314 | * inbound map (PIM). But the bootstrap config choices are limited and |
| 315 | * may not be sufficient for a given board. |
| 316 | * |
| 317 | ************************************************************************/ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 318 | #if defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_TARGET_INIT) |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 319 | void pci_target_init(struct pci_controller * hose ) |
| 320 | { |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 321 | /*--------------------------------------------------------------------------+ |
| 322 | * Disable everything |
| 323 | *--------------------------------------------------------------------------*/ |
Niklaus Giger | 728bd0a | 2009-10-04 20:04:20 +0200 | [diff] [blame] | 324 | out32r( PCIL0_PIM0SA, 0 ); /* disable */ |
| 325 | out32r( PCIL0_PIM1SA, 0 ); /* disable */ |
| 326 | out32r( PCIL0_PIM2SA, 0 ); /* disable */ |
| 327 | out32r( PCIL0_EROMBA, 0 ); /* disable expansion rom */ |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 328 | |
| 329 | /*--------------------------------------------------------------------------+ |
| 330 | * Map all of SDRAM to PCI address 0x0000_0000. Note that the 440 strapping |
| 331 | * options to not support sizes such as 128/256 MB. |
| 332 | *--------------------------------------------------------------------------*/ |
Niklaus Giger | 728bd0a | 2009-10-04 20:04:20 +0200 | [diff] [blame] | 333 | out32r( PCIL0_PIM0LAL, CONFIG_SYS_SDRAM_BASE ); |
| 334 | out32r( PCIL0_PIM0LAH, 0 ); |
| 335 | out32r( PCIL0_PIM0SA, ~(gd->ram_size - 1) | 1 ); |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 336 | |
Niklaus Giger | 728bd0a | 2009-10-04 20:04:20 +0200 | [diff] [blame] | 337 | out32r( PCIL0_BAR0, 0 ); |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 338 | |
| 339 | /*--------------------------------------------------------------------------+ |
| 340 | * Program the board's subsystem id/vendor id |
| 341 | *--------------------------------------------------------------------------*/ |
Niklaus Giger | 728bd0a | 2009-10-04 20:04:20 +0200 | [diff] [blame] | 342 | out16r( PCIL0_SBSYSVID, CONFIG_SYS_PCI_SUBSYS_VENDORID ); |
| 343 | out16r( PCIL0_SBSYSID, CONFIG_SYS_PCI_SUBSYS_DEVICEID ); |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 344 | |
Niklaus Giger | 728bd0a | 2009-10-04 20:04:20 +0200 | [diff] [blame] | 345 | out16r( PCIL0_CMD, in16r(PCIL0_CMD) | PCI_COMMAND_MEMORY ); |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 346 | } |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 347 | #endif /* defined(CONFIG_PCI) && defined(CONFIG_SYS_PCI_TARGET_INIT) */ |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 348 | |
| 349 | |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 350 | void fpga_init(void) |
| 351 | { |
| 352 | unsigned long group; |
| 353 | unsigned long sdr0_pfc0; |
| 354 | unsigned long sdr0_pfc1; |
| 355 | unsigned long sdr0_cust0; |
| 356 | unsigned long pvr; |
| 357 | |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 358 | mfsdr (SDR0_PFC0, sdr0_pfc0); |
| 359 | mfsdr (SDR0_PFC1, sdr0_pfc1); |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 360 | group = SDR0_PFC1_EPS_DECODE(sdr0_pfc1); |
| 361 | pvr = get_pvr (); |
| 362 | |
| 363 | sdr0_pfc0 = (sdr0_pfc0 & ~SDR0_PFC0_GEIE_MASK) | SDR0_PFC0_GEIE_TRE; |
| 364 | if ( ((pvr == PVR_440GX_RA) || (pvr == PVR_440GX_RB)) && ((group == 4) || (group == 5))) { |
| 365 | sdr0_pfc0 = (sdr0_pfc0 & ~SDR0_PFC0_TRE_MASK) | SDR0_PFC0_TRE_DISABLE; |
| 366 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_CTEMS_MASK) | SDR0_PFC1_CTEMS_EMS; |
| 367 | out8(FPGA_REG2, (in8(FPGA_REG2) & ~FPGA_REG2_EXT_INTFACE_MASK) | |
| 368 | FPGA_REG2_EXT_INTFACE_ENABLE); |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 369 | mtsdr (SDR0_PFC0, sdr0_pfc0); |
| 370 | mtsdr (SDR0_PFC1, sdr0_pfc1); |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 371 | } else { |
| 372 | sdr0_pfc0 = (sdr0_pfc0 & ~SDR0_PFC0_TRE_MASK) | SDR0_PFC0_TRE_ENABLE; |
| 373 | switch (group) |
| 374 | { |
| 375 | case 0: |
| 376 | case 1: |
| 377 | case 2: |
| 378 | /* CPU trace A */ |
| 379 | out8(FPGA_REG2, (in8(FPGA_REG2) & ~FPGA_REG2_EXT_INTFACE_MASK) | |
| 380 | FPGA_REG2_EXT_INTFACE_ENABLE); |
| 381 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_CTEMS_MASK) | SDR0_PFC1_CTEMS_EMS; |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 382 | mtsdr (SDR0_PFC0, sdr0_pfc0); |
| 383 | mtsdr (SDR0_PFC1, sdr0_pfc1); |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 384 | break; |
| 385 | case 3: |
| 386 | case 4: |
| 387 | case 5: |
| 388 | case 6: |
| 389 | /* CPU trace B - Over EBMI */ |
| 390 | sdr0_pfc1 = (sdr0_pfc1 & ~SDR0_PFC1_CTEMS_MASK) | SDR0_PFC1_CTEMS_CPUTRACE; |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 391 | mtsdr (SDR0_PFC0, sdr0_pfc0); |
| 392 | mtsdr (SDR0_PFC1, sdr0_pfc1); |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 393 | out8(FPGA_REG2, (in8(FPGA_REG2) & ~FPGA_REG2_EXT_INTFACE_MASK) | |
| 394 | FPGA_REG2_EXT_INTFACE_DISABLE); |
| 395 | break; |
| 396 | } |
| 397 | } |
| 398 | |
| 399 | /* Initialize the ethernet specific functions in the fpga */ |
Stefan Roese | 918010a | 2009-09-09 16:25:29 +0200 | [diff] [blame] | 400 | mfsdr(SDR0_PFC1, sdr0_pfc1); |
| 401 | mfsdr(SDR0_CUST0, sdr0_cust0); |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 402 | if ( (SDR0_PFC1_EPS_DECODE(sdr0_pfc1) == 4) && |
| 403 | ((SDR0_CUST0_RGMII2_DECODE(sdr0_cust0) == RGMII_FER_GMII) || |
| 404 | (SDR0_CUST0_RGMII2_DECODE(sdr0_cust0) == RGMII_FER_TBI))) |
| 405 | { |
| 406 | if ((in8(FPGA_REG0) & FPGA_REG0_ECLS_MASK) == FPGA_REG0_ECLS_VER1) |
| 407 | { |
| 408 | out8(FPGA_REG3, (in8(FPGA_REG3) & ~FPGA_REG3_ENET_MASK1) | |
| 409 | FPGA_REG3_ENET_GROUP7); |
| 410 | } |
| 411 | else |
| 412 | { |
| 413 | if (SDR0_CUST0_RGMII2_DECODE(sdr0_cust0) == RGMII_FER_GMII) |
| 414 | { |
| 415 | out8(FPGA_REG3, (in8(FPGA_REG3) & ~FPGA_REG3_ENET_MASK2) | |
| 416 | FPGA_REG3_ENET_GROUP7); |
| 417 | } |
| 418 | else |
| 419 | { |
| 420 | out8(FPGA_REG3, (in8(FPGA_REG3) & ~FPGA_REG3_ENET_MASK2) | |
| 421 | FPGA_REG3_ENET_GROUP8); |
| 422 | } |
| 423 | } |
| 424 | } |
| 425 | else |
| 426 | { |
| 427 | if ((in8(FPGA_REG0) & FPGA_REG0_ECLS_MASK) == FPGA_REG0_ECLS_VER1) |
| 428 | { |
| 429 | out8(FPGA_REG3, (in8(FPGA_REG3) & ~FPGA_REG3_ENET_MASK1) | |
| 430 | FPGA_REG3_ENET_ENCODE1(SDR0_PFC1_EPS_DECODE(sdr0_pfc1))); |
| 431 | } |
| 432 | else |
| 433 | { |
| 434 | out8(FPGA_REG3, (in8(FPGA_REG3) & ~FPGA_REG3_ENET_MASK2) | |
| 435 | FPGA_REG3_ENET_ENCODE2(SDR0_PFC1_EPS_DECODE(sdr0_pfc1))); |
| 436 | } |
| 437 | } |
| 438 | out8(FPGA_REG4, FPGA_REG4_GPHY_MODE10 | |
| 439 | FPGA_REG4_GPHY_MODE100 | FPGA_REG4_GPHY_MODE1000 | |
| 440 | FPGA_REG4_GPHY_FRC_DPLX | FPGA_REG4_CONNECT_PHYS); |
| 441 | |
| 442 | /* reset the gigabyte phy if necessary */ |
| 443 | if (SDR0_PFC1_EPS_DECODE(sdr0_pfc1) >= 3) |
| 444 | { |
| 445 | if ((in8(FPGA_REG0) & FPGA_REG0_ECLS_MASK) == FPGA_REG0_ECLS_VER1) |
| 446 | { |
| 447 | out8(FPGA_REG3, in8(FPGA_REG3) & ~FPGA_REG3_GIGABIT_RESET_DISABLE); |
| 448 | udelay(10000); |
| 449 | out8(FPGA_REG3, in8(FPGA_REG3) | FPGA_REG3_GIGABIT_RESET_DISABLE); |
| 450 | } |
| 451 | else |
| 452 | { |
| 453 | out8(FPGA_REG2, in8(FPGA_REG2) & ~FPGA_REG2_GIGABIT_RESET_DISABLE); |
| 454 | udelay(10000); |
| 455 | out8(FPGA_REG2, in8(FPGA_REG2) | FPGA_REG2_GIGABIT_RESET_DISABLE); |
| 456 | } |
| 457 | } |
| 458 | |
Stefan Roese | 08fb404 | 2005-11-01 10:08:03 +0100 | [diff] [blame] | 459 | /* |
| 460 | * new Ocotea with Rev. F (pass 3) chips has SMII PHY reset |
| 461 | */ |
| 462 | if ((in8(FPGA_REG0) & FPGA_REG0_ECLS_MASK) == FPGA_REG0_ECLS_VER2) { |
| 463 | out8(FPGA_REG2, in8(FPGA_REG2) & ~FPGA_REG2_SMII_RESET_DISABLE); |
| 464 | udelay(10000); |
| 465 | out8(FPGA_REG2, in8(FPGA_REG2) | FPGA_REG2_SMII_RESET_DISABLE); |
| 466 | } |
| 467 | |
wdenk | 00fe161 | 2004-03-14 00:07:33 +0000 | [diff] [blame] | 468 | /* Turn off the LED's */ |
| 469 | out8(FPGA_REG3, (in8(FPGA_REG3) & ~FPGA_REG3_STAT_MASK) | |
| 470 | FPGA_REG3_STAT_LED8_DISAB | FPGA_REG3_STAT_LED4_DISAB | |
| 471 | FPGA_REG3_STAT_LED2_DISAB | FPGA_REG3_STAT_LED1_DISAB); |
| 472 | |
| 473 | return; |
| 474 | } |
| 475 | |
| 476 | #ifdef CONFIG_POST |
| 477 | /* |
| 478 | * Returns 1 if keys pressed to start the power-on long-running tests |
| 479 | * Called from board_init_f(). |
| 480 | */ |
| 481 | int post_hotkeys_pressed(void) |
| 482 | { |
| 483 | |
| 484 | return (ctrlc()); |
| 485 | } |
| 486 | #endif |