3 * Josh Huber <huber@mclx.com>, Mission Critical Linux, Inc.
5 * See file CREDITS for list of people who contributed to this
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.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 59 Temple Place, Suite 330, Boston,
25 * evb64260.c - main board support/init for the Galileo Eval board.
30 #include <galileo/memory.h>
31 #include <galileo/pci.h>
32 #include <galileo/gt64260R.h>
42 DECLARE_GLOBAL_DATA_PTR;
45 extern void zuma_mbox_init(void);
57 /* ------------------------------------------------------------------------- */
59 /* this is the current GT register space location */
60 /* it starts at CONFIG_SYS_DFL_GT_REGS but moves later to CONFIG_SYS_GT_REGS */
62 /* Unfortunately, we cant change it while we are in flash, so we initialize it
63 * to the "final" value. This means that any debug_led calls before
64 * board_early_init_f wont work right (like in cpu_init_f).
65 * See also my_remap_gt_regs below. (NTL)
68 unsigned int INTERNAL_REG_BASE_ADDR = CONFIG_SYS_GT_REGS;
70 /* ------------------------------------------------------------------------- */
73 * This is a version of the GT register space remapping function that
74 * doesn't touch globals (meaning, it's ok to run from flash.)
76 * Unfortunately, this has the side effect that a writable
77 * INTERNAL_REG_BASE_ADDR is impossible. Oh well.
81 my_remap_gt_regs(u32 cur_loc, u32 new_loc)
85 /* check and see if it's already moved */
86 temp = in_le32((u32 *)(new_loc + INTERNAL_SPACE_DECODE));
87 if ((temp & 0xffff) == new_loc >> 20)
90 temp = (in_le32((u32 *)(cur_loc + INTERNAL_SPACE_DECODE)) &
91 0xffff0000) | (new_loc >> 20);
93 out_le32((u32 *)(cur_loc + INTERNAL_SPACE_DECODE), temp);
95 while (GTREGREAD(INTERNAL_SPACE_DECODE) != temp);
101 /* move PCI stuff out of the way - NTL */
103 pciMapSpace(PCI_HOST0, PCI_REGION0, CONFIG_SYS_PCI0_0_MEM_SPACE,
104 CONFIG_SYS_PCI0_0_MEM_SPACE, CONFIG_SYS_PCI0_MEM_SIZE);
106 pciMapSpace(PCI_HOST0, PCI_REGION1, 0, 0, 0);
107 pciMapSpace(PCI_HOST0, PCI_REGION2, 0, 0, 0);
108 pciMapSpace(PCI_HOST0, PCI_REGION3, 0, 0, 0);
110 pciMapSpace(PCI_HOST0, PCI_IO, CONFIG_SYS_PCI0_IO_SPACE_PCI,
111 CONFIG_SYS_PCI0_IO_SPACE, CONFIG_SYS_PCI0_IO_SIZE);
114 pciMapSpace(PCI_HOST1, PCI_REGION0, CONFIG_SYS_PCI1_0_MEM_SPACE,
115 CONFIG_SYS_PCI1_0_MEM_SPACE, CONFIG_SYS_PCI1_MEM_SIZE);
117 pciMapSpace(PCI_HOST1, PCI_REGION1, 0, 0, 0);
118 pciMapSpace(PCI_HOST1, PCI_REGION2, 0, 0, 0);
119 pciMapSpace(PCI_HOST1, PCI_REGION3, 0, 0, 0);
121 pciMapSpace(PCI_HOST1, PCI_IO, CONFIG_SYS_PCI1_IO_SPACE_PCI,
122 CONFIG_SYS_PCI1_IO_SPACE, CONFIG_SYS_PCI1_IO_SIZE);
124 /* PCI interface settings */
125 GT_REG_WRITE(PCI_0TIMEOUT_RETRY, 0xffff);
126 GT_REG_WRITE(PCI_1TIMEOUT_RETRY, 0xffff);
127 GT_REG_WRITE(PCI_0BASE_ADDRESS_REGISTERS_ENABLE, 0xfffff80e);
128 GT_REG_WRITE(PCI_1BASE_ADDRESS_REGISTERS_ENABLE, 0xfffff80e);
133 /* Setup CPU interface paramaters */
137 cpu_t cpu = get_cpu_type();
140 /* cpu configuration register */
141 tmp = GTREGREAD(CPU_CONFIGURATION);
143 /* set the AACK delay bit
145 tmp |= CPU_CONF_AACK_DELAY;
146 tmp &= ~CPU_CONF_AACK_DELAY_2; /* New RGF */
148 /* Galileo claims this is necessary for all busses >= 100 MHz */
149 tmp |= CPU_CONF_FAST_CLK;
151 if (cpu == CPU_750CX) {
152 tmp &= ~CPU_CONF_DP_VALID; /* Safer, needed for CXe. RGF */
153 tmp &= ~CPU_CONF_AP_VALID;
155 tmp |= CPU_CONF_DP_VALID;
156 tmp |= CPU_CONF_AP_VALID;
159 /* this only works with the MPX bus */
160 tmp &= ~CPU_CONF_RD_OOO; /* Safer RGF */
161 tmp |= CPU_CONF_PIPELINE;
162 tmp |= CPU_CONF_TA_DELAY;
164 GT_REG_WRITE(CPU_CONFIGURATION, tmp);
166 /* CPU master control register */
167 tmp = GTREGREAD(CPU_MASTER_CONTROL);
169 tmp |= CPU_MAST_CTL_ARB_EN;
171 if ((cpu == CPU_7400) ||
175 tmp |= CPU_MAST_CTL_CLEAN_BLK;
176 tmp |= CPU_MAST_CTL_FLUSH_BLK;
179 /* cleanblock must be cleared for CPUs
180 * that do not support this command
182 tmp &= ~CPU_MAST_CTL_CLEAN_BLK;
183 tmp &= ~CPU_MAST_CTL_FLUSH_BLK;
185 GT_REG_WRITE(CPU_MASTER_CONTROL, tmp);
189 * board_early_init_f.
191 * set up gal. device mappings, etc.
193 int board_early_init_f (void)
198 * set up the GT the way the kernel wants it
199 * the call to move the GT register space will obviously
200 * fail if it has already been done, but we're going to assume
201 * that if it's not at the power-on location, it's where we put
202 * it last time. (huber)
204 my_remap_gt_regs(CONFIG_SYS_DFL_GT_REGS, CONFIG_SYS_GT_REGS);
208 /* mask all external interrupt sources */
209 GT_REG_WRITE(CPU_INTERRUPT_MASK_REGISTER_LOW, 0);
210 GT_REG_WRITE(CPU_INTERRUPT_MASK_REGISTER_HIGH, 0);
211 GT_REG_WRITE(PCI_0INTERRUPT_CAUSE_MASK_REGISTER_LOW, 0);
212 GT_REG_WRITE(PCI_0INTERRUPT_CAUSE_MASK_REGISTER_HIGH, 0);
213 GT_REG_WRITE(PCI_1INTERRUPT_CAUSE_MASK_REGISTER_LOW, 0);
214 GT_REG_WRITE(PCI_1INTERRUPT_CAUSE_MASK_REGISTER_HIGH, 0);
215 GT_REG_WRITE(CPU_INT_0_MASK, 0);
216 GT_REG_WRITE(CPU_INT_1_MASK, 0);
217 GT_REG_WRITE(CPU_INT_2_MASK, 0);
218 GT_REG_WRITE(CPU_INT_3_MASK, 0);
220 /* now, onto the configuration */
221 GT_REG_WRITE(SDRAM_CONFIGURATION, CONFIG_SYS_SDRAM_CONFIG);
223 /* ----- DEVICE BUS SETTINGS ------ */
239 * the dual 7450 module requires burst access to the boot
240 * device, so the serial rom copies the boot device to the
241 * on-board sram on the eval board, and updates the correct
242 * registers to boot from the sram. (device0)
244 #if defined(CONFIG_ZUMA_V2) || defined(CONFIG_P3G4)
245 /* Zuma has no SRAM */
248 if (memoryGetDeviceBaseAddress(DEVICE0) && 0xfff00000 == CONFIG_SYS_MONITOR_BASE)
252 memoryMapDeviceSpace(DEVICE0, CONFIG_SYS_DEV0_SPACE, CONFIG_SYS_DEV0_SIZE);
254 memoryMapDeviceSpace(DEVICE1, CONFIG_SYS_DEV1_SPACE, CONFIG_SYS_DEV1_SIZE);
255 memoryMapDeviceSpace(DEVICE2, CONFIG_SYS_DEV2_SPACE, CONFIG_SYS_DEV2_SIZE);
256 memoryMapDeviceSpace(DEVICE3, CONFIG_SYS_DEV3_SPACE, CONFIG_SYS_DEV3_SIZE);
258 /* configure device timing */
259 #ifdef CONFIG_SYS_DEV0_PAR
261 GT_REG_WRITE(DEVICE_BANK0PARAMETERS, CONFIG_SYS_DEV0_PAR);
264 #ifdef CONFIG_SYS_DEV1_PAR
265 GT_REG_WRITE(DEVICE_BANK1PARAMETERS, CONFIG_SYS_DEV1_PAR);
267 #ifdef CONFIG_SYS_DEV2_PAR
268 GT_REG_WRITE(DEVICE_BANK2PARAMETERS, CONFIG_SYS_DEV2_PAR);
271 #ifdef CONFIG_EVB64260
272 #ifdef CONFIG_SYS_32BIT_BOOT_PAR
273 /* detect if we are booting from the 32 bit flash */
274 if (GTREGREAD(DEVICE_BOOT_BANK_PARAMETERS) & (0x3 << 20)) {
275 /* 32 bit boot flash */
276 GT_REG_WRITE(DEVICE_BANK3PARAMETERS, CONFIG_SYS_8BIT_BOOT_PAR);
277 GT_REG_WRITE(DEVICE_BOOT_BANK_PARAMETERS, CONFIG_SYS_32BIT_BOOT_PAR);
279 /* 8 bit boot flash */
280 GT_REG_WRITE(DEVICE_BANK3PARAMETERS, CONFIG_SYS_32BIT_BOOT_PAR);
281 GT_REG_WRITE(DEVICE_BOOT_BANK_PARAMETERS, CONFIG_SYS_8BIT_BOOT_PAR);
284 /* 8 bit boot flash only */
285 GT_REG_WRITE(DEVICE_BOOT_BANK_PARAMETERS, CONFIG_SYS_8BIT_BOOT_PAR);
287 #else /* CONFIG_EVB64260 not defined */
288 /* We are booting from 16-bit flash.
290 GT_REG_WRITE(DEVICE_BOOT_BANK_PARAMETERS, CONFIG_SYS_16BIT_BOOT_PAR);
296 GT_REG_WRITE(MPP_CONTROL0, CONFIG_SYS_MPP_CONTROL_0);
297 GT_REG_WRITE(MPP_CONTROL1, CONFIG_SYS_MPP_CONTROL_1);
298 GT_REG_WRITE(MPP_CONTROL2, CONFIG_SYS_MPP_CONTROL_2);
299 GT_REG_WRITE(MPP_CONTROL3, CONFIG_SYS_MPP_CONTROL_3);
301 GT_REG_WRITE(GPP_LEVEL_CONTROL, CONFIG_SYS_GPP_LEVEL_CONTROL);
302 GT_REG_WRITE(SERIAL_PORT_MULTIPLEX, CONFIG_SYS_SERIAL_PORT_MUX);
307 /* various things to do after relocation */
309 int misc_init_r (void)
320 #ifdef CONFIG_ZUMA_V2
327 after_reloc(ulong dest_addr)
329 /* check to see if we booted from the sram. If so, move things
330 * back to the way they should be. (we're running from main
331 * memory at this point now */
333 if (memoryGetDeviceBaseAddress(DEVICE0) == CONFIG_SYS_MONITOR_BASE) {
334 memoryMapDeviceSpace(DEVICE0, CONFIG_SYS_DEV0_SPACE, CONFIG_SYS_DEV0_SIZE);
335 memoryMapDeviceSpace(BOOT_DEVICE, CONFIG_SYS_FLASH_BASE, _1M);
338 /* now, jump to the main U-Boot board init code */
339 board_init_r ((gd_t *)gd, dest_addr);
344 /* ------------------------------------------------------------------------- */
347 * Check Board Identity:
353 puts ("Board: " CONFIG_SYS_BOARD_NAME "\n");
357 /* utility functions */
359 debug_led(int led, int mode)
361 #if !defined(CONFIG_ZUMA_V2) && !defined(CONFIG_P3G4)
362 volatile int *addr = NULL;
368 addr = (int *)((unsigned int)CONFIG_SYS_DEV1_SPACE | 0x08000);
372 addr = (int *)((unsigned int)CONFIG_SYS_DEV1_SPACE | 0x0c000);
376 addr = (int *)((unsigned int)CONFIG_SYS_DEV1_SPACE | 0x10000);
379 } else if (mode == 0) {
382 addr = (int *)((unsigned int)CONFIG_SYS_DEV1_SPACE | 0x14000);
386 addr = (int *)((unsigned int)CONFIG_SYS_DEV1_SPACE | 0x18000);
390 addr = (int *)((unsigned int)CONFIG_SYS_DEV1_SPACE | 0x1c000);
396 #endif /* CONFIG_ZUMA_V2 */
400 display_mem_map(void)
403 unsigned int base,size,width;
406 for(i=0;i<=BANK3;i++) {
407 base = memoryGetBankBaseAddress(i);
408 size = memoryGetBankSize(i);
411 printf("BANK%d: base - 0x%08x\tsize - %dM bytes\n",i,base,size>>20);
415 /* CPU's PCI windows */
416 for(i=0;i<=PCI_HOST1;i++) {
417 printf("\nCPU's PCI %d windows\n", i);
418 base=pciGetSpaceBase(i,PCI_IO);
419 size=pciGetSpaceSize(i,PCI_IO);
420 printf(" IO: base - 0x%08x\tsize - %dM bytes\n",base,size>>20);
421 for(j=0;j<=PCI_REGION3;j++) {
422 base = pciGetSpaceBase(i,j);
423 size = pciGetSpaceSize(i,j);
424 printf("MEMORY %d: base - 0x%08x\tsize - %dM bytes\n",j,base,
430 printf("\nDEVICES\n");
431 for(i=0;i<=DEVICE3;i++) {
432 base = memoryGetDeviceBaseAddress(i);
433 size = memoryGetDeviceSize(i);
434 width= memoryGetDeviceWidth(i) * 8;
435 printf("DEV %d: base - 0x%08x\tsize - %dM bytes\twidth - %d bits\n",
436 i, base, size>>20, width);
440 base = memoryGetDeviceBaseAddress(BOOT_DEVICE); /* Boot */
441 size = memoryGetDeviceSize(BOOT_DEVICE);
442 width= memoryGetDeviceWidth(BOOT_DEVICE) * 8;
443 printf(" BOOT: base - 0x%08x\tsize - %dM bytes\twidth - %d bits\n",
444 base, size>>20, width);
447 int board_eth_init(bd_t *bis)
449 gt6426x_eth_initialize(bis);