[PATCH v1 01/44] dmaengine: sdxi: cache hardware version for feature gating
From: Wei Huang
Date: Thu Nov 19 2026 - 15:27:47 EST
Cache the SDXI version reported by MMIO_VERSION and add a small
comparison helper for later feature gating. This prepares the core
for SDXI HW discovery without changing existing behavior.
Co-developed-by: Nathan Lynch <nathan.lynch@xxxxxxx>
Signed-off-by: Nathan Lynch <nathan.lynch@xxxxxxx>
Signed-off-by: Wei Huang <wei.huang2@xxxxxxx>
---
drivers/dma/sdxi/device.c | 9 ++++++---
drivers/dma/sdxi/sdxi.h | 9 +++++++++
drivers/dma/sdxi/version.h | 32 ++++++++++++++++++++++++++++++++
3 files changed, 47 insertions(+), 3 deletions(-)
create mode 100644 drivers/dma/sdxi/version.h
diff --git a/drivers/dma/sdxi/device.c b/drivers/dma/sdxi/device.c
index 265ebea1e350..e3fa39ee9988 100644
--- a/drivers/dma/sdxi/device.c
+++ b/drivers/dma/sdxi/device.c
@@ -326,9 +326,12 @@ static int sdxi_fn_activate(struct sdxi_dev *sdxi)
int err;
version = sdxi_read64(sdxi, SDXI_MMIO_VERSION);
- dev_info(sdxi->dev, "SDXI %llu.%llu device found\n",
- FIELD_GET(SDXI_MMIO_VERSION_MAJOR, version),
- FIELD_GET(SDXI_MMIO_VERSION_MINOR, version));
+ sdxi->sdxi_version = (struct sdxi_version) {
+ .major = FIELD_GET(SDXI_MMIO_VERSION_MAJOR, version),
+ .minor = FIELD_GET(SDXI_MMIO_VERSION_MINOR, version),
+ };
+ dev_info(sdxi->dev, "SDXI %u.%u device found\n",
+ sdxi->sdxi_version.major, sdxi->sdxi_version.minor);
/* Read capabilities and features. */
cap0 = sdxi_read64(sdxi, SDXI_MMIO_CAP0);
diff --git a/drivers/dma/sdxi/sdxi.h b/drivers/dma/sdxi/sdxi.h
index 07044d837d9a..0bc08fc6ae75 100644
--- a/drivers/dma/sdxi/sdxi.h
+++ b/drivers/dma/sdxi/sdxi.h
@@ -17,6 +17,7 @@
#include <linux/xarray.h>
#include "mmio.h"
+#include "version.h"
#define ID_TO_L1_INDEX(id) ((id) & 0x7F)
@@ -66,6 +67,8 @@ struct sdxi_dev {
void __iomem *ctrl_regs; /* virt addr of ctrl registers */
void __iomem *dbs; /* virt addr of doorbells */
+ struct sdxi_version sdxi_version;
+
/* hardware capabilities (from cap0 & cap1) */
u32 db_stride; /* doorbell stride in bytes */
u16 max_cxtid; /* Maximum context ID allowed. */
@@ -90,6 +93,12 @@ struct sdxi_dev {
const struct sdxi_bus_ops *bus_ops;
};
+static inline bool sdxi_dev_compatible(const struct sdxi_dev *sdxi,
+ struct sdxi_version version)
+{
+ return sdxi_version_ge(sdxi->sdxi_version, version);
+}
+
/**
* sdxi_alloc_vector() - Allocate an interrupt vector.
*
diff --git a/drivers/dma/sdxi/version.h b/drivers/dma/sdxi/version.h
new file mode 100644
index 000000000000..79a9c996335f
--- /dev/null
+++ b/drivers/dma/sdxi/version.h
@@ -0,0 +1,32 @@
+/* SPDX-License-Identifier: GPL-2.0-only */
+/*
+ * SDXI version constants and comparison helpers.
+ *
+ * Copyright Advanced Micro Devices, Inc.
+ */
+
+#ifndef DMA_SDXI_VERSION_H
+#define DMA_SDXI_VERSION_H
+
+#include <linux/types.h>
+
+struct sdxi_version {
+ u8 major;
+ u8 minor;
+};
+
+#define SDXI_VERSION_1_0 ((struct sdxi_version){ .major = 1, .minor = 0 })
+#define SDXI_VERSION_1_1 ((struct sdxi_version){ .major = 1, .minor = 1 })
+
+static inline u16 sdxi_version_as_u16(struct sdxi_version version)
+{
+ return (version.major << 8) | version.minor;
+}
+
+static inline bool sdxi_version_ge(struct sdxi_version version,
+ struct sdxi_version minimum)
+{
+ return sdxi_version_as_u16(version) >= sdxi_version_as_u16(minimum);
+}
+
+#endif /* DMA_SDXI_VERSION_H */
--
2.56.1