changeset 123:63137aa0ad1f

l1_pwmgr.c: passes compilation (but link fails)
author Mychaela Falconia <falcon@ivan.Harhan.ORG>
date Thu, 12 May 2016 02:18:21 +0000
parents 9360d1f31c00
children 190c68fa5689
files chipsetsw/layer1/cfile/l1_pwmgr.c
diffstat 1 files changed, 51 insertions(+), 107 deletions(-) [+]
line wrap: on
line diff
--- a/chipsetsw/layer1/cfile/l1_pwmgr.c	Wed May 11 23:57:47 2016 +0000
+++ b/chipsetsw/layer1/cfile/l1_pwmgr.c	Thu May 12 02:18:21 2016 +0000
@@ -7,73 +7,9 @@
  *
  ************* Revision Controle System Header *************/
 
-// pinghua add these programe code section to put some sleep code into internal ram.
-/*
- * FreeCalypso: the Leonardo binary object version puts all of l1_pwmgr
- * into the regular run-from-flash text section, so we'll do the same
- * for now.
- */
-#if 0
-#pragma CODE_SECTION(l1s_sleep_manager,".emifconf")
-#pragma CODE_SECTION(EMIF_SetConfReg,".emifconf")
-#pragma CODE_SECTION(audio_madc_sleep,".emifconf")
-#pragma CODE_SECTION(Check_Peripheral_App,".emifconf")
-#pragma CODE_SECTION(DBB_Configure_DS,".emifconf")
-#pragma CODE_SECTION(DBB_Wakeup_DS,".emifconf")
-#pragma CODE_SECTION(l1ctl_pgm_clk32,".emifconf")
-#pragma CODE_SECTION(l1ctl_gauging,".emifconf")
-#pragma CODE_SECTION(GAUGING_Handler,".emifconf")
-#pragma CODE_SECTION(l1s_get_HWTimers_ticks,".emifconf")
-#pragma CODE_SECTION(l1s_adapt_traffic_controller,".emifconf")
-#pragma CODE_SECTION(l1s_wakeup,".emifconf")
-#pragma CODE_SECTION(l1s_wakeup_adjust,".emifconf")
-#pragma CODE_SECTION(l1s_compute_wakeup_ticks,".emifconf")
-#pragma CODE_SECTION(l1s_recover_Frame,".emifconf")
-#pragma CODE_SECTION(l1s_recover_HWTimers,".emifconf")
-#pragma CODE_SECTION(l1s_get_next_gauging_in_Packet_Idle,".emifconf")
-#pragma CODE_SECTION(l1s_gauging_decision_with_PNP,".emifconf")
-#pragma CODE_SECTION(l1s_gauging_decision_with_NP,".emifconf")
-#pragma CODE_SECTION(l1s_gauging_task,".emifconf")
-#pragma CODE_SECTION(l1s_gauging_task_end,".emifconf")
-// 2-03-2007 pinghua added end
-#endif
-
 #define  L1_PWMGR_C
 //#pragma DUPLICATE_FOR_INTERNAL_RAM_START
 
