Skip to content

Commit

Permalink
platform: add iot2050 platform support
Browse files Browse the repository at this point in the history
This patch introuduce iot2050 platform support, it is the port from
meta-iot2050 layer.

Based on original patch by Le Jin.

Signed-off-by: Le Jin <le.jin@siemens.com>
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Ivan Mikhaylov <ivan.mikhaylov@siemens.com>
  • Loading branch information
fr0st61te authored and tingleby committed Aug 5, 2022
1 parent 0c44a72 commit a9f0ff2
Show file tree
Hide file tree
Showing 10 changed files with 1,826 additions and 0 deletions.
1 change: 1 addition & 0 deletions api/mraa/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ typedef enum {
MRAA_ADLINK_LEC_AL_AI = 23, /**< Adlink LEC-AL*/
MRAA_UPXTREME = 24, /**< The UPXTREME Board */
MRAA_INTEL_ILK = 25, /**< Intel Learning Kit */
MRAA_SIEMENS_IOT2050 = 26, /**< Siemens IOT2050 board */
// USB platform extenders start at 256
MRAA_FTDI_FT4222 = 256, /**< FTDI FT4222 USB to i2c bridge */

Expand Down
1 change: 1 addition & 0 deletions api/mraa/types.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ typedef enum {
MTK_OMEGA2 = 18, /**< MT7688 based Onion Omega2 board */
IEI_TANK = 19, /**< IEI Tank System*/
INTEL_UPXTREME = 24, /**< The UPXTREME Board */
SIEMENS_IOT2050 = 26, /**< Siemens IOT2050 board */

FTDI_FT4222 = 256, /**< FTDI FT4222 USB to i2c bridge */

Expand Down
40 changes: 40 additions & 0 deletions include/arm/siemens/iot2050.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Author: Le Jin <le.jin@siemens.com>
* Copyright (c) Siemens AG, 2019
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#pragma once

#ifdef __cplusplus
extern "C" {
#endif

#include "mraa_internal.h"

#define PLATFORM_NAME "SIMATIC IOT2050"
#define MRAA_IOT2050_PINCOUNT (20)

mraa_board_t *
mraa_siemens_iot2050();

#ifdef __cplusplus
}
#endif
97 changes: 97 additions & 0 deletions include/arm/siemens/platform.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/*
* Author: Le Jin <le.jin@siemens.com>
* Copyright (c) Siemens AG, 2019
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef _PLATFORM_H_
#define _PLATFORM_H_
#ifdef __cplusplus
extern "C" {
#endif
#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>
typedef struct {
bool (*init)(void);
void (*deinit)(void);
void (*select_func)(uint8_t group, uint16_t pinIndex, uint8_t func);
void (*select_input)(uint8_t group, uint16_t pinIndex);
void (*select_output)(uint8_t group, uint16_t pinIndex);
void (*select_inout)(uint8_t group, uint16_t pinIndex);
void (*select_hiz)(uint8_t group, uint16_t pinIndex);
void (*select_pull_up)(uint8_t group, uint16_t pinIndex);
void (*select_pull_down)(uint8_t group, uint16_t pinIndex);
void (*select_pull_disable)(uint8_t group, uint16_t pinIndex);
uint32_t (*get_raw_reg_value)(uint8_t group, uint16_t pinIndex);
void (*set_raw_reg_value)(uint8_t group, uint16_t pinIndex, uint32_t value);
void (*dump_info)(uint8_t group, uint16_t pinIndex);
} pin_mux_ops_t;

typedef struct{
bool initialized;
pin_mux_ops_t ops;
} pin_mux_interface_t;

#define VOID_INTERFACE_CALL(instance, function) \
do {\
if((instance) && ((pin_mux_interface_t *)instance)->ops.function) \
((pin_mux_interface_t *)instance)->ops.function(); \
}while(0)

#define VOID_INTERFACE_CALL_WITH_ARGS(instance, function, ...) \
do {\
if((instance) && ((pin_mux_interface_t *)instance)->ops.function) \
((pin_mux_interface_t *)instance)->ops.function(__VA_ARGS__); \
}while(0)

#define INTERFACE_CALL_WITH_ARGS(instance, retType, defaultRetValue, function, ...) \
( \
{ \
retType ret = defaultRetValue; \
if((instance) && ((pin_mux_interface_t *)instance)->ops.function) \
ret = ((pin_mux_interface_t *)instance)->ops.function(__VA_ARGS__); \
ret; \
} \
)

#ifdef _DEBUG
#define DEBUG_PRINT(...) fprintf(stderr, __VA_ARGS__)
#else
#define DEBUG_PRINT(...) do{}while(0)
#endif

void *platfrom_pinmux_get_instance(char *platform);
#define platform_pinmux_release_instance(instance) VOID_INTERFACE_CALL(instance, deinit)
#define platform_pinmux_select_func(instance, ...) VOID_INTERFACE_CALL_WITH_ARGS(instance, select_func, __VA_ARGS__)
#define platform_pinmux_select_input(instance, ...) VOID_INTERFACE_CALL_WITH_ARGS(instance, select_input, __VA_ARGS__)
#define platform_pinmux_select_output(instance, ...) VOID_INTERFACE_CALL_WITH_ARGS(instance, select_output, __VA_ARGS__)
#define platform_pinmux_select_inout(instance, ...) VOID_INTERFACE_CALL_WITH_ARGS(instance, select_inout, __VA_ARGS__)
#define platform_pinmux_select_hiz(instance, ...) VOID_INTERFACE_CALL_WITH_ARGS(instance, select_hiz, __VA_ARGS__)
#define platform_pinmux_select_pull_up(instance, ...) VOID_INTERFACE_CALL_WITH_ARGS(instance, select_pull_up, __VA_ARGS__)
#define platform_pinmux_select_pull_down(instance, ...) VOID_INTERFACE_CALL_WITH_ARGS(instance, select_pull_down, __VA_ARGS__)
#define platform_pinmux_select_pull_disable(instance, ...) VOID_INTERFACE_CALL_WITH_ARGS(instance, select_pull_disable, __VA_ARGS__)
#define platform_pinmux_get_raw_reg_value(instance, ...) INTERFACE_CALL_WITH_ARGS(instance, uint32_t, -1, get_raw_reg_value, __VA_ARGS__)
#define platform_pinmux_set_raw_reg_value(instance, ...) VOID_INTERFACE_CALL_WITH_ARGS(instance, set_raw_reg_value, __VA_ARGS__)
#define platform_pinmux_dump_info(instance, ...) VOID_INTERFACE_CALL_WITH_ARGS(instance, dump_info, __VA_ARGS__)
#ifdef __cplusplus
}
#endif
#endif
34 changes: 34 additions & 0 deletions include/arm/siemens/platform_iot2050.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
* Author: Le Jin <le.jin@siemens.com>
* Copyright (c) Siemens AG, 2019
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
* "Software"), to deal in the Software without restriction, including
* without limitation the rights to use, copy, modify, merge, publish,
* distribute, sublicense, and/or sell copies of the Software, and to
* permit persons to whom the Software is furnished to do so, subject to
* the following conditions:
*
* The above copyright notice and this permission notice shall be
* included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
* LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
* OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
* WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
#ifndef _PLATFORM_IOT2050_H_
#define _PLATFORM_IOT2050_H_
#ifdef __cplusplus
extern "C" {
#endif
#include "arm/siemens/platform.h"
pin_mux_interface_t *iot2050_pinmux_get_instance(void);
#ifdef __cplusplus
}
#endif
#endif
3 changes: 3 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,9 @@ set (mraa_LIB_ARM_SRCS_NOAUTO
${PROJECT_SOURCE_DIR}/src/arm/de_nano_soc.c
${PROJECT_SOURCE_DIR}/src/arm/rockpi4.c
${PROJECT_SOURCE_DIR}/src/arm/adlink_ipi.c
${PROJECT_SOURCE_DIR}/src/arm/siemens/iot2050.c
${PROJECT_SOURCE_DIR}/src/arm/siemens/platform.c
${PROJECT_SOURCE_DIR}/src/arm/siemens/platform_iot2050.c
)

set (mraa_LIB_MIPS_SRCS_NOAUTO
Expand Down
5 changes: 5 additions & 0 deletions src/arm/arm.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "arm/phyboard.h"
#include "arm/raspberry_pi.h"
#include "arm/adlink_ipi.h"
#include "arm/siemens/iot2050.h"
#include "mraa_internal.h"


Expand Down Expand Up @@ -98,6 +99,8 @@ mraa_arm_platform()
platform_type = MRAA_RASPBERRY_PI;
else if (mraa_file_contains("/proc/device-tree/model", "ADLINK ARM, LEC-PX30"))
platform_type = MRAA_ADLINK_IPI;
else if (mraa_file_contains("/proc/device-tree/model", "SIMATIC IOT2050"))
platform_type = MRAA_SIEMENS_IOT2050;
}

switch (platform_type) {
Expand All @@ -124,6 +127,8 @@ mraa_arm_platform()
break;
case MRAA_ADLINK_IPI:
plat = mraa_adlink_ipi();
case MRAA_SIEMENS_IOT2050:
plat = mraa_siemens_iot2050();
break;
default:
plat = NULL;
Expand Down
Loading

0 comments on commit a9f0ff2

Please sign in to comment.