2 * Author: Srinivas Kandagatla <srinivas.kandagatla@linaro.org>
3 * Copyright (c) 2014 Intel Corporation.
4 * Copyright (c) 2015 Linaro Limited.
6 * Copied from src/arm/banana.c
8 * Permission is hereby granted, free of charge, to any person obtaining
9 * a copy of this software and associated documentation files (the
10 * "Software"), to deal in the Software without restriction, including
11 * without limitation the rights to use, copy, modify, merge, publish,
12 * distribute, sublicense, and/or sell copies of the Software, and to
13 * permit persons to whom the Software is furnished to do so, subject to
14 * the following conditions:
16 * The above copyright notice and this permission notice shall be
17 * included in all copies or substantial portions of the Software.
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
20 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
21 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
22 * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
23 * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
24 * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
25 * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 #include <mraa/common.h>
34 #include "arm/96boards.h"
36 #define DT_BASE "/sys/firmware/devicetree/base"
38 #define PLATFORM_NAME_DB410C "DB410C"
40 int db410c_ls_gpio_pins[MRAA_96BOARDS_LS_GPIO_COUNT] = {
41 36, 12, 13, 69, 115, 4, 24, 25, 35, 34, 28, 33,
44 const char* db410c_serialdev[MRAA_96BOARDS_LS_UART_COUNT] = { "/dev/ttyMSM0", "/dev/ttyMSM1"};
46 mraa_board_t* mraa_96boards()
51 char name[MRAA_PIN_NAME_SIZE];
53 mraa_board_t* b = (mraa_board_t*) malloc(sizeof(mraa_board_t));
58 // pin mux for buses are setup by default by kernel so tell mraa to ignore them
61 if (mraa_file_exist(DT_BASE "/model")) {
62 // We are on a modern kernel, great!!!!
63 if (mraa_file_contains(DT_BASE "/model", "Qualcomm Technologies, Inc. APQ 8016 SBC")) {
64 b->platform_name = PLATFORM_NAME_DB410C;
65 b->phy_pin_count = DB410C_PINCOUNT;
66 ls_gpio_pins = db410c_ls_gpio_pins;
67 b->uart_dev[0].device_path = db410c_serialdev[0];
68 b->uart_dev[1].device_path = db410c_serialdev[1];
73 b->uart_dev_count = MRAA_96BOARDS_LS_UART_COUNT;
77 b->i2c_bus_count = MRAA_96BOARDS_LS_I2C_COUNT;
79 b->i2c_bus[0].bus_id = 0;
80 b->i2c_bus[1].bus_id= 1;
83 b->spi_bus_count = MRAA_96BOARDS_LS_SPI_COUNT;
84 b->spi_bus[0].bus_id = 0;
87 b->adv_func = (mraa_adv_func_t*) calloc(1, sizeof(mraa_adv_func_t));
88 if (b->adv_func == NULL) {
93 b->pins = (mraa_pininfo_t*) malloc(sizeof(mraa_pininfo_t) * b->phy_pin_count);
94 if (b->pins == NULL) {
100 // gpio lable starts from GPIO-A to GPIO-F
102 for (i = 0; i < MRAA_96BOARDS_LS_GPIO_COUNT; i++)
104 pin = ls_gpio_pins[i];
105 sprintf(name, "GPIO-%c", ch++);
106 strncpy(b->pins[pin].name, name, MRAA_PIN_NAME_SIZE);
107 b->pins[pin].capabilites = (mraa_pincapabilities_t){ 1, 1, 0, 0, 0, 0, 0, 0 };
108 b->pins[pin].gpio.pinmap = pin;
109 b->pins[pin].gpio.mux_total = 0;
112 b->gpio_count = MRAA_96BOARDS_LS_GPIO_COUNT;
116 b->adc_supported = 0;