drm/amdgpu/atomfirmware: implement vram_width for APUs
authorAlex Deucher <alexander.deucher@amd.com>
Wed, 5 Jul 2017 19:26:48 +0000 (15:26 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Fri, 14 Jul 2017 15:06:18 +0000 (11:06 -0400)
Implement support using the new atomfirmware system info table.

Reviewed-by: Hawking Zhang <Hawking.Zhang@amd.com>
Acked-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.c
drivers/gpu/drm/amd/amdgpu/amdgpu_atomfirmware.h

index 9ddfe34d12afd1022460c087a389e69e721c234c..a7d65f0338834c41d4474daae4ff25b254d4d9bf 100644 (file)
@@ -95,3 +95,36 @@ int amdgpu_atomfirmware_allocate_fb_scratch(struct amdgpu_device *adev)
        ctx->scratch_size_bytes = usage_bytes;
        return 0;
 }
+
+union igp_info {
+       struct atom_integrated_system_info_v1_11 v11;
+};
+
+/*
+ * Return vram width from integrated system info table, if available,
+ * or 0 if not.
+ */
+int amdgpu_atomfirmware_get_vram_width(struct amdgpu_device *adev)
+{
+       struct amdgpu_mode_info *mode_info = &adev->mode_info;
+       int index = get_index_into_master_table(atom_master_list_of_data_tables_v2_1,
+                                               integratedsysteminfo);
+       u16 data_offset, size;
+       union igp_info *igp_info;
+       u8 frev, crev;
+
+       /* get any igp specific overrides */
+       if (amdgpu_atom_parse_data_header(mode_info->atom_context, index, &size,
+                                  &frev, &crev, &data_offset)) {
+               igp_info = (union igp_info *)
+                       (mode_info->atom_context->bios + data_offset);
+               switch (crev) {
+               case 11:
+                       return igp_info->v11.umachannelnumber * 64;
+               default:
+                       return 0;
+               }
+       }
+
+       return 0;
+}
index 907e48f6b301ee800892c56a10d81d1f1eebb633..cedafbb9183e89a2ffe18180d2e11270997f14d0 100644 (file)
@@ -27,5 +27,6 @@
 bool amdgpu_atomfirmware_gpu_supports_virtualization(struct amdgpu_device *adev);
 void amdgpu_atomfirmware_scratch_regs_init(struct amdgpu_device *adev);
 int amdgpu_atomfirmware_allocate_fb_scratch(struct amdgpu_device *adev);
+int amdgpu_atomfirmware_get_vram_width(struct amdgpu_device *adev);
 
 #endif