changeset 887:7f305eb3c530

gsm-fw: tpudrv12.[ch] extended to support Pirelli DP-L10 target Pirelli ramImage compiles, not tested on hw yet compiled code unchanged in the gtamodem configuration (verified)
author Space Falcon <falcon@ivan.Harhan.ORG>
date Sun, 28 Jun 2015 08:15:10 +0000
parents 346a15ea8222
children 0590cfd5803f
files gsm-fw/L1/tpudrv/tpudrv12.c gsm-fw/L1/tpudrv/tpudrv12.h gsm-fw/cfgmagic/processconf.sh
diffstat 3 files changed, 140 insertions(+), 129 deletions(-) [+]
line wrap: on
line diff
--- a/gsm-fw/L1/tpudrv/tpudrv12.c	Sun Jun 28 04:37:13 2015 +0000
+++ b/gsm-fw/L1/tpudrv/tpudrv12.c	Sun Jun 28 08:15:10 2015 +0000
@@ -14,6 +14,9 @@
  * The present reconstruction has been made by copying tpudrv61.c and
  * tweaking it to match the disassembly of the reference binary object
  * named above.
+ *
+ * The ugly hacks to support Pirelli DP-L10 in addition to classic
+ * TI/Openmoko target devices are original to FreeCalypso.
  */
 
 #define TPUDRV12_C
@@ -104,8 +107,8 @@
 	{\
 	*TP_Ptr++ = TPU_MOVE(TSP_TX_REG_1, ((rf_data) >> 8) & 0xFF);	\
 	*TP_Ptr++ = TPU_MOVE(TSP_TX_REG_2, (rf_data) & 0xFF);		\
-	*TP_Ptr++ = TPU_MOVE(TSP_CTRL1, 0x4F);				\
-	*TP_Ptr++ = TPU_MOVE(TSP_CTRL2, 0x02);				\
+	*TP_Ptr++ = TPU_MOVE(TSP_CTRL1, TC1_DEVICE_RF | 0x0F);		\
+	*TP_Ptr++ = TPU_MOVE(TSP_CTRL2, TC2_WR);			\
 	}
 
 /*------------------------------------------*/
@@ -114,8 +117,8 @@
 #define TSP_TO_ABB(data)\
 	{\
 	*TP_Ptr++ = TPU_MOVE(TSP_TX_REG_1, (data) & 0xFF);		\
-	*TP_Ptr++ = TPU_MOVE(TSP_CTRL1, 0x06);				\
-	*TP_Ptr++ = TPU_MOVE(TSP_CTRL2, 0x02);				\
+	*TP_Ptr++ = TPU_MOVE(TSP_CTRL1, TC1_DEVICE_ABB | 0x06);		\
+	*TP_Ptr++ = TPU_MOVE(TSP_CTRL2, TC2_WR);			\
 	}
 
 /*------------------------------------------*/
@@ -166,11 +169,17 @@
     T_TX_RX tx_rx[2];
 };
 
+#if CONFIG_TARGET_PIRELLI
+typedef UWORD16 T_RXTX_UPDOWN;
+#else
+typedef UWORD8  T_RXTX_UPDOWN;
+#endif
+
 struct rf_path_s {
-  UWORD8 rx_up;
-  UWORD8 rx_down;
-  UWORD8 tx_up;
-  UWORD8 tx_down;
+  T_RXTX_UPDOWN rx_up;
+  T_RXTX_UPDOWN rx_down;
+  T_RXTX_UPDOWN tx_up;
+  T_RXTX_UPDOWN tx_down;
   struct synth_s *synth;
 };
 
@@ -331,10 +340,10 @@
 	*TP_Ptr++ = TPU_MOVE(TSP_CTRL1, 0x47);
 	t += 5;
 	*TP_Ptr++ = TPU_AT(t);
-	*TP_Ptr++ = TPU_MOVE(TSP_ACT, 0x00);
+	*TP_Ptr++ = TPU_MOVE(TSP_ACT, RF_SER_OFF);
 	t += 8;
 	*TP_Ptr++ = TPU_AT(t);
