1 /******************************************************************************
2 * This source code is dual-licensed. You may use it under the terms of the
3 * GNU General Public License version 2, or under the license below.
5 * This source code has been made available to you by IBM on an AS-IS
6 * basis. Anyone receiving this source is licensed under IBM
7 * copyrights to use it in any way he or she deems fit, including
8 * copying it, modifying it, compiling it, and redistributing it either
9 * with or without modifications. No license under IBM patents or
10 * patent applications is to be implied by the copyright license.
12 * Any user of this software should understand that IBM cannot provide
13 * technical support for this software and will not be responsible for
14 * any consequences resulting from the use of this software.
16 * Any person who transfers this source code or any derivative work
17 * must include the IBM copyright notice, this paragraph, and the
18 * preceding two paragraphs in the transferred software.
20 * COPYRIGHT I B M CORPORATION 1995
21 * LICENSED MATERIAL - PROGRAM PROPERTY OF I B M
23 *****************************************************************************/
25 #include <asm/ppc4xx.h>
27 #define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */
29 #include <ppc_asm.tmpl>
32 #include <asm/cache.h>
35 #define LI32(reg,val) \
39 #define WDCR_EBC(reg,val) \
41 mtdcr EBC0_CFGADDR,r4;\
46 #define WDCR_SDRAM(reg,val) \
48 mtdcr SDRAM0_CFGADDR,r4;\
51 mtdcr SDRAM0_CFGDATA,r4
53 /******************************************************************************
54 * Function: ext_bus_cntlr_init
56 * Description: Configures EBC Controller and a few basic chip selects.
58 * CS0 is setup to get the Boot Flash out of the addresss range
59 * so that we may setup a stack. CS7 is setup so that we can
60 * access and reset the hardware watchdog.
62 * IMPORTANT: For pass1 this code must run from
63 * cache since you can not reliably change a peripheral banks
64 * timing register (pbxap) while running code from that bank.
65 * For ex., since we are running from ROM on bank 0, we can NOT
66 * execute the code that modifies bank 0 timings from ROM, so
67 * we run it from cache.
69 * Notes: Does NOT use the stack.
70 *****************************************************************************/
73 .globl ext_bus_cntlr_init
74 .type ext_bus_cntlr_init, @function
77 /********************************************************************
78 * Prefetch entire ext_bus_cntrl_init function into the icache.
79 * This is necessary because we are going to change the same CS we
80 * are executing from. Otherwise a CPU lockup may occur.
81 *******************************************************************/
84 mflr r3 /* get address of ..getAddr */
86 /* Calculate number of cache lines for this function */
87 addi r4, 0, (((.Lfe0 - ..getAddr) / CONFIG_SYS_CACHELINE_SIZE) + 2)
90 icbt r0, r3 /* prefetch cache line for addr in r3*/
91 addi r3, r3, CONFIG_SYS_CACHELINE_SIZE /* move to next cache line */
92 bdnz ..ebcloop /* continue for $CTR cache lines */
94 /********************************************************************
95 * Delay to ensure all accesses to ROM are complete before changing
96 * bank 0 timings. 200usec should be enough.
97 * 200,000,000 (cycles/sec) X .000200 (sec) = 0x9C40 cycles.
98 *******************************************************************/
100 ori r3, r3, 0xA000 /* wait 200us from reset */
103 bdnz ..spinlp /* spin loop */
105 /********************************************************************
107 *******************************************************************/
111 /********************************************************************
112 * Setup CPC0_CR1: Change PCIINT signal to PerWE
113 *******************************************************************/
118 /********************************************************************
119 * Setup External Bus Controller (EBC).
120 *******************************************************************/
121 WDCR_EBC(EBC0_CFG, 0xd84c0000)
122 /********************************************************************
123 * Memory Bank 0 (Intel 28F640J3 Flash) initialization
124 *******************************************************************/
125 /*WDCR_EBC(PB1AP, 0x03055200)*/
126 /*WDCR_EBC(PB1AP, 0x04055200)*/
127 WDCR_EBC(PB1AP, 0x08055200)
128 WDCR_EBC(PB0CR, 0xff87a000)
129 /********************************************************************
130 * Memory Bank 3 (Xilinx XC95144 CPLD) initialization
131 *******************************************************************/
132 /*WDCR_EBC(PB3AP, 0x07869200)*/
133 WDCR_EBC(PB3AP, 0x04055200)
134 WDCR_EBC(PB3CR, 0xf081c000)
135 /********************************************************************
136 * Memory Bank 1,2,4-7 (Unused) initialization
137 *******************************************************************/
151 /* We are all done */
152 mtlr r0 /* Restore link register */
153 blr /* Return to calling function */
154 .Lfe0: .size ext_bus_cntlr_init,.Lfe0-ext_bus_cntlr_init
155 /* end ext_bus_cntlr_init() */
157 /******************************************************************************
158 * Function: sdram_init
160 * Description: Configures SDRAM memory banks.
162 * Notes: Does NOT use the stack.
163 *****************************************************************************/
167 .type sdram_init, @function
171 * Disable memory controller to allow
172 * values to be changed.
174 WDCR_SDRAM(SDRAM0_CFG, 0x00000000)
177 * Configure Memory Banks
179 WDCR_SDRAM(SDRAM0_B0CR, 0x00062001)
180 WDCR_SDRAM(SDRAM0_B1CR, 0x00000000)
181 WDCR_SDRAM(SDRAM0_B2CR, 0x00000000)
182 WDCR_SDRAM(SDRAM0_B3CR, 0x00000000)
185 * Set up SDTR1 (SDRAM Timing Register)
187 WDCR_SDRAM(SDRAM0_TR, 0x00854009)
190 * Set RTR (Refresh Timing Register)
192 WDCR_SDRAM(SDRAM0_RTR, 0x10000000)
193 /* WDCR_SDRAM(SDRAM0_RTR, 0x05f00000) */
195 /********************************************************************
196 * Delay to ensure 200usec have elapsed since reset. Assume worst
197 * case that the core is running 200Mhz:
198 * 200,000,000 (cycles/sec) X .000200 (sec) = 0x9C40 cycles
199 *******************************************************************/
201 ori r3, r3, 0xA000 /* Wait >200us from reset */
204 bdnz ..spinlp2 /* spin loop */
206 /********************************************************************
207 * Set memory controller options reg, MCOPT1.
208 *******************************************************************/
209 WDCR_SDRAM(SDRAM0_CFG,0x80800000)
212 blr /* Return to calling function */
213 .Lfe1: .size sdram_init,.Lfe1-sdram_init
214 /* end sdram_init() */