-//sajal added .....................................
-  #if (CODE_VERSION == SIMULATION)
-  //#include "l1_pwmgr.h"
-//omaps00090550 #303 warning removal 	typedef unsigned char  UWORD_8;
-
-//	typedef volatile unsigned short REG_UWORD16; //omaps00090550
-//	#define REG16(A)    (*(REG_UWORD16*)(A))  //omaps00090550
-//	typedef volatile unsigned short REGISTER_UWORD16;  //omaps00090550
-
-	#define MAP_ULPD_REG	                0xFFFE2000	//ULPD registers start address            (CS4)
-	#define ULPD_SETUP_CLK13_REG   	       (*(REGISTER_UWORD16*)((REGISTER_UWORD16 *)(MAP_ULPD_REG) + 14))
-	#define ULPD_SETUP_SLICER_REG	       (*(REGISTER_UWORD16*)((REGISTER_UWORD16 *)(MAP_ULPD_REG) + 15))
-	#define ULPD_SETUP_VTCXO_REG           (*(REGISTER_UWORD16*)((REGISTER_UWORD16 *)(MAP_ULPD_REG) + 16))
-
-	#define MAP_CLKM_REG	          0xFFFFFD00	 //CLOCKM         registers start address  (CS31)
-	#define CLKM_CNTL_CLK_OFFSET         0x02
-	#define CLKM_CNTL_CLK_REG            REG16 (MAP_CLKM_REG + CLKM_CNTL_CLK_OFFSET)
-
-	#define EMIF_CONFIG_PWD_POS                      0
-	#define EMIF_CONFIG_PDE_POS                      1
-	#define EMIF_CONFIG_PREFETCH_POS                3
-	#define EMIF_CONFIG_FLUSH_PREFETCH_POS          5
-	#define EMIF_CONFIG_WP_POS                      6
-
-	#define            EMIF_CONFIG                              REG16(EMIF_CONFIG_BASE_ADDR+EMIF_CONFIG_REG_OFFSET)
-	#define EMIF_CONFIG_BASE_ADDR      0xFFFFFB00      //External Memory inter registers address (CS31)   (NEW)
-	#define EMIF_CONFIG_REG_OFFSET          0x02    // Emif configuration register
-
-#endif
-//sajal added till here......
-
-
-
 #include "timer/timer2.h"
 #include "armio/armio.h"
 
@@ -418,7 +354,7 @@
 #endif
 
 #if L1_GPRS
-  UWORD32 l1s_get_next_gauging_in_Packet_Idle(void);
+  WORD32 l1s_get_next_gauging_in_Packet_Idle(void);
 #endif
 //#pragma DUPLICATE_FOR_INTERNAL_RAM_END
 
@@ -1528,6 +1464,11 @@
  }
 #endif
 
+UWORD32 last_wakeup;
+UWORD8  wakeup_type;        // Type of the interrupt
+UWORD8  why_big_sleep;      // Type of the big sleep
+
+extern UWORD16 int_id;
 
 // l1s_sleep_manager()
 // Description:
@@ -1591,11 +1532,11 @@
     #endif
 
     // init for trace and debug
-    l1s.pw_mgr.why_big_sleep = BIG_SLEEP_DUE_TO_UNDEFINED;
-    l1s.pw_mgr.wakeup_type   = WAKEUP_FOR_UNDEFINED;
+    why_big_sleep = BIG_SLEEP_DUE_TO_UNDEFINED;
+    wakeup_type   = WAKEUP_FOR_UNDEFINED;
 
 #if (CHIPSET != 15)
-    time_from_last_wakeup = (sleep_time - l1s.pw_mgr.wakeup_time + 42432) % 42432;
+    time_from_last_wakeup = (sleep_time - last_wakeup + 42432) % 42432;
 #endif
 
 
@@ -1717,7 +1658,7 @@
          || !HWtimer
          || !min_time_gauging
 		#if (CHIPSET != 15)
-         || ((sleep_mode != CLOCK_STOP) && ((l1s.pw_mgr.why_big_sleep == BIG_SLEEP_DUE_TO_UART) || (l1s.pw_mgr.why_big_sleep == BIG_SLEEP_DUE_TO_SIM)))
+         || ((sleep_mode != CLOCK_STOP) && ((why_big_sleep == BIG_SLEEP_DUE_TO_UART) || (why_big_sleep == BIG_SLEEP_DUE_TO_SIM)))
 		#endif
        #if (OP_BT == 1)
          || !hci_ll_status
@@ -1795,11 +1736,11 @@
     #if (TRACE_TYPE !=0 ) && (TRACE_TYPE != 2) && (TRACE_TYPE != 3)
       // to trace the Wake up source
       // depending of min_time choose the wakeup_type
