Commit 52f36ba1 authored by Russell King's avatar Russell King Committed by Lucas Stach

drm/etnaviv: add helper to extract bitfields

Add a helper to extract etnaviv bitfields from register values.
Acked-by: default avatarChristian Gmeiner <christian.gmeiner@gmail.com>
Signed-off-by: default avatarRussell King <rmk+kernel@arm.linux.org.uk>
Signed-off-by: default avatarLucas Stach <l.stach@pengutronix.de>
parent 507f8991
...@@ -120,6 +120,9 @@ int etnaviv_gpu_get_param(struct etnaviv_gpu *gpu, u32 param, u64 *value) ...@@ -120,6 +120,9 @@ int etnaviv_gpu_get_param(struct etnaviv_gpu *gpu, u32 param, u64 *value)
return 0; return 0;
} }
#define etnaviv_field(val, field) \
(((val) & field##__MASK) >> field##__SHIFT)
static void etnaviv_hw_specs(struct etnaviv_gpu *gpu) static void etnaviv_hw_specs(struct etnaviv_gpu *gpu)
{ {
if (gpu->identity.minor_features0 & if (gpu->identity.minor_features0 &
...@@ -129,37 +132,28 @@ static void etnaviv_hw_specs(struct etnaviv_gpu *gpu) ...@@ -129,37 +132,28 @@ static void etnaviv_hw_specs(struct etnaviv_gpu *gpu)
specs[0] = gpu_read(gpu, VIVS_HI_CHIP_SPECS); specs[0] = gpu_read(gpu, VIVS_HI_CHIP_SPECS);
specs[1] = gpu_read(gpu, VIVS_HI_CHIP_SPECS_2); specs[1] = gpu_read(gpu, VIVS_HI_CHIP_SPECS_2);
gpu->identity.stream_count = gpu->identity.stream_count = etnaviv_field(specs[0],
(specs[0] & VIVS_HI_CHIP_SPECS_STREAM_COUNT__MASK) VIVS_HI_CHIP_SPECS_STREAM_COUNT);
>> VIVS_HI_CHIP_SPECS_STREAM_COUNT__SHIFT; gpu->identity.register_max = etnaviv_field(specs[0],
gpu->identity.register_max = VIVS_HI_CHIP_SPECS_REGISTER_MAX);
(specs[0] & VIVS_HI_CHIP_SPECS_REGISTER_MAX__MASK) gpu->identity.thread_count = etnaviv_field(specs[0],
>> VIVS_HI_CHIP_SPECS_REGISTER_MAX__SHIFT; VIVS_HI_CHIP_SPECS_THREAD_COUNT);
gpu->identity.thread_count = gpu->identity.vertex_cache_size = etnaviv_field(specs[0],
(specs[0] & VIVS_HI_CHIP_SPECS_THREAD_COUNT__MASK) VIVS_HI_CHIP_SPECS_VERTEX_CACHE_SIZE);
>> VIVS_HI_CHIP_SPECS_THREAD_COUNT__SHIFT; gpu->identity.shader_core_count = etnaviv_field(specs[0],
gpu->identity.vertex_cache_size = VIVS_HI_CHIP_SPECS_SHADER_CORE_COUNT);
(specs[0] & VIVS_HI_CHIP_SPECS_VERTEX_CACHE_SIZE__MASK) gpu->identity.pixel_pipes = etnaviv_field(specs[0],
>> VIVS_HI_CHIP_SPECS_VERTEX_CACHE_SIZE__SHIFT; VIVS_HI_CHIP_SPECS_PIXEL_PIPES);
gpu->identity.shader_core_count =
(specs[0] & VIVS_HI_CHIP_SPECS_SHADER_CORE_COUNT__MASK)
>> VIVS_HI_CHIP_SPECS_SHADER_CORE_COUNT__SHIFT;
gpu->identity.pixel_pipes =
(specs[0] & VIVS_HI_CHIP_SPECS_PIXEL_PIPES__MASK)
>> VIVS_HI_CHIP_SPECS_PIXEL_PIPES__SHIFT;
gpu->identity.vertex_output_buffer_size = gpu->identity.vertex_output_buffer_size =
(specs[0] & VIVS_HI_CHIP_SPECS_VERTEX_OUTPUT_BUFFER_SIZE__MASK) etnaviv_field(specs[0],
>> VIVS_HI_CHIP_SPECS_VERTEX_OUTPUT_BUFFER_SIZE__SHIFT; VIVS_HI_CHIP_SPECS_VERTEX_OUTPUT_BUFFER_SIZE);
gpu->identity.buffer_size = gpu->identity.buffer_size = etnaviv_field(specs[1],
(specs[1] & VIVS_HI_CHIP_SPECS_2_BUFFER_SIZE__MASK) VIVS_HI_CHIP_SPECS_2_BUFFER_SIZE);
>> VIVS_HI_CHIP_SPECS_2_BUFFER_SIZE__SHIFT; gpu->identity.instruction_count = etnaviv_field(specs[1],
gpu->identity.instruction_count = VIVS_HI_CHIP_SPECS_2_INSTRUCTION_COUNT);
(specs[1] & VIVS_HI_CHIP_SPECS_2_INSTRUCTION_COUNT__MASK) gpu->identity.num_constants = etnaviv_field(specs[1],
>> VIVS_HI_CHIP_SPECS_2_INSTRUCTION_COUNT__SHIFT; VIVS_HI_CHIP_SPECS_2_NUM_CONSTANTS);
gpu->identity.num_constants =
(specs[1] & VIVS_HI_CHIP_SPECS_2_NUM_CONSTANTS__MASK)
>> VIVS_HI_CHIP_SPECS_2_NUM_CONSTANTS__SHIFT;
} }
/* Fill in the stream count if not specified */ /* Fill in the stream count if not specified */
...@@ -251,12 +245,10 @@ static void etnaviv_hw_identify(struct etnaviv_gpu *gpu) ...@@ -251,12 +245,10 @@ static void etnaviv_hw_identify(struct etnaviv_gpu *gpu)
chipIdentity = gpu_read(gpu, VIVS_HI_CHIP_IDENTITY); chipIdentity = gpu_read(gpu, VIVS_HI_CHIP_IDENTITY);
/* Special case for older graphic cores. */ /* Special case for older graphic cores. */
if (((chipIdentity & VIVS_HI_CHIP_IDENTITY_FAMILY__MASK) if (etnaviv_field(chipIdentity, VIVS_HI_CHIP_IDENTITY_FAMILY) == 0x01) {
>> VIVS_HI_CHIP_IDENTITY_FAMILY__SHIFT) == 0x01) {
gpu->identity.model = chipModel_GC500; gpu->identity.model = chipModel_GC500;
gpu->identity.revision = gpu->identity.revision = etnaviv_field(chipIdentity,
(chipIdentity & VIVS_HI_CHIP_IDENTITY_REVISION__MASK) VIVS_HI_CHIP_IDENTITY_REVISION);
>> VIVS_HI_CHIP_IDENTITY_REVISION__SHIFT;
} else { } else {
gpu->identity.model = gpu_read(gpu, VIVS_HI_CHIP_MODEL); gpu->identity.model = gpu_read(gpu, VIVS_HI_CHIP_MODEL);
......
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