source: rtems/c/src/lib/libbsp/m68k/mcf5206elite/startup/init5206e.c @ f05b2ac

4.104.114.84.95
Last change on this file since f05b2ac was f05b2ac, checked in by Ralf Corsepius <ralf.corsepius@…>, on 04/21/04 at 16:01:48

Remove duplicate white lines.

  • Property mode set to 100644
File size: 9.2 KB
Line 
1/*
2 *  MCF5206e hardware startup routines
3 *
4 *  This is where the real hardware setup is done. A minimal stack
5 *  has been provided by the start.S code. No normal C or RTEMS
6 *  functions can be called from here.
7 *
8 *  This initialization code based on hardware settings of dBUG
9 *  monitor. This must be changed if you like to run it immediately
10 *  after reset.
11 *
12 *  Copyright (C) 2000 OKTET Ltd., St.-Petersburg, Russia
13 *  Author: Victor V. Vengerov <vvv@oktet.ru>
14 *
15 *  Based on work:
16 *  Author:
17 *    David Fiddes, D.J@fiddes.surfaid.org
18 *    http://www.calm.hw.ac.uk/davidf/coldfire/
19 *
20 *  COPYRIGHT (c) 1989-1998.
21 *  On-Line Applications Research Corporation (OAR).
22 *
23 *  The license and distribution terms for this file may be
24 *  found in the file LICENSE in this distribution or at
25 *
26 *  http://www.rtems.com/license/LICENSE.
27 *
28 *  $Id$
29 */
30
31#include <rtems.h>
32#include <bsp.h>
33#include "mcf5206/mcf5206e.h"
34
35#define m68k_set_cacr( _cacr ) \
36  asm volatile ( "movec %0,%%cacr\n\t" \
37                 "nop\n" \
38                 : : "d" (_cacr) )
39
40#define m68k_set_acr0( _acr0 ) \
41  asm volatile (  "movec %0,%%acr0\n\t" \
42                  "nop\n\t" \
43                  : : "d" (_acr0) )
44
45#define m68k_set_acr1( _acr1 ) \
46  asm volatile (  "movec %0,%%acr1\n\t" \
47                  "nop\n\t" \
48                  : : "d" (_acr1) )
49
50#define m68k_set_srambar( _rambar0 ) \
51  asm volatile (  "movec %0,%%rambar0\n\t" \
52                  "nop\n\t" \
53                  : : "d" (_rambar0) )
54
55#define m68k_set_mbar( _mbar ) \
56  asm volatile (  "movec %0,%%mbar\n\t" \
57                  "nop\n\t" \
58                  : : "d" (_mbar) )
59
60#define mcf5206e_enable_cache() \
61  m68k_set_cacr( MCF5206E_CACR_CENB )
62
63#define mcf5206e_disable_cache() \
64  asm volatile (  "nop\n\t"    \
65                  "movec %0,%%cacr\n\t" \
66                  "nop\n\t" \
67                  "movec %0,%%cacr\n\t" \
68                  "nop\n\t" \
69                  : : "d" (MCF5206E_CACR_CINV) )
70
71/* Init5206e --
72 *     Initialize MCF5206e on-chip modules
73 *
74 * PARAMETERS:
75 *     none
76 *
77 * RETURNS:
78 *     none
79 */
80void
81Init5206e(void)
82{
83    extern void CopyDataClearBSSAndStart(unsigned long ramsize);
84
85    /* Set Module Base Address register */
86    m68k_set_mbar((MBAR & MCF5206E_MBAR_BA) | MCF5206E_MBAR_V);
87
88    /* Set System Protection Control Register (SYPCR):
89     * Bus Monitor Enable, Bus Monitor Timing = 1024 clocks,
90     * Software watchdog disabled
91     */
92    *MCF5206E_SYPCR(MBAR) = MCF5206E_SYPCR_BME |
93                            MCF5206E_SYPCR_BMT_1024;
94
95    /* Set Pin Assignment Register (PAR):
96     *     Output Timer 0 (not DREQ) on *TOUT[0] / *DREQ[1]
97     *     Input Timer 0 (not DREQ) on *TIN[0] / *DREQ[0]
98     *     IRQ, not IPL
99     *     UART2 RTS signal (not \RSTO)
100     *     PST/DDATA (not PPIO)
101     *     *WE (not CS/A)
102     */
103    *MCF5206E_PAR(MBAR) = MCF5206E_PAR_PAR9_TOUT |
104                          MCF5206E_PAR_PAR8_TIN0 |
105                          MCF5206E_PAR_PAR7_UART2 |
106                          MCF5206E_PAR_PAR6_IRQ |
107                          MCF5206E_PAR_PAR5_PST |
108                          MCF5206E_PAR_PAR4_DDATA |
109                          MCF5206E_PAR_WE0_WE1_WE2_WE3;
110
111    /* Set SIM Configuration Register (SIMR):
112     * Disable software watchdog timer and bus timeout monitor when
113     * internal freeze signal is asserted.
114     */
115    *MCF5206E_SIMR(MBAR) = MCF5206E_SIMR_FRZ0 | MCF5206E_SIMR_FRZ1;
116
117    /* Set Interrupt Mask Register: Disable all interrupts */
118    *MCF5206E_IMR(MBAR) = 0xFFFF;
119
120    /* Assign Interrupt Control Registers as it is defined in bsp.h */
121    *MCF5206E_ICR(MBAR,MCF5206E_INTR_EXT_IPL1) =
122                            (BSP_INTLVL_AVEC1 << MCF5206E_ICR_IL_S) |
123                            (BSP_INTPRIO_AVEC1 << MCF5206E_ICR_IP_S) |
124                            MCF5206E_ICR_AVEC;
125    *MCF5206E_ICR(MBAR,MCF5206E_INTR_EXT_IPL2) =
126                            (BSP_INTLVL_AVEC2 << MCF5206E_ICR_IL_S) |
127                            (BSP_INTPRIO_AVEC2 << MCF5206E_ICR_IP_S) |
128                            MCF5206E_ICR_AVEC;
129    *MCF5206E_ICR(MBAR,MCF5206E_INTR_EXT_IPL3) =
130                            (BSP_INTLVL_AVEC3 << MCF5206E_ICR_IL_S) |
131                            (BSP_INTPRIO_AVEC3 << MCF5206E_ICR_IP_S) |
132                            MCF5206E_ICR_AVEC;
133    *MCF5206E_ICR(MBAR,MCF5206E_INTR_EXT_IPL4) =
134                            (BSP_INTLVL_AVEC4 << MCF5206E_ICR_IL_S) |
135                            (BSP_INTPRIO_AVEC4 << MCF5206E_ICR_IP_S) |
136                            MCF5206E_ICR_AVEC;
137    *MCF5206E_ICR(MBAR,MCF5206E_INTR_EXT_IPL5) =
138                            (BSP_INTLVL_AVEC5 << MCF5206E_ICR_IL_S) |
139                            (BSP_INTPRIO_AVEC5 << MCF5206E_ICR_IP_S) |
140                            MCF5206E_ICR_AVEC;
141    *MCF5206E_ICR(MBAR,MCF5206E_INTR_EXT_IPL6) =
142                            (BSP_INTLVL_AVEC6 << MCF5206E_ICR_IL_S) |
143                            (BSP_INTPRIO_AVEC6 << MCF5206E_ICR_IP_S) |
144                            MCF5206E_ICR_AVEC;
145    *MCF5206E_ICR(MBAR,MCF5206E_INTR_EXT_IPL7) =
146                            (BSP_INTLVL_AVEC7 << MCF5206E_ICR_IL_S) |
147                            (BSP_INTPRIO_AVEC7 << MCF5206E_ICR_IP_S) |
148                            MCF5206E_ICR_AVEC;
149    *MCF5206E_ICR(MBAR,MCF5206E_INTR_TIMER_1) =
150                            (BSP_INTLVL_TIMER1 << MCF5206E_ICR_IL_S) |
151                            (BSP_INTPRIO_TIMER1 << MCF5206E_ICR_IP_S) |
152                            MCF5206E_ICR_AVEC;
153    *MCF5206E_ICR(MBAR,MCF5206E_INTR_TIMER_2) =
154                            (BSP_INTLVL_TIMER2 << MCF5206E_ICR_IL_S) |
155                            (BSP_INTPRIO_TIMER2 << MCF5206E_ICR_IP_S) |
156                            MCF5206E_ICR_AVEC;
157    *MCF5206E_ICR(MBAR,MCF5206E_INTR_MBUS) =
158                            (BSP_INTLVL_MBUS << MCF5206E_ICR_IL_S) |
159                            (BSP_INTPRIO_MBUS << MCF5206E_ICR_IP_S) |
160                            MCF5206E_ICR_AVEC;
161    *MCF5206E_ICR(MBAR,MCF5206E_INTR_UART_1) =
162                            (BSP_INTLVL_UART1 << MCF5206E_ICR_IL_S) |
163                            (BSP_INTPRIO_UART1 << MCF5206E_ICR_IP_S);
164    *MCF5206E_ICR(MBAR,MCF5206E_INTR_UART_2) =
165                            (BSP_INTLVL_UART2 << MCF5206E_ICR_IL_S) |
166                            (BSP_INTPRIO_UART2 << MCF5206E_ICR_IP_S);
167    *MCF5206E_ICR(MBAR,MCF5206E_INTR_DMA_0) =
168                            (BSP_INTLVL_DMA0 << MCF5206E_ICR_IL_S) |
169                            (BSP_INTPRIO_DMA0 << MCF5206E_ICR_IP_S) |
170                            MCF5206E_ICR_AVEC;
171    *MCF5206E_ICR(MBAR,MCF5206E_INTR_DMA_1) =
172                            (BSP_INTLVL_DMA1 << MCF5206E_ICR_IL_S) |
173                            (BSP_INTPRIO_DMA1 << MCF5206E_ICR_IP_S) |
174                            MCF5206E_ICR_AVEC;
175
176    /* Software Watchdog timer (not used now) */
177    *MCF5206E_SWIVR(MBAR) = 0x0F; /* Uninitialized interrupt */
178    *MCF5206E_SWSR(MBAR) = MCF5206E_SWSR_KEY1;
179    *MCF5206E_SWSR(MBAR) = MCF5206E_SWSR_KEY2;
180
181    /* Configuring Chip Selects */
182    /* CS2: SRAM memory */
183    *MCF5206E_CSAR(MBAR,2) = BSP_MEM_ADDR_ESRAM >> 16;
184    *MCF5206E_CSMR(MBAR,2) = BSP_MEM_MASK_ESRAM;
185    *MCF5206E_CSCR(MBAR,2) = MCF5206E_CSCR_WS1 |
186                             MCF5206E_CSCR_PS_32 |
187                             MCF5206E_CSCR_AA |
188                             MCF5206E_CSCR_EMAA |
189                             MCF5206E_CSCR_WR |
190                             MCF5206E_CSCR_RD;
191
192    /* CS3: GPIO on eLITE board */
193    *MCF5206E_CSAR(MBAR,3) = BSP_MEM_ADDR_GPIO >> 16;
194    *MCF5206E_CSMR(MBAR,3) = BSP_MEM_MASK_GPIO;
195    *MCF5206E_CSCR(MBAR,3) = MCF5206E_CSCR_WS15 |
196                             MCF5206E_CSCR_PS_16 |
197                             MCF5206E_CSCR_AA |
198                             MCF5206E_CSCR_EMAA |
199                             MCF5206E_CSCR_WR |
200                             MCF5206E_CSCR_RD;
201
202    {
203        extern void INTERRUPT_VECTOR();
204        uint32_t         *inttab = (uint32_t*)&INTERRUPT_VECTOR;
205        uint32_t         *intvec = (uint32_t*)BSP_MEM_ADDR_ESRAM;
206        register int i;
207        for (i = 0; i < 256; i++)
208        {
209            *(intvec++) = *(inttab++);
210        }
211    }
212    m68k_set_vbr(BSP_MEM_ADDR_ESRAM);
213
214    /* CS0: Flash EEPROM */
215    *MCF5206E_CSAR(MBAR,0) = BSP_MEM_ADDR_FLASH >> 16;
216    *MCF5206E_CSCR(MBAR,0) = MCF5206E_CSCR_WS3 |
217                             MCF5206E_CSCR_AA |
218                             MCF5206E_CSCR_PS_16 |
219                             MCF5206E_CSCR_EMAA |
220                             MCF5206E_CSCR_WR |
221                             MCF5206E_CSCR_RD;
222    *MCF5206E_CSMR(MBAR,0) = BSP_MEM_MASK_FLASH;
223
224    /*
225     * Invalidate the cache and disable it
226     */
227    mcf5206e_disable_cache();
228
229    /*
230     * Setup ACRs so that if cache turned on, periphal accesses
231     * are not messed up.  (Non-cacheable, serialized)
232     */
233    m68k_set_acr0 ( 0
234        | MCF5206E_ACR_BASE(BSP_MEM_ADDR_ESRAM)
235        | MCF5206E_ACR_MASK(BSP_MEM_MASK_ESRAM)
236        | MCF5206E_ACR_EN
237        | MCF5206E_ACR_SM_ANY
238    );
239    m68k_set_acr1 ( 0
240        | MCF5206E_ACR_BASE(BSP_MEM_ADDR_FLASH)
241        | MCF5206E_ACR_MASK(BSP_MEM_MASK_FLASH)
242        | MCF5206E_ACR_EN
243        | MCF5206E_ACR_SM_ANY
244    );
245
246    mcf5206e_enable_cache();
247
248  /*
249   * Copy data, clear BSS, switch stacks and call boot_card()
250   */
251  CopyDataClearBSSAndStart (BSP_MEM_SIZE_ESRAM - 0x400);
252}
Note: See TracBrowser for help on using the repository browser.