changeset 681:140a0d24a64c

Tango pinmux implemented except for GPIO1 special outputs, which will be implemented later.
author Mychaela Falconia <falcon@freecalypso.org>
date Thu, 25 Jun 2020 05:36:24 +0000
parents ee3ac8c617cb
children 17b7b92e7dba
files src/cs/drivers/drv_app/uart/uartfax.c src/cs/drivers/drv_core/armio/armio.c src/cs/system/main/init.c targets/tangomdm.h
diffstat 4 files changed, 138 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/src/cs/drivers/drv_app/uart/uartfax.c	Thu Jun 25 03:17:43 2020 +0000
+++ b/src/cs/drivers/drv_app/uart/uartfax.c	Thu Jun 25 05:36:24 2020 +0000
@@ -118,6 +118,10 @@
   #include "armio/armio.h"
 #endif
 
+#ifdef CONFIG_TANGO_MODEM
+extern SYS_UWORD8 AI_Tango_pinmux[4];
+#endif
+
 /* 
  * Maximal value for an unsigned 32 bits.
  */
@@ -3021,9 +3025,15 @@
      * DCD should start HIGH (not asserted).
      */
 
+#ifdef CONFIG_TANGO_MODEM
+  if (AI_Tango_pinmux[1] & 0x08) {
+#endif
     *((volatile SYS_UWORD16 *) EXTENDED_MCU_REG) &= ~(1 << IO_DCD);
     AI_ConfigBitAsOutput (ARMIO_DCD);
     AI_SetBit (ARMIO_DCD);
+#ifdef CONFIG_TANGO_MODEM
+  }
+#endif
 
     /*
      * Select I/O for DTR and configure it as input.
@@ -3031,6 +3041,9 @@
      * or rising edge is selected according to the state of DTR.
      */
     
+#ifdef CONFIG_TANGO_MODEM
+  if (AI_Tango_pinmux[1] & 0x80) {
+#endif
     *((volatile SYS_UWORD16 *) ASIC_CONFIG_REG) &= ~(1 << IO_DTR);
     AI_ConfigBitAsInput (ARMIO_DTR);
     uart->dtr_level = AI_ReadBit (ARMIO_DTR);
@@ -3041,6 +3054,10 @@
         AI_SelectIOForIT (ARMIO_DTR, ARMIO_RISING_EDGE);
         
     AI_UnmaskIT (ARMIO_MASKIT_GPIO);
+#ifdef CONFIG_TANGO_MODEM
+  } else
+    uart->dtr_level = 0;
+#endif
 
     /*
      * Reset the 2 indexes of the circular buffer of 2 elements.
@@ -3223,7 +3240,10 @@
 
     WRITE_UART_REGISTER (uart, IER, 0x00);
 
-#if UARTFAX_CLASSIC_DTR_DCD
+#ifdef CONFIG_TANGO_MODEM
+    if (AI_Tango_pinmux[1] & 0x80)
+      AI_MaskIT (ARMIO_MASKIT_GPIO);
+#elif UARTFAX_CLASSIC_DTR_DCD
     AI_MaskIT (ARMIO_MASKIT_GPIO);
 #elif (CHIPSET == 12)
     DISABLE_DSR_INTERRUPT (uart);
@@ -3369,6 +3389,9 @@
      * Read the state of DTR and select the edge.
      */
          
+#ifdef CONFIG_TANGO_MODEM
+  if (AI_Tango_pinmux[1] & 0x80) {
+#endif
     uart->dtr_level = AI_ReadBit (ARMIO_DTR);
     
     if (uart->dtr_level)
@@ -3377,6 +3400,11 @@
         AI_SelectIOForIT (ARMIO_DTR, ARMIO_RISING_EDGE);
         
     AI_UnmaskIT (ARMIO_MASKIT_GPIO);
+#ifdef CONFIG_TANGO_MODEM
+  } else
+    uart->dtr_level = 0;
+#endif
+
 #elif (CHIPSET == 12)
     /*
      * Read the state of DTR - No need to reload MSR register since its value
@@ -4755,6 +4783,9 @@
             /* Turn on DCD */
             #if (CHIPSET == 12)
                 WRITE_UART_REGISTER (uart, MCR, READ_UART_REGISTER(uart, MCR) | MDCD);
