1415a613bSKumar Gala /* 2415a613bSKumar Gala * Copyright 2004 Freescale Semiconductor. 3415a613bSKumar Gala * 4415a613bSKumar Gala * See file CREDITS for list of people who contributed to this 5415a613bSKumar Gala * project. 6415a613bSKumar Gala * 7415a613bSKumar Gala * This program is free software; you can redistribute it and/or 8415a613bSKumar Gala * modify it under the terms of the GNU General Public License as 9415a613bSKumar Gala * published by the Free Software Foundation; either version 2 of 10415a613bSKumar Gala * the License, or (at your option) any later version. 11415a613bSKumar Gala * 12415a613bSKumar Gala * This program is distributed in the hope that it will be useful, 13415a613bSKumar Gala * but WITHOUT ANY WARRANTY; without even the implied warranty of 14415a613bSKumar Gala * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15415a613bSKumar Gala * GNU General Public License for more details. 16415a613bSKumar Gala * 17415a613bSKumar Gala * You should have received a copy of the GNU General Public License 18415a613bSKumar Gala * along with this program; if not, write to the Free Software 19415a613bSKumar Gala * Foundation, Inc., 59 Temple Place, Suite 330, Boston, 20415a613bSKumar Gala * MA 02111-1307 USA 21415a613bSKumar Gala */ 22415a613bSKumar Gala 23415a613bSKumar Gala #include <common.h> 24415a613bSKumar Gala #include <pci.h> 25415a613bSKumar Gala #include <asm/processor.h> 262b40edb1SJon Loeliger #include <asm/mmu.h> 27415a613bSKumar Gala #include <asm/immap_85xx.h> 282b40edb1SJon Loeliger #include <asm/fsl_ddr_sdram.h> 29415a613bSKumar Gala #include <ioports.h> 30a30a549aSJon Loeliger #include <spd_sdram.h> 31415a613bSKumar Gala #include <libfdt.h> 32415a613bSKumar Gala #include <fdt_support.h> 33415a613bSKumar Gala 34415a613bSKumar Gala #include "../common/cadmus.h" 35415a613bSKumar Gala #include "../common/eeprom.h" 36415a613bSKumar Gala #include "../common/via.h" 37415a613bSKumar Gala 38415a613bSKumar Gala #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER) 39415a613bSKumar Gala extern void ddr_enable_ecc(unsigned int dram_size); 40415a613bSKumar Gala #endif 41415a613bSKumar Gala 42415a613bSKumar Gala void local_bus_init(void); 43415a613bSKumar Gala void sdram_init(void); 44415a613bSKumar Gala 45415a613bSKumar Gala /* 46415a613bSKumar Gala * I/O Port configuration table 47415a613bSKumar Gala * 48415a613bSKumar Gala * if conf is 1, then that port pin will be configured at boot time 49415a613bSKumar Gala * according to the five values podr/pdir/ppar/psor/pdat for that entry 50415a613bSKumar Gala */ 51415a613bSKumar Gala 52415a613bSKumar Gala const iop_conf_t iop_conf_tab[4][32] = { 53415a613bSKumar Gala 54415a613bSKumar Gala /* Port A configuration */ 55415a613bSKumar Gala { /* conf ppar psor pdir podr pdat */ 56415a613bSKumar Gala /* PA31 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxENB */ 57415a613bSKumar Gala /* PA30 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 TxClav */ 58415a613bSKumar Gala /* PA29 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxSOC */ 59415a613bSKumar Gala /* PA28 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 RxENB */ 60415a613bSKumar Gala /* PA27 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RxSOC */ 61415a613bSKumar Gala /* PA26 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RxClav */ 62415a613bSKumar Gala /* PA25 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[0] */ 63415a613bSKumar Gala /* PA24 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[1] */ 64415a613bSKumar Gala /* PA23 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[2] */ 65415a613bSKumar Gala /* PA22 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[3] */ 66415a613bSKumar Gala /* PA21 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[4] */ 67415a613bSKumar Gala /* PA20 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[5] */ 68415a613bSKumar Gala /* PA19 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[6] */ 69415a613bSKumar Gala /* PA18 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[7] */ 70415a613bSKumar Gala /* PA17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[7] */ 71415a613bSKumar Gala /* PA16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[6] */ 72415a613bSKumar Gala /* PA15 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[5] */ 73415a613bSKumar Gala /* PA14 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[4] */ 74415a613bSKumar Gala /* PA13 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[3] */ 75415a613bSKumar Gala /* PA12 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[2] */ 76415a613bSKumar Gala /* PA11 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[1] */ 77415a613bSKumar Gala /* PA10 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[0] */ 78415a613bSKumar Gala /* PA9 */ { 0, 1, 1, 1, 0, 0 }, /* FCC1 L1TXD */ 79415a613bSKumar Gala /* PA8 */ { 0, 1, 1, 0, 0, 0 }, /* FCC1 L1RXD */ 80415a613bSKumar Gala /* PA7 */ { 0, 0, 0, 1, 0, 0 }, /* PA7 */ 81415a613bSKumar Gala /* PA6 */ { 0, 1, 1, 1, 0, 0 }, /* TDM A1 L1RSYNC */ 82415a613bSKumar Gala /* PA5 */ { 0, 0, 0, 1, 0, 0 }, /* PA5 */ 83415a613bSKumar Gala /* PA4 */ { 0, 0, 0, 1, 0, 0 }, /* PA4 */ 84415a613bSKumar Gala /* PA3 */ { 0, 0, 0, 1, 0, 0 }, /* PA3 */ 85415a613bSKumar Gala /* PA2 */ { 0, 0, 0, 1, 0, 0 }, /* PA2 */ 86415a613bSKumar Gala /* PA1 */ { 1, 0, 0, 0, 0, 0 }, /* FREERUN */ 87415a613bSKumar Gala /* PA0 */ { 0, 0, 0, 1, 0, 0 } /* PA0 */ 88415a613bSKumar Gala }, 89415a613bSKumar Gala 90415a613bSKumar Gala /* Port B configuration */ 91415a613bSKumar Gala { /* conf ppar psor pdir podr pdat */ 92415a613bSKumar Gala /* PB31 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TX_ER */ 93415a613bSKumar Gala /* PB30 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_DV */ 94415a613bSKumar Gala /* PB29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC2 MII TX_EN */ 95415a613bSKumar Gala /* PB28 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_ER */ 96415a613bSKumar Gala /* PB27 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII COL */ 97415a613bSKumar Gala /* PB26 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII CRS */ 98415a613bSKumar Gala /* PB25 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[3] */ 99415a613bSKumar Gala /* PB24 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[2] */ 100415a613bSKumar Gala /* PB23 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[1] */ 101415a613bSKumar Gala /* PB22 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[0] */ 102415a613bSKumar Gala /* PB21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[0] */ 103415a613bSKumar Gala /* PB20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[1] */ 104415a613bSKumar Gala /* PB19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[2] */ 105415a613bSKumar Gala /* PB18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[3] */ 106415a613bSKumar Gala /* PB17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RX_DIV */ 107415a613bSKumar Gala /* PB16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RX_ERR */ 108415a613bSKumar Gala /* PB15 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TX_ERR */ 109415a613bSKumar Gala /* PB14 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TX_EN */ 110415a613bSKumar Gala /* PB13 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:COL */ 111415a613bSKumar Gala /* PB12 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:CRS */ 112415a613bSKumar Gala /* PB11 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */ 113415a613bSKumar Gala /* PB10 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */ 114415a613bSKumar Gala /* PB9 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */ 115415a613bSKumar Gala /* PB8 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */ 116415a613bSKumar Gala /* PB7 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */ 117415a613bSKumar Gala /* PB6 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */ 118415a613bSKumar Gala /* PB5 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */ 119415a613bSKumar Gala /* PB4 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */ 120415a613bSKumar Gala /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */ 121415a613bSKumar Gala /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */ 122415a613bSKumar Gala /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */ 123415a613bSKumar Gala /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */ 124415a613bSKumar Gala }, 125415a613bSKumar Gala 126415a613bSKumar Gala /* Port C */ 127415a613bSKumar Gala { /* conf ppar psor pdir podr pdat */ 128415a613bSKumar Gala /* PC31 */ { 0, 0, 0, 1, 0, 0 }, /* PC31 */ 129415a613bSKumar Gala /* PC30 */ { 0, 0, 0, 1, 0, 0 }, /* PC30 */ 130415a613bSKumar Gala /* PC29 */ { 0, 1, 1, 0, 0, 0 }, /* SCC1 EN *CLSN */ 131415a613bSKumar Gala /* PC28 */ { 0, 0, 0, 1, 0, 0 }, /* PC28 */ 132415a613bSKumar Gala /* PC27 */ { 0, 0, 0, 1, 0, 0 }, /* UART Clock in */ 133415a613bSKumar Gala /* PC26 */ { 0, 0, 0, 1, 0, 0 }, /* PC26 */ 134415a613bSKumar Gala /* PC25 */ { 0, 0, 0, 1, 0, 0 }, /* PC25 */ 135415a613bSKumar Gala /* PC24 */ { 0, 0, 0, 1, 0, 0 }, /* PC24 */ 136415a613bSKumar Gala /* PC23 */ { 0, 1, 0, 1, 0, 0 }, /* ATMTFCLK */ 137415a613bSKumar Gala /* PC22 */ { 0, 1, 0, 0, 0, 0 }, /* ATMRFCLK */ 138415a613bSKumar Gala /* PC21 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN RXCLK */ 139415a613bSKumar Gala /* PC20 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN TXCLK */ 140415a613bSKumar Gala /* PC19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_CLK CLK13 */ 141415a613bSKumar Gala /* PC18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC Tx Clock (CLK14) */ 142415a613bSKumar Gala /* PC17 */ { 0, 0, 0, 1, 0, 0 }, /* PC17 */ 143415a613bSKumar Gala /* PC16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC Tx Clock (CLK16) */ 144415a613bSKumar Gala /* PC15 */ { 1, 1, 0, 0, 0, 0 }, /* PC15 */ 145415a613bSKumar Gala /* PC14 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN *CD */ 146415a613bSKumar Gala /* PC13 */ { 0, 0, 0, 1, 0, 0 }, /* PC13 */ 147415a613bSKumar Gala /* PC12 */ { 0, 1, 0, 1, 0, 0 }, /* PC12 */ 148415a613bSKumar Gala /* PC11 */ { 0, 0, 0, 1, 0, 0 }, /* LXT971 transmit control */ 149415a613bSKumar Gala /* PC10 */ { 1, 0, 0, 1, 0, 0 }, /* FETHMDC */ 150415a613bSKumar Gala /* PC9 */ { 1, 0, 0, 0, 0, 0 }, /* FETHMDIO */ 151415a613bSKumar Gala /* PC8 */ { 0, 0, 0, 1, 0, 0 }, /* PC8 */ 152415a613bSKumar Gala /* PC7 */ { 0, 0, 0, 1, 0, 0 }, /* PC7 */ 153415a613bSKumar Gala /* PC6 */ { 0, 0, 0, 1, 0, 0 }, /* PC6 */ 154415a613bSKumar Gala /* PC5 */ { 0, 0, 0, 1, 0, 0 }, /* PC5 */ 155415a613bSKumar Gala /* PC4 */ { 0, 0, 0, 1, 0, 0 }, /* PC4 */ 156415a613bSKumar Gala /* PC3 */ { 0, 0, 0, 1, 0, 0 }, /* PC3 */ 157415a613bSKumar Gala /* PC2 */ { 0, 0, 0, 1, 0, 1 }, /* ENET FDE */ 158415a613bSKumar Gala /* PC1 */ { 0, 0, 0, 1, 0, 0 }, /* ENET DSQE */ 159415a613bSKumar Gala /* PC0 */ { 0, 0, 0, 1, 0, 0 }, /* ENET LBK */ 160415a613bSKumar Gala }, 161415a613bSKumar Gala 162415a613bSKumar Gala /* Port D */ 163415a613bSKumar Gala { /* conf ppar psor pdir podr pdat */ 164415a613bSKumar Gala /* PD31 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN RxD */ 165415a613bSKumar Gala /* PD30 */ { 1, 1, 1, 1, 0, 0 }, /* SCC1 EN TxD */ 166415a613bSKumar Gala /* PD29 */ { 1, 1, 0, 1, 0, 0 }, /* SCC1 EN TENA */ 167415a613bSKumar Gala /* PD28 */ { 0, 1, 0, 0, 0, 0 }, /* PD28 */ 168415a613bSKumar Gala /* PD27 */ { 0, 1, 1, 1, 0, 0 }, /* PD27 */ 169415a613bSKumar Gala /* PD26 */ { 0, 0, 0, 1, 0, 0 }, /* PD26 */ 170415a613bSKumar Gala /* PD25 */ { 0, 0, 0, 1, 0, 0 }, /* PD25 */ 171415a613bSKumar Gala /* PD24 */ { 0, 0, 0, 1, 0, 0 }, /* PD24 */ 172415a613bSKumar Gala /* PD23 */ { 0, 0, 0, 1, 0, 0 }, /* PD23 */ 173415a613bSKumar Gala /* PD22 */ { 0, 0, 0, 1, 0, 0 }, /* PD22 */ 174415a613bSKumar Gala /* PD21 */ { 0, 0, 0, 1, 0, 0 }, /* PD21 */ 175415a613bSKumar Gala /* PD20 */ { 0, 0, 0, 1, 0, 0 }, /* PD20 */ 176415a613bSKumar Gala /* PD19 */ { 0, 0, 0, 1, 0, 0 }, /* PD19 */ 177415a613bSKumar Gala /* PD18 */ { 0, 0, 0, 1, 0, 0 }, /* PD18 */ 178415a613bSKumar Gala /* PD17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXPRTY */ 179415a613bSKumar Gala /* PD16 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXPRTY */ 180415a613bSKumar Gala /* PD15 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SDA */ 181415a613bSKumar Gala /* PD14 */ { 0, 0, 0, 1, 0, 0 }, /* LED */ 182415a613bSKumar Gala /* PD13 */ { 0, 0, 0, 0, 0, 0 }, /* PD13 */ 183415a613bSKumar Gala /* PD12 */ { 0, 0, 0, 0, 0, 0 }, /* PD12 */ 184415a613bSKumar Gala /* PD11 */ { 0, 0, 0, 0, 0, 0 }, /* PD11 */ 185415a613bSKumar Gala /* PD10 */ { 0, 0, 0, 0, 0, 0 }, /* PD10 */ 186415a613bSKumar Gala /* PD9 */ { 0, 1, 0, 1, 0, 0 }, /* SMC1 TXD */ 187415a613bSKumar Gala /* PD8 */ { 0, 1, 0, 0, 0, 0 }, /* SMC1 RXD */ 188415a613bSKumar Gala /* PD7 */ { 0, 0, 0, 1, 0, 1 }, /* PD7 */ 189415a613bSKumar Gala /* PD6 */ { 0, 0, 0, 1, 0, 1 }, /* PD6 */ 190415a613bSKumar Gala /* PD5 */ { 0, 0, 0, 1, 0, 1 }, /* PD5 */ 191415a613bSKumar Gala /* PD4 */ { 0, 0, 0, 1, 0, 1 }, /* PD4 */ 192415a613bSKumar Gala /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */ 193415a613bSKumar Gala /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */ 194415a613bSKumar Gala /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */ 195415a613bSKumar Gala /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */ 196415a613bSKumar Gala } 197415a613bSKumar Gala }; 198415a613bSKumar Gala 199415a613bSKumar Gala int checkboard (void) 200415a613bSKumar Gala { 2016d0f6bcfSJean-Christophe PLAGNIOL-VILLARD volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); 202415a613bSKumar Gala 203415a613bSKumar Gala /* PCI slot in USER bits CSR[6:7] by convention. */ 204415a613bSKumar Gala uint pci_slot = get_pci_slot (); 205415a613bSKumar Gala 206415a613bSKumar Gala uint pci_dual = get_pci_dual (); /* PCI DUAL in CM_PCI[3] */ 207415a613bSKumar Gala uint pci1_32 = gur->pordevsr & 0x10000; /* PORDEVSR[15] */ 208415a613bSKumar Gala uint pci1_clk_sel = gur->porpllsr & 0x8000; /* PORPLLSR[16] */ 209415a613bSKumar Gala uint pci2_clk_sel = gur->porpllsr & 0x4000; /* PORPLLSR[17] */ 210415a613bSKumar Gala 211415a613bSKumar Gala uint pci1_speed = get_clock_freq (); /* PCI PSPEED in [4:5] */ 212415a613bSKumar Gala 213415a613bSKumar Gala uint cpu_board_rev = get_cpu_board_revision (); 214415a613bSKumar Gala 215415a613bSKumar Gala printf ("Board: CDS Version 0x%02x, PCI Slot %d\n", 216415a613bSKumar Gala get_board_version (), pci_slot); 217415a613bSKumar Gala 218415a613bSKumar Gala printf ("CPU Board Revision %d.%d (0x%04x)\n", 219415a613bSKumar Gala MPC85XX_CPU_BOARD_MAJOR (cpu_board_rev), 220415a613bSKumar Gala MPC85XX_CPU_BOARD_MINOR (cpu_board_rev), cpu_board_rev); 221415a613bSKumar Gala 222415a613bSKumar Gala printf (" PCI1: %d bit, %s MHz, %s\n", 223415a613bSKumar Gala (pci1_32) ? 32 : 64, 224415a613bSKumar Gala (pci1_speed == 33000000) ? "33" : 225415a613bSKumar Gala (pci1_speed == 66000000) ? "66" : "unknown", 226415a613bSKumar Gala pci1_clk_sel ? "sync" : "async"); 227415a613bSKumar Gala 228415a613bSKumar Gala if (pci_dual) { 229415a613bSKumar Gala printf (" PCI2: 32 bit, 66 MHz, %s\n", 230415a613bSKumar Gala pci2_clk_sel ? "sync" : "async"); 231415a613bSKumar Gala } else { 232415a613bSKumar Gala printf (" PCI2: disabled\n"); 233415a613bSKumar Gala } 234415a613bSKumar Gala 235415a613bSKumar Gala /* 236415a613bSKumar Gala * Initialize local bus. 237415a613bSKumar Gala */ 238415a613bSKumar Gala local_bus_init (); 239415a613bSKumar Gala 240415a613bSKumar Gala return 0; 241415a613bSKumar Gala } 242415a613bSKumar Gala 2439973e3c6SBecky Bruce phys_size_t 244415a613bSKumar Gala initdram(int board_type) 245415a613bSKumar Gala { 246415a613bSKumar Gala long dram_size = 0; 247415a613bSKumar Gala 248415a613bSKumar Gala puts("Initializing\n"); 249415a613bSKumar Gala 250415a613bSKumar Gala #if defined(CONFIG_DDR_DLL) 251415a613bSKumar Gala { 252415a613bSKumar Gala /* 253415a613bSKumar Gala * Work around to stabilize DDR DLL MSYNC_IN. 254415a613bSKumar Gala * Errata DDR9 seems to have been fixed. 255415a613bSKumar Gala * This is now the workaround for Errata DDR11: 256415a613bSKumar Gala * Override DLL = 1, Course Adj = 1, Tap Select = 0 257415a613bSKumar Gala */ 258415a613bSKumar Gala 2596d0f6bcfSJean-Christophe PLAGNIOL-VILLARD volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); 260415a613bSKumar Gala 261415a613bSKumar Gala gur->ddrdllcr = 0x81000000; 262415a613bSKumar Gala asm("sync;isync;msync"); 263415a613bSKumar Gala udelay(200); 264415a613bSKumar Gala } 265415a613bSKumar Gala #endif 2662b40edb1SJon Loeliger 2672b40edb1SJon Loeliger dram_size = fsl_ddr_sdram(); 2682b40edb1SJon Loeliger dram_size = setup_ddr_tlbs(dram_size / 0x100000); 2692b40edb1SJon Loeliger dram_size *= 0x100000; 270415a613bSKumar Gala 271415a613bSKumar Gala #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER) 272415a613bSKumar Gala /* 273415a613bSKumar Gala * Initialize and enable DDR ECC. 274415a613bSKumar Gala */ 275415a613bSKumar Gala ddr_enable_ecc(dram_size); 276415a613bSKumar Gala #endif 2772b40edb1SJon Loeliger 278415a613bSKumar Gala /* 279415a613bSKumar Gala * SDRAM Initialization 280415a613bSKumar Gala */ 281415a613bSKumar Gala sdram_init(); 282415a613bSKumar Gala 283415a613bSKumar Gala puts(" DDR: "); 284415a613bSKumar Gala return dram_size; 285415a613bSKumar Gala } 286415a613bSKumar Gala 287415a613bSKumar Gala /* 288415a613bSKumar Gala * Initialize Local Bus 289415a613bSKumar Gala */ 290415a613bSKumar Gala void 291415a613bSKumar Gala local_bus_init(void) 292415a613bSKumar Gala { 2936d0f6bcfSJean-Christophe PLAGNIOL-VILLARD volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); 2946d0f6bcfSJean-Christophe PLAGNIOL-VILLARD volatile ccsr_lbc_t *lbc = (void *)(CONFIG_SYS_MPC85xx_LBC_ADDR); 295415a613bSKumar Gala 296415a613bSKumar Gala uint clkdiv; 297415a613bSKumar Gala uint lbc_hz; 298415a613bSKumar Gala sys_info_t sysinfo; 299415a613bSKumar Gala uint temp_lbcdll; 300415a613bSKumar Gala 301415a613bSKumar Gala /* 302415a613bSKumar Gala * Errata LBC11. 303415a613bSKumar Gala * Fix Local Bus clock glitch when DLL is enabled. 304415a613bSKumar Gala * 305*8ed44d91SWolfgang Denk * If localbus freq is < 66MHz, DLL bypass mode must be used. 306*8ed44d91SWolfgang Denk * If localbus freq is > 133MHz, DLL can be safely enabled. 307415a613bSKumar Gala * Between 66 and 133, the DLL is enabled with an override workaround. 308415a613bSKumar Gala */ 309415a613bSKumar Gala 310415a613bSKumar Gala get_sys_info(&sysinfo); 311415a613bSKumar Gala clkdiv = lbc->lcrr & 0x0f; 312415a613bSKumar Gala lbc_hz = sysinfo.freqSystemBus / 1000000 / clkdiv; 313415a613bSKumar Gala 314415a613bSKumar Gala if (lbc_hz < 66) { 315415a613bSKumar Gala lbc->lcrr |= 0x80000000; /* DLL Bypass */ 316415a613bSKumar Gala 317415a613bSKumar Gala } else if (lbc_hz >= 133) { 318415a613bSKumar Gala lbc->lcrr &= (~0x80000000); /* DLL Enabled */ 319415a613bSKumar Gala 320415a613bSKumar Gala } else { 321415a613bSKumar Gala lbc->lcrr &= (~0x8000000); /* DLL Enabled */ 322415a613bSKumar Gala udelay(200); 323415a613bSKumar Gala 324415a613bSKumar Gala /* 325415a613bSKumar Gala * Sample LBC DLL ctrl reg, upshift it to set the 326415a613bSKumar Gala * override bits. 327415a613bSKumar Gala */ 328415a613bSKumar Gala temp_lbcdll = gur->lbcdllcr; 329415a613bSKumar Gala gur->lbcdllcr = (((temp_lbcdll & 0xff) << 16) | 0x80000000); 330415a613bSKumar Gala asm("sync;isync;msync"); 331415a613bSKumar Gala } 332415a613bSKumar Gala } 333415a613bSKumar Gala 334415a613bSKumar Gala /* 335415a613bSKumar Gala * Initialize SDRAM memory on the Local Bus. 336415a613bSKumar Gala */ 337415a613bSKumar Gala void 338415a613bSKumar Gala sdram_init(void) 339415a613bSKumar Gala { 3406d0f6bcfSJean-Christophe PLAGNIOL-VILLARD #if defined(CONFIG_SYS_OR2_PRELIM) && defined(CONFIG_SYS_BR2_PRELIM) 341415a613bSKumar Gala 342415a613bSKumar Gala uint idx; 3436d0f6bcfSJean-Christophe PLAGNIOL-VILLARD volatile ccsr_lbc_t *lbc = (void *)(CONFIG_SYS_MPC85xx_LBC_ADDR); 3446d0f6bcfSJean-Christophe PLAGNIOL-VILLARD uint *sdram_addr = (uint *)CONFIG_SYS_LBC_SDRAM_BASE; 345415a613bSKumar Gala uint cpu_board_rev; 346415a613bSKumar Gala uint lsdmr_common; 347415a613bSKumar Gala 348415a613bSKumar Gala puts(" SDRAM: "); 349415a613bSKumar Gala 3506d0f6bcfSJean-Christophe PLAGNIOL-VILLARD print_size (CONFIG_SYS_LBC_SDRAM_SIZE * 1024 * 1024, "\n"); 351415a613bSKumar Gala 352415a613bSKumar Gala /* 353415a613bSKumar Gala * Setup SDRAM Base and Option Registers 354415a613bSKumar Gala */ 3556d0f6bcfSJean-Christophe PLAGNIOL-VILLARD lbc->or2 = CONFIG_SYS_OR2_PRELIM; 356415a613bSKumar Gala asm("msync"); 357415a613bSKumar Gala 3586d0f6bcfSJean-Christophe PLAGNIOL-VILLARD lbc->br2 = CONFIG_SYS_BR2_PRELIM; 359415a613bSKumar Gala asm("msync"); 360415a613bSKumar Gala 3616d0f6bcfSJean-Christophe PLAGNIOL-VILLARD lbc->lbcr = CONFIG_SYS_LBC_LBCR; 362415a613bSKumar Gala asm("msync"); 363415a613bSKumar Gala 3646d0f6bcfSJean-Christophe PLAGNIOL-VILLARD lbc->lsrt = CONFIG_SYS_LBC_LSRT; 3656d0f6bcfSJean-Christophe PLAGNIOL-VILLARD lbc->mrtpr = CONFIG_SYS_LBC_MRTPR; 366415a613bSKumar Gala asm("msync"); 367415a613bSKumar Gala 368415a613bSKumar Gala /* 369415a613bSKumar Gala * Determine which address lines to use baed on CPU board rev. 370415a613bSKumar Gala */ 371415a613bSKumar Gala cpu_board_rev = get_cpu_board_revision(); 3726d0f6bcfSJean-Christophe PLAGNIOL-VILLARD lsdmr_common = CONFIG_SYS_LBC_LSDMR_COMMON; 373415a613bSKumar Gala if (cpu_board_rev == MPC85XX_CPU_BOARD_REV_1_0) { 3746d0f6bcfSJean-Christophe PLAGNIOL-VILLARD lsdmr_common |= CONFIG_SYS_LBC_LSDMR_BSMA1617; 375415a613bSKumar Gala } else if (cpu_board_rev == MPC85XX_CPU_BOARD_REV_1_1) { 3766d0f6bcfSJean-Christophe PLAGNIOL-VILLARD lsdmr_common |= CONFIG_SYS_LBC_LSDMR_BSMA1516; 377415a613bSKumar Gala } else { 378415a613bSKumar Gala /* 379415a613bSKumar Gala * Assume something unable to identify itself is 380415a613bSKumar Gala * really old, and likely has lines 16/17 mapped. 381415a613bSKumar Gala */ 3826d0f6bcfSJean-Christophe PLAGNIOL-VILLARD lsdmr_common |= CONFIG_SYS_LBC_LSDMR_BSMA1617; 383415a613bSKumar Gala } 384415a613bSKumar Gala 385415a613bSKumar Gala /* 386415a613bSKumar Gala * Issue PRECHARGE ALL command. 387415a613bSKumar Gala */ 3886d0f6bcfSJean-Christophe PLAGNIOL-VILLARD lbc->lsdmr = lsdmr_common | CONFIG_SYS_LBC_LSDMR_OP_PCHALL; 389415a613bSKumar Gala asm("sync;msync"); 390415a613bSKumar Gala *sdram_addr = 0xff; 391415a613bSKumar Gala ppcDcbf((unsigned long) sdram_addr); 392415a613bSKumar Gala udelay(100); 393415a613bSKumar Gala 394415a613bSKumar Gala /* 395415a613bSKumar Gala * Issue 8 AUTO REFRESH commands. 396415a613bSKumar Gala */ 397415a613bSKumar Gala for (idx = 0; idx < 8; idx++) { 3986d0f6bcfSJean-Christophe PLAGNIOL-VILLARD lbc->lsdmr = lsdmr_common | CONFIG_SYS_LBC_LSDMR_OP_ARFRSH; 399415a613bSKumar Gala asm("sync;msync"); 400415a613bSKumar Gala *sdram_addr = 0xff; 401415a613bSKumar Gala ppcDcbf((unsigned long) sdram_addr); 402415a613bSKumar Gala udelay(100); 403415a613bSKumar Gala } 404415a613bSKumar Gala 405415a613bSKumar Gala /* 406415a613bSKumar Gala * Issue 8 MODE-set command. 407415a613bSKumar Gala */ 4086d0f6bcfSJean-Christophe PLAGNIOL-VILLARD lbc->lsdmr = lsdmr_common | CONFIG_SYS_LBC_LSDMR_OP_MRW; 409415a613bSKumar Gala asm("sync;msync"); 410415a613bSKumar Gala *sdram_addr = 0xff; 411415a613bSKumar Gala ppcDcbf((unsigned long) sdram_addr); 412415a613bSKumar Gala udelay(100); 413415a613bSKumar Gala 414415a613bSKumar Gala /* 415415a613bSKumar Gala * Issue NORMAL OP command. 416415a613bSKumar Gala */ 4176d0f6bcfSJean-Christophe PLAGNIOL-VILLARD lbc->lsdmr = lsdmr_common | CONFIG_SYS_LBC_LSDMR_OP_NORMAL; 418415a613bSKumar Gala asm("sync;msync"); 419415a613bSKumar Gala *sdram_addr = 0xff; 420415a613bSKumar Gala ppcDcbf((unsigned long) sdram_addr); 421415a613bSKumar Gala udelay(200); /* Overkill. Must wait > 200 bus cycles */ 422415a613bSKumar Gala 423415a613bSKumar Gala #endif /* enable SDRAM init */ 424415a613bSKumar Gala } 425415a613bSKumar Gala 426415a613bSKumar Gala #ifdef CONFIG_PCI 427415a613bSKumar Gala /* For some reason the Tundra PCI bridge shows up on itself as a 428415a613bSKumar Gala * different device. Work around that by refusing to configure it 429415a613bSKumar Gala */ 430415a613bSKumar Gala void dummy_func(struct pci_controller* hose, pci_dev_t dev, struct pci_config_table *tab) { } 431415a613bSKumar Gala 432415a613bSKumar Gala static struct pci_config_table pci_mpc85xxcds_config_table[] = { 433415a613bSKumar Gala {0x10e3, 0x0513, PCI_ANY_ID, 1, 3, PCI_ANY_ID, dummy_func, {0,0,0}}, 434415a613bSKumar Gala {0x1106, 0x0686, PCI_ANY_ID, 1, VIA_ID, 0, mpc85xx_config_via, {0,0,0}}, 435415a613bSKumar Gala {0x1106, 0x0571, PCI_ANY_ID, 1, VIA_ID, 1, 436415a613bSKumar Gala mpc85xx_config_via_usbide, {0,0,0}}, 437415a613bSKumar Gala {0x1105, 0x3038, PCI_ANY_ID, 1, VIA_ID, 2, 438415a613bSKumar Gala mpc85xx_config_via_usb, {0,0,0}}, 439415a613bSKumar Gala {0x1106, 0x3038, PCI_ANY_ID, 1, VIA_ID, 3, 440415a613bSKumar Gala mpc85xx_config_via_usb2, {0,0,0}}, 441415a613bSKumar Gala {0x1106, 0x3058, PCI_ANY_ID, 1, VIA_ID, 5, 442415a613bSKumar Gala mpc85xx_config_via_power, {0,0,0}}, 443415a613bSKumar Gala {0x1106, 0x3068, PCI_ANY_ID, 1, VIA_ID, 6, 444415a613bSKumar Gala mpc85xx_config_via_ac97, {0,0,0}}, 445415a613bSKumar Gala {}, 446415a613bSKumar Gala }; 447415a613bSKumar Gala 448415a613bSKumar Gala 449415a613bSKumar Gala static struct pci_controller hose[] = { 450415a613bSKumar Gala { 451415a613bSKumar Gala config_table: pci_mpc85xxcds_config_table, 452415a613bSKumar Gala }, 453415a613bSKumar Gala #ifdef CONFIG_MPC85XX_PCI2 454415a613bSKumar Gala {}, 455415a613bSKumar Gala #endif 456415a613bSKumar Gala }; 457415a613bSKumar Gala 458415a613bSKumar Gala #endif 459415a613bSKumar Gala 460415a613bSKumar Gala void 461415a613bSKumar Gala pci_init_board(void) 462415a613bSKumar Gala { 463415a613bSKumar Gala #ifdef CONFIG_PCI 464415a613bSKumar Gala pci_mpc85xx_init(hose); 465415a613bSKumar Gala #endif 466415a613bSKumar Gala } 467415a613bSKumar Gala 468415a613bSKumar Gala #if defined(CONFIG_OF_BOARD_SETUP) 469415a613bSKumar Gala void 470415a613bSKumar Gala ft_pci_setup(void *blob, bd_t *bd) 471415a613bSKumar Gala { 472415a613bSKumar Gala int node, tmp[2]; 473415a613bSKumar Gala const char *path; 474415a613bSKumar Gala 475415a613bSKumar Gala node = fdt_path_offset(blob, "/aliases"); 476415a613bSKumar Gala tmp[0] = 0; 477415a613bSKumar Gala if (node >= 0) { 478415a613bSKumar Gala #ifdef CONFIG_PCI1 479415a613bSKumar Gala path = fdt_getprop(blob, node, "pci0", NULL); 480415a613bSKumar Gala if (path) { 481415a613bSKumar Gala tmp[1] = hose[0].last_busno - hose[0].first_busno; 482415a613bSKumar Gala do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1); 483415a613bSKumar Gala } 484415a613bSKumar Gala #endif 485415a613bSKumar Gala #ifdef CONFIG_MPC85XX_PCI2 486415a613bSKumar Gala path = fdt_getprop(blob, node, "pci1", NULL); 487415a613bSKumar Gala if (path) { 488415a613bSKumar Gala tmp[1] = hose[1].last_busno - hose[1].first_busno; 489415a613bSKumar Gala do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1); 490415a613bSKumar Gala } 491415a613bSKumar Gala #endif 492415a613bSKumar Gala } 493415a613bSKumar Gala } 494415a613bSKumar Gala #endif 495