OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [powerpc/] [moab/] [current/] [src/] [moab.S] - Blame information for rev 867

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
##=============================================================================
2
##
3
##      moab.S
4
##
5
##      MOAB board hardware setup
6
##
7
##=============================================================================
8
## ####ECOSGPLCOPYRIGHTBEGIN####
9
## -------------------------------------------
10
## This file is part of eCos, the Embedded Configurable Operating System.
11
## Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
12
##
13
## eCos is free software; you can redistribute it and/or modify it under
14
## the terms of the GNU General Public License as published by the Free
15
## Software Foundation; either version 2 or (at your option) any later
16
## version.
17
##
18
## eCos is distributed in the hope that it will be useful, but WITHOUT
19
## ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
20
## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
21
## for more details.
22
##
23
## You should have received a copy of the GNU General Public License
24
## along with eCos; if not, write to the Free Software Foundation, Inc.,
25
## 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
26
##
27
## As a special exception, if other files instantiate templates or use
28
## macros or inline functions from this file, or you compile this file
29
## and link it with other works to produce a work based on this file,
30
## this file does not by itself cause the resulting work to be covered by
31
## the GNU General Public License. However the source code for this file
32
## must still be made available in accordance with section (3) of the GNU
33
## General Public License v2.
34
##
35
## This exception does not invalidate any other reasons why a work based
36
## on this file might be covered by the GNU General Public License.
37
## -------------------------------------------
38
## ####ECOSGPLCOPYRIGHTEND####
39
##=============================================================================
40
#######DESCRIPTIONBEGIN####
41
##
42
## Author(s):   gthomas
43
## Contributors:hmt
44
## Date:        2002-07-22
45
## Purpose:     MOAB board hardware setup
46
## Description: This file contains any code needed to initialize the
47
##              hardware on a TAMS MOAB (PowerPC 405GPr) board.
48
##
49
######DESCRIPTIONEND####
50
##
51
##=============================================================================
52
 
53
#include 
54
#include                /* register symbols et al */
55
#define CYGARC_HAL_COMMON_EXPORT_CPU_MACROS
56
#include                /* on-chip resource layout, special */
57
 
58
#------------------------------------------------------------------------------
59
 
60
// No useable LEDs
61
#define LED(x)
62
 
63
//
64
// Various setup values - based on board revision &/or xtal speed
65
//
66
#if defined(CYG_HAL_MOAB_BOARD_REVISION_1_0)
67
#define MOAB_DCR_SDRAM0_RTR    0x05F00000
68
#define MOAB_DCR_SDRAM0_B1CR   0x00062001
69
#define MOAB_DCR_SDRAM0_B0CR   0x02062001
70
#define MOAB_DCR_SDRAM0_CFG    0x80800000
71
#elif defined(CYG_HAL_MOAB_BOARD_REVISION_1_1)
72
#define MOAB_DCR_SDRAM0_RTR    0x07F00000
73
#define MOAB_DCR_SDRAM0_B1CR   0x00084001
74
#define MOAB_DCR_SDRAM0_B0CR   0x00000000
75
#define MOAB_DCR_SDRAM0_CFG    0x80800000
76
#else
77
#error "Illegal board revision"
78
#endif
79
#if CYGHWR_HAL_POWERPC_CPU_SPEED == 250
80
#define MOAB_DCR_CPC0_CR0      0x09F8502A
81
#define MOAB_DCR_EBC0_B1AP     0x03840000
82
#elif CYGHWR_HAL_POWERPC_CPU_SPEED == 333
83
#define MOAB_DCR_CPC0_CR0      0x09F8503A
84
#define MOAB_DCR_EBC0_B1AP     0x05840000
85
#elif CYGHWR_HAL_POWERPC_CPU_SPEED == 300
86
#define MOAB_DCR_CPC0_CR0      0x0FF85034
87
#define MOAB_DCR_EBC0_B1AP     0x0A840000
88
#elif CYGHWR_HAL_POWERPC_CPU_SPEED == 400
89
#define MOAB_DCR_CPC0_CR0      0x0FF8503C
90
#define MOAB_DCR_EBC0_B1AP     0x0C840000
91
#else
92
#error "Illegal CPU speed"
93
#endif
94
#------------------------------------------------------------------------------
95
 
96
FUNC_START( hal_hardware_init )
97
        mflr    r30                        // Save return address
98
 
99
#ifndef CYG_HAL_STARTUP_RAM
100
 
101
        // Basic chip configuration
102
        lwi     r3,MOAB_DCR_CPC0_CR0
103
        mtdcr   DCR_CPC0_CR0,r3
104
        li      r3,0x00000000
