Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 31 additions & 0 deletions ixr7220h6-64/modules/embd_ctrl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -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
};

Expand Down
2 changes: 1 addition & 1 deletion ixr7220h6-64/modules/h6_fan_cpld.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
23 changes: 23 additions & 0 deletions ixr7220h6-64/modules/pmbus_psu.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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,
Expand All @@ -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
};

Expand All @@ -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))
{
Expand Down Expand Up @@ -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;
}

Expand Down
2 changes: 1 addition & 1 deletion ixr7220h6-64/modules/port_cpld0.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion ixr7220h6-64/modules/port_cpld1.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion ixr7220h6-64/modules/sys_cpld.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion ixr7220h6-64/modules/sys_fpga.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 0 additions & 1 deletion ixr7220h6-64/scripts/h6_64_platform_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ixr7220h6-64/sonic_platform/chassis.py
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down
19 changes: 10 additions & 9 deletions ixr7220h6-64/sonic_platform/component.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
"""
Expand Down Expand Up @@ -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):
"""
Expand All @@ -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')
Expand Down
39 changes: 19 additions & 20 deletions ixr7220h6-64/sonic_platform/thermal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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"
Expand Down Expand Up @@ -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):
"""
Expand Down
27 changes: 21 additions & 6 deletions ixr7220h6-64/sonic_platform/thermal_actions.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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.
Expand All @@ -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:
Expand All @@ -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):
"""
Expand All @@ -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():
Expand All @@ -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):
"""
Expand Down
Loading