+            #elif defined(CONFIG_TANGO_MODEM)
+                if (AI_Tango_pinmux[1] & 0x08)
+                    AI_ResetBit (ARMIO_DCD);
             #else
                 AI_ResetBit (ARMIO_DCD);
             #endif
@@ -4762,6 +4793,9 @@
             /* Turn off DCD */
             #if (CHIPSET == 12)
                 WRITE_UART_REGISTER (uart, MCR, READ_UART_REGISTER(uart, MCR) & ~MDCD);
+            #elif defined(CONFIG_TANGO_MODEM)
+                if (AI_Tango_pinmux[1] & 0x08)
+                    AI_SetBit (ARMIO_DCD);
             #else
                 AI_SetBit (ARMIO_DCD);
             #endif
@@ -4791,6 +4825,9 @@
             /* Turn on DCD */
             #if (CHIPSET == 12)
                 WRITE_UART_REGISTER (uart, MCR, READ_UART_REGISTER(uart, MCR) | MDCD);
+            #elif defined(CONFIG_TANGO_MODEM)
+                if (AI_Tango_pinmux[1] & 0x08)
+                    AI_ResetBit (ARMIO_DCD);
             #else
                 AI_ResetBit (ARMIO_DCD);
             #endif
@@ -4798,6 +4835,9 @@
             /* Turn off DCD */
             #if (CHIPSET == 12)
                 WRITE_UART_REGISTER (uart, MCR, READ_UART_REGISTER(uart, MCR) & ~MDCD);
+            #elif defined(CONFIG_TANGO_MODEM)
+                if (AI_Tango_pinmux[1] & 0x08)
+                    AI_SetBit (ARMIO_DCD);
             #else
                 AI_SetBit (ARMIO_DCD);
             #endif
--- a/src/cs/drivers/drv_core/armio/armio.c	Thu Jun 25 03:17:43 2020 +0000
+++ b/src/cs/drivers/drv_core/armio/armio.c	Thu Jun 25 05:36:24 2020 +0000
@@ -35,6 +35,12 @@
 #include "armio/armio.h"
 #include "abb/abb.h"	 // for AI_Power function : to be removed, use ABB_Power_Off in abb.c file instead !!!
 
+#ifdef CONFIG_TANGO_MODEM
+#include "ffs/ffs_api.h"
+
+SYS_UWORD8 AI_Tango_pinmux[4];
+#endif
+
 #if (CHIPSET != 12)
 /*
  * AI_EnableBit
@@ -280,12 +286,14 @@
     #if defined(CONFIG_GPIO046_OUTPUTS) || defined(CONFIG_TARGET_GTM900)
       AI_ConfigBitAsOutput(0);
     #endif
-    AI_ConfigBitAsOutput(1);
-    #ifndef CONFIG_TARGET_LEONARDO	/* GPIO 2 is an input on Leonardo! */
-      AI_ConfigBitAsOutput(2);
-    #endif
-    #ifdef CONFIG_GPIO3_OUTPUT
-      AI_ConfigBitAsOutput(3);
+    #ifndef CONFIG_TANGO_MODEM	/* we do dynamic config on Tango instead */
+      AI_ConfigBitAsOutput(1);
+      #ifndef CONFIG_TARGET_LEONARDO	/* GPIO 2 is an input on Leonardo! */
+        AI_ConfigBitAsOutput(2);
+      #endif
+      #ifdef CONFIG_GPIO3_OUTPUT
+        AI_ConfigBitAsOutput(3);
+      #endif
     #endif
     #ifdef CONFIG_GPIO046_OUTPUTS
       AI_ConfigBitAsOutput(4);
@@ -312,6 +320,83 @@
   #endif
 }
 
