summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niewöhner <foss@mniewoehner.de>2019-11-03 10:26:04 +0100
committerPatrick Georgi <pgeorgi@google.com>2019-11-11 10:26:55 +0000
commitf0564a9c44b79e9bfb1001f887348a653f7b7d56 (patch)
treefcbf57cd12c4ccf33e6528025f975c03b0eb8350
parente919390f4735a762234630ab7e0807c14de45421 (diff)
include: introduce update* for mmio operations
Introduce update* as equivalent of pci_update* for mmio operations. Change-Id: I9f188d586c09ee9f1e17290563f68970603204fb Signed-off-by: Michael Niewöhner <foss@mniewoehner.de> Reviewed-on: https://review.coreboot.org/c/coreboot/+/36596 Reviewed-by: Aaron Durbin <adurbin@chromium.org> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
-rw-r--r--src/include/mmio.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/include/mmio.h b/src/include/mmio.h
new file mode 100644
index 0000000000..4f2c806cac
--- /dev/null
+++ b/src/include/mmio.h
@@ -0,0 +1,45 @@
+/*
+ * This file is part of the coreboot project.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ */
+
+/*
+ * mmio.h provides update*() as well as read/write*() from arch/mmio.h
+ */
+
+#ifndef __MMIO_H__
+#define __MMIO_H__
+
+#include <arch/mmio.h>
+#include <stdint.h>
+
+static __always_inline void update8(volatile void *addr, uint8_t mask, uint8_t or)
+{
+ uint8_t reg = read8(addr);
+ reg = (reg & mask) | or;
+ write8(addr, reg);
+}
+
+static __always_inline void update16(volatile void *addr, uint16_t mask, uint16_t or)
+{
+ uint16_t reg = read16(addr);
+ reg = (reg & mask) | or;
+ write16(addr, reg);
+}
+
+static __always_inline void update32(volatile void *addr, uint32_t mask, uint32_t or)
+{
+ uint32_t reg = read32(addr);
+ reg = (reg & mask) | or;
+ write32(addr, reg);
+}
+
+#endif /* __MMIO_H__ */