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"
29 #include "x86/intel_galileo_rev_d.h"
30 #include "x86/intel_galileo_rev_g.h"
31 #include "x86/intel_edison_fab_c.h"
32 #include "x86/intel_de3815.h"
33 #include "x86/intel_nuc5.h"
34 #include "x86/intel_minnow_byt_compatible.h"
39 mraa_platform_t platform_type = MRAA_UNKNOWN_PLATFORM;
41 // let getline allocate memory for *line
43 FILE* fh = fopen("/sys/devices/virtual/dmi/id/board_name", "r");
45 if (getline(&line, &len, fh) != -1) {
46 if (strncmp(line, "GalileoGen2", 11) == 0) {
47 platform_type = MRAA_INTEL_GALILEO_GEN2;
48 plat = mraa_intel_galileo_gen2();
49 } else if (strncmp(line, "BODEGA BAY", 10) == 0) {
50 platform_type = MRAA_INTEL_EDISON_FAB_C;
51 plat = mraa_intel_edison_fab_c();
52 } else if (strncmp(line, "SALT BAY", 8) == 0) {
53 platform_type = MRAA_INTEL_EDISON_FAB_C;
54 plat = mraa_intel_edison_fab_c();
55 } else if (strncmp(line, "DE3815", 6) == 0) {
56 platform_type = MRAA_INTEL_DE3815;
57 plat = mraa_intel_de3815();
58 } else if (strncmp(line, "NUC5i5MYBE", 10) == 0 || strncmp(line, "NUC5i3MYBE", 10) == 0) {
59 platform_type = MRAA_INTEL_NUC5;
60 plat = mraa_intel_nuc5();
61 } else if (strncmp(line, "NOTEBOOK", 8) == 0) {
62 platform_type = MRAA_INTEL_MINNOWBOARD_MAX;
63 plat = mraa_intel_minnowboard_byt_compatible();
64 } else if (strncasecmp(line, "MinnowBoard MAX", 15) == 0) {
65 platform_type = MRAA_INTEL_MINNOWBOARD_MAX;
66 plat = mraa_intel_minnowboard_byt_compatible();
67 } else if (strncasecmp(line, "Galileo", 7) == 0) {
68 platform_type = MRAA_INTEL_GALILEO_GEN1;
69 plat = mraa_intel_galileo_rev_d();
70 } else if (strncasecmp(line, "MinnowBoard Compatible", 22) == 0) {
71 platform_type = MRAA_INTEL_MINNOWBOARD_MAX;
72 plat = mraa_intel_minnowboard_byt_compatible();
74 syslog(LOG_ERR, "Platform not supported, not initialising");
75 platform_type = MRAA_UNKNOWN_PLATFORM;