|
1 // Copyright (c) 1994-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of the License "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // omap3530/assp/src/assp.cpp |
|
15 // |
|
16 |
|
17 #include <kernel.h> |
|
18 #include <assp/omap3530_assp/omap3530_assp_priv.h> |
|
19 #include <assp/omap3530_assp/omap3530_timer.h> |
|
20 #include <assp/omap3530_assp/omap3530_prcm.h> |
|
21 #include <assp/omap3530_assp/omap3530_irqmap.h> |
|
22 #include <assp/omap3530_assp/omap3530_hardware_base.h> |
|
23 #include <assp/omap3530_assp/omap3530_uart.h> |
|
24 #include <assp/omap3530_shared/omap3_mstick.h> |
|
25 |
|
26 #define PS_PER_SECOND 1000000000000 |
|
27 #define US_PER_SECOND 1000000 |
|
28 |
|
29 |
|
30 Omap3530Assp* Omap3530Assp::Variant; |
|
31 |
|
32 |
|
33 DECLARE_STANDARD_ASSP() |
|
34 |
|
35 EXPORT_C Omap3530Assp::Omap3530Assp() |
|
36 { |
|
37 Kern::Printf("%s::%s",__FUNCTION__,__FUNCTION__); |
|
38 |
|
39 } |
|
40 |
|
41 EXPORT_C TMachineStartupType Omap3530Assp::StartupReason() |
|
42 { |
|
43 __KTRACE_OPT(KBOOT,Kern::Printf("Omap3530Assp::StartupReason")); |
|
44 #ifdef _DEBUG // REMOVE THIS |
|
45 TUint s = Kern::SuperPage().iHwStartupReason; |
|
46 __KTRACE_OPT(KBOOT,Kern::Printf("CPU page value %08x", s)); |
|
47 #endif // REMOVE THIS |
|
48 // |
|
49 // TO DO: (mandatory) |
|
50 // |
|
51 // Map the startup reason read from the Super Page to one of TMachineStartupType enumerated values |
|
52 // and return this |
|
53 // |
|
54 return EStartupCold; // EXAMPLE ONLY |
|
55 } |
|
56 |
|
57 EXPORT_C void Omap3530Assp::Init1() |
|
58 { |
|
59 __KTRACE_OPT(KBOOT,Kern::Printf("Omap3530Assp::Init1()")); |
|
60 |
|
61 Variant = (Omap3530Assp*)Arch::TheAsic(); |
|
62 __ASSERT_ALWAYS( Variant != NULL, Kern::Fault( "assp Init1: no variant", 0 ) ); |
|
63 |
|
64 Omap3530Interrupt::Init1(); // initialise the ASSP interrupt controller |
|
65 __KTRACE_OPT(KBOOT,Kern::Printf("Omap3530Assp::Init1() OUT")); |
|
66 } |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 EXPORT_C TUint64 Omap3530Assp::GetXtalFrequency() |
|
73 { |
|
74 return Prcm::ClockFrequency( Prcm::EClkSysClk ); |
|
75 } |
|
76 |
|
77 |
|
78 EXPORT_C void Omap3530Assp::Init3() |
|
79 { |
|
80 __KTRACE_OPT(KBOOT,Kern::Printf("Omap3530Assp::Init3() >")); |
|
81 |
|
82 Prcm::Init3(); |
|
83 |
|
84 TArmCpuId id={0}; |
|
85 ArmCpuVersionId(id); |
|
86 Omap3530Assp::NanoWaitCalibration(); |
|
87 TUint64 hz = Prcm::ClockFrequency( Prcm::EClkMpu ); |
|
88 Kern::Printf("CPU at %d MHz",(TInt)hz/1000000); |
|
89 Kern::SetNanoWaitHandler(NanoWait); |
|
90 Omap3::MsTick::Start(); |
|
91 __KTRACE_OPT(KBOOT,Kern::Printf("Omap3530Assp::Init3() <")); |
|
92 } |
|
93 |
|
94 |
|
95 /* |
|
96 * Returns the number of microseconds for the system millisecond tick; |
|
97 * */ |
|
98 EXPORT_C TInt Omap3530Assp::MsTickPeriod() |
|
99 { |
|
100 return 1000; |
|
101 } |
|
102 |
|
103 |
|
104 |
|
105 |
|
106 EXPORT_C TUint32 Omap3530Assp::NanoWaitCalibration() |
|
107 { |
|
108 // Return the minimum time in nano-seconds that it takes to execute the following code: |
|
109 // nanowait_loop: |
|
110 // subs r0, r0, r1 |
|
111 // bhi nanowait_loop |
|
112 //THE cpu frequency can change so this calibration must be achieved each time the power management modifies the cpu freq. |
|
113 |
|
114 TInt cycles_ns = Prcm::ClockFrequency( Prcm::EClkMpu ) /1000000000 ; |
|
115 |
|
116 |
|
117 return 2 * cycles_ns; // 2 cycles approx 3.333ns at 600MHz |
|
118 } |
|
119 |
|
120 |
|
121 |
|
122 EXPORT_C void Omap3530Assp::ArmCpuVersionId(TArmCpuId &id) |
|
123 // |
|
124 // Read and return the the CPU ID |
|
125 // |
|
126 { |
|
127 TUint armString = Kern::SuperPage().iCpuId; |
|
128 |
|
129 id.Implementor = (armString & 0xFF000000) >>24; |
|
130 id.Variant = (armString & 0x00F00000) >>20; |
|
131 id.Architecture = (armString & 0x000F0000) >>16; |
|
132 id.Primary = (armString & 0x0000FFF0)>> 4; |
|
133 id.Revision = (armString & 0x0000000F); |
|
134 |
|
135 Kern::Printf("%s %s Rev:%d",__FUNCTION__,(id.Primary ==0xc08)?"CORTEX_A8":"UNKNOWN",id.Revision); |
|
136 } |
|
137 |
|
138 EXPORT_C Omap3530Uart::TUartNumber Omap3530Assp::DebugPortNumber() |
|
139 // |
|
140 // Return index of the debug UART Omap3530Uart::EUart([0-2]|None) |
|
141 // |
|
142 { |
|
143 Omap3530Uart::TUartNumber debugPort; |
|
144 switch (Kern::SuperPage().iDebugPort) |
|
145 { |
|
146 case 0: |
|
147 debugPort = Omap3530Uart::EUart0; |
|
148 break; |
|
149 case 1: |
|
150 debugPort = Omap3530Uart::EUart1; |
|
151 break; |
|
152 case 2: |
|
153 debugPort = Omap3530Uart::EUart2; |
|
154 break; |
|
155 |
|
156 default: |
|
157 debugPort = Omap3530Uart::EUartNone; |
|
158 break; |
|
159 } |
|
160 return debugPort; |
|
161 } |
|
162 |
|
163 |
|
164 |
|
165 EXPORT_C TUint Omap3530Assp::ProcessorPeriodInPs() |
|
166 // |
|
167 // Return CPU clock period in picoseconds |
|
168 // |
|
169 { |
|
170 TUint64 cycleTime = (Prcm::ClockFrequency( Prcm::EClkMpu ) * US_PER_SECOND) / PS_PER_SECOND ; |
|
171 return (TUint) cycleTime; |
|
172 } |
|
173 |