Tom Rini | 83d290c | 2018-05-06 17:58:06 -0400 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0+ |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 2 | /* |
chenhui zhao | 568336e | 2011-09-15 14:52:34 +0800 | [diff] [blame] | 3 | * Copyright 2004, 2011 Freescale Semiconductor. |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 4 | * |
| 5 | * (C) Copyright 2002 Scott McNutt <smcnutt@artesyncp.com> |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 6 | */ |
| 7 | |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 8 | #include <common.h> |
| 9 | #include <pci.h> |
| 10 | #include <asm/processor.h> |
Jon Loeliger | aa11d85 | 2008-03-17 15:48:18 -0500 | [diff] [blame] | 11 | #include <asm/mmu.h> |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 12 | #include <asm/immap_85xx.h> |
York Sun | 5614e71 | 2013-09-30 09:22:09 -0700 | [diff] [blame] | 13 | #include <fsl_ddr_sdram.h> |
Wolfgang Denk | 2d5df63 | 2005-07-21 16:14:36 +0200 | [diff] [blame] | 14 | #include <ioports.h> |
Jon Loeliger | a30a549 | 2008-03-04 10:03:03 -0600 | [diff] [blame] | 15 | #include <spd_sdram.h> |
Masahiro Yamada | b08c8c4 | 2018-03-05 01:20:11 +0900 | [diff] [blame] | 16 | #include <linux/libfdt.h> |
Kumar Gala | b90d254 | 2007-11-29 00:11:44 -0600 | [diff] [blame] | 17 | #include <fdt_support.h> |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 18 | |
| 19 | #include "../common/cadmus.h" |
| 20 | #include "../common/eeprom.h" |
Matthew McClintock | cbfc7ce | 2006-06-28 10:46:13 -0500 | [diff] [blame] | 21 | #include "../common/via.h" |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 22 | |
Jon Loeliger | d9b94f2 | 2005-07-25 14:05:07 -0500 | [diff] [blame] | 23 | #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER) |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 24 | extern void ddr_enable_ecc(unsigned int dram_size); |
| 25 | #endif |
| 26 | |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 27 | void local_bus_init(void); |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 28 | |
Wolfgang Denk | 2d5df63 | 2005-07-21 16:14:36 +0200 | [diff] [blame] | 29 | /* |
| 30 | * I/O Port configuration table |
| 31 | * |
| 32 | * if conf is 1, then that port pin will be configured at boot time |
| 33 | * according to the five values podr/pdir/ppar/psor/pdat for that entry |
| 34 | */ |
| 35 | |
| 36 | const iop_conf_t iop_conf_tab[4][32] = { |
| 37 | |
| 38 | /* Port A configuration */ |
| 39 | { /* conf ppar psor pdir podr pdat */ |
| 40 | /* PA31 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxENB */ |
| 41 | /* PA30 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 TxClav */ |
| 42 | /* PA29 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxSOC */ |
| 43 | /* PA28 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 RxENB */ |
| 44 | /* PA27 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RxSOC */ |
| 45 | /* PA26 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RxClav */ |
| 46 | /* PA25 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[0] */ |
| 47 | /* PA24 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[1] */ |
| 48 | /* PA23 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[2] */ |
| 49 | /* PA22 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[3] */ |
| 50 | /* PA21 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[4] */ |
| 51 | /* PA20 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[5] */ |
| 52 | /* PA19 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[6] */ |
| 53 | /* PA18 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[7] */ |
| 54 | /* PA17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[7] */ |
| 55 | /* PA16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[6] */ |
| 56 | /* PA15 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[5] */ |
| 57 | /* PA14 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[4] */ |
| 58 | /* PA13 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[3] */ |
| 59 | /* PA12 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[2] */ |
| 60 | /* PA11 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[1] */ |
| 61 | /* PA10 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[0] */ |
| 62 | /* PA9 */ { 0, 1, 1, 1, 0, 0 }, /* FCC1 L1TXD */ |
| 63 | /* PA8 */ { 0, 1, 1, 0, 0, 0 }, /* FCC1 L1RXD */ |
| 64 | /* PA7 */ { 0, 0, 0, 1, 0, 0 }, /* PA7 */ |
| 65 | /* PA6 */ { 0, 1, 1, 1, 0, 0 }, /* TDM A1 L1RSYNC */ |
| 66 | /* PA5 */ { 0, 0, 0, 1, 0, 0 }, /* PA5 */ |
| 67 | /* PA4 */ { 0, 0, 0, 1, 0, 0 }, /* PA4 */ |
| 68 | /* PA3 */ { 0, 0, 0, 1, 0, 0 }, /* PA3 */ |
| 69 | /* PA2 */ { 0, 0, 0, 1, 0, 0 }, /* PA2 */ |
| 70 | /* PA1 */ { 1, 0, 0, 0, 0, 0 }, /* FREERUN */ |
| 71 | /* PA0 */ { 0, 0, 0, 1, 0, 0 } /* PA0 */ |
| 72 | }, |
| 73 | |
| 74 | /* Port B configuration */ |
| 75 | { /* conf ppar psor pdir podr pdat */ |
| 76 | /* PB31 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TX_ER */ |
| 77 | /* PB30 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_DV */ |
| 78 | /* PB29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC2 MII TX_EN */ |
| 79 | /* PB28 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_ER */ |
| 80 | /* PB27 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII COL */ |
| 81 | /* PB26 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII CRS */ |
| 82 | /* PB25 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[3] */ |
| 83 | /* PB24 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[2] */ |
| 84 | /* PB23 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[1] */ |
| 85 | /* PB22 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[0] */ |
| 86 | /* PB21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[0] */ |
| 87 | /* PB20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[1] */ |
| 88 | /* PB19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[2] */ |
| 89 | /* PB18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[3] */ |
| 90 | /* PB17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RX_DIV */ |
| 91 | /* PB16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RX_ERR */ |
| 92 | /* PB15 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TX_ERR */ |
| 93 | /* PB14 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TX_EN */ |
| 94 | /* PB13 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:COL */ |
| 95 | /* PB12 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:CRS */ |
| 96 | /* PB11 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */ |
| 97 | /* PB10 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */ |
| 98 | /* PB9 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */ |
| 99 | /* PB8 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */ |
| 100 | /* PB7 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */ |
| 101 | /* PB6 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */ |
| 102 | /* PB5 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */ |
| 103 | /* PB4 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */ |
| 104 | /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */ |
| 105 | /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */ |
| 106 | /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */ |
| 107 | /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */ |
| 108 | }, |
| 109 | |
| 110 | /* Port C */ |
| 111 | { /* conf ppar psor pdir podr pdat */ |
| 112 | /* PC31 */ { 0, 0, 0, 1, 0, 0 }, /* PC31 */ |
| 113 | /* PC30 */ { 0, 0, 0, 1, 0, 0 }, /* PC30 */ |
| 114 | /* PC29 */ { 0, 1, 1, 0, 0, 0 }, /* SCC1 EN *CLSN */ |
| 115 | /* PC28 */ { 0, 0, 0, 1, 0, 0 }, /* PC28 */ |
| 116 | /* PC27 */ { 0, 0, 0, 1, 0, 0 }, /* UART Clock in */ |
| 117 | /* PC26 */ { 0, 0, 0, 1, 0, 0 }, /* PC26 */ |
| 118 | /* PC25 */ { 0, 0, 0, 1, 0, 0 }, /* PC25 */ |
| 119 | /* PC24 */ { 0, 0, 0, 1, 0, 0 }, /* PC24 */ |
| 120 | /* PC23 */ { 0, 1, 0, 1, 0, 0 }, /* ATMTFCLK */ |
| 121 | /* PC22 */ { 0, 1, 0, 0, 0, 0 }, /* ATMRFCLK */ |
| 122 | /* PC21 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN RXCLK */ |
| 123 | /* PC20 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN TXCLK */ |
| 124 | /* PC19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_CLK CLK13 */ |
| 125 | /* PC18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC Tx Clock (CLK14) */ |
| 126 | /* PC17 */ { 0, 0, 0, 1, 0, 0 }, /* PC17 */ |
| 127 | /* PC16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC Tx Clock (CLK16) */ |
| 128 | /* PC15 */ { 1, 1, 0, 0, 0, 0 }, /* PC15 */ |
| 129 | /* PC14 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN *CD */ |
| 130 | /* PC13 */ { 0, 0, 0, 1, 0, 0 }, /* PC13 */ |
| 131 | /* PC12 */ { 0, 1, 0, 1, 0, 0 }, /* PC12 */ |
| 132 | /* PC11 */ { 0, 0, 0, 1, 0, 0 }, /* LXT971 transmit control */ |
| 133 | /* PC10 */ { 1, 0, 0, 1, 0, 0 }, /* FETHMDC */ |
| 134 | /* PC9 */ { 1, 0, 0, 0, 0, 0 }, /* FETHMDIO */ |
| 135 | /* PC8 */ { 0, 0, 0, 1, 0, 0 }, /* PC8 */ |
| 136 | /* PC7 */ { 0, 0, 0, 1, 0, 0 }, /* PC7 */ |
| 137 | /* PC6 */ { 0, 0, 0, 1, 0, 0 }, /* PC6 */ |
| 138 | /* PC5 */ { 0, 0, 0, 1, 0, 0 }, /* PC5 */ |
| 139 | /* PC4 */ { 0, 0, 0, 1, 0, 0 }, /* PC4 */ |
| 140 | /* PC3 */ { 0, 0, 0, 1, 0, 0 }, /* PC3 */ |
| 141 | /* PC2 */ { 0, 0, 0, 1, 0, 1 }, /* ENET FDE */ |
| 142 | /* PC1 */ { 0, 0, 0, 1, 0, 0 }, /* ENET DSQE */ |
| 143 | /* PC0 */ { 0, 0, 0, 1, 0, 0 }, /* ENET LBK */ |
| 144 | }, |
| 145 | |
| 146 | /* Port D */ |
| 147 | { /* conf ppar psor pdir podr pdat */ |
| 148 | /* PD31 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN RxD */ |
| 149 | /* PD30 */ { 1, 1, 1, 1, 0, 0 }, /* SCC1 EN TxD */ |
| 150 | /* PD29 */ { 1, 1, 0, 1, 0, 0 }, /* SCC1 EN TENA */ |
| 151 | /* PD28 */ { 0, 1, 0, 0, 0, 0 }, /* PD28 */ |
| 152 | /* PD27 */ { 0, 1, 1, 1, 0, 0 }, /* PD27 */ |
| 153 | /* PD26 */ { 0, 0, 0, 1, 0, 0 }, /* PD26 */ |
| 154 | /* PD25 */ { 0, 0, 0, 1, 0, 0 }, /* PD25 */ |
| 155 | /* PD24 */ { 0, 0, 0, 1, 0, 0 }, /* PD24 */ |
| 156 | /* PD23 */ { 0, 0, 0, 1, 0, 0 }, /* PD23 */ |
| 157 | /* PD22 */ { 0, 0, 0, 1, 0, 0 }, /* PD22 */ |
| 158 | /* PD21 */ { 0, 0, 0, 1, 0, 0 }, /* PD21 */ |
| 159 | /* PD20 */ { 0, 0, 0, 1, 0, 0 }, /* PD20 */ |
| 160 | /* PD19 */ { 0, 0, 0, 1, 0, 0 }, /* PD19 */ |
| 161 | /* PD18 */ { 0, 0, 0, 1, 0, 0 }, /* PD18 */ |
| 162 | /* PD17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXPRTY */ |
| 163 | /* PD16 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXPRTY */ |
| 164 | /* PD15 */ { 0, 1, 1, 0, 1, 0 }, /* I2C SDA */ |
| 165 | /* PD14 */ { 0, 0, 0, 1, 0, 0 }, /* LED */ |
| 166 | /* PD13 */ { 0, 0, 0, 0, 0, 0 }, /* PD13 */ |
| 167 | /* PD12 */ { 0, 0, 0, 0, 0, 0 }, /* PD12 */ |
| 168 | /* PD11 */ { 0, 0, 0, 0, 0, 0 }, /* PD11 */ |
| 169 | /* PD10 */ { 0, 0, 0, 0, 0, 0 }, /* PD10 */ |
| 170 | /* PD9 */ { 0, 1, 0, 1, 0, 0 }, /* SMC1 TXD */ |
| 171 | /* PD8 */ { 0, 1, 0, 0, 0, 0 }, /* SMC1 RXD */ |
| 172 | /* PD7 */ { 0, 0, 0, 1, 0, 1 }, /* PD7 */ |
| 173 | /* PD6 */ { 0, 0, 0, 1, 0, 1 }, /* PD6 */ |
| 174 | /* PD5 */ { 0, 0, 0, 1, 0, 1 }, /* PD5 */ |
| 175 | /* PD4 */ { 0, 0, 0, 1, 0, 1 }, /* PD4 */ |
| 176 | /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */ |
| 177 | /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */ |
| 178 | /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */ |
| 179 | /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */ |
| 180 | } |
| 181 | }; |
| 182 | |
wdenk | 5c952cf | 2004-10-10 21:27:30 +0000 | [diff] [blame] | 183 | int checkboard (void) |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 184 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 185 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
chenhui zhao | 568336e | 2011-09-15 14:52:34 +0800 | [diff] [blame] | 186 | char buf[32]; |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 187 | |
wdenk | 5c952cf | 2004-10-10 21:27:30 +0000 | [diff] [blame] | 188 | /* PCI slot in USER bits CSR[6:7] by convention. */ |
| 189 | uint pci_slot = get_pci_slot (); |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 190 | |
wdenk | 5c952cf | 2004-10-10 21:27:30 +0000 | [diff] [blame] | 191 | uint pci_dual = get_pci_dual (); /* PCI DUAL in CM_PCI[3] */ |
| 192 | uint pci1_32 = gur->pordevsr & 0x10000; /* PORDEVSR[15] */ |
| 193 | uint pci1_clk_sel = gur->porpllsr & 0x8000; /* PORPLLSR[16] */ |
| 194 | uint pci2_clk_sel = gur->porpllsr & 0x4000; /* PORPLLSR[17] */ |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 195 | |
wdenk | 5c952cf | 2004-10-10 21:27:30 +0000 | [diff] [blame] | 196 | uint pci1_speed = get_clock_freq (); /* PCI PSPEED in [4:5] */ |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 197 | |
wdenk | 5c952cf | 2004-10-10 21:27:30 +0000 | [diff] [blame] | 198 | uint cpu_board_rev = get_cpu_board_revision (); |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 199 | |
wdenk | 5c952cf | 2004-10-10 21:27:30 +0000 | [diff] [blame] | 200 | printf ("Board: CDS Version 0x%02x, PCI Slot %d\n", |
| 201 | get_board_version (), pci_slot); |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 202 | |
wdenk | 5c952cf | 2004-10-10 21:27:30 +0000 | [diff] [blame] | 203 | printf ("CPU Board Revision %d.%d (0x%04x)\n", |
| 204 | MPC85XX_CPU_BOARD_MAJOR (cpu_board_rev), |
| 205 | MPC85XX_CPU_BOARD_MINOR (cpu_board_rev), cpu_board_rev); |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 206 | |
Peter Tyser | 8ca78f2 | 2010-10-29 17:59:24 -0500 | [diff] [blame] | 207 | printf("PCI1: %d bit, %s MHz, %s\n", |
wdenk | 5c952cf | 2004-10-10 21:27:30 +0000 | [diff] [blame] | 208 | (pci1_32) ? 32 : 64, |
chenhui zhao | 568336e | 2011-09-15 14:52:34 +0800 | [diff] [blame] | 209 | strmhz(buf, pci1_speed), |
wdenk | 5c952cf | 2004-10-10 21:27:30 +0000 | [diff] [blame] | 210 | pci1_clk_sel ? "sync" : "async"); |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 211 | |
wdenk | 5c952cf | 2004-10-10 21:27:30 +0000 | [diff] [blame] | 212 | if (pci_dual) { |
Peter Tyser | 8ca78f2 | 2010-10-29 17:59:24 -0500 | [diff] [blame] | 213 | printf("PCI2: 32 bit, 66 MHz, %s\n", |
wdenk | 5c952cf | 2004-10-10 21:27:30 +0000 | [diff] [blame] | 214 | pci2_clk_sel ? "sync" : "async"); |
| 215 | } else { |
Peter Tyser | 8ca78f2 | 2010-10-29 17:59:24 -0500 | [diff] [blame] | 216 | printf("PCI2: disabled\n"); |
wdenk | 5c952cf | 2004-10-10 21:27:30 +0000 | [diff] [blame] | 217 | } |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 218 | |
wdenk | 5c952cf | 2004-10-10 21:27:30 +0000 | [diff] [blame] | 219 | /* |
| 220 | * Initialize local bus. |
| 221 | */ |
| 222 | local_bus_init (); |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 223 | |
wdenk | 5c952cf | 2004-10-10 21:27:30 +0000 | [diff] [blame] | 224 | return 0; |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 225 | } |
| 226 | |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 227 | /* |
| 228 | * Initialize Local Bus |
| 229 | */ |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 230 | void |
| 231 | local_bus_init(void) |
| 232 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 233 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
Becky Bruce | f51cdaf | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 234 | volatile fsl_lbc_t *lbc = LBC_BASE_ADDR; |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 235 | |
| 236 | uint clkdiv; |
| 237 | uint lbc_hz; |
| 238 | sys_info_t sysinfo; |
| 239 | uint temp_lbcdll; |
| 240 | |
| 241 | /* |
| 242 | * Errata LBC11. |
| 243 | * Fix Local Bus clock glitch when DLL is enabled. |
| 244 | * |
Wolfgang Denk | 8ed44d9 | 2008-10-19 02:35:50 +0200 | [diff] [blame] | 245 | * If localbus freq is < 66MHz, DLL bypass mode must be used. |
| 246 | * If localbus freq is > 133MHz, DLL can be safely enabled. |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 247 | * Between 66 and 133, the DLL is enabled with an override workaround. |
| 248 | */ |
| 249 | |
| 250 | get_sys_info(&sysinfo); |
Trent Piepho | a5d212a | 2008-12-03 15:16:34 -0800 | [diff] [blame] | 251 | clkdiv = lbc->lcrr & LCRR_CLKDIV; |
Prabhakar Kushwaha | 997399f | 2013-08-16 14:52:26 +0530 | [diff] [blame] | 252 | lbc_hz = sysinfo.freq_systembus / 1000000 / clkdiv; |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 253 | |
| 254 | if (lbc_hz < 66) { |
Paul Gortmaker | a2af6a7 | 2012-08-13 13:48:57 +0000 | [diff] [blame] | 255 | lbc->lcrr |= LCRR_DBYP; /* DLL Bypass */ |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 256 | |
| 257 | } else if (lbc_hz >= 133) { |
Paul Gortmaker | a2af6a7 | 2012-08-13 13:48:57 +0000 | [diff] [blame] | 258 | lbc->lcrr &= (~LCRR_DBYP); /* DLL Enabled */ |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 259 | |
| 260 | } else { |
Paul Gortmaker | a2af6a7 | 2012-08-13 13:48:57 +0000 | [diff] [blame] | 261 | lbc->lcrr &= (~LCRR_DBYP); /* DLL Enabled */ |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 262 | udelay(200); |
| 263 | |
| 264 | /* |
| 265 | * Sample LBC DLL ctrl reg, upshift it to set the |
| 266 | * override bits. |
| 267 | */ |
| 268 | temp_lbcdll = gur->lbcdllcr; |
| 269 | gur->lbcdllcr = (((temp_lbcdll & 0xff) << 16) | 0x80000000); |
| 270 | asm("sync;isync;msync"); |
| 271 | } |
| 272 | } |
| 273 | |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 274 | /* |
| 275 | * Initialize SDRAM memory on the Local Bus. |
| 276 | */ |
Becky Bruce | 70961ba | 2010-12-17 17:17:57 -0600 | [diff] [blame] | 277 | void lbc_sdram_init(void) |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 278 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 279 | #if defined(CONFIG_SYS_OR2_PRELIM) && defined(CONFIG_SYS_BR2_PRELIM) |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 280 | |
| 281 | uint idx; |
Becky Bruce | f51cdaf | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 282 | volatile fsl_lbc_t *lbc = LBC_BASE_ADDR; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 283 | uint *sdram_addr = (uint *)CONFIG_SYS_LBC_SDRAM_BASE; |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 284 | uint cpu_board_rev; |
| 285 | uint lsdmr_common; |
| 286 | |
Becky Bruce | 7ea3871 | 2010-12-17 17:17:59 -0600 | [diff] [blame] | 287 | puts("LBC SDRAM: "); |
| 288 | print_size(CONFIG_SYS_LBC_SDRAM_SIZE * 1024 * 1024, |
| 289 | "\n "); |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 290 | |
| 291 | /* |
| 292 | * Setup SDRAM Base and Option Registers |
| 293 | */ |
Becky Bruce | f51cdaf | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 294 | set_lbc_or(2, CONFIG_SYS_OR2_PRELIM); |
| 295 | set_lbc_br(2, CONFIG_SYS_BR2_PRELIM); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 296 | lbc->lbcr = CONFIG_SYS_LBC_LBCR; |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 297 | asm("msync"); |
| 298 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 299 | lbc->lsrt = CONFIG_SYS_LBC_LSRT; |
| 300 | lbc->mrtpr = CONFIG_SYS_LBC_MRTPR; |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 301 | asm("msync"); |
| 302 | |
| 303 | /* |
| 304 | * Determine which address lines to use baed on CPU board rev. |
| 305 | */ |
| 306 | cpu_board_rev = get_cpu_board_revision(); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 307 | lsdmr_common = CONFIG_SYS_LBC_LSDMR_COMMON; |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 308 | if (cpu_board_rev == MPC85XX_CPU_BOARD_REV_1_0) { |
Kumar Gala | b0fe93ed | 2009-03-26 01:34:38 -0500 | [diff] [blame] | 309 | lsdmr_common |= LSDMR_BSMA1617; |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 310 | } else if (cpu_board_rev == MPC85XX_CPU_BOARD_REV_1_1) { |
Kumar Gala | b0fe93ed | 2009-03-26 01:34:38 -0500 | [diff] [blame] | 311 | lsdmr_common |= LSDMR_BSMA1516; |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 312 | } else { |
| 313 | /* |
| 314 | * Assume something unable to identify itself is |
| 315 | * really old, and likely has lines 16/17 mapped. |
| 316 | */ |
Kumar Gala | b0fe93ed | 2009-03-26 01:34:38 -0500 | [diff] [blame] | 317 | lsdmr_common |= LSDMR_BSMA1617; |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 318 | } |
| 319 | |
| 320 | /* |
| 321 | * Issue PRECHARGE ALL command. |
| 322 | */ |
Kumar Gala | b0fe93ed | 2009-03-26 01:34:38 -0500 | [diff] [blame] | 323 | lbc->lsdmr = lsdmr_common | LSDMR_OP_PCHALL; |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 324 | asm("sync;msync"); |
| 325 | *sdram_addr = 0xff; |
| 326 | ppcDcbf((unsigned long) sdram_addr); |
| 327 | udelay(100); |
| 328 | |
| 329 | /* |
| 330 | * Issue 8 AUTO REFRESH commands. |
| 331 | */ |
| 332 | for (idx = 0; idx < 8; idx++) { |
Kumar Gala | b0fe93ed | 2009-03-26 01:34:38 -0500 | [diff] [blame] | 333 | lbc->lsdmr = lsdmr_common | LSDMR_OP_ARFRSH; |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 334 | asm("sync;msync"); |
| 335 | *sdram_addr = 0xff; |
| 336 | ppcDcbf((unsigned long) sdram_addr); |
| 337 | udelay(100); |
| 338 | } |
| 339 | |
| 340 | /* |
| 341 | * Issue 8 MODE-set command. |
| 342 | */ |
Kumar Gala | b0fe93ed | 2009-03-26 01:34:38 -0500 | [diff] [blame] | 343 | lbc->lsdmr = lsdmr_common | LSDMR_OP_MRW; |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 344 | asm("sync;msync"); |
| 345 | *sdram_addr = 0xff; |
| 346 | ppcDcbf((unsigned long) sdram_addr); |
| 347 | udelay(100); |
| 348 | |
| 349 | /* |
| 350 | * Issue NORMAL OP command. |
| 351 | */ |
Kumar Gala | b0fe93ed | 2009-03-26 01:34:38 -0500 | [diff] [blame] | 352 | lbc->lsdmr = lsdmr_common | LSDMR_OP_NORMAL; |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 353 | asm("sync;msync"); |
| 354 | *sdram_addr = 0xff; |
| 355 | ppcDcbf((unsigned long) sdram_addr); |
| 356 | udelay(200); /* Overkill. Must wait > 200 bus cycles */ |
| 357 | |
| 358 | #endif /* enable SDRAM init */ |
| 359 | } |
| 360 | |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 361 | #if defined(CONFIG_PCI) |
Matthew McClintock | cbfc7ce | 2006-06-28 10:46:13 -0500 | [diff] [blame] | 362 | /* For some reason the Tundra PCI bridge shows up on itself as a |
| 363 | * different device. Work around that by refusing to configure it. |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 364 | */ |
Matthew McClintock | cbfc7ce | 2006-06-28 10:46:13 -0500 | [diff] [blame] | 365 | void dummy_func(struct pci_controller* hose, pci_dev_t dev, struct pci_config_table *tab) { } |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 366 | |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 367 | static struct pci_config_table pci_mpc85xxcds_config_table[] = { |
Matthew McClintock | cbfc7ce | 2006-06-28 10:46:13 -0500 | [diff] [blame] | 368 | {0x10e3, 0x0513, PCI_ANY_ID, 1, 3, PCI_ANY_ID, dummy_func, {0,0,0}}, |
Randy Vinson | 7f3f2bd | 2007-02-27 19:42:22 -0700 | [diff] [blame] | 369 | {0x1106, 0x0686, PCI_ANY_ID, 1, VIA_ID, 0, mpc85xx_config_via, {0,0,0}}, |
| 370 | {0x1106, 0x0571, PCI_ANY_ID, 1, VIA_ID, 1, |
Andy Fleming | ffa621a | 2007-02-24 01:08:13 -0600 | [diff] [blame] | 371 | mpc85xx_config_via_usbide, {0,0,0}}, |
Randy Vinson | 7f3f2bd | 2007-02-27 19:42:22 -0700 | [diff] [blame] | 372 | {0x1105, 0x3038, PCI_ANY_ID, 1, VIA_ID, 2, |
| 373 | mpc85xx_config_via_usb, {0,0,0}}, |
| 374 | {0x1106, 0x3038, PCI_ANY_ID, 1, VIA_ID, 3, |
| 375 | mpc85xx_config_via_usb2, {0,0,0}}, |
| 376 | {0x1106, 0x3058, PCI_ANY_ID, 1, VIA_ID, 5, |
Andy Fleming | ffa621a | 2007-02-24 01:08:13 -0600 | [diff] [blame] | 377 | mpc85xx_config_via_power, {0,0,0}}, |
Randy Vinson | 7f3f2bd | 2007-02-27 19:42:22 -0700 | [diff] [blame] | 378 | {0x1106, 0x3068, PCI_ANY_ID, 1, VIA_ID, 6, |
| 379 | mpc85xx_config_via_ac97, {0,0,0}}, |
Andy Fleming | ffa621a | 2007-02-24 01:08:13 -0600 | [diff] [blame] | 380 | {}, |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 381 | }; |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 382 | |
Matthew McClintock | cbfc7ce | 2006-06-28 10:46:13 -0500 | [diff] [blame] | 383 | static struct pci_controller hose[] = { |
| 384 | { config_table: pci_mpc85xxcds_config_table,}, |
| 385 | #ifdef CONFIG_MPC85XX_PCI2 |
| 386 | {}, |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 387 | #endif |
| 388 | }; |
| 389 | |
| 390 | #endif /* CONFIG_PCI */ |
| 391 | |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 392 | void |
| 393 | pci_init_board(void) |
| 394 | { |
| 395 | #ifdef CONFIG_PCI |
Matthew McClintock | 7376eb8 | 2006-10-11 15:13:01 -0500 | [diff] [blame] | 396 | pci_mpc85xx_init(hose); |
wdenk | 03f5c55 | 2004-10-10 21:21:55 +0000 | [diff] [blame] | 397 | #endif |
| 398 | } |
Kumar Gala | b90d254 | 2007-11-29 00:11:44 -0600 | [diff] [blame] | 399 | |
| 400 | #if defined(CONFIG_OF_BOARD_SETUP) |
| 401 | void |
| 402 | ft_pci_setup(void *blob, bd_t *bd) |
| 403 | { |
| 404 | int node, tmp[2]; |
| 405 | const char *path; |
| 406 | |
| 407 | node = fdt_path_offset(blob, "/aliases"); |
| 408 | tmp[0] = 0; |
| 409 | if (node >= 0) { |
| 410 | #ifdef CONFIG_PCI1 |
| 411 | path = fdt_getprop(blob, node, "pci0", NULL); |
| 412 | if (path) { |
| 413 | tmp[1] = hose[0].last_busno - hose[0].first_busno; |
| 414 | do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1); |
| 415 | } |
| 416 | #endif |
| 417 | #ifdef CONFIG_MPC85XX_PCI2 |
| 418 | path = fdt_getprop(blob, node, "pci1", NULL); |
| 419 | if (path) { |
| 420 | tmp[1] = hose[1].last_busno - hose[1].first_busno; |
| 421 | do_fixup_by_path(blob, path, "bus-range", &tmp, 8, 1); |
| 422 | } |
| 423 | #endif |
| 424 | } |
| 425 | } |
| 426 | #endif |