1
|
/**
|
2
|
* \file startup.c
|
3
|
*
|
4
|
* \brief Configures the PLL registers to achieve the required Operating
|
5
|
* frequency. Power and sleep controller is activated for UART and
|
6
|
* Interuppt controller. Interrupt vector is copied to the shared Ram.
|
7
|
* After doing all the above, controller is given to the application.
|
8
|
*/
|
9
|
|
10
|
/*
|
11
|
* Copyright (C) 2012 Texas Instruments Incorporated - http://www.ti.com/
|
12
|
*
|
13
|
* Redistribution and use in source and binary forms, with or without
|
14
|
* modification, are permitted provided that the following conditions
|
15
|
* are met:
|
16
|
*
|
17
|
* Redistributions of source code must retain the above copyright
|
18
|
* notice, this list of conditions and the following disclaimer.
|
19
|
*
|
20
|
* Redistributions in binary form must reproduce the above copyright
|
21
|
* notice, this list of conditions and the following disclaimer in the
|
22
|
* documentation and/or other materials provided with the
|
23
|
* distribution.
|
24
|
*
|
25
|
* Neither the name of Texas Instruments Incorporated nor the names of
|
26
|
* its contributors may be used to endorse or promote products derived
|
27
|
* from this software without specific prior written permission.
|
28
|
*
|
29
|
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
30
|
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
31
|
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
|
32
|
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
|
33
|
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
34
|
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
35
|
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
36
|
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
37
|
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
38
|
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
39
|
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
40
|
*/
|
41
|
|
42
|
#include "hw_syscfg0_OMAPL138.h"
|
43
|
#include "hw_syscfg1_OMAPL138.h"
|
44
|
#include "hw_pllc_OMAPL138.h"
|
45
|
#include "soc_OMAPL138.h"
|
46
|
|
47
|
#include "evmOMAPL138.h"
|
48
|
|
49
|
#include "hw_types.h"
|
50
|
#include "hw_ddr2_mddr.h"
|
51
|
#include "psc.h"
|
52
|
|
53
|
#define E_PASS 0
|
54
|
#define E_FAIL -1
|
55
|
|
56
|
/***********************************************************************
|
57
|
** EXTERNAL FUNCTION PROTOTYPES
|
58
|
***********************************************************************/
|
59
|
extern void Entry(void);
|
60
|
extern void UndefInstHandler(void);
|
61
|
extern void SWIHandler(void);
|
62
|
extern void AbortHandler(void);
|
63
|
extern void IRQHandler(void);
|
64
|
extern void FIQHandler(void);
|
65
|
|
66
|
/**********************************************************************
|
67
|
* INTERNAL FUNCTION PROTOTYPES
|
68
|
**********************************************************************/
|
69
|
|
70
|
unsigned int PLL0Init(unsigned char clk_src, unsigned char pllm,
|
71
|
unsigned char prediv, unsigned char postdiv,
|
72
|
unsigned char div1, unsigned char div3,
|
73
|
unsigned char div7);
|
74
|
unsigned int PLL1Init(unsigned char pllm, unsigned char postdiv,
|
75
|
unsigned char div1, unsigned char div2,
|
76
|
unsigned char div3);
|
77
|
unsigned int DDR_Init ( unsigned int freq );
|
78
|
static void CopyVectorTable(void);
|
79
|
void BootAbort(void);
|
80
|
int main(void);
|
81
|
|
82
|
/******************************************************************************
|
83
|
** INTERNAL VARIABLE DEFINITIONS
|
84
|
*******************************************************************************/
|
85
|
static unsigned int const vecTbl[14]=
|
86
|
{
|
87
|
0xE59FF018,
|
88
|
0xE59FF018,
|
89
|
0xE59FF018,
|
90
|
0xE59FF018,
|
91
|
0xE59FF014,
|
92
|
0xE24FF008,
|
93
|
0xE59FF010,
|
94
|
0xE59FF010,
|
95
|
(unsigned int)Entry,
|
96
|
(unsigned int)UndefInstHandler,
|
97
|
(unsigned int)SWIHandler,
|
98
|
(unsigned int)AbortHandler,
|
99
|
(unsigned int)IRQHandler,
|
100
|
(unsigned int)FIQHandler
|
101
|
};
|
102
|
|
103
|
|
104
|
/******************************************************************************
|
105
|
** FUNCTION DEFINITIONS
|
106
|
*******************************************************************************/
|
107
|
|
108
|
/**
|
109
|
* \brief Boot strap function which enables the PLL(s) and PSC(s) for basic
|
110
|
* module(s)
|
111
|
*
|
112
|
* \param none
|
113
|
*
|
114
|
* \return None.
|
115
|
*
|
116
|
* This function is the first function that needs to be called in a system.
|
117
|
* This should be set as the entry point in the linker script if loading the
|
118
|
* elf binary via a debugger, on the target. This function never returns, but
|
119
|
* gives control to the application entry point
|
120
|
**/
|
121
|
unsigned int start_boot(void)
|
122
|
{
|
123
|
|
124
|
/* Enable write-protection for registers of SYSCFG module. */
|
125
|
SysCfgRegistersLock();
|
126
|
|
127
|
/* Disable write-protection for registers of SYSCFG module. */
|
128
|
SysCfgRegistersUnlock();
|
129
|
|
130
|
asm(" mrc p15, #0, r0, c1, c0, #0\n\t"
|
131
|
" orr r0, r0, #0x00002000\n\t"
|
132
|
" mcr p15, #0, r0, c1, c0, #0\n\t");
|
133
|
|
134
|
PSCModuleControl(SOC_PSC_1_REGS, HW_PSC_UART2, 0, PSC_MDCTL_NEXT_ENABLE);
|
135
|
|
136
|
PSCModuleControl(SOC_PSC_0_REGS, HW_PSC_AINTC, 0, PSC_MDCTL_NEXT_ENABLE);
|
137
|
/* Initialize the vector table with opcodes */
|
138
|
CopyVectorTable();
|
139
|
|
140
|
/* Calling the main */
|
141
|
main();
|
142
|
|
143
|
while(1);
|
144
|
}
|
145
|
|
146
|
|
147
|
static void CopyVectorTable(void)
|
148
|
{
|
149
|
unsigned int *dest = (unsigned int *)0xFFFF0000;
|
150
|
unsigned int *src = (unsigned int *)vecTbl;
|
151
|
unsigned int count;
|
152
|
|
153
|
for(count = 0; count < sizeof(vecTbl)/sizeof(vecTbl[0]); count++)
|
154
|
{
|
155
|
dest[count] = src[count];
|
156
|
}
|
157
|
|
158
|
}
|
159
|
|
160
|
|
161
|
void BootAbort(void)
|
162
|
{
|
163
|
while (1);
|
164
|
}
|
165
|
|
166
|
/***************************** End Of File ***********************************/
|