1 |
786 |
skrzyp |
#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, 2008 Free Software Foundation, 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
|
18 |
|
|
// version.
|
19 |
|
|
//
|
20 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
21 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
22 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
23 |
|
|
// for more details.
|
24 |
|
|
//
|
25 |
|
|
// You should have received a copy of the GNU General Public License
|
26 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
27 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
28 |
|
|
//
|
29 |
|
|
// As a special exception, if other files instantiate templates or use
|
30 |
|
|
// macros or inline functions from this file, or you compile this file
|
31 |
|
|
// and link it with other works to produce a work based on this file,
|
32 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
33 |
|
|
// the GNU General Public License. However the source code for this file
|
34 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
35 |
|
|
// General Public License v2.
|
36 |
|
|
//
|
37 |
|
|
// This exception does not invalidate any other reasons why a work based
|
38 |
|
|
// on this file might be covered by the GNU General Public License.
|
39 |
|
|
// -------------------------------------------
|
40 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
41 |
|
|
//=============================================================================
|
42 |
|
|
//#####DESCRIPTIONBEGIN####
|
43 |
|
|
//
|
44 |
|
|
// Author(s): Uwe Kindler
|
45 |
|
|
// Contributors: Uwe Kindler
|
46 |
|
|
// Date: 2007-12-02
|
47 |
|
|
// Purpose: phyCORE-LPC229x platform specific support routines
|
48 |
|
|
// Description:
|
49 |
|
|
// Usage: #include <cyg/hal/hal_platform_setup.h>
|
50 |
|
|
//
|
51 |
|
|
//####DESCRIPTIONEND####
|
52 |
|
|
//
|
53 |
|
|
//===========================================================================*/
|
54 |
|
|
#include <pkgconf/system.h>
|
55 |
|
|
#include <cyg/hal/var_io.h>
|
56 |
|
|
|
57 |
|
|
//===========================================================================*/
|
58 |
|
|
|
59 |
|
|
#define LINES (0xFE<<16)
|
60 |
|
|
#define LINE (1<<16)
|
61 |
|
|
.macro _line_init
|
62 |
|
|
// set to GPIO
|
63 |
|
|
ldr r0,=CYGARC_HAL_LPC2XXX_REG_PIN_BASE
|
64 |
|
|
ldr r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PINSEL2]
|
65 |
|
|
bic r1, r1, #8
|
66 |
|
|
str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PINSEL2]
|
67 |
|
|
// set to output
|
68 |
|
|
ldr r0,=CYGARC_HAL_LPC2XXX_REG_IO_BASE
|
69 |
|
|
ldr r1,[r0,#CYGARC_HAL_LPC2XXX_REG_IO1DIR]
|
70 |
|
|
orr r1,r1,#LINE
|
71 |
|
|
str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_IO1DIR]
|
72 |
|
|
// turn ON
|
73 |
|
|
ldr r1,[r0,#CYGARC_HAL_LPC2XXX_REG_IO1PIN]
|
74 |
|
|
bic r1,r1,#LINES
|
75 |
|
|
orr r1,r1,#LINE
|
76 |
|
|
str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_IO1PIN]
|
77 |
|
|
.endm
|
78 |
|
|
|
79 |
|
|
//----------------------------------------------------------------------------
|
80 |
|
|
// The phyCORE Carrier Board HD200 offers a programmable LED at
|
81 |
|
|
// D3 for user implementations. This LED can be connected to port pin
|
82 |
|
|
// P0.8 (TxD1) of the phyCORE-LPC2292/94 which is available via
|
83 |
|
|
// signal GPIO0 (JP17 = closed). A low-level at port pin P0.8 causes the
|
84 |
|
|
// LED to illuminate, LED D3 remains off when writing a high-level to
|
85 |
|
|
// P0.8.
|
86 |
|
|
//
|
87 |
|
|
.macro _led_init
|
88 |
|
|
ldr r0,=CYGARC_HAL_LPC2XXX_REG_IO_BASE
|
89 |
|
|
ldr r1,=(1<<8) // GPIO0 pins 8 is LED output
|
90 |
|
|
str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_IO0DIR]
|
91 |
|
|
.endm
|
92 |
|
|
|
93 |
|
|
.macro _led x
|
94 |
|
|
ldr r0,=CYGARC_HAL_LPC2XXX_REG_IO_BASE
|
95 |
|
|
ldr r1,=(1<<8)
|
96 |
|
|
str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_IO0CLR]
|
97 |
|
|
ldr r1,=((\x & 1)<<8)
|
98 |
|
|
str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_IO0SET]
|
99 |
|
|
.endm
|
100 |
|
|
#define CYGHWR_LED_MACRO _led \x
|
101 |
|
|
|
102 |
|
|
|
103 |
|
|
//----------------------------------------------------------------------------
|
104 |
|
|
// PLL initialisation
|
105 |
|
|
//
|
106 |
|
|
.macro _pll_init
|
107 |
|
|
ldr r0,=CYGARC_HAL_LPC2XXX_REG_SCB_BASE
|
108 |
|
|
|
109 |
|
|
mov r2,#0xAA
|
110 |
|
|
mov r3,#0x55
|
111 |
|
|
|
112 |
|
|
mov r1,#(0x20 | (CYGNUM_HAL_ARM_LPC2XXX_PLL_MUL - 1))
|
113 |
|
|
// load the PLL configuration register
|
114 |
|
|
str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLCFG]
|
115 |
|
|
|
116 |
|
|
mov r1,#1
|
117 |
|
|
str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLCON] // enable PLL
|
118 |
|
|
|
119 |
|
|
// perform validation sequence 0XAA followed by 0x55
|
120 |
|
|
str r2,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLFEED]
|
121 |
|
|
str r3,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLFEED]
|
122 |
|
|
|
123 |
|
|
1:
|
124 |
|
|
ldr r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLSTAT] // wait for it to lock
|
125 |
|
|
ands r1,r1,#(1<<10)
|
126 |
|
|
beq 1b
|
127 |
|
|
|
128 |
|
|
mov r1,#3 // connect PLL
|
129 |
|
|
str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLCON]
|
130 |
|
|
|
131 |
|
|
// perform validation sequence 0XAA followed by 0x55
|
132 |
|
|
str r2,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLFEED]
|
133 |
|
|
str r3,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLFEED]
|
134 |
|
|
.endm
|
135 |
|
|
|
136 |
|
|
|
137 |
|
|
//----------------------------------------------------------------------------
|
138 |
|
|
// External memory and bus initialisation
|
139 |
|
|
//
|
140 |
|
|
.macro _mem_init
|
141 |
|
|
//
|
142 |
|
|
// first map the vector table to internal flash - normally this should be
|
143 |
|
|
// the default value after boot - but we go the safe way here and force
|
144 |
|
|
// the mapping to internal flash (the value for
|
145 |
|
|
// CYGARC_HAL_LPC2XXX_REG_MEMMAP is 1)
|
146 |
|
|
//
|
147 |
|
|
ldr r0,=CYGARC_HAL_LPC2XXX_REG_SCB_BASE
|
148 |
|
|
mov r1,#1
|
149 |
|
|
str r1, [r0,#CYGARC_HAL_LPC2XXX_REG_MEMMAP]
|
150 |
|
|
|
151 |
|
|
//
|
152 |
|
|
// Now its is save to copy the first 64 bytes of flash to RAM
|
153 |
|
|
//
|
154 |
|
|
mov r0,#0
|
155 |
|
|
mov r1,#0x40000000
|
156 |
|
|
mov r2,#0x40
|
157 |
|
|
1:
|
158 |
|
|
ldr r3,[r0,#4]!
|
159 |
|
|
str r3,[r1,#4]!
|
160 |
|
|
cmps r0,r2
|
161 |
|
|
bne 1b
|
162 |
|
|
|
163 |
|
|
//
|
164 |
|
|
// Now we can map the vector table to internal SRAM because the SRAM no
|
165 |
|
|
// contains a copy of the vector tablefrom flash (the value for
|
166 |
|
|
// CYGARC_HAL_LPC2XXX_REG_MEMMAP is 2 = SRAM)
|
167 |
|
|
//
|
168 |
|
|
ldr r0,=CYGARC_HAL_LPC2XXX_REG_SCB_BASE
|
169 |
|
|
// User RAM Mode. Interrupt vectors are re-mapped to Static RAM.
|
170 |
|
|
mov r1,#2
|
171 |
|
|
str r1, [r0,#CYGARC_HAL_LPC2XXX_REG_MEMMAP]
|
172 |
|
|
// 4 processor clocks fetch cycle
|
173 |
|
|
mov r1,#4
|
174 |
|
|
str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_MAMTIM] // flash timings
|
175 |
|
|
mov r1,#2
|
176 |
|
|
str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_MAMCR] // enable full MAM
|
177 |
|
|
|
178 |
|
|
//
|
179 |
|
|
// Set-up external memory - the main task here is to setup the
|
180 |
|
|
// wait states for the external memory properly
|
181 |
|
|
//
|
182 |
|
|
// Bank Configuration Registers 0-3 (BCFG0-3)
|
183 |
|
|
// [0..3] IDCY: Min. number of idle Cycles <0-15>
|
184 |
|
|
// [4] Reserved
|
185 |
|
|
// [5..9] WST1: Wait States 1 <0-31>
|
186 |
|
|
// [10] RBLE: Read Byte Lane Enable
|
187 |
|
|
// [11..15] WST2: Wait States 2 <0-31>
|
188 |
|
|
// [16..23] Reserved
|
189 |
|
|
// [26] WP: Write Protect
|
190 |
|
|
// [27] BM: Burst ROM
|
191 |
|
|
// [28..29] MW: Memory Width <0=8-bit,1=16-bit,2=32-bit,3=Reserved>
|
192 |
|
|
// [30..31] Reserved
|
193 |
|
|
//
|
194 |
|
|
|
195 |
|
|
// enable external parallel bus signals
|
196 |
|
|
ldr r0,=CYGARC_HAL_LPC2XXX_REG_PIN_BASE
|
197 |
|
|
// A0..1 enabled, CS0..3, OE, WE, BLS0..3, D0..31, A2..23, JTAG Pins
|
198 |
|
|
ldr r1,=0x0FE149E4
|
199 |
|
|
str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PINSEL2]
|
200 |
|
|
|
201 |
|
|
// setup external FLASH wait states
|
202 |
|
|
ldr r0,=CYGARC_HAL_LPC2XXX_REG_BCFG0
|
203 |
|
|
ldr r1,=0x20003CE3
|
204 |
|
|
str r1, [r0]
|
205 |
|
|
|
206 |
|
|
// setup external SRAM wait states
|
207 |
|
|
ldr r0,=CYGARC_HAL_LPC2XXX_REG_BCFG1
|
208 |
|
|
ldr r1,=0x020002483
|
209 |
|
|
str r1, [r0]
|
210 |
|
|
|
211 |
|
|
// setup Ethernet chip wait states for /CS2 and /CS3
|
212 |
|
|
ldr r0,=CYGARC_HAL_LPC2XXX_REG_BCFG2
|
213 |
|
|
ldr r1,=0x020000C23
|
214 |
|
|
str r1, [r0]
|
215 |
|
|
ldr r0,=CYGARC_HAL_LPC2XXX_REG_BCFG3
|
216 |
|
|
ldr r1,=0x020000C23
|
217 |
|
|
str r1, [r0]
|
218 |
|
|
.endm
|
219 |
|
|
|
220 |
|
|
.macro _gpio_init
|
221 |
|
|
// enable RX and TX on UART0 and UART1
|
222 |
|
|
ldr r0,=CYGARC_HAL_LPC2XXX_REG_PIN_BASE
|
223 |
|
|
ldr r1,=0x00050005
|
224 |
|
|
str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PINSEL0]
|
225 |
|
|
|
226 |
|
|
// set pin function to EINT0
|
227 |
|
|
ldr r0,=CYGARC_HAL_LPC2XXX_REG_PIN_BASE
|
228 |
|
|
ldr r1,=0x00000001
|
229 |
|
|
str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PINSEL1]
|
230 |
|
|
.endm
|
231 |
|
|
|
232 |
|
|
.macro _block
|
233 |
|
|
ldr r0,=CYGARC_HAL_LPC2XXX_REG_IO_BASE
|
234 |
|
|
ldr r1,=(1<<8)
|
235 |
|
|
str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_IO0CLR]
|
236 |
|
|
2:
|
237 |
|
|
nop
|
238 |
|
|
b 2
|
239 |
|
|
.endm
|
240 |
|
|
#define PLATFORM_BLOCK _block
|
241 |
|
|
//===========================================================================*/
|
242 |
|
|
|
243 |
|
|
#if defined(CYG_HAL_STARTUP_ROM)
|
244 |
|
|
.macro _setup
|
245 |
|
|
_line_init
|
246 |
|
|
_led_init
|
247 |
|
|
_led 1
|
248 |
|
|
_pll_init
|
249 |
|
|
_mem_init
|
250 |
|
|
_gpio_init
|
251 |
|
|
.endm
|
252 |
|
|
#define CYGSEM_HAL_ROM_RESET_USES_JUMP
|
253 |
|
|
#else
|
254 |
|
|
.macro _setup
|
255 |
|
|
|
256 |
|
|
.endm
|
257 |
|
|
#endif
|
258 |
|
|
|
259 |
|
|
#define PLATFORM_SETUP1 _setup
|
260 |
|
|
|
261 |
|
|
//-----------------------------------------------------------------------------
|
262 |
|
|
// end of hal_platform_setup.h
|
263 |
|
|
#endif // CYGONCE_HAL_PLATFORM_SETUP_H
|