comparison packages/hal/arm/mac7100/mace1/current/include/hal_platform_setup.h @ 2236:d9451e6b9670

* include/hal_platform_setup.h: PLL clock and memory remap moved to hal_variant_setup.h * include/mace1_misc.h: LED macros added
author asl
date Sat, 17 Jun 2006 20:08:27 +0000
parents e691ae9721d4
children 74dbf4c3f2e1
comparison
equal deleted inserted replaced
2235:9e2251d75fbe 2236:d9451e6b9670
52 //####DESCRIPTIONEND#### 52 //####DESCRIPTIONEND####
53 // 53 //
54 //=========================================================================== 54 //===========================================================================
55 55
56 #include <cyg/hal/var_io.h> 56 #include <cyg/hal/var_io.h>
57 57 #include <cyg/hal/hal_var_setup.h>
58 //=========================================================================== 58 //===========================================================================
59 59
60 .macro _led y 60 .macro _led y
61 ldr r0,=MAC7100_PIM_PORTDATA(MAC7100_PORT_A_OFFSET) 61 ldr r0,=MAC7100_PIM_PORTDATA(MAC7100_PORT_A_OFFSET)
62 ldrh r1,[r0] 62 ldrh r1,[r0]
66 .endm 66 .endm
67 67
68 68
69 // Initialize LED PORT 69 // Initialize LED PORT
70 // Set appropriate peripheral pins 70 // Set appropriate peripheral pins
71 .macro _led_init 71 .macro _led_init
72 mov r1, #MAC7100_PIM_DDR // Pin setting: Output+Low 72 mov r1, #MAC7100_PIM_DDR // Pin setting: Output+Low
73 ldr r0,=MAC7100_PIM_CONFIG(MAC7100_PORT_A_OFFSET, 8) // LED pin cfg 73 ldr r0,=MAC7100_PIM_CONFIG(MAC7100_PORT_A_OFFSET, 8) // LED pin cfg
74 strh r1,[r0],#2 // LED: LSB ... 74 strh r1,[r0],#2 // LED: LSB ...
75 strh r1,[r0],#2 75 strh r1,[r0],#2
76 strh r1,[r0],#2 76 strh r1,[r0],#2
80 strh r1,[r0],#2 80 strh r1,[r0],#2
81 strh r1,[r0],#2 // LED: MSB ... 81 strh r1,[r0],#2 // LED: MSB ...
82 _led 0 // Set initial LED state. 82 _led 0 // Set initial LED state.
83 .endm 83 .endm
84 84
85 // Initialize PLL
86 #if defined(CYGNUM_HAL_ARM_MAC7100_FDIV) // Divider set by user.
87 # define MAC7100_CRG_REFDV_VAL (CYGNUM_HAL_ARM_MAC7100_FDIV-1)
88 #else // Divider calculated.
89 //NOTE: works for f_osc <= 8MHz
90 # define MAC7100_CRG_REFDV_VAL (((CYGNUM_HAL_ARM_MAC7100_F_OSC/500000) - 1) & 0x0F) // 15 (1)
91 #endif
92 #define MAC7100_CRG_SYNR_VAL (CYGNUM_HAL_ARM_MAC7100_CLOCK_SPEED / 2 / \
93 (CYGNUM_HAL_ARM_MAC7100_F_OSC / (MAC7100_CRG_REFDV_VAL+1))-1) // 47 (5)
94 85
95 #define MAC7100_CRG_PLLCTL_VAL \ 86 // Clock initilalization
96 (MAC7100_CRG_CME|MAC7100_CRG_PLLON|MAC7100_CRG_AUTO| \ 87 .macro _pclock_init
97 MAC7100_CRG_ACQ|MAC7100_CRG_SCME) 88 _mac7100_setpll
98 #define MAC7100_CRG_CLKSEL_VAL (MAC7100_CRG_PLLSEL)
99
100 .macro _pclock_init
101 ldr r2,=MAC7100_CRG_BASE
102 mov r3,#0
103 // Disable clock interrupts
104 strb r3,[r2,#(MAC7100_CRG_CRGINT-MAC7100_CRG_BASE)]
105 // DeSelect PLL clock
106 mov r3,#MAC7100_CRG_REFDV_VAL
107 // Reference Divider reg.
108 strb r3,[r2,#(MAC7100_CRG_REFDV-MAC7100_CRG_BASE)]
109 mov r3,#MAC7100_CRG_SYNR_VAL
110 // Synthesizer register
111 strb r3,[r2,#(MAC7100_CRG_SYNR-MAC7100_CRG_BASE)]
112 mov r3,#MAC7100_CRG_PLLCTL_VAL
113 // PLL control register
114 strb r3,[r2,#(MAC7100_CRG_PLLCTL-MAC7100_CRG_BASE)]
115 // Wait PLL lock <---
116 1: ldrb r3,[r2,#(MAC7100_CRG_CRGFLG-MAC7100_CRG_BASE)]
117 tst r3,#MAC7100_CRG_LOCK
118 bne 2f // PLL locked, GO ON ----->>
119 _led 0x55
120 b 1b // Still waiting for PLL lock -------------------------->
121 2: mov r3,#MAC7100_CRG_CLKSEL_VAL // <<----
122 // Select PLL clock
123 strb r3,[r2,#(MAC7100_CRG_CLKSEL-MAC7100_CRG_BASE)]
124 mov r3,#0
125 strb r3,[r2,#(MAC7100_CRG_BDMCTL-MAC7100_CRG_BASE)] // Set CRG BDMCTL
126 mov r3,r3
127 .endm 89 .endm
128 90
91 // Memory re-mapping
92 .macro _memory_remap
93 _mac7100_remap_single_chip
94 .endm
95
96
97 // Initialize paralel port
129 .macro _pio_init 98 .macro _pio_init
130 .endm 99 .endm
131
132 // Memory re-mapping
133 .macro _TelePort
134 _led 1
135 ldr r1, TelePort //AAMR_REG
136 ldr r0, [r1]
137 100
138 mvn r4, #0xf0000000 // 1. Copy telepoter to RAM
139 ldr r2, TelePort+4 // TelePorter
140 ldr r3, TelePort+8 // TelePort (TelePorter end)
141 and r2,r2,r4
142 and r3,r3,r4
143 mov r4, #0x40000000 // RAM address
144 1: //CopyTelePorter: // copying teleporter
145 ldr r5,[r2],#4 // <---
146 str r5,[r4],#4
147 cmp r2,r3
148 bne 1b //CopyTelePorter // --->
149 ldr r3,TelePort+12
150 mov pc,#0x40000000 // 2. Jump to TelePorter in RAM
151 TelePorter:
152 bic r0,r0,#0x000000ff // 3. Re-map memory
153 orr r0,r0,#0x8b // Flash -> 0x20000000
154 str r0,[r1] // RAM -> 0x00000000 and 0x40000000
155 mov pc,r3 // 4. Teleport back to Flash
156 TelePort:
157 .long MAC7100_MCM_AAMR
158 .long TelePorter
159 .long TelePort
160 .long TelePortReturn
161 TelePortReturn:
162 .endm
163 // End memory re-mapping
164 101
165 #define CYGHWR_LED_MACRO _led \x 102 #define CYGHWR_LED_MACRO _led \x
166 103
167 //=========================================================================== 104 //===========================================================================
168 105
169 #if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM) 106 #if defined(CYG_HAL_STARTUP_ROM) || defined(CYG_HAL_STARTUP_ROMRAM)
170 107
171 .macro _setup 108 .macro _setup
172 ldr r0,=VAE_MAC7100_FlashSecurity 109 ldr r0,=VAE_MAC7100_FlashSecurity
173 _led_init 110 _led_init
174 _TelePort 111 _memory_remap
175 _pclock_init 112 _pclock_init
176 _pio_init 113 _pio_init
177 .endm 114 .endm
178 115
179 #define CYGSEM_HAL_ROM_RESET_USES_JUMP 116 #define CYGSEM_HAL_ROM_RESET_USES_JUMP