drm/xe/pcode: Add support to get pcode version from PMT

Add api get_pcode_version() to read pcode version from PMT telemetry.
Add PUNIT_VERSION telemetry offset in xe_pmt.h.

Signed-off-by: Karthik Poosa <karthik.poosa@intel.com>
Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Link: https://patch.msgid.link/20260702092540.1005095-2-karthik.poosa@intel.com
Signed-off-by: Matt Roper <matthew.d.roper@intel.com>
This commit is contained in:
Karthik Poosa
2026-07-02 14:55:39 +05:30
committed by Matt Roper
parent 3a8bfa1f2a
commit f7c05238ab
3 changed files with 41 additions and 0 deletions

View File

@@ -15,6 +15,8 @@
#define ENERGY_PKG REG_GENMASK64(31, 0)
#define ENERGY_CARD REG_GENMASK64(63, 32)
#define PUNIT_VERSION_OFFSET 0xA0
#define BMG_TELEMETRY_BASE_OFFSET 0xE0000
#define BMG_TELEMETRY_OFFSET (SOC_BASE + BMG_TELEMETRY_BASE_OFFSET)

View File

@@ -11,10 +11,14 @@
#include <drm/drm_managed.h>
#include "regs/xe_pmt.h"
#include "xe_assert.h"
#include "xe_device.h"
#include "xe_mmio.h"
#include "xe_pcode_api.h"
#include "xe_pm.h"
#include "xe_printk.h"
#include "xe_vsec.h"
/**
* DOC: PCODE
@@ -350,3 +354,31 @@ int xe_pcode_probe_early(struct xe_device *xe)
return xe_pcode_ready(xe, false);
}
ALLOW_ERROR_INJECTION(xe_pcode_probe_early, ERRNO); /* See xe_pci_probe */
/**
* xe_get_pcode_version - Read pcode version via PMT telemetry
* @xe: xe instance
* @version: pointer to struct xe_pcode_version to store version info
*
* Reads the pcode version from PMT telemetry and fills the
* provided @version structure.
*
* Return: 0 on success, negative error code on failure.
*/
int xe_get_pcode_version(struct xe_device *xe, struct xe_pcode_version *version)
{
int ret = 0;
guard(xe_pm_runtime)(xe);
ret = xe_pmt_telem_read(xe->drm.dev,
xe_mmio_read32(xe_root_tile_mmio(xe), PUNIT_TELEMETRY_GUID),
(u64 *)version, PUNIT_VERSION_OFFSET, sizeof(*version));
if (ret != sizeof(*version)) {
xe_warn(xe, "pcode version read from PMT failed, ret %pe\n", ERR_PTR(ret));
return ret;
}
xe_dbg(xe, "pcode version major %u minor %u engg %u\n", version->major,
version->minor, version->engg);
return 0;
}

View File

@@ -12,6 +12,12 @@ struct drm_device;
struct xe_device;
struct xe_tile;
struct xe_pcode_version {
u16 minor;
u16 major;
u32 engg;
};
int xe_pcode_init_early(struct xe_tile *tile);
int xe_pcode_probe_early(struct xe_device *xe);
int xe_pcode_ready(struct xe_device *xe, bool locked);
@@ -22,6 +28,7 @@ int xe_pcode_write_timeout(struct xe_tile *tile, u32 mbox, u32 val,
int timeout_ms);
int xe_pcode_write64_timeout(struct xe_tile *tile, u32 mbox, u32 data0,
u32 data1, int timeout);
int xe_get_pcode_version(struct xe_device *xe, struct xe_pcode_version *version);
#define xe_pcode_write(tile, mbox, val) \
xe_pcode_write_timeout(tile, mbox, val, 1)