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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [mips/] [rm7000/] [ocelot/] [v2_0/] [src/] [platform.S] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
##=============================================================================
2
##
3
##      platform.S
4
##
5
##      MIPS Ocelot platform code
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 Red Hat, 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 version.
16
##
17
## eCos is distributed in the hope that it will be useful, but WITHOUT ANY
18
## WARRANTY; without even the implied warranty of MERCHANTABILITY or
19
## FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
20
## for more details.
21
##
22
## You should have received a copy of the GNU General Public License along
23
## with eCos; if not, write to the Free Software Foundation, Inc.,
24
## 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
25
##
26
## As a special exception, if other files instantiate templates or use macros
27
## or inline functions from this file, or you compile this file and link it
28
## with other works to produce a work based on this file, this file does not
29
## by itself cause the resulting work to be covered by the GNU General Public
30
## License. However the source code for this file must still be made available
31
## in accordance with section (3) of the GNU General Public License.
32
##
33
## This exception does not invalidate any other reasons why a work based on
34
## this file might be covered by the GNU General Public License.
35
##
36
## Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
37
## at http://sources.redhat.com/ecos/ecos-license/
38
## -------------------------------------------
39
#####ECOSGPLCOPYRIGHTEND####
40
##=============================================================================
41
#######DESCRIPTIONBEGIN####
42
##
43
## Author(s):   nickg
44
## Contributors:nickg, jskov
45
## Date:        2000-05-09
46
## Purpose:     MIPS Ocelot platform code
47
## Description: Platform specific code for Ocelot board.
48
##
49
######DESCRIPTIONEND####
50
##
51
##=============================================================================
52
 
53
         .set    noreorder
54
 
55
#include 
56
#include 
57
 
58
#ifdef CYGPKG_KERNEL
59
# include 
60
#endif
61
 
62
#include 
63
#include 
64
#include 
65
 
66
##-----------------------------------------------------------------------------
67
## MEMC initialization.
68
 
69
## This code is table driven, which is somewhat more compact that coding it
70
## all.
71
## Table entries consist of an address and a value to store in that address.
72
## A zero address terminates the table. Two special address values modify the
73
## behaviour:
74
## DELAY_LOOP   loops for the number of iterations in the value field.
75
## WRITE16      treats the next 2 words as an address and value to be written
76
##              with a 16 bit write cycle.
77
 
78
#define HAL_GALILEO_CONTROLLER_BASE 0xb4000000
79
#define GL_CPU_CFG           0xb4000000
80
#define GL_CPU_CFG_WRITERATE 0x00010000
81
 
82
#define GL_DEV_PAR_BANK0     0xb400045c
83
#define GL_DEV_PAR_BANK1     0xb4000460
84
#define GL_DEV_PAR_BANK2     0xb4000464
85
#define GL_DEV_PAR_BANK3     0xb4000468
86
#define GL_DEV_PAR_BOOT      0xb400046c
87
 
88
#define GL_SDRAM_CFG         0xb4000448
89
#define GL_SDRAM_CFG_REF_INT_CNT_default 0x00000200
90
#define GL_SDRAM_CFG_CPU_TO_DRAM_ERR     0x00020000
91
#define GL_SDRAM_CFG_ECC_INT             0x00040000
92
#define GL_SDRAM_CFG_DUP_BA              0x00100000
93
#define GL_SDRAM_CFG_REG_SDRAM           0x00800000
94
#define GL_SDRAM_CFG_DADR_12_SEL         0x01000000
95
#define GL_SDRAM_CFG_init (GL_SDRAM_CFG_REF_INT_CNT_default| \
96
                           GL_SDRAM_CFG_CPU_TO_DRAM_ERR|     \
97
                           GL_SDRAM_CFG_ECC_INT|             \
98
                           GL_SDRAM_CFG_DUP_BA|              \
99
                           GL_SDRAM_CFG_REG_SDRAM|           \
100
                           GL_SDRAM_CFG_DADR_12_SEL)
101
 
102
#define GL_SDRAM_PAR_BANK0   0xb400044c
103
#define GL_SDRAM_PAR_BANK2   0xb4000454
104
#define GL_CPU_SCS10_LO      0xb4000008
105
#define GL_CPU_SCS10_HI      0xb4000010
106
#define GL_CPU_SCS32_LO      0xb4000018
107
#define GL_CPU_SCS32_HI      0xb4000020
108
 
109
#define GL_SDRAM_SCS0_LO     0xb4000400
110
#define GL_SDRAM_SCS0_HI     0xb4000404
111
#define GL_SDRAM_SCS1_LO     0xb4000408
112
#define GL_SDRAM_SCS1_HI     0xb400040c
113
#define GL_SDRAM_SCS2_LO     0xb4000410
114
#define GL_SDRAM_SCS2_HI     0xb4000414
115
#define GL_SDRAM_SCS3_LO     0xb4000418
116
#define GL_SDRAM_SCS3_HI     0xb400041c
117
 
