drm/amdgpu: Access the FRU on Aldebaran
authorKent Russell <kent.russell@amd.com>
Mon, 13 Dec 2021 18:59:43 +0000 (13:59 -0500)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 30 Dec 2021 13:54:43 +0000 (08:54 -0500)
This is supported, although the offset is different from VG20, so fix
that with a variable and enable getting the product name and serial
number from the FRU. Do this for all SKUs since all SKUs have the FRU

Signed-off-by: Kent Russell <kent.russell@amd.com>
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdgpu/amdgpu_fru_eeprom.c

index fdca0a447e749e1087b6def823cf761625c7f7bf..2a786e78862777e41399cd5d6dc9a08fc7583081 100644 (file)
@@ -56,6 +56,9 @@ static bool is_fru_eeprom_supported(struct amdgpu_device *adev)
                        return true;
                else
                        return false;
+       case CHIP_ALDEBARAN:
+               /* All Aldebaran SKUs have the FRU */
+               return true;
        default:
                return false;
        }
@@ -91,10 +94,14 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev)
        unsigned char buff[AMDGPU_PRODUCT_NAME_LEN+2];
        u32 addrptr;
        int size, len;
+       int offset = 2;
 
        if (!is_fru_eeprom_supported(adev))
                return 0;
 
+       if (adev->asic_type == CHIP_ALDEBARAN)
+               offset = 0;
+
        /* If algo exists, it means that the i2c_adapter's initialized */
        if (!adev->pm.smu_i2c.algo) {
                DRM_WARN("Cannot access FRU, EEPROM accessor not initialized");
@@ -137,7 +144,7 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev)
                len = AMDGPU_PRODUCT_NAME_LEN - 1;
        }
        /* Start at 2 due to buff using fields 0 and 1 for the address */
-       memcpy(adev->product_name, &buff[2], len);
+       memcpy(adev->product_name, &buff[offset], len);
        adev->product_name[len] = '\0';
 
        addrptr += size + 1;
@@ -155,7 +162,7 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev)
                DRM_WARN("FRU Product Number is larger than 16 characters. This is likely a mistake");
                len = sizeof(adev->product_number) - 1;
        }
-       memcpy(adev->product_number, &buff[2], len);
+       memcpy(adev->product_number, &buff[offset], len);
        adev->product_number[len] = '\0';
 
        addrptr += size + 1;
@@ -182,7 +189,7 @@ int amdgpu_fru_get_product_info(struct amdgpu_device *adev)
                DRM_WARN("FRU Serial Number is larger than 16 characters. This is likely a mistake");
                len = sizeof(adev->serial) - 1;
        }
-       memcpy(adev->serial, &buff[2], len);
+       memcpy(adev->serial, &buff[offset], len);
        adev->serial[len] = '\0';
 
        return 0;