This patch provides an initialization framework for multiple Mali GPUs
by introducing a GPU support look-up table. Each entry contains, at
minimum, the architecture major version of the GPU, and may optionally
provide feature flags and register offset overrides.

Signed-off-by: Karunika Choo <karunika.c...@arm.com>
---
 drivers/gpu/drm/panthor/Makefile         |  1 +
 drivers/gpu/drm/panthor/panthor_device.c |  5 ++
 drivers/gpu/drm/panthor/panthor_device.h |  4 ++
 drivers/gpu/drm/panthor/panthor_hw.c     | 65 ++++++++++++++++++++++++
 drivers/gpu/drm/panthor/panthor_hw.h     | 60 ++++++++++++++++++++++
 5 files changed, 135 insertions(+)
 create mode 100644 drivers/gpu/drm/panthor/panthor_hw.c
 create mode 100644 drivers/gpu/drm/panthor/panthor_hw.h

diff --git a/drivers/gpu/drm/panthor/Makefile b/drivers/gpu/drm/panthor/Makefile
index 15294719b09c..02db21748c12 100644
--- a/drivers/gpu/drm/panthor/Makefile
+++ b/drivers/gpu/drm/panthor/Makefile
@@ -8,6 +8,7 @@ panthor-y := \
        panthor_gem.o \
        panthor_gpu.o \
        panthor_heap.o \
+       panthor_hw.o \
        panthor_mmu.o \
        panthor_sched.o
 
diff --git a/drivers/gpu/drm/panthor/panthor_device.c 
b/drivers/gpu/drm/panthor/panthor_device.c
index f0b2da5b2b96..81df49880bd8 100644
--- a/drivers/gpu/drm/panthor/panthor_device.c
+++ b/drivers/gpu/drm/panthor/panthor_device.c
@@ -18,6 +18,7 @@
 #include "panthor_device.h"
 #include "panthor_fw.h"
 #include "panthor_gpu.h"
+#include "panthor_hw.h"
 #include "panthor_mmu.h"
 #include "panthor_regs.h"
 #include "panthor_sched.h"
@@ -244,6 +245,10 @@ int panthor_device_init(struct panthor_device *ptdev)
                        return ret;
        }
 
+       ret = panthor_hw_init(ptdev);
+       if (ret)
+               goto err_rpm_put;
+
        ret = panthor_gpu_init(ptdev);
        if (ret)
                goto err_rpm_put;
diff --git a/drivers/gpu/drm/panthor/panthor_device.h 
b/drivers/gpu/drm/panthor/panthor_device.h
index 340a5ef09477..5b617ab781a5 100644
--- a/drivers/gpu/drm/panthor/panthor_device.h
+++ b/drivers/gpu/drm/panthor/panthor_device.h
@@ -26,6 +26,7 @@ struct panthor_device;
 struct panthor_gpu;
 struct panthor_group_pool;
 struct panthor_heap_pool;
+struct panthor_hw;
 struct panthor_job;
 struct panthor_mmu;
 struct panthor_fw;