-	*TP_Ptr++ = TPU_MOVE(TSP_ACT, 0x01);
+	*TP_Ptr++ = TPU_MOVE(TSP_ACT, RF_SER_ON);
 	t += 5;
 	*TP_Ptr++ = TPU_AT(t);
 	TSP_TO_RF(0x0012);
@@ -515,7 +524,7 @@
 	*TP_Ptr++ = TPU_FAT(0x1383);
 	TSP_TO_ABB(0x18);
 	*TP_Ptr++ = TPU_FAT(58);
-	*TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].rx_up | 0x01);
+	*TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].rx_up | RF_SER_ON);
 	*TP_Ptr++ = TPU_FAT(62);
 	TSP_TO_ABB(0x14);
 }
@@ -532,7 +541,7 @@
 {
 	*TP_Ptr++ = TPU_FAT(t - 37);
 	TSP_TO_RF(0x003A);
-	*TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].rx_down | 0x01);
+	*TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].rx_down | RF_SER_ON);
 	*TP_Ptr++ = TPU_FAT(t - 4);
 	TSP_TO_ABB(0x00);
 }
@@ -571,9 +580,15 @@
 	*TP_Ptr++ = TPU_FAT(0x1384);
 	TSP_TO_ABB(0xA0);
 	*TP_Ptr++ = TPU_FAT(16);
-	*TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].tx_up | 0x01);
+#if CONFIG_TARGET_PIRELLI
+	*TP_Ptr++ = TPU_MOVE(TSP_ACTX, rf_path[rf_index].tx_up >> 8);
+	*TP_Ptr++ = TPU_FAT(21);
+	*TP_Ptr++ = TPU_MOVE(TSP_ACT, PA_ENABLE | RF_SER_ON);
+#else
+	*TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].tx_up | RF_SER_ON);
 	*TP_Ptr++ = TPU_FAT(21);
 	*TP_Ptr++ = TPU_MOVE(TSP_ACTX, 0x0F);
+#endif
 }
 
 /*-------------------------------------------*/
@@ -592,7 +607,7 @@
 	TSP_TO_ABB(0x80);
 	*TP_Ptr++ = TPU_FAT(t + 22);
 	*TP_Ptr++ = TPU_MOVE(TSP_ACTX, 0x00);
-	*TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].tx_down | 0x01);
+	*TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].tx_down | RF_SER_ON);
 	*TP_Ptr++ = TPU_FAT(t + 25);
 	TSP_TO_RF(0x003A);
 	*TP_Ptr++ = TPU_FAT(t + 31);
@@ -739,8 +754,8 @@
    TPU_Reset(0);
    TP_Ptr = (UWORD16 *) TPU_RAM;
 
-   *TP_Ptr++ = TPU_MOVE(TSP_ACT, 0x01);
-   *TP_Ptr++ = TPU_MOVE(TSP_ACT, 0x17);
+   *TP_Ptr++ = TPU_MOVE(TSP_ACT, RF_SER_ON);
+   *TP_Ptr++ = TPU_MOVE(TSP_ACT, RF_SER_ON | FEM_OFF);
 
    *TP_Ptr++ = TPU_OFFSET(servingCellOffset);
 }
