1 #ifndef CYGONCE_HAL_PLATFORM_SETUP_H
2 #define CYGONCE_HAL_PLATFORM_SETUP_H
3 /*=============================================================================
5 // hal_platform_setup.h
7 // Platform specific support for HAL (assembly code)
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 // Copyright (C) 2008 eCosCentric Limited
16 // eCos is free software; you can redistribute it and/or modify it under
17 // the terms of the GNU General Public License as published by the Free
18 // Software Foundation; either version 2 or (at your option) any later version.
20 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
21 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
22 // FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
25 // You should have received a copy of the GNU General Public License along
26 // with eCos; if not, write to the Free Software Foundation, Inc.,
27 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
29 // As a special exception, if other files instantiate templates or use macros
30 // or inline functions from this file, or you compile this file and link it
31 // with other works to produce a work based on this file, this file does not
32 // by itself cause the resulting work to be covered by the GNU General Public
33 // License. However the source code for this file must still be made available
34 // in accordance with section (3) of the GNU General Public License.
36 // This exception does not invalidate any other reasons why a work based on
37 // this file might be covered by the GNU General Public License.
38 // -------------------------------------------
39 //####ECOSGPLCOPYRIGHTEND####
40 //=============================================================================
41 //#####DESCRIPTIONBEGIN####
43 // Author(s): Uwe Kindler
44 // Contributors: Uwe Kindler
46 // Purpose: phyCORE-LPC229x platform specific support routines
48 // Usage: #include <cyg/hal/hal_platform_setup.h>
50 //####DESCRIPTIONEND####
52 //===========================================================================*/
53 #include <pkgconf/system.h>
54 #include <cyg/hal/var_io.h>
56 //===========================================================================*/
58 #define LINES (0xFE<<16)
62 ldr r0,=CYGARC_HAL_LPC2XXX_REG_PIN_BASE
63 ldr r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PINSEL2]
65 str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PINSEL2]
67 ldr r0,=CYGARC_HAL_LPC2XXX_REG_IO_BASE
68 ldr r1,[r0,#CYGARC_HAL_LPC2XXX_REG_IO1DIR]
70 str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_IO1DIR]
72 ldr r1,[r0,#CYGARC_HAL_LPC2XXX_REG_IO1PIN]
75 str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_IO1PIN]
78 //----------------------------------------------------------------------------
79 // The phyCORE Carrier Board HD200 offers a programmable LED at
80 // D3 for user implementations. This LED can be connected to port pin
81 // P0.8 (TxD1) of the phyCORE-LPC2292/94 which is available via
82 // signal GPIO0 (JP17 = closed). A low-level at port pin P0.8 causes the
83 // LED to illuminate, LED D3 remains off when writing a high-level to
87 ldr r0,=CYGARC_HAL_LPC2XXX_REG_IO_BASE
88 ldr r1,=(1<<8) // GPIO0 pins 8 is LED output
89 str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_IO0DIR]
93 ldr r0,=CYGARC_HAL_LPC2XXX_REG_IO_BASE
95 str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_IO0CLR]
97 str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_IO0SET]
99 #define CYGHWR_LED_MACRO _led \x
102 //----------------------------------------------------------------------------
103 // PLL initialisation
106 ldr r0,=CYGARC_HAL_LPC2XXX_REG_SCB_BASE
111 mov r1,#(0x20 | (CYGNUM_HAL_ARM_LPC2XXX_PLL_MUL - 1))
112 // load the PLL configuration register
113 str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLCFG]
116 str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLCON] // enable PLL
118 // perform validation sequence 0XAA followed by 0x55
119 str r2,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLFEED]
120 str r3,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLFEED]
123 ldr r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLSTAT] // wait for it to lock
127 mov r1,#3 // connect PLL
128 str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLCON]
130 // perform validation sequence 0XAA followed by 0x55
131 str r2,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLFEED]
132 str r3,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLFEED]
136 //----------------------------------------------------------------------------
137 // External memory and bus initialisation
141 // first map the vector table to internal flash - normally this should be
142 // the default value after boot - but we go the safe way here and force
143 // the mapping to internal flash (the value for
144 // CYGARC_HAL_LPC2XXX_REG_MEMMAP is 1)
146 ldr r0,=CYGARC_HAL_LPC2XXX_REG_SCB_BASE
148 str r1, [r0,#CYGARC_HAL_LPC2XXX_REG_MEMMAP]
151 // Now its is save to copy the first 64 bytes of flash to RAM
163 // Now we can map the vector table to internal SRAM because the SRAM no
164 // contains a copy of the vector tablefrom flash (the value for
165 // CYGARC_HAL_LPC2XXX_REG_MEMMAP is 2 = SRAM)
167 ldr r0,=CYGARC_HAL_LPC2XXX_REG_SCB_BASE
168 // User RAM Mode. Interrupt vectors are re-mapped to Static RAM.
170 str r1, [r0,#CYGARC_HAL_LPC2XXX_REG_MEMMAP]
171 // 4 processor clocks fetch cycle
173 str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_MAMTIM] // flash timings
175 str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_MAMCR] // enable full MAM
178 // Set-up external memory - the main task here is to setup the
179 // wait states for the external memory properly
181 // Bank Configuration Registers 0-3 (BCFG0-3)
182 // [0..3] IDCY: Min. number of idle Cycles <0-15>
184 // [5..9] WST1: Wait States 1 <0-31>
185 // [10] RBLE: Read Byte Lane Enable
186 // [11..15] WST2: Wait States 2 <0-31>
188 // [26] WP: Write Protect
189 // [27] BM: Burst ROM
190 // [28..29] MW: Memory Width <0=8-bit,1=16-bit,2=32-bit,3=Reserved>
194 // enable external parallel bus signals
195 ldr r0,=CYGARC_HAL_LPC2XXX_REG_PIN_BASE
196 // A0..1 enabled, CS0..3, OE, WE, BLS0..3, D0..31, A2..23, JTAG Pins
198 str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PINSEL2]
200 // setup external FLASH wait states
201 ldr r0,=CYGARC_HAL_LPC2XXX_REG_BCFG0
205 // setup external SRAM wait states
206 ldr r0,=CYGARC_HAL_LPC2XXX_REG_BCFG1
210 // setup Ethernet chip wait states for /CS2 and /CS3
211 ldr r0,=CYGARC_HAL_LPC2XXX_REG_BCFG2
214 ldr r0,=CYGARC_HAL_LPC2XXX_REG_BCFG3
220 // enable RX and TX on UART0 and UART1
221 ldr r0,=CYGARC_HAL_LPC2XXX_REG_PIN_BASE
223 str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PINSEL0]
225 // set pin function to EINT0
226 ldr r0,=CYGARC_HAL_LPC2XXX_REG_PIN_BASE
228 str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PINSEL1]
232 ldr r0,=CYGARC_HAL_LPC2XXX_REG_IO_BASE
234 str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_IO0CLR]
239 #define PLATFORM_BLOCK _block
240 //===========================================================================*/
242 #if defined(CYG_HAL_STARTUP_ROM)
251 #define CYGSEM_HAL_ROM_RESET_USES_JUMP
258 #define PLATFORM_SETUP1 _setup
260 //-----------------------------------------------------------------------------
261 // end of hal_platform_setup.h
262 #endif // CYGONCE_HAL_PLATFORM_SETUP_H