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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-2.0/] [packages/] [hal/] [arm/] [arm9/] [innovator/] [v2_0/] [include/] [hal_platform_setup.h] - Blame information for rev 174

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 27 unneback
#ifndef CYGONCE_HAL_PLATFORM_SETUP_H
2
#define CYGONCE_HAL_PLATFORM_SETUP_H
3
//=============================================================================
4
//
5
//      hal_platform_setup.h
6
//
7
//      Platform specific support for HAL (assembly code)
8
//
9
//=============================================================================
10
//####ECOSGPLCOPYRIGHTBEGIN####
11
// -------------------------------------------
12
// This file is part of eCos, the Embedded Configurable Operating System.
13
// Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
14
//
15
// eCos is free software; you can redistribute it and/or modify it under
16
// the terms of the GNU General Public License as published by the Free
17
// Software Foundation; either version 2 or (at your option) any later version.
18
//
19
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
20
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
21
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
22
// for more details.
23
//
24
// You should have received a copy of the GNU General Public License along
25
// with eCos; if not, write to the Free Software Foundation, Inc.,
26
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
27
//
28
// As a special exception, if other files instantiate templates or use macros
29
// or inline functions from this file, or you compile this file and link it
30
// with other works to produce a work based on this file, this file does not
31
// by itself cause the resulting work to be covered by the GNU General Public
32
// License. However the source code for this file must still be made available
33
// in accordance with section (3) of the GNU General Public License.
34
//
35
// This exception does not invalidate any other reasons why a work based on
36
// this file might be covered by the GNU General Public License.
37
//
38
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
39
// at http://sources.redhat.com/ecos/ecos-license/
40
// -------------------------------------------
41
//####ECOSGPLCOPYRIGHTEND####
42
//=============================================================================
43
//#####DESCRIPTIONBEGIN####
44
//
45
// Author(s):    Patrick Doyle <wpd@delcomsys.com>
46
// Contributors: Patrick Doyle <wpd@delcomsys.com>
47
// Date:         2002-12-02
48
// Purpose:      Innovator platform specific support routines
49
// Description: 
50
// Usage:        #include <cyg/hal/hal_platform_setup.h>
51
//     Only used by "vectors.S"         
52
//
53
//####DESCRIPTIONEND####
54
//
55
//=============================================================================
56
 
57
#include <pkgconf/system.h>             // System-wide configuration info
58
#include CYGBLD_HAL_VARIANT_H           // Variant specific configuration
59
#include CYGBLD_HAL_PLATFORM_H          // Platform specific configuration
60
#include CYGHWR_MEMORY_LAYOUT_H
61
#include <cyg/hal/hal_mmu.h>            // MMU definitions
62
#include <cyg/hal/innovator.h>          // Platform specific hardware definitions
63
 
64
#define nDEBUG
65
 
66
#if defined(CYG_HAL_STARTUP_ROM)
67
#define PLATFORM_SETUP1 _platform_setup1
68
#define CYGHWR_HAL_ARM_HAS_MMU
69
#define CYGSEM_HAL_ROM_RESET_USES_JUMP
70
 
71
// This is a trick.  If the first two words of SRAM are 0x12345678 and
72
// 0x87654321, then, then the reset routine in FLASH branches to the
73
// third location in SRAM.  This allows us to test startup code (which may
74
// be broken) without writing it to FLASH and rendering the board useless.
75
// (Well, not permanently useless.  Just useless until we track down an
76
// emulator and reload a working copy of RedBoot.)  The nifty thing with
77
// the innovator is that, if you press and hold the reset button for
78
// 2 seconds it triggers a power-on-reset.  The contents of the internal
79
// SRAM are maintained across such a reset.  Thus, we can write our
80
// new test version of RedBoot to SRAM (configured with CYGPRI_HAL_ROM_MLT
81
// set to SRAM) (more on that later), press and hold the reset button,
82
// and see if the new startup code works.
83
//
84
// Now for some notes about this
85
// 1) I am guessing about the "2 seconds" part.  If you press and hold
86
//    the reset button long enough, the FPGA triggers a power-on-reset.
87
//
88
// 2) In order to test the SRAM version of RedBoot, import the
89
//    redboot_SRAM.ecm file (instead of redboot_RAM.ecm or redboot_ROM.ecm)
90
//    and build RedBoot.  If you already have RedBoot in FLASH, you can
91
//    use that to load redboot.bin with a base address of 0x20000000.
92
//    You will be prompted with a "Gee, I don't think 0x20000000 is
93
//    a valid address in RAM, are you sure you want to do this?" message.
94
//    You should answer "Yes".  Here is the command I use:
95
//
96
//    RedBoot> load -v -r -b 0x20000000 redboot.bin
97
//
98
//    You can also use the "sloader" application (loaded via
99
//    Code Composer Studio) to to load the S-Record file for the SRAM
100
//    version of RedBoot.
101
//
102
// 3) I may have seen a case where the code tested fine in SRAM, but didn't
103
//    work when I placed it in FLASH.  But other things could have been
104
//    going on.
105
 
106
#ifdef CYGPRI_HAL_ROM_MLT_SRAM
107
#define PLATFORM_PREAMBLE _platform_preamble
108
        .macro  _platform_preamble
109
        .long   0x12345678
110
        .long   0x87654321
111
        .endm
112
#endif
113
 
114
 
115
#if defined(DEBUG) && !defined(CYGPRI_HAL_ROM_MLT_SRAM)
116
// Don't enable these macro when we are executing from SRAM because
117
// they overwrite SRAM.
118
 
