Add enable fan-wdt and kick
This commit is contained in:
parent
2315510cd2
commit
f3637e4a32
@ -45,7 +45,6 @@ static struct as7726_32x_fan_data *as7726_32x_fan_update_device(struct device *d
|
|||||||
static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf);
|
static ssize_t fan_show_value(struct device *dev, struct device_attribute *da, char *buf);
|
||||||
static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da,
|
static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da,
|
||||||
const char *buf, size_t count);
|
const char *buf, size_t count);
|
||||||
static ssize_t get_sys_temp(struct device *dev, struct device_attribute *da, char *buf);
|
|
||||||
|
|
||||||
/* fan related data, the index should match sysfs_fan_attributes
|
/* fan related data, the index should match sysfs_fan_attributes
|
||||||
*/
|
*/
|
||||||
@ -294,7 +293,7 @@ static ssize_t set_duty_cycle(struct device *dev, struct device_attribute *da,
|
|||||||
if (value < 0 || value > FAN_MAX_DUTY_CYCLE)
|
if (value < 0 || value > FAN_MAX_DUTY_CYCLE)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
as7726_32x_fan_write_value(client, 0x33, 0); /* Disable fan speed watch dog */
|
//as7726_32x_fan_write_value(client, 0x33, 0); /* Disable fan speed watch dog */
|
||||||
as7726_32x_fan_write_value(client, fan_reg[FAN_DUTY_CYCLE_PERCENTAGE], duty_cycle_to_reg_val(value));
|
as7726_32x_fan_write_value(client, fan_reg[FAN_DUTY_CYCLE_PERCENTAGE], duty_cycle_to_reg_val(value));
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
# 4/20/2018: Jostar modify for as7726_32x
|
# 4/20/2018: Jostar modify for as7726_32x
|
||||||
# 12/03/2018:Jostar modify for as7726_32x thermal plan
|
# 12/03/2018:Jostar modify for as7726_32x thermal plan
|
||||||
# 11/16/2020:Jostar modify for as7726_32x thermal plan based on PDDF
|
# 11/16/2020:Jostar modify for as7726_32x thermal plan based on PDDF
|
||||||
|
# 11/19/2023:Jostar modify to add kick fan-wdt
|
||||||
# ------------------------------------------------------------------
|
# ------------------------------------------------------------------
|
||||||
|
|
||||||
try:
|
try:
|
||||||
@ -32,6 +33,7 @@ try:
|
|||||||
import logging.handlers
|
import logging.handlers
|
||||||
import time
|
import time
|
||||||
from sonic_platform import platform
|
from sonic_platform import platform
|
||||||
|
from sonic_py_common.general import getstatusoutput_noshell
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
raise ImportError('%s - required module not found' % str(e))
|
raise ImportError('%s - required module not found' % str(e))
|
||||||
|
|
||||||
@ -162,7 +164,7 @@ class device_monitor(object):
|
|||||||
}
|
}
|
||||||
|
|
||||||
fan_dir= platform_chassis.get_fan(0).get_direction()
|
fan_dir= platform_chassis.get_fan(0).get_direction()
|
||||||
if fan_dir == 'EXHAUST':
|
if fan_dir == 'exhaust':
|
||||||
fan_policy = fan_policy_f2b
|
fan_policy = fan_policy_f2b
|
||||||
else:
|
else:
|
||||||
fan_policy = fan_policy_b2f
|
fan_policy = fan_policy_b2f
|
||||||
@ -305,15 +307,47 @@ def main(argv):
|
|||||||
|
|
||||||
global platform_chassis
|
global platform_chassis
|
||||||
platform_chassis = platform.Platform().get_chassis()
|
platform_chassis = platform.Platform().get_chassis()
|
||||||
|
cmd_str = ["i2cset", "-y", "-f", "54", "0x66", "0x33", "0x0"]
|
||||||
|
status, output = getstatusoutput_noshell(cmd_str)
|
||||||
|
if status:
|
||||||
|
print("Warning: Fan speed watchdog could not be disabled")
|
||||||
|
|
||||||
|
cmd_str = ["i2cset", "-y", "-f", "54", "0x66", "0x33", "0x1"]
|
||||||
|
status, output = getstatusoutput_noshell(cmd_str)
|
||||||
|
if status:
|
||||||
|
print("Warning: Fan speed watchdog could not be enabled")
|
||||||
|
|
||||||
|
#Timer need to be set after enable.
|
||||||
|
#if set timer is eralier than enable wdt. Speed will become to wdt speed after 6sec.
|
||||||
|
cmd_str = ["i2cset", "-y", "-f", "54", "0x66", "0x31", "0xF0"]
|
||||||
|
status, output = getstatusoutput_noshell(cmd_str)
|
||||||
|
if status:
|
||||||
|
print("Warning: Fan speed watchdog timer could not be disabled")
|
||||||
|
|
||||||
platform_chassis.get_fan(0).set_speed(38)
|
platform_chassis.get_fan(0).set_speed(38)
|
||||||
|
|
||||||
print("set default fan speed to 37.5%")
|
print("set default fan speed to 37.5%")
|
||||||
monitor = device_monitor(log_file, log_level)
|
monitor = device_monitor(log_file, log_level)
|
||||||
|
|
||||||
|
cmd_kick = ["i2cset", "-y", "-f", "54", "0x66", "0x31", "0xF0"] #kick WDT
|
||||||
|
cmd_check_wdt = ["i2cget", "-y", "-f", "54", "0x66", "0x33"]
|
||||||
# Loop forever, doing something useful hopefully:
|
# Loop forever, doing something useful hopefully:
|
||||||
while True:
|
while True:
|
||||||
monitor.manage_fans()
|
monitor.manage_fans()
|
||||||
|
getstatusoutput_noshell(cmd_kick)
|
||||||
time.sleep(10)
|
time.sleep(10)
|
||||||
|
#polling to check fan-wdt status
|
||||||
|
status, output = getstatusoutput_noshell(cmd_check_wdt)
|
||||||
|
if status is not None:
|
||||||
|
val= int(output,16)
|
||||||
|
if (val & 0x1) == 0:
|
||||||
|
logging.warning('Detect Fan-WDT disable')
|
||||||
|
logging.warning('Try to enable Fan-WDT')
|
||||||
|
cmd_str = ["i2cset", "-y", "-f", "54", "0x66", "0x33", "0x1"]
|
||||||
|
getstatusoutput_noshell(cmd_str)
|
||||||
|
cmd_str = ["i2cset", "-y", "-f", "54", "0x66", "0x31", "0xF0"]
|
||||||
|
getstatusoutput_noshell(cmd_str)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
main(sys.argv[1:])
|
main(sys.argv[1:])
|
||||||
|
Reference in New Issue
Block a user