SoFIA 3GR: Add SoFIA 3GR platform with i2c support
[contrib/mraa.git] / src / x86 / x86.c
old mode 100644 (file)
new mode 100755 (executable)
index 7c524c1..83a31b8
 #include <string.h>
 
 #include "mraa_internal.h"
+
 #include "x86/intel_galileo_rev_d.h"
 #include "x86/intel_galileo_rev_g.h"
 #include "x86/intel_edison_fab_c.h"
 #include "x86/intel_de3815.h"
-#include "x86/intel_minnow_max.h"
 #include "x86/intel_nuc5.h"
+#include "x86/intel_minnow_byt_compatible.h"
 
 mraa_platform_t
 mraa_x86_platform()
 {
+#ifndef MRAA_PLATFORM_FORCE
     mraa_platform_t platform_type = MRAA_UNKNOWN_PLATFORM;
+
     char* line = NULL;
     // let getline allocate memory for *line
     size_t len = 0;
@@ -60,21 +63,55 @@ mraa_x86_platform()
                 plat = mraa_intel_nuc5();
             } else if (strncmp(line, "NOTEBOOK", 8) == 0) {
                 platform_type = MRAA_INTEL_MINNOWBOARD_MAX;
-                plat = mraa_intel_minnow_max();
+                plat = mraa_intel_minnowboard_byt_compatible();
             } else if (strncasecmp(line, "MinnowBoard MAX", 15) == 0) {
                 platform_type = MRAA_INTEL_MINNOWBOARD_MAX;
-                plat = mraa_intel_minnow_max();
+                plat = mraa_intel_minnowboard_byt_compatible();
             } else if (strncasecmp(line, "Galileo", 7) == 0) {
                 platform_type = MRAA_INTEL_GALILEO_GEN1;
                 plat = mraa_intel_galileo_rev_d();
-            } else {
+            } else if (strncasecmp(line, "MinnowBoard Compatible", 22) == 0) {
+               platform_type = MRAA_INTEL_MINNOWBOARD_MAX;
+               plat = mraa_intel_minnowboard_byt_compatible();
+           } else {
                 syslog(LOG_ERR, "Platform not supported, not initialising");
                 platform_type = MRAA_UNKNOWN_PLATFORM;
             }
             free(line);
         }
         fclose(fh);
+    } else {
+        fh = fopen("/proc/cmdline", "r");
+        if (fh != NULL) {
+            if (getline(&line, &len, fh) != -1) {
+                if (strstr(line, "sf3gr_mrd_version=P2.0")) {
+                    platform_type = MRAA_INTEL_SOFIA_3GR;
+                    plat = mraa_intel_sofia_3gr();
+                }
+                free(line);
+            }
+            fclose(fh);
+        }
     }
-
     return platform_type;
+#else
+    #if defined(xMRAA_INTEL_GALILEO_GEN2)
+    plat = mraa_intel_galileo_gen2();
+    #elif defined(xMRAA_INTEL_EDISON_FAB_C)
+    plat = mraa_intel_edison_fab_c();
+    #elif defined(xMRAA_INTEL_DE3815)
+    plat = mraa_intel_de3815();
+    #elif defined(xMRAA_INTEL_MINNOWBOARD_MAX)
+    plat = mraa_intel_minnowboard_byt_compatible();
+    #elif defined(xMRAA_INTEL_GALILEO_GEN1)
+    plat = mraa_intel_galileo_rev_d();
+    #elif defined(xMRAA_INTEL_NUC5)
+    plat = mraa_intel_nuc5();
+    #elif defined(xMRAA_INTEL_SOFIA_3GR)
+    plat = mraa_intel_sofia_3gr();
+    #else
+        #error "Not using a valid platform value from mraa_platform_t - cannot compile"
+    #endif
+    return MRAA_PLATFORM_FORCE;
+#endif
 }