comparison src/cs/system/main/init.c @ 0:4e78acac3d88

src/{condat,cs,gpf,nucleus}: import from Selenite
author Mychaela Falconia <falcon@freecalypso.org>
date Fri, 16 Oct 2020 06:23:26 +0000
parents
children 82665effff30
comparison
equal deleted inserted replaced
-1:000000000000 0:4e78acac3d88
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.h"
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 defined(CONFIG_TARGET_DSAMPLE) || defined(CONFIG_TARGET_TANGO)
359 /*
360 * Pirelli's version of this Init_Target() function
361 * in their fw sets the ASIC_CONF register to 0x6050,
362 * which means PWL on the LT/PWL pin and LPG on the
363 * DSR_MODEM pin.
364 *
365 * Also as a bold FreeCalypso change, we now set the same
366 * PWL and LPG pin configs on the D-Sample: the DS board
367 * has LEDs for PWL and for LPG and they work as expected,
368 * thus the board is clearly wired for this pin config.
369 *
370 * Finally, we set the same config on Tango targets:
371 * DSR_MODEM/LPG is configured as LPG in order to avoid
372 * the floating input, whereas LT/PWL works better as PWL.
373 */
374 *((volatile SYS_UWORD16 *) ASIC_CONF) = 0x6050;
375 #elif defined(CONFIG_TARGET_GTAMODEM) || defined(CONFIG_TARGET_GTM900)
376 /*
377 * The DSR_MODEM/LPG Calypso signal is unconnected on
378 * Openmoko's modem, so let's mux it as LPG (output)
379 * so it doesn't float, like Foxconn seem to have done
380 * on the Pirelli.
381 *
382 * On the GTM900 module this signal is explicitly defined as LPG.
383 */
384 *((volatile SYS_UWORD16 *) ASIC_CONF) = 0x6040;
385 #else
386 /* TI's original firmware setting */
387 *((volatile SYS_UWORD16 *) ASIC_CONF) = 0x6000;
388 #endif /* (BOARD == 35) */
389 #endif
390 #endif
391 #endif /* ANLG(ANALOG)) */
392
393 #if (OP_L1_STANDALONE == 1)
394 #if (BOARD == 40) || (BOARD == 41) || \
395 (BOARD == 42) || (BOARD == 43) || (BOARD == 45)
396 // enable 8 Ohm amplifier for audio on D-sample
397 AI_ConfigBitAsOutput (1);
398 AI_SetBit(1);
399 #elif (BOARD == 70) || (BOARD == 71)
400 //Locosto I-sample or UPP costo board.BOARD
401 // Initialize the ARMIO bits as per the I-sample spec
402 // FIXME
403 #endif
404 #endif /* (OP_L1_STANDALONE == 1) */
405 #endif /* PSP_STANDALONE ==0 */
406
407 // Watchdog
408 //--------------------------------------------------
409 TM_DisableWatchdog(); /* Disable Watchdog */
410 #if (CHIPSET == 12) || (CHIPSET == 15)
411 TM_SEC_DisableWatchdog();
412 #endif
413
414 #if ((CHIPSET == 4) || (CHIPSET == 7) || (CHIPSET == 8) || (CHIPSET == 10) || (CHIPSET == 11) || (CHIPSET == 12) || (CHIPSET == 15))
415
416 #if (CHIPSET == 12)
417
418 #if 0 /* example of configuration for DMA debug */
419 #if (BOARD == 6) /* debug on EVA 4 , GPO2 must not be changed */
420
421 /* TPU_FRAME, NMIIT, IACKn */
422 F_DBG_IRQ_CONFIG(C_DBG_IRQ_IRQ4|C_DBG_IRQ_NMIIT|C_DBG_IRQ_IACKN);
423
424 /* NDMA_REQ_VIEW1, NDMA_REQ_VIEW0, DMA_V(1), DMA_S(1), DMAREQ_P1(3:0)*/
425 F_DBG_DMA_P1_NDFLASH_CONFIG(C_DBG_DMA_P1_NDFLASH_NDMA_REQ_VIEW_1 |
426 C_DBG_DMA_P1_NDFLASH_NDMA_REQ_VIEW_0 |
427 C_DBG_DMA_P1_NDFLASH_DMA_REQ_P1_3 |
428 C_DBG_DMA_P1_NDFLASH_DMA_REQ_P1_2 |
429 C_DBG_DMA_P1_NDFLASH_DMA_REQ_P1_1 |
430 C_DBG_DMA_P1_NDFLASH_DMA_REQ_P1_0 |
431 C_DBG_DMA_P1_NDFLASH_DMA_REQ_S_1 |
432 C_DBG_DMA_P1_NDFLASH_DMA_REQ_V1 );
433 /* DMA_REQ_S(2)*/
434 F_DBG_DMA_P2_CONFIG(C_DBG_DMA_P2_DMA_REQ_S2);
435
436 /* DMA_CLK_REQ, BRIDGE_CLK */
437 F_DBG_CLK1_CONFIG(C_DBG_CLK1_DMA_CLK_REQ |
438 C_DBG_CLK1_BRIDGE_CLK );
439
440 /* XIO_nREADY */
441 F_DBG_IMIF_CONFIG(C_DBG_IMIF_XIO_NREADY_MEM);
442
443 /* DSP_nIRQ_VIEW1, DSP_nIRQ_VIEW0, BRIDGE_EN */
444 F_DBG_KB_USIM_SHD_CONFIG(C_DBG_KB_USIM_SHD_DSP_NIRQ_VIEW_1 |
445 C_DBG_KB_USIM_SHD_DSP_NIRQ_VIEW_0 |
446 C_DBG_KB_USIM_SHD_BRIDGE_EN );
447
448 /* RHEA_nREADY , RHEA_nSTROBE */
449 F_DBG_USIM_CONFIG(C_DBG_USIM_RHEA_NSTROBE |
450 C_DBG_USIM_RHEA_NREADY );
451
452 /* XIO_STROBE */
453 F_DBG_MISC2_CONFIG(C_DBG_MISC2_X_IOSTRBN);
454
455 /* DMA_CLK_REQ */
456 F_DBG_CLK2_CONFIG(C_DBG_CLK2_DMA_CLK_REQ2);
457
458 /* DSP_IRQ_SEL0=DMA, DSP_IRQ_SEL1=DMA, DMA_REQ_SEL0=RIF_RX, DMA_REQ_SEL1=RIF_RX */
459 F_DBG_VIEW_CONFIG(0,0,C_DBG_DSP_INT_DMA,
460 C_DBG_DSP_INT_DMA,
461 C_DMA_CHANNEL_RIF_RX,
462 C_DMA_CHANNEL_RIF_RX);
463
464 #endif /* (BOARD == 6) */
465 #endif /* DMA debug example */
466 #else
467 /*
468 * Configure ASIC in order to output the DPLL and ARM clock
469 */
470 // (*( volatile UWORD16* )(0xFFFEF008)) = 0x8000; // DPLL
471 // (*( volatile UWORD16* )(0xFFFEF00E)) = 0x0004; // ARM clock
472 // (*( volatile UWORD16* )(0xfffef004)) = 0x0600; // DSP clock + nIACK
473 #endif /* (CHIPSET == 12) || CHIPSET == 15*/
474
475
476 /*
477 * Enable/Disable of clock switch off for INTH, TIMER, BRIDGE and DPLL modules
478 */
479 // IRQ, Timer and bridge may SLEEP
480 // In first step, same configuration as SAMSON
481 //--------------------------------------------------
482 #if (CHIPSET == 12)
483 CLKM_INITCNTL(CLKM_IRQ_DIS | CLKM_TIMER_DIS | CLKM_BRIDGE_DIS | CLKM_DPLL_DIS);
484 #elif (CHIPSET == 15)
485 CLKM_INITCNTL(CLKM_IRQ_DIS | CLKM_TIMER_DIS | CLKM_CPORT_EN | CLKM_BRIDGE_DIS | 0x8000 ); /* CLKM_DPLL_DIS is remove by Ranga*/
486
487 #else
488 CLKM_INITCNTL(CLKM_IRQ_DIS | CLKM_TIMER_DIS);
489
490 // Select VTCXO input frequency
491 //--------------------------------------------------
492 CLKM_UNUSED_VTCXO_26MHZ;
493
494 // Rita RF uses 26MHz VCXO
495 #if (RF_FAM == 12)
496 CLKM_USE_VTCXO_26MHZ;
497 #endif
498 // Renesas RF uses 26MHz on F-sample but 13MHz on TEB
499 #if (RF_FAM == 43) && (BOARD == 46)
500 CLKM_USE_VTCXO_26MHZ;
501 #endif
502 #endif
503
504
505 // Control HOM/SAM automatic switching
506 //--------------------------------------------------
507 *((volatile unsigned short *) CLKM_CNTL_CLK) &= ~CLKM_EN_IDLE3_FLG;
508
509 /*
510 * The following part has been reconstructed from disassembly.
511 */
512 RHEA_INITRHEA(0,0,0xFF);
513 DPLL_INIT_BYPASS_MODE(DPLL_BYPASS_DIV_1);
514 #if (CHIPSET == 8)
515 DPLL_INIT_DPLL_CLOCK(DPLL_LOCK_DIV_1, 6);
516 #elif (CHIPSET == 10) || (CHIPSET == 11)
517 DPLL_INIT_DPLL_CLOCK(DPLL_LOCK_DIV_1, 8);
518 #else
519 #error "We only have DPLL setup for CHIPSETs 8 and 10"
520 #endif
521 CLKM_InitARMClock(0x00, 2, 0); /* no low freq, no ext clock, div by 1 */
522 /*
523 * FreeCalypso change: memory timings and widths are target-dependent;
524 * please refer to the MEMIF-wait-states document in the freecalypso-docs
525 * repository for the full explanation.
526 */
527 #ifdef CONFIG_TARGET_PIRELLI
528 /*
529 * Pirelli's version of this Init_Target() function
530 * in their fw does the following:
531 */
532 MEM_INIT_CS0(4, MEM_DVS_16, MEM_WRITE_EN, 0);
533 MEM_INIT_CS1(4, MEM_DVS_16, MEM_WRITE_EN, 0);
534 MEM_INIT_CS2(5, MEM_DVS_16, MEM_WRITE_EN, 0);
535 MEM_INIT_CS3(4, MEM_DVS_16, MEM_WRITE_EN, 0);
536 MEM_INIT_CS4(7, MEM_DVS_16, MEM_WRITE_EN, 0);
537 #elif defined(CONFIG_TARGET_C155)
538 /*
539 * C155/156 official fw MEMIF config is almost the same as Pirelli's,
540 * only nCS4 WS is different, but nCS4 is unused on this model...
541 */
542 MEM_INIT_CS0(4, MEM_DVS_16, MEM_WRITE_EN, 0);
543 MEM_INIT_CS1(4, MEM_DVS_16, MEM_WRITE_EN, 0);
544 MEM_INIT_CS2(5, MEM_DVS_16, MEM_WRITE_EN, 0);
545 MEM_INIT_CS3(4, MEM_DVS_16, MEM_WRITE_EN, 0);
546 MEM_INIT_CS4(6, MEM_DVS_16, MEM_WRITE_EN, 0);
547 #elif defined(CONFIG_TARGET_C11X) || defined(CONFIG_TARGET_C139) || \
548 defined(CONFIG_TARGET_GTAMODEM)
549 /*
550 * The original settings from Openmoko,
551 * only nCS0 and nCS1 are actually used,
552 * same as on Mot C1xx phones,
553 * the nCS2/3/4 settings are dummies from TI.
554 */
555 MEM_INIT_CS0(3, MEM_DVS_16, MEM_WRITE_EN, 0);
556 MEM_INIT_CS1(3, MEM_DVS_16, MEM_WRITE_EN, 0);
557 MEM_INIT_CS2(5, MEM_DVS_16, MEM_WRITE_EN, 0);
558 MEM_INIT_CS3(3, MEM_DVS_16, MEM_WRITE_EN, 0);
559 MEM_INIT_CS4(0, MEM_DVS_8, MEM_WRITE_EN, 0);
560 #elif defined(CONFIG_TARGET_J100)
561 /*
562 * Same as Mot C11x/12x/139/140 and Openmoko except for nCS2 WS:
563 * it appears that SE J100 has its ringtone melody generator chip
564 * hooked up there.
565 */
566 MEM_INIT_CS0(3, MEM_DVS_16, MEM_WRITE_EN, 0);
567 MEM_INIT_CS1(3, MEM_DVS_16, MEM_WRITE_EN, 0);
568 MEM_INIT_CS2(6, MEM_DVS_16, MEM_WRITE_EN, 0);
569 MEM_INIT_CS3(3, MEM_DVS_16, MEM_WRITE_EN, 0);
570 MEM_INIT_CS4(0, MEM_DVS_8, MEM_WRITE_EN, 0);
571 #elif defined(CONFIG_TARGET_LUNA)
572 /*
573 * nCS0 is flash, nCS1 is XRAM, the LCD is connected to nCS3.
574 * nCS2 and nCS4 are currently unused.
575 */
576 MEM_INIT_CS0(4, MEM_DVS_16, MEM_WRITE_EN, 0);
577 MEM_INIT_CS1(4, MEM_DVS_16, MEM_WRITE_EN, 0);
578 MEM_INIT_CS2(4, MEM_DVS_16, MEM_WRITE_EN, 0);
579 MEM_INIT_CS3(5, MEM_DVS_16, MEM_WRITE_EN, 1);
580 MEM_INIT_CS4(0, MEM_DVS_8, MEM_WRITE_EN, 0);
581 #elif (CHIPSET == 8)
582 /*
583 * Our only Calypso C05 target is Mother Mychaela's D-Sample board.
584 * WS=3 with the ARM7 core running at 39 MHz gives us 92 ns,
585 * so we should be good on this board.
586 */
587 MEM_INIT_CS0(3, MEM_DVS_16, MEM_WRITE_EN, 0);
588 MEM_INIT_CS1(3, MEM_DVS_16, MEM_WRITE_EN, 0);
589 MEM_INIT_CS2(3, MEM_DVS_16, MEM_WRITE_EN, 0);
590 MEM_INIT_CS3(3, MEM_DVS_16, MEM_WRITE_EN, 0);
591 MEM_INIT_CS4(0, MEM_DVS_8, MEM_WRITE_EN, 0);
592 #elif (CHIPSET == 10) || (CHIPSET == 11)
593 /*
594 * Default for Calypso C035 targets in the absence of a more specific
595 * selection above. We put the WS=4 memory-oriented setting on all
596 * chip selects so we automatically cover targets with a second flash
597 * chip select no matter if it's nCS2, nCS3 or nCS4, as well as even
598 * weirder targets with XRAM somewhere other than nCS1.
599 */
600 MEM_INIT_CS0(4, MEM_DVS_16, MEM_WRITE_EN, 0);
601 MEM_INIT_CS1(4, MEM_DVS_16, MEM_WRITE_EN, 0);
602 MEM_INIT_CS2(4, MEM_DVS_16, MEM_WRITE_EN, 0);
603 MEM_INIT_CS3(4, MEM_DVS_16, MEM_WRITE_EN, 0);
604 MEM_INIT_CS4(4, MEM_DVS_16, MEM_WRITE_EN, 0);
605 #else
606 #error "Unknown MEMIF configuration"
607 #endif
608 MEM_INIT_CS6(0, MEM_DVS_32, MEM_WRITE_EN, 0);
609 MEM_INIT_CS7(0, MEM_DVS_32, MEM_WRITE_DIS, 0);
610 RHEA_INITAPI(0,1);
611 RHEA_INITARM(0,0);
612 DPLL_SET_PLL_ENABLE;
613
614 /*
615 * Disable and Clear all pending interrupts
616 */
617 #if (CHIPSET == 12) || (CHIPSET == 15)
618 F_INTH_DISABLE_ALL_IT; // MASK all it
619 F_INTH2_VALID_NEXT(C_INTH_IRQ); // reset current IT in INTH2 IRQ
620 F_INTH_VALID_NEXT(C_INTH_IRQ); // reset current IT in INTH IRQ
621 F_INTH_VALID_NEXT(C_INTH_FIQ); // reset current IT in INTH FIQ
622 F_INTH_RESET_ALL_IT; // reset all IRQ/FIQ source
623 #else
624 INTH_DISABLEALLIT;
625 #if 0 /* not present in our reference binary object */
626 INTH_RESETALLIT;
627 #endif
628 INTH_CLEAR; /* reset IRQ/FIQ source */
629 #endif
630
631 // INTH
632 //--------------------------------------------------
633 #if (CHIPSET == 12) || (CHIPSET == 15)
634 #if (GSM_IDLE_RAM != 0)
635 f_inth_setup((T_INTH_CONFIG *)a_inth_config_idle_ram); // setup configuration IT handlers
636 #else
637 f_inth_setup((T_INTH_CONFIG *)a_inth_config); // setup configuration IT handlers
638 #endif
639 #else
640 IQ_SetupInterrupts();
641 #endif
642
643
644 #if (CHIPSET == 12) || (CHIPSET == 15)
645 #if (OP_L1_STANDALONE == 0)
646
647 f_dma_global_parameter_set((T_DMA_TYPE_GLOBAL_PARAMETER *)&d_dma_global_parameter);
648 #endif
649 f_dma_channel_allocation_set(C_DMA_CHANNEL_0, C_DMA_CHANNEL_DSP);
650 #if (OP_L1_STANDALONE == 1)
651 f_dma_global_parameter_set((T_DMA_TYPE_GLOBAL_PARAMETER *)&d_dma_global_parameter);
652 f_dma_channel_allocation_set(C_DMA_CHANNEL_0, C_DMA_CHANNEL_DSP);
653 #endif
654
655 #else
656 // DMA
657 //--------------------------------------------------
658 // channel0 = Arm, channel1 = Lead, channel2 = forced to Arm, channel3=forced to Arm, dma_burst = 0001, priority = same
659 #if (OP_L1_STANDALONE == 0)
660 DMA_ALLOCDMA(1,0,1,1); // Channel 1 used by DSP with RIF RX
661 #endif
662 #endif
663
664 /* CHIPSET = 4 or 7 or 8 or 10 or 11 or 12 */
665
666 #else
667
668 // RHEA Bridge
669 //--------------------------------------------------
670 // ACCES_FAC_0 = 0, ACCES_FAC_1 = 0 ,TIMEOUT = 0x7F
671 RHEA_INITRHEA(0,0,0x7F);
672
673 #if (CHIPSET == 6)
674 // WS_H = 1 , WS_L = 15
675 RHEA_INITAPI(1,15); // should be 0x01E1 for 65 Mhz
676 #else
677 // WS_H = 0 , WS_L = 7
678 RHEA_INITAPI(0,7); // should be 0x0101 for 65 Mhz
679 #endif
680
681 // Write_en_0 = 0 , Write_en_1 = 0
682 RHEA_INITARM(0,0);
683
684 // INTH
685 //--------------------------------------------------
686 INTH_DISABLEALLIT; // MASK all it
687 INTH_CLEAR; // reset IRQ/FIQ source
688 IQ_SetupInterrupts();
689
690 // DMA
691 //--------------------------------------------------
692 // channel0 = Arm, channel1 = Lead, dma_burst = 0001, priority = same
693 DMA_ALLOCDMA(1,0,1,1); // should be 0x25 (channel 1 = lead)
694
695 #if (CHIPSET == 6)
696 // Memory WS configuration for ULYSS/G1 (26 Mhz) board
697 //-----------------------------------------------------
698 MEM_INIT_CS2(2,MEM_DVS_16,MEM_WRITE_EN,0);
699 #endif
700
701 // CLKM
702 //--------------------------------------------------
703 CLKM_InitARMClock(0x00, 2); /* no low freq, no ext clock, div by 1 */
704
705 #if (CHIPSET == 6)
706 CLKM_INITCNTL(CLKM_IRQ_DIS | CLKM_BRIDGE_DIS | CLKM_TIMER_DIS | CLKM_VTCXO_26);
707 #else
708 CLKM_INITCNTL(CLKM_IRQ_DIS | CLKM_BRIDGE_DIS | CLKM_TIMER_DIS);
709 #endif
710
711 #endif /* CHIPSET = 4 or 7 or 8 or 10 or 11 or 12 */
712
713 // Freeze ULPD timer ....
714 //--------------------------------------------------
715 *((volatile SYS_UWORD16 *) ULDP_GSM_TIMER_INIT_REG ) = 0;
716 *((volatile SYS_UWORD16 *) ULDP_GSM_TIMER_CTRL_REG ) = TPU_FREEZE;
717
718 // reset INC_SIXTEEN and INC_FRAC
719 //--------------------------------------------------
720 #if (OP_L1_STANDALONE == 1)
721 l1ctl_pgm_clk32(DEFAULT_HFMHZ_VALUE,DEFAULT_32KHZ_VALUE);
722 #else
723 ULDP_INCSIXTEEN_UPDATE(132); //32768.29038 =>132, 32500 => 133
724 // 26000 --> 166
725 ULDP_INCFRAC_UPDATE(15840); //32768.29038 =>15840, 32500 => 21845
726 // 26000 --> 43691
727 #endif /* OP_L1_STANDALONE */
728
729 // program ULPD WAKE-UP ....
730 //=================================================
731 #if (CHIPSET == 2)
732 *((volatile SYS_UWORD16 *)ULDP_SETUP_FRAME_REG) = SETUP_FRAME; // 2 frame
733 *((volatile SYS_UWORD16 *)ULDP_SETUP_VTCXO_REG) = SETUP_VTCXO; // 31 periods
734 *((volatile SYS_UWORD16 *)ULDP_SETUP_SLICER_REG) = SETUP_SLICER; // 31 periods
735 *((volatile SYS_UWORD16 *)ULDP_SETUP_CLK13_REG) = SETUP_CLK13; // 31 periods
736 #else
737 *((volatile SYS_UWORD16 *)ULDP_SETUP_FRAME_REG) = SETUP_FRAME; // 3 frames
738 *((volatile SYS_UWORD16 *)ULDP_SETUP_VTCXO_REG) = SETUP_VTCXO; // 0 periods
739 *((volatile SYS_UWORD16 *)ULDP_SETUP_SLICER_REG) = SETUP_SLICER; // 31 periods
740 *((volatile SYS_UWORD16 *)ULDP_SETUP_CLK13_REG) = SETUP_CLK13; // 31 periods
741 *((volatile SYS_UWORD16 *)ULPD_SETUP_RF_REG) = SETUP_RF; // 31 periods
742 #endif
743
744 // Set Gauging versus HF (PLL)
745 //=================================================
746 ULDP_GAUGING_SET_HF; // Enable gauging versus HF
747 ULDP_GAUGING_HF_PLL; // Gauging versus PLL
748
749 // current supply for quartz oscillation
750 //=================================================
751 #if (OP_L1_STANDALONE == 1)
752 #if ((CHIPSET != 9) && (CHIPSET != 12) && (CHIPSET !=15)) // programming model changed for Ulysse C035, stay with default value
753 *(volatile SYS_UWORD16 *)QUARTZ_REG = 0x27;
754 #endif
755 #else
756 #if ((BOARD == 6) || (BOARD == 8) || (BOARD == 9) || (BOARD == 35) || (BOARD == 40) || (BOARD == 41))
757 *((volatile SYS_UWORD16 *)QUARTZ_REG) = 0x27;
758 #elif (BOARD == 7)
759 *((volatile SYS_UWORD16 *)QUARTZ_REG) = 0x24;
760 #endif
761 #endif /* OP_L1_STANDALONE */
762
763 // stop Gauging if any (debug purpose ...)
764 //--------------------------------------------------
765 if ( *((volatile SYS_UWORD16 *) ULDP_GAUGING_CTRL_REG) & ULDP_GAUGING_EN)
766 {
767 volatile UWORD32 j;
768 ULDP_GAUGING_STOP; /* Stop the gauging */
769 /* wait for gauging it*/
770 // one 32khz period = 401 periods of 13Mhz
771 for (j=1; j<50; j++);
772 while (! (* (volatile SYS_UWORD16 *) ULDP_GAUGING_STATUS_REG) & ULDP_IT_GAUGING);
773 }
774
775 #if (OP_L1_STANDALONE == 0)
776 AI_ClockEnable ();
777
778 #if (BOARD == 7)
779 // IOs configuration of the B-Sample in order to optimize the power consumption
780 AI_InitIOConfig();
781
782 // Set LPG instead of DSR_MODEM
783 *((volatile SYS_UWORD16 *) ASIC_CONF) |= 0x40;
784 // Reset the PERM_ON bit of LCR_REG
785 *((volatile SYS_UWORD16 *) MEM_LPG) &= ~(0x80);
786 #elif ((BOARD == 8) || (BOARD == 9))
787 // IOs configuration of the C-Sample in order to optimize the power consumption
788 AI_InitIOConfig();
789
790 // set the debug latch to 0x00.
791 *((volatile SYS_UWORD8 *) 0x2800000) = 0x00;
792 #elif ((BOARD == 35) || (BOARD == 46))
793 AI_InitIOConfig();
794 // CSMI INTERFACE
795 // Initialize CSMI clients for GSM control
796 // and Fax/Data services
797 CSMI_Init();
798 GC_Initialize(); // GSM control initialization
799 CU_Initialize(); // Trace initialization
800 CF_Initialize(); // Fax/Data pre-initialization
801 #elif ((BOARD == 40) || (BOARD == 41))
802 // IOs configuration of the D-Sample in order to optimize the power consumption
803 AI_InitIOConfig();
804
805 #ifdef BTEMOBILE
806 // Reset BT chip by toggling the Island's nRESET_OUT signal
807 *((volatile SYS_UWORD16 *) 0xFFFFFD04) |= 0x04;
808 *((volatile SYS_UWORD16 *) 0xFFFFFD04) &= ~(0x4);
809 #endif
810
811 // set the debug latch to 0x0000.
812 /*
813 * FreeCalypso change: this write is only correct when running
814 * on an actual D-Sample board, but not on any of the real-world
815 * Calypso target devices.
816 */
817 #ifdef CONFIG_TARGET_DSAMPLE
818 *((volatile SYS_UWORD16 *) 0x2700000) = 0x0000;
819 #endif
820 #endif // BOARD
821
822 // Enable HW Timers 1 & 2
823 TM_EnableTimer (1);
824 TM_EnableTimer (2);
825
826 #endif /* (OP_L1_STANDALONE == 0) */
827
828 #endif /* #if (BOARD == 5) */
829 }
830
831 /*
832 * Init_Drivers
833 *
834 * Performs Drivers Initialization.
835 */
836 void Set_Switch_ON_Cause(void);
837 void Init_Drivers(void)
838 {
839
840 #if (CHIPSET==15)
841 bspI2c_init();
842 bspTwl3029_init();
843
844 #if (OP_L1_STANDALONE == 0)
845 Set_Switch_ON_Cause();
846 #endif
847
848
849 /* Turn on DRP We will make VRMCC to device group Modem
850 * And Switch it on.
851 */
852 bspTwl3029_Power_setDevGrp(NULL,BSP_TWL3029_POWER_VRMMC,BSP_TWL3029_POWER_DEV_GRP_MODEM);
853 wait_ARM_cycles(convert_nanosec_to_cycles(100000*2));
854 bspTwl3029_Power_enable(NULL,BSP_TWL3029_POWER_VRMMC,BSP_TWL3029_POWER_STATE_ACTIVE);
855 #endif
856
857 #if (CHIPSET!=15)
858 #if ABB_SEMAPHORE_PROTECTION
859 // Create the ABB semaphore
860 ABB_Sem_Create();
861 #endif // SEMAPHORE_PROTECTION
862 #endif
863
864 #if (OP_L1_STANDALONE == 0)
865 /*
866 * Initialize FFS invoking restore procedure by MPU-S
867 */
868 #if ((BOARD == 35) || (BOARD == 46))
869 GC_FfsRestore();
870 #endif
871
872 /*
873 * FFS main initialization.
874 */
875
876 ffs_main_init();
877
878
879 /*
880 * Initialize Riviera manager and create tasks thanks to it.
881 */
882 #if (CHIPSET!=15) || (REMU==0)
883 rvf_init();
884 rvm_init(); /* A-M-E-M-D-E-D! */
885 create_tasks();
886 #endif
887 /*
888 * SIM Main Initialization.
889 */
890 #if (CHIPSET!=15)
891 SIM_Initialize ();
892 #else
893 bspUicc_bootInit();
894 #endif
895 #endif
896
897 #ifdef CONFIG_TANGO_MODEM
898 AI_Init_Tango_pinmux();
899 #endif
900 }
901
902 /*
903 * Init_Serial_Flows
904 *
905 * Performs Serialswitch + related serial data flows initialization.
906 */
907 void Init_Serial_Flows (void)
908 {
909 #if (OP_L1_STANDALONE == 0)
910
911 /*
912 * Initialize Serial Switch module.
913 */
914 #if ((BOARD==35) || (BOARD == 46))
915 SER_InitSerialConfig (GC_GetSerialConfig());
916 #else
917 SER_InitSerialConfig (&appli_ser_cfg_info);
918 #endif
919 /*
920 * Then Initialize the Serial Data Flows and the associated UARTs:
921 * - G2-3 Trace if GSM/GPRS Protocol Stack
922 * - AT-Cmd/Fax & Data Flow
923 *
924 * Layer1/Riviera Trace Flow and Bluetooth HCI Flow are initialized
925 * by the appropriate SW Entities.
926 *
927 * G2-3 Trace => No more Used
928 */
929 SER_tr_Init(SER_PROTOCOL_STACK, TR_BAUD_38400, NULL);
930
931 /*
932 * Fax & Data / AT-Command Interpreter Serial Data Flow Initialization
933 */
934
935 #if ((BOARD != 35) && (BOARD != 46))
936 (void) SER_fd_Initialize ();
937 #endif
938 #else /* OP_L1_STANDALONE */
939
940 #if (TESTMODE || (TRACE_TYPE==1) || (TRACE_TYPE==2) || (TRACE_TYPE==3) || (TRACE_TYPE==6) || (TRACE_TYPE==7))
941 #if ((BOARD == 35) || (BOARD == 46))
942 ser_cfg_info[UA_UART_0] = '0';
943 #else
944 ser_cfg_info[UA_UART_0] = 'G';
945 #endif
946 #if (CHIPSET !=15)
947 ser_cfg_info[UA_UART_1] = 'R'; // Riviear Demux on UART MODEM
948 #else
949 ser_cfg_info[UA_UART_0] = 'R'; // Riviear Demux on UART MODEM
950 #endif
951
952 /* init Uart Modem */
953 SER_InitSerialConfig (&appli_ser_cfg_info);
954
955 #if TESTMODE || (TRACE_TYPE == 1) || (TRACE_TYPE == 7)
956 SER_tr_Init (SER_LAYER_1, TR_BAUD_115200, rvt_activate_RX_HISR);
957
958 rvt_register_id("OTHER",&trace_id,(RVT_CALLBACK_FUNC)NULL);
959 #else
960 SER_tr_Init (SER_LAYER_1, TR_BAUD_38400, NULL);
961 #endif
962
963 L1_trace_string(" \n\r");
964
965 #endif /* TRACE_TYPE */
966
967 #endif /* OP_L1_STANDALONE */
968 }
969
970 /*
971 * Init_Unmask_IT
972 *
973 * Unmask all used interrupts.
974 */
975 void Init_Unmask_IT (void)
976 {
977 IQ_Unmask(IQ_FRAME);
978 IQ_Unmask(IQ_UART_IRDA_IT);
979 IQ_Unmask(IQ_UART_IT);
980 IQ_Unmask(IQ_ARMIO);
981 #if (L1_DYN_DSP_DWNLD == 1)
982 IQ_Unmask(IQ_API);
983 #endif
984 }