118
#define GL_SDRAM_MODE        0xb4000474
119
#define GL_SDRAM_MODE_NORMAL 0x00000000
120
#define GL_SDRAM_MODE_ENABLE 0x00000003
121
 
122
#define PLD_BOARD_STAT       0xbc000004
123
#define PLD_INT_SET          0xbc00000c
124
#define PLD_INT_CLEAR        0xbc00000d
125
#define PLD_INT_SET_USER_LED 0x40
126
 
127
#define CPU_TO_LE(x) (((x & 0xff) << 24) | ((x & 0xff00) << 8) | ((x & 0xff0000) >> 8) | ((x >> 24) & 0xff))
128
 
129
#define HAL_OCELOT_RAM_BASE                      0x00000000
130
 
131
#define HAL_GALILEO_CPU_DECODE_SHIFT            21
132
#define HAL_GALILEO_DEV_DECODE_SHIFT            20
133
 
134
#define HAL_GALILEO_SCS10_LD_OFFSET             0x008
135
#define HAL_GALILEO_SCS10_HD_OFFSET             0x010
136
#define HAL_GALILEO_SCS32_LD_OFFSET             0x018
137
#define HAL_GALILEO_SCS32_HD_OFFSET             0x020
138
 
139
#define HAL_GALILEO_SCS0_LD_OFFSET              0x400
140
#define HAL_GALILEO_SCS0_HD_OFFSET              0x404
141
#define HAL_GALILEO_SCS1_LD_OFFSET              0x408
142
#define HAL_GALILEO_SCS1_HD_OFFSET              0x40c
143
#define HAL_GALILEO_SCS2_LD_OFFSET              0x410
144
#define HAL_GALILEO_SCS2_HD_OFFSET              0x414
145
#define HAL_GALILEO_SCS3_LD_OFFSET              0x418
146
#define HAL_GALILEO_SCS3_HD_OFFSET              0x41c
147
 
148
#if !defined(CYG_HAL_STARTUP_RAM)
149
 
150
#define DELAY_LOOP      1
151
#define WRITE16         2
152
 
153
 
154
#define swap(v, t1, t2, t3)                     \
155
        lui  t1,0xff;                           \
156
        andi t2,v,0xff00;                       \
157
        and  t3,v,t1;                           \
158
        sll  t1,v,0x18;                         \
159
        srl  v,v,0x18;                          \
160
        or   v,v,t1;                            \
161
        srl  t3,t3,0x08;                        \
162
        sll  t2,t2,0x08;                        \
163
        or   v,v,t3;                            \
164
        or   v,v,t2;
165
 
166
 
167
FUNC_START(hal_memc_setup)
168
        lar     t0,hal_memc_setup_table
169
        la      t1,0xbfc00000
170
        la      t2,DELAY_LOOP
171
        la      t3,WRITE16
172
1:
173
        lw      a0,0(t0)        # next table entry
174
        lw      a1,4(t0)        # value to write
175
        addiu   t0,8            # go to next entry
176
        beq     a0,t2,2f        # Check for delay
177
         nop
178
        beq     a0,t3,3f        # Check for 16 bit write
179
         nop
180
        beqz    a0,9f           # zero terminates loop
181
         nop
182
        sw      a1,0(a0)        # write it
183
        lw      zero,0(t1)      # uncached read to flush write buffer
184
        b       1b
185
         nop
186
2:
187
        lw      zero,0(t1)      # uncached read to flush write buffer
188
        bnez    a1,2b           # count down by value in a1
189
         addiu   a1,-1          # decrement in delay slot
190
        b       1b              # go back to loop
191
         nop
192
3:
193
        lw      a3,0(t0)        # get next word
194
        addiu   t0,4            # skip it
195
        sh      a3,0(a1)        # store halfword
196
        lw      zero,0(t1)      # uncached read to flush write buffer
197
        b       1b
198
         nop
199
9:
200
 
201
        // Complete the SDRAM setup.
202
        la      t0,GL_SDRAM_MODE
203
        la      t1,CPU_TO_LE(GL_SDRAM_MODE_ENABLE)
204
        sw      t1,0(t0)
205
        //  Wait 100us after writing mode
206
        la      a1,(CYGHWR_HAL_MIPS_RM7000_CPU_CLOCK * 100 / 1000000)
207
 
208
        lui     a0,0xa000       // uncached bank0 device
209
        sw      zero,0(a0)
210
 
211
        mtc0    zero,$9
212
1:      mfc0    a0,$9
213
        nop
