2 * SPDX-License-Identifier: GPL-2.0 ibm-pibs
5 #include <asm/ppc4xx.h>
7 #define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */
9 #include <ppc_asm.tmpl>
12 #include <asm/cache.h>
15 #define LI32(reg,val) \
19 #define WDCR_EBC(reg,val) \
21 mtdcr EBC0_CFGADDR,r4;\
26 #define WDCR_SDRAM(reg,val) \
28 mtdcr SDRAM0_CFGADDR,r4;\
31 mtdcr SDRAM0_CFGDATA,r4
33 /******************************************************************************
34 * Function: ext_bus_cntlr_init
36 * Description: Configures EBC Controller and a few basic chip selects.
38 * CS0 is setup to get the Boot Flash out of the addresss range
39 * so that we may setup a stack. CS7 is setup so that we can
40 * access and reset the hardware watchdog.
42 * IMPORTANT: For pass1 this code must run from
43 * cache since you can not reliably change a peripheral banks
44 * timing register (pbxap) while running code from that bank.
45 * For ex., since we are running from ROM on bank 0, we can NOT
46 * execute the code that modifies bank 0 timings from ROM, so
47 * we run it from cache.
49 * Notes: Does NOT use the stack.
50 *****************************************************************************/
53 .globl ext_bus_cntlr_init
54 .type ext_bus_cntlr_init, @function
57 /********************************************************************
58 * Prefetch entire ext_bus_cntrl_init function into the icache.
59 * This is necessary because we are going to change the same CS we
60 * are executing from. Otherwise a CPU lockup may occur.
61 *******************************************************************/
64 mflr r3 /* get address of ..getAddr */
66 /* Calculate number of cache lines for this function */
67 addi r4, 0, (((.Lfe0 - ..getAddr) / CONFIG_SYS_CACHELINE_SIZE) + 2)
70 icbt r0, r3 /* prefetch cache line for addr in r3*/
71 addi r3, r3, CONFIG_SYS_CACHELINE_SIZE /* move to next cache line */
72 bdnz ..ebcloop /* continue for $CTR cache lines */
74 /********************************************************************
75 * Delay to ensure all accesses to ROM are complete before changing
76 * bank 0 timings. 200usec should be enough.
77 * 200,000,000 (cycles/sec) X .000200 (sec) = 0x9C40 cycles.
78 *******************************************************************/
80 ori r3, r3, 0xA000 /* wait 200us from reset */
83 bdnz ..spinlp /* spin loop */
85 /********************************************************************
87 *******************************************************************/
91 /********************************************************************
92 * Setup CPC0_CR1: Change PCIINT signal to PerWE
93 *******************************************************************/
98 /********************************************************************
99 * Setup External Bus Controller (EBC).
100 *******************************************************************/
101 WDCR_EBC(EBC0_CFG, 0xd84c0000)
102 /********************************************************************
103 * Memory Bank 0 (Intel 28F640J3 Flash) initialization
104 *******************************************************************/
105 /*WDCR_EBC(PB1AP, 0x03055200)*/
106 /*WDCR_EBC(PB1AP, 0x04055200)*/
107 WDCR_EBC(PB1AP, 0x08055200)
108 WDCR_EBC(PB0CR, 0xff87a000)
109 /********************************************************************
110 * Memory Bank 3 (Xilinx XC95144 CPLD) initialization
111 *******************************************************************/
112 /*WDCR_EBC(PB3AP, 0x07869200)*/
113 WDCR_EBC(PB3AP, 0x04055200)
114 WDCR_EBC(PB3CR, 0xf081c000)
115 /********************************************************************
116 * Memory Bank 1,2,4-7 (Unused) initialization
117 *******************************************************************/
131 /* We are all done */
132 mtlr r0 /* Restore link register */
133 blr /* Return to calling function */
134 .Lfe0: .size ext_bus_cntlr_init,.Lfe0-ext_bus_cntlr_init
135 /* end ext_bus_cntlr_init() */
137 /******************************************************************************
138 * Function: sdram_init
140 * Description: Configures SDRAM memory banks.
142 * Notes: Does NOT use the stack.
143 *****************************************************************************/
147 .type sdram_init, @function
151 * Disable memory controller to allow
152 * values to be changed.
154 WDCR_SDRAM(SDRAM0_CFG, 0x00000000)
157 * Configure Memory Banks
159 WDCR_SDRAM(SDRAM0_B0CR, 0x00062001)
160 WDCR_SDRAM(SDRAM0_B1CR, 0x00000000)
161 WDCR_SDRAM(SDRAM0_B2CR, 0x00000000)
162 WDCR_SDRAM(SDRAM0_B3CR, 0x00000000)
165 * Set up SDTR1 (SDRAM Timing Register)
167 WDCR_SDRAM(SDRAM0_TR, 0x00854009)
170 * Set RTR (Refresh Timing Register)
172 WDCR_SDRAM(SDRAM0_RTR, 0x10000000)
173 /* WDCR_SDRAM(SDRAM0_RTR, 0x05f00000) */
175 /********************************************************************
176 * Delay to ensure 200usec have elapsed since reset. Assume worst
177 * case that the core is running 200Mhz:
178 * 200,000,000 (cycles/sec) X .000200 (sec) = 0x9C40 cycles
179 *******************************************************************/
181 ori r3, r3, 0xA000 /* Wait >200us from reset */
184 bdnz ..spinlp2 /* spin loop */
186 /********************************************************************
187 * Set memory controller options reg, MCOPT1.
188 *******************************************************************/
189 WDCR_SDRAM(SDRAM0_CFG,0x80800000)
192 blr /* Return to calling function */
193 .Lfe1: .size sdram_init,.Lfe1-sdram_init
194 /* end sdram_init() */