1 |
27 |
unneback |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// mpc50_misc.c
|
4 |
|
|
//
|
5 |
|
|
// HAL misc board support code for MPC 5.0
|
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 Red Hat, 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 version.
|
16 |
|
|
//
|
17 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT ANY
|
18 |
|
|
// WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
19 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
20 |
|
|
// for more details.
|
21 |
|
|
//
|
22 |
|
|
// You should have received a copy of the GNU General Public License along
|
23 |
|
|
// with eCos; if not, write to the Free Software Foundation, Inc.,
|
24 |
|
|
// 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
|
25 |
|
|
//
|
26 |
|
|
// As a special exception, if other files instantiate templates or use macros
|
27 |
|
|
// or inline functions from this file, or you compile this file and link it
|
28 |
|
|
// with other works to produce a work based on this file, this file does not
|
29 |
|
|
// by itself cause the resulting work to be covered by the GNU General Public
|
30 |
|
|
// License. However the source code for this file must still be made available
|
31 |
|
|
// in accordance with section (3) of the GNU General Public License.
|
32 |
|
|
//
|
33 |
|
|
// This exception does not invalidate any other reasons why a work based on
|
34 |
|
|
// this file might be covered by the GNU General Public License.
|
35 |
|
|
//
|
36 |
|
|
// Alternative licenses for eCos may be arranged by contacting Red Hat, Inc.
|
37 |
|
|
// at http://sources.redhat.com/ecos/ecos-license/
|
38 |
|
|
// -------------------------------------------
|
39 |
|
|
//####ECOSGPLCOPYRIGHTEND####
|
40 |
|
|
//=============================================================================
|
41 |
|
|
//#####DESCRIPTIONBEGIN####
|
42 |
|
|
//
|
43 |
|
|
// Author(s): <knud.woehler@microplex.de>
|
44 |
|
|
// Date: 2003-01-06
|
45 |
|
|
//
|
46 |
|
|
//####DESCRIPTIONEND####
|
47 |
|
|
//
|
48 |
|
|
//========================================================================*/
|
49 |
|
|
#include <pkgconf/hal.h>
|
50 |
|
|
#include <pkgconf/system.h>
|
51 |
|
|
#include CYGBLD_HAL_PLATFORM_H
|
52 |
|
|
#include <cyg/infra/cyg_type.h>
|
53 |
|
|
#include <cyg/infra/cyg_trac.h>
|
54 |
|
|
#include <cyg/infra/cyg_ass.h>
|
55 |
|
|
#include <cyg/hal/hal_io.h>
|
56 |
|
|
#include <cyg/hal/hal_arch.h>
|
57 |
|
|
#include <cyg/hal/hal_diag.h>
|
58 |
|
|
#include <cyg/hal/hal_intr.h>
|
59 |
|
|
#include <cyg/hal/hal_cache.h>
|
60 |
|
|
#include <cyg/hal/hal_pxa2x0.h>
|
61 |
|
|
#include <cyg/hal/hal_misc.h>
|
62 |
|
|
#include <cyg/hal/mpc50.h>
|
63 |
|
|
#include <cyg/infra/diag.h>
|
64 |
|
|
#include <cyg/hal/hal_mm.h>
|
65 |
|
|
|
66 |
|
|
|
67 |
|
|
void hal_mmu_init(void)
|
68 |
|
|
{
|
69 |
|
|
#ifdef CYG_HAL_STARTUP_ROM
|
70 |
|
|
|
71 |
|
|
typedef cyg_uint32 aptr; // for arithmetic
|
72 |
|
|
|
73 |
|
|
unsigned long ttb_base = PXA2X0_RAM_BANK0_BASE + 0x4000;
|
74 |
|
|
unsigned long *SDRAMConfig;
|
75 |
|
|
int *p_hdsize = (int *)((aptr)(&hal_dram_size) | (0xA00u *SZ_1M));
|
76 |
|
|
int *p_hdtype = (int *)((aptr)(&hal_dram_type) | (0xA00u *SZ_1M));
|
77 |
|
|
|
78 |
|
|
*p_hdtype = 0;
|
79 |
|
|
for(SDRAMConfig=0; *SDRAMConfig != MPC50_VAL_MAGIC ;SDRAMConfig++);
|
80 |
|
|
SDRAMConfig += (MPC50_VAL_OFFS_MDCNFG>>2);
|
81 |
|
|
|
82 |
|
|
// set TTB Register
|
83 |
|
|
asm volatile ("mcr p15,0,%0,c2,c0,0" : : "r"(ttb_base));
|
84 |
|
|
|
85 |
|
|
// erase Page Table
|
86 |
|
|
memset((void *)ttb_base, 0, ARM_FIRST_LEVEL_PAGE_TABLE_SIZE);
|
87 |
|
|
|
88 |
|
|
// create Page Table
|
89 |
|
|
|
90 |
|
|
/* Actual Virtual Size Attribute Function */
|
91 |
|
|
/* Base Base MB cached? buffered? access permissions */
|
92 |
|
|
/* xxx00000 xxx00000 */
|
93 |
|
|
X_ARM_MMU_SECTION(0x000, 0x500, 16, ARM_CACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* Boot flash ROMspace */
|
94 |
|
|
X_ARM_MMU_SECTION(0x040, 0x600, 64, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* FPGA Register */
|
95 |
|
|
X_ARM_MMU_SECTION(0x080, 0x680, 64, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* LAN Register */
|
96 |
|
|
X_ARM_MMU_SECTION(0x400, 0x400, 192, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* PXA2x0 Register */
|
97 |
|
|
|
98 |
|
|
if((*SDRAMConfig & 0x00000018) == 0x08) // 32MB per bank
|
99 |
|
|
{
|
100 |
|
|
X_ARM_MMU_SECTION(0xA00, 0x0, 32, ARM_CACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM Bank 0 */
|
101 |
|
|
X_ARM_MMU_SECTION(0xA40, 0x020, 32, ARM_CACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM Bank 1 */
|
102 |
|
|
*p_hdsize = 64 * SZ_1M; // 64MB
|
103 |
|
|
if((*SDRAMConfig & 0x00030000) != 0) // 4 banks
|
104 |
|
|
{
|
105 |
|
|
X_ARM_MMU_SECTION(0xA80, 0x040, 32, ARM_CACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM Bank 2 */
|
106 |
|
|
X_ARM_MMU_SECTION(0xAc0, 0x060, 32, ARM_CACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM Bank 3 */
|
107 |
|
|
*p_hdsize = 128 * SZ_1M; // 128MB
|
108 |
|
|
}
|
109 |
|
|
}else{ // 64MB per bank
|
110 |
|
|
X_ARM_MMU_SECTION(0xA00, 0x0, 64, ARM_CACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM Bank 0 */
|
111 |
|
|
X_ARM_MMU_SECTION(0xA40, 0x040, 64, ARM_CACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM Bank 1 */
|
112 |
|
|
*p_hdsize = 128 * SZ_1M; // 128MB
|
113 |
|
|
if((*SDRAMConfig & 0x00030000) != 0) // 4 banks
|
114 |
|
|
{
|
115 |
|
|
X_ARM_MMU_SECTION(0xA80, 0x080, 64, ARM_CACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM Bank 2 */
|
116 |
|
|
X_ARM_MMU_SECTION(0xAc0, 0x0c0, 64, ARM_CACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SDRAM Bank 3 */
|
117 |
|
|
*p_hdsize = 256 * SZ_1M; // 256MB
|
118 |
|
|
}
|
119 |
|
|
}
|
120 |
|
|
X_ARM_MMU_SECTION(0xA00, 0xA00, 256, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* Unmapped Memory */
|
121 |
|
|
|
122 |
|
|
X_ARM_MMU_SECTION(0xC00, 0xC00, 128, ARM_CACHEABLE, ARM_BUFFERABLE, ARM_ACCESS_PERM_RW_RW);
|
123 |
|
|
#endif
|
124 |
|
|
}
|
125 |
|
|
|
126 |
|
|
void plf_hardware_init(void)
|
127 |
|
|
{
|
128 |
|
|
int t;
|
129 |
|
|
unsigned long int gpioValue ;
|
130 |
|
|
|
131 |
|
|
// enable FFUART clock
|
132 |
|
|
gpioValue = *PXA2X0_CKEN ;
|
133 |
|
|
gpioValue = gpioValue | (unsigned long)0x40 ;
|
134 |
|
|
*PXA2X0_CKEN = gpioValue ;
|
135 |
|
|
|
136 |
|
|
mpc50_user_hardware_init();
|
137 |
|
|
|
138 |
|
|
return ;
|
139 |
|
|
}
|
140 |
|
|
|
141 |
|
|
#include CYGHWR_MEMORY_LAYOUT_H
|
142 |
|
|
typedef void code_fun(void);
|
143 |
|
|
void mpc50_program_new_stack(void *func)
|
144 |
|
|
{
|
145 |
|
|
register CYG_ADDRESS stack_ptr asm("sp");
|
146 |
|
|
register CYG_ADDRESS old_stack asm("r4");
|
147 |
|
|
register code_fun *new_func asm("r0");
|
148 |
|
|
old_stack = stack_ptr;
|
149 |
|
|
stack_ptr = CYGMEM_REGION_ram + CYGMEM_REGION_ram_SIZE - sizeof(CYG_ADDRESS);
|
150 |
|
|
new_func = (code_fun*)func;
|
151 |
|
|
new_func();
|
152 |
|
|
stack_ptr = old_stack;
|
153 |
|
|
return;
|
154 |
|
|
}
|
155 |
|
|
|
156 |
|
|
//
|
157 |
|
|
// Memory layout
|
158 |
|
|
//
|
159 |
|
|
externC cyg_uint8 *
|
160 |
|
|
hal_arm_mem_real_region_top( cyg_uint8 *regionend )
|
161 |
|
|
{
|
162 |
|
|
CYG_ASSERT( hal_dram_size > 0, "Didn't detect DRAM size!" );
|
163 |
|
|
CYG_ASSERT( hal_dram_size <= 256<<20, "More than 256MB reported - that can't be right" );
|
164 |
|
|
CYG_ASSERT( 0 == (hal_dram_size & 0xfffff), "hal_dram_size not whole Mb" );
|
165 |
|
|
// is it the "normal" end of the DRAM region? If so, it should be
|
166 |
|
|
// replaced by the real size
|
167 |
|
|
if ( regionend == ((cyg_uint8 *)CYGMEM_REGION_ram + CYGMEM_REGION_ram_SIZE) )
|
168 |
|
|
{
|
169 |
|
|
regionend = (cyg_uint8 *)CYGMEM_REGION_ram + hal_dram_size;
|
170 |
|
|
}
|
171 |
|
|
return regionend;
|
172 |
|
|
}
|
173 |
|
|
|
174 |
|
|
void mpc50_user_hardware_init(void) CYGBLD_ATTRIB_WEAK;
|
175 |
|
|
|
176 |
|
|
void mpc50_user_hardware_init()
|
177 |
|
|
{
|
178 |
|
|
}
|
179 |
|
|
|
180 |
|
|
|
181 |
|
|
|
182 |
|
|
/*------------------------------------------------------------------------*/
|
183 |
|
|
// EOF mpc50_misc.c
|