drm/amd/amdgpu: Simplify bitfield operations in gfx v8
authorTom St Denis <tom.stdenis@amd.com>
Tue, 9 Aug 2016 14:13:21 +0000 (10:13 -0400)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 10 Aug 2016 18:05:08 +0000 (14:05 -0400)
commit61cb8cef526d238de2ff278d9e562a6239d8f98a
treebe9f2be7b713ac186dbda7a84b60b0250079ab2b
parent5003f2785a20d9caf4040d9d9039644f6ee41892
drm/amd/amdgpu: Simplify bitfield operations in gfx v8

This patch introduces a new macro WREG32_FIELD which is used
to write to a register with a new value in a field.  It's designed
to replace the pattern:

tmp = RREG32(mmFoo);
tmp &= ~REG__FIELD_MASK;
tmp |= new_value << REG__FIELD__SHIFT;
WREG32(mmFoo, tmp)

with:

WREG32_FIELD(Foo, FIELD, new_value);

Unlike WREG32_P() it understands offsets/masks and doesn't
require the caller to shift the value (or mask properly).

It's applied where suitable in the gfx_v8_0.c driver to start
with.

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu.h
drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c