1 |
786 |
skrzyp |
//=============================================================================
|
2 |
|
|
//
|
3 |
|
|
// uE250_misc.c
|
4 |
|
|
//
|
5 |
|
|
// Miscellaneous platform support for NMI uE250
|
6 |
|
|
//
|
7 |
|
|
//=============================================================================
|
8 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
9 |
|
|
// -------------------------------------------
|
10 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
11 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
|
12 |
|
|
//
|
13 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
14 |
|
|
// the terms of the GNU General Public License as published by the Free
|
15 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
16 |
|
|
// version.
|
17 |
|
|
//
|
18 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
19 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
20 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
21 |
|
|
// for more details.
|
22 |
|
|
//
|
23 |
|
|
// You should have received a copy of the GNU General Public License
|
24 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
25 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
26 |
|
|
//
|
27 |
|
|
// As a special exception, if other files instantiate templates or use
|
28 |
|
|
// macros or inline functions from this file, or you compile this file
|
29 |
|
|
// and link it with other works to produce a work based on this file,
|
30 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
31 |
|
|
// the GNU General Public License. However the source code for this file
|
32 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
33 |
|
|
// General Public License v2.
|
34 |
|
|
//
|
35 |
|
|
// This exception does not invalidate any other reasons why a work based
|
36 |
|
|
// on this file might be covered by the GNU General Public License.
|
37 |
|
|
// -------------------------------------------
|
38 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
39 |
|
|
//=============================================================================
|
40 |
|
|
|
41 |
|
|
#include <pkgconf/hal.h>
|
42 |
|
|
#include <pkgconf/system.h>
|
43 |
|
|
#include CYGBLD_HAL_PLATFORM_H
|
44 |
|
|
|
45 |
|
|
#include <cyg/infra/cyg_type.h> // base types
|
46 |
|
|
#include <cyg/infra/cyg_trac.h> // tracing macros
|
47 |
|
|
#include <cyg/infra/cyg_ass.h> // assertion macros
|
48 |
|
|
|
49 |
|
|
#include <cyg/hal/hal_io.h> // IO macros
|
50 |
|
|
#include <cyg/hal/hal_arch.h> // Register state info
|
51 |
|
|
#include <cyg/hal/hal_diag.h>
|
52 |
|
|
#include <cyg/hal/hal_intr.h> // Interrupt names
|
53 |
|
|
#include <cyg/hal/hal_cache.h>
|
54 |
|
|
#include <cyg/hal/hal_pxa2x0.h>
|
55 |
|
|
// FIXME
|
56 |
|
|
#include <cyg/hal/uE250.h> // Platform specifics
|
57 |
|
|
|
58 |
|
|
#include <cyg/infra/diag.h> // diag_printf
|
59 |
|
|
|
60 |
|
|
#include <cyg/hal/hal_mm.h>
|
61 |
|
|
|
62 |
|
|
#include <string.h> // memset
|
63 |
|
|
|
64 |
|
|
externC void initialize_plx_bridge(void);
|
65 |
|
|
|
66 |
|
|
void
|
67 |
|
|
hal_mmu_init(void)
|
68 |
|
|
{
|
69 |
|
|
// Set up the translation tables at offset 0x4000
|
70 |
|
|
unsigned long ttb_base = PXA2X0_RAM_BANK0_BASE + 0x4000;
|
71 |
|
|
unsigned long i;
|
72 |
|
|
|
73 |
|
|
/*
|
74 |
|
|
* Set the TTB register
|
75 |
|
|
*/
|
76 |
|
|
asm volatile ("mcr p15,0,%0,c2,c0,0" : : "r"(ttb_base) /*:*/);
|
77 |
|
|
|
78 |
|
|
/*
|
79 |
|
|
* Set the Domain Access Control Register
|
80 |
|
|
*/
|
81 |
|
|
i = ARM_ACCESS_DACR_DEFAULT;
|
82 |
|
|
asm volatile ("mcr p15,0,%0,c3,c0,0" : : "r"(i) /*:*/);
|
83 |
|
|
|
84 |
|
|
/*
|
85 |
|
|
* First clear all TT entries - ie Set them to Faulting
|
86 |
|
|
*/
|
87 |
|
|
memset((void *)ttb_base, 0, ARM_FIRST_LEVEL_PAGE_TABLE_SIZE);
|
88 |
|
|
|
89 |
|
|
/* Actual Virtual Size Attributes Function */
|
90 |
|
|
/* Base Base MB cached? buffered? access permissions */
|
91 |
|
|
/* xxx00000 xxx00000 */
|
92 |
|
|
#define _CACHED ARM_CACHEABLE
|
93 |
|
|
#define _UNCACHED ARM_UNCACHEABLE
|
94 |
|
|
#define _BUF ARM_BUFFERABLE
|
95 |
|
|
#define _NOBUF ARM_UNBUFFERABLE
|
96 |
|
|
#define _RWRW ARM_ACCESS_PERM_RW_RW
|
97 |
|
|
X_ARM_MMU_SECTION(0x000, 0x500, 32, _CACHED, _BUF, _RWRW); /* Boot flash ROMspace */
|
98 |
|
|
X_ARM_MMU_SECTION(0x150, 0x150, 4, _UNCACHED, _NOBUF, _RWRW); /* PCI Config space CS5 */
|
99 |
|
|
X_ARM_MMU_SECTION(0x040, 0x340, 64, _UNCACHED, _NOBUF, _RWRW); /* PCI Control regs CS1 */
|
100 |
|
|
X_ARM_MMU_SECTION(0xA00, 0x000, 64, _CACHED, _BUF, _RWRW); /* DRAM Bank 0 */
|
101 |
|
|
X_ARM_MMU_SECTION(0xA00, 0xC00, 64, _UNCACHED, _BUF, _RWRW); /* DRAM Bank 0 */
|
102 |
|
|
X_ARM_MMU_SECTION(0xE00, 0xE00, 128, _CACHED, _BUF, _RWRW); /* Zeros (Cache Clean) Bank */
|
103 |
|
|
|
104 |
|
|
X_ARM_MMU_SECTION(0x0c0, 0x0c0, 64, _UNCACHED, _NOBUF, _RWRW); /* PCI Mem space CS3 */
|
105 |
|
|
X_ARM_MMU_SECTION(0x100, 0x100, 64, _UNCACHED, _NOBUF, _RWRW); /* PCI Mem space CS4 */
|
106 |
|
|
X_ARM_MMU_SECTION(0x140, 0x140, 16, _UNCACHED, _NOBUF, _RWRW); /* PCI Mem space CS5 */
|
107 |
|
|
X_ARM_MMU_SECTION(0x160, 0x160, 32, _UNCACHED, _NOBUF, _RWRW); /* PCI I/O space CS5 */
|
108 |
|
|
X_ARM_MMU_SECTION(0x400, 0x400, 64, _UNCACHED, _NOBUF, _RWRW); /* Peripheral Registers */
|
109 |
|
|
X_ARM_MMU_SECTION(0x440, 0x440, 64, _UNCACHED, _NOBUF, _RWRW); /* LCD Registers */
|
110 |
|
|
X_ARM_MMU_SECTION(0x480, 0x480, 64, _UNCACHED, _NOBUF, _RWRW); /* Memory Ctl Registers */
|
111 |
|
|
X_ARM_MMU_SECTION(0x900, 0x900, 64, _UNCACHED, _NOBUF, _RWRW); /* PCI I/O Space */
|
112 |
|
|
}
|
113 |
|
|
|
114 |
|
|
//
|
115 |
|
|
// Platform specific initialization
|
116 |
|
|
//
|
117 |
|
|
|
118 |
|
|
void
|
119 |
|
|
plf_hardware_init(void)
|
120 |
|
|
{
|
121 |
|
|
|
122 |
|
|
*PXA2X0_GPCR0 = 0x00400000;
|
123 |
|
|
// PXA250_GPSR0 = 0x00200000;
|
124 |
|
|
|
125 |
|
|
// RAM startup only - rewrite relevent bits depending on config
|
126 |
|
|
#ifndef CYG_HAL_STARTUP_ROM
|
127 |
|
|
HAL_DCACHE_SYNC(); // Force data out
|
128 |
|
|
HAL_DCACHE_INVALIDATE_ALL(); // Flush TLBs: make new mmu state effective
|
129 |
|
|
#endif // ! CYG_HAL_STARTUP_ROM - RAM start only
|
130 |
|
|
|
131 |
|
|
hal_if_init();
|
132 |
|
|
|
133 |
|
|
cyg_hal_plf_pci_init();
|
134 |
|
|
|
135 |
|
|
initialize_plx_bridge();
|
136 |
|
|
}
|
137 |
|
|
|
138 |
|
|
//
|
139 |
|
|
// Memory layout - runtime variations of all kinds.
|
140 |
|
|
//
|
141 |
|
|
externC cyg_uint8 *
|
142 |
|
|
hal_arm_mem_real_region_top( cyg_uint8 *regionend )
|
143 |
|
|
{
|
144 |
|
|
CYG_ASSERT( hal_dram_size > 0, "Didn't detect DRAM size!" );
|
145 |
|
|
CYG_ASSERT( hal_dram_size <= 256<<20,
|
146 |
|
|
"More than 256MB reported - that can't be right" );
|
147 |
|
|
CYG_ASSERT( 0 == (hal_dram_size & 0xfffff),
|
148 |
|
|
"hal_dram_size not whole Mb" );
|
149 |
|
|
// is it the "normal" end of the DRAM region? If so, it should be
|
150 |
|
|
// replaced by the real size
|
151 |
|
|
if ( regionend ==
|
152 |
|
|
((cyg_uint8 *)CYGMEM_REGION_ram + CYGMEM_REGION_ram_SIZE) ) {
|
153 |
|
|
regionend = (cyg_uint8 *)CYGMEM_REGION_ram + hal_dram_size;
|
154 |
|
|
}
|
155 |
|
|
// Also, we must check for the top of the heap having moved. This is
|
156 |
|
|
// because the heap does not abut the top of memory.
|
157 |
|
|
#ifdef CYGMEM_SECTION_heap1
|
158 |
|
|
if ( regionend ==
|
159 |
|
|
((cyg_uint8 *)CYGMEM_SECTION_heap1 + CYGMEM_SECTION_heap1_SIZE) ) {
|
160 |
|
|
// hal_dram_size excludes the PCI window on this platform.
|
161 |
|
|
if ( regionend > (cyg_uint8 *)CYGMEM_REGION_ram + hal_dram_size )
|
162 |
|
|
regionend = (cyg_uint8 *)CYGMEM_REGION_ram + hal_dram_size;
|
163 |
|
|
}
|
164 |
|
|
#endif
|
165 |
|
|
return regionend;
|
166 |
|
|
}
|
167 |
|
|
|
168 |
|
|
// ------------------------------------------------------------------------
|
169 |
|
|
// Extended, platform-specific, interrupt handling
|
170 |
|
|
|
171 |
|
|
// FIXME - still needs work to support interrupts from PXA bridge
|
172 |
|
|
|
173 |
|
|
int
|
174 |
|
|
_uE250_extended_irq(void)
|
175 |
|
|
{
|
176 |
|
|
cyg_uint32 stat = PCICTL_STATUS_REG;
|
177 |
|
|
int irq = 0;
|
178 |
|
|
|
179 |
|
|
if (stat & 0x1F0) {
|
180 |
|
|
PCICTL_INT_RESET = 0xFF; // Clear all pending interrupts
|
181 |
|
|
}
|
182 |
|
|
if (stat & 0x00F) {
|
183 |
|
|
// PCI interrupt
|
184 |
|
|
for (irq = 0; irq < 4; irq++) {
|
185 |
|
|
if ((stat & (1 << irq)) != 0) {
|
186 |
|
|
break;
|
187 |
|
|
}
|
188 |
|
|
}
|
189 |
|
|
irq += _uPCI_BASE_INTERRUPT;
|
190 |
|
|
}
|
191 |
|
|
HAL_INTERRUPT_ACKNOWLEDGE(CYGNUM_HAL_INTERRUPT_GPIO1);
|
192 |
|
|
PCICTL_INT_EDGE = 0xFF; // Generate interrupts
|
193 |
|
|
return irq;
|
194 |
|
|
}
|
195 |
|
|
|
196 |
|
|
void
|
197 |
|
|
_uE250_extended_int_mask(int vector)
|
198 |
|
|
{
|
199 |
|
|
if (vector <= CYGNUM_HAL_INTERRUPT_PCI_INTD) {
|
200 |
|
|
PCICTL_IRQ_MASK &= ~(1<<(vector-CYGNUM_HAL_INTERRUPT_PCI_INTA));
|
201 |
|
|
}
|
202 |
|
|
}
|
203 |
|
|
|
204 |
|
|
void
|
205 |
|
|
_uE250_extended_int_unmask(int vector)
|
206 |
|
|
{
|
207 |
|
|
if (vector <= CYGNUM_HAL_INTERRUPT_PCI_INTD) {
|
208 |
|
|
PCICTL_IRQ_MASK |= (1<<(vector-CYGNUM_HAL_INTERRUPT_PCI_INTA));
|
209 |
|
|
}
|
210 |
|
|
}
|
211 |
|
|
|
212 |
|
|
void
|
213 |
|
|
_uE250_extended_int_acknowledge(int vector)
|
214 |
|
|
{
|
215 |
|
|
}
|
216 |
|
|
|
217 |
|
|
void
|
218 |
|
|
_uE250_extended_int_configure(int vector, int level, int up)
|
219 |
|
|
{
|
220 |
|
|
}
|
221 |
|
|
|
222 |
|
|
void
|
223 |
|
|
_uE250_extended_int_set_level(int vector, int level)
|
224 |
|
|
{
|
225 |
|
|
}
|
226 |
|
|
|
227 |
|
|
|
228 |
|
|
// ------------------------------------------------------------------------
|
229 |
|
|
// EOF uE250_misc.c
|