roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 1 | /***************************************************************************** |
| 2 | * (C) Copyright 2003; Tundra Semiconductor Corp. |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 3 | * |
Wolfgang Denk | 1a45966 | 2013-07-08 09:37:19 +0200 | [diff] [blame] | 4 | * SPDX-License-Identifier: GPL-2.0+ |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 5 | *****************************************************************************/ |
| 6 | |
| 7 | /*---------------------------------------------------------------------------- |
| 8 | * FILENAME: tsi108_init.c |
| 9 | * |
| 10 | * Originator: Alex Bounine |
| 11 | * |
| 12 | * DESCRIPTION: |
| 13 | * Initialization code for the Tundra Tsi108 bridge chip |
| 14 | *---------------------------------------------------------------------------*/ |
| 15 | |
| 16 | #include <common.h> |
| 17 | #include <74xx_7xx.h> |
| 18 | #include <config.h> |
| 19 | #include <version.h> |
| 20 | #include <asm/processor.h> |
| 21 | #include <tsi108.h> |
| 22 | |
Wolfgang Denk | 1218abf | 2007-09-15 20:48:41 +0200 | [diff] [blame] | 23 | DECLARE_GLOBAL_DATA_PTR; |
| 24 | |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 25 | extern void mpicInit (int verbose); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 26 | |
| 27 | /* |
| 28 | * Configuration Options |
| 29 | */ |
| 30 | |
| 31 | typedef struct { |
| 32 | ulong upper; |
| 33 | ulong lower; |
| 34 | } PB2OCN_LUT_ENTRY; |
| 35 | |
| 36 | PB2OCN_LUT_ENTRY pb2ocn_lut1[32] = { |
| 37 | /* 0 - 7 */ |
| 38 | {0x00000000, 0x00000201}, /* PBA=0xE000_0000 -> PCI/X (Byte-Swap) */ |
| 39 | {0x00000000, 0x00000201}, /* PBA=0xE100_0000 -> PCI/X (Byte-Swap) */ |
| 40 | {0x00000000, 0x00000201}, /* PBA=0xE200_0000 -> PCI/X (Byte-Swap) */ |
| 41 | {0x00000000, 0x00000201}, /* PBA=0xE300_0000 -> PCI/X (Byte-Swap) */ |
| 42 | {0x00000000, 0x00000201}, /* PBA=0xE400_0000 -> PCI/X (Byte-Swap) */ |
| 43 | {0x00000000, 0x00000201}, /* PBA=0xE500_0000 -> PCI/X (Byte-Swap) */ |
| 44 | {0x00000000, 0x00000201}, /* PBA=0xE600_0000 -> PCI/X (Byte-Swap) */ |
| 45 | {0x00000000, 0x00000201}, /* PBA=0xE700_0000 -> PCI/X (Byte-Swap) */ |
| 46 | |
| 47 | /* 8 - 15 */ |
| 48 | {0x00000000, 0x00000201}, /* PBA=0xE800_0000 -> PCI/X (Byte-Swap) */ |
| 49 | {0x00000000, 0x00000201}, /* PBA=0xE900_0000 -> PCI/X (Byte-Swap) */ |
| 50 | {0x00000000, 0x00000201}, /* PBA=0xEA00_0000 -> PCI/X (Byte-Swap) */ |
| 51 | {0x00000000, 0x00000201}, /* PBA=0xEB00_0000 -> PCI/X (Byte-Swap) */ |
| 52 | {0x00000000, 0x00000201}, /* PBA=0xEC00_0000 -> PCI/X (Byte-Swap) */ |
| 53 | {0x00000000, 0x00000201}, /* PBA=0xED00_0000 -> PCI/X (Byte-Swap) */ |
| 54 | {0x00000000, 0x00000201}, /* PBA=0xEE00_0000 -> PCI/X (Byte-Swap) */ |
| 55 | {0x00000000, 0x00000201}, /* PBA=0xEF00_0000 -> PCI/X (Byte-Swap) */ |
| 56 | |
| 57 | /* 16 - 23 */ |
| 58 | {0x00000000, 0x00000201}, /* PBA=0xF000_0000 -> PCI/X (Byte-Swap) */ |
| 59 | {0x00000000, 0x00000201}, /* PBA=0xF100_0000 -> PCI/X (Byte-Swap) */ |
| 60 | {0x00000000, 0x00000201}, /* PBA=0xF200_0000 -> PCI/X (Byte-Swap) */ |
| 61 | {0x00000000, 0x00000201}, /* PBA=0xF300_0000 -> PCI/X (Byte-Swap) */ |
| 62 | {0x00000000, 0x00000201}, /* PBA=0xF400_0000 -> PCI/X (Byte-Swap) */ |
| 63 | {0x00000000, 0x00000201}, /* PBA=0xF500_0000 -> PCI/X (Byte-Swap) */ |
| 64 | {0x00000000, 0x00000201}, /* PBA=0xF600_0000 -> PCI/X (Byte-Swap) */ |
| 65 | {0x00000000, 0x00000201}, /* PBA=0xF700_0000 -> PCI/X (Byte-Swap) */ |
| 66 | /* 24 - 31 */ |
| 67 | {0x00000000, 0x00000201}, /* PBA=0xF800_0000 -> PCI/X (Byte-Swap) */ |
| 68 | {0x00000000, 0x00000201}, /* PBA=0xF900_0000 -> PCI/X (Byte-Swap) */ |
Randy Vinson | 20220d2 | 2008-08-13 11:44:57 -0700 | [diff] [blame] | 69 | {0x00000000, 0x00000241}, /* PBA=0xFA00_0000 -> PCI/X PCI I/O (Byte-Swap + Translate) */ |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 70 | {0x00000000, 0x00000201}, /* PBA=0xFB00_0000 -> PCI/X PCI Config (Byte-Swap) */ |
| 71 | |
| 72 | {0x00000000, 0x02000240}, /* PBA=0xFC00_0000 -> HLP */ |
| 73 | {0x00000000, 0x01000240}, /* PBA=0xFD00_0000 -> HLP */ |
| 74 | {0x00000000, 0x03000240}, /* PBA=0xFE00_0000 -> HLP */ |
| 75 | {0x00000000, 0x00000240} /* PBA=0xFF00_0000 -> HLP : (Translation Enabled + Byte-Swap)*/ |
| 76 | }; |
| 77 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 78 | #ifdef CONFIG_SYS_CLK_SPREAD |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 79 | typedef struct { |
| 80 | ulong ctrl0; |
| 81 | ulong ctrl1; |
| 82 | } PLL_CTRL_SET; |
| 83 | |
| 84 | /* |
| 85 | * Clock Generator SPLL0 initialization values |
| 86 | * PLL0 configuration table for various PB_CLKO freq. |
| 87 | * Uses pre-calculated values for Fs = 30 kHz, D = 0.5% |
| 88 | * Fout depends on required PB_CLKO. Based on Fref = 33 MHz |
| 89 | */ |
| 90 | |
| 91 | static PLL_CTRL_SET pll0_config[8] = { |
| 92 | {0x00000000, 0x00000000}, /* 0: bypass */ |
| 93 | {0x00000000, 0x00000000}, /* 1: reserved */ |
| 94 | {0x00430044, 0x00000043}, /* 2: CG_PB_CLKO = 183 MHz */ |
| 95 | {0x005c0044, 0x00000039}, /* 3: CG_PB_CLKO = 100 MHz */ |
| 96 | {0x005c0044, 0x00000039}, /* 4: CG_PB_CLKO = 133 MHz */ |
| 97 | {0x004a0044, 0x00000040}, /* 5: CG_PB_CLKO = 167 MHz */ |
| 98 | {0x005c0044, 0x00000039}, /* 6: CG_PB_CLKO = 200 MHz */ |
| 99 | {0x004f0044, 0x0000003e} /* 7: CG_PB_CLKO = 233 MHz */ |
| 100 | }; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 101 | #endif /* CONFIG_SYS_CLK_SPREAD */ |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 102 | |
| 103 | /* |
| 104 | * Prosessor Bus Clock (in MHz) defined by CG_PB_SELECT |
| 105 | * (based on recommended Tsi108 reference clock 33MHz) |
| 106 | */ |
| 107 | static int pb_clk_sel[8] = { 0, 0, 183, 100, 133, 167, 200, 233 }; |
| 108 | |
| 109 | /* |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 110 | * get_board_bus_clk () |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 111 | * |
| 112 | * returns the bus clock in Hz. |
| 113 | */ |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 114 | unsigned long get_board_bus_clk (void) |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 115 | { |
| 116 | ulong i; |
| 117 | |
| 118 | /* Detect PB clock freq. */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 119 | i = in32(CONFIG_SYS_TSI108_CSR_BASE + TSI108_CLK_REG_OFFSET + CG_PWRUP_STATUS); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 120 | i = (i >> 16) & 0x07; /* Get PB PLL multiplier */ |
| 121 | |
| 122 | return pb_clk_sel[i] * 1000000; |
| 123 | } |
| 124 | |
| 125 | /* |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 126 | * board_early_init_f () |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 127 | * |
| 128 | * board-specific initialization executed from flash |
| 129 | */ |
| 130 | |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 131 | int board_early_init_f (void) |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 132 | { |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 133 | ulong i; |
| 134 | |
| 135 | gd->mem_clk = 0; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 136 | i = in32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_CLK_REG_OFFSET + |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 137 | CG_PWRUP_STATUS); |
roy zang | 9d27b3a | 2006-12-04 17:56:59 +0800 | [diff] [blame] | 138 | i = (i >> 20) & 0x07; /* Get GD PLL multiplier */ |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 139 | switch (i) { |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 140 | case 0: /* external clock */ |
| 141 | printf ("Using external clock\n"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 142 | break; |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 143 | case 1: /* system clock */ |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 144 | gd->mem_clk = gd->bus_clk; |
| 145 | break; |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 146 | case 4: /* 133 MHz */ |
| 147 | case 5: /* 166 MHz */ |
| 148 | case 6: /* 200 MHz */ |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 149 | gd->mem_clk = pb_clk_sel[i] * 1000000; |
| 150 | break; |
| 151 | default: |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 152 | printf ("Invalid DDR2 clock setting\n"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 153 | return -1; |
| 154 | } |
Wolfgang Denk | bde6358 | 2008-07-11 22:56:11 +0200 | [diff] [blame] | 155 | printf ("BUS: %lu MHz\n", get_board_bus_clk() / 1000000); |
| 156 | printf ("MEM: %lu MHz\n", gd->mem_clk / 1000000); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 157 | return 0; |
| 158 | } |
| 159 | |
| 160 | /* |
| 161 | * board_early_init_r() - Tsi108 initialization function executed right after |
| 162 | * relocation. Contains code that cannot be executed from flash. |
| 163 | */ |
| 164 | |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 165 | int board_early_init_r (void) |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 166 | { |
| 167 | ulong temp, i; |
| 168 | ulong reg_val; |
| 169 | volatile ulong *reg_ptr; |
Wolfgang Denk | 647d3c3 | 2007-03-04 01:36:05 +0100 | [diff] [blame] | 170 | |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 171 | reg_ptr = |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 172 | (ulong *) (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PB_REG_OFFSET + 0x900); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 173 | |
| 174 | for (i = 0; i < 32; i++) { |
| 175 | *reg_ptr++ = 0x00000201; /* SWAP ENABLED */ |
| 176 | *reg_ptr++ = 0x00; |
| 177 | } |
| 178 | |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 179 | __asm__ __volatile__ ("eieio"); |
| 180 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 181 | |
| 182 | /* Setup PB_OCN_BAR2: size 256B + ENable @ 0x0_80000000 */ |
| 183 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 184 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PB_REG_OFFSET + PB_OCN_BAR2, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 185 | 0x80000001); |
| 186 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 187 | |
| 188 | /* Make sure that OCN_BAR2 decoder is set (to allow following immediate |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 189 | * read from SDRAM) |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 190 | */ |
| 191 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 192 | temp = in32(CONFIG_SYS_TSI108_CSR_BASE + TSI108_PB_REG_OFFSET + PB_OCN_BAR2); |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 193 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 194 | |
| 195 | /* |
| 196 | * Remap PB_OCN_BAR1 to accomodate PCI-bus aperture and EPROM into the |
| 197 | * processor bus address space. Immediately after reset LUT and address |
| 198 | * translation are disabled for this BAR. Now we have to initialize LUT |
| 199 | * and switch from the BOOT mode to the normal operation mode. |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 200 | * |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 201 | * The aperture defined by PB_OCN_BAR1 startes at address 0xE0000000 |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 202 | * and covers 512MB of address space. To allow larger aperture we also |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 203 | * have to relocate register window of Tsi108 |
| 204 | * |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 205 | * Initialize LUT (32-entries) prior switching PB_OCN_BAR1 from BOOT |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 206 | * mode. |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 207 | * |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 208 | * initialize pointer to LUT associated with PB_OCN_BAR1 |
| 209 | */ |
| 210 | reg_ptr = |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 211 | (ulong *) (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PB_REG_OFFSET + 0x800); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 212 | |
| 213 | for (i = 0; i < 32; i++) { |
| 214 | *reg_ptr++ = pb2ocn_lut1[i].lower; |
| 215 | *reg_ptr++ = pb2ocn_lut1[i].upper; |
| 216 | } |
| 217 | |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 218 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 219 | |
roy zang | 9d27b3a | 2006-12-04 17:56:59 +0800 | [diff] [blame] | 220 | /* Base addresses for CS0, CS1, CS2, CS3 */ |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 221 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 222 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B0_ADDR, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 223 | 0x00000000); |
| 224 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 225 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 226 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B1_ADDR, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 227 | 0x00100000); |
| 228 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 229 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 230 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B2_ADDR, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 231 | 0x00200000); |
| 232 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 233 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 234 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B3_ADDR, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 235 | 0x00300000); |
| 236 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 237 | |
| 238 | /* Masks for HLP banks */ |
| 239 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 240 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B0_MASK, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 241 | 0xFFF00000); |
| 242 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 243 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 244 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B1_MASK, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 245 | 0xFFF00000); |
| 246 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 247 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 248 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B2_MASK, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 249 | 0xFFF00000); |
| 250 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 251 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 252 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B3_MASK, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 253 | 0xFFF00000); |
| 254 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 255 | |
| 256 | /* Set CTRL0 values for banks */ |
| 257 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 258 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B0_CTRL0, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 259 | 0x7FFC44C2); |
| 260 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 261 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 262 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B1_CTRL0, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 263 | 0x7FFC44C0); |
| 264 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 265 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 266 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B2_CTRL0, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 267 | 0x7FFC44C0); |
| 268 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 269 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 270 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B3_CTRL0, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 271 | 0x7FFC44C2); |
| 272 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 273 | |
| 274 | /* Set banks to latched mode, enabled, and other default settings */ |
| 275 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 276 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B0_CTRL1, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 277 | 0x7C0F2000); |
| 278 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 279 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 280 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B1_CTRL1, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 281 | 0x7C0F2000); |
| 282 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 283 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 284 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B2_CTRL1, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 285 | 0x7C0F2000); |
| 286 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 287 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 288 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_HLP_REG_OFFSET + HLP_B3_CTRL1, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 289 | 0x7C0F2000); |
| 290 | __asm__ __volatile__ ("sync"); |
Wolfgang Denk | 647d3c3 | 2007-03-04 01:36:05 +0100 | [diff] [blame] | 291 | |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 292 | /* |
| 293 | * Set new value for PB_OCN_BAR1: switch from BOOT to LUT mode. |
| 294 | * value for PB_OCN_BAR1: (BA-0xE000_0000 + size 512MB + ENable) |
| 295 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 296 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PB_REG_OFFSET + PB_OCN_BAR1, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 297 | 0xE0000011); |
| 298 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 299 | |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 300 | /* Make sure that OCN_BAR2 decoder is set (to allow following |
| 301 | * immediate read from SDRAM) |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 302 | */ |
Wolfgang Denk | 647d3c3 | 2007-03-04 01:36:05 +0100 | [diff] [blame] | 303 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 304 | temp = in32(CONFIG_SYS_TSI108_CSR_BASE + TSI108_PB_REG_OFFSET + PB_OCN_BAR1); |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 305 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 306 | |
| 307 | /* |
| 308 | * SRI: At this point we have enabled the HLP banks. That means we can |
| 309 | * now read from the NVRAM and initialize the environment variables. |
| 310 | * We will over-ride the env_init called in board_init_f |
| 311 | * This is really a work-around because, the HLP bank 1 |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 312 | * where NVRAM resides is not visible during board_init_f |
Stefan Roese | a47a12b | 2010-04-15 16:07:28 +0200 | [diff] [blame] | 313 | * (arch/powerpc/lib/board.c) |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 314 | * Alternatively, we could use the I2C EEPROM at start-up to configure |
| 315 | * and enable all HLP banks and not just HLP 0 as is being done for |
| 316 | * Taiga Rev. 2. |
| 317 | */ |
Wolfgang Denk | 647d3c3 | 2007-03-04 01:36:05 +0100 | [diff] [blame] | 318 | |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 319 | env_init (); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 320 | |
| 321 | #ifndef DISABLE_PBM |
Wolfgang Denk | 647d3c3 | 2007-03-04 01:36:05 +0100 | [diff] [blame] | 322 | |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 323 | /* |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 324 | * For IBM processors we have to set Address-Only commands generated |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 325 | * by PBM that are different from ones set after reset. |
| 326 | */ |
| 327 | |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 328 | temp = get_cpu_type (); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 329 | |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 330 | if ((CPU_750FX == temp) || (CPU_750GX == temp)) |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 331 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PB_REG_OFFSET + PB_MCMD, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 332 | 0x00009955); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 333 | #endif /* DISABLE_PBM */ |
| 334 | |
| 335 | #ifdef CONFIG_PCI |
| 336 | /* |
| 337 | * Initialize PCI/X block |
| 338 | */ |
| 339 | |
| 340 | /* Map PCI/X Configuration Space (16MB @ 0x0_FE000000) */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 341 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 342 | PCI_PFAB_BAR0_UPPER, 0); |
| 343 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 344 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 345 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_PFAB_BAR0, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 346 | 0xFB000001); |
| 347 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 348 | |
| 349 | /* Set Bus Number for the attached PCI/X bus (we will use 0 for NB) */ |
| 350 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 351 | temp = in32(CONFIG_SYS_TSI108_CSR_BASE + |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 352 | TSI108_PCI_REG_OFFSET + PCI_PCIX_STAT); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 353 | |
| 354 | temp &= ~0xFF00; /* Clear the BUS_NUM field */ |
| 355 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 356 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_PCIX_STAT, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 357 | temp); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 358 | |
| 359 | /* Map PCI/X IO Space (64KB @ 0x0_FD000000) takes one 16MB LUT entry */ |
| 360 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 361 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_PFAB_IO_UPPER, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 362 | 0); |
| 363 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 364 | |
| 365 | /* This register is on the PCI side to interpret the address it receives |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 366 | * and maps it as a IO address. |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 367 | */ |
| 368 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 369 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_PFAB_IO, |
Randy Vinson | 20220d2 | 2008-08-13 11:44:57 -0700 | [diff] [blame] | 370 | 0x00000001); |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 371 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 372 | |
| 373 | /* |
| 374 | * Map PCI/X Memory Space |
| 375 | * |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 376 | * Transactions directed from OCM to PCI Memory Space are directed |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 377 | * from PB to PCI |
| 378 | * unchanged (as defined by PB_OCN_BAR1,2 and LUT settings). |
| 379 | * If address remapping is required the corresponding PCI_PFAB_MEM32 |
| 380 | * and PCI_PFAB_PFMx register groups have to be configured. |
| 381 | * |
| 382 | * Map the path from the PCI/X bus into the system memory |
| 383 | * |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 384 | * The memory mapped window assotiated with PCI P2O_BAR2 provides |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 385 | * access to the system memory without address remapping. |
| 386 | * All system memory is opened for accesses initiated by PCI/X bus |
| 387 | * masters. |
| 388 | * |
| 389 | * Initialize LUT associated with PCI P2O_BAR2 |
| 390 | * |
| 391 | * set pointer to LUT associated with PCI P2O_BAR2 |
| 392 | */ |
| 393 | |
| 394 | reg_ptr = |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 395 | (ulong *) (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + 0x500); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 396 | |
| 397 | #ifdef DISABLE_PBM |
| 398 | |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 399 | /* In case when PBM is disabled (no HW supported cache snoopng on PB) |
| 400 | * P2O_BAR2 is directly mapped into the system memory without address |
| 401 | * translation. |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 402 | */ |
| 403 | |
| 404 | reg_val = 0x00000004; /* SDRAM port + NO Addr_Translation */ |
| 405 | |
| 406 | for (i = 0; i < 32; i++) { |
| 407 | *reg_ptr++ = reg_val; /* P2O_BAR2_LUTx */ |
| 408 | *reg_ptr++ = 0; /* P2O_BAR2_LUT_UPPERx */ |
| 409 | } |
| 410 | |
| 411 | /* value for PCI BAR2 (size = 512MB, Enabled, No Addr. Translation) */ |
| 412 | reg_val = 0x00007500; |
| 413 | #else |
| 414 | |
| 415 | reg_val = 0x00000002; /* Destination port = PBM */ |
| 416 | |
| 417 | for (i = 0; i < 32; i++) { |
| 418 | *reg_ptr++ = reg_val; /* P2O_BAR2_LUTx */ |
| 419 | /* P2O_BAR2_LUT_UPPERx : Set data swapping mode for PBM (byte swapping) */ |
| 420 | *reg_ptr++ = 0x40000000; |
| 421 | /* offset = 16MB, address translation is enabled to allow byte swapping */ |
| 422 | reg_val += 0x01000000; |
| 423 | } |
| 424 | |
| 425 | /* value for PCI BAR2 (size = 512MB, Enabled, Address Translation Enabled) */ |
| 426 | reg_val = 0x00007100; |
| 427 | #endif |
| 428 | |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 429 | __asm__ __volatile__ ("eieio"); |
| 430 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 431 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 432 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_P2O_PAGE_SIZES, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 433 | reg_val); |
| 434 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 435 | |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 436 | /* Set 64-bit PCI bus address for system memory |
| 437 | * ( 0 is the best choice for easy mapping) |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 438 | */ |
| 439 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 440 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_P2O_BAR2, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 441 | 0x00000000); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 442 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_P2O_BAR2_UPPER, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 443 | 0x00000000); |
| 444 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 445 | |
| 446 | #ifndef DISABLE_PBM |
| 447 | /* |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 448 | * The memory mapped window assotiated with PCI P2O_BAR3 provides |
| 449 | * access to the system memory using SDRAM OCN port and address |
| 450 | * translation. This is alternative way to access SDRAM from PCI |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 451 | * required for Tsi108 emulation testing. |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 452 | * All system memory is opened for accesses initiated by |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 453 | * PCI/X bus masters. |
| 454 | * |
| 455 | * Initialize LUT associated with PCI P2O_BAR3 |
| 456 | * |
| 457 | * set pointer to LUT associated with PCI P2O_BAR3 |
| 458 | */ |
| 459 | reg_ptr = |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 460 | (ulong *) (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + 0x600); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 461 | |
| 462 | reg_val = 0x00000004; /* Destination port = SDC */ |
| 463 | |
| 464 | for (i = 0; i < 32; i++) { |
| 465 | *reg_ptr++ = reg_val; /* P2O_BAR3_LUTx */ |
Wolfgang Denk | 647d3c3 | 2007-03-04 01:36:05 +0100 | [diff] [blame] | 466 | |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 467 | /* P2O_BAR3_LUT_UPPERx : Set data swapping mode for PBM (byte swapping) */ |
Wolfgang Denk | 647d3c3 | 2007-03-04 01:36:05 +0100 | [diff] [blame] | 468 | *reg_ptr++ = 0; |
| 469 | |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 470 | /* offset = 16MB, address translation is enabled to allow byte swapping */ |
| 471 | reg_val += 0x01000000; |
| 472 | } |
| 473 | |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 474 | __asm__ __volatile__ ("eieio"); |
| 475 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 476 | |
| 477 | /* Configure PCI P2O_BAR3 (size = 512MB, Enabled) */ |
| 478 | |
| 479 | reg_val = |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 480 | in32(CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 481 | PCI_P2O_PAGE_SIZES); |
| 482 | reg_val &= ~0x00FF; |
| 483 | reg_val |= 0x0071; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 484 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_P2O_PAGE_SIZES, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 485 | reg_val); |
| 486 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 487 | |
| 488 | /* Set 64-bit base PCI bus address for window (0x20000000) */ |
| 489 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 490 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_P2O_BAR3_UPPER, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 491 | 0x00000000); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 492 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_P2O_BAR3, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 493 | 0x20000000); |
| 494 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 495 | |
| 496 | #endif /* !DISABLE_PBM */ |
| 497 | |
Wolfgang Denk | 647d3c3 | 2007-03-04 01:36:05 +0100 | [diff] [blame] | 498 | #ifdef ENABLE_PCI_CSR_BAR |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 499 | /* open if required access to Tsi108 CSRs from the PCI/X bus */ |
| 500 | /* enable BAR0 on the PCI/X bus */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 501 | reg_val = in32(CONFIG_SYS_TSI108_CSR_BASE + |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 502 | TSI108_PCI_REG_OFFSET + PCI_MISC_CSR); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 503 | reg_val |= 0x02; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 504 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_MISC_CSR, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 505 | reg_val); |
| 506 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 507 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 508 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_P2O_BAR0_UPPER, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 509 | 0x00000000); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 510 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_P2O_BAR0, |
| 511 | CONFIG_SYS_TSI108_CSR_BASE); |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 512 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 513 | |
| 514 | #endif |
| 515 | |
| 516 | /* |
| 517 | * Finally enable PCI/X Bus Master and Memory Space access |
| 518 | */ |
Wolfgang Denk | 647d3c3 | 2007-03-04 01:36:05 +0100 | [diff] [blame] | 519 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 520 | reg_val = in32(CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_CSR); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 521 | reg_val |= 0x06; |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 522 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_PCI_REG_OFFSET + PCI_CSR, reg_val); |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 523 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 524 | |
| 525 | #endif /* CONFIG_PCI */ |
| 526 | |
| 527 | /* |
| 528 | * Initialize MPIC outputs (interrupt pins): |
| 529 | * Interrupt routing on the Grendel Emul. Board: |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 530 | * PB_INT[0] -> INT (CPU0) |
| 531 | * PB_INT[1] -> INT (CPU1) |
| 532 | * PB_INT[2] -> MCP (CPU0) |
| 533 | * PB_INT[3] -> MCP (CPU1) |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 534 | * Set interrupt controller outputs as Level_Sensitive/Active_Low |
| 535 | */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 536 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_MPIC_REG_OFFSET + MPIC_CSR(0), 0x02); |
| 537 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_MPIC_REG_OFFSET + MPIC_CSR(1), 0x02); |
| 538 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_MPIC_REG_OFFSET + MPIC_CSR(2), 0x02); |
| 539 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_MPIC_REG_OFFSET + MPIC_CSR(3), 0x02); |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 540 | __asm__ __volatile__ ("sync"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 541 | |
| 542 | /* |
| 543 | * Ensure that Machine Check exception is enabled |
| 544 | * We need it to support PCI Bus probing (configuration reads) |
| 545 | */ |
Wolfgang Denk | 647d3c3 | 2007-03-04 01:36:05 +0100 | [diff] [blame] | 546 | |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 547 | reg_val = mfmsr (); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 548 | mtmsr(reg_val | MSR_ME); |
| 549 | |
| 550 | return 0; |
| 551 | } |
| 552 | |
| 553 | /* |
| 554 | * Needed to print out L2 cache info |
| 555 | * used in the misc_init_r function |
| 556 | */ |
| 557 | |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 558 | unsigned long get_l2cr (void) |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 559 | { |
| 560 | unsigned long l2controlreg; |
| 561 | asm volatile ("mfspr %0, 1017":"=r" (l2controlreg):); |
| 562 | return l2controlreg; |
| 563 | } |
| 564 | |
| 565 | /* |
| 566 | * misc_init_r() |
| 567 | * |
| 568 | * various things to do after relocation |
| 569 | * |
| 570 | */ |
| 571 | |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 572 | int misc_init_r (void) |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 573 | { |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 574 | #ifdef CONFIG_SYS_CLK_SPREAD /* Initialize Spread-Spectrum Clock generation */ |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 575 | ulong i; |
| 576 | |
| 577 | /* Ensure that Spread-Spectrum is disabled */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 578 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_CLK_REG_OFFSET + CG_PLL0_CTRL0, 0); |
| 579 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_CLK_REG_OFFSET + CG_PLL1_CTRL0, 0); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 580 | |
| 581 | /* Initialize PLL1: CG_PCI_CLK , internal OCN_CLK |
| 582 | * Uses pre-calculated value for Fout = 800 MHz, Fs = 30 kHz, D = 0.5% |
| 583 | */ |
| 584 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 585 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_CLK_REG_OFFSET + CG_PLL1_CTRL0, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 586 | 0x002e0044); /* D = 0.25% */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 587 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_CLK_REG_OFFSET + CG_PLL1_CTRL1, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 588 | 0x00000039); /* BWADJ */ |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 589 | |
| 590 | /* Initialize PLL0: CG_PB_CLKO */ |
| 591 | /* Detect PB clock freq. */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 592 | i = in32(CONFIG_SYS_TSI108_CSR_BASE + TSI108_CLK_REG_OFFSET + CG_PWRUP_STATUS); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 593 | i = (i >> 16) & 0x07; /* Get PB PLL multiplier */ |
| 594 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 595 | out32 (CONFIG_SYS_TSI108_CSR_BASE + |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 596 | TSI108_CLK_REG_OFFSET + CG_PLL0_CTRL0, pll0_config[i].ctrl0); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 597 | out32 (CONFIG_SYS_TSI108_CSR_BASE + |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 598 | TSI108_CLK_REG_OFFSET + CG_PLL0_CTRL1, pll0_config[i].ctrl1); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 599 | |
| 600 | /* Wait and set SSEN for both PLL0 and 1 */ |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 601 | udelay (1000); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 602 | out32 (CONFIG_SYS_TSI108_CSR_BASE + TSI108_CLK_REG_OFFSET + CG_PLL1_CTRL0, |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 603 | 0x802e0044); /* D=0.25% */ |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 604 | out32 (CONFIG_SYS_TSI108_CSR_BASE + |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 605 | TSI108_CLK_REG_OFFSET + CG_PLL0_CTRL0, |
Wolfgang Denk | 53677ef | 2008-05-20 16:00:29 +0200 | [diff] [blame] | 606 | 0x80000000 | pll0_config[i].ctrl0); |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 607 | #endif /* CONFIG_SYS_CLK_SPREAD */ |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 608 | |
Jean-Christophe PLAGNIOL-VILLARD | 6d0f6bc | 2008-10-16 15:01:15 +0200 | [diff] [blame] | 609 | #ifdef CONFIG_SYS_L2 |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 610 | l2cache_enable (); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 611 | #endif |
Wolfgang Denk | bde6358 | 2008-07-11 22:56:11 +0200 | [diff] [blame] | 612 | printf ("BUS: %lu MHz\n", gd->bus_clk / 1000000); |
| 613 | printf ("MEM: %lu MHz\n", gd->mem_clk / 1000000); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 614 | |
| 615 | /* |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 616 | * All the information needed to print the cache details is avaiblable |
| 617 | * at this point i.e. above call to l2cache_enable is the very last |
| 618 | * thing done with regards to enabling diabling the cache. |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 619 | * So this seems like a good place to print all this information |
| 620 | */ |
Wolfgang Denk | 647d3c3 | 2007-03-04 01:36:05 +0100 | [diff] [blame] | 621 | |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 622 | printf ("CACHE: "); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 623 | switch (get_cpu_type()) { |
| 624 | case CPU_7447A: |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 625 | printf ("L1 Instruction cache - 32KB 8-way"); |
| 626 | (get_hid0 () & (1 << 15)) ? printf (" ENABLED\n") : |
| 627 | printf (" DISABLED\n"); |
| 628 | printf ("L1 Data cache - 32KB 8-way"); |
| 629 | (get_hid0 () & (1 << 14)) ? printf (" ENABLED\n") : |
| 630 | printf (" DISABLED\n"); |
| 631 | printf ("Unified L2 cache - 512KB 8-way"); |
| 632 | (get_l2cr () & (1 << 31)) ? printf (" ENABLED\n") : |
| 633 | printf (" DISABLED\n"); |
| 634 | printf ("\n"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 635 | break; |
| 636 | |
| 637 | case CPU_7448: |
roy zang | ee31121 | 2006-12-01 11:47:36 +0800 | [diff] [blame] | 638 | printf ("L1 Instruction cache - 32KB 8-way"); |
| 639 | (get_hid0 () & (1 << 15)) ? printf (" ENABLED\n") : |
| 640 | printf (" DISABLED\n"); |
| 641 | printf ("L1 Data cache - 32KB 8-way"); |
| 642 | (get_hid0 () & (1 << 14)) ? printf (" ENABLED\n") : |
| 643 | printf (" DISABLED\n"); |
| 644 | printf ("Unified L2 cache - 1MB 8-way"); |
| 645 | (get_l2cr () & (1 << 31)) ? printf (" ENABLED\n") : |
| 646 | printf (" DISABLED\n"); |
roy zang | 87c4db0 | 2006-11-02 18:59:15 +0800 | [diff] [blame] | 647 | break; |
| 648 | default: |
| 649 | break; |
| 650 | } |
| 651 | return 0; |
| 652 | } |