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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [arm/] [lpc2xxx/] [olpce2294/] [current/] [include/] [hal_platform_setup.h] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
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):     Sergei Gavrikov
45
// Contributors:  Sergei Gavrikov
46
// Date:          2008-08-31
47
// Purpose:       Olimex LPC-E2294 platform specific support routines
48
// Description:
49
// Usage:         #include <cyg/hal/hal_platform_setup.h>
50
//
51
//####DESCRIPTIONEND####
52
//
53
//===========================================================================*/
54
 
55
#include <pkgconf/system.h>
56
#include <cyg/hal/var_io.h>
57
 
58
        // There are no diagnostic leds on the board, but there is a LCD there
59
        // with BACKLIGHT feature. No way to display some info on LCD here, but
60
        // we can drive by BACKLIGHT put to a cathode a static signal.
61
 
62
        .macro  _led_init
63
        ldr r0,=CYGARC_HAL_LPC2XXX_REG_IO_BASE
64
        ldr r1,[r0,#CYGARC_HAL_LPC2XXX_REG_IO0DIR]
65
        orr r1,r1,#(1<<10)
66
        str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_IO0DIR]
67
 
68
        .endm // _led_init
69
 
70
        .macro _led x
71
        ldr r0,=CYGARC_HAL_LPC2XXX_REG_IO_BASE
72
        ldr r1,=(1<<10)
73
        str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_IO0CLR]
74
        ldr r1,=((\x & 1)<<10)
75
        str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_IO0SET]
76
 
77
        .endm // _led
78
 
79
        .macro _pll_init
80
        ldr r0,=CYGARC_HAL_LPC2XXX_REG_SCB_BASE
81
 
82
        mov r2,#0xAA
83
        mov r3,#0x55
84
 
85
        // enable PLL
86
        mov r1,#1
87
        str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLCON]
88
 
89
        mov r1,#(0x20 | (CYGNUM_HAL_ARM_LPC2XXX_PLL_MUL - 1))
90
        str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLCFG]
91
 
92
        // update PLL registers
93
        str r2,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLFEED]
94
        str r3,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLFEED]
95
 
96
        // wait for it to lock
97
1:
98
        ldr r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLSTAT]
99
        ands r1,r1,#(1<<10)
100
        beq 1b
101
 
102
        // connect PLL
103
        mov r1,#3
104
        str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLCON]
105
 
106
        // update PLL registers
107
        str r2,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLFEED]
