wdenk | 67c4f48 | 2002-08-26 22:23:10 +0000 | [diff] [blame] | 1 | /* |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame^] | 2 | * (C) Copyright 2001-2003 |
wdenk | 67c4f48 | 2002-08-26 22:23:10 +0000 | [diff] [blame] | 3 | * Wolfgang Denk, DENX Software Engineering, wd@denx.de. |
| 4 | * |
| 5 | * Modified during 2001 by |
| 6 | * Advanced Communications Technologies (Australia) Pty. Ltd. |
| 7 | * Howard Walker, Tuong Vu-Dinh |
| 8 | * |
| 9 | * (C) Copyright 2001, Stuart Hughes, Lineo Inc, stuarth@lineo.com |
| 10 | * Added support for the 16M dram simm on the 8260ads boards |
| 11 | * |
| 12 | * See file CREDITS for list of people who contributed to this |
| 13 | * project. |
| 14 | * |
| 15 | * This program is free software; you can redistribute it and/or |
| 16 | * modify it under the terms of the GNU General Public License as |
| 17 | * published by the Free Software Foundation; either version 2 of |
| 18 | * the License, or (at your option) any later version. |
| 19 | * |
| 20 | * This program is distributed in the hope that it will be useful, |
| 21 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 22 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 23 | * GNU General Public License for more details. |
| 24 | * |
| 25 | * You should have received a copy of the GNU General Public License |
| 26 | * along with this program; if not, write to the Free Software |
| 27 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 28 | * MA 02111-1307 USA |
| 29 | */ |
| 30 | |
| 31 | #include <common.h> |
| 32 | #include <ioports.h> |
| 33 | #include <mpc8260.h> |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame^] | 34 | #include <i2c.h> |
| 35 | #include <spd.h> |
wdenk | 67c4f48 | 2002-08-26 22:23:10 +0000 | [diff] [blame] | 36 | |
| 37 | /* |
| 38 | * I/O Port configuration table |
| 39 | * |
| 40 | * if conf is 1, then that port pin will be configured at boot time |
| 41 | * according to the five values podr/pdir/ppar/psor/pdat for that entry |
| 42 | */ |
| 43 | |
| 44 | const iop_conf_t iop_conf_tab[4][32] = { |
| 45 | |
| 46 | /* Port A configuration */ |
| 47 | { /* conf ppar psor pdir podr pdat */ |
| 48 | /* PA31 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxENB */ |
| 49 | /* PA30 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 TxClav */ |
| 50 | /* PA29 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 TxSOC */ |
| 51 | /* PA28 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 RxENB */ |
| 52 | /* PA27 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RxSOC */ |
| 53 | /* PA26 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 RxClav */ |
| 54 | /* PA25 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[0] */ |
| 55 | /* PA24 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[1] */ |
| 56 | /* PA23 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[2] */ |
| 57 | /* PA22 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[3] */ |
| 58 | /* PA21 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[4] */ |
| 59 | /* PA20 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[5] */ |
| 60 | /* PA19 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[6] */ |
| 61 | /* PA18 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXD[7] */ |
| 62 | /* PA17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[7] */ |
| 63 | /* PA16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[6] */ |
| 64 | /* PA15 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[5] */ |
| 65 | /* PA14 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[4] */ |
| 66 | /* PA13 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[3] */ |
| 67 | /* PA12 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[2] */ |
| 68 | /* PA11 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[1] */ |
| 69 | /* PA10 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXD[0] */ |
| 70 | /* PA9 */ { 0, 1, 1, 1, 0, 0 }, /* FCC1 L1TXD */ |
| 71 | /* PA8 */ { 0, 1, 1, 0, 0, 0 }, /* FCC1 L1RXD */ |
| 72 | /* PA7 */ { 0, 0, 0, 1, 0, 0 }, /* PA7 */ |
| 73 | /* PA6 */ { 1, 1, 1, 1, 0, 0 }, /* TDM A1 L1RSYNC */ |
| 74 | /* PA5 */ { 0, 0, 0, 1, 0, 0 }, /* PA5 */ |
| 75 | /* PA4 */ { 0, 0, 0, 1, 0, 0 }, /* PA4 */ |
| 76 | /* PA3 */ { 0, 0, 0, 1, 0, 0 }, /* PA3 */ |
| 77 | /* PA2 */ { 0, 0, 0, 1, 0, 0 }, /* PA2 */ |
| 78 | /* PA1 */ { 1, 0, 0, 0, 0, 0 }, /* FREERUN */ |
| 79 | /* PA0 */ { 0, 0, 0, 1, 0, 0 } /* PA0 */ |
| 80 | }, |
| 81 | |
| 82 | /* Port B configuration */ |
| 83 | { /* conf ppar psor pdir podr pdat */ |
| 84 | /* PB31 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TX_ER */ |
| 85 | /* PB30 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_DV */ |
| 86 | /* PB29 */ { 1, 1, 1, 1, 0, 0 }, /* FCC2 MII TX_EN */ |
| 87 | /* PB28 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_ER */ |
| 88 | /* PB27 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII COL */ |
| 89 | /* PB26 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII CRS */ |
| 90 | /* PB25 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[3] */ |
| 91 | /* PB24 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[2] */ |
| 92 | /* PB23 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[1] */ |
| 93 | /* PB22 */ { 1, 1, 0, 1, 0, 0 }, /* FCC2 MII TxD[0] */ |
| 94 | /* PB21 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[0] */ |
| 95 | /* PB20 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[1] */ |
| 96 | /* PB19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[2] */ |
| 97 | /* PB18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RxD[3] */ |
| 98 | /* PB17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RX_DIV */ |
| 99 | /* PB16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RX_ERR */ |
| 100 | /* PB15 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TX_ERR */ |
| 101 | /* PB14 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TX_EN */ |
| 102 | /* PB13 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:COL */ |
| 103 | /* PB12 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:CRS */ |
| 104 | /* PB11 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */ |
| 105 | /* PB10 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */ |
| 106 | /* PB9 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */ |
| 107 | /* PB8 */ { 0, 1, 0, 0, 0, 0 }, /* FCC3:RXD */ |
| 108 | /* PB7 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */ |
| 109 | /* PB6 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */ |
| 110 | /* PB5 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */ |
| 111 | /* PB4 */ { 0, 1, 0, 1, 0, 0 }, /* FCC3:TXD */ |
| 112 | /* PB3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */ |
| 113 | /* PB2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */ |
| 114 | /* PB1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */ |
| 115 | /* PB0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */ |
| 116 | }, |
| 117 | |
| 118 | /* Port C */ |
| 119 | { /* conf ppar psor pdir podr pdat */ |
| 120 | /* PC31 */ { 0, 0, 0, 1, 0, 0 }, /* PC31 */ |
| 121 | /* PC30 */ { 0, 0, 0, 1, 0, 0 }, /* PC30 */ |
| 122 | /* PC29 */ { 0, 1, 1, 0, 0, 0 }, /* SCC1 EN *CLSN */ |
| 123 | /* PC28 */ { 0, 0, 0, 1, 0, 0 }, /* PC28 */ |
| 124 | /* PC27 */ { 0, 0, 0, 1, 0, 0 }, /* UART Clock in */ |
| 125 | /* PC26 */ { 0, 0, 0, 1, 0, 0 }, /* PC26 */ |
| 126 | /* PC25 */ { 0, 0, 0, 1, 0, 0 }, /* PC25 */ |
| 127 | /* PC24 */ { 0, 0, 0, 1, 0, 0 }, /* PC24 */ |
| 128 | /* PC23 */ { 0, 1, 0, 1, 0, 0 }, /* ATMTFCLK */ |
| 129 | /* PC22 */ { 0, 1, 0, 0, 0, 0 }, /* ATMRFCLK */ |
| 130 | /* PC21 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN RXCLK */ |
| 131 | /* PC20 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN TXCLK */ |
| 132 | /* PC19 */ { 1, 1, 0, 0, 0, 0 }, /* FCC2 MII RX_CLK CLK13 */ |
| 133 | /* PC18 */ { 1, 1, 0, 0, 0, 0 }, /* FCC Tx Clock (CLK14) */ |
| 134 | /* PC17 */ { 0, 0, 0, 1, 0, 0 }, /* PC17 */ |
| 135 | /* PC16 */ { 0, 1, 0, 0, 0, 0 }, /* FCC Tx Clock (CLK16) */ |
| 136 | /* PC15 */ { 0, 0, 0, 1, 0, 0 }, /* PC15 */ |
| 137 | /* PC14 */ { 0, 1, 0, 0, 0, 0 }, /* SCC1 EN *CD */ |
| 138 | /* PC13 */ { 0, 0, 0, 1, 0, 0 }, /* PC13 */ |
| 139 | /* PC12 */ { 0, 1, 0, 1, 0, 0 }, /* PC12 */ |
| 140 | /* PC11 */ { 0, 0, 0, 1, 0, 0 }, /* LXT971 transmit control */ |
| 141 | /* PC10 */ { 1, 1, 0, 0, 0, 0 }, /* LXT970 FETHMDC */ |
| 142 | /* PC9 */ { 1, 1, 0, 0, 0, 0 }, /* LXT970 FETHMDIO */ |
| 143 | /* PC8 */ { 0, 0, 0, 1, 0, 0 }, /* PC8 */ |
| 144 | /* PC7 */ { 0, 0, 0, 1, 0, 0 }, /* PC7 */ |
| 145 | /* PC6 */ { 0, 0, 0, 1, 0, 0 }, /* PC6 */ |
| 146 | /* PC5 */ { 0, 0, 0, 1, 0, 0 }, /* PC5 */ |
| 147 | /* PC4 */ { 0, 0, 0, 1, 0, 0 }, /* PC4 */ |
| 148 | /* PC3 */ { 0, 0, 0, 1, 0, 0 }, /* PC3 */ |
| 149 | /* PC2 */ { 0, 0, 0, 1, 0, 1 }, /* ENET FDE */ |
| 150 | /* PC1 */ { 0, 0, 0, 1, 0, 0 }, /* ENET DSQE */ |
| 151 | /* PC0 */ { 0, 0, 0, 1, 0, 0 }, /* ENET LBK */ |
| 152 | }, |
| 153 | |
| 154 | /* Port D */ |
| 155 | { /* conf ppar psor pdir podr pdat */ |
| 156 | /* PD31 */ { 1, 1, 0, 0, 0, 0 }, /* SCC1 EN RxD */ |
| 157 | /* PD30 */ { 1, 1, 1, 1, 0, 0 }, /* SCC1 EN TxD */ |
| 158 | /* PD29 */ { 0, 1, 0, 1, 0, 0 }, /* SCC1 EN TENA */ |
| 159 | /* PD28 */ { 0, 1, 0, 0, 0, 0 }, /* PD28 */ |
| 160 | /* PD27 */ { 0, 1, 1, 1, 0, 0 }, /* PD27 */ |
| 161 | /* PD26 */ { 0, 0, 0, 1, 0, 0 }, /* PD26 */ |
| 162 | /* PD25 */ { 0, 0, 0, 1, 0, 0 }, /* PD25 */ |
| 163 | /* PD24 */ { 0, 0, 0, 1, 0, 0 }, /* PD24 */ |
| 164 | /* PD23 */ { 0, 0, 0, 1, 0, 0 }, /* PD23 */ |
| 165 | /* PD22 */ { 0, 0, 0, 1, 0, 0 }, /* PD22 */ |
| 166 | /* PD21 */ { 0, 0, 0, 1, 0, 0 }, /* PD21 */ |
| 167 | /* PD20 */ { 0, 0, 0, 1, 0, 0 }, /* PD20 */ |
| 168 | /* PD19 */ { 0, 0, 0, 1, 0, 0 }, /* PD19 */ |
| 169 | /* PD18 */ { 0, 0, 0, 1, 0, 0 }, /* PD18 */ |
| 170 | /* PD17 */ { 0, 1, 0, 0, 0, 0 }, /* FCC1 ATMRXPRTY */ |
| 171 | /* PD16 */ { 0, 1, 0, 1, 0, 0 }, /* FCC1 ATMTXPRTY */ |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame^] | 172 | /* PD15 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SDA */ |
| 173 | /* PD14 */ { 1, 1, 1, 0, 1, 0 }, /* I2C SCL */ |
wdenk | 67c4f48 | 2002-08-26 22:23:10 +0000 | [diff] [blame] | 174 | /* PD13 */ { 0, 0, 0, 0, 0, 0 }, /* PD13 */ |
| 175 | /* PD12 */ { 0, 0, 0, 0, 0, 0 }, /* PD12 */ |
| 176 | /* PD11 */ { 0, 0, 0, 0, 0, 0 }, /* PD11 */ |
| 177 | /* PD10 */ { 0, 0, 0, 0, 0, 0 }, /* PD10 */ |
| 178 | /* PD9 */ { 1, 1, 0, 1, 0, 0 }, /* SMC1 TXD */ |
| 179 | /* PD8 */ { 1, 1, 0, 0, 0, 0 }, /* SMC1 RXD */ |
| 180 | /* PD7 */ { 0, 0, 0, 1, 0, 1 }, /* PD7 */ |
| 181 | /* PD6 */ { 0, 0, 0, 1, 0, 1 }, /* PD6 */ |
| 182 | /* PD5 */ { 0, 0, 0, 1, 0, 1 }, /* PD5 */ |
| 183 | /* PD4 */ { 0, 0, 0, 1, 0, 1 }, /* PD4 */ |
| 184 | /* PD3 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */ |
| 185 | /* PD2 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */ |
| 186 | /* PD1 */ { 0, 0, 0, 0, 0, 0 }, /* pin doesn't exist */ |
| 187 | /* PD0 */ { 0, 0, 0, 0, 0, 0 } /* pin doesn't exist */ |
| 188 | } |
| 189 | }; |
| 190 | |
| 191 | typedef struct bscr_ { |
| 192 | unsigned long bcsr0; |
| 193 | unsigned long bcsr1; |
| 194 | unsigned long bcsr2; |
| 195 | unsigned long bcsr3; |
| 196 | unsigned long bcsr4; |
| 197 | unsigned long bcsr5; |
| 198 | unsigned long bcsr6; |
| 199 | unsigned long bcsr7; |
| 200 | } bcsr_t; |
| 201 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame^] | 202 | void reset_phy (void) |
wdenk | 67c4f48 | 2002-08-26 22:23:10 +0000 | [diff] [blame] | 203 | { |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame^] | 204 | volatile bcsr_t *bcsr = (bcsr_t *) CFG_BCSR; |
wdenk | 67c4f48 | 2002-08-26 22:23:10 +0000 | [diff] [blame] | 205 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame^] | 206 | /* reset the FEC port */ |
| 207 | bcsr->bcsr1 &= ~FETH_RST; |
| 208 | bcsr->bcsr1 |= FETH_RST; |
wdenk | 67c4f48 | 2002-08-26 22:23:10 +0000 | [diff] [blame] | 209 | } |
| 210 | |
| 211 | |
| 212 | int board_pre_init (void) |
| 213 | { |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame^] | 214 | volatile bcsr_t *bcsr = (bcsr_t *) CFG_BCSR; |
wdenk | 67c4f48 | 2002-08-26 22:23:10 +0000 | [diff] [blame] | 215 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame^] | 216 | bcsr->bcsr1 = ~FETHIEN & ~RS232EN_1; |
| 217 | |
| 218 | return 0; |
wdenk | 67c4f48 | 2002-08-26 22:23:10 +0000 | [diff] [blame] | 219 | } |
| 220 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame^] | 221 | #define ns2clk(ns) (ns / (1000000000 / CONFIG_8260_CLKIN) + 1) |
| 222 | |
| 223 | long int initdram (int board_type) |
wdenk | 67c4f48 | 2002-08-26 22:23:10 +0000 | [diff] [blame] | 224 | { |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame^] | 225 | volatile immap_t *immap = (immap_t *) CFG_IMMR; |
| 226 | volatile memctl8260_t *memctl = &immap->im_memctl; |
| 227 | volatile uchar *ramaddr, c = 0xff; |
| 228 | |
| 229 | /* Initialisation is for 16MB DIMM the board is shipped with */ |
| 230 | long int msize = 16; |
| 231 | uint or = 0xFF000CA0; |
| 232 | uint psdmr = CFG_PSDMR; |
| 233 | uint psrt = CFG_PSRT; |
| 234 | |
| 235 | int i; |
wdenk | 67c4f48 | 2002-08-26 22:23:10 +0000 | [diff] [blame] | 236 | |
| 237 | #ifndef CFG_RAMBOOT |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame^] | 238 | immap->im_siu_conf.sc_ppc_acr = 0x00000002; |
| 239 | immap->im_siu_conf.sc_ppc_alrh = 0x01267893; |
| 240 | immap->im_siu_conf.sc_tescr1 = 0x00004000; |
wdenk | 67c4f48 | 2002-08-26 22:23:10 +0000 | [diff] [blame] | 241 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame^] | 242 | memctl->memc_mptpr = CFG_MPTPR; |
| 243 | /* init local sdram, bank 4 */ |
| 244 | memctl->memc_lsrt = 0x00000010; |
| 245 | memctl->memc_or4 = 0xFFC01480; |
| 246 | memctl->memc_br4 = 0x04001861; |
| 247 | memctl->memc_lsdmr = 0x2886A522; |
| 248 | ramaddr = (uchar *) CFG_LSDRAM_BASE; |
| 249 | *ramaddr = c; |
| 250 | memctl->memc_lsdmr = 0x0886A522; |
| 251 | for (i = 0; i < 8; i++) { |
| 252 | *ramaddr = c; |
| 253 | } |
| 254 | memctl->memc_lsdmr = 0x1886A522; |
| 255 | *ramaddr = c; |
| 256 | memctl->memc_lsdmr = 0x4086A522; |
wdenk | 67c4f48 | 2002-08-26 22:23:10 +0000 | [diff] [blame] | 257 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame^] | 258 | /* init sdram dimm */ |
| 259 | #ifdef CONFIG_SPD_EEPROM |
| 260 | { |
| 261 | spd_eeprom_t spd; |
| 262 | uint pbi, bsel, rowst, lsb, tmp; |
wdenk | 67c4f48 | 2002-08-26 22:23:10 +0000 | [diff] [blame] | 263 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame^] | 264 | i2c_read (CONFIG_SPD_ADDR, 0, 1, (uchar *) & spd, sizeof (spd)); |
| 265 | |
| 266 | /* Bank-based interleaving is not supported for physical bank |
| 267 | sizes greater than 128MB which is encoded as 0x20 in SPD |
| 268 | */ |
| 269 | pbi = (spd.row_dens > 32) ? 1 : CONFIG_SDRAM_PBI; |
| 270 | msize = spd.nrows * (4 * spd.row_dens); /* Mixed size not supported */ |
| 271 | or = ~(msize - 1) << 20; /* SDAM */ |
| 272 | switch (spd.nbanks) { /* BPD */ |
| 273 | case 2: |
| 274 | bsel = 1; |
| 275 | break; |
| 276 | case 4: |
| 277 | bsel = 2; |
| 278 | or |= 0x00002000; |
| 279 | break; |
| 280 | case 8: |
| 281 | bsel = 3; |
| 282 | or |= 0x00004000; |
| 283 | break; |
| 284 | } |
| 285 | lsb = 3; /* For 64-bit port, lsb is 3 bits */ |
| 286 | |
| 287 | if (pbi) { /* Bus partition depends on interleaving */ |
| 288 | rowst = 32 - (spd.nrow_addr + spd.ncol_addr + bsel + lsb); |
| 289 | or |= (rowst << 9); /* ROWST */ |
| 290 | } else { |
| 291 | rowst = 32 - (spd.nrow_addr + spd.ncol_addr + lsb); |
| 292 | or |= ((rowst * 2 - 12) << 9); /* ROWST */ |
| 293 | } |
| 294 | or |= ((spd.nrow_addr - 9) << 6); /* NUMR */ |
| 295 | |
| 296 | psdmr = (pbi << 31); /* PBI */ |
| 297 | /* Bus multiplexing parameters */ |
| 298 | tmp = 32 - (lsb + spd.nrow_addr); /* Tables 10-19 and 10-20 */ |
| 299 | psdmr |= ((tmp - (rowst - 5) - 13) << 24); /* SDAM */ |
| 300 | psdmr |= ((tmp - 3 - 12) << 21); /* BSMA */ |
| 301 | |
| 302 | tmp = (31 - lsb - 10) - tmp; |
| 303 | /* Pin connected to SDA10 is (31 - lsb - 10). |
| 304 | rowst is multiplexed over (32 - (lsb + spd.nrow_addr)), |
| 305 | so (rowst + tmp) alternates with AP. |
| 306 | */ |
| 307 | if (pbi) /* Table 10-7 */ |
| 308 | psdmr |= ((10 - (rowst + tmp)) << 18); /* SDA10 */ |
| 309 | else |
| 310 | psdmr |= ((12 - (rowst + tmp)) << 18); /* SDA10 */ |
| 311 | |
| 312 | /* SDRAM device-specific parameters */ |
| 313 | tmp = ns2clk (70); /* Refresh recovery is not in SPD, so assume 70ns */ |
| 314 | switch (tmp) { /* RFRC */ |
| 315 | case 1: |
| 316 | case 2: |
| 317 | psdmr |= (1 << 15); |
| 318 | break; |
| 319 | case 3: |
| 320 | case 4: |
| 321 | case 5: |
| 322 | case 6: |
| 323 | case 7: |
| 324 | case 8: |
| 325 | psdmr |= ((tmp - 2) << 15); |
| 326 | break; |
| 327 | default: |
| 328 | psdmr |= (7 << 15); |
| 329 | } |
| 330 | psdmr |= (ns2clk (spd.trp) % 8 << 12); /* PRETOACT */ |
| 331 | psdmr |= (ns2clk (spd.trcd) % 8 << 9); /* ACTTORW */ |
| 332 | /* BL=0 because for 64-bit SDRAM burst length must be 4 */ |
| 333 | /* LDOTOPRE ??? */ |
| 334 | for (i = 0, tmp = spd.write_lat; (i < 4) && ((tmp & 1) == 0); i++) |
| 335 | tmp >>= 1; |
| 336 | switch (i) { /* WRC */ |
| 337 | case 0: |
| 338 | case 1: |
| 339 | psdmr |= (1 << 4); |
| 340 | break; |
| 341 | case 2: |
| 342 | case 3: |
| 343 | psdmr |= (i << 4); |
| 344 | break; |
| 345 | } |
| 346 | /* EAMUX=0 - no external address multiplexing */ |
| 347 | /* BUFCMD=0 - no external buffers */ |
| 348 | for (i = 1, tmp = spd.cas_lat; (i < 3) && ((tmp & 1) == 0); i++) |
| 349 | tmp >>= 1; |
| 350 | psdmr |= i; /* CL */ |
| 351 | |
| 352 | switch (spd.refresh & 0x7F) { |
| 353 | case 1: |
| 354 | tmp = 3900; |
| 355 | break; |
| 356 | case 2: |
| 357 | tmp = 7800; |
| 358 | break; |
| 359 | case 3: |
| 360 | tmp = 31300; |
| 361 | break; |
| 362 | case 4: |
| 363 | tmp = 62500; |
| 364 | break; |
| 365 | case 5: |
| 366 | tmp = 125000; |
| 367 | break; |
| 368 | default: |
| 369 | tmp = 15625; |
| 370 | } |
| 371 | psrt = tmp / (1000000000 / CONFIG_8260_CLKIN * |
| 372 | ((memctl->memc_mptpr >> 8) + 1)) - 1; |
| 373 | #ifdef SPD_DEBUG |
| 374 | printf ("\nDIMM type: %-18.18s\n", spd.mpart); |
| 375 | printf ("SPD size: %d\n", spd.info_size); |
| 376 | printf ("EEPROM size: %d\n", 1 << spd.chip_size); |
| 377 | printf ("Memory type: %d\n", spd.mem_type); |
| 378 | printf ("Row addr: %d\n", spd.nrow_addr); |
| 379 | printf ("Column addr: %d\n", spd.ncol_addr); |
| 380 | printf ("# of rows: %d\n", spd.nrows); |
| 381 | printf ("Row density: %d\n", spd.row_dens); |
| 382 | printf ("# of banks: %d\n", spd.nbanks); |
| 383 | printf ("Data width: %d\n", |
| 384 | 256 * spd.dataw_msb + spd.dataw_lsb); |
| 385 | printf ("Chip width: %d\n", spd.primw); |
| 386 | printf ("Refresh rate: %02X\n", spd.refresh); |
| 387 | printf ("CAS latencies: %02X\n", spd.cas_lat); |
| 388 | printf ("Write latencies: %02X\n", spd.write_lat); |
| 389 | printf ("tRP: %d\n", spd.trp); |
| 390 | printf ("tRCD: %d\n", spd.trcd); |
| 391 | |
| 392 | printf ("OR=%X, PSDMR=%08X, PSRT=%0X\n", or, psdmr, psrt); |
| 393 | #endif /* SPD_DEBUG */ |
| 394 | } |
| 395 | #endif /* CONFIG_SPD_EEPROM */ |
| 396 | memctl->memc_psrt = psrt; |
| 397 | memctl->memc_or2 = or; |
| 398 | memctl->memc_br2 = CFG_SDRAM_BASE | 0x00000041; |
| 399 | ramaddr = (uchar *) CFG_SDRAM_BASE; |
| 400 | memctl->memc_psdmr = psdmr | 0x28000000; /* Precharge all banks */ |
| 401 | *ramaddr = c; |
| 402 | memctl->memc_psdmr = psdmr | 0x08000000; /* CBR refresh */ |
| 403 | for (i = 0; i < 8; i++) |
| 404 | *ramaddr = c; |
| 405 | |
| 406 | memctl->memc_psdmr = psdmr | 0x18000000; /* Mode Register write */ |
| 407 | *ramaddr = c; |
| 408 | memctl->memc_psdmr = psdmr | 0x40000000; /* Refresh enable */ |
| 409 | *ramaddr = c; |
wdenk | 67c4f48 | 2002-08-26 22:23:10 +0000 | [diff] [blame] | 410 | #endif |
| 411 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame^] | 412 | /* return total ram size of DIMM */ |
| 413 | return (msize * 1024 * 1024); |
wdenk | 67c4f48 | 2002-08-26 22:23:10 +0000 | [diff] [blame] | 414 | } |
| 415 | |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame^] | 416 | int checkboard (void) |
wdenk | 67c4f48 | 2002-08-26 22:23:10 +0000 | [diff] [blame] | 417 | { |
wdenk | db2f721f | 2003-03-06 00:58:30 +0000 | [diff] [blame^] | 418 | puts ("Board: Motorola MPC8260ADS\n"); |
| 419 | return 0; |
wdenk | 67c4f48 | 2002-08-26 22:23:10 +0000 | [diff] [blame] | 420 | } |