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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [hal/] [arm/] [sa11x0/] [cerf/] [current/] [src/] [cerf_misc.c] - Blame information for rev 786

Details | Compare with Previous | View Log

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

powered by: WebSVN 2.1.0

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