Skip to content

Commit 6246059

Browse files
committed
drm/amdgpu: simplify amdgpu_ras_eeprom.c
All chips that support RAS also support IP discovery, so use the IP versions rather than a mix of IP versions and asic types. Checking the validity of the atom_ctx pointer is not required as the vbios is already fetched at this point. v2: add comments to id asic types based on feedback from Luben Reviewed-by: Luben Tuikov <luben.tuikov@amd.com> Signed-off-by: Alex Deucher <alexander.deucher@amd.com> Cc: Luben Tuikov <luben.tuikov@amd.com>
1 parent 2748868 commit 6246059

1 file changed

Lines changed: 20 additions & 52 deletions

File tree

drivers/gpu/drm/amd/amdgpu/amdgpu_ras_eeprom.c

Lines changed: 20 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -106,48 +106,13 @@
106106
#define to_amdgpu_device(x) (container_of(x, struct amdgpu_ras, eeprom_control))->adev
107107

108108
static bool __is_ras_eeprom_supported(struct amdgpu_device *adev)
109-
{
110-
if (adev->asic_type == CHIP_IP_DISCOVERY) {
111-
switch (adev->ip_versions[MP1_HWIP][0]) {
112-
case IP_VERSION(13, 0, 0):
113-
case IP_VERSION(13, 0, 10):
114-
return true;
115-
default:
116-
return false;
117-
}
118-
}
119-
120-
return adev->asic_type == CHIP_VEGA20 ||
121-
adev->asic_type == CHIP_ARCTURUS ||
122-
adev->asic_type == CHIP_SIENNA_CICHLID ||
123-
adev->asic_type == CHIP_ALDEBARAN;
124-
}
125-
126-
static bool __get_eeprom_i2c_addr_arct(struct amdgpu_device *adev,
127-
struct amdgpu_ras_eeprom_control *control)
128-
{
129-
struct atom_context *atom_ctx = adev->mode_info.atom_context;
130-
131-
if (!control || !atom_ctx)
132-
return false;
133-
134-
if (strnstr(atom_ctx->vbios_version,
135-
"D342",
136-
sizeof(atom_ctx->vbios_version)))
137-
control->i2c_address = EEPROM_I2C_MADDR_0;
138-
else
139-
control->i2c_address = EEPROM_I2C_MADDR_4;
140-
141-
return true;
142-
}
143-
144-
static bool __get_eeprom_i2c_addr_ip_discovery(struct amdgpu_device *adev,
145-
struct amdgpu_ras_eeprom_control *control)
146109
{
147110
switch (adev->ip_versions[MP1_HWIP][0]) {
111+
case IP_VERSION(11, 0, 2): /* VEGA20 and ARCTURUS */
112+
case IP_VERSION(11, 0, 7): /* Sienna cichlid */
148113
case IP_VERSION(13, 0, 0):
114+
case IP_VERSION(13, 0, 2): /* Aldebaran */
149115
case IP_VERSION(13, 0, 10):
150-
control->i2c_address = EEPROM_I2C_MADDR_4;
151116
return true;
152117
default:
153118
return false;
@@ -178,29 +143,32 @@ static bool __get_eeprom_i2c_addr(struct amdgpu_device *adev,
178143
return true;
179144
}
180145

181-
switch (adev->asic_type) {
182-
case CHIP_VEGA20:
183-
control->i2c_address = EEPROM_I2C_MADDR_0;
146+
switch (adev->ip_versions[MP1_HWIP][0]) {
147+
case IP_VERSION(11, 0, 2):
148+
/* VEGA20 and ARCTURUS */
149+
if (adev->asic_type == CHIP_VEGA20)
150+
control->i2c_address = EEPROM_I2C_MADDR_0;
151+
else if (strnstr(atom_ctx->vbios_version,
152+
"D342",
153+
sizeof(atom_ctx->vbios_version)))
154+
control->i2c_address = EEPROM_I2C_MADDR_0;
155+
else
156+
control->i2c_address = EEPROM_I2C_MADDR_4;
184157
return true;
185-
186-
case CHIP_ARCTURUS:
187-
return __get_eeprom_i2c_addr_arct(adev, control);
188-
189-
case CHIP_SIENNA_CICHLID:
158+
case IP_VERSION(11, 0, 7):
190159
control->i2c_address = EEPROM_I2C_MADDR_0;
191160
return true;
192-
193-
case CHIP_ALDEBARAN:
161+
case IP_VERSION(13, 0, 2):
194162
if (strnstr(atom_ctx->vbios_version, "D673",
195163
sizeof(atom_ctx->vbios_version)))
196164
control->i2c_address = EEPROM_I2C_MADDR_4;
197165
else
198166
control->i2c_address = EEPROM_I2C_MADDR_0;
199167
return true;
200-
201-
case CHIP_IP_DISCOVERY:
202-
return __get_eeprom_i2c_addr_ip_discovery(adev, control);
203-
168+
case IP_VERSION(13, 0, 0):
169+
case IP_VERSION(13, 0, 10):
170+
control->i2c_address = EEPROM_I2C_MADDR_4;
171+
return true;
204172
default:
205173
return false;
206174
}

0 commit comments

Comments
 (0)