@@ -753,12 +768,12 @@
 void l1dmacro_RF_sleep  (void)
 {
 	TSP_TO_RF(0x0002);
-	*TP_Ptr++ = TPU_MOVE(TSP_ACT, 0x01);
+	*TP_Ptr++ = TPU_MOVE(TSP_ACT, RF_SER_ON);
 	*TP_Ptr++ = TPU_WAIT(1);
 	*TP_Ptr++ = TPU_MOVE(TSP_SPI_SET1, 0x21);
 	*TP_Ptr++ = TPU_MOVE(TSP_SPI_SET2, 0x02);
-	*TP_Ptr++ = TPU_MOVE(TSP_CTRL1, 0x41);
-	*TP_Ptr++ = TPU_MOVE(TSP_CTRL2, 0x02);
+	*TP_Ptr++ = TPU_MOVE(TSP_CTRL1, TC1_DEVICE_RF | 0x01);
+	*TP_Ptr++ = TPU_MOVE(TSP_CTRL2, TC2_WR);
 	*TP_Ptr++ = TPU_WAIT(100);
 	/* code from tpudrv61.c follows, same for Rita and LoCosto */
 	*TP_Ptr++ = TPU_SLEEP;
@@ -783,14 +798,14 @@
 	TP_Ptr = (SYS_UWORD16 *) TPU_RAM;
 	*TP_Ptr++ = TPU_MOVE(TSP_SPI_SET1, 0x01);
 	*TP_Ptr++ = TPU_MOVE(TSP_SPI_SET2, 0x06);
-	*TP_Ptr++ = TPU_MOVE(TSP_CTRL1, 0x41);
-	*TP_Ptr++ = TPU_MOVE(TSP_CTRL2, 0x02);
+	*TP_Ptr++ = TPU_MOVE(TSP_CTRL1, TC1_DEVICE_RF | 0x01);
+	*TP_Ptr++ = TPU_MOVE(TSP_CTRL2, TC2_WR);
 	*TP_Ptr++ = TPU_WAIT(100);
-	*TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].rx_down | 0x01);
+	*TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].rx_down | RF_SER_ON);
 	*TP_Ptr++ = TPU_WAIT(1);
-	*TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].rx_down);
+	*TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].rx_down | RF_SER_OFF);
 	*TP_Ptr++ = TPU_WAIT(8);
-	*TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].rx_down | 0x01);
+	*TP_Ptr++ = TPU_MOVE(TSP_ACT, rf_path[rf_index].rx_down | RF_SER_ON);
 	*TP_Ptr++ = TPU_WAIT(5);
 	TSP_TO_RF(0x0012);
 	*TP_Ptr++ = TPU_FAT(0);
@@ -841,7 +856,7 @@
    // Set FEM to inactive state before turning ON the RF Board
    // At this point the RF regulators are still OFF. Thus the
    // FEM command is not inverted yet => Must use the FEM "SLEEP programming"
-   *TP_Ptr++ = TPU_MOVE(TSP_ACT, 0x01);
+   *TP_Ptr++ = TPU_MOVE(TSP_ACT, FEM_SLEEP | RF_SER_ON);
 
    // TPU_SLEEP
    l1dmacro_idle();
--- a/gsm-fw/L1/tpudrv/tpudrv12.h	Sun Jun 28 04:37:13 2015 +0000
+++ b/gsm-fw/L1/tpudrv/tpudrv12.h	Sun Jun 28 08:15:10 2015 +0000
@@ -222,128 +222,130 @@
 
 
 // RF signals connected to TSPACT  [0..7]
-//#define RESET_RF      BIT_0  // act0
-#define RF_SER_ON     BIT_0    // act0 
+
+#if CONFIG_TARGET_PIRELLI
+#define	RF_RESET_LINE	BIT_5
+#else
+#define	RF_RESET_LINE	BIT_0
+#endif
+
+#define RF_SER_ON     RF_RESET_LINE
 #define RF_SER_OFF    0      
 
+#define TEST_TX_ON    0
+#define TEST_RX_ON    0
 
-#if (FEM_TEST==1)
-  //for test 
-  #define TEST_TX_ON    BIT_2 // act2
-  #define TEST_RX_ON    BIT_3 // act3
+#if CONFIG_TARGET_GTAMODEM || CONFIG_TARGET_LEONARDO
 