119
#define FAKE_LED_MACRO_SETUP                    \
120
        ldr     r0,=0x20000000;                 \
121
        ldr     r1,[r0];                        \
122
        subs    r2,r1,#0x20000000;              \
123
        movlo   r1,#0x20000000;                 \
124
        ldr     r4,=0x2002fff8;                 \
125
        subs    r2,r1,r4;                       \
126
        movhi   r1,#0x20000000;                 \
127
        bic     r1,r1,#0x3;                     \
128
        add     r1,r1,#4;                       \
129
        str     r1, [r0];
130
 
131
#define FAKE_LED_MACRO(n)                       \
132
        ldr     r11,=0x20000000;                \
133
        ldr     r11,[r11];                      \
134
        ldr     r12,=n;                         \
135
        str     r12,[r11]
136
#else
137
#define FAKE_LED_MACRO_SETUP
138
#define FAKE_LED_MACRO(n)
139
#endif
140
 
141
// This macro represents the initial startup code for the platform        
142
        .macro  _platform_setup1
143
        // See if we should branch to an application stored in
144
        // internal SRAM.  We do this by checking for a magic cookie
145
        // in the first two locations of SRAM and jumping to the
146
        // third location in SRAM if we find it (after zeroing those
147
        // two locations so we don't create an infinite reboot loop).
148
        ldr     r0,=0x12345678
149
        ldr     r1,=0x87654321
150
        ldr     r2,=0x20000000
151
        ldr     r3,[r2]
152
        cmp     r3,r0