-      l1s.pw_mgr.wakeup_type = WAKEUP_FOR_L1_TASK;
-      if (min_time == l1a_l1s_com.time_to_next_l1s_task) l1s.pw_mgr.wakeup_type = WAKEUP_FOR_L1_TASK;
-      if (min_time == HWtimer)                           l1s.pw_mgr.wakeup_type = WAKEUP_FOR_HW_TIMER_TASK;
-      if (min_time == min_time_gauging)                  l1s.pw_mgr.wakeup_type = WAKEUP_FOR_GAUGING_TASK;
-      if (min_time == OSload)                            l1s.pw_mgr.wakeup_type = WAKEUP_FOR_OS_TASK;
+      wakeup_type = WAKEUP_FOR_L1_TASK;
+      if (min_time == l1a_l1s_com.time_to_next_l1s_task) wakeup_type = WAKEUP_FOR_L1_TASK;
+      if (min_time == HWtimer)                           wakeup_type = WAKEUP_FOR_HW_TIMER_TASK;
+      if (min_time == min_time_gauging)                  wakeup_type = WAKEUP_FOR_GAUGING_TASK;
+      if (min_time == OSload)                            wakeup_type = WAKEUP_FOR_OS_TASK;
     #endif
 
     //=================================================
@@ -1826,13 +1767,13 @@
            // BIG SLEEP is chosen : check the reason
            l1s.pw_mgr.sleep_performed = FRAME_STOP;
            if ((l1s.pw_mgr.enough_gaug != TRUE) && (l1a_l1s_com.mode != CS_MODE0))
-             l1s.pw_mgr.why_big_sleep = BIG_SLEEP_DUE_TO_GAUGING;
+             why_big_sleep = BIG_SLEEP_DUE_TO_GAUGING;
            else
-             l1s.pw_mgr.why_big_sleep = BIG_SLEEP_DUE_TO_DSP_TRACES;
+             why_big_sleep = BIG_SLEEP_DUE_TO_DSP_TRACES;
          }
       }
       if (l1s.pw_mgr.mode_authorized == BIG_SLEEP)
-        l1s.pw_mgr.why_big_sleep = BIG_SLEEP_DUE_TO_SLEEP_MODE;
+        why_big_sleep = BIG_SLEEP_DUE_TO_SLEEP_MODE;
 
       if ( ((l1s.pw_mgr.mode_authorized == BIG_SLEEP) && (sleep_mode >= FRAME_STOP)) ||
            ((l1s.pw_mgr.mode_authorized >= DEEP_SLEEP) && (sleep_mode == FRAME_STOP)) )
