From 4985206d65941a8790dd720886f180f293077ba7 Mon Sep 17 00:00:00 2001 From: modeco80 Date: Sun, 30 Jul 2023 19:52:12 -0400 Subject: [PATCH] initial commit --- include/lcpu_mmio.h | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 include/lcpu_mmio.h diff --git a/include/lcpu_mmio.h b/include/lcpu_mmio.h new file mode 100644 index 0000000..356db71 --- /dev/null +++ b/include/lcpu_mmio.h @@ -0,0 +1,36 @@ +/* LCPU MMIO device access */ + +#ifndef LCPU_MMIO_H +#define LCPU_MMIO_H + +typedef struct { /* Header registers for the Wire device */ + uint32_t nrInputs; + uint32_t nrOutputs; +} LCPU_WireDevice_Header; + +#define LCPU_WIRE_BASE 0x11310000 +#define LCPU_WIRE_IO_BASE WIRE_BASE + sizeof(LCPU_WireDevice_Header) +#define LCPU_WIRE_OUTPUT_BASE WIRE_IO_BASE + (WIRE_HEADER->nrInputs * sizeof(uint32_t)) + +#define LCPU_WIRE_HEADER ((volatile LCPU_WireDevice_Header*)WIRE_BASE) + +/* retrieve wire input [i] */ +#define LCPU_WIRE_INPUT(i) *(volatile const uint32_t*)(WIRE_IO_BASE + (i * sizeof(uint32_t))) + +/* set wire output [i] */ +#define LCPU_WIRE_OUTPUT(i) *(volatile uint32_t*)(WIRE_OUTPUT_BASE + (i * sizeof(uint32_t))) + +/* syscon device */ +#define LCPU_SYSCON *(volatile uint32_t*)0x11100000 + +/* UART device */ +#define LCPU_UART_BASE 0x10000000 +#define LCPU_UART_DATA *(volatile uint32_t*)UART_BASE +#define LCPU_UART_STATUS UART_DATA + + +/* syscon helpers */ +#define LCPU_REBOOT() LCPU_SYSCON = 0x7777; +#define LCPU_SHUTDOWN() LCPU_SYSCON = 0x5555; + +#endif