1 | /* |
---|
2 | * This file contains the ARM BSP startup package. It includes application, |
---|
3 | * board, and monitor specific initialization and configuration. The generic CPU |
---|
4 | * dependent initialization has been performed before this routine is invoked. |
---|
5 | */ |
---|
6 | |
---|
7 | /* |
---|
8 | * Copyright (c) 2000 Canon Research Centre France SA. |
---|
9 | * Emmanuel Raguet, mailto:raguet@crf.canon.fr |
---|
10 | * |
---|
11 | * The license and distribution terms for this file may be |
---|
12 | * found in the file LICENSE in this distribution or at |
---|
13 | * http://www.rtems.com/license/LICENSE. |
---|
14 | */ |
---|
15 | |
---|
16 | #include <bsp.h> |
---|
17 | #include <bsp/irq-generic.h> |
---|
18 | #include <rtems/bspIo.h> |
---|
19 | #include <s3c24xx.h> |
---|
20 | |
---|
21 | /* |
---|
22 | * External Prototypes |
---|
23 | */ |
---|
24 | extern void rtems_exception_init_mngt(void); |
---|
25 | |
---|
26 | /* |
---|
27 | * BSP Specific Initialization in C |
---|
28 | */ |
---|
29 | void bsp_start_default( void ) |
---|
30 | { |
---|
31 | uint32_t cr; |
---|
32 | uint32_t pend,last; |
---|
33 | uint32_t REFCNT; |
---|
34 | int i; |
---|
35 | |
---|
36 | /* stop RTC */ |
---|
37 | #ifdef CPU_S3C2400 |
---|
38 | rTICINT = 0x0; |
---|
39 | #else |
---|
40 | rTICNT = 0x0; |
---|
41 | #endif |
---|
42 | /* stop watchdog,ADC and timers */ |
---|
43 | rWTCON = 0x0; |
---|
44 | rTCON = 0x0; |
---|
45 | rADCCON = 0x0; |
---|
46 | |
---|
47 | /* disable interrupts */ |
---|
48 | rINTMOD = 0x0; |
---|
49 | rINTMSK = BIT_ALLMSK; /* unmasked by drivers */ |
---|
50 | |
---|
51 | last = 0; |
---|
52 | for(i=0; i<4; i++) { |
---|
53 | pend = rSRCPND; |
---|
54 | if(pend == 0 || pend == last) |
---|
55 | break; |
---|
56 | rSRCPND = pend; |
---|
57 | rINTPND = pend; |
---|
58 | last = pend; |
---|
59 | } |
---|
60 | |
---|
61 | /* setup clocks */ |
---|
62 | rCLKDIVN = M_CLKDIVN; |
---|
63 | rMPLLCON = ((M_MDIV<<12)+(M_PDIV<<4)+M_SDIV); |
---|
64 | /* setup rREFRESH |
---|
65 | * period = 15.6 us, HCLK=66Mhz, (2048+1-15.6*66) |
---|
66 | */ |
---|
67 | REFCNT = 2048+1-(15.6*get_HCLK()/1000000); |
---|
68 | rREFRESH = ((REFEN<<23)+(TREFMD<<22)+(Trp<<20)+(Trc<<18)+(Tchr<<16)+REFCNT); |
---|
69 | |
---|
70 | /* set prescaler for timers 2,3,4 to 16(15+1) */ |
---|
71 | cr = rTCFG0 & 0xFFFF00FF; |
---|
72 | rTCFG0 = (cr | (15<<8)); |
---|
73 | |
---|
74 | /* set prescaler for timers 0,1 to 1(0+1) */ |
---|
75 | cr = rTCFG0 & 0xFFFFFF00; |
---|
76 | rTCFG0 = (cr | (0<<0)); |
---|
77 | |
---|
78 | /* |
---|
79 | * Init rtems exceptions management |
---|
80 | */ |
---|
81 | rtems_exception_init_mngt(); |
---|
82 | |
---|
83 | /* |
---|
84 | * Init rtems interrupt management |
---|
85 | */ |
---|
86 | bsp_interrupt_initialize(); |
---|
87 | } |
---|
88 | |
---|
89 | /* |
---|
90 | * By making this a weak alias for bsp_start_default, a brave soul |
---|
91 | * can override the actual bsp_start routine used. |
---|
92 | */ |
---|
93 | |
---|
94 | void bsp_start (void) __attribute__ ((weak, alias("bsp_start_default"))); |
---|