@@ -122,6 +123,9 @@ struct panthor_device {
        /** @csif_info: Command stream interface information. */
        struct drm_panthor_csif_info csif_info;
 
+       /** @hw: GPU specific data. */
+       struct panthor_hw *hw;
+
        /** @gpu: GPU management data. */
        struct panthor_gpu *gpu;
 
diff --git a/drivers/gpu/drm/panthor/panthor_hw.c 
b/drivers/gpu/drm/panthor/panthor_hw.c
new file mode 100644
index 000000000000..4dbe23df0c4c
--- /dev/null
+++ b/drivers/gpu/drm/panthor/panthor_hw.c
@@ -0,0 +1,65 @@
+// SPDX-License-Identifier: GPL-2.0 or MIT
+/* Copyright 2025 ARM Limited. All rights reserved. */
+
+#include "panthor_device.h"
+#include "panthor_hw.h"
+#include "panthor_regs.h"
+
+static struct panthor_hw panthor_hw_devices[] = {
+       {
+               .arch_major = 10,
+       },
+};
+
+static int init_gpu_id(struct panthor_device *ptdev)
+{
+       ptdev->gpu_info.gpu_id = gpu_read(ptdev, GPU_ID);
+
+       if (!ptdev->gpu_info.gpu_id) {
+               drm_err(&ptdev->base, "Invalid GPU ID (0x0)");
+               return -ENXIO;
+       }
+
+       return 0;
+}
+
+int panthor_hw_init(struct panthor_device *ptdev)
+{
+       struct panthor_hw *hdev = NULL;
+       u32 arch_major = 0;
+       int i, ret;
+
+       ret = init_gpu_id(ptdev);
+       if (ret)
+               return ret;
+
+       arch_major = GPU_ARCH_MAJOR(ptdev->gpu_info.gpu_id);
+
+       if (!arch_major) {
+               drm_err(&ptdev->base, "Invalid arch_major (0x0)");
+               return -ENXIO;
+       }
+
+       for (i = 0; i < ARRAY_SIZE(panthor_hw_devices); i++) {
+               if (arch_major == panthor_hw_devices[i].arch_major) {
+                       hdev = &panthor_hw_devices[i];
+                       break;
+               }
+       }
+
+       if (!hdev) {
+               drm_err(&ptdev->base, "Unsupported GPU (arch_major 0x%x)",
+                       arch_major);
+               return -ENODEV;
+       }
+
+       ptdev->hw = hdev;
+
+       return 0;
+}
+
+bool panthor_hw_supports(struct panthor_device *ptdev,
+                        enum panthor_hw_feature feature)
+{
+       return test_bit(feature, ptdev->hw->features);
+}
diff --git a/drivers/gpu/drm/panthor/panthor_hw.h 
b/drivers/gpu/drm/panthor/panthor_hw.h
new file mode 100644
index 000000000000..1a3cbc5589fd
--- /dev/null
+++ b/drivers/gpu/drm/panthor/panthor_hw.h
@@ -0,0 +1,60 @@
+/* SPDX-License-Identifier: GPL-2.0 or MIT */
+/* Copyright 2025 ARM Limited. All rights reserved. */
+
+#ifndef __PANTHOR_HW_H__
+#define __PANTHOR_HW_H__
+
+#include <linux/types.h>
+#include <linux/bitmap.h>
+
+struct panthor_device;
+
+/**
+ * enum panthor_hw_feature - Bit position of each HW feature
+ *
+ * Used to define GPU specific features based on the GPU architecture.
+ * New feature flags will be added with support for newer GPU architectures.
+ */
+enum panthor_hw_feature {
+       /** @PANTHOR_HW_FEATURES_END: Must be last. */
+       PANTHOR_HW_FEATURES_END
+};
+
+/**
+ * struct panthor_hw_regmap - Register offsets for specific register blocks
+ */
+struct panthor_hw_regmap {
+
+};
+
+/**
+ * struct panthor_hw_ops - HW operations that are specific to a GPU
+ */
+struct panthor_hw_ops {
+
+};
+
+/**
+ * struct panthor_hw - GPU specific register mapping and functions
+ */
+struct panthor_hw {
+       /** @arch_major: Architecture major to match against */
+       u32 arch_major;
+
+       /** @features: Bitmap containing panthor_hw_feature */
+       DECLARE_BITMAP(features, PANTHOR_HW_FEATURES_END);
+
+       /** @map: Panthor regmap */
+       struct panthor_hw_regmap map;
+
+       /** @ops: Panthor HW specific operations */
+       struct panthor_hw_ops ops;
+};
+
+int panthor_hw_init(struct panthor_device *ptdev);
+
+bool panthor_hw_supports(struct panthor_device *ptdev,
+                        enum panthor_hw_feature feature);
+
+#endif /* __PANTHOR_HW_H__ */
+
-- 
2.49.0

Reply via email to