]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/hal/arm/at91/jtst/v2_0/include/hal_platform_setup.h
Initial revision
[karo-tx-redboot.git] / packages / hal / arm / at91 / jtst / v2_0 / include / hal_platform_setup.h
1 #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):   gthomas
46 // Contributors: amichelotti
47 // Date:        2004-06-4
48 // Purpose:     JTST platform specific support routines
49 // Description: 
50 // Usage:       #include <cyg/hal/hal_platform_setup.h>
51 //
52 //####DESCRIPTIONEND####
53 //
54 //===========================================================================*/
55
56 #include <cyg/hal/var_io.h>
57 #include <cyg/hal/hal_misc.h>
58
59         .macro __pio_clkgen_init
60         ldr     r0,=AT91_PIO
61         ldr     r1,=BIT21|BIT22|BIT23|BIT24|BIT25|BIT26|BIT27
62         str     r1,[r0,#AT91_PIO_SODR] // set this bit must be always 1, 
63                                  // otherwise resets
64         ldr     r1,=BIT21|BIT22|BIT23|BIT24|BIT25|BIT26|BIT27
65         str     r1,[r0,#AT91_PIO_OER]  // set to output
66         str     r1,[r0,#AT91_PIO_PER]  // software control
67         ldr     r1,=BIT21|BIT22|BIT23|BIT24|BIT25|BIT26|BIT27
68         str     r1,[r0,#AT91_PIO_CODR] // leds all on
69         ldr     r1,=BIT30|BIT3
70         ldr     r1,[r0,#AT91_PIO_PDR]  // (BIT30) usb interrupt line in
71                                        // (BIT3) active watchdog reset line
72         ldr     r0,=AT91_CLKGEN
73         ldr     r1,=32
74         str     r1,[r0,#AT91_CLKGEN_CPTMAX0]
75         str     r1,[r0,#AT91_CLKGEN_CPTMAX1]
76         ldr     r1,=128
77         str     r1,[r0,#AT91_CLKGEN_CPTMAX2] //watch dog divider1
78         ldr     r1,=1024
79         str     r1,[r0,#AT91_CLKGEN_CPTMAX3] //watch dog divider2
80         ldr     r1,=2046
81         str     r1,[r0,#AT91_CLKGEN_CPTMAX4] //watch dog divider3 (max accepted value)
82
83         ldr     r1,=1
84         str     r1,[r0,#AT91_CLKGEN_CLKENABLE]
85
86 #if defined(CYG_HAL_STARTUP_RAM)
87   // set internal ram as interrupt stack and other
88         ldr     r0, =0x7ffc
89         ldr     r1,=__startup_stack
90         ldr     r2,=__startup_stack_base
91         sub     r3,r1,r2
92         ldr     r1,=.__startup_stack
93         str     r0,[r1]
94         sub     r0,r0,r3
95 #ifdef CYGIMP_HAL_COMMON_INTERRUPTS_USE_INTERRUPT_STACK
96         ldr     r1,=__interrupt_stack
97         ldr     r2,=__interrupt_stack_base
98         sub     r3,r1,r2
99         ldr     r1,=.__interrupt_stack
100         str     r0,[r1]
101 #endif
102 #endif
103         .endm
104
105 #if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM)
106
107         .macro  _setup
108         ldr     r10,=_InitMemory        // Initialize memory controller
109         movs    r0,pc,lsr #20           // If ROM startup, PC < 0x100000
110         moveq   r10,r10,lsl #12         //   mask address to low 20 bits
111         moveq   r10,r10,lsr #12
112         ldmia   r10!,{r0-r9,r11-r12}    // Table of initialization constants
113 #if defined(CYG_HAL_STARTUP_ROMRAM)
114         ldr     r10,=0x0000FFFF
115         and     r12,r12,r10
116         ldr     r10,=0x00510000
117         orr     r12,r12,r10
118 #endif
119         stmia   r11!,{r0-r9}            // Write to controller
120         mov     pc,r12                  // Change address space, break pipeline
121 _InitMemory:
122         .long   0x00502031  // FLASH
123         .long   0x00602021  // RAM
124         .long   0x00702021  // unused
125         .long   0x00802021  // unused
126         .long   0x00902021  // unused
127         .long   0x00A02021  // unused
128         .long   0x00b02021  // unused
129         .long   0x00c02021  // unused
130         .long   0x00000001  // REMAP commande
131         .long   0x00000006  // 7 memory regions, standard read
132         .long   AT91_EBI    // External Bus Interface address
133         .long   10f         // address where to jump
134 10:
135
136 #if defined(CYG_HAL_STARTUP_ROMRAM)
137         ldr     r0,=0x00510000          // Relocate FLASH/ROM to on-chip RAM
138         ldr     r1,=0x00600000          // RAM base & length
139         ldr     r2,=0x00610000
140 20:     ldr     r3,[r0],#4
141         str     r3,[r1],#4
142         cmp     r1,r2
143         bne     20b
144         ldr     r0,=30f
145         mov     pc,r0
146 30:
147
148 #endif
149
150 __pio_clkgen_init
151         .endm
152
153 #define CYGSEM_HAL_ROM_RESET_USES_JUMP
154 #define PLATFORM_SETUP1     _setup
155 #else
156
157 #define PLATFORM_SETUP1 __pio_clkgen_init
158
159 #endif
160
161 //-----------------------------------------------------------------------------
162 // end of hal_platform_setup.h
163 #endif // CYGONCE_HAL_PLATFORM_SETUP_H