Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 1 | /* |
| 2 | * Copyright 2007-2009 Freescale Semiconductor, Inc. |
| 3 | * |
| 4 | * See file CREDITS for list of people who contributed to this |
| 5 | * project. |
| 6 | * |
| 7 | * This program is free software; you can redistribute it and/or |
| 8 | * modify it under the terms of the GNU General Public License as |
| 9 | * published by the Free Software Foundation; either version 2 of |
| 10 | * the License, or (at your option) any later version. |
| 11 | * |
| 12 | * This program is distributed in the hope that it will be useful, |
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 | * GNU General Public License for more details. |
| 16 | * |
| 17 | * You should have received a copy of the GNU General Public License |
| 18 | * along with this program; if not, write to the Free Software |
| 19 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, |
| 20 | * MA 02111-1307 USA |
| 21 | */ |
| 22 | |
| 23 | #include <common.h> |
| 24 | #include <command.h> |
| 25 | #include <pci.h> |
| 26 | #include <asm/processor.h> |
| 27 | #include <asm/mmu.h> |
| 28 | #include <asm/cache.h> |
| 29 | #include <asm/immap_85xx.h> |
| 30 | #include <asm/fsl_pci.h> |
| 31 | #include <asm/fsl_ddr_sdram.h> |
| 32 | #include <asm/io.h> |
| 33 | #include <miiphy.h> |
| 34 | #include <libfdt.h> |
| 35 | #include <fdt_support.h> |
| 36 | #include <tsec.h> |
| 37 | #include <asm/fsl_law.h> |
| 38 | #include <asm/mp.h> |
Roy Zang | 29c3518 | 2009-06-30 13:56:23 +0800 | [diff] [blame] | 39 | #include <netdev.h> |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 40 | |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 41 | #include "../common/sgmii_riser.h" |
| 42 | |
| 43 | DECLARE_GLOBAL_DATA_PTR; |
| 44 | |
| 45 | phys_size_t fixed_sdram(void); |
| 46 | |
| 47 | int checkboard(void) |
| 48 | { |
Kumar Gala | 6bb5b41 | 2009-07-14 22:42:01 -0500 | [diff] [blame] | 49 | u8 sw7; |
| 50 | u8 *pixis_base = (u8 *)PIXIS_BASE; |
| 51 | |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 52 | puts("Board: P2020DS "); |
| 53 | #ifdef CONFIG_PHYS_64BIT |
| 54 | puts("(36-bit addrmap) "); |
| 55 | #endif |
Kumar Gala | 6bb5b41 | 2009-07-14 22:42:01 -0500 | [diff] [blame] | 56 | |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 57 | printf("Sys ID: 0x%02x, " |
Kumar Gala | 6bb5b41 | 2009-07-14 22:42:01 -0500 | [diff] [blame] | 58 | "Sys Ver: 0x%02x, FPGA Ver: 0x%02x, ", |
| 59 | in_8(pixis_base + PIXIS_ID), in_8(pixis_base + PIXIS_VER), |
| 60 | in_8(pixis_base + PIXIS_PVER)); |
| 61 | |
| 62 | sw7 = in_8(pixis_base + PIXIS_SW(7)); |
| 63 | switch ((sw7 & PIXIS_SW7_LBMAP) >> 6) { |
| 64 | case 0: |
| 65 | case 1: |
| 66 | printf ("vBank: %d\n", ((sw7 & PIXIS_SW7_VBANK) >> 4)); |
| 67 | break; |
| 68 | case 2: |
| 69 | case 3: |
| 70 | puts ("Promjet\n"); |
| 71 | break; |
| 72 | } |
| 73 | |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 74 | return 0; |
| 75 | } |
| 76 | |
| 77 | phys_size_t initdram(int board_type) |
| 78 | { |
| 79 | phys_size_t dram_size = 0; |
| 80 | |
| 81 | puts("Initializing...."); |
| 82 | |
| 83 | #ifdef CONFIG_SPD_EEPROM |
| 84 | dram_size = fsl_ddr_sdram(); |
| 85 | #else |
| 86 | dram_size = fixed_sdram(); |
| 87 | |
| 88 | if (set_ddr_laws(CONFIG_SYS_DDR_SDRAM_BASE, |
| 89 | dram_size, |
| 90 | LAW_TRGT_IF_DDR) < 0) { |
| 91 | printf("ERROR setting Local Access Windows for DDR\n"); |
| 92 | return 0; |
| 93 | }; |
| 94 | #endif |
| 95 | dram_size = setup_ddr_tlbs(dram_size / 0x100000); |
| 96 | dram_size *= 0x100000; |
| 97 | |
| 98 | puts(" DDR: "); |
| 99 | return dram_size; |
| 100 | } |
| 101 | |
| 102 | #if !defined(CONFIG_SPD_EEPROM) |
| 103 | /* |
| 104 | * Fixed sdram init -- doesn't use serial presence detect. |
| 105 | */ |
| 106 | |
| 107 | phys_size_t fixed_sdram(void) |
| 108 | { |
| 109 | volatile ccsr_ddr_t *ddr = (ccsr_ddr_t *)CONFIG_SYS_MPC85xx_DDR_ADDR; |
| 110 | uint d_init; |
| 111 | |
| 112 | ddr->cs0_config = CONFIG_SYS_DDR_CS0_CONFIG; |
| 113 | ddr->timing_cfg_3 = CONFIG_SYS_DDR_TIMING_3; |
| 114 | ddr->timing_cfg_0 = CONFIG_SYS_DDR_TIMING_0; |
| 115 | ddr->sdram_mode = CONFIG_SYS_DDR_MODE_1; |
| 116 | ddr->sdram_mode_2 = CONFIG_SYS_DDR_MODE_2; |
| 117 | ddr->sdram_md_cntl = CONFIG_SYS_DDR_MODE_CTRL; |
| 118 | ddr->sdram_interval = CONFIG_SYS_DDR_INTERVAL; |
| 119 | ddr->sdram_data_init = CONFIG_SYS_DDR_DATA_INIT; |
| 120 | ddr->sdram_clk_cntl = CONFIG_SYS_DDR_CLK_CTRL; |
| 121 | ddr->sdram_cfg_2 = CONFIG_SYS_DDR_CONTROL2; |
| 122 | ddr->ddr_zq_cntl = CONFIG_SYS_DDR_ZQ_CNTL; |
| 123 | ddr->ddr_wrlvl_cntl = CONFIG_SYS_DDR_WRLVL_CNTL; |
| 124 | ddr->ddr_cdr1 = CONFIG_SYS_DDR_CDR1; |
| 125 | ddr->timing_cfg_4 = CONFIG_SYS_DDR_TIMING_4; |
| 126 | ddr->timing_cfg_5 = CONFIG_SYS_DDR_TIMING_5; |
| 127 | |
| 128 | if (!strcmp("performance", getenv("perf_mode"))) { |
| 129 | /* Performance Mode Values */ |
| 130 | |
| 131 | ddr->cs1_config = CONFIG_SYS_DDR_CS1_CONFIG_PERF; |
| 132 | ddr->cs0_bnds = CONFIG_SYS_DDR_CS0_BNDS_PERF; |
| 133 | ddr->cs1_bnds = CONFIG_SYS_DDR_CS1_BNDS_PERF; |
| 134 | ddr->timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1_PERF; |
| 135 | ddr->timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2_PERF; |
| 136 | |
| 137 | asm("sync;isync"); |
| 138 | |
| 139 | udelay(500); |
| 140 | |
| 141 | ddr->sdram_cfg = CONFIG_SYS_DDR_CONTROL_PERF; |
| 142 | } else { |
| 143 | /* Stable Mode Values */ |
| 144 | |
| 145 | ddr->cs1_config = CONFIG_SYS_DDR_CS1_CONFIG; |
| 146 | ddr->cs0_bnds = CONFIG_SYS_DDR_CS0_BNDS; |
| 147 | ddr->cs1_bnds = CONFIG_SYS_DDR_CS1_BNDS; |
| 148 | ddr->timing_cfg_1 = CONFIG_SYS_DDR_TIMING_1; |
| 149 | ddr->timing_cfg_2 = CONFIG_SYS_DDR_TIMING_2; |
| 150 | |
| 151 | /* ECC will be assumed in stable mode */ |
| 152 | ddr->err_int_en = CONFIG_SYS_DDR_ERR_INT_EN; |
| 153 | ddr->err_disable = CONFIG_SYS_DDR_ERR_DIS; |
| 154 | ddr->err_sbe = CONFIG_SYS_DDR_SBE; |
| 155 | |
| 156 | asm("sync;isync"); |
| 157 | |
| 158 | udelay(500); |
| 159 | |
| 160 | ddr->sdram_cfg = CONFIG_SYS_DDR_CONTROL; |
| 161 | } |
| 162 | |
| 163 | #if defined(CONFIG_ECC_INIT_VIA_DDRCONTROLLER) |
| 164 | d_init = 1; |
| 165 | debug("DDR - 1st controller: memory initializing\n"); |
| 166 | /* |
| 167 | * Poll until memory is initialized. |
| 168 | * 512 Meg at 400 might hit this 200 times or so. |
| 169 | */ |
| 170 | while ((ddr->sdram_cfg_2 & (d_init << 4)) != 0) |
| 171 | udelay(1000); |
| 172 | debug("DDR: memory initialized\n\n"); |
| 173 | asm("sync; isync"); |
| 174 | udelay(500); |
| 175 | #endif |
| 176 | |
| 177 | return CONFIG_SYS_SDRAM_SIZE * 1024 * 1024; |
| 178 | } |
| 179 | |
| 180 | #endif |
| 181 | |
| 182 | #ifdef CONFIG_PCIE1 |
| 183 | static struct pci_controller pcie1_hose; |
| 184 | #endif |
| 185 | |
| 186 | #ifdef CONFIG_PCIE2 |
| 187 | static struct pci_controller pcie2_hose; |
| 188 | #endif |
| 189 | |
| 190 | #ifdef CONFIG_PCIE3 |
| 191 | static struct pci_controller pcie3_hose; |
| 192 | #endif |
| 193 | |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 194 | #ifdef CONFIG_PCI |
| 195 | void pci_init_board(void) |
| 196 | { |
| 197 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
Kumar Gala | 4958af8 | 2009-09-03 09:42:01 -0500 | [diff] [blame] | 198 | struct fsl_pci_info pci_info[3]; |
Kumar Gala | 9263e82 | 2009-11-04 13:01:51 -0600 | [diff] [blame] | 199 | u32 devdisr, pordevsr, io_sel; |
Kumar Gala | 4958af8 | 2009-09-03 09:42:01 -0500 | [diff] [blame] | 200 | int first_free_busno = 0; |
| 201 | int num = 0; |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 202 | |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 203 | int pcie_ep, pcie_configured; |
Kumar Gala | 4958af8 | 2009-09-03 09:42:01 -0500 | [diff] [blame] | 204 | |
| 205 | devdisr = in_be32(&gur->devdisr); |
| 206 | pordevsr = in_be32(&gur->pordevsr); |
| 207 | io_sel = (pordevsr & MPC85xx_PORDEVSR_IO_SEL) >> 19; |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 208 | |
Kumar Gala | 9263e82 | 2009-11-04 13:01:51 -0600 | [diff] [blame] | 209 | debug (" pci_init_board: devdisr=%x, io_sel=%x\n", devdisr, io_sel); |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 210 | |
Kumar Gala | 4958af8 | 2009-09-03 09:42:01 -0500 | [diff] [blame] | 211 | if (!(pordevsr & MPC85xx_PORDEVSR_SGMII2_DIS)) |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 212 | printf(" eTSEC2 is in sgmii mode.\n"); |
Kumar Gala | 4958af8 | 2009-09-03 09:42:01 -0500 | [diff] [blame] | 213 | if (!(pordevsr & MPC85xx_PORDEVSR_SGMII3_DIS)) |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 214 | printf(" eTSEC3 is in sgmii mode.\n"); |
| 215 | |
Kumar Gala | 4958af8 | 2009-09-03 09:42:01 -0500 | [diff] [blame] | 216 | puts("\n"); |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 217 | #ifdef CONFIG_PCIE2 |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 218 | pcie_configured = is_fsl_pci_cfg(LAW_TRGT_IF_PCIE_2, io_sel); |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 219 | |
| 220 | if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE2)) { |
Kumar Gala | 4958af8 | 2009-09-03 09:42:01 -0500 | [diff] [blame] | 221 | SET_STD_PCIE_INFO(pci_info[num], 2); |
Kumar Gala | 9263e82 | 2009-11-04 13:01:51 -0600 | [diff] [blame] | 222 | pcie_ep = fsl_setup_hose(&pcie2_hose, pci_info[num].regs); |
Kumar Gala | 4958af8 | 2009-09-03 09:42:01 -0500 | [diff] [blame] | 223 | printf(" PCIE2 connected to ULI as %s (base addr %lx)\n", |
Peter Tyser | 64917ca | 2010-01-17 15:38:26 -0600 | [diff] [blame] | 224 | pcie_ep ? "Endpoint" : "Root Complex", |
Kumar Gala | 4958af8 | 2009-09-03 09:42:01 -0500 | [diff] [blame] | 225 | pci_info[num].regs); |
| 226 | first_free_busno = fsl_pci_init_port(&pci_info[num++], |
Kumar Gala | 01471d5 | 2009-11-04 01:29:04 -0600 | [diff] [blame] | 227 | &pcie2_hose, first_free_busno); |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 228 | |
| 229 | /* |
| 230 | * The workaround doesn't work on p2020 because the location |
| 231 | * we try and read isn't valid on p2020, fix this later |
| 232 | */ |
| 233 | #if 0 |
| 234 | /* |
| 235 | * Activate ULI1575 legacy chip by performing a fake |
| 236 | * memory access. Needed to make ULI RTC work. |
| 237 | * Device 1d has the first on-board memory BAR. |
| 238 | */ |
| 239 | |
| 240 | pci_hose_read_config_dword(hose, PCI_BDF(2, 0x1d, 0), |
| 241 | PCI_BASE_ADDRESS_1, &temp32); |
| 242 | if (temp32 >= CONFIG_SYS_PCIE3_MEM_BUS) { |
| 243 | void *p = pci_mem_to_virt(PCI_BDF(2, 0x1d, 0), |
| 244 | temp32, 4, 0); |
| 245 | debug(" uli1575 read to %p\n", p); |
| 246 | in_be32(p); |
| 247 | } |
| 248 | #endif |
| 249 | } else { |
| 250 | printf(" PCIE2: disabled\n"); |
| 251 | } |
Kumar Gala | 4958af8 | 2009-09-03 09:42:01 -0500 | [diff] [blame] | 252 | puts("\n"); |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 253 | #else |
Kumar Gala | 4958af8 | 2009-09-03 09:42:01 -0500 | [diff] [blame] | 254 | setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCIE2); /* disable */ |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 255 | #endif |
| 256 | |
| 257 | #ifdef CONFIG_PCIE3 |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 258 | pcie_configured = is_fsl_pci_cfg(LAW_TRGT_IF_PCIE_3, io_sel); |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 259 | |
| 260 | if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE3)) { |
Kumar Gala | 4958af8 | 2009-09-03 09:42:01 -0500 | [diff] [blame] | 261 | SET_STD_PCIE_INFO(pci_info[num], 3); |
Kumar Gala | 9263e82 | 2009-11-04 13:01:51 -0600 | [diff] [blame] | 262 | pcie_ep = fsl_setup_hose(&pcie3_hose, pci_info[num].regs); |
Kumar Gala | 4958af8 | 2009-09-03 09:42:01 -0500 | [diff] [blame] | 263 | printf(" PCIE3 connected to Slot 1 as %s (base addr %lx)\n", |
Peter Tyser | 64917ca | 2010-01-17 15:38:26 -0600 | [diff] [blame] | 264 | pcie_ep ? "Endpoint" : "Root Complex", |
Kumar Gala | 4958af8 | 2009-09-03 09:42:01 -0500 | [diff] [blame] | 265 | pci_info[num].regs); |
| 266 | first_free_busno = fsl_pci_init_port(&pci_info[num++], |
Kumar Gala | 01471d5 | 2009-11-04 01:29:04 -0600 | [diff] [blame] | 267 | &pcie3_hose, first_free_busno); |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 268 | } else { |
| 269 | printf(" PCIE3: disabled\n"); |
| 270 | } |
Kumar Gala | 4958af8 | 2009-09-03 09:42:01 -0500 | [diff] [blame] | 271 | puts("\n"); |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 272 | #else |
Kumar Gala | 4958af8 | 2009-09-03 09:42:01 -0500 | [diff] [blame] | 273 | setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCIE3); /* disable */ |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 274 | #endif |
| 275 | |
| 276 | #ifdef CONFIG_PCIE1 |
Kumar Gala | 3e7b6c1 | 2009-09-02 09:03:08 -0500 | [diff] [blame] | 277 | pcie_configured = is_fsl_pci_cfg(LAW_TRGT_IF_PCIE_1, io_sel); |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 278 | |
| 279 | if (pcie_configured && !(devdisr & MPC85xx_DEVDISR_PCIE)) { |
Kumar Gala | 4958af8 | 2009-09-03 09:42:01 -0500 | [diff] [blame] | 280 | SET_STD_PCIE_INFO(pci_info[num], 1); |
Kumar Gala | 9263e82 | 2009-11-04 13:01:51 -0600 | [diff] [blame] | 281 | pcie_ep = fsl_setup_hose(&pcie1_hose, pci_info[num].regs); |
Kumar Gala | 4958af8 | 2009-09-03 09:42:01 -0500 | [diff] [blame] | 282 | printf(" PCIE1 connected to Slot 2 as %s (base addr %lx)\n", |
Peter Tyser | 64917ca | 2010-01-17 15:38:26 -0600 | [diff] [blame] | 283 | pcie_ep ? "Endpoint" : "Root Complex", |
Kumar Gala | 4958af8 | 2009-09-03 09:42:01 -0500 | [diff] [blame] | 284 | pci_info[num].regs); |
| 285 | first_free_busno = fsl_pci_init_port(&pci_info[num++], |
Kumar Gala | 01471d5 | 2009-11-04 01:29:04 -0600 | [diff] [blame] | 286 | &pcie1_hose, first_free_busno); |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 287 | } else { |
| 288 | printf(" PCIE1: disabled\n"); |
| 289 | } |
Kumar Gala | 4958af8 | 2009-09-03 09:42:01 -0500 | [diff] [blame] | 290 | puts("\n"); |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 291 | #else |
Kumar Gala | 4958af8 | 2009-09-03 09:42:01 -0500 | [diff] [blame] | 292 | setbits_be32(&gur->devdisr, MPC85xx_DEVDISR_PCIE); /* disable */ |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 293 | #endif |
| 294 | } |
| 295 | #endif |
| 296 | |
| 297 | int board_early_init_r(void) |
| 298 | { |
| 299 | const unsigned int flashbase = CONFIG_SYS_FLASH_BASE; |
Kumar Gala | 5fb6ea3 | 2009-11-13 09:25:07 -0600 | [diff] [blame] | 300 | const u8 flash_esel = find_tlb_idx((void *)flashbase, 1); |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 301 | |
| 302 | /* |
| 303 | * Remap Boot flash + PROMJET region to caching-inhibited |
| 304 | * so that flash can be erased properly. |
| 305 | */ |
| 306 | |
| 307 | /* Flush d-cache and invalidate i-cache of any FLASH data */ |
| 308 | flush_dcache(); |
| 309 | invalidate_icache(); |
| 310 | |
| 311 | /* invalidate existing TLB entry for flash + promjet */ |
| 312 | disable_tlb(flash_esel); |
| 313 | |
| 314 | set_tlb(1, flashbase, CONFIG_SYS_FLASH_BASE_PHYS, |
| 315 | MAS3_SX|MAS3_SW|MAS3_SR, MAS2_I|MAS2_G, |
| 316 | 0, flash_esel, BOOKE_PAGESZ_256M, 1); |
| 317 | |
| 318 | return 0; |
| 319 | } |
| 320 | |
| 321 | #ifdef CONFIG_GET_CLK_FROM_ICS307 |
| 322 | /* decode S[0-2] to Output Divider (OD) */ |
| 323 | static unsigned char ics307_S_to_OD[] = { |
| 324 | 10, 2, 8, 4, 5, 7, 3, 6 |
| 325 | }; |
| 326 | |
| 327 | /* Calculate frequency being generated by ICS307-02 clock chip based upon |
| 328 | * the control bytes being programmed into it. */ |
| 329 | /* XXX: This function should probably go into a common library */ |
| 330 | static unsigned long |
| 331 | ics307_clk_freq(unsigned char cw0, unsigned char cw1, unsigned char cw2) |
| 332 | { |
| 333 | const unsigned long InputFrequency = CONFIG_ICS307_REFCLK_HZ; |
| 334 | unsigned long VDW = ((cw1 << 1) & 0x1FE) + ((cw2 >> 7) & 1); |
| 335 | unsigned long RDW = cw2 & 0x7F; |
| 336 | unsigned long OD = ics307_S_to_OD[cw0 & 0x7]; |
| 337 | unsigned long freq; |
| 338 | |
| 339 | /* CLK1Frequency = InputFrequency * 2 * (VDW + 8) / ((RDW + 2) * OD) */ |
| 340 | |
| 341 | /* cw0: C1 C0 TTL F1 F0 S2 S1 S0 |
| 342 | * cw1: V8 V7 V6 V5 V4 V3 V2 V1 |
| 343 | * cw2: V0 R6 R5 R4 R3 R2 R1 R0 |
| 344 | * |
| 345 | * R6:R0 = Reference Divider Word (RDW) |
| 346 | * V8:V0 = VCO Divider Word (VDW) |
| 347 | * S2:S0 = Output Divider Select (OD) |
| 348 | * F1:F0 = Function of CLK2 Output |
| 349 | * TTL = duty cycle |
| 350 | * C1:C0 = internal load capacitance for cyrstal |
| 351 | */ |
| 352 | |
| 353 | /* Adding 1 to get a "nicely" rounded number, but this needs |
| 354 | * more tweaking to get a "properly" rounded number. */ |
| 355 | |
| 356 | freq = 1 + (InputFrequency * 2 * (VDW + 8) / ((RDW + 2) * OD)); |
| 357 | |
| 358 | debug("ICS307: CW[0-2]: %02X %02X %02X => %lu Hz\n", cw0, cw1, cw2, |
| 359 | freq); |
| 360 | return freq; |
| 361 | } |
| 362 | |
| 363 | unsigned long get_board_sys_clk(ulong dummy) |
| 364 | { |
| 365 | return gd->bus_clk; |
| 366 | } |
| 367 | |
| 368 | unsigned long get_board_ddr_clk(ulong dummy) |
| 369 | { |
| 370 | return gd->mem_clk; |
| 371 | } |
| 372 | |
| 373 | unsigned long |
| 374 | calculate_board_sys_clk(ulong dummy) |
| 375 | { |
| 376 | ulong val; |
Kumar Gala | 048e7ef | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 377 | u8 *pixis_base = (u8 *)PIXIS_BASE; |
| 378 | |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 379 | val = ics307_clk_freq( |
Kumar Gala | 048e7ef | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 380 | in_8(pixis_base + PIXIS_VSYSCLK0), |
| 381 | in_8(pixis_base + PIXIS_VSYSCLK1), |
| 382 | in_8(pixis_base + PIXIS_VSYSCLK2)); |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 383 | debug("sysclk val = %lu\n", val); |
| 384 | return val; |
| 385 | } |
| 386 | |
| 387 | unsigned long |
| 388 | calculate_board_ddr_clk(ulong dummy) |
| 389 | { |
| 390 | ulong val; |
Kumar Gala | 048e7ef | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 391 | u8 *pixis_base = (u8 *)PIXIS_BASE; |
| 392 | |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 393 | val = ics307_clk_freq( |
Kumar Gala | 048e7ef | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 394 | in_8(pixis_base + PIXIS_VDDRCLK0), |
| 395 | in_8(pixis_base + PIXIS_VDDRCLK1), |
| 396 | in_8(pixis_base + PIXIS_VDDRCLK2)); |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 397 | debug("ddrclk val = %lu\n", val); |
| 398 | return val; |
| 399 | } |
| 400 | #else |
| 401 | unsigned long get_board_sys_clk(ulong dummy) |
| 402 | { |
| 403 | u8 i; |
| 404 | ulong val = 0; |
Kumar Gala | 048e7ef | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 405 | u8 *pixis_base = (u8 *)PIXIS_BASE; |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 406 | |
Kumar Gala | 048e7ef | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 407 | i = in_8(pixis_base + PIXIS_SPD); |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 408 | i &= 0x07; |
| 409 | |
| 410 | switch (i) { |
| 411 | case 0: |
| 412 | val = 33333333; |
| 413 | break; |
| 414 | case 1: |
| 415 | val = 40000000; |
| 416 | break; |
| 417 | case 2: |
| 418 | val = 50000000; |
| 419 | break; |
| 420 | case 3: |
| 421 | val = 66666666; |
| 422 | break; |
| 423 | case 4: |
| 424 | val = 83333333; |
| 425 | break; |
| 426 | case 5: |
| 427 | val = 100000000; |
| 428 | break; |
| 429 | case 6: |
| 430 | val = 133333333; |
| 431 | break; |
| 432 | case 7: |
| 433 | val = 166666666; |
| 434 | break; |
| 435 | } |
| 436 | |
| 437 | return val; |
| 438 | } |
| 439 | |
| 440 | unsigned long get_board_ddr_clk(ulong dummy) |
| 441 | { |
| 442 | u8 i; |
| 443 | ulong val = 0; |
Kumar Gala | 048e7ef | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 444 | u8 *pixis_base = (u8 *)PIXIS_BASE; |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 445 | |
Kumar Gala | 048e7ef | 2009-07-22 10:12:39 -0500 | [diff] [blame] | 446 | i = in_8(pixis_base + PIXIS_SPD); |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 447 | i &= 0x38; |
| 448 | i >>= 3; |
| 449 | |
| 450 | switch (i) { |
| 451 | case 0: |
| 452 | val = 33333333; |
| 453 | break; |
| 454 | case 1: |
| 455 | val = 40000000; |
| 456 | break; |
| 457 | case 2: |
| 458 | val = 50000000; |
| 459 | break; |
| 460 | case 3: |
| 461 | val = 66666666; |
| 462 | break; |
| 463 | case 4: |
| 464 | val = 83333333; |
| 465 | break; |
| 466 | case 5: |
| 467 | val = 100000000; |
| 468 | break; |
| 469 | case 6: |
| 470 | val = 133333333; |
| 471 | break; |
| 472 | case 7: |
| 473 | val = 166666666; |
| 474 | break; |
| 475 | } |
| 476 | return val; |
| 477 | } |
| 478 | #endif |
| 479 | |
| 480 | #ifdef CONFIG_TSEC_ENET |
| 481 | int board_eth_init(bd_t *bis) |
| 482 | { |
| 483 | struct tsec_info_struct tsec_info[4]; |
| 484 | volatile ccsr_gur_t *gur = (void *)(CONFIG_SYS_MPC85xx_GUTS_ADDR); |
| 485 | int num = 0; |
| 486 | |
| 487 | #ifdef CONFIG_TSEC1 |
| 488 | SET_STD_TSEC_INFO(tsec_info[num], 1); |
| 489 | num++; |
| 490 | #endif |
| 491 | #ifdef CONFIG_TSEC2 |
| 492 | SET_STD_TSEC_INFO(tsec_info[num], 2); |
| 493 | if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII2_DIS)) |
| 494 | tsec_info[num].flags |= TSEC_SGMII; |
| 495 | num++; |
| 496 | #endif |
| 497 | #ifdef CONFIG_TSEC3 |
| 498 | SET_STD_TSEC_INFO(tsec_info[num], 3); |
| 499 | if (!(gur->pordevsr & MPC85xx_PORDEVSR_SGMII3_DIS)) |
| 500 | tsec_info[num].flags |= TSEC_SGMII; |
| 501 | num++; |
| 502 | #endif |
| 503 | |
| 504 | if (!num) { |
| 505 | printf("No TSECs initialized\n"); |
| 506 | |
| 507 | return 0; |
| 508 | } |
| 509 | |
| 510 | #ifdef CONFIG_FSL_SGMII_RISER |
| 511 | fsl_sgmii_riser_init(tsec_info, num); |
| 512 | #endif |
| 513 | |
| 514 | tsec_eth_init(bis, tsec_info, num); |
| 515 | |
Roy Zang | 29c3518 | 2009-06-30 13:56:23 +0800 | [diff] [blame] | 516 | return pci_eth_init(bis); |
Srikanth Srinivasan | feb7838 | 2009-04-03 15:36:13 -0500 | [diff] [blame] | 517 | } |
| 518 | #endif |
| 519 | |
| 520 | #if defined(CONFIG_OF_BOARD_SETUP) |
| 521 | void ft_board_setup(void *blob, bd_t *bd) |
| 522 | { |
| 523 | phys_addr_t base; |
| 524 | phys_size_t size; |
| 525 | |
| 526 | ft_cpu_setup(blob, bd); |
| 527 | |
| 528 | base = getenv_bootm_low(); |
| 529 | size = getenv_bootm_size(); |
| 530 | |
| 531 | fdt_fixup_memory(blob, (u64)base, (u64)size); |
| 532 | |
| 533 | #ifdef CONFIG_PCIE3 |
| 534 | ft_fsl_pci_setup(blob, "pci0", &pcie3_hose); |
| 535 | #endif |
| 536 | #ifdef CONFIG_PCIE2 |
| 537 | ft_fsl_pci_setup(blob, "pci1", &pcie2_hose); |
| 538 | #endif |
| 539 | #ifdef CONFIG_PCIE1 |
| 540 | ft_fsl_pci_setup(blob, "pci2", &pcie1_hose); |
| 541 | #endif |
| 542 | #ifdef CONFIG_FSL_SGMII_RISER |
| 543 | fsl_sgmii_riser_fdt_fixup(blob); |
| 544 | #endif |
| 545 | } |
| 546 | #endif |
| 547 | |
| 548 | #ifdef CONFIG_MP |
| 549 | void board_lmb_reserve(struct lmb *lmb) |
| 550 | { |
| 551 | cpu_mp_lmb_reserve(lmb); |
| 552 | } |
| 553 | #endif |