1 | /** |
---|
2 | * @file |
---|
3 | * |
---|
4 | * @ingroup mpc83xx |
---|
5 | * |
---|
6 | * @brief Source for BSP startup code. |
---|
7 | */ |
---|
8 | |
---|
9 | /* |
---|
10 | * Copyright (c) 2008 |
---|
11 | * Embedded Brains GmbH |
---|
12 | * Obere Lagerstr. 30 |
---|
13 | * D-82178 Puchheim |
---|
14 | * Germany |
---|
15 | * rtems@embedded-brains.de |
---|
16 | * |
---|
17 | * The license and distribution terms for this file may be |
---|
18 | * found in the file LICENSE in this distribution or at |
---|
19 | * http://www.rtems.com/license/LICENSE. |
---|
20 | */ |
---|
21 | |
---|
22 | #include <libchip/serial.h> |
---|
23 | |
---|
24 | #include <libcpu/powerpc-utility.h> |
---|
25 | |
---|
26 | #include <bsp.h> |
---|
27 | #include <bsp/vectors.h> |
---|
28 | #include <bsp/bootcard.h> |
---|
29 | #include <bsp/irq-generic.h> |
---|
30 | #include <bsp/u-boot.h> |
---|
31 | |
---|
32 | /* Configuration parameters for console driver, ... */ |
---|
33 | unsigned int BSP_bus_frequency; |
---|
34 | |
---|
35 | /* Configuration parameter for clock driver */ |
---|
36 | uint32_t bsp_time_base_frequency; |
---|
37 | |
---|
38 | /* Legacy */ |
---|
39 | uint32_t bsp_clicks_per_usec; |
---|
40 | |
---|
41 | /* Default decrementer exception handler */ |
---|
42 | static int mpc83xx_decrementer_exception_handler( BSP_Exception_frame *frame, unsigned number) |
---|
43 | { |
---|
44 | ppc_set_decrementer_register(UINT32_MAX); |
---|
45 | |
---|
46 | return 0; |
---|
47 | } |
---|
48 | |
---|
49 | void BSP_panic(char *s) |
---|
50 | { |
---|
51 | rtems_interrupt_level level; |
---|
52 | |
---|
53 | rtems_interrupt_disable(level); |
---|
54 | |
---|
55 | printk("%s PANIC %s\n", rtems_get_version_string(), s); |
---|
56 | |
---|
57 | while (1) { |
---|
58 | /* Do nothing */ |
---|
59 | } |
---|
60 | } |
---|
61 | |
---|
62 | void _BSP_Fatal_error(unsigned n) |
---|
63 | { |
---|
64 | rtems_interrupt_level level; |
---|
65 | |
---|
66 | rtems_interrupt_disable( level); |
---|
67 | |
---|
68 | printk( "%s PANIC ERROR %u\n", rtems_get_version_string(), n); |
---|
69 | |
---|
70 | while (1) { |
---|
71 | /* Do nothing */ |
---|
72 | } |
---|
73 | } |
---|
74 | |
---|
75 | void bsp_start( void) |
---|
76 | { |
---|
77 | rtems_status_code sc = RTEMS_SUCCESSFUL; |
---|
78 | unsigned long i = 0; |
---|
79 | |
---|
80 | ppc_cpu_id_t myCpu; |
---|
81 | ppc_cpu_revision_t myCpuRevision; |
---|
82 | |
---|
83 | uintptr_t interrupt_stack_start = (uintptr_t) bsp_interrupt_stack_start; |
---|
84 | uintptr_t interrupt_stack_size = (uintptr_t) bsp_interrupt_stack_size; |
---|
85 | |
---|
86 | /* |
---|
87 | * Get CPU identification dynamically. Note that the get_ppc_cpu_type() function |
---|
88 | * store the result in global variables so that it can be used latter... |
---|
89 | */ |
---|
90 | myCpu = get_ppc_cpu_type(); |
---|
91 | myCpuRevision = get_ppc_cpu_revision(); |
---|
92 | |
---|
93 | /* Basic CPU initialization */ |
---|
94 | cpu_init(); |
---|
95 | |
---|
96 | /* |
---|
97 | * Enable instruction and data caches. Do not force writethrough mode. |
---|
98 | */ |
---|
99 | |
---|
100 | #ifdef BSP_INSTRUCTION_CACHE_ENABLED |
---|
101 | rtems_cache_enable_instruction(); |
---|
102 | #endif |
---|
103 | |
---|
104 | #ifdef BSP_DATA_CACHE_ENABLED |
---|
105 | rtems_cache_enable_data(); |
---|
106 | #endif |
---|
107 | |
---|
108 | /* |
---|
109 | * This is evaluated during runtime, so it should be ok to set it |
---|
110 | * before we initialize the drivers. |
---|
111 | */ |
---|
112 | |
---|
113 | /* Initialize some device driver parameters */ |
---|
114 | |
---|
115 | #ifdef HAS_UBOOT |
---|
116 | BSP_bus_frequency = bsp_uboot_board_info.bi_busfreq; |
---|
117 | #else /* HAS_UBOOT */ |
---|
118 | BSP_bus_frequency = BSP_CLKIN_FRQ * BSP_SYSPLL_MF / BSP_SYSPLL_CKID; |
---|
119 | #endif /* HAS_UBOOT */ |
---|
120 | bsp_time_base_frequency = BSP_bus_frequency / 4; |
---|
121 | bsp_clicks_per_usec = bsp_time_base_frequency / 1000000; |
---|
122 | |
---|
123 | /* Initialize some console parameters */ |
---|
124 | for (i = 0; i < Console_Configuration_Count; ++i) { |
---|
125 | Console_Configuration_Ports [i].ulClock = BSP_bus_frequency; |
---|
126 | |
---|
127 | #ifdef HAS_UBOOT |
---|
128 | Console_Configuration_Ports [i].pDeviceParams = |
---|
129 | (void *) bsp_uboot_board_info.bi_baudrate; |
---|
130 | #endif |
---|
131 | } |
---|
132 | |
---|
133 | /* Initialize exception handler */ |
---|
134 | #ifndef BSP_DATA_CACHE_ENABLED |
---|
135 | ppc_exc_cache_wb_check = 0; |
---|
136 | #endif |
---|
137 | ppc_exc_initialize( |
---|
138 | PPC_INTERRUPT_DISABLE_MASK_DEFAULT, |
---|
139 | interrupt_stack_start, |
---|
140 | interrupt_stack_size |
---|
141 | ); |
---|
142 | |
---|
143 | /* Install default handler for the decrementer exception */ |
---|
144 | sc = ppc_exc_set_handler( ASM_DEC_VECTOR, mpc83xx_decrementer_exception_handler); |
---|
145 | if (sc != RTEMS_SUCCESSFUL) { |
---|
146 | BSP_panic("cannot install decrementer exception handler"); |
---|
147 | } |
---|
148 | |
---|
149 | /* Initalize interrupt support */ |
---|
150 | bsp_interrupt_initialize(); |
---|
151 | |
---|
152 | #ifdef SHOW_MORE_INIT_SETTINGS |
---|
153 | printk("Exit from bspstart\n"); |
---|
154 | #endif |
---|
155 | } |
---|