2 * Author: Thomas Ingleby <thomas.c.ingleby@intel.com>
3 * Copyright (c) 2014 Intel Corporation.
5 * Permission is hereby granted, free of charge, to any person obtaining
6 * a copy of this software and associated documentation files (the
7 * "Software"), to deal in the Software without restriction, including
8 * without limitation the rights to use, copy, modify, merge, publish,
9 * distribute, sublicense, and/or sell copies of the Software, and to
10 * permit persons to whom the Software is furnished to do so, subject to
11 * the following conditions:
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
28 #include "mraa_internal.h"
30 #include "x86/intel_galileo_rev_d.h"
31 #include "x86/intel_galileo_rev_g.h"
32 #include "x86/intel_edison_fab_c.h"
33 #include "x86/intel_de3815.h"
34 #include "x86/intel_nuc5.h"
35 #include "x86/intel_minnow_byt_compatible.h"
36 #include "x86/intel_sofia_3gr.h"
41 #ifndef MRAA_PLATFORM_FORCE
42 mraa_platform_t platform_type = MRAA_UNKNOWN_PLATFORM;
45 // let getline allocate memory for *line
47 FILE* fh = fopen("/sys/devices/virtual/dmi/id/board_name", "r");
49 if (getline(&line, &len, fh) != -1) {
50 if (strncmp(line, "GalileoGen2", 11) == 0) {
51 platform_type = MRAA_INTEL_GALILEO_GEN2;
52 plat = mraa_intel_galileo_gen2();
53 } else if (strncmp(line, "BODEGA BAY", 10) == 0) {
54 platform_type = MRAA_INTEL_EDISON_FAB_C;
55 plat = mraa_intel_edison_fab_c();
56 } else if (strncmp(line, "SALT BAY", 8) == 0) {
57 platform_type = MRAA_INTEL_EDISON_FAB_C;
58 plat = mraa_intel_edison_fab_c();
59 } else if (strncmp(line, "DE3815", 6) == 0) {
60 platform_type = MRAA_INTEL_DE3815;
61 plat = mraa_intel_de3815();
62 } else if (strncmp(line, "NUC5i5MYBE", 10) == 0 || strncmp(line, "NUC5i3MYBE", 10) == 0) {
63 platform_type = MRAA_INTEL_NUC5;
64 plat = mraa_intel_nuc5();
65 } else if (strncmp(line, "NOTEBOOK", 8) == 0) {
66 platform_type = MRAA_INTEL_MINNOWBOARD_MAX;
67 plat = mraa_intel_minnowboard_byt_compatible();
68 } else if (strncasecmp(line, "MinnowBoard MAX", 15) == 0) {
69 platform_type = MRAA_INTEL_MINNOWBOARD_MAX;
70 plat = mraa_intel_minnowboard_byt_compatible();
71 } else if (strncasecmp(line, "Galileo", 7) == 0) {
72 platform_type = MRAA_INTEL_GALILEO_GEN1;
73 plat = mraa_intel_galileo_rev_d();
74 } else if (strncasecmp(line, "MinnowBoard Compatible", 22) == 0) {
75 platform_type = MRAA_INTEL_MINNOWBOARD_MAX;
76 plat = mraa_intel_minnowboard_byt_compatible();
78 syslog(LOG_ERR, "Platform not supported, not initialising");
79 platform_type = MRAA_UNKNOWN_PLATFORM;
85 fh = fopen("/proc/cmdline", "r");
87 if (getline(&line, &len, fh) != -1) {
88 if (strstr(line, "sf3gr_mrd_version=P2.0")) {
89 platform_type = MRAA_INTEL_SOFIA_3GR;
90 plat = mraa_intel_sofia_3gr();
99 #if defined(xMRAA_INTEL_GALILEO_GEN2)
100 plat = mraa_intel_galileo_gen2();
101 #elif defined(xMRAA_INTEL_EDISON_FAB_C)
102 plat = mraa_intel_edison_fab_c();
103 #elif defined(xMRAA_INTEL_DE3815)
104 plat = mraa_intel_de3815();
105 #elif defined(xMRAA_INTEL_MINNOWBOARD_MAX)
106 plat = mraa_intel_minnowboard_byt_compatible();
107 #elif defined(xMRAA_INTEL_GALILEO_GEN1)
108 plat = mraa_intel_galileo_rev_d();
109 #elif defined(xMRAA_INTEL_NUC5)
110 plat = mraa_intel_nuc5();
111 #elif defined(xMRAA_INTEL_SOFIA_3GR)
112 plat = mraa_intel_sofia_3gr();
114 #error "Not using a valid platform value from mraa_platform_t - cannot compile"
116 return MRAA_PLATFORM_FORCE;