3 * Josh Huber <huber@mclx.com>, Mission Critical Linux, Inc.
5 * SPDX-License-Identifier: GPL-2.0+
9 * evb64260.c - main board support/init for the Galileo Eval board.
14 #include <galileo/memory.h>
15 #include <galileo/pci.h>
16 #include <galileo/gt64260R.h>
19 #include <linux/compiler.h>
27 DECLARE_GLOBAL_DATA_PTR
;
30 extern void zuma_mbox_init(void);
42 /* ------------------------------------------------------------------------- */
44 /* this is the current GT register space location */
45 /* it starts at CONFIG_SYS_DFL_GT_REGS but moves later to CONFIG_SYS_GT_REGS */
47 /* Unfortunately, we cant change it while we are in flash, so we initialize it
48 * to the "final" value. This means that any debug_led calls before
49 * board_early_init_f wont work right (like in cpu_init_f).
50 * See also my_remap_gt_regs below. (NTL)
53 unsigned int INTERNAL_REG_BASE_ADDR
= CONFIG_SYS_GT_REGS
;
55 /* ------------------------------------------------------------------------- */
58 * This is a version of the GT register space remapping function that
59 * doesn't touch globals (meaning, it's ok to run from flash.)
61 * Unfortunately, this has the side effect that a writable
62 * INTERNAL_REG_BASE_ADDR is impossible. Oh well.
66 my_remap_gt_regs(u32 cur_loc
, u32 new_loc
)
70 /* check and see if it's already moved */
71 temp
= in_le32((u32
*)(new_loc
+ INTERNAL_SPACE_DECODE
));
72 if ((temp
& 0xffff) == new_loc
>> 20)
75 temp
= (in_le32((u32
*)(cur_loc
+ INTERNAL_SPACE_DECODE
)) &
76 0xffff0000) | (new_loc
>> 20);
78 out_le32((u32
*)(cur_loc
+ INTERNAL_SPACE_DECODE
), temp
);
80 while (GTREGREAD(INTERNAL_SPACE_DECODE
) != temp
);
86 /* move PCI stuff out of the way - NTL */
88 pciMapSpace(PCI_HOST0
, PCI_REGION0
, CONFIG_SYS_PCI0_0_MEM_SPACE
,
89 CONFIG_SYS_PCI0_0_MEM_SPACE
, CONFIG_SYS_PCI0_MEM_SIZE
);
91 pciMapSpace(PCI_HOST0
, PCI_REGION1
, 0, 0, 0);
92 pciMapSpace(PCI_HOST0
, PCI_REGION2
, 0, 0, 0);
93 pciMapSpace(PCI_HOST0
, PCI_REGION3
, 0, 0, 0);
95 pciMapSpace(PCI_HOST0
, PCI_IO
, CONFIG_SYS_PCI0_IO_SPACE_PCI
,
96 CONFIG_SYS_PCI0_IO_SPACE
, CONFIG_SYS_PCI0_IO_SIZE
);
99 pciMapSpace(PCI_HOST1
, PCI_REGION0
, CONFIG_SYS_PCI1_0_MEM_SPACE
,
100 CONFIG_SYS_PCI1_0_MEM_SPACE
, CONFIG_SYS_PCI1_MEM_SIZE
);
102 pciMapSpace(PCI_HOST1
, PCI_REGION1
, 0, 0, 0);
103 pciMapSpace(PCI_HOST1
, PCI_REGION2
, 0, 0, 0);
104 pciMapSpace(PCI_HOST1
, PCI_REGION3
, 0, 0, 0);
106 pciMapSpace(PCI_HOST1
, PCI_IO
, CONFIG_SYS_PCI1_IO_SPACE_PCI
,
107 CONFIG_SYS_PCI1_IO_SPACE
, CONFIG_SYS_PCI1_IO_SIZE
);
109 /* PCI interface settings */
110 GT_REG_WRITE(PCI_0TIMEOUT_RETRY
, 0xffff);
111 GT_REG_WRITE(PCI_1TIMEOUT_RETRY
, 0xffff);
112 GT_REG_WRITE(PCI_0BASE_ADDRESS_REGISTERS_ENABLE
, 0xfffff80e);
113 GT_REG_WRITE(PCI_1BASE_ADDRESS_REGISTERS_ENABLE
, 0xfffff80e);
118 /* Setup CPU interface paramaters */
122 cpu_t cpu
= get_cpu_type();
125 /* cpu configuration register */
126 tmp
= GTREGREAD(CPU_CONFIGURATION
);
128 /* set the AACK delay bit
130 tmp
|= CPU_CONF_AACK_DELAY
;
131 tmp
&= ~CPU_CONF_AACK_DELAY_2
; /* New RGF */
133 /* Galileo claims this is necessary for all busses >= 100 MHz */
134 tmp
|= CPU_CONF_FAST_CLK
;
136 if (cpu
== CPU_750CX
) {
137 tmp
&= ~CPU_CONF_DP_VALID
; /* Safer, needed for CXe. RGF */
138 tmp
&= ~CPU_CONF_AP_VALID
;
140 tmp
|= CPU_CONF_DP_VALID
;
141 tmp
|= CPU_CONF_AP_VALID
;
144 /* this only works with the MPX bus */
145 tmp
&= ~CPU_CONF_RD_OOO
; /* Safer RGF */
146 tmp
|= CPU_CONF_PIPELINE
;
147 tmp
|= CPU_CONF_TA_DELAY
;
149 GT_REG_WRITE(CPU_CONFIGURATION
, tmp
);
151 /* CPU master control register */
152 tmp
= GTREGREAD(CPU_MASTER_CONTROL
);
154 tmp
|= CPU_MAST_CTL_ARB_EN
;
156 if ((cpu
== CPU_7400
) ||
160 tmp
|= CPU_MAST_CTL_CLEAN_BLK
;
161 tmp
|= CPU_MAST_CTL_FLUSH_BLK
;
164 /* cleanblock must be cleared for CPUs
165 * that do not support this command
167 tmp
&= ~CPU_MAST_CTL_CLEAN_BLK
;
168 tmp
&= ~CPU_MAST_CTL_FLUSH_BLK
;
170 GT_REG_WRITE(CPU_MASTER_CONTROL
, tmp
);
174 * board_early_init_f.
176 * set up gal. device mappings, etc.
178 int board_early_init_f (void)
183 * set up the GT the way the kernel wants it
184 * the call to move the GT register space will obviously
185 * fail if it has already been done, but we're going to assume
186 * that if it's not at the power-on location, it's where we put
187 * it last time. (huber)
189 my_remap_gt_regs(CONFIG_SYS_DFL_GT_REGS
, CONFIG_SYS_GT_REGS
);
193 /* mask all external interrupt sources */
194 GT_REG_WRITE(CPU_INTERRUPT_MASK_REGISTER_LOW
, 0);
195 GT_REG_WRITE(CPU_INTERRUPT_MASK_REGISTER_HIGH
, 0);
196 GT_REG_WRITE(PCI_0INTERRUPT_CAUSE_MASK_REGISTER_LOW
, 0);
197 GT_REG_WRITE(PCI_0INTERRUPT_CAUSE_MASK_REGISTER_HIGH
, 0);
198 GT_REG_WRITE(PCI_1INTERRUPT_CAUSE_MASK_REGISTER_LOW
, 0);
199 GT_REG_WRITE(PCI_1INTERRUPT_CAUSE_MASK_REGISTER_HIGH
, 0);
200 GT_REG_WRITE(CPU_INT_0_MASK
, 0);
201 GT_REG_WRITE(CPU_INT_1_MASK
, 0);
202 GT_REG_WRITE(CPU_INT_2_MASK
, 0);
203 GT_REG_WRITE(CPU_INT_3_MASK
, 0);
205 /* now, onto the configuration */
206 GT_REG_WRITE(SDRAM_CONFIGURATION
, CONFIG_SYS_SDRAM_CONFIG
);
208 /* ----- DEVICE BUS SETTINGS ------ */
224 * the dual 7450 module requires burst access to the boot
225 * device, so the serial rom copies the boot device to the
226 * on-board sram on the eval board, and updates the correct
227 * registers to boot from the sram. (device0)
229 #if defined(CONFIG_ZUMA_V2) || defined(CONFIG_P3G4)
230 /* Zuma has no SRAM */
233 if (memoryGetDeviceBaseAddress(DEVICE0
) && 0xfff00000 == CONFIG_SYS_MONITOR_BASE
)
237 memoryMapDeviceSpace(DEVICE0
, CONFIG_SYS_DEV0_SPACE
, CONFIG_SYS_DEV0_SIZE
);
239 memoryMapDeviceSpace(DEVICE1
, CONFIG_SYS_DEV1_SPACE
, CONFIG_SYS_DEV1_SIZE
);
240 memoryMapDeviceSpace(DEVICE2
, CONFIG_SYS_DEV2_SPACE
, CONFIG_SYS_DEV2_SIZE
);
241 memoryMapDeviceSpace(DEVICE3
, CONFIG_SYS_DEV3_SPACE
, CONFIG_SYS_DEV3_SIZE
);
243 /* configure device timing */
244 #ifdef CONFIG_SYS_DEV0_PAR
246 GT_REG_WRITE(DEVICE_BANK0PARAMETERS
, CONFIG_SYS_DEV0_PAR
);
249 #ifdef CONFIG_SYS_DEV1_PAR
250 GT_REG_WRITE(DEVICE_BANK1PARAMETERS
, CONFIG_SYS_DEV1_PAR
);
252 #ifdef CONFIG_SYS_DEV2_PAR
253 GT_REG_WRITE(DEVICE_BANK2PARAMETERS
, CONFIG_SYS_DEV2_PAR
);
256 #ifdef CONFIG_EVB64260
257 #ifdef CONFIG_SYS_32BIT_BOOT_PAR
258 /* detect if we are booting from the 32 bit flash */
259 if (GTREGREAD(DEVICE_BOOT_BANK_PARAMETERS
) & (0x3 << 20)) {
260 /* 32 bit boot flash */
261 GT_REG_WRITE(DEVICE_BANK3PARAMETERS
, CONFIG_SYS_8BIT_BOOT_PAR
);
262 GT_REG_WRITE(DEVICE_BOOT_BANK_PARAMETERS
, CONFIG_SYS_32BIT_BOOT_PAR
);
264 /* 8 bit boot flash */
265 GT_REG_WRITE(DEVICE_BANK3PARAMETERS
, CONFIG_SYS_32BIT_BOOT_PAR
);
266 GT_REG_WRITE(DEVICE_BOOT_BANK_PARAMETERS
, CONFIG_SYS_8BIT_BOOT_PAR
);
269 /* 8 bit boot flash only */
270 GT_REG_WRITE(DEVICE_BOOT_BANK_PARAMETERS
, CONFIG_SYS_8BIT_BOOT_PAR
);
272 #else /* CONFIG_EVB64260 not defined */
273 /* We are booting from 16-bit flash.
275 GT_REG_WRITE(DEVICE_BOOT_BANK_PARAMETERS
, CONFIG_SYS_16BIT_BOOT_PAR
);
281 GT_REG_WRITE(MPP_CONTROL0
, CONFIG_SYS_MPP_CONTROL_0
);
282 GT_REG_WRITE(MPP_CONTROL1
, CONFIG_SYS_MPP_CONTROL_1
);
283 GT_REG_WRITE(MPP_CONTROL2
, CONFIG_SYS_MPP_CONTROL_2
);
284 GT_REG_WRITE(MPP_CONTROL3
, CONFIG_SYS_MPP_CONTROL_3
);
286 GT_REG_WRITE(GPP_LEVEL_CONTROL
, CONFIG_SYS_GPP_LEVEL_CONTROL
);
287 GT_REG_WRITE(SERIAL_PORT_MULTIPLEX
, CONFIG_SYS_SERIAL_PORT_MUX
);
292 /* various things to do after relocation */
294 int misc_init_r (void)
305 #ifdef CONFIG_ZUMA_V2
312 after_reloc(ulong dest_addr
)
314 /* check to see if we booted from the sram. If so, move things
315 * back to the way they should be. (we're running from main
316 * memory at this point now */
318 if (memoryGetDeviceBaseAddress(DEVICE0
) == CONFIG_SYS_MONITOR_BASE
) {
319 memoryMapDeviceSpace(DEVICE0
, CONFIG_SYS_DEV0_SPACE
, CONFIG_SYS_DEV0_SIZE
);
320 memoryMapDeviceSpace(BOOT_DEVICE
, CONFIG_SYS_FLASH_BASE
, _1M
);
323 /* now, jump to the main U-Boot board init code */
324 board_init_r ((gd_t
*)gd
, dest_addr
);
329 /* ------------------------------------------------------------------------- */
332 * Check Board Identity:
338 puts ("Board: " CONFIG_SYS_BOARD_NAME
"\n");
342 /* utility functions */
344 debug_led(int led
, int mode
)
346 #if !defined(CONFIG_ZUMA_V2) && !defined(CONFIG_P3G4)
347 volatile int *addr
= NULL
;
348 __maybe_unused
int dummy
;
353 addr
= (int *)((unsigned int)CONFIG_SYS_DEV1_SPACE
| 0x08000);
357 addr
= (int *)((unsigned int)CONFIG_SYS_DEV1_SPACE
| 0x0c000);
361 addr
= (int *)((unsigned int)CONFIG_SYS_DEV1_SPACE
| 0x10000);
364 } else if (mode
== 0) {
367 addr
= (int *)((unsigned int)CONFIG_SYS_DEV1_SPACE
| 0x14000);
371 addr
= (int *)((unsigned int)CONFIG_SYS_DEV1_SPACE
| 0x18000);
375 addr
= (int *)((unsigned int)CONFIG_SYS_DEV1_SPACE
| 0x1c000);
381 #endif /* CONFIG_ZUMA_V2 */
385 display_mem_map(void)
388 unsigned int base
,size
,width
;
391 for(i
=0;i
<=BANK3
;i
++) {
392 base
= memoryGetBankBaseAddress(i
);
393 size
= memoryGetBankSize(i
);
396 printf("BANK%d: base - 0x%08x\tsize - %dM bytes\n",i
,base
,size
>>20);
400 /* CPU's PCI windows */
401 for(i
=0;i
<=PCI_HOST1
;i
++) {
402 printf("\nCPU's PCI %d windows\n", i
);
403 base
=pciGetSpaceBase(i
,PCI_IO
);
404 size
=pciGetSpaceSize(i
,PCI_IO
);
405 printf(" IO: base - 0x%08x\tsize - %dM bytes\n",base
,size
>>20);
406 for(j
=0;j
<=PCI_REGION3
;j
++) {
407 base
= pciGetSpaceBase(i
,j
);
408 size
= pciGetSpaceSize(i
,j
);
409 printf("MEMORY %d: base - 0x%08x\tsize - %dM bytes\n",j
,base
,
415 printf("\nDEVICES\n");
416 for(i
=0;i
<=DEVICE3
;i
++) {
417 base
= memoryGetDeviceBaseAddress(i
);
418 size
= memoryGetDeviceSize(i
);
419 width
= memoryGetDeviceWidth(i
) * 8;
420 printf("DEV %d: base - 0x%08x\tsize - %dM bytes\twidth - %d bits\n",
421 i
, base
, size
>>20, width
);
425 base
= memoryGetDeviceBaseAddress(BOOT_DEVICE
); /* Boot */
426 size
= memoryGetDeviceSize(BOOT_DEVICE
);
427 width
= memoryGetDeviceWidth(BOOT_DEVICE
) * 8;
428 printf(" BOOT: base - 0x%08x\tsize - %dM bytes\twidth - %d bits\n",
429 base
, size
>>20, width
);
432 int board_eth_init(bd_t
*bis
)
434 gt6426x_eth_initialize(bis
);