FreeCalypso > hg > fc-magnetite
comparison src/cs/system/main/init.c @ 519:838eeafb0051
Main and Audio source directories lowercased
author | Mychaela Falconia <falcon@freecalypso.org> |
---|---|
date | Sun, 22 Jul 2018 07:41:05 +0000 |
parents | src/cs/system/Main/init.c@706f4b71aceb |
children | 92dbfa906f66 |
comparison
equal
deleted
inserted
replaced
518:4b7e0dba42f6 | 519:838eeafb0051 |
---|---|
1 /* | |
2 * INIT.C | |
3 * | |
4 * This module allows to initialize the board: | |
5 * - wait states, | |
6 * - unmask selected interrupts, | |
7 * - initialize clock, | |
8 * - disable watchdog. | |
9 * Dummy functions used by the EVA3 library are defined. | |
10 */ | |
11 | |
12 /* Config Files */ | |
13 | |
14 #ifndef _WINDOWS | |
15 #include "l1sw.cfg" | |
16 #include "rf.cfg" | |
17 #include "chipset.cfg" | |
18 #include "board.cfg" | |
19 #include "swconfig.cfg" | |
20 #include "fc-target.cfg" | |
21 #if (OP_L1_STANDALONE == 0) | |
22 #include "rv.cfg" | |
23 #include "sys.cfg" | |
24 #include "debug.cfg" | |
25 #ifdef BLUETOOTH_INCLUDED | |
26 #include "btemobile.cfg" | |
27 #endif | |
28 #ifdef BLUETOOTH | |
29 #include "bluetooth.cfg" | |
30 #endif | |
31 #endif | |
32 | |
33 #if (OP_L1_STANDALONE == 0) | |
34 #include "rv/rv_defined_swe.h" | |
35 #endif | |
36 #endif | |
37 | |
38 /* Include Files */ | |
39 #include <assert.h> | |
40 #include <ctype.h> | |
41 #include <stdarg.h> | |
42 #include <stdlib.h> | |
43 #include <string.h> | |
44 | |
45 #include "nucleus.h" | |
46 | |
47 #include "sys_types.h" | |
48 #include "l1_types.h" | |
49 #include "l1_confg.h" | |
50 #include "l1_const.h" | |
51 | |
52 #if TESTMODE | |
53 #include "l1tm_defty.h" | |
54 #endif // TESTMODE | |
55 | |
56 #if (AUDIO_TASK == 1) | |
57 #include "l1audio_const.h" | |
58 #include "l1audio_cust.h" | |
59 #include "l1audio_defty.h" | |
60 #endif // AUDIO_TASK | |
61 | |
62 #if (L1_GTT == 1) | |
63 #include "l1gtt_const.h" | |
64 #include "l1gtt_defty.h" | |
65 #endif | |
66 | |
67 #if (L1_MP3 == 1) | |
68 #include "l1mp3_defty.h" | |
69 #endif | |
70 | |
71 #if (L1_MIDI == 1) | |
72 #include "l1midi_defty.h" | |
73 #endif | |
74 | |
75 #if (L1_AAC == 1) | |
76 #include "l1aac_defty.h" | |
77 #endif | |
78 #if (L1_DYN_DSP_DWNLD == 1) | |
79 #include "l1_dyn_dwl_defty.h" | |
80 #endif | |
81 | |
82 #if (TRACE_TYPE == 4) | |
83 #include "l1_defty.h" | |
84 #endif | |
85 | |
86 | |
87 #if ((OP_L1_STANDALONE == 1) && (CODE_VERSION != SIMULATION) && (PSP_STANDALONE == 0)) | |
88 | |
89 #if (AUDIO_TASK == 1) | |
90 #include "l1audio_signa.h" | |
91 #include "l1audio_msgty.h" | |
92 #endif // AUDIO_TASK | |
93 | |
94 #if (L1_GTT == 1) | |
95 #include "l1gtt_signa.h" | |
96 #include "l1gtt_msgty.h" | |
97 #endif | |
98 | |
99 #include "l1_defty.h" | |
100 #include "cust_os.h" | |
101 #include "l1_msgty.h" | |
102 #include "nu_main.h" | |
103 #include "l1_varex.h" | |
104 #include "l1_proto.h" | |
105 #include "hw_debug.h" | |
106 #include "l1_trace.h" | |
107 | |
108 #endif /* ((OP_L1_STANDALONE == 1) && (CODE_VERSION != SIMULATION) && (PSP_STANDALONE==0)) */ | |
109 | |
110 | |
111 #include "armio/armio.h" | |
112 #include "timer/timer.h" | |
113 | |
114 #if (OP_L1_STANDALONE == 0) | |
115 #include "rvf/rvf_api.h" | |
116 #include "rvm/rvm_api.h" /* A-M-E-N-D-E-D! */ | |
117 #include "sim/sim.h" | |
118 #endif | |
119 | |
120 #include "abb/abb.h" | |
121 | |
122 #include "inth/iq.h" | |
123 #include "tpudrv.h" | |
124 #include "memif/mem.h" | |
125 #include "clkm/clkm.h" | |
126 #include "inth/inth.h" | |
127 | |
128 #if (OP_L1_STANDALONE == 1) | |
129 #include "uart/serialswitch_core.h" | |
130 #else | |
131 #include "uart/serialswitch.h" | |
132 #endif | |
133 #include "uart/traceswitch.h" | |
134 | |
135 | |
136 #include "dma/dma.h" | |
137 #include "rhea/rhea_arm.h" | |
138 | |
139 #include "ulpd/ulpd.h" | |
140 | |
141 #if (PSP_STANDALONE == 0) | |
142 #if (OP_L1_STANDALONE == 0) | |
143 extern void ffs_main_init(void); | |
144 extern void create_tasks(void); | |
145 #if TI_NUC_MONITOR == 1 | |
146 extern void ti_nuc_monitor_tdma_action( void ); | |
147 #endif | |
148 | |
149 #if WCP_PROF == 1 | |
150 #if PRF_CALIBRATION == 1 | |
151 extern NU_HISR prf_CalibrationHISR; | |
152 #endif | |
153 #endif | |
154 | |
155 #else | |
156 void l1ctl_pgm_clk32(UWORD32 nb_hf, UWORD32 nb_32khz); | |
157 extern void L1_trace_string(char *s); | |
158 #endif /* (OP_L1_STANDALONE) */ | |
159 #endif | |
160 | |
161 #if (OP_L1_STANDALONE == 1) | |
162 #if ((TRACE_TYPE==1) || (TRACE_TYPE==2) || (TRACE_TYPE==3) || (TRACE_TYPE==7) || TESTMODE) | |
163 #include "uart/uart.h" | |
164 /* | |
165 * Serial Configuration set up. | |
166 */ | |
167 | |
168 extern char ser_cfg_info[NUMBER_OF_TR_UART]; | |
169 #include "rvt_gen.h" | |
170 extern T_RVT_USER_ID trace_id; | |
171 #endif | |
172 #endif /* (OP_L1_STANDALONE == 1) */ | |
173 | |
174 /* | |
175 * Serial Configuration set up. | |
176 */ | |
177 | |
178 /* | |
179 ** One config is: | |
180 ** {XXX_BT_HCI, // Bluetooth HCI | |
181 ** XXX_FAX_DATA, // Fax/Data AT-Cmd | |
182 ** XXX_TRACE, // L1/Riviera Trace Mux | |
183 ** XXX_TRACE}, // Trace PS | |
184 ** | |
185 ** with XXX being DUMMY, UART_IRDA or UART_MODEM | |
186 */ | |
187 | |
188 #if ((((TRACE_TYPE==1) || (TRACE_TYPE==2) || (TRACE_TYPE==3) || (TRACE_TYPE==7) ||\ | |
189 (TESTMODE)) && (OP_L1_STANDALONE == 1)) || (OP_L1_STANDALONE == 0)) | |
190 #if (OP_L1_STANDALONE == 1) | |
191 static T_AppliSerialInfo appli_ser_cfg_info = | |
192 #else | |
193 T_AppliSerialInfo appli_ser_cfg_info = | |
194 #endif /* OP_L1_STANDALONE */ | |
195 { | |
196 #ifdef CONFIG_RVTMUX_ON_MODEM | |
197 {DUMMY_BT_HCI, | |
198 DUMMY_FAX_DATA, | |
199 UART_MODEM_TRACE, | |
200 DUMMY_TRACE}, // 0x0248 | |
201 #else // RVTMUX_ON_MODEM | |
202 {DUMMY_BT_HCI, | |
203 UART_MODEM_FAX_DATA, | |
204 UART_IRDA_TRACE, | |
205 DUMMY_TRACE}, // default config = 0x0168 | |
206 #endif | |
207 #ifdef BTEMOBILE | |
208 12, // 12 serial config allowed | |
209 #else // BTEMOBILE | |
210 9, // 9 serial config allowed | |
211 #endif | |
212 { | |
213 // Configs with Condat Panel only | |
214 {DUMMY_BT_HCI, | |
215 DUMMY_FAX_DATA, | |
216 DUMMY_TRACE, | |
217 UART_IRDA_TRACE}, // 0x1048 | |
218 {DUMMY_BT_HCI, | |
219 DUMMY_FAX_DATA, | |
220 DUMMY_TRACE, | |
221 UART_MODEM_TRACE}, // 0x2048 | |
222 // Configs with L1/Riviera Trace only | |
223 {DUMMY_BT_HCI, | |
224 DUMMY_FAX_DATA, | |
225 UART_IRDA_TRACE, | |
226 DUMMY_TRACE}, // 0x0148 | |
227 {DUMMY_BT_HCI, | |
228 DUMMY_FAX_DATA, | |
229 UART_MODEM_TRACE, | |
230 DUMMY_TRACE}, // 0x0248 | |
231 // Configs with AT-Cmd only | |
232 {DUMMY_BT_HCI, | |
233 UART_MODEM_FAX_DATA, | |
234 DUMMY_TRACE, | |
235 DUMMY_TRACE}, // 0x0068 | |
236 // Configs with Condat Panel and L1/Riviera Trace | |
237 {DUMMY_BT_HCI, | |
238 DUMMY_FAX_DATA, | |
239 UART_MODEM_TRACE, | |
240 UART_IRDA_TRACE}, // 0x1248 | |
241 {DUMMY_BT_HCI, | |
242 DUMMY_FAX_DATA, | |
243 UART_IRDA_TRACE, | |
244 UART_MODEM_TRACE}, // 0x2148 | |
245 // Configs with Condat Panel and AT-Cmd | |
246 {DUMMY_BT_HCI, | |
247 UART_MODEM_FAX_DATA, | |
248 DUMMY_TRACE, | |
249 UART_IRDA_TRACE}, // 0x1068 | |
250 #ifdef BTEMOBILE | |
251 // Configs with L1/Riviera Trace and Bluetooth HCI | |
252 {UART_IRDA_BT_HCI, | |
253 DUMMY_FAX_DATA, | |
254 UART_MODEM_TRACE, | |
255 DUMMY_TRACE}, // 0x0249 | |
256 {UART_MODEM_BT_HCI, | |
257 DUMMY_FAX_DATA, | |
258 UART_IRDA_TRACE, | |
259 DUMMY_TRACE}, // 0x014A | |
260 // Configs with AT-Cmd and Bluetooth HCI | |
261 {UART_IRDA_BT_HCI, | |
262 UART_MODEM_FAX_DATA, | |
263 DUMMY_TRACE, | |
264 DUMMY_TRACE}, // 0x0069 | |
265 #endif // BTEMOBILE | |
266 // Configs with L1/Riviera Trace and AT-Cmd | |
267 {DUMMY_BT_HCI, | |
268 UART_MODEM_FAX_DATA, | |
269 UART_IRDA_TRACE, | |
270 DUMMY_TRACE} // 0x0168 | |
271 } | |
272 }; | |
273 #endif /* (TRACE_TYPE ...) || (OP_L1_STANDALONE == 0) */ | |
274 | |
275 | |
276 /* | |
277 * Init_Target | |
278 * | |
279 * Performs low-level HW Initialization. | |
280 */ | |
281 void Init_Target(void) | |
282 { | |
283 #if (BOARD == 5) | |
284 #define WS_ROM (1) | |
285 #define WS_RAM (1) | |
286 #define WS_APIF (1) | |
287 #define WS_CS2 (7) /* LCD on EVA3. */ | |
288 #define WS_CS0 (7) /* DUART on EVA3. UART16750 and latch on A-Sample. */ | |
289 #define WS_CS1 (7) /* LCD on A-Sample. */ | |
290 | |
291 IQ_InitWaitState (WS_ROM, WS_RAM, WS_APIF, WS_CS2, WS_CS0, WS_CS1); | |
292 IQ_InitClock (2); /* Internal clock division factor. */ | |
293 | |
294 IQ_MaskAll (); /* Mask all interrupts. */ | |
295 IQ_SetupInterrupts (); /* IRQ priorities. */ | |
296 | |
297 TM_DisableWatchdog (); | |
298 | |
299 /* | |
300 * Reset all TSP and DBG fdefault values | |
301 */ | |
302 | |
303 AI_ResetTspIO (); | |
304 AI_ResetDbgReg (); | |
305 AI_ResetIoConfig (); | |
306 | |
307 /* | |
308 * Warning! The external reset signal is connected to the Omega and the | |
309 * external device. If the layer 1 is used its initialization removes | |
310 * the external reset. If the application does not use the layer 1 | |
311 * you must remove the external reset (bit 2 of the reset control | |
312 * register 0x505808). | |
313 */ | |
314 | |
315 AI_ResetTspIO(); | |
316 AI_ResetDbgReg(); | |
317 AI_ResetIoConfig(); | |
318 | |
319 /* | |
320 * Configure all IOs (see RD300 specification). | |
321 */ | |
322 | |
323 AI_ConfigBitAsInput (1); | |
324 AI_EnableBit (1); | |
325 | |
326 AI_ConfigBitAsOutput (2); | |
327 AI_EnableBit (2); | |
328 | |
329 AI_ConfigBitAsInput (11); | |
330 AI_EnableBit (11); | |
331 | |
332 AI_ConfigBitAsOutput (13); | |
333 AI_EnableBit (13); | |
334 | |
335 AI_Power (1); /* Maintain power supply. */ | |
336 | |
337 #elif (BOARD == 6) || (BOARD == 7) || (BOARD == 8) || (BOARD == 9) || \ | |
338 (BOARD == 40) || (BOARD == 41) || (BOARD == 42) || (BOARD == 43) || (BOARD == 45) || \ | |
339 (BOARD == 35) || (BOARD == 46) || (BOARD == 70) || (BOARD == 71) | |
340 | |
341 #if (PSP_STANDALONE == 0) | |
342 // RIF/SPI rising edge clock for ULYSSE | |
343 //-------------------------------------------------- | |
344 #if ((ANLG_FAM == 1) || (ANLG_FAM == 2) || (ANLG_FAM == 3)|| (ANLG_FAM == 11)) | |
345 #if ((CHIPSET >= 3)) | |
346 #if (CHIPSET == 12) | |
347 F_CONF_RIF_RX_RISING_EDGE; | |
348 F_CONF_SPI_RX_RISING_EDGE; | |
349 #elif (CHIPSET == 15) | |
350 //do the DRP init here for Locosto | |
351 #if (L1_DRP == 1) | |
352 // drp_power_on(); This should be done after the script is downloaded. | |
353 #endif | |
354 #else | |
355 #if (BOARD==35) | |
356 *((volatile SYS_UWORD16 *) ASIC_CONF) = 0x2000; | |
357 #elif defined(CONFIG_TARGET_PIRELLI) | |
358 /* | |
359 * Pirelli's version of this Init_Target() function | |
360 * in their fw sets the ASIC_CONF register to 0x6050, | |
361 * which means PWL on the LT/PWL pin and LPG on the | |
362 * DSR_MODEM pin. | |
363 */ | |
364 *((volatile SYS_UWORD16 *) ASIC_CONF) = 0x6050; | |
365 #elif defined(CONFIG_TARGET_GTAMODEM) | |
366 /* | |
367 * The DSR_MODEM/LPG Calypso signal is unconnected on | |
368 * Openmoko's modem, so let's mux it as LPG (output) | |
369 * so it doesn't float, like Foxconn seem to have done | |
370 * on the Pirelli. | |
371 */ | |
372 *((volatile SYS_UWORD16 *) ASIC_CONF) = 0x6040; | |
373 #else | |
374 *((volatile SYS_UWORD16 *) ASIC_CONF) = 0x6000; | |
375 #endif /* (BOARD == 35) */ | |
376 #endif | |
377 #endif | |
378 #endif /* ANLG(ANALOG)) */ | |
379 | |
380 #if (OP_L1_STANDALONE == 1) | |
381 #if (BOARD == 40) || (BOARD == 41) || \ | |
382 (BOARD == 42) || (BOARD == 43) || (BOARD == 45) | |
383 // enable 8 Ohm amplifier for audio on D-sample | |
384 AI_ConfigBitAsOutput (1); | |
385 AI_SetBit(1); | |
386 #elif (BOARD == 70) || (BOARD == 71) | |
387 //Locosto I-sample or UPP costo board.BOARD | |
388 // Initialize the ARMIO bits as per the I-sample spec | |
389 // FIXME | |
390 #endif | |
391 #endif /* (OP_L1_STANDALONE == 1) */ | |
392 #endif /* PSP_STANDALONE ==0 */ | |
393 | |
394 // Watchdog | |
395 //-------------------------------------------------- | |
396 TM_DisableWatchdog(); /* Disable Watchdog */ | |
397 #if (CHIPSET == 12) || (CHIPSET == 15) | |
398 TM_SEC_DisableWatchdog(); | |
399 #endif | |
400 | |
401 #if ((CHIPSET == 4) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12) || (CHIPSET == 15)) | |
402 | |
403 #if (CHIPSET == 12) | |
404 | |
405 #if 0 /* example of configuration for DMA debug */ | |
406 #if (BOARD == 6) /* debug on EVA 4 , GPO2 must not be changed */ | |
407 | |
408 /* TPU_FRAME, NMIIT, IACKn */ | |
409 F_DBG_IRQ_CONFIG(C_DBG_IRQ_IRQ4|C_DBG_IRQ_NMIIT|C_DBG_IRQ_IACKN); | |
410 | |
411 /* NDMA_REQ_VIEW1, NDMA_REQ_VIEW0, DMA_V(1), DMA_S(1), DMAREQ_P1(3:0)*/ | |
412 F_DBG_DMA_P1_NDFLASH_CONFIG(C_DBG_DMA_P1_NDFLASH_NDMA_REQ_VIEW_1 | | |
413 C_DBG_DMA_P1_NDFLASH_NDMA_REQ_VIEW_0 | | |
414 C_DBG_DMA_P1_NDFLASH_DMA_REQ_P1_3 | | |
415 C_DBG_DMA_P1_NDFLASH_DMA_REQ_P1_2 | | |
416 C_DBG_DMA_P1_NDFLASH_DMA_REQ_P1_1 | | |
417 C_DBG_DMA_P1_NDFLASH_DMA_REQ_P1_0 | | |
418 C_DBG_DMA_P1_NDFLASH_DMA_REQ_S_1 | | |
419 C_DBG_DMA_P1_NDFLASH_DMA_REQ_V1 ); | |
420 /* DMA_REQ_S(2)*/ | |
421 F_DBG_DMA_P2_CONFIG(C_DBG_DMA_P2_DMA_REQ_S2); | |
422 | |
423 /* DMA_CLK_REQ, BRIDGE_CLK */ | |
424 F_DBG_CLK1_CONFIG(C_DBG_CLK1_DMA_CLK_REQ | | |
425 C_DBG_CLK1_BRIDGE_CLK ); | |
426 | |
427 /* XIO_nREADY */ | |
428 F_DBG_IMIF_CONFIG(C_DBG_IMIF_XIO_NREADY_MEM); | |
429 | |
430 /* DSP_nIRQ_VIEW1, DSP_nIRQ_VIEW0, BRIDGE_EN */ | |
431 F_DBG_KB_USIM_SHD_CONFIG(C_DBG_KB_USIM_SHD_DSP_NIRQ_VIEW_1 | | |
432 C_DBG_KB_USIM_SHD_DSP_NIRQ_VIEW_0 | | |
433 C_DBG_KB_USIM_SHD_BRIDGE_EN ); | |
434 | |
435 /* RHEA_nREADY , RHEA_nSTROBE */ | |
436 F_DBG_USIM_CONFIG(C_DBG_USIM_RHEA_NSTROBE | | |
437 C_DBG_USIM_RHEA_NREADY ); | |
438 | |
439 /* XIO_STROBE */ | |
440 F_DBG_MISC2_CONFIG(C_DBG_MISC2_X_IOSTRBN); | |
441 | |
442 /* DMA_CLK_REQ */ | |
443 F_DBG_CLK2_CONFIG(C_DBG_CLK2_DMA_CLK_REQ2); | |
444 | |
445 /* DSP_IRQ_SEL0=DMA, DSP_IRQ_SEL1=DMA, DMA_REQ_SEL0=RIF_RX, DMA_REQ_SEL1=RIF_RX */ | |
446 F_DBG_VIEW_CONFIG(0,0,C_DBG_DSP_INT_DMA, | |
447 C_DBG_DSP_INT_DMA, | |
448 C_DMA_CHANNEL_RIF_RX, | |
449 C_DMA_CHANNEL_RIF_RX); | |
450 | |
451 #endif /* (BOARD == 6) */ | |
452 #endif /* DMA debug example */ | |
453 #else | |
454 /* | |
455 * Configure ASIC in order to output the DPLL and ARM clock | |
456 */ | |
457 // (*( volatile UWORD16* )(0xFFFEF008)) = 0x8000; // DPLL | |
458 // (*( volatile UWORD16* )(0xFFFEF00E)) = 0x0004; // ARM clock | |
459 // (*( volatile UWORD16* )(0xfffef004)) = 0x0600; // DSP clock + nIACK | |
460 #endif /* (CHIPSET == 12) || CHIPSET == 15*/ | |
461 | |
462 | |
463 /* | |
464 * Enable/Disable of clock switch off for INTH, TIMER, BRIDGE and DPLL modules | |
465 */ | |
466 // IRQ, Timer and bridge may SLEEP | |
467 // In first step, same configuration as SAMSON | |
468 //-------------------------------------------------- | |
469 #if (CHIPSET == 12) | |
470 CLKM_INITCNTL(CLKM_IRQ_DIS | CLKM_TIMER_DIS | CLKM_BRIDGE_DIS | CLKM_DPLL_DIS); | |
471 #elif (CHIPSET == 15) | |
472 CLKM_INITCNTL(CLKM_IRQ_DIS | CLKM_TIMER_DIS | CLKM_CPORT_EN | CLKM_BRIDGE_DIS | 0x8000 ); /* CLKM_DPLL_DIS is remove by Ranga*/ | |
473 | |
474 #else | |
475 CLKM_INITCNTL(CLKM_IRQ_DIS | CLKM_TIMER_DIS); | |
476 | |
477 // Select VTCXO input frequency | |
478 //-------------------------------------------------- | |
479 CLKM_UNUSED_VTCXO_26MHZ; | |
480 | |
481 // Rita RF uses 26MHz VCXO | |
482 #if (RF_FAM == 12) | |
483 CLKM_USE_VTCXO_26MHZ; | |
484 #endif | |
485 // Renesas RF uses 26MHz on F-sample but 13MHz on TEB | |
486 #if (RF_FAM == 43) && (BOARD == 46) | |
487 CLKM_USE_VTCXO_26MHZ; | |
488 #endif | |
489 #endif | |
490 | |
491 | |
492 // Control HOM/SAM automatic switching | |
493 //-------------------------------------------------- | |
494 *((volatile unsigned short *) CLKM_CNTL_CLK) &= ~CLKM_EN_IDLE3_FLG; | |
495 | |
496 /* | |
497 * The following part has been reconstructed from disassembly. | |
498 */ | |
499 RHEA_INITRHEA(0,0,0xFF); | |
500 DPLL_INIT_BYPASS_MODE(DPLL_BYPASS_DIV_1); | |
501 #if (CHIPSET == 8) | |
502 DPLL_INIT_DPLL_CLOCK(DPLL_LOCK_DIV_1, 6); | |
503 #elif (CHIPSET == 10) | |
504 DPLL_INIT_DPLL_CLOCK(DPLL_LOCK_DIV_1, 8); | |
505 #else | |
506 #error "We only have DPLL setup for CHIPSETs 8 and 10" | |
507 #endif | |
508 CLKM_InitARMClock(0x00, 2, 0); /* no low freq, no ext clock, div by 1 */ | |
509 /* | |
510 * FreeCalypso change: memory timings and widths | |
511 * are target-dependent. | |
512 */ | |
513 #ifdef CONFIG_TARGET_PIRELLI | |
514 /* | |
515 * Pirelli's version of this Init_Target() function | |
516 * in their fw does the following: | |
517 */ | |
518 MEM_INIT_CS0(4, MEM_DVS_16, MEM_WRITE_EN, 0); | |
519 MEM_INIT_CS1(4, MEM_DVS_16, MEM_WRITE_EN, 0); | |
520 MEM_INIT_CS2(5, MEM_DVS_16, MEM_WRITE_EN, 0); | |
521 MEM_INIT_CS3(4, MEM_DVS_16, MEM_WRITE_EN, 0); | |
522 MEM_INIT_CS4(7, MEM_DVS_16, MEM_WRITE_EN, 0); | |
523 #elif defined(CONFIG_TARGET_FCFAM) | |
524 /* | |
525 * The settings currently adopted for the FreeCalypso | |
526 * hardware family, only nCS0, nCS1 and nCS2 are used | |
527 * presently. | |
528 */ | |
529 MEM_INIT_CS0(4, MEM_DVS_16, MEM_WRITE_EN, 0); | |
530 MEM_INIT_CS1(4, MEM_DVS_16, MEM_WRITE_EN, 0); | |
531 MEM_INIT_CS2(4, MEM_DVS_16, MEM_WRITE_EN, 0); | |
532 MEM_INIT_CS3(4, MEM_DVS_16, MEM_WRITE_EN, 0); | |
533 MEM_INIT_CS4(4, MEM_DVS_16, MEM_WRITE_EN, 0); | |
534 #elif defined(CONFIG_TARGET_DSAMPLE) && (CHIPSET == 8) | |
535 /* | |
536 * On D-Sample C05 (older Calypso silicon version) the clocks | |
537 * run slower: the ARM clock runs at 39 MHz instead of 52 MHz. | |
538 * Therefore, we need to use fewer wait states to effect | |
539 * the same memory speed. | |
540 */ | |
541 MEM_INIT_CS0(2, MEM_DVS_16, MEM_WRITE_EN, 0); | |
542 MEM_INIT_CS1(2, MEM_DVS_16, MEM_WRITE_EN, 0); | |
543 MEM_INIT_CS2(2, MEM_DVS_16, MEM_WRITE_EN, 0); | |
544 MEM_INIT_CS3(2, MEM_DVS_16, MEM_WRITE_EN, 0); | |
545 MEM_INIT_CS4(0, MEM_DVS_8, MEM_WRITE_EN, 0); | |
546 #else | |
547 /* | |
548 * The original settings from Openmoko, | |
549 * only nCS0 and nCS1 are actually used, | |
550 * same as on Mot C1xx phones, | |
551 * the nCS2/3/4 settings are dummies from TI. | |
552 */ | |
553 MEM_INIT_CS0(3, MEM_DVS_16, MEM_WRITE_EN, 0); | |
554 MEM_INIT_CS1(3, MEM_DVS_16, MEM_WRITE_EN, 0); | |
555 MEM_INIT_CS2(5, MEM_DVS_16, MEM_WRITE_EN, 0); | |
556 MEM_INIT_CS3(3, MEM_DVS_16, MEM_WRITE_EN, 0); | |
557 MEM_INIT_CS4(0, MEM_DVS_8, MEM_WRITE_EN, 0); | |
558 #endif | |
559 MEM_INIT_CS6(0, MEM_DVS_32, MEM_WRITE_EN, 0); | |
560 MEM_INIT_CS7(0, MEM_DVS_32, MEM_WRITE_DIS, 0); | |
561 RHEA_INITAPI(0,1); | |
562 RHEA_INITARM(0,0); | |
563 DPLL_SET_PLL_ENABLE; | |
564 | |
565 /* | |
566 * Disable and Clear all pending interrupts | |
567 */ | |
568 #if (CHIPSET == 12) || (CHIPSET == 15) | |
569 F_INTH_DISABLE_ALL_IT; // MASK all it | |
570 F_INTH2_VALID_NEXT(C_INTH_IRQ); // reset current IT in INTH2 IRQ | |
571 F_INTH_VALID_NEXT(C_INTH_IRQ); // reset current IT in INTH IRQ | |
572 F_INTH_VALID_NEXT(C_INTH_FIQ); // reset current IT in INTH FIQ | |
573 F_INTH_RESET_ALL_IT; // reset all IRQ/FIQ source | |
574 #else | |
575 INTH_DISABLEALLIT; | |
576 #if 0 /* not present in our reference binary object */ | |
577 INTH_RESETALLIT; | |
578 #endif | |
579 INTH_CLEAR; /* reset IRQ/FIQ source */ | |
580 #endif | |
581 | |
582 // INTH | |
583 //-------------------------------------------------- | |
584 #if (CHIPSET == 12) || (CHIPSET == 15) | |
585 #if (GSM_IDLE_RAM != 0) | |
586 f_inth_setup((T_INTH_CONFIG *)a_inth_config_idle_ram); // setup configuration IT handlers | |
587 #else | |
588 f_inth_setup((T_INTH_CONFIG *)a_inth_config); // setup configuration IT handlers | |
589 #endif | |
590 #else | |
591 IQ_SetupInterrupts(); | |
592 #endif | |
593 | |
594 | |
595 #if (CHIPSET == 12) || (CHIPSET == 15) | |
596 #if (OP_L1_STANDALONE == 0) | |
597 | |
598 f_dma_global_parameter_set((T_DMA_TYPE_GLOBAL_PARAMETER *)&d_dma_global_parameter); | |
599 #endif | |
600 f_dma_channel_allocation_set(C_DMA_CHANNEL_0, C_DMA_CHANNEL_DSP); | |
601 #if (OP_L1_STANDALONE == 1) | |
602 f_dma_global_parameter_set((T_DMA_TYPE_GLOBAL_PARAMETER *)&d_dma_global_parameter); | |
603 f_dma_channel_allocation_set(C_DMA_CHANNEL_0, C_DMA_CHANNEL_DSP); | |
604 #endif | |
605 | |
606 #else | |
607 // DMA | |
608 //-------------------------------------------------- | |
609 // channel0 = Arm, channel1 = Lead, channel2 = forced to Arm, channel3=forced to Arm, dma_burst = 0001, priority = same | |
610 #if (OP_L1_STANDALONE == 0) | |
611 DMA_ALLOCDMA(1,0,1,1); // Channel 1 used by DSP with RIF RX | |
612 #endif | |
613 #endif | |
614 | |
615 /* CHIPSET = 4 or 7 or 8 or 10 or 11 or 12 */ | |
616 | |
617 #else | |
618 | |
619 // RHEA Bridge | |
620 //-------------------------------------------------- | |
621 // ACCES_FAC_0 = 0, ACCES_FAC_1 = 0 ,TIMEOUT = 0x7F | |
622 RHEA_INITRHEA(0,0,0x7F); | |
623 | |
624 #if (CHIPSET == 6) | |
625 // WS_H = 1 , WS_L = 15 | |
626 RHEA_INITAPI(1,15); // should be 0x01E1 for 65 Mhz | |
627 #else | |
628 // WS_H = 0 , WS_L = 7 | |
629 RHEA_INITAPI(0,7); // should be 0x0101 for 65 Mhz | |
630 #endif | |
631 | |
632 // Write_en_0 = 0 , Write_en_1 = 0 | |
633 RHEA_INITARM(0,0); | |
634 | |
635 // INTH | |
636 //-------------------------------------------------- | |
637 INTH_DISABLEALLIT; // MASK all it | |
638 INTH_CLEAR; // reset IRQ/FIQ source | |
639 IQ_SetupInterrupts(); | |
640 | |
641 // DMA | |
642 //-------------------------------------------------- | |
643 // channel0 = Arm, channel1 = Lead, dma_burst = 0001, priority = same | |
644 DMA_ALLOCDMA(1,0,1,1); // should be 0x25 (channel 1 = lead) | |
645 | |
646 #if (CHIPSET == 6) | |
647 // Memory WS configuration for ULYSS/G1 (26 Mhz) board | |
648 //----------------------------------------------------- | |
649 MEM_INIT_CS2(2,MEM_DVS_16,MEM_WRITE_EN,0); | |
650 #endif | |
651 | |
652 // CLKM | |
653 //-------------------------------------------------- | |
654 CLKM_InitARMClock(0x00, 2); /* no low freq, no ext clock, div by 1 */ | |
655 | |
656 #if (CHIPSET == 6) | |
657 CLKM_INITCNTL(CLKM_IRQ_DIS | CLKM_BRIDGE_DIS | CLKM_TIMER_DIS | CLKM_VTCXO_26); | |
658 #else | |
659 CLKM_INITCNTL(CLKM_IRQ_DIS | CLKM_BRIDGE_DIS | CLKM_TIMER_DIS); | |
660 #endif | |
661 | |
662 #endif /* CHIPSET = 4 or 7 or 8 or 10 or 11 or 12 */ | |
663 | |
664 // Freeze ULPD timer .... | |
665 //-------------------------------------------------- | |
666 *((volatile SYS_UWORD16 *) ULDP_GSM_TIMER_INIT_REG ) = 0; | |
667 *((volatile SYS_UWORD16 *) ULDP_GSM_TIMER_CTRL_REG ) = TPU_FREEZE; | |
668 | |
669 // reset INC_SIXTEEN and INC_FRAC | |
670 //-------------------------------------------------- | |
671 #if (OP_L1_STANDALONE == 1) | |
672 l1ctl_pgm_clk32(DEFAULT_HFMHZ_VALUE,DEFAULT_32KHZ_VALUE); | |
673 #else | |
674 ULDP_INCSIXTEEN_UPDATE(132); //32768.29038 =>132, 32500 => 133 | |
675 // 26000 --> 166 | |
676 ULDP_INCFRAC_UPDATE(15840); //32768.29038 =>15840, 32500 => 21845 | |
677 // 26000 --> 43691 | |
678 #endif /* OP_L1_STANDALONE */ | |
679 | |
680 // program ULPD WAKE-UP .... | |
681 //================================================= | |
682 #if (CHIPSET == 2) | |
683 *((volatile SYS_UWORD16 *)ULDP_SETUP_FRAME_REG) = SETUP_FRAME; // 2 frame | |
684 *((volatile SYS_UWORD16 *)ULDP_SETUP_VTCXO_REG) = SETUP_VTCXO; // 31 periods | |
685 *((volatile SYS_UWORD16 *)ULDP_SETUP_SLICER_REG) = SETUP_SLICER; // 31 periods | |
686 *((volatile SYS_UWORD16 *)ULDP_SETUP_CLK13_REG) = SETUP_CLK13; // 31 periods | |
687 #else | |
688 *((volatile SYS_UWORD16 *)ULDP_SETUP_FRAME_REG) = SETUP_FRAME; // 3 frames | |
689 *((volatile SYS_UWORD16 *)ULDP_SETUP_VTCXO_REG) = SETUP_VTCXO; // 0 periods | |
690 *((volatile SYS_UWORD16 *)ULDP_SETUP_SLICER_REG) = SETUP_SLICER; // 31 periods | |
691 *((volatile SYS_UWORD16 *)ULDP_SETUP_CLK13_REG) = SETUP_CLK13; // 31 periods | |
692 *((volatile SYS_UWORD16 *)ULPD_SETUP_RF_REG) = SETUP_RF; // 31 periods | |
693 #endif | |
694 | |
695 // Set Gauging versus HF (PLL) | |
696 //================================================= | |
697 ULDP_GAUGING_SET_HF; // Enable gauging versus HF | |
698 ULDP_GAUGING_HF_PLL; // Gauging versus PLL | |
699 | |
700 // current supply for quartz oscillation | |
701 //================================================= | |
702 #if (OP_L1_STANDALONE == 1) | |
703 #if ((CHIPSET != 9) && (CHIPSET != 12) && (CHIPSET !=15)) // programming model changed for Ulysse C035, stay with default value | |
704 *(volatile SYS_UWORD16 *)QUARTZ_REG = 0x27; | |
705 #endif | |
706 #else | |
707 #if ((BOARD == 6) || (BOARD == 8) || (BOARD == 9) || (BOARD == 35) || (BOARD == 40) || (BOARD == 41)) | |
708 *((volatile SYS_UWORD16 *)QUARTZ_REG) = 0x27; | |
709 #elif (BOARD == 7) | |
710 *((volatile SYS_UWORD16 *)QUARTZ_REG) = 0x24; | |
711 #endif | |
712 #endif /* OP_L1_STANDALONE */ | |
713 | |
714 // stop Gauging if any (debug purpose ...) | |
715 //-------------------------------------------------- | |
716 if ( *((volatile SYS_UWORD16 *) ULDP_GAUGING_CTRL_REG) & ULDP_GAUGING_EN) | |
717 { | |
718 volatile UWORD32 j; | |
719 ULDP_GAUGING_STOP; /* Stop the gauging */ | |
720 /* wait for gauging it*/ | |
721 // one 32khz period = 401 periods of 13Mhz | |
722 for (j=1; j<50; j++); | |
723 while (! (* (volatile SYS_UWORD16 *) ULDP_GAUGING_STATUS_REG) & ULDP_IT_GAUGING); | |
724 } | |
725 | |
726 #if (OP_L1_STANDALONE == 0) | |
727 AI_ClockEnable (); | |
728 | |
729 #if (BOARD == 7) | |
730 // IOs configuration of the B-Sample in order to optimize the power consumption | |
731 AI_InitIOConfig(); | |
732 | |
733 // Set LPG instead of DSR_MODEM | |
734 *((volatile SYS_UWORD16 *) ASIC_CONF) |= 0x40; | |
735 // Reset the PERM_ON bit of LCR_REG | |
736 *((volatile SYS_UWORD16 *) MEM_LPG) &= ~(0x80); | |
737 #elif ((BOARD == 8) || (BOARD == 9)) | |
738 // IOs configuration of the C-Sample in order to optimize the power consumption | |
739 AI_InitIOConfig(); | |
740 | |
741 // set the debug latch to 0x00. | |
742 *((volatile SYS_UWORD8 *) 0x2800000) = 0x00; | |
743 #elif ((BOARD == 35) || (BOARD == 46)) | |
744 AI_InitIOConfig(); | |
745 // CSMI INTERFACE | |
746 // Initialize CSMI clients for GSM control | |
747 // and Fax/Data services | |
748 CSMI_Init(); | |
749 GC_Initialize(); // GSM control initialization | |
750 CU_Initialize(); // Trace initialization | |
751 CF_Initialize(); // Fax/Data pre-initialization | |
752 #elif ((BOARD == 40) || (BOARD == 41)) | |
753 // IOs configuration of the D-Sample in order to optimize the power consumption | |
754 AI_InitIOConfig(); | |
755 | |
756 #ifdef BTEMOBILE | |
757 // Reset BT chip by toggling the Island's nRESET_OUT signal | |
758 *((volatile SYS_UWORD16 *) 0xFFFFFD04) |= 0x04; | |
759 *((volatile SYS_UWORD16 *) 0xFFFFFD04) &= ~(0x4); | |
760 #endif | |
761 | |
762 // set the debug latch to 0x0000. | |
763 /* | |
764 * FreeCalypso change: this write is only correct when running | |
765 * on an actual D-Sample board, but not on any of the real-world | |
766 * Calypso target devices. | |
767 */ | |
768 #ifdef CONFIG_TARGET_DSAMPLE | |
769 *((volatile SYS_UWORD16 *) 0x2700000) = 0x0000; | |
770 #endif | |
771 #endif // BOARD | |
772 | |
773 // Enable HW Timers 1 & 2 | |
774 TM_EnableTimer (1); | |
775 TM_EnableTimer (2); | |
776 | |
777 #endif /* (OP_L1_STANDALONE == 0) */ | |
778 | |
779 #endif /* #if (BOARD == 5) */ | |
780 } | |
781 | |
782 /* | |
783 * Init_Drivers | |
784 * | |
785 * Performs Drivers Initialization. | |
786 */ | |
787 void Set_Switch_ON_Cause(void); | |
788 void Init_Drivers(void) | |
789 { | |
790 | |
791 #if (CHIPSET==15) | |
792 bspI2c_init(); | |
793 bspTwl3029_init(); | |
794 | |
795 #if (OP_L1_STANDALONE == 0) | |
796 Set_Switch_ON_Cause(); | |
797 #endif | |
798 | |
799 | |
800 /* Turn on DRP We will make VRMCC to device group Modem | |
801 * And Switch it on. | |
802 */ | |
803 bspTwl3029_Power_setDevGrp(NULL,BSP_TWL3029_POWER_VRMMC,BSP_TWL3029_POWER_DEV_GRP_MODEM); | |
804 wait_ARM_cycles(convert_nanosec_to_cycles(100000*2)); | |
805 bspTwl3029_Power_enable(NULL,BSP_TWL3029_POWER_VRMMC,BSP_TWL3029_POWER_STATE_ACTIVE); | |
806 #endif | |
807 | |
808 #if (CHIPSET!=15) | |
809 #if ABB_SEMAPHORE_PROTECTION | |
810 // Create the ABB semaphore | |
811 ABB_Sem_Create(); | |
812 #endif // SEMAPHORE_PROTECTION | |
813 #endif | |
814 | |
815 #if (OP_L1_STANDALONE == 0) | |
816 /* | |
817 * Initialize FFS invoking restore procedure by MPU-S | |
818 */ | |
819 #if ((BOARD == 35) || (BOARD == 46)) | |
820 GC_FfsRestore(); | |
821 #endif | |
822 | |
823 /* | |
824 * FFS main initialization. | |
825 */ | |
826 | |
827 ffs_main_init(); | |
828 | |
829 | |
830 /* | |
831 * Initialize Riviera manager and create tasks thanks to it. | |
832 */ | |
833 #if (CHIPSET!=15) || (REMU==0) | |
834 rvf_init(); | |
835 rvm_init(); /* A-M-E-M-D-E-D! */ | |
836 create_tasks(); | |
837 #endif | |
838 /* | |
839 * SIM Main Initialization. | |
840 */ | |
841 #if (CHIPSET!=15) | |
842 SIM_Initialize (); | |
843 #else | |
844 bspUicc_bootInit(); | |
845 #endif | |
846 #endif | |
847 } | |
848 | |
849 /* | |
850 * Init_Serial_Flows | |
851 * | |
852 * Performs Serialswitch + related serial data flows initialization. | |
853 */ | |
854 void Init_Serial_Flows (void) | |
855 { | |
856 #if (OP_L1_STANDALONE == 0) | |
857 | |
858 /* | |
859 * Initialize Serial Switch module. | |
860 */ | |
861 #if ((BOARD==35) || (BOARD == 46)) | |
862 SER_InitSerialConfig (GC_GetSerialConfig()); | |
863 #else | |
864 SER_InitSerialConfig (&appli_ser_cfg_info); | |
865 #endif | |
866 /* | |
867 * Then Initialize the Serial Data Flows and the associated UARTs: | |
868 * - G2-3 Trace if GSM/GPRS Protocol Stack | |
869 * - AT-Cmd/Fax & Data Flow | |
870 * | |
871 * Layer1/Riviera Trace Flow and Bluetooth HCI Flow are initialized | |
872 * by the appropriate SW Entities. | |
873 * | |
874 * G2-3 Trace => No more Used | |
875 */ | |
876 SER_tr_Init(SER_PROTOCOL_STACK, TR_BAUD_38400, NULL); | |
877 | |
878 /* | |
879 * Fax & Data / AT-Command Interpreter Serial Data Flow Initialization | |
880 */ | |
881 | |
882 #if ((BOARD != 35) && (BOARD != 46)) | |
883 (void) SER_fd_Initialize (); | |
884 #endif | |
885 #else /* OP_L1_STANDALONE */ | |
886 | |
887 #if (TESTMODE || (TRACE_TYPE==1) || (TRACE_TYPE==2) || (TRACE_TYPE==3) || (TRACE_TYPE==6) || (TRACE_TYPE==7)) | |
888 #if ((BOARD == 35) || (BOARD == 46)) | |
889 ser_cfg_info[UA_UART_0] = '0'; | |
890 #else | |
891 ser_cfg_info[UA_UART_0] = 'G'; | |
892 #endif | |
893 #if (CHIPSET !=15) | |
894 ser_cfg_info[UA_UART_1] = 'R'; // Riviear Demux on UART MODEM | |
895 #else | |
896 ser_cfg_info[UA_UART_0] = 'R'; // Riviear Demux on UART MODEM | |
897 #endif | |
898 | |
899 /* init Uart Modem */ | |
900 SER_InitSerialConfig (&appli_ser_cfg_info); | |
901 | |
902 #if TESTMODE || (TRACE_TYPE == 1) || (TRACE_TYPE == 7) | |
903 SER_tr_Init (SER_LAYER_1, TR_BAUD_115200, rvt_activate_RX_HISR); | |
904 | |
905 rvt_register_id("OTHER",&trace_id,(RVT_CALLBACK_FUNC)NULL); | |
906 #else | |
907 SER_tr_Init (SER_LAYER_1, TR_BAUD_38400, NULL); | |
908 #endif | |
909 | |
910 L1_trace_string(" \n\r"); | |
911 | |
912 #endif /* TRACE_TYPE */ | |
913 | |
914 #endif /* OP_L1_STANDALONE */ | |
915 } | |
916 | |
917 /* | |
918 * Init_Unmask_IT | |
919 * | |
920 * Unmask all used interrupts. | |
921 */ | |
922 void Init_Unmask_IT (void) | |
923 { | |
924 IQ_Unmask(IQ_FRAME); | |
925 IQ_Unmask(IQ_UART_IRDA_IT); | |
926 IQ_Unmask(IQ_UART_IT); | |
927 IQ_Unmask(IQ_ARMIO); | |
928 #if (L1_DYN_DSP_DWNLD == 1) | |
929 IQ_Unmask(IQ_API); | |
930 #endif | |
931 } |