diff src/cs/drivers/drv_core/armio/armio.c @ 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
line wrap: on
line diff
--- 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
  *