diff --git a/ixr7220h6-64/modules/embd_ctrl.c b/ixr7220h6-64/modules/embd_ctrl.c index 8a6a588..0ce843a 100644 --- a/ixr7220h6-64/modules/embd_ctrl.c +++ b/ixr7220h6-64/modules/embd_ctrl.c @@ -32,6 +32,11 @@ #define CPU_TEMP_REG 0x10 #define MEM0_TEMP_REG 0x12 #define MEM1_TEMP_REG 0x13 +#define DATE_YEAR_REG 0xFB +#define DATE_MONTH_REG 0xFC +#define DATE_DAY_REG 0xFD +#define VER_MAJOR_REG 0xFE +#define VER_MINOR_REG 0xFF static const unsigned short ec_address_list[] = {0x21, I2C_CLIENT_END}; @@ -92,15 +97,41 @@ static ssize_t show_mem1_temperature(struct device *dev, struct device_attribute return sprintf(buf, "%d\n", (s8)val * 1000); } +static ssize_t show_ec_date(struct device *dev, struct device_attribute *devattr, char *buf) +{ + struct ec_data *data = dev_get_drvdata(dev); + u8 year = 0; + u8 month = 0; + u8 day = 0; + year = ec_i2c_read(data, DATE_YEAR_REG); + month = ec_i2c_read(data, DATE_MONTH_REG); + day = ec_i2c_read(data, DATE_DAY_REG); + return sprintf(buf, "%d/%d/%d\n", day, month, year); +} + +static ssize_t show_ec_ver(struct device *dev, struct device_attribute *devattr, char *buf) +{ + struct ec_data *data = dev_get_drvdata(dev); + u8 ver_major = 0; + u8 ver_minor = 0; + ver_major = ec_i2c_read(data, DATE_YEAR_REG); + ver_major = ec_i2c_read(data, DATE_MONTH_REG); + return sprintf(buf, "%2x.%2x\n", ver_major, ver_minor); +} + // sysfs attributes static SENSOR_DEVICE_ATTR(cpu_temperature, S_IRUGO, show_cpu_temperature, NULL, 0); static SENSOR_DEVICE_ATTR(mem0_temperature, S_IRUGO, show_mem0_temperature, NULL, 0); static SENSOR_DEVICE_ATTR(mem1_temperature, S_IRUGO, show_mem1_temperature, NULL, 0); +static SENSOR_DEVICE_ATTR(ec_date, S_IRUGO, show_ec_date, NULL, 0); +static SENSOR_DEVICE_ATTR(ec_ver, S_IRUGO, show_ec_ver, NULL, 0); static struct attribute *embd_ctrl_attributes[] = { &sensor_dev_attr_cpu_temperature.dev_attr.attr, &sensor_dev_attr_mem0_temperature.dev_attr.attr, &sensor_dev_attr_mem1_temperature.dev_attr.attr, + &sensor_dev_attr_ec_date.dev_attr.attr, + &sensor_dev_attr_ec_ver.dev_attr.attr, NULL }; diff --git a/ixr7220h6-64/modules/h6_fan_cpld.c b/ixr7220h6-64/modules/h6_fan_cpld.c index 55660be..421c52e 100644 --- a/ixr7220h6-64/modules/h6_fan_cpld.c +++ b/ixr7220h6-64/modules/h6_fan_cpld.c @@ -397,7 +397,7 @@ static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, ret = sprintf(buf, "0x%02x\n", data->reg_val[FAN_PCB_REG]); break; case FAN_FW_VERSION: - ret = sprintf(buf, "%d.%d\n", + ret = sprintf(buf, "%02x.%02x\n", data->reg_val[FAN_MAJOR_VERSION_REG], data->reg_val[FAN_MINOR_VERSION_REG]); break; diff --git a/ixr7220h6-64/modules/pmbus_psu.c b/ixr7220h6-64/modules/pmbus_psu.c index 5f4d92e..f3bab04 100644 --- a/ixr7220h6-64/modules/pmbus_psu.c +++ b/ixr7220h6-64/modules/pmbus_psu.c @@ -437,6 +437,16 @@ static ssize_t show_psu_led(struct device *dev, struct device_attribute *dev_att return sprintf(buf, "%d\n", val); } +static ssize_t show_psu_stat(struct device *dev, struct device_attribute *dev_attr, char *buf) +{ + struct i2c_client *client = to_i2c_client(dev); + int val; + + val = psu_read_word(client, PSU_REG_STATUS); + + return sprintf(buf, "0x%04x\n", val); +} + /* sysfs attributes */ static SENSOR_DEVICE_ATTR(psu_v_in, S_IRUGO, for_vin, NULL, PSU_V_IN); static SENSOR_DEVICE_ATTR(psu_v_out, S_IRUGO, for_vout_data, NULL, PSU_V_OUT); @@ -455,6 +465,7 @@ static SENSOR_DEVICE_ATTR(psu_rst, S_IRUGO | S_IWUSR, show_psu_rst, set_psu_rst, static SENSOR_DEVICE_ATTR(psu_ioc, S_IRUGO, show_psu_ioc, NULL, 0); static SENSOR_DEVICE_ATTR(psu_rev, S_IRUGO, show_psu_rev, NULL, 0); static SENSOR_DEVICE_ATTR(psu_led, S_IRUGO, show_psu_led, NULL, 0); +static SENSOR_DEVICE_ATTR(psu_stat, S_IRUGO, show_psu_stat, NULL, 0); static struct attribute *psu_attributes[] = { &sensor_dev_attr_psu_v_in.dev_attr.attr, @@ -474,6 +485,7 @@ static struct attribute *psu_attributes[] = { &sensor_dev_attr_psu_ioc.dev_attr.attr, &sensor_dev_attr_psu_rev.dev_attr.attr, &sensor_dev_attr_psu_led.dev_attr.attr, + &sensor_dev_attr_psu_stat.dev_attr.attr, NULL }; @@ -485,6 +497,7 @@ static int psu_probe(struct i2c_client *client) { struct psu_data *data; int status; + int val; if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA | I2C_FUNC_SMBUS_BLOCK_DATA)) { @@ -515,6 +528,16 @@ static int psu_probe(struct i2c_client *client) return status; } + val = psu_read_word(client, PSU_REG_STATUS); + if (((val>>4)&0x1) == 1) + { + dev_warn(&client->dev, "PSU latched, resetting\n"); + status = psu_write_byte_pec(client, PSU_REG_OPERATION, 0x60); + if (status < 0) { + dev_warn(&client->dev, "%s WRITE ERROR: reg(0x%02x) err %d\n", PSU_DRIVER_NAME, PSU_REG_OPERATION, status); + } + } + return 0; } diff --git a/ixr7220h6-64/modules/port_cpld0.c b/ixr7220h6-64/modules/port_cpld0.c index 01d512b..a5057aa 100644 --- a/ixr7220h6-64/modules/port_cpld0.c +++ b/ixr7220h6-64/modules/port_cpld0.c @@ -120,7 +120,7 @@ static ssize_t show_ver(struct device *dev, struct device_attribute *devattr, ch reg_major = cpld_i2c_read(data, VER_MAJOR_REG); reg_minor = cpld_i2c_read(data, VER_MINOR_REG); - return sprintf(buf, "%d.%d\n", reg_major, reg_minor); + return sprintf(buf, "%02x.%02x\n", reg_major, reg_minor); } static ssize_t show_scratch(struct device *dev, struct device_attribute *devattr, char *buf) diff --git a/ixr7220h6-64/modules/port_cpld1.c b/ixr7220h6-64/modules/port_cpld1.c index bc7b98a..f5a7d93 100644 --- a/ixr7220h6-64/modules/port_cpld1.c +++ b/ixr7220h6-64/modules/port_cpld1.c @@ -112,7 +112,7 @@ static ssize_t show_ver(struct device *dev, struct device_attribute *devattr, ch reg_major = cpld_i2c_read(data, VER_MAJOR_REG); reg_minor = cpld_i2c_read(data, VER_MINOR_REG); - return sprintf(buf, "%d.%d\n", reg_major, reg_minor); + return sprintf(buf, "%02x.%02x\n", reg_major, reg_minor); } static ssize_t show_scratch(struct device *dev, struct device_attribute *devattr, char *buf) diff --git a/ixr7220h6-64/modules/sys_cpld.c b/ixr7220h6-64/modules/sys_cpld.c index 39ba024..4429028 100644 --- a/ixr7220h6-64/modules/sys_cpld.c +++ b/ixr7220h6-64/modules/sys_cpld.c @@ -84,7 +84,7 @@ static ssize_t show_ver(struct device *dev, struct device_attribute *devattr, ch reg_major = cpld_i2c_read(data, VER_MAJOR_REG); reg_minor = cpld_i2c_read(data, VER_MINOR_REG); - return sprintf(buf, "%d.%d\n", reg_major, reg_minor); + return sprintf(buf, "%02x.%02x\n", reg_major, reg_minor); } static ssize_t show_scratch(struct device *dev, struct device_attribute *devattr, char *buf) diff --git a/ixr7220h6-64/modules/sys_fpga.c b/ixr7220h6-64/modules/sys_fpga.c index bc6e9a6..ee50d95 100644 --- a/ixr7220h6-64/modules/sys_fpga.c +++ b/ixr7220h6-64/modules/sys_fpga.c @@ -82,7 +82,7 @@ static ssize_t show_ver(struct device *dev, struct device_attribute *devattr, ch reg_major = cpld_i2c_read(data, VER_MAJOR_REG); reg_minor = cpld_i2c_read(data, VER_MINOR_REG); - return sprintf(buf, "%d.%d\n", reg_major, reg_minor); + return sprintf(buf, "%02x.%02x\n", reg_major, reg_minor); } static ssize_t show_scratch(struct device *dev, struct device_attribute *devattr, char *buf) diff --git a/ixr7220h6-64/scripts/h6_64_platform_init.sh b/ixr7220h6-64/scripts/h6_64_platform_init.sh index 750eab5..86b601c 100755 --- a/ixr7220h6-64/scripts/h6_64_platform_init.sh +++ b/ixr7220h6-64/scripts/h6_64_platform_init.sh @@ -100,7 +100,6 @@ done # thermal echo embd_ctrl 0x21 > /sys/bus/i2c/devices/i2c-0/new_device -echo jc42 0x18 > /sys/bus/i2c/devices/i2c-0/new_device echo lm75 0x48 > /sys/bus/i2c/devices/i2c-77/new_device echo lm75 0x49 > /sys/bus/i2c/devices/i2c-77/new_device echo tmp464 0x48 > /sys/bus/i2c/devices/i2c-101/new_device diff --git a/ixr7220h6-64/sonic_platform/chassis.py b/ixr7220h6-64/sonic_platform/chassis.py index 8d1b3bc..85a62f0 100755 --- a/ixr7220h6-64/sonic_platform/chassis.py +++ b/ixr7220h6-64/sonic_platform/chassis.py @@ -31,7 +31,7 @@ FAN_DRAWERS = 8 FANS_PER_DRAWER = 2 PSU_NUM = 4 -THERMAL_NUM = 17 +THERMAL_NUM = 16 COMPONENT_NUM = 7 CPLD_DIR = "/sys/bus/i2c/devices/73-0061/" diff --git a/ixr7220h6-64/sonic_platform/component.py b/ixr7220h6-64/sonic_platform/component.py index f637b7e..046e021 100755 --- a/ixr7220h6-64/sonic_platform/component.py +++ b/ixr7220h6-64/sonic_platform/component.py @@ -69,12 +69,6 @@ def _get_command_result(self, cmdline): return result - def _get_cpld_version(self): - if self.name == "BIOS": - return read_sysfs_file(self.sysfs_dir + "bios_version") - else: - return read_sysfs_file(self.sysfs_dir + "version") - def get_name(self): """ Retrieves the name of the component @@ -149,7 +143,10 @@ def get_firmware_version(self): Returns: A string containing the firmware version of the component """ - return self._get_cpld_version() + if self.name == "BIOS": + return read_sysfs_file(self.sysfs_dir + "bios_version") + else: + return read_sysfs_file(self.sysfs_dir + "version") def install_firmware(self, image_path): """ @@ -251,7 +248,7 @@ def update_firmware(self, image_path): Raises: RuntimeError: update failed """ - return False + return self.install_firmware(image_path) def get_available_firmware_version(self, image_path): """ @@ -265,7 +262,11 @@ def get_available_firmware_version(self, image_path): Returns: A string containing the available firmware version of the component """ - return "N/A" + if image_path: + image_name = ntpath.basename(image_path) + return image_name + + return 'NA' def _power_cycle(self): os.system('sync') diff --git a/ixr7220h6-64/sonic_platform/thermal.py b/ixr7220h6-64/sonic_platform/thermal.py index ffc5391..1edb464 100755 --- a/ixr7220h6-64/sonic_platform/thermal.py +++ b/ixr7220h6-64/sonic_platform/thermal.py @@ -15,27 +15,28 @@ sonic_logger = logger.Logger('thermal') -THERMAL_NUM = 17 +THERMAL_NUM = 16 class Thermal(ThermalBase): """Nokia platform-specific Thermal class""" HWMON_DIR = "/sys/bus/i2c/devices/{}/hwmon/hwmon*/" - I2C_DEV_LIST = ["0-0018", "77-0049", "77-0048", "98-004d", "98-004b", - "98-004c", "98-004a", "101-0048", "98-0049", "98-0048", - "111-004d", "119-004d", "0-0021","0-0021"] - THERMAL_NAME = ["CPU Board", "CB Left", "CB Right", "SFP Board", "MB Left", - "MB Center 1", "MB MAC", "MB Center 2", "MB Right", "MB Front Right", - "FCM Upper", "FCM Lower", "CPU", "DDR", "Max Port Temp.", - "SSD", "ASIC TH6"] - THRESHHOLD = [65.0, 66.0, 68.0, 62.0, 75.0, - 105.0, 105.0, 105.0, 78.0, 65.0, - 66.0, 66.0, 95.0, 70.0, 85.0, - 70.0, 95.0] - CRITICAL_THRESHHOLD = [70.0, 70.0, 72.0, 67.0, 80.0, - 115.0, 115.0, 115.0, 80.0, 70.0, - 69.0, 69.0, 99.0, 80.0, 90.0, - 80.0, 100.0] + I2C_DEV_LIST = ["77-0049", "77-0048", "98-004d", "98-004b", "98-004c", + "98-004a", "101-0048", "98-0049", "98-0048", "111-004d", + "119-004d", "0-0021","0-0021"] + THERMAL_NAME = ["CB Left", "CB Right", "SFP Board", "MB Left", "MB Center 1", + "MB MAC", "MB Center 2", "MB Right", "MB Front Right", "FCM Upper", + "FCM Lower", "CPU", "DDR", "Max Port Temp.","SSD", + "ASIC TH6"] + THRESHHOLD = [65.0, 65.0, 60.0, 85.0, 99.0, + 99.0, 110.0, 85.0, 72.0, 67.0, + 65.0, 94.0, 75.0, 75.0, 75.0, + 95.0] + + CRITICAL_THRESHHOLD = [70.0, 70.0, 65.0, 90.0, 100.0, + 100.0, 115.0, 90.0, 77.0, 72.0, + 70.0, 99.0, 80.0, 77.0, 80.0, + 100.0] def __init__(self, thermal_index, sfps): ThermalBase.__init__(self) @@ -49,7 +50,7 @@ def __init__(self, thermal_index, sfps): self.thermal_high_crit_threshold_file = None self.thermal_temperature_file = None - if self.index == THERMAL_NUM - 1: #SSD + if self.index == THERMAL_NUM - 1: self.device_path = glob.glob("/sys/block/sda/device/hwmon/*") if len(self.device_path) > 0: self.thermal_temperature_file = self.device_path[0] + "/temp1_input" @@ -189,9 +190,7 @@ def get_high_critical_threshold(self): A float number, the high critical threshold temperature of thermal in Celsius up to nearest thousandth of one degree Celsius, e.g. 30.125 """ - if self.index == THERMAL_NUM: - return 103.0 - return 80.0 + return self.CRITICAL_THRESHHOLD[self.index - 1] def set_high_critical_threshold(self): """ diff --git a/ixr7220h6-64/sonic_platform/thermal_actions.py b/ixr7220h6-64/sonic_platform/thermal_actions.py index e71359e..e7d9452 100755 --- a/ixr7220h6-64/sonic_platform/thermal_actions.py +++ b/ixr7220h6-64/sonic_platform/thermal_actions.py @@ -15,14 +15,16 @@ class SetFanSpeedAction(ThermalPolicyActionBase): JSON_FIELD_SPEED = 'speed' JSON_FIELD_DEFAULT_SPEED = 'default_speed' JSON_FIELD_THRESHOLD1_SPEED = 'threshold1_speed' + JSON_FIELD_THRESHOLD2_SPEED = 'threshold2_speed' JSON_FIELD_HIGHTEMP_SPEED = 'hightemp_speed' def __init__(self): """ Constructor of SetFanSpeedAction """ - self.default_speed = 46 - self.threshold1_speed=73 + self.default_speed = 47 + self.threshold1_speed = 60 + self.threshold2_speed = 80 self.hightemp_speed = 100 self.speed = self.default_speed @@ -77,8 +79,9 @@ def load_from_json(self, json_obj): Construct ThermalRecoverAction via JSON. JSON example: { "type": "thermal.temp_check_and_set_all_fan_speed" - "default_speed": "46", - "threshold1_speed": "73", + "default_speed": "47", + "threshold1_speed": "60", + "threshold2_speed": "80", "hightemp_speed": "100" } :param json_obj: A JSON object representing a ThermalRecoverAction action. @@ -104,6 +107,16 @@ def load_from_json(self, json_obj): raise ValueError('SetFanSpeedAction missing mandatory field {} in JSON policy file'. format(SetFanSpeedAction.JSON_FIELD_THRESHOLD1_SPEED)) + if SetFanSpeedAction.JSON_FIELD_THRESHOLD2_SPEED in json_obj: + threshold2_speed = float(json_obj[SetFanSpeedAction.JSON_FIELD_THRESHOLD2_SPEED]) + if threshold2_speed < 0 or threshold2_speed > 100: + raise ValueError('SetFanSpeedAction invalid default speed value {} in JSON policy file, valid value should be [0, 100]'. + format(threshold2_speed)) + self.threshold2_speed = float(json_obj[SetFanSpeedAction.JSON_FIELD_THRESHOLD2_SPEED]) + else: + raise ValueError('SetFanSpeedAction missing mandatory field {} in JSON policy file'. + format(SetFanSpeedAction.JSON_FIELD_THRESHOLD2_SPEED)) + if SetFanSpeedAction.JSON_FIELD_HIGHTEMP_SPEED in json_obj: hightemp_speed = float(json_obj[SetFanSpeedAction.JSON_FIELD_HIGHTEMP_SPEED]) if hightemp_speed < 0 or hightemp_speed > 100: @@ -114,7 +127,7 @@ def load_from_json(self, json_obj): raise ValueError('SetFanSpeedAction missing mandatory field {} in JSON policy file'. format(SetFanSpeedAction.JSON_FIELD_HIGHTEMP_SPEED)) - sonic_logger.log_warning("ThermalRecoverAction: default: {}, threshold1: {}, hightemp: {}".format(self.default_speed, self.threshold1_speed, self.hightemp_speed)) + sonic_logger.log_warning("ThermalRecoverAction: default: {}, threshold1: {}, threshold2: {}, hightemp: {}".format(self.default_speed, self.threshold1_speed, self.threshold2_speed, self.hightemp_speed)) def execute(self, thermal_info_dict): """ @@ -129,6 +142,8 @@ def execute(self, thermal_info_dict): thermal_info_obj = thermal_info_dict[ThermalInfo.INFO_NAME] if thermal_info_obj.is_set_fan_high_temp_speed(): ThermalRecoverAction.set_all_fan_speed(thermal_info_dict, self.hightemp_speed) + elif thermal_info_obj.is_set_fan_threshold_two_speed(): + ThermalRecoverAction.set_all_fan_speed(thermal_info_dict, self.threshold2_speed) elif thermal_info_obj.is_set_fan_threshold_one_speed(): ThermalRecoverAction.set_all_fan_speed(thermal_info_dict, self.threshold1_speed) elif thermal_info_obj.is_set_fan_default_speed(): @@ -148,7 +163,7 @@ def execute(self, thermal_info_dict): :return: """ sonic_logger.log_warning("Alarm for temperature critical is detected, reboot Device") - + @thermal_json_object('thermal_control.control') class ControlThermalAlgoAction(ThermalPolicyActionBase): """ diff --git a/ixr7220h6-64/sonic_platform/thermal_infos.py b/ixr7220h6-64/sonic_platform/thermal_infos.py index 5b60d3b..4aa231d 100755 --- a/ixr7220h6-64/sonic_platform/thermal_infos.py +++ b/ixr7220h6-64/sonic_platform/thermal_infos.py @@ -71,10 +71,14 @@ class ThermalInfo(ThermalPolicyInfoBase): def __init__(self): self._old_threshold_level = -1 self._current_threshold_level = 0 - self._num_fan_levels = 1 - self._level_up_threshold = [[55, 60, 65, 55, 65, 100, 100, 100, 75, 60, 55, 55, 85, 65, 65, 60, 80]] + self._num_fan_levels = 3 + self._level_up_threshold = [[44, 44, 15, 58, 88, 87, 90, 65, 43, 43, 30, 83, 56, 58, 47, 73], + [52, 50, 29, 65, 92, 92, 94, 70, 49, 50, 41, 88, 61, 68, 51, 86], + [57, 55, 37, 70, 97, 97, 99, 75, 55, 55, 46, 93, 66, 73, 55, 91]] - self._level_down_threshold = [[45, 36, 45, 45, 50, 68, 68, 68, 60, 36, 45, 45, 68, 40, 45, 35, 55]] + self._level_down_threshold = [[33, 31, 12, 46, 72, 73, 75, 51, 31, 30, 25, 70, 42, 50, 33, 70], + [41, 39, 25, 53, 77, 77, 78, 56, 39, 41, 32, 78, 48, 60, 40, 75], + [49, 48, 33, 61, 84, 84, 86, 62, 44, 48, 37, 83, 54, 69, 47, 80]] def collect(self, chassis): """ @@ -86,6 +90,7 @@ def collect(self, chassis): self._over_high_critical_threshold = False self._set_fan_default_speed = False self._set_fan_threshold_one_speed = False + self._set_fan_threshold_two_speed = False self._set_fan_high_temp_speed = False # Calculate average temp within the device @@ -98,7 +103,6 @@ def collect(self, chassis): min_level = [self._num_fan_levels for i in range(num_of_thermals)] for index in range(num_of_thermals): for level in range(self._num_fan_levels): - if self._temps[index]>self._level_up_threshold[level][index]: if max_level