Commit 7089dd3c authored by Hawking Zhang's avatar Hawking Zhang Committed by Alex Deucher

drm/amdgpu: support query vram_info v3_0

vram_info table provides various vram information
including vram_vendor, vram_type, vram_width, etc.

v2: correct the calculation of vram_width
Signed-off-by: default avatarHawking Zhang <Hawking.Zhang@amd.com>
Reviewed-by: default avatarLikun Gao <Likun.Gao@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 1a482448
...@@ -162,12 +162,14 @@ union vram_info { ...@@ -162,12 +162,14 @@ union vram_info {
struct atom_vram_info_header_v2_4 v24; struct atom_vram_info_header_v2_4 v24;
struct atom_vram_info_header_v2_5 v25; struct atom_vram_info_header_v2_5 v25;
struct atom_vram_info_header_v2_6 v26; struct atom_vram_info_header_v2_6 v26;
struct atom_vram_info_header_v3_0 v30;
}; };
union vram_module { union vram_module {
struct atom_vram_module_v9 v9; struct atom_vram_module_v9 v9;
struct atom_vram_module_v10 v10; struct atom_vram_module_v10 v10;
struct atom_vram_module_v11 v11; struct atom_vram_module_v11 v11;
struct atom_vram_module_v3_0 v30;
}; };
static int convert_atom_mem_type_to_vram_type(struct amdgpu_device *adev, static int convert_atom_mem_type_to_vram_type(struct amdgpu_device *adev,
...@@ -294,7 +296,28 @@ amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev, ...@@ -294,7 +296,28 @@ amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev,
vram_info = (union vram_info *) vram_info = (union vram_info *)
(mode_info->atom_context->bios + data_offset); (mode_info->atom_context->bios + data_offset);
module_id = (RREG32(adev->bios_scratch_reg_offset + 4) & 0x00ff0000) >> 16; module_id = (RREG32(adev->bios_scratch_reg_offset + 4) & 0x00ff0000) >> 16;
if (frev == 3) {
switch (crev) {
/* v30 */
case 0:
vram_module = (union vram_module *)vram_info->v30.vram_module;
mem_vendor = (vram_module->v30.dram_vendor_id) & 0xF;
if (vram_vendor)
*vram_vendor = mem_vendor;
mem_type = vram_info->v30.memory_type;
if (vram_type)
*vram_type = convert_atom_mem_type_to_vram_type(adev, mem_type);
mem_channel_number = vram_info->v30.channel_num;
mem_channel_width = vram_info->v30.channel_width;
if (vram_width)
*vram_width = mem_channel_number * mem_channel_width;
break;
default:
return -EINVAL;
}
} else if (frev == 2) {
switch (crev) { switch (crev) {
/* v23 */
case 3: case 3:
if (module_id > vram_info->v23.vram_module_num) if (module_id > vram_info->v23.vram_module_num)
module_id = 0; module_id = 0;
...@@ -315,6 +338,7 @@ amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev, ...@@ -315,6 +338,7 @@ amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev,
if (vram_vendor) if (vram_vendor)
*vram_vendor = mem_vendor; *vram_vendor = mem_vendor;
break; break;
/* v24 */
case 4: case 4:
if (module_id > vram_info->v24.vram_module_num) if (module_id > vram_info->v24.vram_module_num)
module_id = 0; module_id = 0;
...@@ -335,6 +359,7 @@ amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev, ...@@ -335,6 +359,7 @@ amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev,
if (vram_vendor) if (vram_vendor)
*vram_vendor = mem_vendor; *vram_vendor = mem_vendor;
break; break;
/* v25 */
case 5: case 5:
if (module_id > vram_info->v25.vram_module_num) if (module_id > vram_info->v25.vram_module_num)
module_id = 0; module_id = 0;
...@@ -355,6 +380,7 @@ amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev, ...@@ -355,6 +380,7 @@ amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev,
if (vram_vendor) if (vram_vendor)
*vram_vendor = mem_vendor; *vram_vendor = mem_vendor;
break; break;
/* v26 */
case 6: case 6:
if (module_id > vram_info->v26.vram_module_num) if (module_id > vram_info->v26.vram_module_num)
module_id = 0; module_id = 0;
...@@ -378,6 +404,10 @@ amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev, ...@@ -378,6 +404,10 @@ amdgpu_atomfirmware_get_vram_info(struct amdgpu_device *adev,
default: default:
return -EINVAL; return -EINVAL;
} }
} else {
/* invalid frev */
return -EINVAL;
}
} }
} }
......
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