From d09fd777fcc65834a805235bb4ac778946a46095 Mon Sep 17 00:00:00 2001
From: Neil Jones <neil.jones@imgtec.com>
Date: Thu, 9 Feb 2017 12:22:28 +0000
Subject: [PATCH] boards: mips-malta: Add basic malta FPGA support.

Add basic support for the MIPS malta FPGA platform.
---
 boards/mips-malta/Makefile              |  3 ++
 boards/mips-malta/Makefile.features     |  9 ++++
 boards/mips-malta/Makefile.include      |  4 ++
 boards/mips-malta/include/board.h       | 46 +++++++++++++++++++
 boards/mips-malta/include/periph_conf.h | 59 +++++++++++++++++++++++++
 boards/mips-malta/malta.c               | 28 ++++++++++++
 6 files changed, 149 insertions(+)
 create mode 100644 boards/mips-malta/Makefile
 create mode 100644 boards/mips-malta/Makefile.features
 create mode 100644 boards/mips-malta/Makefile.include
 create mode 100644 boards/mips-malta/include/board.h
 create mode 100644 boards/mips-malta/include/periph_conf.h
 create mode 100644 boards/mips-malta/malta.c

diff --git a/boards/mips-malta/Makefile b/boards/mips-malta/Makefile
new file mode 100644
index 0000000000..f8fcbb53a0
--- /dev/null
+++ b/boards/mips-malta/Makefile
@@ -0,0 +1,3 @@
+MODULE = board
+
+include $(RIOTBASE)/Makefile.base
diff --git a/boards/mips-malta/Makefile.features b/boards/mips-malta/Makefile.features
new file mode 100644
index 0000000000..bf4ba1fe26
--- /dev/null
+++ b/boards/mips-malta/Makefile.features
@@ -0,0 +1,9 @@
+# Put defined MCU peripherals here (in alphabetical order)
+FEATURES_PROVIDED += periph_timer
+FEATURES_PROVIDED += periph_uart
+
+# Various other features (if any)
+FEATURES_PROVIDED += cpp
+
+# The board MPU family (used for grouping by the CI system)
+FEATURES_MCU_GROUP = mips32r2
diff --git a/boards/mips-malta/Makefile.include b/boards/mips-malta/Makefile.include
new file mode 100644
index 0000000000..f162303b4d
--- /dev/null
+++ b/boards/mips-malta/Makefile.include
@@ -0,0 +1,4 @@
+export CPU = mips32r2_common
+export INCLUDES += -I$(RIOTBOARD)/$(BOARD)/include/
+export USE_HARD_FLOAT = 1
+export USE_DSP = 1
diff --git a/boards/mips-malta/include/board.h b/boards/mips-malta/include/board.h
new file mode 100644
index 0000000000..9d69c1bbc6
--- /dev/null
+++ b/boards/mips-malta/include/board.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright 2016, Imagination Technologies Limited and/or its
+ *                 affiliated group companies.
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser
+ * General Public License v2.1. See the file LICENSE in the top level
+ * directory for more details.
+ *
+ */
+
+/**
+ * @defgroup    boards_mips-malta MIPS MALTA
+ * @ingroup     boards
+ * @brief       Board specific files for the MIPS Malta FPGA system
+ * @{
+ *
+ * @file
+ * @brief       Board specific definitions for the MIPS Malta FPGA System.
+ *
+ * @author      Neil Jones <neil.jones@imgtec.com>
+ */
+
+#ifndef _BOARD_H_
+#define _BOARD_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief       Set how many increments of the count register per uS
+ *              needed by timer code
+ */
+#define TICKS_PER_US (15)
+
+/**
+ * @brief       Board level initialisation
+ */
+void board_init(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _BOARD_H_ */
+/** @} */
diff --git a/boards/mips-malta/include/periph_conf.h b/boards/mips-malta/include/periph_conf.h
new file mode 100644
index 0000000000..d8dad5660d
--- /dev/null
+++ b/boards/mips-malta/include/periph_conf.h
@@ -0,0 +1,59 @@
+/*
+ * Copyright 2016, Imagination Technologies Limited and/or its
+ *                 affiliated group companies.
+ *
+ * This file is subject to the terms and conditions of the GNU Lesser
+ * General Public License v2.1. See the file LICENSE in the top level
+ * directory for more details.
+ *
+ */
+
+/**
+ * @defgroup    boards_mips-malta MIPS MALTA
+ * @ingroup     boards
+ * @brief       peripheral configuration for the MIPS Malta FPGA system
+ * @{
+ *
+ * @file
+ * @brief       peripheral configuration for the MIPS Malta FPGA system
+ *
+ * @author      Neil Jones <neil.jones@imgtec.com>
+ */
+
+#ifndef _PERIPH_CONF_H_
+#define _PERIPH_CONF_H_
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/**
+ * @brief   Timer definitions
+ * @{
+ */
+#define TIMER_NUMOF         (1)
+#define TIMER_0_CHANNELS    (3)
+/** @} */
+
+/**
+ * @brief No UART driver for this board currently
+ *        Note this value must be set though (to 0)
+ */
+#define UART_NUMOF          (0)
+
+/**
+ * @brief Enable DSP context save + restore.
+ */
+#define MIPS_DSP            (1)
+
+/**
+ * @brief Enable FPU context save + restore.
+ */
+#define MIPS_HARD_FLOAT     (1)
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /*_PERIPH_CONF_H_*/
+/** @} */
diff --git a/boards/mips-malta/malta.c b/boards/mips-malta/malta.c
new file mode 100644
index 0000000000..e2be4e3d02
--- /dev/null
+++ b/boards/mips-malta/malta.c
@@ -0,0 +1,28 @@
+/*
+ * Copyright 2016, Imagination Technologies Limited and/or its
+ *                 affiliated group companies.
+ * This file is subject to the terms and conditions of the GNU Lesser
+ * General Public License v2.1. See the file LICENSE in the top level
+ * directory for more details.
+ */
+#include <stdio.h>
+#include "periph/uart.h"
+
+#define MIPS_MALTA_ADDR    (0xbf000500)
+#define MIPS_MALTA_VAL_RST (0x42)
+
+static void malta_reset(void)
+{
+    *(volatile long *)MIPS_MALTA_ADDR = MIPS_MALTA_VAL_RST;
+    __asm__ volatile ("wait");
+}
+
+void board_init(void)
+{
+    /* Board initialisation is done by the bootloader (u-boot) on Malta */
+}
+
+void pm_reboot(void)
+{
+    malta_reset();
+}
-- 
GitLab