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 <bsp/irq.h> |
---|
48 | #include <libcpu/cpuIdent.h> |
---|
49 | #include <libcpu/spr.h> |
---|
50 | |
---|
51 | #include <string.h> |
---|
52 | |
---|
53 | SPR_RW(SPRG1) |
---|
54 | |
---|
55 | /* |
---|
56 | * Driver configuration parameters |
---|
57 | */ |
---|
58 | uint32_t bsp_clock_speed; |
---|
59 | uint32_t bsp_time_base_frequency; |
---|
60 | uint32_t bsp_clicks_per_usec; |
---|
61 | uint32_t bsp_serial_per_sec; /* Serial clocks per second */ |
---|
62 | bool bsp_serial_external_clock; |
---|
63 | bool bsp_serial_xon_xoff; |
---|
64 | bool bsp_serial_cts_rts; |
---|
65 | uint32_t bsp_serial_rate; |
---|
66 | uint32_t bsp_timer_average_overhead; /* Average overhead of timer in ticks */ |
---|
67 | uint32_t bsp_timer_least_valid; /* Least valid number from timer */ |
---|
68 | bool bsp_timer_internal_clock; /* TRUE, when timer runs with CPU clk */ |
---|
69 | |
---|
70 | void _BSP_GPLED1_on(void); |
---|
71 | void _BSP_GPLED0_on(void); |
---|
72 | void cpu_init(void); |
---|
73 | |
---|
74 | extern char IntrStack_start []; |
---|
75 | extern char intrStack []; |
---|
76 | |
---|
77 | void BSP_panic(char *s) |
---|
78 | { |
---|
79 | _BSP_GPLED1_on(); |
---|
80 | printk("%s PANIC %s\n",_RTEMS_version, s); |
---|
81 | __asm__ __volatile ("sc"); |
---|
82 | } |
---|
83 | |
---|
84 | void _BSP_Fatal_error(unsigned int v) |
---|
85 | { |
---|
86 | _BSP_GPLED0_on(); |
---|
87 | _BSP_GPLED1_on(); |
---|
88 | printk("%s PANIC ERROR %x\n",_RTEMS_version, v); |
---|
89 | __asm__ __volatile ("sc"); |
---|
90 | } |
---|
91 | |
---|
92 | void _BSP_GPLED0_on(void) |
---|
93 | { |
---|
94 | BCSR *csr; |
---|
95 | csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000); |
---|
96 | csr->bcsr0 &= ~GP0_LED; /* Turn on GP0 LED */ |
---|
97 | } |
---|
98 | |
---|
99 | void _BSP_GPLED0_off(void) |
---|
100 | { |
---|
101 | BCSR *csr; |
---|
102 | csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000); |
---|
103 | csr->bcsr0 |= GP0_LED; /* Turn off GP0 LED */ |
---|
104 | } |
---|
105 | |
---|
106 | void _BSP_GPLED1_on(void) |
---|
107 | { |
---|
108 | BCSR *csr; |
---|
109 | csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000); |
---|
110 | csr->bcsr0 &= ~GP1_LED; /* Turn on GP1 LED */ |
---|
111 | } |
---|
112 | |
---|
113 | void _BSP_GPLED1_off(void) |
---|
114 | { |
---|
115 | BCSR *csr; |
---|
116 | csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000); |
---|
117 | csr->bcsr0 |= GP1_LED; /* Turn off GP1 LED */ |
---|
118 | } |
---|
119 | |
---|
120 | void _BSP_Uart1_enable(void) |
---|
121 | { |
---|
122 | BCSR *csr; |
---|
123 | csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000); |
---|
124 | csr->bcsr1 &= ~UART1_E; /* Enable Uart1 */ |
---|
125 | } |
---|
126 | |
---|
127 | void _BSP_Uart1_disable(void) |
---|
128 | { |
---|
129 | BCSR *csr; |
---|
130 | csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000); |
---|
131 | csr->bcsr1 |= UART1_E; /* Disable Uart1 */ |
---|
132 | } |
---|
133 | |
---|
134 | void _BSP_Uart2_enable(void) |
---|
135 | { |
---|
136 | BCSR *csr; |
---|
137 | csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000); |
---|
138 | csr->bcsr1 &= ~UART2_E; /* Enable Uart2 */ |
---|
139 | } |
---|
140 | |
---|
141 | void _BSP_Uart2_disable(void) |
---|
142 | { |
---|
143 | BCSR *csr; |
---|
144 | csr = (BCSR *)(m8260.memc[1].br & 0xFFFF8000); |
---|
145 | csr->bcsr1 |= UART2_E; /* Disable Uart2 */ |
---|
146 | |
---|
147 | } |
---|
148 | |
---|
149 | void bsp_start(void) |
---|
150 | { |
---|
151 | ppc_cpu_id_t myCpu; |
---|
152 | ppc_cpu_revision_t myCpuRevision; |
---|
153 | |
---|
154 | /* Set MPC8260ADS board LEDS and Uart enable lines */ |
---|
155 | _BSP_GPLED0_off(); |
---|
156 | _BSP_GPLED1_off(); |
---|
157 | _BSP_Uart1_enable(); |
---|
158 | _BSP_Uart2_enable(); |
---|
159 | |
---|
160 | /* |
---|
161 | * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function |
---|
162 | * store the result in global variables so that it can be used latter... |
---|
163 | */ |
---|
164 | myCpu = get_ppc_cpu_type(); |
---|
165 | myCpuRevision = get_ppc_cpu_revision(); |
---|
166 | |
---|
167 | cpu_init(); |
---|
168 | |
---|
169 | /* |
---|
170 | mmu_init(); |
---|
171 | */ |
---|
172 | |
---|
173 | /* Initialize exception handler */ |
---|
174 | /* FIXME: Interrupt stack begin and size */ |
---|
175 | ppc_exc_initialize( |
---|
176 | PPC_INTERRUPT_DISABLE_MASK_DEFAULT, |
---|
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 | |
---|
212 | #ifdef REV_0_2 |
---|
213 | /* set up some board specific registers */ |
---|
214 | m8260.siumcr &= 0xF3FFFFFF; /* set TBEN ** BUG FIX ** */ |
---|
215 | m8260.siumcr |= 0x08000000; |
---|
216 | #endif |
---|
217 | |
---|
218 | /* use BRG1 to generate 32kHz timebase */ |
---|
219 | /* |
---|
220 | m8260.brgc1 = M8260_BRG_EN + (uint32_t)(((uint16_t)((40016384)/(32768)) - 1) << 1) + 0; |
---|
221 | */ |
---|
222 | |
---|
223 | #ifdef SHOW_MORE_INIT_SETTINGS |
---|
224 | printk("Exit from bspstart\n"); |
---|
225 | #endif |
---|
226 | |
---|
227 | } |
---|