blob: 61f37d74f2a42a725771d3618878d3013f772aee [file] [log] [blame]
wdenkb573bf12002-07-16 18:49:25 +00001/*------------------------------------------------------------------------------+
Josh Boyer471573b2009-08-07 13:53:20 -04002 * This source code is dual-licensed. You may use it under the terms of
3 * the GNU General Public License version 2, or under the license below.
wdenkb573bf12002-07-16 18:49:25 +00004 *
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.
11 *
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.
15 *
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.
19 *
20 * COPYRIGHT I B M CORPORATION 1995
21 * LICENSED MATERIAL - PROGRAM PROPERTY OF I B M
22 *-------------------------------------------------------------------------------*/
23
24/*-----------------------------------------------------------------------------
25 * Function: ext_bus_cntlr_init
26 * Description: Initializes the External Bus Controller for the external
27 * peripherals. IMPORTANT: For pass1 this code must run from
28 * cache since you can not reliably change a peripheral banks
29 * timing register (pbxap) while running code from that bank.
30 * For ex., since we are running from ROM on bank 0, we can NOT
31 * execute the code that modifies bank 0 timings from ROM, so
32 * we run it from cache.
33 * Bank 0 - Flash or Multi Purpose Socket
34 * Bank 1 - Multi Purpose Socket or Flash
35 * Bank 2 - not used
36 * Bank 3 - not used
37 * Bank 4 - not used
38 * Bank 5 - not used
39 * Bank 6 - used to switch on the 12V for the Multipurpose socket
40 * Bank 7 - Config Register
41 *-----------------------------------------------------------------------------*/
42#include <ppc4xx.h>
43
44#define _LINUX_CONFIG_H 1 /* avoid reading Linux autoconf.h file */
45
wdenk2c9b05d2003-09-10 22:30:53 +000046#include <configs/PIP405.h>
wdenkb573bf12002-07-16 18:49:25 +000047#include <ppc_asm.tmpl>
48#include <ppc_defs.h>
49
50#include <asm/cache.h>
51#include <asm/mmu.h>
wdenk2c9b05d2003-09-10 22:30:53 +000052#include "pip405.h"
wdenkb573bf12002-07-16 18:49:25 +000053
wdenk2c9b05d2003-09-10 22:30:53 +000054 .globl ext_bus_cntlr_init
55 ext_bus_cntlr_init:
56 mflr r4 /* save link register */
57 mfdcr r3,strap /* get strapping reg */
58 andi. r0, r3, PSR_ROM_LOC /* mask out irrelevant bits */
59 bnelr /* jump back if PCI boot */
wdenkb573bf12002-07-16 18:49:25 +000060
wdenkb573bf12002-07-16 18:49:25 +000061 bl ..getAddr
62..getAddr:
63 mflr r3 /* get address of ..getAddr */
64 mtlr r4 /* restore link register */
65 addi r4,0,14 /* set ctr to 14; used to prefetch */
66 mtctr r4 /* 14 cache lines to fit this function */
wdenk57b2d802003-06-27 21:31:46 +000067 /* in cache (gives us 8x14=112 instrctns) */
wdenkb573bf12002-07-16 18:49:25 +000068..ebcloop:
69 icbt r0,r3 /* prefetch cache line for addr in r3 */
70 addi r3,r3,32 /* move to next cache line */
71 bdnz ..ebcloop /* continue for 14 cache lines */
72
73 /*-------------------------------------------------------------------
74 * Delay to ensure all accesses to ROM are complete before changing
75 * bank 0 timings.
76 *------------------------------------------------------------------- */
77 addis r3,0,0x0
78 ori r3,r3,0xA000
79 mtctr r3
80..spinlp:
81 bdnz ..spinlp /* spin loop */
82
83 /*-----------------------------------------------------------------------
84 * decide boot up mode
85 *----------------------------------------------------------------------- */
86 addi r4,0,pb0cr
87 mtdcr ebccfga,r4
88 mfdcr r4,ebccfgd
89
90 andi. r0, r4, 0x2000 /* mask out irrelevant bits */
wdenk2c9b05d2003-09-10 22:30:53 +000091 beq 0f /* jump if 8 bit bus width */
wdenkb573bf12002-07-16 18:49:25 +000092
93 /* setup 16 bit things
94 *-----------------------------------------------------------------------
95 * Memory Bank 0 (16 Bit Flash) initialization
96 *---------------------------------------------------------------------- */
97
98 addi r4,0,pb0ap
wdenk2c9b05d2003-09-10 22:30:53 +000099 mtdcr ebccfga,r4
100 addis r4,0,(FLASH_AP_B)@h
101 ori r4,r4,(FLASH_AP_B)@l
102 mtdcr ebccfgd,r4
wdenkb573bf12002-07-16 18:49:25 +0000103
wdenk2c9b05d2003-09-10 22:30:53 +0000104 addi r4,0,pb0cr
105 mtdcr ebccfga,r4
106 /* BS=0x010(4MB),BU=0x3(R/W), */
107 addis r4,0,(FLASH_CR_B)@h
108 ori r4,r4,(FLASH_CR_B)@l
109 mtdcr ebccfgd,r4
wdenkb573bf12002-07-16 18:49:25 +0000110 b 1f
111
1120:
wdenk2c9b05d2003-09-10 22:30:53 +0000113 /* 8Bit boot mode: */
wdenkb573bf12002-07-16 18:49:25 +0000114 /*-----------------------------------------------------------------------
wdenk2c9b05d2003-09-10 22:30:53 +0000115 * Memory Bank 0 Multi Purpose Socket initialization
116 *----------------------------------------------------------------------- */
117 /* 0x7F8FFE80 slowest boot */
wdenkb573bf12002-07-16 18:49:25 +0000118 addi r4,0,pb0ap
wdenk2c9b05d2003-09-10 22:30:53 +0000119 mtdcr ebccfga,r4
120 addis r4,0,(MPS_AP_B)@h
121 ori r4,r4,(MPS_AP_B)@l
122 mtdcr ebccfgd,r4
wdenkb573bf12002-07-16 18:49:25 +0000123
wdenk2c9b05d2003-09-10 22:30:53 +0000124 addi r4,0,pb0cr
125 mtdcr ebccfga,r4
126 /* BS=0x010(4MB),BU=0x3(R/W), */
127 addis r4,0,(MPS_CR_B)@h
128 ori r4,r4,(MPS_CR_B)@l
129 mtdcr ebccfgd,r4
wdenkb573bf12002-07-16 18:49:25 +0000130
wdenk2c9b05d2003-09-10 22:30:53 +0000131
1321:
wdenkb573bf12002-07-16 18:49:25 +0000133 /*-----------------------------------------------------------------------
wdenk2c9b05d2003-09-10 22:30:53 +0000134 * Memory Bank 2-3-4-5-6 (not used) initialization
wdenkb573bf12002-07-16 18:49:25 +0000135 *-----------------------------------------------------------------------*/
wdenkb573bf12002-07-16 18:49:25 +0000136 addi r4,0,pb1cr
137 mtdcr ebccfga,r4
wdenk2c9b05d2003-09-10 22:30:53 +0000138 addis r4,0,0x0000
139 ori r4,r4,0x0000
wdenkb573bf12002-07-16 18:49:25 +0000140 mtdcr ebccfgd,r4
141
wdenkb573bf12002-07-16 18:49:25 +0000142 addi r4,0,pb2cr
143 mtdcr ebccfga,r4
144 addis r4,0,0x0000
145 ori r4,r4,0x0000
146 mtdcr ebccfgd,r4
147
148 addi r4,0,pb3cr
149 mtdcr ebccfga,r4
150 addis r4,0,0x0000
151 ori r4,r4,0x0000
152 mtdcr ebccfgd,r4
153
154 addi r4,0,pb4cr
155 mtdcr ebccfga,r4
156 addis r4,0,0x0000
157 ori r4,r4,0x0000
158 mtdcr ebccfgd,r4
159
160 addi r4,0,pb5cr
161 mtdcr ebccfga,r4
162 addis r4,0,0x0000
163 ori r4,r4,0x0000
164 mtdcr ebccfgd,r4
165
wdenk2c9b05d2003-09-10 22:30:53 +0000166 addi r4,0,pb6cr
wdenkb573bf12002-07-16 18:49:25 +0000167 mtdcr ebccfga,r4
168 addis r4,0,0x0000
169 ori r4,r4,0x0000
170 mtdcr ebccfgd,r4
171
wdenkb573bf12002-07-16 18:49:25 +0000172 addi r4,0,pb7cr
173 mtdcr ebccfga,r4
wdenk2c9b05d2003-09-10 22:30:53 +0000174 addis r4,0,0x0000
175 ori r4,r4,0x0000
wdenkb573bf12002-07-16 18:49:25 +0000176 mtdcr ebccfgd,r4
wdenk2c9b05d2003-09-10 22:30:53 +0000177 nop /* pass2 DCR errata #8 */
wdenkb573bf12002-07-16 18:49:25 +0000178 blr
179
wdenk2c9b05d2003-09-10 22:30:53 +0000180#if defined(CONFIG_BOOT_PCI)
181 .section .bootpg,"ax"
182 .globl _start_pci
183/*******************************************
184 */
185
186_start_pci:
187 /* first handle errata #68 / PCI_18 */
188 iccci r0, r0 /* invalidate I-cache */
189 lis r31, 0
190 mticcr r31 /* ICCR = 0 (all uncachable) */
191 isync
192
193 mfccr0 r28 /* set CCR0[24] = 1 */
194 ori r28, r28, 0x0080
195 mtccr0 r28
196
197 /* setup PMM0MA (0xEF400004) and PMM0PCIHA (0xEF40000C) */
198 lis r28, 0xEF40
199 addi r28, r28, 0x0004
200 stw r31, 0x0C(r28) /* clear PMM0PCIHA */
201 lis r29, 0xFFF8 /* open 512 kByte */
202 addi r29, r29, 0x0001/* and enable this region */
203 stwbrx r29, r0, r28 /* write PMM0MA */
204
205 lis r28, 0xEEC0 /* address of PCIC0_CFGADDR */
206 addi r29, r28, 4 /* add 4 to r29 -> PCIC0_CFGDATA */
207
208 lis r31, 0x8000 /* set en bit bus 0 */
209 ori r31, r31, 0x304C/* device 6 func 0 reg 4C (XBCS register) */
210 stwbrx r31, r0, r28 /* write it */
211
212 lwbrx r31, r0, r29 /* load XBCS register */
213 oris r31, r31, 0x02C4/* clear BIOSCS WPE, set lower, extended and 1M extended BIOS enable */
214 stwbrx r31, r0, r29 /* write back XBCS register */
215
216 nop
217 nop
218 b _start /* normal start */
219#endif