1 |
786 |
skrzyp |
#ifndef CYGONCE_HAL_VAR_SETUP_H
|
2 |
|
|
#define CYGONCE_HAL_VAR_SETUP_H
|
3 |
|
|
|
4 |
|
|
//=============================================================================
|
5 |
|
|
//
|
6 |
|
|
// hal_var_setup.h
|
7 |
|
|
//
|
8 |
|
|
// Variant specific support for HAL (assembly code)
|
9 |
|
|
//
|
10 |
|
|
//=============================================================================
|
11 |
|
|
// ####ECOSGPLCOPYRIGHTBEGIN####
|
12 |
|
|
// -------------------------------------------
|
13 |
|
|
// This file is part of eCos, the Embedded Configurable Operating System.
|
14 |
|
|
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2006 Free Software Foundation, Inc.
|
15 |
|
|
//
|
16 |
|
|
// eCos is free software; you can redistribute it and/or modify it under
|
17 |
|
|
// the terms of the GNU General Public License as published by the Free
|
18 |
|
|
// Software Foundation; either version 2 or (at your option) any later
|
19 |
|
|
// version.
|
20 |
|
|
//
|
21 |
|
|
// eCos is distributed in the hope that it will be useful, but WITHOUT
|
22 |
|
|
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
23 |
|
|
// FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
24 |
|
|
// for more details.
|
25 |
|
|
//
|
26 |
|
|
// You should have received a copy of the GNU General Public License
|
27 |
|
|
// along with eCos; if not, write to the Free Software Foundation, Inc.,
|
28 |
|
|
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
29 |
|
|
//
|
30 |
|
|
// As a special exception, if other files instantiate templates or use
|
31 |
|
|
// macros or inline functions from this file, or you compile this file
|
32 |
|
|
// and link it with other works to produce a work based on this file,
|
33 |
|
|
// this file does not by itself cause the resulting work to be covered by
|
34 |
|
|
// the GNU General Public License. However the source code for this file
|
35 |
|
|
// must still be made available in accordance with section (3) of the GNU
|
36 |
|
|
// General Public License v2.
|
37 |
|
|
//
|
38 |
|
|
// This exception does not invalidate any other reasons why a work based
|
39 |
|
|
// on this file might be covered by the GNU General Public License.
|
40 |
|
|
// -------------------------------------------
|
41 |
|
|
// ####ECOSGPLCOPYRIGHTEND####
|
42 |
|
|
//=============================================================================
|
43 |
|
|
//#####DESCRIPTIONBEGIN####
|
44 |
|
|
//
|
45 |
|
|
// Author(s): Ilija Koco <ilijak@siva.com.mk>
|
46 |
|
|
// Contributors:
|
47 |
|
|
// Date: 2006-06-05
|
48 |
|
|
// Purpose: MAC7100 variant specific support routines
|
49 |
|
|
// Description:
|
50 |
|
|
// Usage: in <cyg/hal/hal_platform_serup.h> include following:
|
51 |
|
|
// #include <cyg/hal/hal_var_setup.h>
|
52 |
|
|
//
|
53 |
|
|
//####DESCRIPTIONEND####
|
54 |
|
|
//
|
55 |
|
|
//===========================================================================
|
56 |
|
|
|
57 |
|
|
// Clock initilalization
|
58 |
|
|
// Initialize PLL
|
59 |
|
|
#if defined(CYGNUM_HAL_ARM_MAC7100_FDIV) // Divider set by user.
|
60 |
|
|
# define MAC7100_CRG_REFDV_VAL (CYGNUM_HAL_ARM_MAC7100_FDIV-1)
|
61 |
|
|
#else // Divider calculated.
|
62 |
|
|
//NOTE: works for f_osc <= 8MHz
|
63 |
|
|
# define MAC7100_CRG_REFDV_VAL (((CYGNUM_HAL_ARM_MAC7100_F_OSC/500000) - 1) & 0x0F) // 15 (1)
|
64 |
|
|
#endif
|
65 |
|
|
#define MAC7100_CRG_SYNR_VAL (CYGNUM_HAL_ARM_MAC7100_CLOCK_SPEED / 2 / \
|
66 |
|
|
(CYGNUM_HAL_ARM_MAC7100_F_OSC / (MAC7100_CRG_REFDV_VAL+1))-1) // 47 (5)
|
67 |
|
|
|
68 |
|
|
#define MAC7100_CRG_PLLCTL_VAL \
|
69 |
|
|
(MAC7100_CRG_CME|MAC7100_CRG_PLLON|MAC7100_CRG_AUTO| \
|
70 |
|
|
MAC7100_CRG_ACQ|MAC7100_CRG_SCME)
|
71 |
|
|
#define MAC7100_CRG_CLKSEL_VAL (MAC7100_CRG_PLLSEL)
|
72 |
|
|
|
73 |
|
|
.macro _mac7100_setpll
|
74 |
|
|
ldr r2,=MAC7100_CRG_BASE
|
75 |
|
|
mov r3,#0
|
76 |
|
|
// Disable clock interrupts
|
77 |
|
|
strb r3,[r2,#(MAC7100_CRG_CRGINT-MAC7100_CRG_BASE)]
|
78 |
|
|
// DeSelect PLL clock
|
79 |
|
|
mov r3,#MAC7100_CRG_REFDV_VAL
|
80 |
|
|
// Reference Divider reg.
|
81 |
|
|
strb r3,[r2,#(MAC7100_CRG_REFDV-MAC7100_CRG_BASE)]
|
82 |
|
|
mov r3,#MAC7100_CRG_SYNR_VAL
|
83 |
|
|
// Synthesizer register
|
84 |
|
|
strb r3,[r2,#(MAC7100_CRG_SYNR-MAC7100_CRG_BASE)]
|
85 |
|
|
mov r3,#MAC7100_CRG_PLLCTL_VAL
|
86 |
|
|
// PLL control register
|
87 |
|
|
strb r3,[r2,#(MAC7100_CRG_PLLCTL-MAC7100_CRG_BASE)]
|
88 |
|
|
// Wait PLL lock <-----------------------------------<
|
89 |
|
|
1: ldrb r3,[r2,#(MAC7100_CRG_CRGFLG-MAC7100_CRG_BASE)]
|
90 |
|
|
tst r3,#MAC7100_CRG_LOCK
|
91 |
|
|
bne 2f // PLL locked, GO ON ---------->>
|
92 |
|
|
b 1b // Still waiting for PLL lock ------------>
|
93 |
|
|
2: mov r3,#MAC7100_CRG_CLKSEL_VAL // <<-------<<
|
94 |
|
|
// Select PLL clock
|
95 |
|
|
strb r3,[r2,#(MAC7100_CRG_CLKSEL-MAC7100_CRG_BASE)]
|
96 |
|
|
mov r3,#0
|
97 |
|
|
strb r3,[r2,#(MAC7100_CRG_BDMCTL-MAC7100_CRG_BASE)] // Set CRG BDMCTL
|
98 |
|
|
mov r3,r3
|
99 |
|
|
.endm
|
100 |
|
|
|
101 |
|
|
// Memory re-mapping for single chip configuration
|
102 |
|
|
// Re-map internal memory so that vectors can reside in RAM.
|
103 |
|
|
// RAM base 0x00000000 (as well as 0x40000000)
|
104 |
|
|
// Flash base 0x20000000
|
105 |
|
|
.macro _mac7100_remap_single_chip
|
106 |
|
|
_led 1
|
107 |
|
|
ldr r1, _mac7100_teleport
|
108 |
|
|
ldr r0, [r1] //AAMR Register
|
109 |
|
|
|
110 |
|
|
mvn r4, #0xf0000000 // 1.Copy telepoter to RAM
|
111 |
|
|
ldr r2, _mac7100_teleport+4 // TelePorter
|
112 |
|
|
ldr r3, _mac7100_teleport+8 // TelePort (TelePorter end)
|
113 |
|
|
and r2,r2,r4
|
114 |
|
|
and r3,r3,r4
|
115 |
|
|
mov r4, #0x40000000 // RAM address
|
116 |
|
|
1: // Copy teleporter: // copying teleporter <---<
|
117 |
|
|
ldr r5,[r2],#4
|
118 |
|
|
str r5,[r4],#4
|
119 |
|
|
cmp r2,r3
|
120 |
|
|
bne 1b // Copy teleporter -------->
|
121 |
|
|
ldr r3,_mac7100_teleport+12
|
122 |
|
|
mov pc,#0x40000000 // 2.Jump to _mac7100_teleporter in RAM
|
123 |
|
|
_mac7100_teleporter:
|
124 |
|
|
bic r0,r0,#0x000000ff // 3.Re-map memory
|
125 |
|
|
orr r0,r0,#0x8b // Flash -> 0x20000000
|
126 |
|
|
str r0,[r1] // RAM -> 0x00000000 and 0x40000000
|
127 |
|
|
mov pc,r3 // 4.Teleport back to Flash
|
128 |
|
|
_mac7100_teleport:
|
129 |
|
|
.long MAC7100_MCM_AAMR
|
130 |
|
|
.long _mac7100_teleporter
|
131 |
|
|
.long _mac7100_teleport
|
132 |
|
|
.long _mac7100_teleport_return
|
133 |
|
|
_mac7100_teleport_return:
|
134 |
|
|
.endm
|
135 |
|
|
|
136 |
|
|
// End memory re-mapping for single chip configuration
|
137 |
|
|
|
138 |
|
|
//-----------------------------------------------------------------------------
|
139 |
|
|
// end of hal_var_setup.h
|
140 |
|
|
#endif // CYGONCE_HAL_VAR_SETUP_H
|