-  //3-band config (D-sample)
-  #define FEM_1     BIT_1     // act1
-  #define FEM_2     0         //BIT_2  // act2
-  #define FEM_3     0         //BIT_3  // act3
-#elif (BOARD == 42 || BOARD == 43 || BOARD == 35 || (BOARD == 41 && (RF_PA == 0 || RF_PA == 1 || RF_PA == 2 || RF_PA == 4))) // ESample, P2, Leonardo 
-    #define TEST_TX_ON    0
-    #define TEST_RX_ON    0
-      // 4-band config (E-sample, P2, Leonardo)
-    #define FEM_7         BIT_2     // act2
-    #define FEM_8         BIT_1     // act1
-    #define FEM_9         BIT_4     // act4
+  // 4-band config (E-sample, P2, Leonardo)
+  #define FEM_7         BIT_2     // act2
+  #define FEM_8         BIT_1     // act1
+  #define FEM_9         BIT_4     // act4
 
-      #if (RF_PA == 0)     // LCPA for ES, P2 and Leo
-          #define PA_HI_BAND    BIT_3     // act3
-          #define PA_LO_BAND    0
-          #define PA_OFF        0
-  #elif (RF_PA == 1) // RF3146 for ES and Leonardo
-    #define PA_HI_BAND    BIT_3   // act3
-    #define PA_LO_BAND    0
-    #define PA_OFF        0
-  #elif (RF_PA == 2) // RF3133 for P2 and Leonardo
-    #define PA_HI_BAND    BIT_3   // act3
-          #define PA_LO_BAND    0
-          #define PA_OFF        0
-  #elif (RF_PA == 4) // AWT6108 for Leonardo
-    #define PA_HI_BAND    BIT_3   // act3
-          #define PA_LO_BAND    0
-          #define PA_OFF        0
-  #else
-    #error "RF_PA not correctly defined"
-  #endif
+  #define PA_HI_BAND    BIT_3   // act3
+  #define PA_LO_BAND    0
+  #define PA_OFF        0
 
-#else // DSample + EVARITA
-    #if (RF_PA != 3) // Hitachi for EVARITA
-      #error
-      #endif
-
-    //#define TEST_RX_ON    0
-    //#define TEST_TX_ON    BIT_3   // act3
-    #define TEST_TX_ON    0
-    #define TEST_RX_ON    BIT_3     // act3
+  #define FEM_PINS (FEM_7 | FEM_8 | FEM_9)
 
-    //3-band config (D-sample)
-    #define FEM_1         BIT_1     // act1
-    #define FEM_2         BIT_2     // act2
-    #define FEM_3         BIT_3     // act3
-#endif
+  #define FEM_OFF    ( FEM_PINS ^ 0 )
 
-#if (BOARD == 42 || BOARD == 43 || BOARD == 35 || (BOARD == 41 && (RF_PA == 0 || RF_PA == 1 || RF_PA == 2 || RF_PA == 4))) // ESample, P2, Leonardo 
-
-    #define FEM_PINS (FEM_7 | FEM_8 | FEM_9)
-
-    #define FEM_OFF    ( FEM_PINS ^ 0 )
-
-    #define FEM_SLEEP  ( 0 )  
+  #define FEM_SLEEP  ( 0 )  
 
   // This configuration is always inverted.
 
-    // 4-band config
-    // RX_UP/DOWN and TX_UP/DOWN
-  #define RU_900     ( PA_OFF     | FEM_PINS ^ 0     )
-  #define RD_900     ( PA_OFF     | FEM_PINS ^ 0     )
-  #define TU_900     ( PA_LO_BAND | FEM_PINS ^ FEM_9 )
-  #define TD_900     ( PA_OFF     | FEM_PINS ^ 0     )
+  // RX_UP/DOWN and TX_UP/DOWN
+  #if CONFIG_TARGET_GTAMODEM
+    // Openmoko's hobbled triband hardware
+    #define RU_900     ( PA_OFF     | FEM_PINS ^ 0     )
+    #define RD_900     ( PA_OFF     | FEM_PINS ^ 0     )
+    #define TU_900     ( PA_LO_BAND | FEM_PINS ^ FEM_9 )
+    #define TD_900     ( PA_OFF     | FEM_PINS ^ 0     )
 