214
        blt     a0, a1, 1b
215
         nop
216
 
217
        lui     a0,0xa080       // uncached bank2 device
218
        sw      zero,0(a0)
219
 
220
        mtc0    zero,$9
221
1:      mfc0    a0,$9
222
        nop
223
        blt     a0, a1, 1b
224
         nop
225
 
226
        la      t0,GL_SDRAM_MODE
227
        la      t1,CPU_TO_LE(GL_SDRAM_MODE_NORMAL)
228
        sw      t1,0(t0)
229
 
230
        // Set CPU cfg word
231
        la      a0,GL_CPU_CFG
232
        lw      a1,0(a0)
233
        la      t0,CPU_TO_LE(0x20000)
234
        or      a1,a1,t0        // disable retries
235
 
236
        // CPU WriteRate - set GT to match CPU
237
        mfc0    t0,$16
238
        la      t1, 0x0f000000
239
        and     t0, t0, t1
240
        beqz    t0,1f           // defaults to zero
241
         nop
242
        la      t0, CPU_TO_LE(GL_CPU_CFG_WRITERATE)
243
        or      a1, a1, t0
244
1:
245
        sw      a1,0(a0)
246
 
247
        # FIXME: Hardwired for 256MB - need kuseg magic to map full 512MB.
248
        #
249
        # Setup SDRAM Bank 0 Address Decoding
250
        #
251
        la      s7, HAL_GALILEO_CONTROLLER_BASE
252
        la      a0, HAL_OCELOT_RAM_BASE                 # Phys bottom of Bank 0
253
        la      a1, (HAL_OCELOT_RAM_BASE+128*1024*1024)
254
        subu    a1, 1                                   # Phys top of Bank0
255
 
256
        srl     t0, a0, HAL_GALILEO_CPU_DECODE_SHIFT    # Setup SCS[1:0]
257
        swap(t0,t1,t2,t3)                               #   1st level decoding
258
        sw      t0, HAL_GALILEO_SCS10_LD_OFFSET(s7)     #   (CPU Decode Region)
259
        srl     t0, a1, HAL_GALILEO_CPU_DECODE_SHIFT    #
260
        swap(t0,t1,t2,t3)
261
        sw      t0, HAL_GALILEO_SCS10_HD_OFFSET(s7)     #
262
 
263
        srl     t0, a0, HAL_GALILEO_DEV_DECODE_SHIFT    # Setup SCS0
264
        swap(t0,t1,t2,t3)                               #   2nd level decoding
265
        sw      t0, HAL_GALILEO_SCS0_LD_OFFSET(s7)      #   (Device Sub-decode Region)
266
        srl     t0, a1, HAL_GALILEO_DEV_DECODE_SHIFT    #
267
        swap(t0,t1,t2,t3)
268
        sw      t0, HAL_GALILEO_SCS0_HD_OFFSET(s7)      #
269
 
270
        #
271
        # Setup SDRAM Bank 1 Address Decoding
272
        #
273
        la      a0, (HAL_OCELOT_RAM_BASE+128*1024*1024) # Phys bottom of Bank 1
274
        la      a1, (HAL_OCELOT_RAM_BASE+256*1024*1024)
275
        subu    a1, 1                                   # Phys top of Bank1
276
 
277
        srl     t0, a0, HAL_GALILEO_CPU_DECODE_SHIFT    # Setup SCS[3:2]
278
        swap(t0,t1,t2,t3)                               #   1st level decoding
279
        sw      t0, HAL_GALILEO_SCS32_LD_OFFSET(s7)     #   (CPU Decode Region)
280
        srl     t0, a1, HAL_GALILEO_CPU_DECODE_SHIFT    #
281
        swap(t0,t1,t2,t3)
282
        sw      t0, HAL_GALILEO_SCS32_HD_OFFSET(s7)     #
283
 
284
        srl     t0, a0, HAL_GALILEO_DEV_DECODE_SHIFT    # Setup SCS2
285
        swap(t0,t1,t2,t3)                               #   2nd level decoding
286
        sw      t0, HAL_GALILEO_SCS2_LD_OFFSET(s7)      #   (Device Sub-decode Region)
287
        srl     t0, a1, HAL_GALILEO_DEV_DECODE_SHIFT    #
288
        swap(t0,t1,t2,t3)
289
        sw      t0, HAL_GALILEO_SCS2_HD_OFFSET(s7)      #
290
 
291
        jr      ra
292
         nop
293
 
294
FUNC_END(hal_memc_setup)
295
 
296
##-----------------------------------------------------------------------------
297
## The initialization table
298
 
299
hal_memc_setup_table:
300
 
301
        .long   DELAY_LOOP,       10000 # Wait for HW to settle
302
 