153
        ldr     r3,[r2,#4]
154
        cmpeq   r3,r1
155
        ldr     r3,=0
156
        streq   r3,[r2],#4
157
        streq   r3,[r2],#4
158
        moveq   pc,r2
159
 
160
        FAKE_LED_MACRO_SETUP
161
        FAKE_LED_MACRO(1)
162
 
163
        //#define PLATFORM_SETUP_FROM_CCS_GEL_SCRIPT
164
#ifdef PLATFORM_SETUP_FROM_CCS_GEL_SCRIPT       
165
        // This is the version of _platform_setup adapted from the contents
166
        // of the GEL script shipped with Code Composer Studio
167
 
168
        // This is all stolen from the ipaq setup
169
 
170
        // Make sure MMU is OFF
171
        mov r0,#INTERNAL_SRAM_BASE // Force cache writeback by reloading
172
        add r2,r0,#0x2000          // cache from the internal memory bank
173
123:    ldr r1,[r0],#16
174
        cmp r0, r2
175
        bne 123b
176
        mov r0,#0
177
        mov r1,#0x0070          // MMU Control System bit
178
        mcr p15,0,r0,c7,c7,0      // Flush data and instruction cache
179
        mcr p15,0,r0,c8,c7,0      // Flush ID TLBs
180
        mcr p15,0,r0,c9,c0,0      // Flush Read-Buffer
181
        mcr p15,0,r0,c7,c10,4    // Drain write buffer
182
        mcr p15,0,r0,c13,c0,0     // Disable virtual ID mapping
183
        mcr p15,0,r1,c1,c0,0      // Write MMU control register
184
        nop; nop; nop; nop
185
 
186
        mov     r0,#(CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE|CPSR_SUPERVISOR_MODE)
187
        msr     cpsr,r0
188
 
189
        // The rest of this is stolen from "init.c" in the sloader program.
190
        // FIXME -- add configury
191
        // Set up DPLL1:
192
        // (reserved)                                 00
193
        // IOB        = 1     Initialize on break       1
194
        // (reserved)                                    0
195
        // PLL_MULT   = 5     60 MHz clock                 0010 1
196
        // PLL_DIV    = 00:   CLKOUT = CLKREF                    00
197
        // PLL_ENABLE = 1     Enable DPLL                          1
198
        // BYPASS_DIV = 00:   CLKOUT = CLKREF                        00
199
        // (read only)                                                 00
200
        //
201
        // 0x2290:                                    0010 0010 1001 0000
202
        //
203
 
204
        ldr     r1,=DPLL1_BASE
205
        ldr     r2,=0x2290
206
        str     r2,[r1,#_DPLL_CTL_REG]
207
  /* Wait for lock */
208
1:      ldr     r2,[r1,#_DPLL_CTL_REG]
209
        and     r2,r2,#1
210
        cmp     r2,#1
211
        bne     1b
212
 
213
  /* memif_init() */
214
  /* Configure ARM9 Memory Interface */
215
  /* Set up CS0 for memory & bus size of 16 bits, asynchronous read,
216
   * 3 wait states, and a divide by 2 clock.
217
   * Set up CS1, CS2, & CS3 the same way, except with 1 wait state.
218
   */
219
/*
220
  TC_EMIFS_CS0_CONFIG   = 0x00003339;
221
  TC_EMIFS_CS1_CONFIG   = 0x00001139;
222
  TC_EMIFS_CS2_CONFIG   = 0x00001139;
223
  TC_EMIFS_CS3_CONFIG   = 0x00001139;
224
*/
225
        ldr     r1,=TC_BASE
226
        ldr     r2,=0x3339
227
        str     r2,[r1,#0x10]
228
        ldr     r2,=0x1149
229
        str     r2,[r1,#0x14]
230
        ldr     r2,=0x1139
231
        str     r2,[r1,#0x18]
232
        str     r2,[r1,#0x1c]
233
 
234
  /* Configure the SDRAM */
235
  /* EMIFF (nCS4) configuration */
236
  /* TC_EMIFF_SDRAM_CONFIG = 0x000100F4; */
237
  /* MRS (nCS4) initialization  */
238
  /* TC_EMIFF_MRS          = 0x00000037; */
239
        ldr     r2,=0x000100F4
240
        str     r2,[r1,#0x20]
241
        ldr     r2,=0x00000037
242
        str     r2,[r1,#0x24]
243
 
244
  /* Disable ARM9 Watchdog Timer by writing the special sequence to it */
245
/*
246
  WATCHDOG_TIMER_MODE = 0x00F5;
247
  WATCHDOG_TIMER_MODE = 0x00A0;
248
*/
249
        ldr     r1,=WATCHDOG_BASE
250
        ldr     r2,=0xF5
251
        strh    r2,[r1,#0x08]
252
        ldr     r2,=0xA0
253
        strh    r2,[r1,#0x08]
254
  /* Select the 12MHz oscillator for the frequency reference for the
255
   * internal timers.  I am doing this today (12/19/02) to simplify my
256
   * life -- This way, I don't care what the clock rate of the core is.
257
   */
258
        ldr     r1,=CLKM_BASE
259
        ldrh    r2,[r1,#0x00]   // ARM_CKCTL
260
        bic     r2,r2,#0x1000   // Set ARM_TIMXO = 0
261
        strh    r2,[r1,#0x00]
262
 
263
  /* Enable the MPUXOR_CK by:
264
   * "MPUXOR_CK ... is derived from CK_REF ... and is enabled by EN_XORPCK"
265
   *
266
   * EN_XORPCK is bit 1 of ARM_IDLECT2
267
   */
268
/*
269
  CLKM_ARM_IDLECT2 |= 0x0002;
270
*/
271
        ldrh    r2,[r1,#0x08]
272
        orr     r2,r2,#0x0082   // Bits 7 (EN_TIMCK) and 1 (EN_XORPCK)
273
        strh    r2,[r1,#0x08]
274
 
275
  /* Then set the PER_EN bit to 1
276
   *
277
   * PER_EN is bit 0 of ARM_RSTCT2
278
   */
279
/*
280
  CLKM_ARM_RSTCT2 |= 0x0001;
281
*/
282
        ldrh    r2,[r1,#0x14]
283
        orr     r2,r2,#0x0001
284
        strh    r2,[r1,#0x14]
285
 
286
  /* Set the "BT_UART_GATING" bit to 1 in the FUNC_MUX_CTRL_0 register.
287
   * This enables the TX1 and RTS1 pins.
288
   */
289
/*
290
  CONFIG_FUNC_MUX_CTRL_0 |= BIT_25;
291
*/
292
        ldr     r1,=CONFIG_BASE
293
        ldr     r3,=0x02000000
294
        ldr     r2,[r1,#0x00]
295
        orr     r2,r2,r3
296
        str     r2,[r1,#0x00]
297
 
298
  /* Set bit 6 of the FPGA Power Control Register.  If I could find some
299
   * documentation on this, I could explain better why I am doing this, but
300
   * for now, emperical evidence suggests that this disables the "shutdown"
301
   * signal to the RS232 level shifter.
302
   */
303
/*
304
  FPGA_PWR_CTRL_REG |= BIT_06;
305
*/
306
        ldr     r1,=FPGA_BASE
307
        ldrb    r2,[r1,#0x05]
308
        orr     r2,r2,#0x20
309
#ifdef ADD_COMPATIBILITY_FOR_THE_EVM_SOMEDAY
310
        orr     r2,r2,#0x40
311
#endif
312
        strb    r2,[r1,#0x05]
313
 
314
        // Set up a stack [for calling C code]
315
#if defined(CYG_HAL_STARTUP_SLOADER) || defined(CYG_HAL_STARTUP_ROM)
316
        // The startup stack is in internal SRAM
317
        ldr     sp,=__startup_stack
318
        // This _MOST_DEFINATELY_ needs to be fixed
319
        orr     sp,sp,#0x10000000
320
#else
321
        // The startup stack is in SDRAM, at some virtual address, but
322
        // we have not set up the MMU yet, so we need to initialize SP
323
        // with the physical address of '__startup_stack'
324
#error "Somehow"
325
#endif
326
        bl      hal_mmu_init
327
 
328
        // Enable MMU
329
        ldr     r2,=10f
330
        ldr     r1,=MMU_Control_Init|MMU_Control_M
331
        mcr     MMU_CP,0,r1,MMU_Control,c0
332
        mov     pc,r2
333
 
334
        //        mcr     MMU_CP,0,r0,MMU_InvalidateCache,c7,0  // Flush data and instruction cache
335
        //      mcr     MMU_CP,0,r0,MMU_TLB,c7,0                // Flush ID TLBs
336
10:
337
        nop
338
        nop
339
        nop
340
 
341
#if 0
342
        ldr     r3,=0x20000000
343
        str     r1,[r3]
344
        mrc     MMU_CP,0,r1,MMU_Control,c0
345
        str     r1,[r3, #0x04]
346
        mrc     p15,0,r1,c15,c1,0
347
        str     r1,[r3, #0x08]
348
 
349
here:
350
        //        b       here
351
#endif
352
#else   // PLATFORM_SETUP_FROM_CCS_GEL_SCRIPT
353
        // This is all stolen from the ipaq setup
354
 
355
        // Make sure MMU is OFF
356
        mov r0,#INTERNAL_SRAM_BASE // Force cache writeback by reloading
357
        add r2,r0,#0x2000          // cache from the internal memory bank
358
123:    ldr r1,[r0],#16
359
        cmp r0, r2
360
        bne 123b
361
        mov r0,#0
362
        mov r1,#0x0070          // MMU Control System bit
363
        mcr p15,0,r0,c7,c7,0      // Flush data and instruction cache
364
        mcr p15,0,r0,c8,c7,0      // Flush ID TLBs
365
        mcr p15,0,r0,c9,c0,0      // Flush Read-Buffer
366
        mcr p15,0,r0,c7,c10,4    // Drain write buffer
367
        mcr p15,0,r0,c13,c0,0     // Disable virtual ID mapping
368
        mcr p15,0,r1,c1,c0,0      // Write MMU control register
369
        nop; nop; nop; nop
370
        FAKE_LED_MACRO(2)
371
 
372
        mov     r0,#(CPSR_IRQ_DISABLE|CPSR_FIQ_DISABLE|CPSR_SUPERVISOR_MODE)
373
        msr     cpsr,r0
374
        FAKE_LED_MACRO(3)
375
 
376
        // This is the platform setup adapted from the rrload setup implied
377
        // by head_omap1510.S
378
 
379
// Disable the Watchdog Timer.
380
// ---------------------------
381
        mov  r1, #0xF5
382
        ldr  r0, REG_WDT_TIMER_MODE
383
        strh r1, [r0]  // Set WDTIM Mode
384
        mov  r1, #0xA0
385
        strh r1, [r0]  // Set WDTIM Mode
386
        FAKE_LED_MACRO(4)
387
 
388
// setting for DPLL1 control register.
389
// ----------------------------------
390
        ldr  r0, REG_DPLL1_CTL
391
        mov  r1, #0x10
392
        strh r1, [r0]
393
// Continue to loop if bit shows "not locked"
394
poll1:
395
        ldrh r1, [r0]
396
        ands r1, r1, #0x01
397
        beq  poll1
398
        FAKE_LED_MACRO(5)
399
 
400
// Init Arm9 processor.
401
// --------------------
402
        mrs r0, cpsr            // Get current mode bits.
403
        bic r0, r0, #0x1f        // Clear mode bits.
404
        orr r0, r0, #0xd3        // Disable IRQs/FIQs, supervisor mode.
405
        msr cpsr, r0            // Enter Supervisor mode.
406
        mov r1, #0x81           // Set ARM925T configuration.
407
        mcr p15, 0, r1, c15, c1, 0  // Write ARM925T configuration register.
408
        FAKE_LED_MACRO(6)
409
 
410
// Disable All Interrupts
411
// -----------
412
        ldr r1, V_0xffffffff
413
        ldr r0, REG_IHL1_MIR
414
        str r1, [r0]
415
        ldr r0, REG_IHL2_MIR
416
        str r1, [r0]
417
        FAKE_LED_MACRO(7)
418
 
419
// Determine if this is a 1509 or 1510, then
420
// set the Configuration Registers accordingly
421
// 1509 shows 0, 1510 shows 0x1b47002f
422
// -------------------
423
        ldr     r0, REG_IDCODE
424
        ldr     r1, [r0]
425
        cmp     r1, #0x0
426
        beq     omap1509
427
        FAKE_LED_MACRO(8)
428
 
429
// OK, so we're a 1510.  
430
omap1510:
431
/*
432
        Errata for ES1 says to do this:
433
 
434
        1)  Check for power-on or warm reset.
435
        2)  Configure SDRAM controller depending on reset type.
436
*/
437
        // Check for reset type
438
        ldr     r0, REG_ARM_SYSST
439
        ldrh    r1, [r0]
440
        mov     r2, #0x20
441
        tst     r2, r1
442
        beq     zzz_warm_reset
443
        FAKE_LED_MACRO(9)
444
 
445
POR:
446
        // Wait 100mS for SDRAM to stabilize before
447
        // configuring SDRAM controller.
448
        // Number guessed at.
449
        mov     r0, #0x2000
450
1:      subs    r0, r0, #0x1
451
        bne     1b
452
        FAKE_LED_MACRO(10)
453
 
454
        b       after_initial_configure_SDRAM
455
 
456
zzz_warm_reset:
457
        FAKE_LED_MACRO(11)
458
 
459
        // Set auto-refresh counter value to 1.
460
        // Program MRS to appropriate CAS latency
461
        // Wait for SDRAM array to be completely
462
        // refreshed, 1 cycle * #SDRAM rows.
463
        ldr     r0, REG_TC_EMIFF_SDRAM_CONFIG
464
        mov     r1, #0x100
465
        str     r1, [r0]
466
        ldr     r0, REG_TC_EMIFF_MRS
467
        ldr     r1, VAL_TC_EMIFF_MRS
468
        str     r1, [r0]
469
        mov     r2, #0x2000
470
1:      subs    r2, r2, #0x1
471
        bne     1b
472
        ldr     r0, REG_TC_EMIFF_SDRAM_CONFIG
473
        mov     r1, #0x10000
474
        str     r1, [r0]
475
 
476
after_initial_configure_SDRAM:
477
        FAKE_LED_MACRO(12)
478
 
479
 
480
// Config Spec says to write values
481
// to each of the configuration registers,
482
// then take the chip out of 1509 compatibility mode.
483
 
484
        ldr     r0, REG_PULL_DWN_CTRL_0
485
        ldr     r1, VAL_PULL_DWN_CTRL_0
486
        str     r1, [r0]
487
        ldr     r0, REG_PULL_DWN_CTRL_1
488
        ldr     r1, VAL_PULL_DWN_CTRL_1
489
        str     r1, [r0]
490
        ldr     r0, REG_PULL_DWN_CTRL_2
491
        ldr     r1, VAL_PULL_DWN_CTRL_2
492
        str     r1, [r0]
493
        ldr     r0, REG_PULL_DWN_CTRL_3
494
        ldr     r1, VAL_PULL_DWN_CTRL_3
495
        str     r1, [r0]
496
        ldr     r0, REG_FUNC_MUX_CTRL_4
497
        ldr     r1, VAL_FUNC_MUX_CTRL_4
498
        str     r1, [r0]
499
        ldr     r0, REG_FUNC_MUX_CTRL_5
500
        ldr     r1, VAL_FUNC_MUX_CTRL_5
501
        str     r1, [r0]
502
        ldr     r0, REG_FUNC_MUX_CTRL_6
503
        ldr     r1, VAL_FUNC_MUX_CTRL_6
504
        str     r1, [r0]
505
        ldr     r0, REG_FUNC_MUX_CTRL_7
506
        ldr     r1, VAL_FUNC_MUX_CTRL_7
507
        str     r1, [r0]
508
        ldr     r0, REG_FUNC_MUX_CTRL_8
509
        ldr     r1, VAL_FUNC_MUX_CTRL_8
510
        str     r1, [r0]
511
        ldr     r0, REG_FUNC_MUX_CTRL_9
512
        ldr     r1, VAL_FUNC_MUX_CTRL_9
513
        str     r1, [r0]
514
        ldr     r0, REG_FUNC_MUX_CTRL_A
515
        ldr     r1, VAL_FUNC_MUX_CTRL_A
516
        str     r1, [r0]
517
        ldr     r0, REG_FUNC_MUX_CTRL_B
518
        ldr     r1, VAL_FUNC_MUX_CTRL_B
519
        str     r1, [r0]
520
        ldr     r0, REG_FUNC_MUX_CTRL_C
521
        ldr     r1, VAL_FUNC_MUX_CTRL_C
522
        str     r1, [r0]
523
        ldr     r0, REG_FUNC_MUX_CTRL_D
524
        ldr     r1, VAL_FUNC_MUX_CTRL_D
525
        str     r1, [r0]
526
        ldr     r0, REG_VOLTAGE_CTRL_0
527
        ldr     r1, VAL_VOLTAGE_CTRL_0
528
        str     r1, [r0]
529
        ldr     r0, REG_TEST_DBG_CTRL_0
530
        ldr     r1, VAL_TEST_DBG_CTRL_0
531
        str     r1, [r0]
532
        ldr     r0, REG_MOD_CONF_CTRL_0
533
        ldr     r1, VAL_MOD_CONF_CTRL_0
534
        str     r1, [r0]
535
        FAKE_LED_MACRO(13)
536
 
537
        // Take out of compatibility mode
538
        ldr     r0, REG_COMP_MODE_CTRL_0
539
        ldr     r1, VAL_COMP_MODE_CTRL_0
540
        str     r1, [r0]
541
        FAKE_LED_MACRO(14)
542
 
543
        b post_config_registers
544
 
545
omap1509:
546
        ldr     r0, REG_FUNC_MUX_CTRL_0
547
        ldr     r1, [r0]
548
        orr     r1, r1, #0x6000000  // UART_GIGA_GATE bit as well as UART_BT_GATE bit
549
        str     r1, [r0]
550
// Errata for ES5.5 says this must be done before DSP or MPU can
551
// access internal RAMs.  This is benign for earlier revs.
552
        ldr     r0, REG_FUNC_MUX_CTRL_1
553
        mov     r1, #0xc
554
        str     r1, [r0]
555
 
556
post_config_registers:
557
        FAKE_LED_MACRO(15)
558
        mov r0, #0x1800
559
again:
560
        subs r0, r0, #0x1
561
        bne again
562
        FAKE_LED_MACRO(16)
563
 
564
// Invalidate cache
565
// -----------------
566
        mov r0,#0
567
        nop
568
        mcr p15, 0x0, r0, c7, c5, 0x0
569
        nop
570
        nop
571
        nop
572
        nop
573
        FAKE_LED_MACRO(17)
574
 
575
//  Enable I-Cache
576
// -------------
577
        mrc p15, 0x0, r1, c1, c0, 0x0
578
        orr r1, r1, #0x1000
579
        nop
580
        mcr p15, 0x0, r1, c1, c0, 0x0
581
        nop
582
        nop
583
        nop
584
        nop
585
        FAKE_LED_MACRO(18)
586
 
587
// Initialize Traffic Controller (TC)
588
// ----------------------------------
589
        ldr r0, REG_TC_IMIF_PRIO
590
        mov r1, #0x0
591
        str r1, [r0]
592
        ldr r0, REG_TC_EMIFS_PRIO
593
        str r1, [r0]
594
        ldr r0, REG_TC_EMIFF_PRIO
595
        str r1, [r0]
596
 
597
        ldr r0, REG_TC_EMIFS_CONFIG
598
        ldr r1, [r0]
599
        bic r1, r1, #0x08       /* clear the global power-down enable PDE bit */
600
        bic r1, r1, #0x01       /* write protect flash by clearing the WP bit */
601
        str r1, [r0]  // EMIFS GlB Configuration. (value 0x12 most likely)
602
 
603
// Set TC chip select registers
604
// SDRAM value based on 168MHz 1510.
605
// ----------------------------
606
        ldr r0, REG_TC_EMIFS_CS1_CONFIG
607
        ldr r1, VAL_TC_EMIFS_CS1_CONFIG_PRELIM
608
        str r1, [r0]
609
        ldr r0, REG_TC_EMIFS_CS2_CONFIG
610
        ldr r1, VAL_TC_EMIFS_CS2_CONFIG_PRELIM
611
        str r1, [r0]
612
        ldr r0, REG_TC_EMIFF_SDRAM_CONFIG
613
        ldr r1, VAL_TC_EMIFF_SDRAM_CONFIG
614
        str r1, [r0]
615
        ldr r0, REG_TC_EMIFF_MRS
616
        ldr r1, VAL_TC_EMIFF_MRS
617
        str r1, [r0]
618
 
619
        mov r0,#0x1800
620
again2:
621
        subs r0,r0,#0x1
622
        bne again2
623
        FAKE_LED_MACRO(19)
624
 
625
 // Next, Enable the RS232 Line Drivers in the FPGA.
626
 // Also, power on the audio CODEC's amplifier here,
627
 // which will make a noise on the audio output.
628
 // This is done here instead of in the kernel so there
629
 // isn't a loud popping noise at the start of each
630
 // song.
631
 // Also, disable the CODEC's clocks.
632
 // omap1510-HelenP1 [specific]
633
        ldr r0, REG_FPGA_POWER
634
        mov r1, #0
635
        ldr r2, REG_FPGA_DIP_SWITCH
636
        ldrb r3, [r2]
637
        cmp r3, #0x8
638
        movne r1, #0x62     // Enable the RS232 Line Drivers in the EPLD
639
        strb r1, [r0]
640
        ldr r0, REG_FPGA_AUDIO
641
        mov r1, #0x0     // Disable sound driver (CODEC clocks)
642
        strb r1, [r0]
643
 
644
        mov r0, #0x1800
645
again0:
646
        subs r0, r0, #0x1
647
        bne again0
648
        FAKE_LED_MACRO(20)
649
 
650
// Init RHEA
651
// ----------        
652
        ldr r1, V_0x0000ff22
653
        mov r0, #0x0
654
        str r1, [r0]   // yep, that's really a write to address 0x00000000.
655
 
656
// *revisit-skranz* is needed?        
657
        mov r0, #0x1800
658
again12:
659
        subs r0, r0, #0x1
660
        bne again12
661
        FAKE_LED_MACRO(21)
662
 
663
// Misc 2
664
// ------        
665
        mov r1, #0xfb
666
        ldr r0, REG_LB_CLOCK_DIV
667
        str r1, [r0]
668
 
669
// *revisit-skranz* is needed?        
670
        mov r0, #0x1800
671
again4:
672
        subs r0, r0, #0x1
673
        bne again4
674
        FAKE_LED_MACRO(22)
675
 
676
// ARM Clock Module Setup
677
// ----------------------        
678
        mov r1, #0x40
679
        ldr r0, REG_ARM_IDLECT2
680
        strh r1, [r0]  // CLKM, Clock domain control.
681
 
682
        mov r1, #0x01  // PER_EN bit
683
        ldr r0, REG_ARM_RSTCT2
684
        strh r1, [r0]  // CLKM; Peripheral reset.
685
 
686
        // Reset CLKM
687
#ifdef ORIGINAL_CODE
688
        mov r1, #0x06  // Needed for UART[12]
689
#else
690
        mov r1, #0x86  // Needed for UART[12]
691
#endif
692
        ldr r0, REG_ARM_IDLECT2
693
        strh r1, [r0]  // CLKM, Clock domain control.
694
 
695
        // Set CLKM to Sync-Scalable
696
        mov r1, #0x1000  // Needed for UART[12]
697
        ldr r0, REG_ARM_SYSST
698
        strh r1, [r0]
699
 
700
// *revisit-skranz* is needed?        
701
        mov r0, #0x1800
702
again6:
703
        subs r0, r0, #0x1
704
        bne again6
705
        FAKE_LED_MACRO(23)
706
 
707
        ldr r1, VAL_ARM_CKCTL
708
        ldr r0, REG_ARM_CKCTL
709
        strh r1, [r0]
710
 
711
// setup DPLL1 Control Register
712
// ----------------------------
713
        ldr r1, VAL_DPLL1_CTL
714
        ldr r0, REG_DPLL1_CTL
715
        strh r1, [r0]
716
        ands r1, r1, #0x10   // Check if PLL is enabled.
717
        beq finish2          // Do not look for lock if BYPASS selected
718
poll2:
719
        ldrh r1, [r0]
720
        ands r1, r1, #0x01   // Check the LOCK bit.
721
        beq poll2            // ...loop until bit goes hi.
722
finish2:
723
        FAKE_LED_MACRO(24)
724
 
725
        // Setup TC EMIFS configuration.
726
        // CS0 value based on 168MHz
727
        // ---------------------------------------------------
728
        ldr r1, VAL_TC_EMIFS_CS0_CONFIG // increase flash speed.
729
        ldr r0, REG_TC_EMIFS_CS0_CONFIG
730
        str r1, [r0] // Chip Select 0
731
        ldr r1, VAL_TC_EMIFS_CS1_CONFIG
732
        ldr r0, REG_TC_EMIFS_CS1_CONFIG
733
        str r1, [r0] // Chip Select 1
734
        ldr r1, VAL_TC_EMIFS_CS2_CONFIG
735
        ldr r0, REG_TC_EMIFS_CS2_CONFIG
736
        str r1, [r0] // Chip Select 2
737
        ldr r1, VAL_TC_EMIFS_CS3_CONFIG
738
        ldr r0, REG_TC_EMIFS_CS3_CONFIG
739
        str r1, [r0] // Chip Select 3
740
 
741
// *revisit-skranz* is needed?        
742
        mov r0, #0x1800
743
again9:
744
        subs r0, r0, #0x1
745
        bne again9
746
        FAKE_LED_MACRO(25)
747
 
748
        // The following was added by WPD
749
        // Set up a stack [for calling C code]
750
#ifdef CYG_HAL_STARTUP_ROM
751
        // The startup stack is in internal SRAM
752
        ldr     sp,=__startup_stack
753
        // This _MOST_DEFINATELY_ needs to be fixed
754
        orr     sp,sp,#0x10000000
755
#else
756
        // The startup stack is in SDRAM, at some virtual address, but
757
        // we have not set up the MMU yet, so we need to initialize SP
758
        // with the physical address of '__startup_stack'
759
#error "Somehow"
760
#endif
761
        bl      hal_mmu_init
762
        FAKE_LED_MACRO(26)
763
 
764
        // Enable MMU
765
        ldr     r2,=10f
766
        ldr     r1,=MMU_Control_Init|MMU_Control_M
767
        mcr     MMU_CP,0,r1,MMU_Control,c0
768
        mov     pc,r2
769
 
770
        //        mcr     MMU_CP,0,r0,MMU_InvalidateCache,c7,0  // Flush data and instruction cache
771
        //      mcr     MMU_CP,0,r0,MMU_TLB,c7,0                // Flush ID TLBs
772
10:
773
        nop
774
        nop
775
        nop
776
        FAKE_LED_MACRO(27)
777
 
778
#if 0
779
        ldr     r3,=0x20000000
780
        str     r1,[r3]
781
        mrc     MMU_CP,0,r1,MMU_Control,c0
782
        str     r1,[r3, #0x04]
783
        mrc     p15,0,r1,c15,c1,0
784
        str     r1,[r3, #0x08]
785
 
786
here:
787
        //        b       here
788
#endif
789
#endif
790
        .endm
791
 
792
#else // defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM) || defined(CYG_HAL_STARTUP_REDBOOT)
793
#define PLATFORM_SETUP1
794
#endif
795
 
796
//-----------------------------------------------------------------------------
797
//-----------------------------------------------------------------------------
798
// end of hal_platform_setup.h
799
 
800
// ------------------------------------------------------        
801
// --------------Static Data Definitions-----------------
802
// ------------------------------------------------------
803
 
804
/* inernal OMAP registers */
805
        /* interrupt handler level 2 registers */
806
REG_IHL2_MIR:                   /* 32 bits */
807
        .word 0xfffe0004
808
        /* OMAP configuration registers */
809
REG_FUNC_MUX_CTRL_0:            /* 32 bits */
810
        .word 0xfffe1000
811
REG_FUNC_MUX_CTRL_1:            /* 32 bits */
812
        .word 0xfffe1004
813
REG_FUNC_MUX_CTRL_2:            /* 32 bits */
814
        .word 0xfffe1008
815
REG_COMP_MODE_CTRL_0:           /* 32 bits */
816
        .word 0xfffe100c
817
REG_FUNC_MUX_CTRL_3:            /* 32 bits */
818
        .word 0xfffe1010
819
REG_FUNC_MUX_CTRL_4:            /* 32 bits */
820
        .word 0xfffe1014
821
REG_FUNC_MUX_CTRL_5:            /* 32 bits */
822
        .word 0xfffe1018
823
REG_FUNC_MUX_CTRL_6:            /* 32 bits */
824
        .word 0xfffe101c
825
REG_FUNC_MUX_CTRL_7:            /* 32 bits */
826
        .word 0xfffe1020
827
REG_FUNC_MUX_CTRL_8:            /* 32 bits */
828
        .word 0xfffe1024
829
REG_FUNC_MUX_CTRL_9:            /* 32 bits */
830
        .word 0xfffe1028
831
REG_FUNC_MUX_CTRL_A:            /* 32 bits */
832
        .word 0xfffe102C
833
REG_FUNC_MUX_CTRL_B:            /* 32 bits */
834
        .word 0xfffe1030
835
REG_FUNC_MUX_CTRL_C:            /* 32 bits */
836
        .word 0xfffe1034
837
REG_FUNC_MUX_CTRL_D:            /* 32 bits */
838
        .word 0xfffe1038
839
REG_PULL_DWN_CTRL_0:            /* 32 bits */
840
        .word 0xfffe1040
841
REG_PULL_DWN_CTRL_1:            /* 32 bits */
842
        .word 0xfffe1044
843
REG_PULL_DWN_CTRL_2:            /* 32 bits */
844
        .word 0xfffe1048
845
REG_PULL_DWN_CTRL_3:            /* 32 bits */
846
        .word 0xfffe104c
847
REG_VOLTAGE_CTRL_0:             /* 32 bits */
848
        .word 0xfffe1060
849
REG_TEST_DBG_CTRL_0:            /* 32 bits */
850
        .word 0xfffe1070
851
REG_MOD_CONF_CTRL_0:            /* 32 bits */
852
        .word 0xfffe1080
853
        /* local bus control registers */
854
REG_LB_CLOCK_DIV:               /* 32 bits */
855
        .word 0xfffec10c
856
        /* watchdog timer registers */
857
REG_WDT_TIMER_MODE:             /* 16 bits */
858
        .word 0xfffec808
859
        /* interrupt handler level 1 registers */
860
REG_IHL1_MIR:                   /* 32 bits */
861
        .word 0xfffecb04
862
        /* traffic controller memory interface registers */
863
REG_TC_IMIF_PRIO:               /* 32 bits */
864
        .word 0xfffecc00
865
REG_TC_EMIFS_PRIO:              /* 32 bits */
866
        .word 0xfffecc04
867
REG_TC_EMIFF_PRIO:              /* 32 bits */
868
        .word 0xfffecc08
869
REG_TC_EMIFS_CONFIG:            /* 32 bits */
870
        .word 0xfffecc0c
871
REG_TC_EMIFS_CS0_CONFIG:        /* 32 bits */
872
        .word 0xfffecc10
873
REG_TC_EMIFS_CS1_CONFIG:        /* 32 bits */
874
        .word 0xfffecc14
875
REG_TC_EMIFS_CS2_CONFIG:        /* 32 bits */
876
        .word 0xfffecc18
877
REG_TC_EMIFS_CS3_CONFIG:        /* 32 bits */
878
        .word 0xfffecc1c
879
REG_TC_EMIFF_SDRAM_CONFIG:      /* 32 bits */
880
        .word 0xfffecc20
881
REG_TC_EMIFF_MRS:               /* 32 bits */
882
        .word 0xfffecc24
883
        /* MPU clock/reset/power mode control registers */
884
REG_ARM_CKCTL:                  /* 16 bits */
885
        .word 0xfffece00
886
REG_ARM_IDLECT2:                /* 16 bits */
887
        .word 0xfffece08
888
REG_ARM_RSTCT2:                 /* 16 bits */
889
        .word 0xfffece14
890
REG_ARM_SYSST:                  /* 16 bits */
891
        .word 0xfffece18
892
        /* DPLL control registers */
893
REG_DPLL1_CTL:                  /* 16 bits */
894
        .word 0xfffecf00
895
        /* identification code register */
896
REG_IDCODE:                     /* 32 bits */
897
        .word 0xfffed404
898
 
899
/* board-specific registers */
900
 
901
REG_FPGA_LED_DIGIT:             /* 8 bits (not used on Innovator) */
902
        .word 0x08000003
903
REG_FPGA_POWER:                 /* 8 bits */
904
        .word 0x08000005
905
REG_FPGA_AUDIO:                 /* 8 bits (not used on Innovator) */
906
        .word 0x0800000c
907
REG_FPGA_DIP_SWITCH:            /* 8 bits (not used on Innovator) */
908
        .word 0x0800000e
909
 
910
/* constants */
911
 
912
VAL_COMP_MODE_CTRL_0:
913
        .word 0x0000eaef
914
VAL_FUNC_MUX_CTRL_4:
915
        .word 0x00000000
916
VAL_FUNC_MUX_CTRL_5:
917
        .word 0x00000000
918
VAL_FUNC_MUX_CTRL_6:
919
        .word 0x00000001
920
VAL_FUNC_MUX_CTRL_7:
921
        .word 0x00000000
922
VAL_FUNC_MUX_CTRL_8:
923
        .word 0x10001200
924
VAL_FUNC_MUX_CTRL_9:
925
        .word 0x01201012
926
VAL_FUNC_MUX_CTRL_A:
927
        .word 0x00000248
928
VAL_FUNC_MUX_CTRL_B:
929
        .word 0x00000248
930
VAL_FUNC_MUX_CTRL_C:
931
        .word 0x09000000
932
VAL_FUNC_MUX_CTRL_D:
933
        .word 0x00000000
934
VAL_PULL_DWN_CTRL_0:
935
        .word 0x11a10000
936
VAL_PULL_DWN_CTRL_1:
937
        .word 0x2e047fff
938
VAL_PULL_DWN_CTRL_2:
939
        .word 0xffd7d3e6
940
VAL_PULL_DWN_CTRL_3:
941
        .word 0x00003f03
942
VAL_VOLTAGE_CTRL_0:
943
        .word 0x00000007
944
VAL_TEST_DBG_CTRL_0:
945
        /* The OMAP5910 TRM says this register must be 0, but HelenConfRegs
946
         * says to write a 7.  Don't know what the right thing is to do, so
947
         * I'm leaving it at 7 since that's what was already here.
948
         */
949
        .word 0x00000007
950
VAL_MOD_CONF_CTRL_0:
951
        .word 0x0b000008
952
VAL_ARM_CKCTL:
953
#ifdef ORIGINAL_CODE
954
        .word 0x110f
955
#else
956
        .word 0x010f
957
#endif
958
VAL_DPLL1_CTL:
959
        .word 0x2710
960
VAL_TC_EMIFS_CS1_CONFIG_PRELIM:
961
        .word 0x00001149
962
VAL_TC_EMIFS_CS2_CONFIG_PRELIM:
963
        .word 0x00004158
964
VAL_TC_EMIFS_CS0_CONFIG:
965
        .word 0x002130b0
966
VAL_TC_EMIFS_CS1_CONFIG:
967
        .word 0x0000f559
968
VAL_TC_EMIFS_CS2_CONFIG:
969
        .word 0x000055f0
970
VAL_TC_EMIFS_CS3_CONFIG:
971
        .word 0x00003331
972
VAL_TC_EMIFF_SDRAM_CONFIG:
973
        .word 0x010290fc
974
VAL_TC_EMIFF_MRS:
975
        .word 0x00000027
976
 
977
V_0xffffffff:
978
        .word 0xffffffff
979
 
980
V_0x0000ff22:
981
        .word 0x0000ff22
982
#endif // CYGONCE_HAL_PLATFORM_SETUP_H

powered by: WebSVN 2.1.0

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