-  #define RU_850     ( PA_LO_BAND | FEM_PINS ^ 0  )
-  #define RD_850     ( PA_OFF     | FEM_PINS ^ 0     )
-  #define TU_850     ( PA_LO_BAND | FEM_PINS ^ FEM_9 )
-  #define TD_850     ( PA_OFF     | FEM_PINS ^ 0     )
+    #define RU_850     ( PA_OFF     | FEM_PINS ^ 0     )
+    #define RD_850     ( PA_OFF     | FEM_PINS ^ 0     )
+    #define TU_850     ( PA_LO_BAND | FEM_PINS ^ FEM_9 )
+    #define TD_850     ( PA_OFF     | FEM_PINS ^ 0     )
+
+    #define RU_1800    ( PA_OFF     | FEM_PINS ^ 0     )
+    #define RD_1800    ( PA_OFF     | FEM_PINS ^ 0     )
+    #define TU_1800    ( PA_HI_BAND | FEM_PINS ^ FEM_7 )
+    #define TD_1800    ( PA_OFF     | FEM_PINS ^ 0     )
 
-  #define RU_1800    ( PA_OFF     | FEM_PINS ^ 0     )
-  #define RD_1800    ( PA_OFF     | FEM_PINS ^ 0     )
-  #define TU_1800    ( PA_HI_BAND | FEM_PINS ^ FEM_7 )
-  #define TD_1800    ( PA_OFF     | FEM_PINS ^ 0     )
+    #define RU_1900    ( PA_OFF     | FEM_PINS ^ FEM_8 )
+    #define RD_1900    ( PA_OFF     | FEM_PINS ^ 0     )
+    #define TU_1900    ( PA_HI_BAND | FEM_PINS ^ FEM_7 )
+    #define TD_1900    ( PA_OFF     | FEM_PINS ^ 0     )
+  #else
+    // original quadband arrangement
+    #define RU_900     ( PA_OFF     | FEM_PINS ^ 0     )
+    #define RD_900     ( PA_OFF     | FEM_PINS ^ 0     )
+    #define TU_900     ( PA_LO_BAND | FEM_PINS ^ FEM_7 )
+    #define TD_900     ( PA_OFF     | FEM_PINS ^ 0     )
 
-  #define RU_1900    ( PA_LO_BAND | FEM_PINS ^ FEM_8     )
-  #define RD_1900    ( PA_OFF     | FEM_PINS ^ 0     )
-  #define TU_1900    ( PA_HI_BAND | FEM_PINS ^ FEM_7 )
-  #define TD_1900    ( PA_OFF     | FEM_PINS ^ 0     )
+    #define RU_850     ( PA_OFF     | FEM_PINS ^ FEM_9 )
+    #define RD_850     ( PA_OFF     | FEM_PINS ^ 0     )
+    #define TU_850     ( PA_LO_BAND | FEM_PINS ^ FEM_7 )
+    #define TD_850     ( PA_OFF     | FEM_PINS ^ 0     )
 
-#else  // end BOARD = 43
-       // start RF HW interfacing with EVARITA
+    #define RU_1800    ( PA_OFF     | FEM_PINS ^ 0     )
+    #define RD_1800    ( PA_OFF     | FEM_PINS ^ 0     )
+    #define TU_1800    ( PA_HI_BAND | FEM_PINS ^ FEM_8 )
+    #define TD_1800    ( PA_OFF     | FEM_PINS ^ 0     )
 
-  #define FEM_OFF    (FEM_1 | FEM_2)
-  #define FEM_SLEEP  (0)             // To avoid leakage during Deep-Seep
+    #define RU_1900    ( PA_OFF     | FEM_PINS ^ 0     )
+    #define RD_1900    ( PA_OFF     | FEM_PINS ^ 0     )
+    #define TU_1900    ( PA_HI_BAND | FEM_PINS ^ FEM_8 )
+    #define TD_1900    ( PA_OFF     | FEM_PINS ^ 0     )
+  #endif
+
+#elif CONFIG_TARGET_PIRELLI
 
