1 |
27 |
unneback |
//==========================================================================
|
2 |
|
|
//
|
3 |
|
|
// assabet_misc.c
|
4 |
|
|
//
|
5 |
|
|
// HAL misc board support code for StrongARM SA1110/Assabet
|
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): gthomas
|
44 |
|
|
// Contributors: hmt
|
45 |
|
|
// Travis C. Furrer <furrer@mit.edu>
|
46 |
|
|
// Date: 2000-05-21
|
47 |
|
|
// Purpose: HAL board support
|
48 |
|
|
// Description: Implementations of HAL board interfaces
|
49 |
|
|
//
|
50 |
|
|
//####DESCRIPTIONEND####
|
51 |
|
|
//
|
52 |
|
|
//========================================================================*/
|
53 |
|
|
|
54 |
|
|
#include <pkgconf/hal.h>
|
55 |
|
|
#include <pkgconf/system.h>
|
56 |
|
|
#include CYGBLD_HAL_PLATFORM_H
|
57 |
|
|
|
58 |
|
|
#include <cyg/infra/cyg_type.h> // base types
|
59 |
|
|
#include <cyg/infra/cyg_trac.h> // tracing macros
|
60 |
|
|
#include <cyg/infra/cyg_ass.h> // assertion macros
|
61 |
|
|
|
62 |
|
|
#include <cyg/hal/hal_io.h> // IO macros
|
63 |
|
|
#include <cyg/hal/hal_arch.h> // Register state info
|
64 |
|
|
#include <cyg/hal/hal_diag.h>
|
65 |
|
|
#include <cyg/hal/hal_intr.h> // Interrupt names
|
66 |
|
|
#include <cyg/hal/hal_cache.h>
|
67 |
|
|
#include <cyg/hal/hal_sa11x0.h> // Hardware definitions
|
68 |
|
|
#include <cyg/hal/assabet.h> // Platform specifics
|
69 |
|
|
|
70 |
|
|
#include <cyg/infra/diag.h> // diag_printf
|
71 |
|
|
|
72 |
|
|
// All the MM table layout is here:
|
73 |
|
|
#include <cyg/hal/hal_mm.h>
|
74 |
|
|
|
75 |
|
|
#include <string.h> // memset
|
76 |
|
|
|
77 |
|
|
void
|
78 |
|
|
hal_mmu_init(void)
|
79 |
|
|
{
|
80 |
|
|
unsigned long ttb_base = SA11X0_RAM_BANK0_BASE + 0x4000;
|
81 |
|
|
unsigned long i;
|
82 |
|
|
|
83 |
|
|
/*
|
84 |
|
|
* Set the TTB register
|
85 |
|
|
*/
|
86 |
|
|
asm volatile ("mcr p15,0,%0,c2,c0,0" : : "r"(ttb_base) /*:*/);
|
87 |
|
|
|
88 |
|
|
/*
|
89 |
|
|
* Set the Domain Access Control Register
|
90 |
|
|
*/
|
91 |
|
|
i = ARM_ACCESS_DACR_DEFAULT;
|
92 |
|
|
asm volatile ("mcr p15,0,%0,c3,c0,0" : : "r"(i) /*:*/);
|
93 |
|
|
|
94 |
|
|
/*
|
95 |
|
|
* First clear all TT entries - ie Set them to Faulting
|
96 |
|
|
*/
|
97 |
|
|
memset((void *)ttb_base, 0, ARM_FIRST_LEVEL_PAGE_TABLE_SIZE);
|
98 |
|
|
|
99 |
|
|
/* Actual Virtual Size Attributes Function */
|
100 |
|
|
/* Base Base MB cached? buffered? access permissions */
|
101 |
|
|
/* xxx00000 xxx00000 */
|
102 |
|
|
X_ARM_MMU_SECTION(0x000, 0x500, 32, ARM_CACHEABLE, ARM_BUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* Boot flash ROMspace */
|
103 |
|
|
X_ARM_MMU_SECTION(0x080, 0x080, 4, ARM_CACHEABLE, ARM_BUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* Application flash ROM */
|
104 |
|
|
X_ARM_MMU_SECTION(0x100, 0x100, 128, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SA-1101 Development Board Registers */
|
105 |
|
|
X_ARM_MMU_SECTION(0x180, 0x180, 128, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* Ethernet Adaptor */
|
106 |
|
|
X_ARM_MMU_SECTION(0x184, 0x184, 1, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* XBusReg */
|
107 |
|
|
X_ARM_MMU_SECTION(0x188, 0x188, 1, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SysRegA */
|
108 |
|
|
X_ARM_MMU_SECTION(0x18C, 0x18C, 1, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SysRegB */
|
109 |
|
|
X_ARM_MMU_SECTION(0x190, 0x190, 4, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* CPLD A */
|
110 |
|
|
X_ARM_MMU_SECTION(0x194, 0x194, 4, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* CPLD B */
|
111 |
|
|
X_ARM_MMU_SECTION(0x200, 0x200, 512, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* PCMCIA Socket A */
|
112 |
|
|
X_ARM_MMU_SECTION(0x300, 0x300, 512, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* PCMCIA Sockets B */
|
113 |
|
|
X_ARM_MMU_SECTION(0x400, 0x400, 128, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* SA1111 Daughter card */
|
114 |
|
|
X_ARM_MMU_SECTION(0x480, 0x480, 128, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* Video Controller Daughter card */
|
115 |
|
|
X_ARM_MMU_SECTION(0x800, 0x800, 0x400, ARM_UNCACHEABLE, ARM_UNBUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* StrongARM(R) Registers */
|
116 |
|
|
X_ARM_MMU_SECTION(0xC00, 0, 32, ARM_CACHEABLE, ARM_BUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* DRAM Bank 0 */
|
117 |
|
|
X_ARM_MMU_SECTION(0xC00, 0xC00, 32, ARM_UNCACHEABLE, ARM_BUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* DRAM Bank 0 */
|
118 |
|
|
X_ARM_MMU_SECTION(0xE00, 0xE00, 128, ARM_CACHEABLE, ARM_BUFFERABLE, ARM_ACCESS_PERM_RW_RW); /* Zeros (Cache Clean) Bank */
|
119 |
|
|
|
120 |
|
|
}
|
121 |
|
|
|
122 |
|
|
//
|
123 |
|
|
// Board control register support
|
124 |
|
|
// Update the board control register (write only). Only the bits
|
125 |
|
|
// specified by 'mask' are changed to 'value'.
|
126 |
|
|
//
|
127 |
|
|
|
128 |
|
|
void
|
129 |
|
|
assabet_BCR(unsigned long mask, unsigned long value)
|
130 |
|
|
{
|
131 |
|
|
_assabet_BCR = (_assabet_BCR & ~mask) | (mask & value);
|
132 |
|
|
*SA1110_BOARD_CONTROL = _assabet_BCR;
|
133 |
|
|
}
|
134 |
|
|
|
135 |
|
|
//
|
136 |
|
|
// Platform specific initialization
|
137 |
|
|
//
|
138 |
|
|
|
139 |
|
|
void
|
140 |
|
|
plf_hardware_init(void)
|
141 |
|
|
{
|
142 |
|
|
// Force "alternate" use of GPIO pins used for LCD screen
|
143 |
|
|
*SA11X0_GPIO_ALTERNATE_FUNCTION |= 0x000003FC; // Bits 2..9
|
144 |
|
|
*SA11X0_GPIO_PIN_DIRECTION |= 0x000003FC; // Bits 2..9
|
145 |
|
|
*SA11X0_GPIO_PIN_OUTPUT_CLEAR = 0x000003FC; // Bits 2..9
|
146 |
|
|
}
|
147 |
|
|
|
148 |
|
|
#include CYGHWR_MEMORY_LAYOUT_H
|
149 |
|
|
typedef void code_fun(void);
|
150 |
|
|
void assabet_program_new_stack(void *func)
|
151 |
|
|
{
|
152 |
|
|
register CYG_ADDRESS stack_ptr asm("sp");
|
153 |
|
|
register CYG_ADDRESS old_stack asm("r4");
|
154 |
|
|
register code_fun *new_func asm("r0");
|
155 |
|
|
old_stack = stack_ptr;
|
156 |
|
|
stack_ptr = CYGMEM_REGION_ram + CYGMEM_REGION_ram_SIZE - sizeof(CYG_ADDRESS);
|
157 |
|
|
new_func = (code_fun*)func;
|
158 |
|
|
new_func();
|
159 |
|
|
stack_ptr = old_stack;
|
160 |
|
|
return;
|
161 |
|
|
}
|
162 |
|
|
|
163 |
|
|
// ------------------------------------------------------------------------
|
164 |
|
|
// EOF assabet_misc.c
|