Commit 76da73f0 authored by Lijo Lazar's avatar Lijo Lazar Committed by Alex Deucher

drm/amdgpu: Add sysfs attribute to get board info

Add a sysfs attribute which shows the board form factor like OAM or
CEM.
Signed-off-by: default avatarLijo Lazar <lijo.lazar@amd.com>
Reviewed-by: default avatarAlex Deucher <alexander.deucher@amd.com>
Reviewed-by: default avatarHawking Zhang <Hawking.Zhang@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent b0a45533
...@@ -162,6 +162,58 @@ static ssize_t amdgpu_device_get_pcie_replay_count(struct device *dev, ...@@ -162,6 +162,58 @@ static ssize_t amdgpu_device_get_pcie_replay_count(struct device *dev,
static DEVICE_ATTR(pcie_replay_count, 0444, static DEVICE_ATTR(pcie_replay_count, 0444,
amdgpu_device_get_pcie_replay_count, NULL); amdgpu_device_get_pcie_replay_count, NULL);
static ssize_t amdgpu_device_get_board_info(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);
enum amdgpu_pkg_type pkg_type = AMDGPU_PKG_TYPE_CEM;
const char *pkg;
if (adev->smuio.funcs && adev->smuio.funcs->get_pkg_type)
pkg_type = adev->smuio.funcs->get_pkg_type(adev);
switch (pkg_type) {
case AMDGPU_PKG_TYPE_CEM:
pkg = "cem";
break;
case AMDGPU_PKG_TYPE_OAM:
pkg = "oam";
break;
default:
pkg = "unknown";
break;
}
return sysfs_emit(buf, "%s : %s\n", "type", pkg);
}
static DEVICE_ATTR(board_info, 0444, amdgpu_device_get_board_info, NULL);
static struct attribute *amdgpu_board_attrs[] = {
&dev_attr_board_info.attr,
NULL,
};
static umode_t amdgpu_board_attrs_is_visible(struct kobject *kobj,
struct attribute *attr, int n)
{
struct device *dev = kobj_to_dev(kobj);
struct drm_device *ddev = dev_get_drvdata(dev);
struct amdgpu_device *adev = drm_to_adev(ddev);
if (adev->flags & AMD_IS_APU)
return 0;
return attr->mode;
}
static const struct attribute_group amdgpu_board_attrs_group = {
.attrs = amdgpu_board_attrs,
.is_visible = amdgpu_board_attrs_is_visible
};
static void amdgpu_device_get_pcie_info(struct amdgpu_device *adev); static void amdgpu_device_get_pcie_info(struct amdgpu_device *adev);
...@@ -4038,6 +4090,11 @@ int amdgpu_device_init(struct amdgpu_device *adev, ...@@ -4038,6 +4090,11 @@ int amdgpu_device_init(struct amdgpu_device *adev,
if (r) if (r)
dev_err(adev->dev, "Could not create amdgpu device attr\n"); dev_err(adev->dev, "Could not create amdgpu device attr\n");
r = devm_device_add_group(adev->dev, &amdgpu_board_attrs_group);
if (r)
dev_err(adev->dev,
"Could not create amdgpu board attributes\n");
amdgpu_fru_sysfs_init(adev); amdgpu_fru_sysfs_init(adev);
if (IS_ENABLED(CONFIG_PERF_EVENTS)) if (IS_ENABLED(CONFIG_PERF_EVENTS))
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment