nanohub: new variant "argonkey"

ST sensor hub mezzanine compatible with "Low speed expansion
connector" of Linaro 96board specifications
- Consumer Edition (CE);
- Enterprise Edition (EE);
- IoT Edition (IE) only for 1.8V version.

Hardware list:
- CPU: STM32F412CG
- NOR Flash: 1024 KB
- SRAM: 256 KB
- RTC crystal for accurate time-stamping
- Accel/Gyro + Geomagnetic sensors: ST LSM6DSL + ST LIS2MDL
- Pressure/Temp sensor: ST LPS22HB
- Humidity sensor: ST HTS221
- Proximity sensor: ST VL53L0X
- ALS sensor: Intersil ILS29034
- Hall sensor: Murata MRMS501A
- MEMS digital microphone: ST MP34DT05
- LED driver with 16 LEDs: TI LP3943
- Two GPIO-driven LEDs
- I2C EEPROM for board detection: ST M24C02-F

No driver for proximity sensor and microphone in this commit.
EEPROM is managed by host only so no need for any support in
argonkey firmware.

Change-Id: I10b4b60c2596b7734135243d45857fc9a08c3b9f
Signed-off-by: Antonio Borneo <antonio.borneo@st.com>
diff --git a/firmware/argonkey_aux_variant_config.mk b/firmware/argonkey_aux_variant_config.mk
new file mode 100644
index 0000000..e677395
--- /dev/null
+++ b/firmware/argonkey_aux_variant_config.mk
@@ -0,0 +1,78 @@
+#
+# Copyright (C) 2017 STMicroelectronics
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# only locally defined variables can be used at this time
+
+my_variant := argonkey
+
+AUX_OS_$(my_variant)             := nanohub
+AUX_ARCH_$(my_variant)           := stm32
+AUX_SUBARCH_$(my_variant)        := stm32f412
+AUX_CPU_$(my_variant)            := cortexm4
+
+# variant supports building OS bootloader, main OS image and application as targets
+# target should one of the following:
+#   "" (empty) -- applies to all targets
+#  _BL -- applies to OS bootloader target build only
+#  _OS -- applies to OS image target build only
+# _APP -- applies to application target build only
+#
+# the following variables may be defined in variant script for any target:
+# NANO_VARIANT<target>_CFLAGS_<variant>
+# NANO_VARIANT<target>_C_INCLUDES_<variant>
+# NANO_VARIANT<target>_STATIC_LIBRARIRES_<variant>
+# NANO_VARIANT<target>_WHOLE_STATIC_LIBRARIRES_<variant>
+#
+# the following may be defined for _OS and _BL only, to control
+# what additional source files need to be included in the build;
+# the file paths in this list are relative to the target (_OS or _BL) LOCAL_PATH;
+# NANO_VARIANT<target>_SRC_FILES_<variant>
+
+NANO_VARIANT_OSCFG_STATIC_LIBRARIES_$(my_variant) := libnanohub_os_$(my_variant)
+
+NANO_VARIANT_OS_CFLAGS_$(my_variant) := \
+    -DDEBUG_SWD                         \
+
+#'Ar' -> argonkey
+NANO_VARIANT_CFLAGS_$(my_variant) := -DPLATFORM_HW_TYPE=0x4172
+
+NANO_VARIANT_C_INCLUDES_$(my_variant) := \
+    device/google/contexthub/firmware/variant/$(my_variant)/inc \
+
+# this is relative to NANOHUB_OS_PATH
+NANO_VARIANT_OSCFG_SRC_FILES_$(my_variant) :=               \
+    os/algos/calibration/accelerometer/accel_cal.c          \
+    os/algos/calibration/gyroscope/gyro_cal.c               \
+    os/algos/calibration/gyroscope/gyro_stillness_detect.c  \
+    os/algos/calibration/magnetometer/mag_cal.c             \
+    os/algos/calibration/common/diversity_checker.c         \
+    os/algos/calibration/over_temp/over_temp_cal.c          \
+    os/algos/common/math/mat.c                              \
+    os/algos/common/math/quat.c                             \
+    os/algos/common/math/vec.c                              \
+    os/algos/fusion.c                                       \
+    os/algos/time_sync.c                                    \
+    os/drivers/hall/hall.c                                  \
+    os/drivers/intersil_isl29034/isl29034.c                 \
+    os/drivers/leds/leds_gpio.c                             \
+    os/drivers/leds/leds_lp3943.c                           \
+    os/drivers/orientation/orientation.c                    \
+    os/drivers/st_hts221/hts221.c                           \
+    os/drivers/st_lps22hb/lps22hb.c                         \
+    os/drivers/st_lsm6dsm/st_lsm6dsm.c                      \
+    os/drivers/tilt_detection/tilt_detection.c              \
+    os/drivers/window_orientation/window_orientation.c      \
diff --git a/firmware/variant/Android.mk b/firmware/variant/Android.mk
index 985418d..2321334 100644
--- a/firmware/variant/Android.mk
+++ b/firmware/variant/Android.mk
@@ -14,5 +14,5 @@
 # limitations under the License.
 #
 
