mirror of
https://github.com/torvalds/linux.git
synced 2025-11-04 18:49:34 +02:00
drm/amdgpu: Add vbios build number interface
Fetch VBIOS build number from atom rom image. Add a sysfs interface to read the build number. Signed-off-by: Lijo Lazar <lijo.lazar@amd.com> Acked-by: Alex Deucher <alexander.deucher@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
This commit is contained in:
parent
c5f4fb4058
commit
d6fa802661
3 changed files with 54 additions and 3 deletions
|
|
@ -1816,16 +1816,43 @@ static ssize_t amdgpu_atombios_get_vbios_version(struct device *dev,
|
||||||
return sysfs_emit(buf, "%s\n", ctx->vbios_pn);
|
return sysfs_emit(buf, "%s\n", ctx->vbios_pn);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static ssize_t amdgpu_atombios_get_vbios_build(struct device *dev,
|
||||||
|
struct device_attribute *attr,
|
||||||
|
char *buf)
|
||||||
|
{
|
||||||
|
struct drm_device *ddev = dev_get_drvdata(dev);
|
||||||
|
struct amdgpu_device *adev = drm_to_adev(ddev);
|
||||||
|
struct atom_context *ctx = adev->mode_info.atom_context;
|
||||||
|
|
||||||
|
return sysfs_emit(buf, "%s\n", ctx->build_num);
|
||||||
|
}
|
||||||
|
|
||||||
static DEVICE_ATTR(vbios_version, 0444, amdgpu_atombios_get_vbios_version,
|
static DEVICE_ATTR(vbios_version, 0444, amdgpu_atombios_get_vbios_version,
|
||||||
NULL);
|
NULL);
|
||||||
|
static DEVICE_ATTR(vbios_build, 0444, amdgpu_atombios_get_vbios_build, NULL);
|
||||||
|
|
||||||
static struct attribute *amdgpu_vbios_version_attrs[] = {
|
static struct attribute *amdgpu_vbios_version_attrs[] = {
|
||||||
&dev_attr_vbios_version.attr,
|
&dev_attr_vbios_version.attr, &dev_attr_vbios_build.attr, NULL
|
||||||
NULL
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static umode_t amdgpu_vbios_version_attrs_is_visible(struct kobject *kobj,
|
||||||
|
struct attribute *attr,
|
||||||
|
int index)
|
||||||
|
{
|
||||||
|
struct device *dev = kobj_to_dev(kobj);
|
||||||
|
struct drm_device *ddev = dev_get_drvdata(dev);
|
||||||
|
struct amdgpu_device *adev = drm_to_adev(ddev);
|
||||||
|
struct atom_context *ctx = adev->mode_info.atom_context;
|
||||||
|
|
||||||
|
if (attr == &dev_attr_vbios_build.attr && !strlen(ctx->build_num))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
return attr->mode;
|
||||||
|
}
|
||||||
|
|
||||||
const struct attribute_group amdgpu_vbios_version_attr_group = {
|
const struct attribute_group amdgpu_vbios_version_attr_group = {
|
||||||
.attrs = amdgpu_vbios_version_attrs
|
.attrs = amdgpu_vbios_version_attrs,
|
||||||
|
.is_visible = amdgpu_vbios_version_attrs_is_visible,
|
||||||
};
|
};
|
||||||
|
|
||||||
int amdgpu_atombios_sysfs_init(struct amdgpu_device *adev)
|
int amdgpu_atombios_sysfs_init(struct amdgpu_device *adev)
|
||||||
|
|
|
||||||
|
|
@ -1494,6 +1494,27 @@ static void atom_get_vbios_version(struct atom_context *ctx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void atom_get_vbios_build(struct atom_context *ctx)
|
||||||
|
{
|
||||||
|
unsigned char *atom_rom_hdr;
|
||||||
|
unsigned char *str;
|
||||||
|
uint16_t base;
|
||||||
|
|
||||||
|
base = CU16(ATOM_ROM_TABLE_PTR);
|
||||||
|
atom_rom_hdr = CSTR(base);
|
||||||
|
|
||||||
|
str = CSTR(CU16(base + ATOM_ROM_CFG_PTR));
|
||||||
|
/* Skip config string */
|
||||||
|
while (str < atom_rom_hdr && *str++)
|
||||||
|
;
|
||||||
|
/* Skip change list string */
|
||||||
|
while (str < atom_rom_hdr && *str++)
|
||||||
|
;
|
||||||
|
|
||||||
|
if ((str + STRLEN_NORMAL) < atom_rom_hdr)
|
||||||
|
strscpy(ctx->build_num, str, STRLEN_NORMAL);
|
||||||
|
}
|
||||||
|
|
||||||
struct atom_context *amdgpu_atom_parse(struct card_info *card, void *bios)
|
struct atom_context *amdgpu_atom_parse(struct card_info *card, void *bios)
|
||||||
{
|
{
|
||||||
int base;
|
int base;
|
||||||
|
|
@ -1554,6 +1575,7 @@ struct atom_context *amdgpu_atom_parse(struct card_info *card, void *bios)
|
||||||
atom_get_vbios_pn(ctx);
|
atom_get_vbios_pn(ctx);
|
||||||
atom_get_vbios_date(ctx);
|
atom_get_vbios_date(ctx);
|
||||||
atom_get_vbios_version(ctx);
|
atom_get_vbios_version(ctx);
|
||||||
|
atom_get_vbios_build(ctx);
|
||||||
|
|
||||||
return ctx;
|
return ctx;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -37,6 +37,7 @@ struct drm_device;
|
||||||
#define ATOM_ROM_MAGIC "ATOM"
|
#define ATOM_ROM_MAGIC "ATOM"
|
||||||
#define ATOM_ROM_MAGIC_PTR 4
|
#define ATOM_ROM_MAGIC_PTR 4
|
||||||
|
|
||||||
|
#define ATOM_ROM_CFG_PTR 0xC
|
||||||
#define ATOM_ROM_MSG_PTR 0x10
|
#define ATOM_ROM_MSG_PTR 0x10
|
||||||
#define ATOM_ROM_CMD_PTR 0x1E
|
#define ATOM_ROM_CMD_PTR 0x1E
|
||||||
#define ATOM_ROM_DATA_PTR 0x20
|
#define ATOM_ROM_DATA_PTR 0x20
|
||||||
|
|
@ -151,6 +152,7 @@ struct atom_context {
|
||||||
uint32_t version;
|
uint32_t version;
|
||||||
uint8_t vbios_ver_str[STRLEN_NORMAL];
|
uint8_t vbios_ver_str[STRLEN_NORMAL];
|
||||||
uint8_t date[STRLEN_NORMAL];
|
uint8_t date[STRLEN_NORMAL];
|
||||||
|
uint8_t build_num[STRLEN_NORMAL];
|
||||||
};
|
};
|
||||||
|
|
||||||
extern int amdgpu_atom_debug;
|
extern int amdgpu_atom_debug;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue