/* * Copyright 2019 Advanced Micro Devices, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR * OTHER DEALINGS IN THE SOFTWARE. * */ #include <linux/pci.h> #include "amdgpu.h" #include "amdgpu_i2c.h" #include "smu_v11_0_i2c.h" #include "atom.h" #include "amdgpu_fru_eeprom.h" #include "amdgpu_eeprom.h" #define FRU_EEPROM_MADDR_6 … #define FRU_EEPROM_MADDR_8 … static bool is_fru_eeprom_supported(struct amdgpu_device *adev, u32 *fru_addr) { … } int amdgpu_fru_get_product_info(struct amdgpu_device *adev) { … } /** * DOC: product_name * * The amdgpu driver provides a sysfs API for reporting the product name * for the device * The file product_name is used for this and returns the product name * as returned from the FRU. * NOTE: This is only available for certain server cards */ static ssize_t amdgpu_fru_product_name_show(struct device *dev, struct device_attribute *attr, char *buf) { … } static DEVICE_ATTR(product_name, 0444, amdgpu_fru_product_name_show, NULL); /** * DOC: product_number * * The amdgpu driver provides a sysfs API for reporting the part number * for the device * The file product_number is used for this and returns the part number * as returned from the FRU. * NOTE: This is only available for certain server cards */ static ssize_t amdgpu_fru_product_number_show(struct device *dev, struct device_attribute *attr, char *buf) { … } static DEVICE_ATTR(product_number, 0444, amdgpu_fru_product_number_show, NULL); /** * DOC: serial_number * * The amdgpu driver provides a sysfs API for reporting the serial number * for the device * The file serial_number is used for this and returns the serial number * as returned from the FRU. * NOTE: This is only available for certain server cards */ static ssize_t amdgpu_fru_serial_number_show(struct device *dev, struct device_attribute *attr, char *buf) { … } static DEVICE_ATTR(serial_number, 0444, amdgpu_fru_serial_number_show, NULL); /** * DOC: fru_id * * The amdgpu driver provides a sysfs API for reporting FRU File Id * for the device. * The file fru_id is used for this and returns the File Id value * as returned from the FRU. * NOTE: This is only available for certain server cards */ static ssize_t amdgpu_fru_id_show(struct device *dev, struct device_attribute *attr, char *buf) { … } static DEVICE_ATTR(fru_id, 0444, amdgpu_fru_id_show, NULL); /** * DOC: manufacturer * * The amdgpu driver provides a sysfs API for reporting manufacturer name from * FRU information. * The file manufacturer returns the value as returned from the FRU. * NOTE: This is only available for certain server cards */ static ssize_t amdgpu_fru_manufacturer_name_show(struct device *dev, struct device_attribute *attr, char *buf) { … } static DEVICE_ATTR(manufacturer, 0444, amdgpu_fru_manufacturer_name_show, NULL); static const struct attribute *amdgpu_fru_attributes[] = …; int amdgpu_fru_sysfs_init(struct amdgpu_device *adev) { … } void amdgpu_fru_sysfs_fini(struct amdgpu_device *adev) { … }