-subdirs := nucleo lunchbox linux neonkey
+subdirs := nucleo lunchbox linux neonkey argonkey
 include $(call all-named-subdir-makefiles,$(subdirs))
diff --git a/firmware/variant/argonkey/Android.mk b/firmware/variant/argonkey/Android.mk
new file mode 100644
index 0000000..773dc11
--- /dev/null
+++ b/firmware/variant/argonkey/Android.mk
@@ -0,0 +1,36 @@
+#
+# Copyright (C) 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+LOCAL_PATH := $(call my-dir)
+
+include $(CLEAR_NANO_VARS)
+
+LOCAL_MODULE := libnanohub_os_argonkey
+LOCAL_MODULE_TAGS := optional
+LOCAL_AUX_OS_VARIANT := argonkey
+
+LOCAL_SRC_FILES :=      \
+    src/os/i2c.c        \
+    src/os/led.c        \
+    src/os/spi.c        \
+
+LOCAL_C_INCLUDES := \
+    $(LOCAL_PATH)/inc \
+
+LOCAL_EXPORT_C_INCLUDE_DIRS := \
+    $(LOCAL_C_INCLUDES)
+
+include $(BUILD_NANOHUB_OS_STATIC_LIBRARY)
diff --git a/firmware/variant/argonkey/Makefile b/firmware/variant/argonkey/Makefile
new file mode 100644
index 0000000..a06da6a
--- /dev/null
+++ b/firmware/variant/argonkey/Makefile
@@ -0,0 +1,6 @@
+include argonkey_conf.mk
+
+SRC_PATH := ../..
+OUT := out/nanohub/$(VARIANT)
+
+include $(SRC_PATH)/variant/variant.mk
diff --git a/firmware/variant/argonkey/README.DMA.txt b/firmware/variant/argonkey/README.DMA.txt
new file mode 100644
index 0000000..4356c55
--- /dev/null
+++ b/firmware/variant/argonkey/README.DMA.txt
@@ -0,0 +1,21 @@
+Allocation of DMA Streams
+
+DMA1:
+Stream#0: Channel#1 (I2C1_RX) I2C1_DMA_RX_CFG_A i2c-to-AP
+Stream#1: Channel#1 (I2C3_RX) I2C3_DMA_RX_CFG_A i2c-to-ext
+Stream#2: Channel#7 (I2C2_RX) I2C2_DMA_RX_CFG_A i2c-to-sens
+Stream#3: Channel#0 (SPI2_RX) SPI2_DMA_RX_CFG   spi-to-sens
+Stream#4: Channel#0 (SPI2_TX) SPI2_DMA_TX_CFG   spi-to-sens
+Stream#5: Channel#6 (I2C3_TX) I2C3_DMA_TX_CFG_B i2c-to-sens
+Stream#6: Channel#1 (I2C1_TX) I2C1_DMA_TX_CFG_B i2c-to-AP
+Stream#7: Channel#7 (I2C2_TX) I2C2_DMA_TX_CFG   i2c-to-sens
+
+DMA2:
+Stream#0:
+Stream#1:
+Stream#2: Channel#3 (SPI1_RX) SPI1_DMA_RX_CFG_B spi-to-AP
+Stream#3: Channel#2 (I2S5_RX) SPI5_DMA_RX_CFG_A i2s-to-mic
+Stream#4: Channel#2 (I2S5_TX) SPI5_DMA_TX_CFG_A i2s-to-mic
+Stream#5: Channel#3 (SPI1_TX) SPI1_DMA_TX_CFG_B spi-to-AP
+Stream#6:
+Stream#7:
diff --git a/firmware/variant/argonkey/README.GPIO.txt b/firmware/variant/argonkey/README.GPIO.txt
new file mode 100644
index 0000000..131de55
--- /dev/null
+++ b/firmware/variant/argonkey/README.GPIO.txt
@@ -0,0 +1,36 @@
+Allocation of GPIOs and EXTI interrupts
+
+PA0   WAKEUP     EXTI0_IRQn
+PA1   WIRQ1
+PA2   SW_USR     EXTI2_IRQn (connected to INT_HUM too, but Humidity driver does not use it)
+PA3   WIRQ2
+PA4   SPI1_NSS   (slave)
+PA5   SPI1_SCK   (slave)
+PA6   SPI1_MISO  (slave)
+PA7   SPI1_MOSI  (slave)
+PA8   I2C3_SCL
+PA9   UART1_TX
+PA10  UART1_RX
+PA11  EXT_GPIO0  EXTI15_10_IRQn
+PA12  EXT_GPIO1  EXTI15_10_IRQn
+PA13  SWDIO
+PA14  SWCLK
+PA15  INT_BARO   EXTI15_10_IRQn
+
+PB0   I2S5_CK
+PB1   INT_ACCG   EXTI1_IRQn
+PB2   LED1       (at reset it is used in input as BOOT1)
+PB3   INT_ALS    EXTI3_IRQn
+PB4   I2C3_SDA
+PB5   INT_HALL   EXTI9_5_IRQn
+PB6   I2C1_SCL   (slave)
+PB7   I2C1_SDA   (slave)
+PB8   I2S5_SD
+PB9   I2C2_SDA
+PB10  I2C2_SCL
+PB12  SPI2_NSS
+PB13  SPI2_SCK
+PB14  SPI2_MISO
+PB15  SPI2_MOSI
+
+PC13  LED0
diff --git a/firmware/variant/argonkey/argonkey.mk b/firmware/variant/argonkey/argonkey.mk
new file mode 100644
index 0000000..75dc5af
--- /dev/null
+++ b/firmware/variant/argonkey/argonkey.mk
@@ -0,0 +1,87 @@
+#
+# Copyright (C) 2017 STMicroelectronics
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+#variant makefile for argonkey
+
+ifneq ($(PLATFORM),stm32)
+        $(error "ARGONKEY variant cannot be build on a platform that is not stm32")
+endif
+
+FLAGS += -DPLATFORM_HW_TYPE=0x4172   #'Ar' -> argonkey
+FLAGS += -DDEBUG_SWD
+
+FLAGS += -I$(VARIANT_PATH)/inc
+
+#board configuration shims
+SRCS_os += $(VARIANT_PATH)/src/os/i2c.c
+SRCS_os += $(VARIANT_PATH)/src/os/led.c
+SRCS_os += $(VARIANT_PATH)/src/os/spi.c
+#keys
+
+#drivers
+# Fusion algorithms
+SRCS_os += os/algos/fusion.c \
+	os/algos/common/math/mat.c \
+	os/algos/common/math/quat.c \
+	os/algos/common/math/vec.c
+
+# LSM6DSL accel+gyro with mag slave
+SRCS_os += os/drivers/st_lsm6dsm/st_lsm6dsm.c \
+        os/algos/calibration/accelerometer/accel_cal.c \
+        os/algos/calibration/gyroscope/gyro_cal.c \
+        os/algos/calibration/gyroscope/gyro_stillness_detect.c \
+        os/algos/calibration/magnetometer/mag_cal.c \
+        os/algos/calibration/common/diversity_checker.c \
+        os/algos/calibration/over_temp/over_temp_cal.c \
+        os/algos/time_sync.c
+
+# Orientation sensor driver
+SRCS_os += os/drivers/orientation/orientation.c
+
+# Window orientation sensor driver
+SRCS_os += os/drivers/window_orientation/window_orientation.c
+
+# LPS22HB baro+temp
+SRCS_os += os/drivers/st_lps22hb/lps22hb.c
+
+# Hall effect sensor driver
+SRCS_os += os/drivers/hall/hall.c
+
+# HTS221 humidity
+SRCS_os += os/drivers/st_hts221/hts221.c
+
+# ISL29034 ALS
+SRCS_os += os/drivers/intersil_isl29034/isl29034.c
+
+# LED on GPIO
+SRCS_os += os/drivers/leds/leds_gpio.c
+
+# LP3943 LED controller
+SRCS_os += os/drivers/leds/leds_lp3943.c
+
+# Tilt detection
+SRCS_os += os/drivers/tilt_detection/tilt_detection.c
+
+# Digital microphone
+# FIXME
+
+# VL53L0X Proximity
+# FIXME
+
+# Button
+# FIXME
+
+$(info included ARGONKEY variant)
diff --git a/firmware/variant/argonkey/argonkey_conf.mk b/firmware/variant/argonkey/argonkey_conf.mk
new file mode 100644
index 0000000..a525226
--- /dev/null
+++ b/firmware/variant/argonkey/argonkey_conf.mk
@@ -0,0 +1,26 @@
+#
+# Copyright (C) 2016 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+#      http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+# settings that apps and OS both want to know about variant
+
+VENDOR := google
+VARIANT := argonkey
+CPU := cortexm4
+CHIP := stm32f412
+PLATFORM := stm32
+
+# VARIANT_PATH is relative to ANDROID TOP
+VARIANT_PATH := device/google/contexthub/firmware/variant/$(VARIANT)
diff --git a/firmware/variant/argonkey/inc/variant/sensType.h b/firmware/variant/argonkey/inc/variant/sensType.h
new file mode 100644
index 0000000..23cd0ef
--- /dev/null
+++ b/firmware/variant/argonkey/inc/variant/sensType.h
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _VARIANT_SENS_TYPE_H_
+#define _VARIANT_SENS_TYPE_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define SENS_TYPE_GYRO_BIAS       (SENS_TYPE_FIRST_USER + 0)
+#define SENS_TYPE_MAG_BIAS        (SENS_TYPE_FIRST_USER + 1)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/firmware/variant/argonkey/inc/variant/variant.h b/firmware/variant/argonkey/inc/variant/variant.h
new file mode 100644
index 0000000..62fb4e8
--- /dev/null
+++ b/firmware/variant/argonkey/inc/variant/variant.h
@@ -0,0 +1,157 @@
+/*
+ * Copyright (C) 2017 STMicroelectronics
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef _VARIANT_ARGONKEY_H_
+#define _VARIANT_ARGONKEY_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define PLATFORM_HW_TYPE            0x4172   // 'Ar' -> argonkey
+
+#define VARIANT_VER                 0x00000000
+
+//we have LSE in argonkey
+#define RTC_CLK                     RTC_CLK_LSE
+#define RTC_PREDIV_A                0UL
+#define RTC_PREDIV_S                32767UL
+
+//spi bus for comms
+#define PLATFORM_HOST_INTF_SPI_BUS  0
+
+#define SH_INT_WAKEUP               GPIO_PA(0)
+#define SH_EXTI_WAKEUP_IRQ          EXTI0_IRQn
+#define AP_INT_WAKEUP               GPIO_PA(1)
+/*
+ * Allocating a GPIO for non-wakeup host interrupt is optional in CHRE.
+ * ArgonKey implements this feature and enables it here. If you want to use
+ * the GPIO_PA(3) for other purposes, you should comment the line below and
+ * the corresponding line in the host's devicetree.
+ */
+#define AP_INT_NONWAKEUP            GPIO_PA(3)
+
+#define DEBUG_UART_UNITNO           1
+#define DEBUG_UART_GPIO_TX          GPIO_PA(9)
+#define DEBUG_UART_GPIO_RX          GPIO_PA(10)
+
+#define DEBUG_LOG_EVT               0x3B474F4C
+
+#define BL_FLASH_TABLE                                                  \
+{                                                                       \
+    { (uint8_t *)(&BL),                      0x04000, BL_FLASH_BL     },\
+    { (uint8_t *)(__eedata_start),           0x04000, BL_FLASH_EEDATA },\
+    { (uint8_t *)(__eedata_start + 0x04000), 0x04000, BL_FLASH_EEDATA },\
+    { (uint8_t *)(__code_start),             0x04000, BL_FLASH_KERNEL },\
+    { (uint8_t *)(__code_start + 0x04000),   0x10000, BL_FLASH_KERNEL },\
+    { (uint8_t *)(__code_start + 0x14000),   0x20000, BL_FLASH_KERNEL },\
+    { (uint8_t *)(__shared_start),           0x20000, BL_FLASH_SHARED },\
+    { (uint8_t *)(__shared_start + 0x20000), 0x20000, BL_FLASH_SHARED },\
+    { (uint8_t *)(__shared_start + 0x40000), 0x20000, BL_FLASH_SHARED },\
+    { (uint8_t *)(__shared_start + 0x60000), 0x20000, BL_FLASH_SHARED },\
+    { (uint8_t *)(__shared_start + 0x80000), 0x20000, BL_FLASH_SHARED },\
+    { (uint8_t *)(__shared_start + 0xA0000), 0x20000, BL_FLASH_SHARED },\
+}
+
+/* ------------------------------------------------------------------------ */
+/* sensor accel+gyro lsm6dsl (compatible lsm6dsm) on spi */
+
+// #define LSM6DSM_DBG_ENABLED                 1
+
+#define LSM6DSM_SPI_SLAVE_BUS_ID               1
+#define LSM6DSM_SPI_SLAVE_FREQUENCY_HZ         8000000
+#define LSM6DSM_SPI_SLAVE_CS_GPIO              GPIO_PB(12)
+
+#define LSM6DSM_INT_IRQ                        EXTI1_IRQn
+#define LSM6DSM_INT1_GPIO                      GPIO_PB(1)
+
+/* i2c slave sensor mag lis2mdl (lsm303agr compatible) */
+#define LSM6DSM_I2C_MASTER_LSM303AGR           1
+
+#define LSM6DSM_ACCEL_GYRO_ROT_MATRIX          -1, 0, 0, 0, -1, 0, 0, 0, 1
+#define LSM6DSM_MAGN_ROT_MATRIX                -1, 0, 0, 0, 1, 0, 0, 0, 1
+
+#define LSM6DSM_GYRO_CALIB_ENABLED             1
+#define LSM6DSM_MAGN_CALIB_ENABLED             1
+
+/* ------------------------------------------------------------------------ */
+/* sensor baro+temp lps22hb on i2c */
+/* unused PIN GPIO_PA(15), INT EXTI15_10_IRQn */
+
+// #define LPS22HB_DBG_ENABLED                 1
+
+#define LPS22HB_I2C_BUS_ID                     1
+#define LPS22HB_I2C_SPEED                      400000
+#define LPS22HB_I2C_ADDR                       0x5D
+
+/* ------------------------------------------------------------------------ */
+/* sensor humidity hts221 on i2c */
+/* unused PIN GPIO_PA(2), INT EXTI2_IRQn is used as button */
+
+// #define HTS221_DBG_ENABLED                  1
+
+#define HTS221_I2C_BUS_ID                      1
+#define HTS221_I2C_SPEED                       400000
+#define HTS221_I2C_ADDR                        0x5F
+
+/* ------------------------------------------------------------------------ */
+/* sensor als isl29034 on i2c */
+
+#define ISL29034_I2C_BUS_ID                    1
+#define ISL29034_I2C_SPEED                     400000
+#define ISL29034_I2C_ADDR                      0x44
+
+/* ------------------------------------------------------------------------ */
+/* sensor proximity vl53l0x on i2c */
+
+// FIXME
+// I2C_BUS_ID 1
+// I2C_SPEED  400000
+// I2C_ADDR   0x29
+// PIN        GPIO_PB(3)
+// IRQ        EXTI3_IRQn
+
+/* ------------------------------------------------------------------------ */
+/* sensor hall mrms501a on gpio */
+
+#define HALL_PIN                               GPIO_PB(5)
+#define HALL_IRQ                               EXTI9_5_IRQn
+
+/* ------------------------------------------------------------------------ */
+/* microphone on i2s */
+
+// FIXME
+// I2S_BUS_ID 4
+
+/* ------------------------------------------------------------------------ */
+/* led controller lp3943 on i2c */
+
+#define LP3943_I2C_BUS_ID                      2
+#define LP3943_I2C_SPEED                       200000
+#define LP3943_I2C_ADDR                        0x60
+
+/* ------------------------------------------------------------------------ */
+/* button on gpio */
+
+// FIXME
+// PIN GPIO_PA(2)
+// INT EXTI2_IRQn
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/firmware/variant/argonkey/src/os/i2c.c b/firmware/variant/argonkey/src/os/i2c.c
new file mode 100644
index 0000000..566c784
--- /dev/null
+++ b/firmware/variant/argonkey/src/os/i2c.c
@@ -0,0 +1,62 @@
+/*
+ * Copyright (C) 2016-2017 STMicroelectronics
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <plat/i2c.h>
+#include <util.h>
+
+static const struct StmI2cBoardCfg mStmI2cBoardCfgs[] = {
+    [0] = {
+        .gpioScl = I2C1_GPIO_SCL_PB6,
+        .gpioSda = I2C1_GPIO_SDA_PB7,
+
+        .gpioPull = GPIO_PULL_NONE,
+
+        .dmaRx = I2C1_DMA_RX_CFG_A,
+        .dmaTx = I2C1_DMA_TX_CFG_B,
+
+        .sleepDev = Stm32sleepDevI2c1,
+    },
+    [1] = {
+        .gpioScl = I2C2_GPIO_SCL_PB10,
+        .gpioSda = I2C2_GPIO_SDA_PB9,
+
+        .gpioPull = GPIO_PULL_NONE,
+
+        .dmaRx = I2C2_DMA_RX_CFG_A,
+        .dmaTx = I2C2_DMA_TX_CFG,
+
+        .sleepDev = Stm32sleepDevI2c2,
+    },
+    [2] = {
+        .gpioScl = I2C3_GPIO_SCL_PA8,
+        .gpioSda = I2C3_GPIO_SDA_PB4,
+
+        .gpioPull = GPIO_PULL_NONE,
+
+        .dmaRx = I2C3_DMA_RX_CFG_A,
+        .dmaTx = I2C3_DMA_TX_CFG_B,
+
+        .sleepDev = Stm32sleepDevI2c3,
+    },
+};
+
+const struct StmI2cBoardCfg *boardStmI2cCfg(uint8_t busId)
+{
+    if (busId >= ARRAY_SIZE(mStmI2cBoardCfgs))
+        return NULL;
+
+    return &mStmI2cBoardCfgs[busId];
+}
diff --git a/firmware/variant/argonkey/src/os/led.c b/firmware/variant/argonkey/src/os/led.c
new file mode 100644
index 0000000..3762154
--- /dev/null
+++ b/firmware/variant/argonkey/src/os/led.c
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2017 STMicroelectronics
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <leds_gpio.h>
+#include <util.h>
+#include <plat/gpio.h>
+
+static uint32_t local_leds_array[] = {
+    GPIO_PC(13), /* GPIO_LED0 */ \
+    GPIO_PB(2)   /* GPIO_LED1 */
+};
+
+static struct LedsGpio local_leds = {
+    .leds_array = local_leds_array,
+    .num = ARRAY_SIZE(local_leds_array),
+};
+
+const struct LedsGpio *ledsGpioBoardCfg(void)
+{
+    return &local_leds;
+}
diff --git a/firmware/variant/argonkey/src/os/spi.c b/firmware/variant/argonkey/src/os/spi.c
new file mode 100644
index 0000000..40457bd
--- /dev/null
+++ b/firmware/variant/argonkey/src/os/spi.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright (C) 2016 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <plat/spi.h>
+#include <util.h>
+
+static const struct StmSpiBoardCfg mStmSpiBoardCfgs[] = {
+    [0] = {
+        .gpioMiso = GPIO_PA(6),
+        .gpioMosi = GPIO_PA(7),
+        .gpioSclk = GPIO_PA(5),
+        .gpioNss = GPIO_PA(4),
+
+        .gpioFunc = GPIO_AF_SPI1,
+        .gpioSpeed = GPIO_SPEED_MEDIUM,
+
+        .irqNss = -1,
+
+        .dmaRx = SPI1_DMA_RX_CFG_B,
+        .dmaTx = SPI1_DMA_TX_CFG_B,
+
+        .sleepDev = -1,
+    },
+    [1] = {
+        .gpioMiso = GPIO_PB(14),
+        .gpioMosi = GPIO_PB(15),
+        .gpioSclk = GPIO_PB(13),
+        .gpioNss = GPIO_PB(12),
+
+        .gpioSpeed = GPIO_SPEED_MEDIUM,
+        .gpioFunc = GPIO_AF_SPI2_A,
+
+        .irqNss = EXTI15_10_IRQn,
+
+        .dmaRx = SPI2_DMA_RX_CFG,
+        .dmaTx = SPI2_DMA_TX_CFG,
+
+        .sleepDev = Stm32sleepDevSpi2,
+    },
+};
+
+const struct StmSpiBoardCfg *boardStmSpiCfg(uint8_t busId)
+{
+    if (busId >= ARRAY_SIZE(mStmSpiBoardCfgs))
+        return NULL;
+
+    return &mStmSpiBoardCfgs[busId];
+}