-  // 3-band config
-  // RX_UP/DOWN and TX_UP/DOWN
-  #define RU_900     ( FEM_1 | FEM_2 )
-  #define RD_900     ( FEM_1 | FEM_2 )
-  #define TU_900     ( FEM_1         )
-  #define TD_900     ( FEM_1 | FEM_2 )
+  #define ANTSW_RX_PCS	BIT_4
+  #define ANTSW_TX_HIGH	BIT_10
+  #define ANTSW_TX_LOW	BIT_11
+
+  #define PA_HI_BAND    BIT_3   // act3
+  #define PA_LO_BAND    0
+  #define PA_OFF        0
+
+  #define PA_ENABLE	BIT_0
+
+  // Pirelli uses a non-inverting buffer
+
+  #define FEM_OFF    ( 0 )
 
-  #define RU_850     ( FEM_1 | FEM_2 )
-  #define RD_850     ( FEM_1 | FEM_2 )
-  #define TU_850     ( FEM_1         )
-  #define TD_850     ( FEM_1 | FEM_2 )
+  #define FEM_SLEEP  ( 0 )  
+
+  // RX_UP/DOWN and TX_UP/DOWN (triband)
+  #define RU_900     ( PA_OFF     | 0             )
+  #define RD_900     ( PA_OFF     | 0             )
+  #define TU_900     ( PA_LO_BAND | ANTSW_TX_LOW  )
+  #define TD_900     ( PA_OFF     | 0             )
 
-  #define RU_1800    ( FEM_1 | FEM_2 )
-  #define RD_1800    ( FEM_1 | FEM_2 )
-  #define TU_1800    (         FEM_2 )
-  #define TD_1800    ( FEM_1 | FEM_2 )
+  #define RU_850     ( PA_OFF     | 0             )
+  #define RD_850     ( PA_OFF     | 0             )
+  #define TU_850     ( PA_LO_BAND | ANTSW_TX_LOW  )
+  #define TD_850     ( PA_OFF     | 0             )
 
-  #define RU_1900    ( FEM_1 | FEM_2 )
-  #define RD_1900    ( FEM_1 | FEM_2 )
-  #define TU_1900    ( FEM_2)
-  #define TD_1900    ( FEM_1 | FEM_2 )
+  #define RU_1800    ( PA_OFF     | 0             )
+  #define RD_1800    ( PA_OFF     | 0             )
+  #define TU_1800    ( PA_HI_BAND | ANTSW_TX_HIGH )
+  #define TD_1800    ( PA_OFF     | 0             )
 
-#endif  // BOARD != 43
+  #define RU_1900    ( PA_OFF     | ANTSW_RX_PCS  )
+  #define RD_1900    ( PA_OFF     | 0             )
+  #define TU_1900    ( PA_HI_BAND | ANTSW_TX_HIGH )
+  #define TD_1900    ( PA_OFF     | 0             )
+
+#endif  // FreeCalypso target selection
 
 #define TC1_DEVICE_ABB     TC1_DEVICE0  // TSPEN0
+#if CONFIG_TARGET_PIRELLI
+#define TC1_DEVICE_RF      TC1_DEVICE1  // TSPEN1
+#else
 #define TC1_DEVICE_RF      TC1_DEVICE2  // TSPEN2
+#endif
 
 
 //--- TIMINGS ----------------------------------------------------------
--- a/gsm-fw/cfgmagic/processconf.sh	Sun Jun 28 04:37:13 2015 +0000
+++ b/gsm-fw/cfgmagic/processconf.sh	Sun Jun 28 08:15:10 2015 +0000
@@ -95,12 +95,6 @@
 		1>&2
 	exit 1
 fi
-if [ "$CONFIG_INCLUDE_L1" = 1 -a "$TARGET" != gtamodem ]
-then
-	echo "Error: tpudrv has not been extended to target != gtamodem yet" \
-		1>&2
-	exit 1
-fi
 
 # The list of build components: we have some invariants that are always
 # included, and some others that are included depending on the configuration.