105
        mtdcr   DCR_CPC0_CR1,r3
106
 
107
        lwi     r3,0x60606000            // Edge conditioning register
108
        mtdcr   DCR_CPC0_ECR,r3
109
 
110
        // Boot ROM access
111
        li      r3,DCR_EBC0_B0AP          // BOOT FLASH at 0xFFExxxxx, R/W
112
        lwi     r4,0x05010480
113
        mtdcr   DCR_EBC0_CFGADDR,r3
114
        mtdcr   DCR_EBC0_CFGDATA,r4
115
        li      r3,DCR_EBC0_B0CR
116
        lwi     r4,0xFFE38000
117
        mtdcr   DCR_EBC0_CFGADDR,r3
118
        mtdcr   DCR_EBC0_CFGDATA,r4
119
 
120
        // GPIO
121
        //   GPIO 13 - I - media present
122
        //   GPIO 14 - O - main flash ALE
123
        //   GPIO 15 - O - main flash CLE
124
        //   GPIO 16 - O/x - watchdog
125
        //   GPIO 17 - O - NAND CE
126
        //   GPIO 24 - O - heartbeat LED
127
        lwi     r4,GPIO_OR              // Leave NAND not-selected, heartbeat off
128
        lwi     r3,0x00004080
129
        stw     r3,0(r4)
130
        lwi     r4,GPIO_TCR             // Tri-state control - enables outputs
131
        lwi     r3,0x0003C080           // ... with watchdog enabled
132
        stw     r3,0(r4)
133
 
134
        li      r3,DCR_SDRAM0_CFG          // See if SDRAM already configured
135
        mtdcr   DCR_SDRAM0_CFGADDR,r3
136
        mfdcr   r4,DCR_SDRAM0_CFGDATA
137
        lwi     r3,MOAB_DCR_SDRAM0_CFG
138
        and     r4,r4,r3
139
        cmpw    r3,r4
140
        beq     sdram_ok
141
 
142
        li      r3,0x00000000              // Make sure nothing is cacheable
143
        mticcr  r3
144
        mtdccr  r3
145
        // Force data caches to be totally clean
146
        lwi     r3,0
147
        lwi     r4,0x8000
148
10:     dcbf    0,r3
149
        dccci   0,r3
150
        addi    r3,r3,16
151
        cmpw    r3,r4
152
        bne     10b
153
 
154
        // DRAM controller
155
        li      r3,DCR_SDRAM0_CFG            // Turn off controller to allow changes
156
        lwi     r4,0x00000000
157
        mtdcr   DCR_SDRAM0_CFGADDR,r3
158
        mtdcr   DCR_SDRAM0_CFGDATA,r4
159
        li      r3,DCR_SDRAM0_TR
160
        lwi     r4,0x010A800E
161
        mtdcr   DCR_SDRAM0_CFGADDR,r3
162
        mtdcr   DCR_SDRAM0_CFGDATA,r4
163
        li      r3,DCR_SDRAM0_RTR            // Refresh timing
164
        lwi     r4,MOAB_DCR_SDRAM0_RTR
165
        mtdcr   DCR_SDRAM0_CFGADDR,r3
166
        mtdcr   DCR_SDRAM0_CFGDATA,r4
167
        li      r3,DCR_SDRAM0_B1CR           // Note: non-ascending addresses because
168
                                             // the low 1/2 of memory fails on some boards
169
        lwi     r4,MOAB_DCR_SDRAM0_B1CR
170
        mtdcr   DCR_SDRAM0_CFGADDR,r3
171
        mtdcr   DCR_SDRAM0_CFGDATA,r4
172
        li      r3,DCR_SDRAM0_B0CR
173
        lwi     r4,MOAB_DCR_SDRAM0_B0CR
174
        mtdcr   DCR_SDRAM0_CFGADDR,r3
175
        mtdcr   DCR_SDRAM0_CFGDATA,r4
176
 
177
        lwi     r4,GPIO_OR                // Turn heartbeat LED on
178
        lwi     r3,0x00004000
179
        stw     r3,0(r4)
180
 
181
        lwi     r3,0xA000                 // Pause for at least 200us
182
        mtctr   r3
183
13:     nop
184
        bdnz    13b
185
 
186
        li      r3,DCR_SDRAM0_CFG         // Enable controller
187
        lwi     r4,MOAB_DCR_SDRAM0_CFG
188
        mtdcr   DCR_SDRAM0_CFGADDR,r3
189
        mtdcr   DCR_SDRAM0_CFGDATA,r4
190
 
191
sdram_ok:
192
        // Bus controller
