aboutsummaryrefslogtreecommitdiff
path: root/stm-fmc.h
diff options
context:
space:
mode:
Diffstat (limited to 'stm-fmc.h')
-rw-r--r--stm-fmc.h33
1 files changed, 20 insertions, 13 deletions
diff --git a/stm-fmc.h b/stm-fmc.h
index 8c37bd7..e9b5749 100644
--- a/stm-fmc.h
+++ b/stm-fmc.h
@@ -4,6 +4,8 @@
* Functions to set up and use the FMC bus.
*
* Copyright (c) 2015, NORDUnet A/S All rights reserved.
+ * Copyright: 2020, The Commons Conservancy Cryptech Project
+ * SPDX-License-Identifier: BSD-3-Clause
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
@@ -15,9 +17,9 @@
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
- * - Neither the name of the NORDUnet nor the names of its contributors may
- * be used to endorse or promote products derived from this software
- * without specific prior written permission.
+ * - Neither the name of the copyright holder nor the names of its
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
@@ -39,12 +41,6 @@
#define FMC_FPGA_BASE_ADDR 0x60000000
#define FMC_FPGA_ADDR_MASK 0x03FFFFFC // there are 26 physical lines, but "only" 24 usable for now
-#define FMC_FPGA_NWAIT_MAX_POLL_TICKS 10
-
-#define FMC_GPIO_PORT_NWAIT GPIOD
-#define FMC_GPIO_PIN_NWAIT GPIO_PIN_6
-
-#define FMC_NWAIT_IDLE GPIO_PIN_SET
#define fmc_af_gpio(port, pins) \
GPIO_InitStruct.Pin = pins; \
@@ -56,10 +52,21 @@
HAL_GPIO_Init(port, &GPIO_InitStruct)
-extern HAL_StatusTypeDef fmc_init(void);
-extern void fmc_init_gpio(void);
+extern void fmc_init(void);
+
+static inline void *fmc_fpga_addr(off_t addr)
+{
+ return (void *)(FMC_FPGA_BASE_ADDR + (addr & FMC_FPGA_ADDR_MASK));
+}
+
+static inline void fmc_write_32(uint32_t addr, uint32_t data)
+{
+ *(uint32_t *)fmc_fpga_addr(addr) = data;
+}
-extern int fmc_write_32(uint32_t addr, uint32_t *data);
-extern int fmc_read_32(uint32_t addr, uint32_t *data);
+static inline void fmc_read_32(uint32_t addr, uint32_t *data)
+{
+ *data = *(uint32_t *)fmc_fpga_addr(addr);
+}
#endif /* __STM_FMC_H */