1 | /* bsp_start() |
---|
2 | * |
---|
3 | * This routine starts the application. It includes application, |
---|
4 | * board, and monitor specific initialization and configuration. |
---|
5 | * The generic CPU dependent initialization has been performed |
---|
6 | * before this routine is invoked. |
---|
7 | * |
---|
8 | * The MPC860 specific stuff was written by Jay Monkman (jmonkman@frasca.com) |
---|
9 | * |
---|
10 | * Modified for the MPC8260ADS board by Andy Dachs <a.dachs@sstl.co.uk> |
---|
11 | * Surrey Satellite Technology Limited, 2001 |
---|
12 | * A 40MHz system clock is assumed. |
---|
13 | * The PON. RST.CONF. Dip switches (DS1) are |
---|
14 | * 1 - Off |
---|
15 | * 2 - On |
---|
16 | * 3 - Off |
---|
17 | * 4 - On |
---|
18 | * 5 - Off |
---|
19 | * 6 - Off |
---|
20 | * 7 - Off |
---|
21 | * 8 - Off |
---|
22 | * Dip switches on DS2 and DS3 are all set to ON |
---|
23 | * The LEDs on the board are used to signal panic and fatal_error |
---|
24 | * conditions. |
---|
25 | * The mmu is unused at this time. |
---|
26 | * |
---|
27 | * |
---|
28 | * COPYRIGHT (c) 1989-2007. |
---|
29 | * On-Line Applications Research Corporation (OAR). |
---|
30 | * |
---|
31 | * The license and distribution terms for this file may be |
---|
32 | * found in the file LICENSE in this distribution or at |
---|
33 | * http://www.rtems.com/license/LICENSE. |
---|
34 | */ |
---|
35 | |
---|
36 | #include <bsp.h> |
---|
37 | |
---|
38 | /* |
---|
39 | #include <mmu.h> |
---|
40 | */ |
---|
41 | |
---|
42 | #include <mpc8260.h> |
---|
43 | #include <rtems/score/thread.h> |
---|
44 | #include <rtems/powerpc/powerpc.h> |
---|
45 | |
---|
46 | #include <rtems/bspIo.h> |
---|
47 | #include <rtems/counter.h> |
---|
48 | #include <bsp/irq.h> |
---|
49 | #include <libcpu/cpuIdent.h> |
---|
50 | #include <libcpu/spr.h> |
---|
51 | |
---|
52 | #include <string.h> |
---|
53 | |
---|
54 | SPR_RW(SPRG1) |
---|
55 | |
---|
56 | /* |
---|
57 | * Driver configuration parameters |
---|
58 | */ |
---|
59 | uint32_t bsp_clock_speed; |
---|
60 | uint32_t bsp_time_base_frequency; |
---|
61 | uint32_t bsp_clicks_per_usec; |
---|
62 | uint32_t bsp_serial_per_sec; /* Serial clocks per second */ |
---|
63 | bool bsp_serial_external_clock; |
---|
64 | bool bsp_serial_xon_xoff; |
---|
65 | bool bsp_serial_cts_rts; |
---|
66 | uint32_t bsp_serial_rate; |
---|
67 | uint32_t bsp_timer_average_overhead; /* Average overhead of timer in ticks */ |
---|
68 | uint32_t bsp_timer_least_valid; /* Least valid number from timer */ |
---|
69 | bool bsp_timer_internal_clock; /* TRUE, when timer runs with CPU clk */ |
---|
70 | |
---|
71 | void _BSP_GPLED1_on(void); |
---|
72 | void _BSP_GPLED0_on(void); |
---|
73 | void cpu_init(void); |
---|
74 | |
---|
75 | extern char IntrStack_start []; |
---|
76 | extern char intrStack []; |
---|
77 | |
---|
78 | void BSP_panic(char *s) |
---|
79 | { |
---|
80 | _BSP_GPLED1_on(); |
---|
81 | printk("%s PANIC %s\n",_RTEMS_version, s); |
---|
82 | __asm__ __volatile ("sc"); |
---|
83 | } |
---|
84 | |
---|
85 | void _BSP_Fatal_error(unsigned int v) |
---|
86 | { |
---|
87 | _BSP_GPLED0_on(); |
---|
88 | _BSP_GPLED1_on(); |
---|
89 | printk("%s PANIC ERROR %x\n",_RTEMS_version, v); |
---|
90 | __asm__ __volatile ("sc"); |
---|
91 | } |
---|
92 | |
---|
93 | void _BSP_GPLED0_on(void) |
---|
94 | { |
---|
95 | BCSR *csr; |
---|
96 | csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000); |
---|
97 | csr->bcsr0 &= ~GP0_LED; /* Turn on GP0 LED */ |
---|
98 | } |
---|
99 | |
---|
100 | void _BSP_GPLED0_off(void) |
---|
101 | { |
---|
102 | BCSR *csr; |
---|
103 | csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000); |
---|
104 | csr->bcsr0 |= GP0_LED; /* Turn off GP0 LED */ |
---|
105 | } |
---|
106 | |
---|
107 | void _BSP_GPLED1_on(void) |
---|
108 | { |
---|
109 | BCSR *csr; |
---|
110 | csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000); |
---|
111 | csr->bcsr0 &= ~GP1_LED; /* Turn on GP1 LED */ |
---|
112 | } |
---|
113 | |
---|
114 | void _BSP_GPLED1_off(void) |
---|
115 | { |
---|
116 | BCSR *csr; |
---|
117 | csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000); |
---|
118 | csr->bcsr0 |= GP1_LED; /* Turn off GP1 LED */ |
---|
119 | } |
---|
120 | |
---|
121 | void _BSP_Uart1_enable(void) |
---|
122 | { |
---|
123 | BCSR *csr; |
---|
124 | csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000); |
---|
125 | csr->bcsr1 &= ~UART1_E; /* Enable Uart1 */ |
---|
126 | } |
---|
127 | |
---|
128 | void _BSP_Uart1_disable(void) |
---|
129 | { |
---|
130 | BCSR *csr; |
---|
131 | csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000); |
---|
132 | csr->bcsr1 |= UART1_E; /* Disable Uart1 */ |
---|
133 | } |
---|
134 | |
---|
135 | void _BSP_Uart2_enable(void) |
---|
136 | { |
---|
137 | BCSR *csr; |
---|
138 | csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000); |
---|
139 | csr->bcsr1 &= ~UART2_E; /* Enable Uart2 */ |
---|
140 | } |
---|
141 | |
---|
142 | void _BSP_Uart2_disable(void) |
---|
143 | { |
---|
144 | BCSR *csr; |
---|
145 | csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000); |
---|
146 | csr->bcsr1 |= UART2_E; /* Disable Uart2 */ |
---|
147 | |
---|
148 | } |
---|
149 | |
---|
150 | void bsp_start(void) |
---|
151 | { |
---|
152 | ppc_cpu_id_t myCpu; |
---|
153 | ppc_cpu_revision_t myCpuRevision; |
---|
154 | |
---|
155 | /* Set MPC8260ADS board LEDS and Uart enable lines */ |
---|
156 | _BSP_GPLED0_off(); |
---|
157 | _BSP_GPLED1_off(); |
---|
158 | _BSP_Uart1_enable(); |
---|
159 | _BSP_Uart2_enable(); |
---|
160 | |
---|
161 | /* |
---|
162 | * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function |
---|
163 | * store the result in global variables so that it can be used latter... |
---|
164 | */ |
---|
165 | myCpu = get_ppc_cpu_type(); |
---|
166 | myCpuRevision = get_ppc_cpu_revision(); |
---|
167 | |
---|
168 | cpu_init(); |
---|
169 | |
---|
170 | /* |
---|
171 | mmu_init(); |
---|
172 | */ |
---|
173 | |
---|
174 | /* Initialize exception handler */ |
---|
175 | /* FIXME: Interrupt stack begin and size */ |
---|
176 | ppc_exc_initialize( |
---|
177 | (uintptr_t) IntrStack_start, |
---|
178 | (uintptr_t) intrStack - (uintptr_t) IntrStack_start |
---|
179 | ); |
---|
180 | |
---|
181 | /* Initalize interrupt support */ |
---|
182 | bsp_interrupt_initialize(); |
---|
183 | |
---|
184 | /* |
---|
185 | mmu_init(); |
---|
186 | */ |
---|
187 | |
---|
188 | /* |
---|
189 | * Enable instruction and data caches. Do not force writethrough mode. |
---|
190 | */ |
---|
191 | #if BSP_INSTRUCTION_CACHE_ENABLED |
---|
192 | rtems_cache_enable_instruction(); |
---|
193 | #endif |
---|
194 | #if BSP_DATA_CACHE_ENABLED |
---|
195 | rtems_cache_enable_data(); |
---|
196 | #endif |
---|
197 | |
---|
198 | /* |
---|
199 | * initialize the device driver parameters |
---|
200 | */ |
---|
201 | bsp_time_base_frequency = 10000000; |
---|
202 | bsp_clicks_per_usec = 10; /* for 40MHz extclk */ |
---|
203 | bsp_serial_per_sec = 40000000; |
---|
204 | bsp_serial_external_clock = 0; |
---|
205 | bsp_serial_xon_xoff = 0; |
---|
206 | bsp_serial_cts_rts = 0; |
---|
207 | bsp_serial_rate = 9600; |
---|
208 | bsp_timer_average_overhead = 3; |
---|
209 | bsp_timer_least_valid = 3; |
---|
210 | bsp_clock_speed = 40000000; |
---|
211 | rtems_counter_initialize_converter(bsp_clock_speed); |
---|
212 | |
---|
213 | #ifdef REV_0_2 |
---|
214 | /* set up some board specific registers */ |
---|
215 | m8260.siumcr &= 0xF3FFFFFF; /* set TBEN ** BUG FIX ** */ |
---|
216 | m8260.siumcr |= 0x08000000; |
---|
217 | #endif |
---|
218 | |
---|
219 | /* use BRG1 to generate 32kHz timebase */ |
---|
220 | /* |
---|
221 | m8260.brgc1 = M8260_BRG_EN + (uint32_t)(((uint16_t)((40016384)/(32768)) - 1) << 1) + 0; |
---|
222 | */ |
---|
223 | |
---|
224 | #ifdef SHOW_MORE_INIT_SETTINGS |
---|
225 | printk("Exit from bspstart\n"); |
---|
226 | #endif |
---|
227 | |
---|
228 | } |
---|