]> git.kernelconcepts.de Git - karo-tx-redboot.git/blob - packages/hal/arm/lpc2xxx/lpcmt/v2_0/include/hal_platform_setup.h
Initial revision
[karo-tx-redboot.git] / packages / hal / arm / lpc2xxx / lpcmt / v2_0 / include / hal_platform_setup.h
1 #ifndef CYGONCE_HAL_PLATFORM_SETUP_H
2 #define CYGONCE_HAL_PLATFORM_SETUP_H
3
4 /*=============================================================================
5 //
6 //      hal_platform_setup.h
7 //
8 //      Platform specific support for HAL (assembly code)
9 //
10 //=============================================================================
11 //####ECOSGPLCOPYRIGHTBEGIN####
12 // -------------------------------------------
13 // This file is part of eCos, the Embedded Configurable Operating System.
14 // Copyright (C) 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
15 // Copyright (C) 2003 Nick Garnett <nickg@calivar.com>
16 // Copyright (C) 2004 eCosCentric Limited 
17 //
18 // eCos is free software; you can redistribute it and/or modify it under
19 // the terms of the GNU General Public License as published by the Free
20 // Software Foundation; either version 2 or (at your option) any later version.
21 //
22 // eCos is distributed in the hope that it will be useful, but WITHOUT ANY
23 // WARRANTY; without even the implied warranty of MERCHANTABILITY or
24 // FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
25 // for more details.
26 //
27 // You should have received a copy of the GNU General Public License along
28 // with eCos; if not, write to the Free Software Foundation, Inc.,
29 // 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
30 //
31 // As a special exception, if other files instantiate templates or use macros
32 // or inline functions from this file, or you compile this file and link it
33 // with other works to produce a work based on this file, this file does not
34 // by itself cause the resulting work to be covered by the GNU General Public
35 // License. However the source code for this file must still be made available
36 // in accordance with section (3) of the GNU General Public License.
37 //
38 // This exception does not invalidate any other reasons why a work based on
39 // this file might be covered by the GNU General Public License.
40 // -------------------------------------------
41 //####ECOSGPLCOPYRIGHTEND####
42 //=============================================================================
43 //#####DESCRIPTIONBEGIN####
44 //
45 // Author(s):   jani 
46 // Contributors:
47 // Date:        2004-09-12
48 // Purpose:     LPC2XXX/LPCMT platform specific support routines
49 // Description:
50 // Usage:       #include <cyg/hal/hal_platform_setup.h>
51 //
52 //####DESCRIPTIONEND####
53 //
54 //===========================================================================*/
55
56 #include <pkgconf/system.h>
57 #include <cyg/hal/var_io.h>
58
59 //===========================================================================*/
60
61         .macro  _led_init
62         ldr r0,=CYGARC_HAL_LPC2XXX_REG_IO_BASE
63         ldr r1,=(1<<12) // GPIO0 pin 12 is LED output
64         str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_IODIR]
65         .endm
66
67         .macro _led x
68         ldr r0,=CYGARC_HAL_LPC2XXX_REG_IO_BASE
69         ldr r1,=(1<<12)
70         str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_IOCLR]
71         ldr r1,=((\x & 1)<<12)
72         str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_IOSET]
73         .endm
74         
75         .macro _pll_init
76         ldr r0,=CYGARC_HAL_LPC2XXX_REG_SCB_BASE
77
78         mov r2,#0xAA
79         mov r3,#0x55
80         
81         mov r1,#1                       // enable PLL   
82         str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLCON]
83         
84         mov r1,#(0x20 | (CYGNUM_HAL_ARM_LPC2XXX_PLL_MUL - 1))
85         str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLCFG]      
86         
87         str r2,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLFEED]     // update PLL registers
88         str r3,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLFEED]
89
90 1:
91         ldr r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLSTAT]     // wait for it to lock
92         ands r1,r1,#(1<<10)
93         beq 1b
94         
95         mov r1,#3                       // connect PLL
96         str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLCON]
97
98         str r2,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLFEED]     // update PLL registers
99         str r3,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLFEED]
100         
101         .endm
102         
103         .macro _mem_init
104         mov r0,#0                       // copy first 64 bytes of flash to RAM
105         mov r1,#0x40000000
106         mov r2,#0x40
107 1:
108         ldr r3,[r0,#4]!
109         str r3,[r1,#4]!
110         cmps r0,r2
111         bne 1b
112
113         ldr r0,=CYGARC_HAL_LPC2XXX_REG_SCB_BASE
114         mov r1,#2
115         str r1, [r0,#CYGARC_HAL_LPC2XXX_REG_MEMMAP]     // int vectors mapped to RAM
116         mov r1,#4
117         str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_MAMTIM]      // flash timings
118         mov r1,#2
119         str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_MAMCR]       // enable full MAM
120         .endm
121                 
122         .macro _gpio_init
123         ldr r0,=CYGARC_HAL_LPC2XXX_REG_PIN_BASE // enable  RX and TX on UART0
124         ldr r1,=0x00000005
125         str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PINSEL0]
126         .endm
127         
128 #define CYGHWR_LED_MACRO _led \x 
129
130 //===========================================================================*/
131                         
132 #if defined(CYG_HAL_STARTUP_ROM)
133                         
134         .macro  _setup
135         
136         _pll_init
137         
138         _mem_init
139         
140         _gpio_init
141         
142         _led_init
143         
144         .endm
145
146 #define CYGSEM_HAL_ROM_RESET_USES_JUMP
147
148 #else
149
150         .macro  _setup
151         .endm
152         
153 #endif
154
155 #define PLATFORM_SETUP1     _setup
156
157         
158 //-----------------------------------------------------------------------------
159 // end of hal_platform_setup.h
160 #endif // CYGONCE_HAL_PLATFORM_SETUP_H