@@ -2114,7 +2055,7 @@
       if ( l1s.pw_mgr.sleep_performed == CLOCK_STOP )
       {
         // DEEP SLEEP -> need time to setup afc and rf
-         wake_up_time = min_time - l1_config.params.rf_wakeup_tpu_scenario_duration;
+         wake_up_time = min_time - l1_config.params.setup_afc_and_rf;
 	 #if (CODE_VERSION == NOT_SIMULATION)
 	// Sleep one more TDMA - this is done as part of merging init and TPU control
 	      wake_up_time += 1;
@@ -2263,11 +2204,11 @@
          asm(" NOP");
        #endif
 
-      l1s.pw_mgr.wakeup_time = l1s.actual_time.fn_mod42432;
-
-      if (l1s.pw_mgr.wakeup_time == sleep_time)
+      last_wakeup = l1s.actual_time.fn_mod42432;
+
+      if (last_wakeup == sleep_time)
       // sleep duration == 0 -> wakeup in the same frame as sleep
-        l1s.pw_mgr.wakeup_type = WAKEUP_ASYNCHRONOUS_SLEEP_DURATION_0;
+        wakeup_type = WAKEUP_ASYNCHRONOUS_SLEEP_DURATION_0;
 
 #if (GSM_IDLE_RAM != 0)
 // Update counters with sleep duration -> will be used case expiration in next wake up phase before traffic controller is enabled by msg sending
@@ -2381,15 +2322,15 @@
          if (l1a_l1s_com.mode != CS_MODE0) // in this mode the trace prevent from going to deep sleep due to UART activity
          {
            #if (GSM_IDLE_RAM == 0)
-             l1_trace_sleep(sleep_time,l1s.actual_time.fn_mod42432,l1s.pw_mgr.sleep_performed,l1s.pw_mgr.wakeup_type,l1s.pw_mgr.why_big_sleep, l1s.pw_mgr.wake_up_int_id);
+             l1_trace_sleep(sleep_time, l1s.actual_time.fn_mod42432, l1s.pw_mgr.sleep_performed, wakeup_type, why_big_sleep);
            #else
-             l1_trace_sleep_intram(sleep_time,l1s.actual_time.fn_mod42432,l1s.pw_mgr.sleep_performed,l1s.pw_mgr.wakeup_type,l1s.pw_mgr.why_big_sleep, l1s.pw_mgr.wake_up_int_id);
+             l1_trace_sleep_intram(sleep_time, l1s.actual_time.fn_mod42432, l1s.pw_mgr.sleep_performed, wakeup_type, why_big_sleep);
              #if (TRACE_TYPE==1) || (TRACE_TYPE==4)
                l1s_trace_mftab();
              #endif
            #endif
          }
-         l1s.pw_mgr.wake_up_int_id = 0;
+         int_id = 0;
        #endif
 
        #if (TRACE_TYPE == 1) || (TRACE_TYPE == 4)
@@ -2479,13 +2420,13 @@
       #endif
 
       #if (CHIPSET == 12) || (CHIPSET == 15)
-        l1s.pw_mgr.wake_up_int_id = ((* (SYS_UWORD16 *) C_INTH_B_IRQ_REG) & C_INTH_SRC_NUM);// For debug: Save IRQ that causes the waking up
-        if ( l1s.pw_mgr.wake_up_int_id >= 256 )
-          l1s.pw_mgr.wake_up_int_id = ((* (SYS_UWORD16 *) C_INTH_B_FIQ_REG) & C_INTH_SRC_NUM)+100;
+        int_id = ((* (SYS_UWORD16 *) C_INTH_B_IRQ_REG) & C_INTH_SRC_NUM);// For debug: Save IRQ that causes the waking up
+        if ( int_id >= 256 )
+          int_id = ((* (SYS_UWORD16 *) C_INTH_B_FIQ_REG) & C_INTH_SRC_NUM)+100;
       #else
-        l1s.pw_mgr.wake_up_int_id = ((* (SYS_UWORD16 *) INTH_B_IRQ_REG) & INTH_SRC_NUM);// For debug: Save IRQ that causes the waking up
-        if ( l1s.pw_mgr.wake_up_int_id >= 256 )
-          l1s.pw_mgr.wake_up_int_id = ((* (SYS_UWORD16 *) INTH_B_FIQ_REG) & INTH_SRC_NUM)+100;
+        int_id = ((* (SYS_UWORD16 *) INTH_B_IRQ_REG) & INTH_SRC_NUM);// For debug: Save IRQ that causes the waking up
+        if ( int_id >= 256 )
+          int_id = ((* (SYS_UWORD16 *) INTH_B_FIQ_REG) & INTH_SRC_NUM)+100;
       #endif
 
       // clear pending IQ_FRAME it and unmask it
@@ -2569,7 +2510,7 @@
 
       #if (TRACE_TYPE !=0 ) && (TRACE_TYPE != 2) && (TRACE_TYPE != 3)
         if ((l1s.pw_mgr.frame_adjust == TRUE))
-          l1s.pw_mgr.wakeup_type = WAKEUP_BY_ASYNC_INTERRUPT;
+          wakeup_type = WAKEUP_BY_ASYNC_INTERRUPT;
       #endif
 
 
@@ -2689,12 +2630,12 @@
        l1s.pw_mgr.sleep_duration  = READ_ULDP_TIMER_INIT;
        // INTH is different from the ULPD interrupt -> aynchronous wakeup
      #if (CHIPSET == 12) || (CHIPSET == 15)
-       if (l1s.pw_mgr.wake_up_int_id != C_INTH_TGSM_IT)
+       if (int_id != C_INTH_TGSM_IT)
      #else
-       if (l1s.pw_mgr.wake_up_int_id != IQ_TGSM)
+       if (int_id != IQ_TGSM)
      #endif
-            {
-         l1s.pw_mgr.wakeup_type = WAKEUP_ASYNCHRONOUS_ULPD_0;
+       {
+         wakeup_type = WAKEUP_ASYNCHRONOUS_ULPD_0;
          // RESET IT_ULPD in ULPD module
         // The ULDP_GSM_TIMER_IT_REG is a read only register and is cleared on reading the register
         temp_clear_intr =(* (volatile UWORD16 *) ULDP_GSM_TIMER_IT_REG) & ULPD_IT_TIMER_GSM;
@@ -2703,13 +2644,13 @@
            F_INTH_RESET_ONE_IT(C_INTH_TGSM_IT);
            // RESET IQ_FRAME in IT register
            F_INTH_RESET_ONE_IT(C_INTH_FRAME_IT);
-           l1s.pw_mgr.wake_up_int_id = C_INTH_TGSM_IT;
+           int_id = C_INTH_TGSM_IT;
          #else
            // RESET IQ_TGSM (IT_ULPD) in IT register
            INTH_RESETONEIT(IQ_TGSM);
            // RESET IQ_FRAME in IT register
            INTH_RESETONEIT(IQ_FRAME);
-           l1s.pw_mgr.wake_up_int_id = IQ_TGSM;
+           int_id = IQ_TGSM;
          #endif
          return(FALSE);
        }
@@ -2929,19 +2870,21 @@
 /*  return -1 means no activity planned                  */
 /*-------------------------------------------------------*/
 #if L1_GPRS
-  UWORD32 l1s_get_next_gauging_in_Packet_Idle(void)
+  UWORD32 next_gauging_scheduled_for_PNP; // gauging for Packet Idle
+
+  WORD32 l1s_get_next_gauging_in_Packet_Idle(void)
   {
     WORD32 next_gauging;
 
     // gauging performed with Normal Paging (we are in Idle mode)
     if (l1a_l1s_com.l1s_en_task[NP] == TASK_ENABLED)
-      return ((UWORD32)(-1)); // no activity planned   //omaps00090550
+      return (-1); // no activity planned
 
     // we are not in Packet Idle Mode
     if (l1a_l1s_com.l1s_en_task[PNP] != TASK_ENABLED)
-      return ((UWORD32)(-1)); // no activity planned   //omaps00090550
-
-    next_gauging = l1s.next_gauging_scheduled_for_PNP - l1s.actual_time.fn ;
+      return (-1); // no activity planned
+
+    next_gauging = next_gauging_scheduled_for_PNP - l1s.actual_time.fn ;
     if (next_gauging < 0)
       next_gauging+=MAX_FN;
 
@@ -2965,7 +2908,7 @@
   #define TWO_SECONDS_IN_FRAME (UWORD16)(2000/4.615)
   WORD32  time_to_next_gauging=0;  //changed to WORD32- sajal
     // It's time to perform the next gauging
-  time_to_next_gauging = l1s.next_gauging_scheduled_for_PNP - l1s.actual_time.fn;
+  time_to_next_gauging = next_gauging_scheduled_for_PNP - l1s.actual_time.fn;
   if (time_to_next_gauging < 0)
   {
     time_to_next_gauging += MAX_FN;
@@ -2974,8 +2917,8 @@
   if( (time_to_next_gauging == 0) || (time_to_next_gauging > TWO_SECONDS_IN_FRAME))
   {
 
-      l1s.next_gauging_scheduled_for_PNP = l1s.actual_time.fn + TWO_SECONDS_IN_FRAME;
-      if (l1s.next_gauging_scheduled_for_PNP >= MAX_FN) l1s.next_gauging_scheduled_for_PNP -= MAX_FN;
+      next_gauging_scheduled_for_PNP = l1s.actual_time.fn + TWO_SECONDS_IN_FRAME;
+      if (next_gauging_scheduled_for_PNP >= MAX_FN) next_gauging_scheduled_for_PNP -= MAX_FN;
       return (TRUE);
     }
 
@@ -3003,7 +2946,8 @@
     // A gauging session is needed : start gauging session with this paging bloc !
 
         //Nina modify to save power, not forbid deep sleep, only force gauging in next paging
-#if 0
+	// FreeCalypso TCS211 reconstruction: Nina's change reverted
+#if 1
 	if (l1s.pw_mgr.enough_gaug != TRUE)
     time_to_gaug = 0;
 #else