303
        .long   GL_DEV_PAR_BANK0, CPU_TO_LE(0x000b6b33) // PLD
304
        .long   GL_DEV_PAR_BANK1, CPU_TO_LE(0x000bad53) // NVRAM
305
        .long   GL_DEV_PAR_BANK2, CPU_TO_LE(0x000bad54) // UART
306
        .long   GL_DEV_PAR_BANK3, CPU_TO_LE(0x000fef73) // flash disk
307
        .long   GL_DEV_PAR_BOOT,  CPU_TO_LE(0x144bee63) // boot flash
308
 
309
        .long   GL_SDRAM_CFG, CPU_TO_LE(GL_SDRAM_CFG_init)
310
        .long   GL_SDRAM_PAR_BANK0, CPU_TO_LE(0x00000c69 | 0x4000)
311
        .long   GL_SDRAM_PAR_BANK2, CPU_TO_LE(0x00000c69 | 0x4000)
312
 
313
        .long   GL_CPU_SCS10_LO, CPU_TO_LE(0x00000000)
314
        .long   GL_CPU_SCS10_HI, CPU_TO_LE(0x00000003)
315
        .long   GL_CPU_SCS32_LO, CPU_TO_LE(0x00000004)
316
        .long   GL_CPU_SCS32_HI, CPU_TO_LE(0x00000007)
317
 
318
        .long   GL_SDRAM_SCS0_LO, CPU_TO_LE(0x00000000)
319
        .long   GL_SDRAM_SCS0_HI, CPU_TO_LE(0x00000007)
320
        .long   GL_SDRAM_SCS1_LO, CPU_TO_LE(0x000000ff)
321
        .long   GL_SDRAM_SCS1_HI, CPU_TO_LE(0x00000000)
322
        .long   GL_SDRAM_SCS2_LO, CPU_TO_LE(0x00000008)
323
        .long   GL_SDRAM_SCS2_HI, CPU_TO_LE(0x0000000f)
324
        .long   GL_SDRAM_SCS3_LO, CPU_TO_LE(0x000000ff)
325
        .long   GL_SDRAM_SCS3_HI, CPU_TO_LE(0x00000000)
326
 
327
        .long   0, 0
328
 
329
#endif // !CYG_HAL_STARTUP_RAM
330
 
331
##-----------------------------------------------------------------------------
332
## ISR tables.
333
 
334
        .extern hal_default_isr
335
 
336
        .data
337
 
338
#ifdef CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN
339
        .globl  hal_interrupt_handlers
340
hal_interrupt_handlers:
341
        .long   hal_default_isr         # chaining vector
342
 
343
        .globl  hal_interrupt_data
344
hal_interrupt_data:
345
        .long   0                       # chaining vector data
346
 
347
        .globl  hal_interrupt_objects
348
hal_interrupt_objects:
349
        .long   0                       # chaining vector object
350
 
351
        .globl  cyg_hal_interrupt_level
352
cyg_hal_interrupt_level:
353
        .rept   CYGNUM_HAL_ISR_COUNT
354
        .byte   0
355
        .endr
356
 
357
#else // CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN
358
 
359
        .globl  hal_interrupt_handlers
360
hal_interrupt_handlers:
361
        .long   hal_default_isr
362
        .long   hal_default_isr
363
        .long   hal_default_isr
364
        .long   hal_default_isr
365
        .long   hal_default_isr
366
        .long   hal_default_isr
367
        .long   hal_default_isr
368
        .long   hal_default_isr
369
        .long   hal_default_isr
370
        .long   hal_default_isr
371
 
372
        .rept   CYGNUM_HAL_ISR_COUNT-10
373
        .long   hal_default_isr
374
        .endr
375
 
376
        .globl  hal_interrupt_data
377
hal_interrupt_data:
378
        .long   0
379
        .long   0
380
        .long   0
381
        .long   0
382
        .long   0
383
        .long   0
384
        .long   0
385
        .long   0
386
        .long   0
387
        .long   0
388
 
389
        .rept   CYGNUM_HAL_ISR_COUNT-10
390
        .long   0
391
        .endr
392
 
393
        .globl  hal_interrupt_objects
394
hal_interrupt_objects:
395
        .rept   CYGNUM_HAL_ISR_COUNT
396
        .long   0
397
        .endr
398
 
399
        .globl  cyg_hal_interrupt_level
400
cyg_hal_interrupt_level:
401
        .rept   CYGNUM_HAL_ISR_COUNT
402
        .byte   0
403
        .endr
404
 
405
#endif // CYGIMP_HAL_COMMON_INTERRUPTS_CHAIN
406
 
407
##-----------------------------------------------------------------------------
408
## end of platform.S

powered by: WebSVN 2.1.0

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