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
2 changes: 1 addition & 1 deletion ixr7220h6-128/modules/h6_fan_cpld.c
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ static u32 reg_val_to_speed_rpm(u8 reg_val)

static u8 reg_val_to_is_present(u8 reg_val, enum fan_id id)
{
return !((reg_val >> id) & 0x1);
return !((reg_val >> (id+4)) & 0x1);
}

static u8 reg_val_to_color(u8 reg_val, enum fan_id id)
Expand Down
36 changes: 9 additions & 27 deletions ixr7220h6-128/modules/mb_pld.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
// REGISTERS ADDRESS MAP
#define VER_MAJOR_REG 0x00
#define VER_MINOR_REG 0x01
#define SCRATCH_REG 0x04
#define BMC_RESET_REG 0x04
#define OSFP_EFUSE_REG0 0x10
#define SYS_LED_REG0 0x80
#define SYS_LED_REG1 0x81
Expand All @@ -42,6 +42,7 @@ struct cpld_data {
struct i2c_client *client;
struct mutex update_lock;
int osfp_efuse;
int bmc_reset;
};

static int cpld_i2c_read(struct cpld_data *data, u8 reg)
Expand Down Expand Up @@ -82,32 +83,10 @@ static ssize_t show_ver(struct device *dev, struct device_attribute *devattr, ch
return sprintf(buf, "%02x.%02x\n", reg_major, reg_minor);
}

static ssize_t show_scratch(struct device *dev, struct device_attribute *devattr, char *buf)
static ssize_t show_bmc_reset(struct device *dev, struct device_attribute *devattr, char *buf)
{
struct cpld_data *data = dev_get_drvdata(dev);
u8 val = 0;

val = cpld_i2c_read(data, SCRATCH_REG);

return sprintf(buf, "0x%02x\n", val);
}

static ssize_t set_scratch(struct device *dev, struct device_attribute *devattr, const char *buf, size_t count)
{
struct cpld_data *data = dev_get_drvdata(dev);
u8 usr_val = 0;

int ret = kstrtou8(buf, 16, &usr_val);
if (ret != 0) {
return ret;
}
if (usr_val > 0xFF) {
return -EINVAL;
}

cpld_i2c_write(data, SCRATCH_REG, usr_val);

return count;
return sprintf(buf, "%02x\n", data->bmc_reset);
}

static ssize_t show_led0(struct device *dev, struct device_attribute *devattr, char *buf)
Expand Down Expand Up @@ -220,7 +199,7 @@ static ssize_t set_osfp_efuse(struct device *dev, struct device_attribute *devat

// sysfs attributes
static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_ver, NULL, 0);
static SENSOR_DEVICE_ATTR(scratch, S_IRUGO | S_IWUSR, show_scratch, set_scratch, 0);
static SENSOR_DEVICE_ATTR(bmc_reset, S_IRUGO, show_bmc_reset, NULL, 0);

