From abbf5a2ef4b46218a1b24ef6afd6cf7b35a87e55 Mon Sep 17 00:00:00 2001 From: Drew Barbier Date: Mon, 2 Jul 2018 00:40:06 -0500 Subject: e2 and clic start --- bsp/env/coreip-e2-arty/platform.h | 92 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) create mode 100644 bsp/env/coreip-e2-arty/platform.h (limited to 'bsp/env/coreip-e2-arty/platform.h') diff --git a/bsp/env/coreip-e2-arty/platform.h b/bsp/env/coreip-e2-arty/platform.h new file mode 100644 index 0000000..8ee0a83 --- /dev/null +++ b/bsp/env/coreip-e2-arty/platform.h @@ -0,0 +1,92 @@ +// See LICENSE for license details. + +#ifndef _SIFIVE_PLATFORM_H +#define _SIFIVE_PLATFORM_H + +// Some things missing from the official encoding.h + +#if __riscv_xlen == 32 +#define MCAUSE_INT 0x80000000UL +#define MCAUSE_CAUSE 0x000003FFUL +#else +#define MCAUSE_INT 0x8000000000000000UL +#define MCAUSE_CAUSE 0x00000000000003FFUL +#endif + +#define MTVEC_DIRECT 0X00 +#define MTVEC_VECTORED 0x01 +#define MTVEC_CLIC 0x02 +#define MTVEC_CLIC_VECT 0X03 + + +#include "sifive/const.h" +#include "sifive/devices/gpio.h" +#include "sifive/devices/clic.h" +#include "sifive/devices/pwm.h" +#include "sifive/devices/spi.h" +#include "sifive/devices/uart.h" + +/**************************************************************************** + * Platform definitions + *****************************************************************************/ + +// Memory map +#define CLINT_CTRL_ADDR _AC(0x02000000,UL) +#define CLIC_HART0_ADDR _AC(0x02800000, UL) +#define GPIO_CTRL_ADDR _AC(0x20002000,UL) +#define PWM0_CTRL_ADDR _AC(0x20005000,UL) +#define RAM_MEM_ADDR _AC(0x80000000,UL) +#define RAM_MEM_SIZE _AC(0x10000,UL) +#define SPI0_CTRL_ADDR _AC(0x20004000,UL) +#define SPI0_MEM_ADDR _AC(0x40000000,UL) +#define SPI0_MEM_SIZE _AC(0x20000000,UL) +#define TESTBENCH_MEM_ADDR _AC(0x20000000,UL) +#define TESTBENCH_MEM_SIZE _AC(0x10000000,UL) +//#define TRAPVEC_TABLE_CTRL_ADDR _AC(0x00001010,UL) +#define UART0_CTRL_ADDR _AC(0x20000000,UL) + +// IOF masks + +// Interrupt numbers +#define RESERVED_INT_BASE 0 +#define UART0_INT_BASE 1 +#define EXTERNAL_INT_BASE 2 +#define SPI0_INT_BASE 6 +#define GPIO_INT_BASE 7 +#define PWM0_INT_BASE 23 + +// Helper functions +#define _REG64(p, i) (*(volatile uint64_t *)((p) + (i))) +#define _REG32(p, i) (*(volatile uint32_t *)((p) + (i))) +#define _REG16(p, i) (*(volatile uint16_t *)((p) + (i))) +#define SET_BITS(reg, mask, value) if ((value) == 0) { (reg) &= ~(mask); } else { (reg) |= (mask); } +#define CLINT_REG(offset) _REG32(CLINT_CTRL_ADDR, offset) +#define CLIC0_REG(offset) _REG32(CLIC_HART0_ADDR, offset) +#define CLIC0_REG8(offset) (*(volatile uint8_t *)((CLIC_HART0_ADDR) + (offset))) +#define GPIO_REG(offset) _REG32(GPIO_CTRL_ADDR, offset) +#define PWM0_REG(offset) _REG32(PWM0_CTRL_ADDR, offset) +#define SPI0_REG(offset) _REG32(SPI0_CTRL_ADDR, offset) +#define UART0_REG(offset) _REG32(UART0_CTRL_ADDR, offset) +#define CLINT_REG(offset) _REG32(CLINT_CTRL_ADDR, offset) +#define CLIC0_REG64(offset) _REG64(CLIC_HART0_ADDR, offset) +#define GPIO_REG64(offset) _REG64(GPIO_CTRL_ADDR, offset) +#define PWM0_REG64(offset) _REG64(PWM0_CTRL_ADDR, offset) +#define SPI0_REG64(offset) _REG64(SPI0_CTRL_ADDR, offset) +#define UART0_REG64(offset) _REG64(UART0_CTRL_ADDR, offset) + +// Misc + +#define NUM_GPIO 16 + +#define CLIC_NUM_INTERRUPTS 28 + 16 +#define CLIC_NUM_CONFIG_BITS 4 //2 for E20 + +#define HAS_BOARD_BUTTONS + +#include "coreplexip-arty.h" + +unsigned long get_cpu_freq(void); +unsigned long get_timer_freq(void); +uint64_t get_timer_value(void); + +#endif /* _SIFIVE_PLATFORM_H */ -- cgit v1.2.1-18-gbd029 From 835b33318a3b350051ef153d382a5980efe19ed6 Mon Sep 17 00:00:00 2001 From: Drew Barbier Date: Mon, 2 Jul 2018 16:04:45 -0500 Subject: update description --- bsp/env/coreip-e2-arty/platform.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bsp/env/coreip-e2-arty/platform.h') diff --git a/bsp/env/coreip-e2-arty/platform.h b/bsp/env/coreip-e2-arty/platform.h index 8ee0a83..6bf2121 100644 --- a/bsp/env/coreip-e2-arty/platform.h +++ b/bsp/env/coreip-e2-arty/platform.h @@ -79,7 +79,7 @@ #define NUM_GPIO 16 #define CLIC_NUM_INTERRUPTS 28 + 16 -#define CLIC_NUM_CONFIG_BITS 4 //2 for E20 +#define CLIC_CONFIG_BITS 0x1E //2 for E20 #define HAS_BOARD_BUTTONS -- cgit v1.2.1-18-gbd029 From 9d58b2120c5a9b9dbc95c0ea90b16280e36dc9ca Mon Sep 17 00:00:00 2001 From: Drew Barbier Date: Mon, 2 Jul 2018 22:48:21 -0500 Subject: short msi handler --- bsp/env/coreip-e2-arty/platform.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bsp/env/coreip-e2-arty/platform.h') diff --git a/bsp/env/coreip-e2-arty/platform.h b/bsp/env/coreip-e2-arty/platform.h index 6bf2121..305726d 100644 --- a/bsp/env/coreip-e2-arty/platform.h +++ b/bsp/env/coreip-e2-arty/platform.h @@ -32,7 +32,7 @@ // Memory map #define CLINT_CTRL_ADDR _AC(0x02000000,UL) -#define CLIC_HART0_ADDR _AC(0x02800000, UL) +#define CLIC_HART0_ADDR _AC(0x02800000,UL) #define GPIO_CTRL_ADDR _AC(0x20002000,UL) #define PWM0_CTRL_ADDR _AC(0x20005000,UL) #define RAM_MEM_ADDR _AC(0x80000000,UL) -- cgit v1.2.1-18-gbd029 From 962b23a3797ba659577056ed3fc57c2d0a77df62 Mon Sep 17 00:00:00 2001 From: Drew Barbier Date: Wed, 4 Jul 2018 18:48:19 -0500 Subject: clic driver level and priority functions --- bsp/env/coreip-e2-arty/platform.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bsp/env/coreip-e2-arty/platform.h') diff --git a/bsp/env/coreip-e2-arty/platform.h b/bsp/env/coreip-e2-arty/platform.h index 305726d..ba06160 100644 --- a/bsp/env/coreip-e2-arty/platform.h +++ b/bsp/env/coreip-e2-arty/platform.h @@ -79,7 +79,7 @@ #define NUM_GPIO 16 #define CLIC_NUM_INTERRUPTS 28 + 16 -#define CLIC_CONFIG_BITS 0x1E //2 for E20 +#define CLIC_CONFIG_BITS 4 #define HAS_BOARD_BUTTONS -- cgit v1.2.1-18-gbd029 From c17273a65d0d2928217d587688f3fe2bea2406e8 Mon Sep 17 00:00:00 2001 From: Drew Barbier Date: Thu, 5 Jul 2018 22:32:56 -0500 Subject: support the E20 --- bsp/env/coreip-e2-arty/platform.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'bsp/env/coreip-e2-arty/platform.h') diff --git a/bsp/env/coreip-e2-arty/platform.h b/bsp/env/coreip-e2-arty/platform.h index ba06160..9ae9864 100644 --- a/bsp/env/coreip-e2-arty/platform.h +++ b/bsp/env/coreip-e2-arty/platform.h @@ -79,7 +79,12 @@ #define NUM_GPIO 16 #define CLIC_NUM_INTERRUPTS 28 + 16 -#define CLIC_CONFIG_BITS 4 + +#ifdef E20 + #define CLIC_CONFIG_BITS 2 +#else + #define CLIC_CONFIG_BITS 4 +#endif #define HAS_BOARD_BUTTONS -- cgit v1.2.1-18-gbd029 From 90968cafb22d81e01a6fd05055df3922215b88a9 Mon Sep 17 00:00:00 2001 From: Drew Barbier Date: Sun, 8 Jul 2018 18:03:30 -0500 Subject: support clint only projects --- bsp/env/coreip-e2-arty/platform.h | 1 + 1 file changed, 1 insertion(+) (limited to 'bsp/env/coreip-e2-arty/platform.h') diff --git a/bsp/env/coreip-e2-arty/platform.h b/bsp/env/coreip-e2-arty/platform.h index 9ae9864..0ce0484 100644 --- a/bsp/env/coreip-e2-arty/platform.h +++ b/bsp/env/coreip-e2-arty/platform.h @@ -21,6 +21,7 @@ #include "sifive/const.h" #include "sifive/devices/gpio.h" +#include "sifive/devices/clint.h" #include "sifive/devices/clic.h" #include "sifive/devices/pwm.h" #include "sifive/devices/spi.h" -- cgit v1.2.1-18-gbd029