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

Last change on this file since 05dc5a7f was 05dc5a7f, checked in by Joel Sherrill <joel.sherrill@…>, on 09/04/03 at 17:30:40

2003-09-04 Joel Sherrill <joel@…>

  • console/console.c, start/start.S, startup/bspclean.c, startup/bspstart.c, startup/init5206e.c: Removed incorrect statement about copyright assignment.
  • Property mode set to 100644
File size: 9.3 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.OARcorp.com/rtems/license.html.
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
64#define mcf5206e_disable_cache() \
65  asm volatile (  "nop\n\t"    \
66                  "movec %0,%%cacr\n\t" \
67                  "nop\n\t" \
68                  "movec %0,%%cacr\n\t" \
69                  "nop\n\t" \
70                  : : "d" (MCF5206E_CACR_CINV) )
71
72/* Init5206e --
73 *     Initialize MCF5206e on-chip modules
74 *
75 * PARAMETERS:
76 *     none
77 *
78 * RETURNS:
79 *     none
80 */
81void
82Init5206e(void)
83{
84    extern void CopyDataClearBSSAndStart(unsigned long ramsize);
85 
86    /* Set Module Base Address register */
87    m68k_set_mbar((MBAR & MCF5206E_MBAR_BA) | MCF5206E_MBAR_V);
88   
89    /* Set System Protection Control Register (SYPCR):
90     * Bus Monitor Enable, Bus Monitor Timing = 1024 clocks,
91     * Software watchdog disabled
92     */
93    *MCF5206E_SYPCR(MBAR) = MCF5206E_SYPCR_BME |
94                            MCF5206E_SYPCR_BMT_1024;
95   
96    /* Set Pin Assignment Register (PAR):
97     *     Output Timer 0 (not DREQ) on *TOUT[0] / *DREQ[1]
98     *     Input Timer 0 (not DREQ) on *TIN[0] / *DREQ[0]
99     *     IRQ, not IPL
100     *     UART2 RTS signal (not \RSTO)
101     *     PST/DDATA (not PPIO)
102     *     *WE (not CS/A)
103     */
104    *MCF5206E_PAR(MBAR) = MCF5206E_PAR_PAR9_TOUT |
105                          MCF5206E_PAR_PAR8_TIN0 |
106                          MCF5206E_PAR_PAR7_UART2 |
107                          MCF5206E_PAR_PAR6_IRQ |
108                          MCF5206E_PAR_PAR5_PST |
109                          MCF5206E_PAR_PAR4_DDATA |
110                          MCF5206E_PAR_WE0_WE1_WE2_WE3;
111   
112    /* Set SIM Configuration Register (SIMR):
113     * Disable software watchdog timer and bus timeout monitor when
114     * internal freeze signal is asserted.
115     */
116    *MCF5206E_SIMR(MBAR) = MCF5206E_SIMR_FRZ0 | MCF5206E_SIMR_FRZ1;
117
118    /* Set Interrupt Mask Register: Disable all interrupts */
119    *MCF5206E_IMR(MBAR) = 0xFFFF;
120   
121    /* Assign Interrupt Control Registers as it is defined in bsp.h */
122    *MCF5206E_ICR(MBAR,MCF5206E_INTR_EXT_IPL1) =
123                            (BSP_INTLVL_AVEC1 << MCF5206E_ICR_IL_S) |
124                            (BSP_INTPRIO_AVEC1 << MCF5206E_ICR_IP_S) |
125                            MCF5206E_ICR_AVEC;
126    *MCF5206E_ICR(MBAR,MCF5206E_INTR_EXT_IPL2) =
127                            (BSP_INTLVL_AVEC2 << MCF5206E_ICR_IL_S) |
128                            (BSP_INTPRIO_AVEC2 << MCF5206E_ICR_IP_S) |
129                            MCF5206E_ICR_AVEC;
130    *MCF5206E_ICR(MBAR,MCF5206E_INTR_EXT_IPL3) =
131                            (BSP_INTLVL_AVEC3 << MCF5206E_ICR_IL_S) |
132                            (BSP_INTPRIO_AVEC3 << MCF5206E_ICR_IP_S) |
133                            MCF5206E_ICR_AVEC;
134    *MCF5206E_ICR(MBAR,MCF5206E_INTR_EXT_IPL4) =
135                            (BSP_INTLVL_AVEC4 << MCF5206E_ICR_IL_S) |
136                            (BSP_INTPRIO_AVEC4 << MCF5206E_ICR_IP_S) |
137                            MCF5206E_ICR_AVEC;
138    *MCF5206E_ICR(MBAR,MCF5206E_INTR_EXT_IPL5) =
139                            (BSP_INTLVL_AVEC5 << MCF5206E_ICR_IL_S) |
140                            (BSP_INTPRIO_AVEC5 << MCF5206E_ICR_IP_S) |
141                            MCF5206E_ICR_AVEC;
142    *MCF5206E_ICR(MBAR,MCF5206E_INTR_EXT_IPL6) =
143                            (BSP_INTLVL_AVEC6 << MCF5206E_ICR_IL_S) |
144                            (BSP_INTPRIO_AVEC6 << MCF5206E_ICR_IP_S) |
145                            MCF5206E_ICR_AVEC;
146    *MCF5206E_ICR(MBAR,MCF5206E_INTR_EXT_IPL7) =
147                            (BSP_INTLVL_AVEC7 << MCF5206E_ICR_IL_S) |
148                            (BSP_INTPRIO_AVEC7 << MCF5206E_ICR_IP_S) |
149                            MCF5206E_ICR_AVEC;
150    *MCF5206E_ICR(MBAR,MCF5206E_INTR_TIMER_1) =
151                            (BSP_INTLVL_TIMER1 << MCF5206E_ICR_IL_S) |
152                            (BSP_INTPRIO_TIMER1 << MCF5206E_ICR_IP_S) |
153                            MCF5206E_ICR_AVEC;
154    *MCF5206E_ICR(MBAR,MCF5206E_INTR_TIMER_2) =
155                            (BSP_INTLVL_TIMER2 << MCF5206E_ICR_IL_S) |
156                            (BSP_INTPRIO_TIMER2 << MCF5206E_ICR_IP_S) |
157                            MCF5206E_ICR_AVEC;
158    *MCF5206E_ICR(MBAR,MCF5206E_INTR_MBUS) =
159                            (BSP_INTLVL_MBUS << MCF5206E_ICR_IL_S) |
160                            (BSP_INTPRIO_MBUS << MCF5206E_ICR_IP_S) |
161                            MCF5206E_ICR_AVEC;
162    *MCF5206E_ICR(MBAR,MCF5206E_INTR_UART_1) =
163                            (BSP_INTLVL_UART1 << MCF5206E_ICR_IL_S) |
164                            (BSP_INTPRIO_UART1 << MCF5206E_ICR_IP_S);
165    *MCF5206E_ICR(MBAR,MCF5206E_INTR_UART_2) =
166                            (BSP_INTLVL_UART2 << MCF5206E_ICR_IL_S) |
167                            (BSP_INTPRIO_UART2 << MCF5206E_ICR_IP_S);
168    *MCF5206E_ICR(MBAR,MCF5206E_INTR_DMA_0) =
169                            (BSP_INTLVL_DMA0 << MCF5206E_ICR_IL_S) |
170                            (BSP_INTPRIO_DMA0 << MCF5206E_ICR_IP_S) |
171                            MCF5206E_ICR_AVEC;
172    *MCF5206E_ICR(MBAR,MCF5206E_INTR_DMA_1) =
173                            (BSP_INTLVL_DMA1 << MCF5206E_ICR_IL_S) |
174                            (BSP_INTPRIO_DMA1 << MCF5206E_ICR_IP_S) |
175                            MCF5206E_ICR_AVEC;
176
177    /* Software Watchdog timer (not used now) */
178    *MCF5206E_SWIVR(MBAR) = 0x0F; /* Uninitialized interrupt */
179    *MCF5206E_SWSR(MBAR) = MCF5206E_SWSR_KEY1;
180    *MCF5206E_SWSR(MBAR) = MCF5206E_SWSR_KEY2;
181   
182    /* Configuring Chip Selects */
183    /* CS2: SRAM memory */
184    *MCF5206E_CSAR(MBAR,2) = BSP_MEM_ADDR_ESRAM >> 16;
185    *MCF5206E_CSMR(MBAR,2) = BSP_MEM_MASK_ESRAM;
186    *MCF5206E_CSCR(MBAR,2) = MCF5206E_CSCR_WS1 |
187                             MCF5206E_CSCR_PS_32 |
188                             MCF5206E_CSCR_AA |
189                             MCF5206E_CSCR_EMAA |
190                             MCF5206E_CSCR_WR |
191                             MCF5206E_CSCR_RD;
192   
193    /* CS3: GPIO on eLITE board */
194    *MCF5206E_CSAR(MBAR,3) = BSP_MEM_ADDR_GPIO >> 16;
195    *MCF5206E_CSMR(MBAR,3) = BSP_MEM_MASK_GPIO;
196    *MCF5206E_CSCR(MBAR,3) = MCF5206E_CSCR_WS15 |
197                             MCF5206E_CSCR_PS_16 |
198                             MCF5206E_CSCR_AA |
199                             MCF5206E_CSCR_EMAA |
200                             MCF5206E_CSCR_WR |
201                             MCF5206E_CSCR_RD;
202   
203    {
204        extern void INTERRUPT_VECTOR();
205        rtems_unsigned32 *inttab = (rtems_unsigned32 *)&INTERRUPT_VECTOR;
206        rtems_unsigned32 *intvec = (rtems_unsigned32 *)BSP_MEM_ADDR_ESRAM;
207        register int i;
208        for (i = 0; i < 256; i++)
209        {
210            *(intvec++) = *(inttab++);
211        }
212    }
213    m68k_set_vbr(BSP_MEM_ADDR_ESRAM);
214   
215    /* CS0: Flash EEPROM */
216    *MCF5206E_CSAR(MBAR,0) = BSP_MEM_ADDR_FLASH >> 16;
217    *MCF5206E_CSCR(MBAR,0) = MCF5206E_CSCR_WS3 |
218                             MCF5206E_CSCR_AA |
219                             MCF5206E_CSCR_PS_16 |
220                             MCF5206E_CSCR_EMAA |
221                             MCF5206E_CSCR_WR |
222                             MCF5206E_CSCR_RD;
223    *MCF5206E_CSMR(MBAR,0) = BSP_MEM_MASK_FLASH;
224   
225    /*
226     * Invalidate the cache and disable it
227     */
228    mcf5206e_disable_cache();
229
230    /*
231     * Setup ACRs so that if cache turned on, periphal accesses
232     * are not messed up.  (Non-cacheable, serialized)
233     */
234    m68k_set_acr0 ( 0
235        | MCF5206E_ACR_BASE(BSP_MEM_ADDR_ESRAM)
236        | MCF5206E_ACR_MASK(BSP_MEM_MASK_ESRAM)
237        | MCF5206E_ACR_EN
238        | MCF5206E_ACR_SM_ANY
239    );
240    m68k_set_acr1 ( 0
241        | MCF5206E_ACR_BASE(BSP_MEM_ADDR_FLASH)
242        | MCF5206E_ACR_MASK(BSP_MEM_MASK_FLASH)
243        | MCF5206E_ACR_EN
244        | MCF5206E_ACR_SM_ANY
245    );
246
247    mcf5206e_enable_cache();
248 
249  /*
250   * Copy data, clear BSS, switch stacks and call boot_card()
251   */
252  CopyDataClearBSSAndStart (BSP_MEM_SIZE_ESRAM - 0x400);
253}
Note: See TracBrowser for help on using the repository browser.