108
        str r3,[r0,#CYGARC_HAL_LPC2XXX_REG_PLLFEED]
109
 
110
        .endm // _pll_init
111
 
112
        .macro _mem_init
113
        // copy first 64 bytes from ROM to on-chip RAM
114
        mov r0,#0
115
        mov r1,#0x40000000
116
        mov r2,#0x40
117
1:
118
        ldr r3,[r0,#4]!
119
        str r3,[r1,#4]!
120
        cmp r0,r2
121
        bne 1b
122
 
123
        ldr r0,=CYGARC_HAL_LPC2XXX_REG_SCB_BASE
124
        mov r1,#2 // interrupt vector table is mapped to RAM
125
        str r1, [r0,#CYGARC_HAL_LPC2XXX_REG_MEMMAP]
126
 
127
        // flash timings
128
        mov r1,#4
129
        str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_MAMTIM]
130
        mov r1,#2 // 2, full MAM
131
        str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_MAMCR]
132
 
133
        // External memory interface depends on the bank width (32, 16 or 8 bit
134
        // selected via MW bits in corresponding BCFG register).  Furthermore,
135
        // choice of the memory chip(s) will require an adequate setup of RBLE
136
        // bit in BCFG register, too. RBLE = 0 in case of 8-bit based external
137
        // memories, while memory chips capable of accepting 16 or 32 bit wide
138
        // data will work with RBLE = 1.
139
        //
140
        // BANK0: 4M FLASH
141
        // TE28F320C3BD70 (1024Kx32 x 1, 70nS)
142
        ldr r0,=CYGARC_HAL_LPC2XXX_REG_BCFG0
143
        ldr r1,=  (0x3 << 0)    /* IDCY=3, idle timing  */\
144
                | (0x4 << 5)    /* WST1=4, read timing  */\
145
                | (0x1 << 10)   /* RBLE=1               */\
146
                | (0x6 << 11)   /* WST2=6, write timing */\
147
                | (0x1 << 28)   /* MW=1,   16-bits      */
148
        str r1,[r0]
149
 
150
        // BANK1: 1M RAM
151
        // K6R4016V1D (512Kx16 x 2, 10nS)
152
        ldr r0,=CYGARC_HAL_LPC2XXX_REG_BCFG1
153
        // Warning: changed these timings, you can fall dramatically the eCos
154
        // kernel performance. Check it then using the eCos 'tm_basic' test.
155
        ldr r1,=  (0x0 << 0)    /* IDCY=0, idle cycles  */\
156
                | (0x0 << 5)    /* WST1=0, read timing  */\
157
                | (0x1 << 10)   /* RBLE=1               */\
158
                | (0x0 << 11)   /* WST2=0, write timing */\
159
                | (0x2 << 28)   /* MW=2,   32-bits      */
160
        str r1,[r0]
161
 
162
        // BANK2: Ethernet
163
        // CS8900A (8-bit, no interrupt driven mode)
164
        ldr r0,=CYGARC_HAL_LPC2XXX_REG_BCFG2
165
        ldr r1,=  (0x1 << 0)    /* IDCY=1, idle cycles  */\
166
                | (0x8 << 5)    /* WST1=8, read timing  */\
167
                | (0x1 << 10)   /* RBLE=1               */\
168
                | (0x6 << 11)   /* WST2=6, write timing */\
169
                | (0x0 << 28)   /* MW=0,   8-bits       */
170
        str r1,[r0]
171
 
172
        .endm // _mem_init
173
 
174
        .macro _gpio_init
175
        ldr r0,=CYGARC_HAL_LPC2XXX_REG_PIN_BASE
176
 
177
        // Configure P0.15:0 as PIO, but UART0, UART1, EINT2 ('B1' button)
178
        ldr r1,=  (0x1 << 0)    /* P0.0 as TxD0         */\
179
                | (0x1 << 2)    /* P0.1 as RxD0         */\
180
                | (0x1 << 16)   /* P0.1 as TxD1         */\
181
                | (0x1 << 18)   /* P0.1 as RxD1         */\
182
                | (0x2 << 30)   /* P0.15 as EINT2       */
183
        str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PINSEL0]
184
 
185
        // Configure P0.30:16 as PIO, but EINT0 ('B2' button)
186
        ldr r1,=  (0x1 << 0)    /* P0.16 as EINT0       */
187
        str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PINSEL1]
188
 
189
        // GPIO P1.25:16, P3.24 are used as PIO
190
        ldr r1,=  (0x1 << 2)    /* P1.31:26 Debug port  */\
191
                | (0x2 << 4)    /* D31:0,CS0,OE,BLS0-3  */\
192
                | (0x1 << 8)    /* WE enabled           */\
193
                | (0x1 << 11)   /* CS1 enabled          */\
194
                | (0x1 << 14)   /* CS2 enabled          */\
195
                | (0x1 << 23)   /* A0 enabled           */\
196
                | (0x1 << 24)   /* A1 enabled           */\
197
                | (0x7 << 25)   /* A23:2 enabled        */
198
        str r1,[r0,#CYGARC_HAL_LPC2XXX_REG_PINSEL2]
199
 
200
        .endm // _gpio_init
201
 
202
#define CYGHWR_LED_MACRO _led \x
203
 
204
#if defined(CYG_HAL_STARTUP_ROM)
205
 
206
        .macro  _setup
207
 
208
        _pll_init
209
 
210
        _mem_init
211
 
212
        _gpio_init
213
 
214
        _led_init
215
 
216
        .endm
217
 
218
#define CYGSEM_HAL_ROM_RESET_USES_JUMP
219
 
220
#else
221
 
222
        .macro  _setup
223
 
224
        .endm
225
 
226
#endif // CYG_HAL_STARTUP_ROM
227
 
228
#define PLATFORM_SETUP1     _setup
229
 
230
#endif // CYGONCE_HAL_PLATFORM_SETUP_H
231
 

powered by: WebSVN 2.1.0

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