static SENSOR_DEVICE_ATTR(led_sys, S_IRUGO | S_IWUSR, show_led0, set_led0, 0);
static SENSOR_DEVICE_ATTR(led_psu, S_IRUGO, show_led0, NULL, 4);
Expand All @@ -231,7 +210,7 @@ static SENSOR_DEVICE_ATTR(osfp_efuse, S_IRUGO | S_IWUSR, show_osfp_efuse, set_os

static struct attribute *mb_pld_attributes[] = {
&sensor_dev_attr_version.dev_attr.attr,
&sensor_dev_attr_scratch.dev_attr.attr,
&sensor_dev_attr_bmc_reset.dev_attr.attr,

&sensor_dev_attr_led_sys.dev_attr.attr,
&sensor_dev_attr_led_psu.dev_attr.attr,
Expand Down Expand Up @@ -281,6 +260,9 @@ static int mb_pld_probe(struct i2c_client *client)
for (i=0;i<8;i++) cpld_i2c_write(data, OSFP_EFUSE_REG0+i, 0xFF);
data->osfp_efuse = 1;

data->bmc_reset = cpld_i2c_read(data, BMC_RESET_REG);
cpld_i2c_write(data, BMC_RESET_REG, 0x0);

return 0;

exit_sysfs_create_group:
Expand Down
16 changes: 14 additions & 2 deletions ixr7220h6-128/scripts/h6_128_platform_init.sh
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ sleep 1
i2cset -y 1 0x77 0x0 0x03
sleep 2
i2cset -y 1 0x71 0xc 0xff
i2cset -y 1 0x71 0x82 0x1
i2cset -y 1 0x71 0x80 0x7f
sleep 1

echo cb_pld 0x60 > /sys/bus/i2c/devices/i2c-1/new_device
Expand All @@ -50,7 +52,7 @@ sleep 1
echo mux_mb 0x72 > /sys/bus/i2c/devices/i2c-135/new_device

echo mb_pld 0x71 > /sys/bus/i2c/devices/i2c-135/new_device

i2cset -y 149 0x74 0x5 0x1f
echo mux_fcm 0x75 > /sys/bus/i2c/devices/i2c-145/new_device
echo mux_fcm 0x76 > /sys/bus/i2c/devices/i2c-146/new_device
sleep 1
Expand Down Expand Up @@ -136,13 +138,23 @@ i2cset -y 132 0x61 0x11 0x80
i2cset -y 132 0x61 0x18 0x80
i2cset -y 132 0x61 0x23 0x00
i2cset -y 132 0x61 0x2d 0x00
ip link set eth1 up

for ch in {1..8}; do
echo 60 > /sys/bus/i2c/devices/145-0032/hwmon/hwmon*/fan${ch}_pwm
echo 60 > /sys/bus/i2c/devices/146-0033/hwmon/hwmon*/fan${ch}_pwm
done

i2cset -y 147 0x20 0x0 0x0
value=$(i2cget -y 147 0x20 0xba w)
if [ "$?" == "0" ]; then
if [ "$value" != "0x203c" ]; then
i2cset -y 147 0x20 0xba 0x203c w
sleep 1
i2cset -y 147 0x20 0x17
sleep 15
fi
fi

SN=$(decode-syseeprom -s)
logger -t h6_128_platform_init "Nokia-IXR7220-H6-128: SN = ${SN}"

Expand Down
25 changes: 13 additions & 12 deletions ixr7220h6-128/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 = 20
THERMAL_NUM = 21
COMPONENT_NUM = 11

PLD_DIR = "/sys/bus/i2c/devices/135-0071/"
Expand Down Expand Up @@ -86,7 +86,7 @@ def __init__(self):
drawer = drawer_ctor(drawer_index)
self._fan_drawer_list.append(drawer)
for fan_index in range(fan_num_per_drawer):
fan = Fan(fan_index, drawer_index)
fan = Fan(fan_index, drawer_index, drawer=drawer)
drawer._fan_list.append(fan)
self._fan_list.append(fan)

Expand Down Expand Up @@ -285,20 +285,21 @@ def get_reboot_cause(self):
is "REBOOT_CAUSE_HARDWARE_OTHER", the second string can be used
to pass a description of the reboot cause.
"""
result = read_sysfs_file(SYSFPGA_DIR + "reset_cause")
result1 = read_sysfs_file(SYSFPGA_DIR + "reset_cause")
result2 = read_sysfs_file(PLD_DIR + "bmc_reset")
val1 = int(result1, 16)
val2 = int(result2, 16)

if (int(result, 16) & 0x10) >> 4 == 1:
if val1 & 0x10:
return (self.REBOOT_CAUSE_WATCHDOG, "CPU_WD")

if (int(result, 16) & 0x01) == 1:
if val1 & 0x01:
return (self.REBOOT_CAUSE_WATCHDOG, "EC_WD")

if (int(result, 16) & 0x02) >> 1 == 1:
if val1 & 0x02:
return (self.REBOOT_CAUSE_HARDWARE_OTHER, "CPU Over Heat")

if (int(result, 16) & 0x08) >> 3 == 1:
return (self.REBOOT_CAUSE_HARDWARE_OTHER, "Power Cycle")

if val2 == 0x5A:
return (self.REBOOT_CAUSE_POWER_LOSS, "BMC Remote Power Cycle")
if val1 & 0x08:
return (self.REBOOT_CAUSE_POWER_LOSS, "Power Cycle")
return (self.REBOOT_CAUSE_NON_HARDWARE, None)

def get_watchdog(self):
Expand Down
47 changes: 35 additions & 12 deletions ixr7220h6-128/sonic_platform/fan.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
raise ImportError(str(e) + "- required module not found")

FANS_PER_DRAWER = 2
MAX_FAN_F_SPEED = 15400
MAX_FAN_R_SPEED = 13600
MAX_FAN15_F_SPEED = 15400
MAX_FAN15_R_SPEED = 13600
MAX_FAN20_F_SPEED = 20000
MAX_FAN20_R_SPEED = 17500
FAN15_PN = '3HE21988AA01'
FAN_TOLERANCE = 50
WORKING_FAN_SPEED = 2000

Expand All @@ -36,8 +39,11 @@
class Fan(FanBase):
"""Nokia platform-specific Fan class"""

def __init__(self, fan_index, drawer_index, psu_fan=False, dependency=None):
def __init__(self, fan_index, drawer_index, psu_fan=False, dependency=None, drawer=None):
self._fan_index = fan_index
self.is_psu_fan = psu_fan
self._drawer = drawer
self._max_speed_inited = False
i2c_dev = I2C_DEV_LIST[drawer_index%2]
hwmon_path = glob.glob(HWMON_DIR.format(i2c_dev))
self.fan_led_color = ['off', 'green', 'amber', 'green_blink']
Expand All @@ -51,10 +57,10 @@ def __init__(self, fan_index, drawer_index, psu_fan=False, dependency=None):
self.get_fan_presence_reg = hwmon_path[0] + f"fan{(drawer_index//2)+1}_present"
self.fan_led_reg = hwmon_path[0] + f"fan{(drawer_index//2)+1}_led"

if fan_index == 0:
self.max_fan_speed = MAX_FAN_F_SPEED
if self._fan_index == 0:
self.max_fan_speed = MAX_FAN20_F_SPEED
else:
self.max_fan_speed = MAX_FAN_R_SPEED
self.max_fan_speed = MAX_FAN20_R_SPEED

else:
# this is a PSU Fan
Expand Down Expand Up @@ -82,8 +88,11 @@ def get_presence(self):
"""
result = read_sysfs_file(self.get_fan_presence_reg)
if result == '1': # present
if not self._max_speed_inited and not self.is_psu_fan:
self._get_max_fan_speed()
return True

self._max_speed_inited = False
return False

def get_model(self):
Expand All @@ -102,9 +111,6 @@ def get_serial(self):
Returns:
string: Serial number of Fan
"""
#if self.get_presence():
# result = read_sysfs_file(self.eeprom_dir + "serial_number")
# return result.strip()
return 'N/A'

def get_part_number(self):
Expand All @@ -114,9 +120,6 @@ def get_part_number(self):
Returns:
string: Part number of Fan
"""
#if self.get_presence():
# result = read_sysfs_file(self.eeprom_dir + "part_number")
# return result.strip()
return 'N/A'

def get_service_tag(self):
Expand Down Expand Up @@ -178,6 +181,10 @@ def get_speed(self):
:return: integer, denoting front FAN speed
"""
speed = 0
if not self.get_presence():
return speed
elif not self._max_speed_inited:
return speed

fan_speed = read_sysfs_file(self.get_fan_speed_reg)
if (fan_speed != 'ERR'):
Expand Down Expand Up @@ -260,3 +267,19 @@ def get_target_speed(self):
if fan_duty != 'ERR':
return int(fan_duty)
return 0

def _get_max_fan_speed(self):
if self._drawer is None:
self._max_speed_inited = True
return

part_number = self._drawer.get_part_number()
if part_number == 'N/A' or part_number is None:
return

is_front = (self._fan_index == 0)

if part_number.startswith(FAN15_PN):
self.max_fan_speed = MAX_FAN15_F_SPEED if is_front else MAX_FAN15_R_SPEED

self._max_speed_inited = True
15 changes: 9 additions & 6 deletions ixr7220h6-128/sonic_platform/psu.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def get_model(self):
string: Part number of PSU
"""
if self.get_presence():
return read_sysfs_file(self.eeprom_dir+"product_name")
return read_sysfs_file(self.eeprom_dir+"part_number")

return 'N/A'

Expand All @@ -103,7 +103,7 @@ def get_serial(self):
string: Serial number of PSU
"""
if self.get_presence():
return read_sysfs_file(self.eeprom_dir+"serial_number")
return read_sysfs_file(self.eeprom_dir+"customer_sn")

return 'N/A'

Expand Down Expand Up @@ -266,10 +266,13 @@ def get_status_master_led(self):
A string, one of the predefined STATUS_LED_COLOR_* strings.
"""
result = read_sysfs_file(LED_REG_DIR+"led_psu")
if result == '1':
return 'green'
else:
return 'amber'
val = int(result, 16)
if val == 0x1:
return self.psu_led_color[1]
elif val == 0x2 or val == 0x0:
return self.psu_led_color[3]

return 'N/A'

def set_status_master_led(self, _color):
"""
Expand Down
32 changes: 17 additions & 15 deletions ixr7220h6-128/sonic_platform/thermal.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,32 +15,32 @@

sonic_logger = logger.Logger('thermal')

THERMAL_NUM = 20
THERMAL_NUM = 21

class Thermal(ThermalBase):
"""Nokia platform-specific Thermal class"""

HWMON_DIR = "/sys/bus/i2c/devices/{}/hwmon/hwmon*/"
I2C_DEV_LIST = ["144-0048", "155-004b", "155-004c", "155-004d",
"155-0049", "155-0048", "155-004a", "175-0048", "178-0048",
"181-0048", "184-0048", "168-004d","169-004e", "162-004d",
"163-004e", "0-0021", "0-0021"]
"181-0048", "184-0048", "162-004d","163-004e", "168-004d",
"169-004e", "0-0021", "0-0021", "0-0021"]
THERMAL_NAME = ["Carrier Board", "MB Top U34", "MB Top U178", "MB Bottom U196",
"MB Bottom U183", "MB Top U3", "MB Top U15", "LDB Left", "LDB Right",
"UDB Left", "UDB Right", "Top FCM 1", "Top FCM 2", "Bottom FCM 1",
"Bottom FCM 2", "CPU", "DDR", "Max Port Temp.", "SSD",
"Bottom FCM 2", "CPU", "DDR1", "DDR2", "Max Port Temp.", "SSD",
"ASIC TH6"]

THRESHOLD = [62.0, 75.0, 75.0, 75.0,
75.0, 75.0, 75.0, 60.0, 60.0,
60.0, 60.0, 60.0, 60.0, 62.0,
62.0, 95.0, 70.0, 75.0, 70.0,
95.0]
CRITICAL_THRESHOLD = [70.0, 85.0, 85.0, 85.0,
85.0, 85.0, 85.0, 70.0, 70.0,
70.0, 70.0, 70.0, 70.0, 72.0,
72.0, 99.0, 80.0, 77.0, 80.0,
100.0]
THRESHOLD = [55.0, 75.0, 60.0, 70.0,
52.0, 60.0, 60.0, 55.0, 55.0,
55.0, 55.0, 60.0, 60.0, 55.0,
52.0, 80.0, 51.0, 51.0, 65.0, 50.0,
111.0]
CRITICAL_THRESHOLD = [65.0, 85.0, 85.0, 80.0,
65.0, 70.0, 70.0, 65.0, 65.0,
65.0, 65.0, 70.0, 70.0, 65.0,
65.0, 99.0, 70.0, 70.0, 77.0, 65.0,
115.0]

def __init__(self, thermal_index, sfps):
ThermalBase.__init__(self)
Expand All @@ -63,8 +63,10 @@ def __init__(self, thermal_index, sfps):
elif self.index == THERMAL_NUM - 3:
self.thermal_temperature_file = "/sys/bus/i2c/devices/" + self.I2C_DEV_LIST[self.index - 1] + "/mem1_temperature"
elif self.index == THERMAL_NUM - 4:
self.thermal_temperature_file = "/sys/bus/i2c/devices/" + self.I2C_DEV_LIST[self.index - 1] + "/mem0_temperature"
elif self.index == THERMAL_NUM - 5:
self.thermal_temperature_file = "/sys/bus/i2c/devices/" + self.I2C_DEV_LIST[self.index - 1] + "/cpu_temperature"
elif self.index < THERMAL_NUM - 4:
elif self.index < THERMAL_NUM - 5:
self.device_path = glob.glob(self.HWMON_DIR.format(self.I2C_DEV_LIST[self.index - 1]))
if len(self.device_path) > 0:
self.thermal_temperature_file = self.device_path[0] + "temp1_input"
Expand Down
Loading
Loading