193
        li      r3,DCR_EBC0_B1AP          // MAIN FLASH at 0xCxxxxxxx, R/W
194
        lwi     r4,MOAB_DCR_EBC0_B1AP
195
        mtdcr   DCR_EBC0_CFGADDR,r3
196
        mtdcr   DCR_EBC0_CFGDATA,r4
197
        li      r3,DCR_EBC0_B1CR
198
        lwi     r4,0xC0018000             // 1MB, 8bits [actually only 1 byte!]
199
        mtdcr   DCR_EBC0_CFGADDR,r3
200
        mtdcr   DCR_EBC0_CFGDATA,r4
201
 
202
        // On-chip memory
203
        lwi     r4,0xD0000000            // Instruction/Data at 0xD0XXXXXX..0xD7XXXXXX
204
        lwi     r3,0x80000000
205
        mtdcr   DCR_OCM0_ISARC,r4
206
        mtdcr   DCR_OCM0_DSARC,r4
207
        mtdcr   DCR_OCM0_ISCNTL,r3
208
        mtdcr   DCR_OCM0_DSCNTL,r3
209
 
210
        lwi     r4,GPIO_OR              // Turn heartbeat LED off
211
        lwi     r3,0x0000C080
212
        stw     r3,0(r4)
213
        lwi     r4,GPIO_TCR             // Tri-state control - enables outputs
214
        lwi     r3,0x00034080           // ... with watchdog disabled
215
        stw     r3,0(r4)
216
 
217
#endif  // ROM or ROMRAM startup
218
 
219
        lwi     r3,0x80000001              // DRAM can be cached - instructions only
220
        iccci   0,r3
221
        mticcr  r3
222
        lwi     r3,0x00000000
223
        mtdccr  r3
224
 
225
#ifdef CYG_HAL_STARTUP_ROMRAM
226
        // Copy image from ROM to RAM
227
        mr      r6,r30
228
        lwi     r7,0xFFF80000
229
        and     r6,r6,r7
230
        subi    r6,r6,4
231
        lwi     r7,0-4            // where to copy to
232
        lwi     r8,__ram_data_end
233
10:     lwzu    r5,4(r6)
234
        stwu    r5,4(r7)
235
        cmplw   r7,r8
236
        bne     10b
237
        lwi     r30,_hal_hardware_init_done
238
#endif
239
 
240
        lwi     r4,GPIO_OR              // Turn heartbeat LED on
241
        lwi     r3,0x00004000
242
        stw     r3,0(r4)
243
 
244
        mtlr    r30             // Restore return address
245
        blr
246
FUNC_END( hal_hardware_init )
247
 
248
        .globl  _hang
249
_hang:   nop
250
        b       _hang
251
        blr
252
 
253
#if 0
254
        .text
255
        .globl  _get_cache_contents
256
_get_cache_contents:
257
        subi    r3,r3,4
258
        li      r4,256
259
        mtctr   r4
260
        li      r4,0        // Address
261
        lwi     r7,0xFFFFFFE0
262
        mfspr   r5,SPR_CCR0
263
10:     and     r5,r5,r7        // CIS=0,CWS=0 =>  DATA, WAY A
264
        mtspr   SPR_CCR0,r5
265
        sync
266
        isync
267
        dcread  r6,0,r4
268
        stwu    r6,4(r3)
269
        and     r5,r5,r7        // CIS=0,CWS=1 =>  DATA, WAY B
270
        ori     r5,r5,0x01
271
        mtspr   SPR_CCR0,r5
272
        sync
273
        isync
274
        mfspr   r5,SPR_CCR0
275
        dcread  r6,0,r4
276
        stwu    r6,4(r3)
277
        and     r5,r5,r7        // CIS=1,CWS=0 =>  TAG, WAY A
278
        ori     r5,r5,0x10
279
        mtspr   SPR_CCR0,r5
280
        sync
281
        isync
282
        dcread  r6,0,r4
283
        stwu    r6,4(r3)
284
        and     r5,r5,r7        // CIS=1,CWS=1 =>  TAG, WAY B
285
        ori     r5,r5,0x11
286
        mtspr   SPR_CCR0,r5
287
        sync
288
        isync
289
        dcread  r6,0,r4
290
        stwu    r6,4(r3)
291
        addi    r4,r4,32
292
        bdnz    10b
293
        blr
294
#endif
295
 
296
#ifndef CYG_HAL_STARTUP_RAM
297
        .section        ".reset_vector","ax"
298
        ba      0xFFF80100
299
        .previous
300
#endif
301
 
302
#------------------------------------------------------------------------------
303
# end of moab.S

powered by: WebSVN 2.1.0

© copyright 1999-2025 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.