Home | History | Annotate | Download | only in x86
      1 /*
      2  * Author: Lay, Kuan Loon <kuan.loon.lay (at) intel.com>
      3  * Copyright (c) 2015 Intel Corporation.
      4  *
      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:
     12  *
     13  * The above copyright notice and this permission notice shall be
     14  * included in all copies or substantial portions of the Software.
     15  *
     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.
     23  */
     24 
     25 #include <stdlib.h>
     26 #include <string.h>
     27 #include <sys/types.h>
     28 #include <sys/stat.h>
     29 #include <fcntl.h>
     30 
     31 #include "common.h"
     32 #include "x86/intel_sofia_3gr.h"
     33 
     34 #define PLATFORM_NAME "SoFIA 3GR"
     35 
     36 mraa_board_t*
     37 mraa_intel_sofia_3gr()
     38 {
     39     mraa_board_t* b = (mraa_board_t*) calloc(1, sizeof(mraa_board_t));
     40     if (b == NULL) {
     41         return NULL;
     42     }
     43 
     44     b->platform_name = PLATFORM_NAME;
     45     b->phy_pin_count = MRAA_INTEL_SOFIA_3GR_PINCOUNT;
     46 
     47     b->adv_func = (mraa_adv_func_t*) calloc(1, sizeof(mraa_adv_func_t));
     48     if (b->adv_func == NULL) {
     49         goto error;
     50     }
     51 
     52     b->pins = (mraa_pininfo_t*) calloc(MRAA_INTEL_SOFIA_3GR_PINCOUNT, sizeof(mraa_pininfo_t));
     53     if (b->pins == NULL) {
     54         free(b->adv_func);
     55         goto error;
     56     }
     57 
     58     strncpy(b->pins[0].name, "I2C1SCL", 8);
     59     b->pins[0].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
     60     b->pins[0].i2c.pinmap = 1;
     61     b->pins[0].i2c.mux_total = 0;
     62 
     63     strncpy(b->pins[1].name, "I2C1SDA", 8);
     64     b->pins[1].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
     65     b->pins[1].i2c.pinmap = 1;
     66     b->pins[1].i2c.mux_total = 0;
     67 
     68     strncpy(b->pins[2].name, "I2C2SCL", 8);
     69     b->pins[2].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
     70     b->pins[2].i2c.pinmap = 1;
     71     b->pins[2].i2c.mux_total = 0;
     72 
     73     strncpy(b->pins[3].name, "I2C2SDA", 8);
     74     b->pins[3].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
     75     b->pins[3].i2c.pinmap = 1;
     76     b->pins[3].i2c.mux_total = 0;
     77 
     78     strncpy(b->pins[4].name, "I2C3SCL", 8);
     79     b->pins[4].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
     80     b->pins[4].i2c.pinmap = 1;
     81     b->pins[4].i2c.mux_total = 0;
     82 
     83     strncpy(b->pins[5].name, "I2C3SDA", 8);
     84     b->pins[5].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
     85     b->pins[5].i2c.pinmap = 1;
     86     b->pins[5].i2c.mux_total = 0;
     87 
     88     strncpy(b->pins[6].name, "I2C4SCL", 8);
     89     b->pins[6].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
     90     b->pins[6].i2c.pinmap = 1;
     91     b->pins[6].i2c.mux_total = 0;
     92 
     93     strncpy(b->pins[7].name, "I2C4SDA", 8);
     94     b->pins[7].capabilites = (mraa_pincapabilities_t){ 1, 0, 0, 0, 0, 1, 0, 0 };
     95     b->pins[7].i2c.pinmap = 1;
     96     b->pins[7].i2c.mux_total = 0;
     97 
     98     return b;
     99 error:
    100     syslog(LOG_CRIT, "SoFIA 3GR: Platform failed to initialise");
    101     free(b);
    102     return NULL;
    103 }
    104