+#ifdef CONFIG_TANGO_MODEM
+void AI_Init_Tango_pinmux(void)
+{
+	ffs_file_read("/etc/tango-pinmux", AI_Tango_pinmux, 4);
+	/* apply this config */
+	if (AI_Tango_pinmux[0] & 0x80) {
+		if (AI_Tango_pinmux[0] & 1)
+			AI_SetBit(1);
+		else
+			AI_ResetBit(1);
+		AI_ConfigBitAsOutput(1);
+	}
+	/* GPIO2 config */
+	if (AI_Tango_pinmux[1] & 0x02) {
+		if (AI_Tango_pinmux[1] & 0x01)
+			AI_SetBit(2);
+		else
+			AI_ResetBit(2);
+		AI_ConfigBitAsOutput(2);
+	}
+	/* GPIO3 config */
+	if (AI_Tango_pinmux[1] & 0x20) {
+		if (AI_Tango_pinmux[1] & 0x10)
+			AI_SetBit(3);
+		else
+			AI_ResetBit(3);
+		AI_ConfigBitAsOutput(3);
+	}
+	/* RESET_OUT/IO7 config */
+	if (AI_Tango_pinmux[2] & 0x08) {
+		AI_EnableBit(3);
+		if (AI_Tango_pinmux[2] & 0x02) {
+			if (AI_Tango_pinmux[2] & 0x01)
+				AI_SetBit(7);
+			else
+				AI_ResetBit(7);
+		} else
+			AI_ConfigBitAsInput(7);
+	}
+	/* MCSI/GPIO config */
+	if (AI_Tango_pinmux[2] & 0x80) {
+		if (AI_Tango_pinmux[3] & 0x10) {
+			if (AI_Tango_pinmux[3] & 0x01)
+				AI_SetBit(9);
+			else
+				AI_ResetBit(9);
+		} else
+			AI_ConfigBitAsInput(9);
+		AI_EnableBit(5);
+		AI_EnableBit(6);
+		AI_EnableBit(7);
+		AI_EnableBit(8);
+		if (AI_Tango_pinmux[3] & 0x20) {
+			if (AI_Tango_pinmux[3] & 0x02)
+				AI_SetBit(10);
+			else
+				AI_ResetBit(10);
+			AI_ConfigBitAsOutput(10);
+		}
+		if (AI_Tango_pinmux[3] & 0x40) {
+			if (AI_Tango_pinmux[3] & 0x04)
+				AI_SetBit(11);
+			else
+				AI_ResetBit(11);
+			AI_ConfigBitAsOutput(11);
+		}
+		if (AI_Tango_pinmux[3] & 0x80) {
+			if (AI_Tango_pinmux[3] & 0x08)
+				AI_SetBit(12);
+			else
+				AI_ResetBit(12);
+			AI_ConfigBitAsOutput(12);
+		}
+	}
+}
+#endif
+
 /*
  * AI_SelectIOForIT
  *
--- a/src/cs/system/main/init.c	Thu Jun 25 03:17:43 2020 +0000
+++ b/src/cs/system/main/init.c	Thu Jun 25 05:36:24 2020 +0000
@@ -893,6 +893,10 @@
 	bspUicc_bootInit();
     #endif
   #endif
+
+  #ifdef CONFIG_TANGO_MODEM
+    AI_Init_Tango_pinmux();
+  #endif
 }
 
 /*
--- a/targets/tangomdm.h	Thu Jun 25 03:17:43 2020 +0000
+++ b/targets/tangomdm.h	Thu Jun 25 05:36:24 2020 +0000
@@ -1,7 +1,8 @@
 #define	CONFIG_TARGET_TANGO	1
 #define	CONFIG_GPIO046_OUTPUTS	1
+#define	CONFIG_TANGO_MODEM	1
 #define	CONFIG_MCSI_MODEM	1
 #define	CONFIG_GPIO1_HIGH	1
 #define	GPIO1_SPEAKER_CTRL	0
-#define	UARTFAX_CLASSIC_DTR_DCD	0
+#define	UARTFAX_CLASSIC_DTR_DCD	1
 #define	TARGET_HAS_PWL		1