Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 1 | /* |
Kumar Gala | 6bc9fd5 | 2010-09-30 09:15:03 -0500 | [diff] [blame^] | 2 | * Copyright (C) 2006,2010 Freescale Semiconductor, Inc. |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 3 | * Dave Liu <daveliu@freescale.com> |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 4 | * |
| 5 | * See file CREDITS for list of people who contributed to this |
| 6 | * project. |
| 7 | * |
| 8 | * This program is free software; you can redistribute it and/or |
| 9 | * modify it under the terms of the GNU General Public License as |
| 10 | * published by the Free Software Foundation; either version 2 of |
| 11 | * the License, or (at your option) any later version. |
| 12 | */ |
| 13 | |
| 14 | #include <common.h> |
| 15 | #include <ioports.h> |
| 16 | #include <mpc83xx.h> |
| 17 | #include <i2c.h> |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 18 | #include <miiphy.h> |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 19 | #if defined(CONFIG_PCI) |
| 20 | #include <pci.h> |
| 21 | #endif |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 22 | #include <spd_sdram.h> |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 23 | #include <asm/mmu.h> |
Anton Vorontsov | cbf15d6 | 2009-09-16 23:21:59 +0400 | [diff] [blame] | 24 | #include <asm/io.h> |
Kumar Gala | 6bc9fd5 | 2010-09-30 09:15:03 -0500 | [diff] [blame^] | 25 | #include <asm/fsl_enet.h> |
Kim Phillips | 3204c7c | 2007-12-20 15:57:28 -0600 | [diff] [blame] | 26 | #if defined(CONFIG_OF_LIBFDT) |
Gerald Van Baren | d6abef4 | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 27 | #include <libfdt.h> |
Gerald Van Baren | d6abef4 | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 28 | #endif |
Anton Vorontsov | 8d12923 | 2009-09-16 23:22:08 +0400 | [diff] [blame] | 29 | #include <hwconfig.h> |
| 30 | #include <fdt_support.h> |
Tony Li | c8b57f1 | 2007-08-17 10:35:59 +0800 | [diff] [blame] | 31 | #if defined(CONFIG_PQ_MDS_PIB) |
Kim Phillips | d8ded96 | 2007-08-16 22:53:09 -0500 | [diff] [blame] | 32 | #include "../common/pq-mds-pib.h" |
Tony Li | c8b57f1 | 2007-08-17 10:35:59 +0800 | [diff] [blame] | 33 | #endif |
Anton Vorontsov | cbf15d6 | 2009-09-16 23:21:59 +0400 | [diff] [blame] | 34 | #include "../../../drivers/qe/uec.h" |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 35 | |
Dave Liu | e732e9c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 36 | const qe_iop_conf_t qe_iop_conf_tab[] = { |
| 37 | /* GETH1 */ |
| 38 | {0, 3, 1, 0, 1}, /* TxD0 */ |
| 39 | {0, 4, 1, 0, 1}, /* TxD1 */ |
| 40 | {0, 5, 1, 0, 1}, /* TxD2 */ |
| 41 | {0, 6, 1, 0, 1}, /* TxD3 */ |
| 42 | {1, 6, 1, 0, 3}, /* TxD4 */ |
| 43 | {1, 7, 1, 0, 1}, /* TxD5 */ |
| 44 | {1, 9, 1, 0, 2}, /* TxD6 */ |
| 45 | {1, 10, 1, 0, 2}, /* TxD7 */ |
| 46 | {0, 9, 2, 0, 1}, /* RxD0 */ |
| 47 | {0, 10, 2, 0, 1}, /* RxD1 */ |
| 48 | {0, 11, 2, 0, 1}, /* RxD2 */ |
| 49 | {0, 12, 2, 0, 1}, /* RxD3 */ |
| 50 | {0, 13, 2, 0, 1}, /* RxD4 */ |
| 51 | {1, 1, 2, 0, 2}, /* RxD5 */ |
| 52 | {1, 0, 2, 0, 2}, /* RxD6 */ |
| 53 | {1, 4, 2, 0, 2}, /* RxD7 */ |
| 54 | {0, 7, 1, 0, 1}, /* TX_EN */ |
| 55 | {0, 8, 1, 0, 1}, /* TX_ER */ |
| 56 | {0, 15, 2, 0, 1}, /* RX_DV */ |
| 57 | {0, 16, 2, 0, 1}, /* RX_ER */ |
| 58 | {0, 0, 2, 0, 1}, /* RX_CLK */ |
| 59 | {2, 9, 1, 0, 3}, /* GTX_CLK - CLK10 */ |
| 60 | {2, 8, 2, 0, 1}, /* GTX125 - CLK9 */ |
| 61 | /* GETH2 */ |
| 62 | {0, 17, 1, 0, 1}, /* TxD0 */ |
| 63 | {0, 18, 1, 0, 1}, /* TxD1 */ |
| 64 | {0, 19, 1, 0, 1}, /* TxD2 */ |
| 65 | {0, 20, 1, 0, 1}, /* TxD3 */ |
| 66 | {1, 2, 1, 0, 1}, /* TxD4 */ |
| 67 | {1, 3, 1, 0, 2}, /* TxD5 */ |
| 68 | {1, 5, 1, 0, 3}, /* TxD6 */ |
| 69 | {1, 8, 1, 0, 3}, /* TxD7 */ |
| 70 | {0, 23, 2, 0, 1}, /* RxD0 */ |
| 71 | {0, 24, 2, 0, 1}, /* RxD1 */ |
| 72 | {0, 25, 2, 0, 1}, /* RxD2 */ |
| 73 | {0, 26, 2, 0, 1}, /* RxD3 */ |
| 74 | {0, 27, 2, 0, 1}, /* RxD4 */ |
| 75 | {1, 12, 2, 0, 2}, /* RxD5 */ |
| 76 | {1, 13, 2, 0, 3}, /* RxD6 */ |
| 77 | {1, 11, 2, 0, 2}, /* RxD7 */ |
| 78 | {0, 21, 1, 0, 1}, /* TX_EN */ |
| 79 | {0, 22, 1, 0, 1}, /* TX_ER */ |
| 80 | {0, 29, 2, 0, 1}, /* RX_DV */ |
| 81 | {0, 30, 2, 0, 1}, /* RX_ER */ |
| 82 | {0, 31, 2, 0, 1}, /* RX_CLK */ |
| 83 | {2, 2, 1, 0, 2}, /* GTX_CLK = CLK10 */ |
| 84 | {2, 3, 2, 0, 1}, /* GTX125 - CLK4 */ |
| 85 | |
| 86 | {0, 1, 3, 0, 2}, /* MDIO */ |
| 87 | {0, 2, 1, 0, 1}, /* MDC */ |
| 88 | |
Anton Vorontsov | cbea438 | 2007-11-14 18:54:53 +0300 | [diff] [blame] | 89 | {5, 0, 1, 0, 2}, /* UART2_SOUT */ |
| 90 | {5, 1, 2, 0, 3}, /* UART2_CTS */ |
| 91 | {5, 2, 1, 0, 1}, /* UART2_RTS */ |
| 92 | {5, 3, 2, 0, 2}, /* UART2_SIN */ |
| 93 | |
Dave Liu | e732e9c | 2006-11-03 12:11:15 -0600 | [diff] [blame] | 94 | {0, 0, 0, 0, QE_IOP_TAB_END}, /* END of table */ |
| 95 | }; |
| 96 | |
Anton Vorontsov | cbf15d6 | 2009-09-16 23:21:59 +0400 | [diff] [blame] | 97 | /* Handle "mpc8360ea rev.2.1 erratum 2: RGMII Timing"? */ |
| 98 | static int board_handle_erratum2(void) |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 99 | { |
Anton Vorontsov | cbf15d6 | 2009-09-16 23:21:59 +0400 | [diff] [blame] | 100 | const immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; |
Kim Phillips | 7a1e91b | 2007-02-14 19:50:53 -0600 | [diff] [blame] | 101 | |
Anton Vorontsov | cbf15d6 | 2009-09-16 23:21:59 +0400 | [diff] [blame] | 102 | return REVID_MAJOR(immr->sysconf.spridr) == 2 && |
| 103 | REVID_MINOR(immr->sysconf.spridr) == 1; |
| 104 | } |
| 105 | |
| 106 | int board_early_init_f(void) |
| 107 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 108 | const immap_t *immr = (immap_t *)CONFIG_SYS_IMMR; |
Anton Vorontsov | cbf15d6 | 2009-09-16 23:21:59 +0400 | [diff] [blame] | 109 | u8 *bcsr = (u8 *)CONFIG_SYS_BCSR; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 110 | |
| 111 | /* Enable flash write */ |
| 112 | bcsr[0xa] &= ~0x04; |
| 113 | |
Kim Phillips | ecb2d6f | 2008-03-28 10:19:07 -0500 | [diff] [blame] | 114 | /* Disable G1TXCLK, G2TXCLK h/w buffers (rev.2.x h/w bug workaround) */ |
| 115 | if (REVID_MAJOR(immr->sysconf.spridr) == 2) |
Kim Phillips | 7a1e91b | 2007-02-14 19:50:53 -0600 | [diff] [blame] | 116 | bcsr[0xe] = 0x30; |
| 117 | |
Anton Vorontsov | cbea438 | 2007-11-14 18:54:53 +0300 | [diff] [blame] | 118 | /* Enable second UART */ |
| 119 | bcsr[0x9] &= ~0x01; |
| 120 | |
Anton Vorontsov | cbf15d6 | 2009-09-16 23:21:59 +0400 | [diff] [blame] | 121 | if (board_handle_erratum2()) { |
| 122 | void *immap = (immap_t *)(CONFIG_SYS_IMMR + 0x14a8); |
| 123 | |
| 124 | /* |
| 125 | * IMMR + 0x14A8[4:5] = 11 (clk delay for UCC 2) |
| 126 | * IMMR + 0x14A8[18:19] = 11 (clk delay for UCC 1) |
| 127 | */ |
| 128 | setbits_be32(immap, 0x0c003000); |
| 129 | |
| 130 | /* |
| 131 | * IMMR + 0x14AC[20:27] = 10101010 |
| 132 | * (data delay for both UCC's) |
| 133 | */ |
| 134 | clrsetbits_be32(immap + 4, 0xff0, 0xaa0); |
| 135 | } |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 136 | return 0; |
| 137 | } |
| 138 | |
Tony Li | c8b57f1 | 2007-08-17 10:35:59 +0800 | [diff] [blame] | 139 | int board_early_init_r(void) |
| 140 | { |
| 141 | #ifdef CONFIG_PQ_MDS_PIB |
| 142 | pib_init(); |
| 143 | #endif |
| 144 | return 0; |
| 145 | } |
| 146 | |
Anton Vorontsov | cbf15d6 | 2009-09-16 23:21:59 +0400 | [diff] [blame] | 147 | #ifdef CONFIG_UEC_ETH |
| 148 | static uec_info_t uec_info[] = { |
| 149 | #ifdef CONFIG_UEC_ETH1 |
| 150 | STD_UEC_INFO(1), |
| 151 | #endif |
| 152 | #ifdef CONFIG_UEC_ETH2 |
| 153 | STD_UEC_INFO(2), |
| 154 | #endif |
| 155 | }; |
| 156 | |
| 157 | int board_eth_init(bd_t *bd) |
| 158 | { |
| 159 | if (board_handle_erratum2()) { |
| 160 | int i; |
| 161 | |
| 162 | for (i = 0; i < ARRAY_SIZE(uec_info); i++) |
Heiko Schocher | 40b44bc | 2010-01-20 09:04:28 +0100 | [diff] [blame] | 163 | uec_info[i].enet_interface_type = RGMII_RXID; |
| 164 | uec_info[i].speed = 1000; |
Anton Vorontsov | cbf15d6 | 2009-09-16 23:21:59 +0400 | [diff] [blame] | 165 | } |
| 166 | return uec_eth_init(bd, uec_info, ARRAY_SIZE(uec_info)); |
| 167 | } |
| 168 | #endif /* CONFIG_UEC_ETH */ |
| 169 | |
Peter Tyser | cb4731f | 2009-06-30 17:15:50 -0500 | [diff] [blame] | 170 | #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER) |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 171 | extern void ddr_enable_ecc(unsigned int dram_size); |
| 172 | #endif |
| 173 | int fixed_sdram(void); |
Anton Vorontsov | fa9e297 | 2008-09-10 18:12:37 +0400 | [diff] [blame] | 174 | static int sdram_init(unsigned int base); |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 175 | |
Becky Bruce | bd99ae7 | 2008-06-09 16:03:40 -0500 | [diff] [blame] | 176 | phys_size_t initdram(int board_type) |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 177 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 178 | volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 179 | u32 msize = 0; |
Anton Vorontsov | e71fd2e | 2009-09-16 23:21:57 +0400 | [diff] [blame] | 180 | u32 lbc_sdram_size; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 181 | |
| 182 | if ((im->sysconf.immrbar & IMMRBAR_BASE_ADDR) != (u32) im) |
| 183 | return -1; |
| 184 | |
| 185 | /* DDR SDRAM - Main SODIMM */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 186 | im->sysconf.ddrlaw[0].bar = CONFIG_SYS_DDR_BASE & LAWBAR_BAR; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 187 | #if defined(CONFIG_SPD_EEPROM) |
| 188 | msize = spd_sdram(); |
| 189 | #else |
| 190 | msize = fixed_sdram(); |
| 191 | #endif |
| 192 | |
Peter Tyser | cb4731f | 2009-06-30 17:15:50 -0500 | [diff] [blame] | 193 | #if defined(CONFIG_DDR_ECC) && !defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER) |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 194 | /* |
| 195 | * Initialize DDR ECC byte |
| 196 | */ |
| 197 | ddr_enable_ecc(msize * 1024 * 1024); |
| 198 | #endif |
| 199 | /* |
| 200 | * Initialize SDRAM if it is on local bus. |
| 201 | */ |
Anton Vorontsov | e71fd2e | 2009-09-16 23:21:57 +0400 | [diff] [blame] | 202 | lbc_sdram_size = sdram_init(msize * 1024 * 1024); |
| 203 | if (!msize) |
| 204 | msize = lbc_sdram_size; |
Kim Phillips | 3b9c20f | 2007-08-16 22:52:48 -0500 | [diff] [blame] | 205 | |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 206 | /* return total bus SDRAM size(bytes) -- DDR */ |
| 207 | return (msize * 1024 * 1024); |
| 208 | } |
| 209 | |
| 210 | #if !defined(CONFIG_SPD_EEPROM) |
| 211 | /************************************************************************* |
| 212 | * fixed sdram init -- doesn't use serial presence detect. |
| 213 | ************************************************************************/ |
| 214 | int fixed_sdram(void) |
| 215 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 216 | volatile immap_t *im = (immap_t *) CONFIG_SYS_IMMR; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 217 | u32 msize = 0; |
| 218 | u32 ddr_size; |
| 219 | u32 ddr_size_log2; |
| 220 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 221 | msize = CONFIG_SYS_DDR_SIZE; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 222 | for (ddr_size = msize << 20, ddr_size_log2 = 0; |
| 223 | (ddr_size > 1); ddr_size = ddr_size >> 1, ddr_size_log2++) { |
| 224 | if (ddr_size & 1) { |
| 225 | return -1; |
| 226 | } |
| 227 | } |
| 228 | im->sysconf.ddrlaw[0].ar = |
| 229 | LAWAR_EN | ((ddr_size_log2 - 1) & LAWAR_SIZE); |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 230 | #if (CONFIG_SYS_DDR_SIZE != 256) |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 231 | #warning Currenly any ddr size other than 256 is not supported |
| 232 | #endif |
Xie Xiaobo | 6149a5a | 2007-02-14 18:27:17 +0800 | [diff] [blame] | 233 | #ifdef CONFIG_DDR_II |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 234 | im->ddr.csbnds[0].csbnds = CONFIG_SYS_DDR_CS0_BNDS; |
| 235 | im->ddr.cs_config[0] = CONFIG_SYS_DDR_CS0_CONFIG; |
| 236 | im->ddr.timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0; |
| 237 | im->ddr.timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1; |
| 238 | im->ddr.timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2; |
| 239 | im->ddr.timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3; |
| 240 | im->ddr.sdram_cfg = CONFIG_SYS_DDR_SDRAM_CFG; |
| 241 | im->ddr.sdram_cfg2 = CONFIG_SYS_DDR_SDRAM_CFG2; |
| 242 | im->ddr.sdram_mode = CONFIG_SYS_DDR_MODE; |
| 243 | im->ddr.sdram_mode2 = CONFIG_SYS_DDR_MODE2; |
| 244 | im->ddr.sdram_interval = CONFIG_SYS_DDR_INTERVAL; |
| 245 | im->ddr.sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CNTL; |
Xie Xiaobo | 6149a5a | 2007-02-14 18:27:17 +0800 | [diff] [blame] | 246 | #else |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 247 | im->ddr.csbnds[0].csbnds = 0x00000007; |
| 248 | im->ddr.csbnds[1].csbnds = 0x0008000f; |
| 249 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 250 | im->ddr.cs_config[0] = CONFIG_SYS_DDR_CONFIG; |
| 251 | im->ddr.cs_config[1] = CONFIG_SYS_DDR_CONFIG; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 252 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 253 | im->ddr.timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1; |
| 254 | im->ddr.timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2; |
| 255 | im->ddr.sdram_cfg = CONFIG_SYS_DDR_CONTROL; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 256 | |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 257 | im->ddr.sdram_mode = CONFIG_SYS_DDR_MODE; |
| 258 | im->ddr.sdram_interval = CONFIG_SYS_DDR_INTERVAL; |
Xie Xiaobo | 6149a5a | 2007-02-14 18:27:17 +0800 | [diff] [blame] | 259 | #endif |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 260 | udelay(200); |
| 261 | im->ddr.sdram_cfg |= SDRAM_CFG_MEM_EN; |
| 262 | |
| 263 | return msize; |
| 264 | } |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 265 | #endif /*!CONFIG_SYS_SPD_EEPROM */ |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 266 | |
| 267 | int checkboard(void) |
| 268 | { |
| 269 | puts("Board: Freescale MPC8360EMDS\n"); |
| 270 | return 0; |
| 271 | } |
| 272 | |
| 273 | /* |
| 274 | * if MPC8360EMDS is soldered with SDRAM |
| 275 | */ |
Anton Vorontsov | fa9e297 | 2008-09-10 18:12:37 +0400 | [diff] [blame] | 276 | #ifdef CONFIG_SYS_LB_SDRAM |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 277 | /* |
| 278 | * Initialize SDRAM memory on the Local Bus. |
| 279 | */ |
| 280 | |
Anton Vorontsov | fa9e297 | 2008-09-10 18:12:37 +0400 | [diff] [blame] | 281 | static int sdram_init(unsigned int base) |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 282 | { |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 283 | volatile immap_t *immap = (immap_t *) CONFIG_SYS_IMMR; |
Becky Bruce | 0d4cee1 | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 284 | fsl_lbc_t *lbc = LBC_BASE_ADDR; |
Anton Vorontsov | fa9e297 | 2008-09-10 18:12:37 +0400 | [diff] [blame] | 285 | const int sdram_size = CONFIG_SYS_LBC_SDRAM_SIZE * 1024 * 1024; |
| 286 | int rem = base % sdram_size; |
| 287 | uint *sdram_addr; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 288 | |
Anton Vorontsov | fa9e297 | 2008-09-10 18:12:37 +0400 | [diff] [blame] | 289 | /* window base address should be aligned to the window size */ |
| 290 | if (rem) |
| 291 | base = base - rem + sdram_size; |
| 292 | |
| 293 | sdram_addr = (uint *)base; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 294 | /* |
Anton Vorontsov | fa9e297 | 2008-09-10 18:12:37 +0400 | [diff] [blame] | 295 | * Setup SDRAM Base and Option Registers |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 296 | */ |
Becky Bruce | 0d4cee1 | 2010-06-17 11:37:20 -0500 | [diff] [blame] | 297 | set_lbc_br(2, base | CONFIG_SYS_BR2); |
| 298 | set_lbc_or(2, CONFIG_SYS_OR2); |
Anton Vorontsov | fa9e297 | 2008-09-10 18:12:37 +0400 | [diff] [blame] | 299 | immap->sysconf.lblaw[2].bar = base; |
| 300 | immap->sysconf.lblaw[2].ar = CONFIG_SYS_LBLAWAR2; |
| 301 | |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 302 | /*setup mtrpt, lsrt and lbcr for LB bus */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 303 | lbc->lbcr = CONFIG_SYS_LBC_LBCR; |
| 304 | lbc->mrtpr = CONFIG_SYS_LBC_MRTPR; |
| 305 | lbc->lsrt = CONFIG_SYS_LBC_LSRT; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 306 | asm("sync"); |
| 307 | |
| 308 | /* |
| 309 | * Configure the SDRAM controller Machine Mode Register. |
| 310 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 311 | lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_5; /* Normal Operation */ |
| 312 | lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_1; /* Precharge All Banks */ |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 313 | asm("sync"); |
| 314 | *sdram_addr = 0xff; |
| 315 | udelay(100); |
| 316 | |
| 317 | /* |
| 318 | * We need do 8 times auto refresh operation. |
| 319 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 320 | lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_2; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 321 | asm("sync"); |
| 322 | *sdram_addr = 0xff; /* 1 times */ |
| 323 | udelay(100); |
| 324 | *sdram_addr = 0xff; /* 2 times */ |
| 325 | udelay(100); |
| 326 | *sdram_addr = 0xff; /* 3 times */ |
| 327 | udelay(100); |
| 328 | *sdram_addr = 0xff; /* 4 times */ |
| 329 | udelay(100); |
| 330 | *sdram_addr = 0xff; /* 5 times */ |
| 331 | udelay(100); |
| 332 | *sdram_addr = 0xff; /* 6 times */ |
| 333 | udelay(100); |
| 334 | *sdram_addr = 0xff; /* 7 times */ |
| 335 | udelay(100); |
| 336 | *sdram_addr = 0xff; /* 8 times */ |
| 337 | udelay(100); |
| 338 | |
| 339 | /* Mode register write operation */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 340 | lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_4; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 341 | asm("sync"); |
| 342 | *(sdram_addr + 0xcc) = 0xff; |
| 343 | udelay(100); |
| 344 | |
| 345 | /* Normal operation */ |
Jean-Christophe PLAGNIOL-VILLARD | 0383694 | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 346 | lbc->lsdmr = CONFIG_SYS_LBC_LSDMR_5 | 0x40000000; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 347 | asm("sync"); |
| 348 | *sdram_addr = 0xff; |
| 349 | udelay(100); |
Anton Vorontsov | fa9e297 | 2008-09-10 18:12:37 +0400 | [diff] [blame] | 350 | |
| 351 | /* |
| 352 | * In non-aligned case we don't [normally] use that memory because |
| 353 | * there is a hole. |
| 354 | */ |
| 355 | if (rem) |
| 356 | return 0; |
| 357 | return CONFIG_SYS_LBC_SDRAM_SIZE; |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 358 | } |
| 359 | #else |
Anton Vorontsov | fa9e297 | 2008-09-10 18:12:37 +0400 | [diff] [blame] | 360 | static int sdram_init(unsigned int base) { return 0; } |
Dave Liu | a46daea | 2006-11-03 19:33:44 -0600 | [diff] [blame] | 361 | #endif |
| 362 | |
Kim Phillips | 2141681 | 2007-08-15 22:30:33 -0500 | [diff] [blame] | 363 | #if defined(CONFIG_OF_BOARD_SETUP) |
Anton Vorontsov | 8d12923 | 2009-09-16 23:22:08 +0400 | [diff] [blame] | 364 | static void ft_board_fixup_qe_usb(void *blob, bd_t *bd) |
| 365 | { |
| 366 | if (!hwconfig_subarg_cmp("qe_usb", "mode", "peripheral")) |
| 367 | return; |
| 368 | |
| 369 | do_fixup_by_compat(blob, "fsl,mpc8323-qe-usb", "mode", |
| 370 | "peripheral", sizeof("peripheral"), 1); |
| 371 | } |
| 372 | |
Kim Phillips | 2141681 | 2007-08-15 22:30:33 -0500 | [diff] [blame] | 373 | void ft_board_setup(void *blob, bd_t *bd) |
Kim Phillips | 774e1b5 | 2006-11-01 00:10:40 -0600 | [diff] [blame] | 374 | { |
Kim Phillips | 2141681 | 2007-08-15 22:30:33 -0500 | [diff] [blame] | 375 | ft_cpu_setup(blob, bd); |
Gerald Van Baren | d6abef4 | 2007-03-31 12:23:51 -0400 | [diff] [blame] | 376 | #ifdef CONFIG_PCI |
| 377 | ft_pci_setup(blob, bd); |
| 378 | #endif |
Anton Vorontsov | 8d12923 | 2009-09-16 23:22:08 +0400 | [diff] [blame] | 379 | ft_board_fixup_qe_usb(blob, bd); |
Kim Phillips | 19e2f6f | 2007-11-09 14:28:08 -0600 | [diff] [blame] | 380 | /* |
| 381 | * mpc8360ea pb mds errata 2: RGMII timing |
| 382 | * if on mpc8360ea rev. 2.1, |
| 383 | * change both ucc phy-connection-types from rgmii-id to rgmii-rxid |
| 384 | */ |
Anton Vorontsov | cbf15d6 | 2009-09-16 23:21:59 +0400 | [diff] [blame] | 385 | if (board_handle_erratum2()) { |
Kim Phillips | 19e2f6f | 2007-11-09 14:28:08 -0600 | [diff] [blame] | 386 | int nodeoffset; |
Kim Phillips | cccb19c | 2007-12-10 14:16:22 -0600 | [diff] [blame] | 387 | const char *prop; |
Kim Phillips | cc87fd1 | 2008-01-15 09:51:12 -0600 | [diff] [blame] | 388 | int path; |
Kim Phillips | 19e2f6f | 2007-11-09 14:28:08 -0600 | [diff] [blame] | 389 | |
Kim Phillips | 03c45da | 2008-01-14 16:14:46 -0600 | [diff] [blame] | 390 | nodeoffset = fdt_path_offset(blob, "/aliases"); |
Kim Phillips | 19e2f6f | 2007-11-09 14:28:08 -0600 | [diff] [blame] | 391 | if (nodeoffset >= 0) { |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 392 | #if defined(CONFIG_HAS_ETH0) |
| 393 | /* fixup UCC 1 if using rgmii-id mode */ |
Kim Phillips | cc87fd1 | 2008-01-15 09:51:12 -0600 | [diff] [blame] | 394 | prop = fdt_getprop(blob, nodeoffset, "ethernet0", NULL); |
| 395 | if (prop) { |
| 396 | path = fdt_path_offset(blob, prop); |
Kim Phillips | 03c45da | 2008-01-14 16:14:46 -0600 | [diff] [blame] | 397 | prop = fdt_getprop(blob, path, |
| 398 | "phy-connection-type", 0); |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 399 | if (prop && (strcmp(prop, "rgmii-id") == 0)) |
Kumar Gala | 6bc9fd5 | 2010-09-30 09:15:03 -0500 | [diff] [blame^] | 400 | fdt_fixup_phy_connection(blob, path, |
| 401 | RGMII_RXID); |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 402 | } |
| 403 | #endif |
| 404 | #if defined(CONFIG_HAS_ETH1) |
| 405 | /* fixup UCC 2 if using rgmii-id mode */ |
Kim Phillips | cc87fd1 | 2008-01-15 09:51:12 -0600 | [diff] [blame] | 406 | prop = fdt_getprop(blob, nodeoffset, "ethernet1", NULL); |
| 407 | if (prop) { |
| 408 | path = fdt_path_offset(blob, prop); |
Kim Phillips | 03c45da | 2008-01-14 16:14:46 -0600 | [diff] [blame] | 409 | prop = fdt_getprop(blob, path, |
| 410 | "phy-connection-type", 0); |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 411 | if (prop && (strcmp(prop, "rgmii-id") == 0)) |
Kumar Gala | 6bc9fd5 | 2010-09-30 09:15:03 -0500 | [diff] [blame^] | 412 | fdt_fixup_phy_connection(blob, path, |
| 413 | RGMII_RXID); |
Kim Phillips | fd47a74 | 2007-12-20 14:09:22 -0600 | [diff] [blame] | 414 | } |
| 415 | #endif |
Kim Phillips | 19e2f6f | 2007-11-09 14:28:08 -0600 | [diff] [blame] | 416 | } |
| 417 | } |
Kim Phillips | 774e1b5 | 2006-11-01 00:10:40 -0600 | [diff] [blame] | 418 | } |
Kim Phillips | 2141681 | 2007-08-15 22:30:33 -0500 | [diff] [blame] | 419 | #endif |