[igt-dev] [PATCH i-g-t v8 2/3] lib/intel_mmio: add funtions for read/write register funtions
Daniel Mrzyglod
daniel.t.mrzyglod at intel.com
Tue Aug 27 13:21:09 UTC 2019
This patch is first move to extend functionality of intel_mmio library.
There was limitation for 1 device, adding pointer for IO functions to
mmaped area gives us possibility to use those IO functions for other mmaped
devices.
v8: remove unnecessary castings
v4: reword commitmsg, spelling errors
Cc: Antonio Argenziano <antonio.argenziano at intel.com>
Cc: Daniele Spurio Ceraolo <daniele.ceraolospurio at intel.com>
Cc: Katarzyna Dec <katarzyna.dec at intel.com>
Cc: Chris Wilson <chris at chris-wilson.co.uk>
Cc: Petri Latvala <petri.latvala at intel.com>
Cc: Zbigniew KempczyĆski <zbigniew.kempczynski at intel.com>
Cc: Jani Nikula <jani.nikula at intel.com>
Signed-off-by: Daniel Mrzyglod <daniel.t.mrzyglod at intel.com>
---
lib/intel_io.h | 7 ++++
lib/intel_mmio.c | 107 +++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 114 insertions(+)
diff --git a/lib/intel_io.h b/lib/intel_io.h
index 6014c485..99cb1829 100644
--- a/lib/intel_io.h
+++ b/lib/intel_io.h
@@ -49,6 +49,13 @@ void OUTREG(uint32_t reg, uint32_t val);
void OUTREG16(uint32_t reg, uint16_t val);
void OUTREG8(uint32_t reg, uint8_t val);
+uint32_t INREG_DEV(void *igt_mmio, uint32_t reg);
+uint16_t INREG16_DEV(void *igt_mmio, uint32_t reg);
+uint8_t INREG8_DEV(void *igt_mmio, uint32_t reg);
+void OUTREG_DEV(void *igt_mmio, uint32_t reg, uint32_t val);
+void OUTREG16_DEV(void *igt_mmio, uint32_t reg, uint16_t val);
+void OUTREG8_DEV(void *igt_mmio, uint32_t reg, uint8_t val);
+
/* sideband access functions from intel_iosf.c */
uint32_t intel_dpio_reg_read(uint32_t reg, int phy);
void intel_dpio_reg_write(uint32_t reg, uint32_t val, int phy);
diff --git a/lib/intel_mmio.c b/lib/intel_mmio.c
index a5458aeb..c257f7a0 100644
--- a/lib/intel_mmio.c
+++ b/lib/intel_mmio.c
@@ -405,3 +405,110 @@ void OUTREG8(uint32_t reg, uint8_t val)
{
*((volatile uint8_t *)igt_global_mmio + reg) = val;
}
+
+
+/**
+ * INREG_DEV:
+ * @igt_mmio maped memory pointer
+ * @reg: register offset
+ *
+ * 32-bit read of the register at offset @reg. This function only works when the
+ * new register access helper is initialized with intel_register_access_init().
+ *
+ * This function directly accesses the igt_mmio without safety checks.
+ *
+ * Returns:
+ * The value read from the register.
+ */
+uint32_t INREG_DEV(void *igt_mmio, uint32_t reg)
+{
+ return *((volatile char *)igt_mmio + reg);
+}
+
+/**
+ * INREG16_DEV:
+ * @igt_mmio maped memory pointer
+ * @reg: register offset
+ *
+ * 16-bit read of the register at offset @reg. This function only works when the
+ * new register access helper is initialized with intel_register_access_init().
+ *
+ * This function directly accesses the igt_mmio without safety checks.
+ *
+ * Returns:
+ * The value read from the register.
+ */
+uint16_t INREG16_DEV(void *igt_mmio, uint32_t reg)
+{
+ return *((volatile char *)igt_mmio + reg);
+}
+
+/**
+ * INREG8_DEV:
+ * @igt_mmio maped memory pointer
+ * @reg: register offset
+ *
+ * 8-bit read of the register at offset @reg. This function only works when the
+ * new register access helper is initialized with intel_register_access_init().
+ *
+ * This function directly accesses the igt_mmio without safety checks.
+ *
+ * Returns:
+ * The value read from the register.
+ */
+uint8_t INREG8_DEV(void *igt_mmio, uint32_t reg)
+{
+ return *((volatile uint8_t *)igt_mmio + reg);
+}
+
+/**
+ * OUTREG_DEV:
+ * @igt_mmio maped memory pointer
+ * @reg: register offset
+ * @val: value to write
+ *
+ * 32-bit write of @val to the register at offset @reg. This function only works
+ * when the new register access helper is initialized with
+ * intel_register_access_init().
+ *
+ * This function directly accesses the igt_mmio without safety checks.
+ */
+void OUTREG_DEV(void *igt_mmio, uint32_t reg, uint32_t val)
+{
+ *(volatile uint32_t *)((volatile char *)igt_mmio + reg) = val;
+}
+
+/**
+ * OUTREG16_DEV:
+ * @igt_mmio maped memory pointer
+ * @reg: register offset
+ * @val: value to write
+ *
+ * 16-bit write of @val to the register at offset @reg. This function only works
+ * when the new register access helper is initialized with
+ * intel_register_access_init().
+ *
+ * This function directly accesses the igt_mmio without safety checks.
+ */
+void OUTREG16_DEV(void *igt_mmio, uint32_t reg, uint16_t val)
+{
+ *(volatile uint16_t *)((volatile char *)igt_mmio + reg) = val;
+}
+
+/**
+ * OUTREG8_DEV:
+ * @igt_mmio maped memory pointer
+ * @reg: register offset
+ * @val: value to write
+ *
+ * 8-bit write of @val to the register at offset @reg. This function only works
+ * when the new register access helper is initialized with
+ * intel_register_access_init().
+ *
+ * This function directly accesses the igt_mmio without safety checks.
+ */
+void OUTREG8_DEV(void *igt_mmio, uint32_t reg, uint8_t val)
+{
+ *((volatile uint8_t *)igt_mmio + reg) = val;
+}
+
--
2.21.0
More information about the igt-dev
mailing list