Skip to content

Commit 22eea55

Browse files
wadelnnlguohan
authored andcommitted
[Platform] Add psuutil and update submodule for Ingrasys S9100-32X, S8810-32Q, S9200-64X on master branch (#1271)
* [platform] Add Psuutil and fixed voltage alarm for S9100 * Add I2C CPLD kernel module for psuutil. * Support psuutil script. * Add voltage min and max threshold. Signed-off-by: Wade He <[email protected]> * [Platform] Add Psuutil and update sensors.conf for S8810-32Q and S9200-64X * Support psuutil script. * Update sensors.conf for tmp75. Signed-off-by: Wade He <[email protected]>
1 parent 5eb5e21 commit 22eea55

File tree

6 files changed

+300
-4
lines changed

6 files changed

+300
-4
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#
2+
# psuutil.py
3+
# Platform-specific PSU status interface for SONiC
4+
#
5+
6+
7+
import os.path
8+
9+
try:
10+
from sonic_psu.psu_base import PsuBase
11+
except ImportError as e:
12+
raise ImportError(str(e) + "- required module not found")
13+
14+
15+
class PsuUtil(PsuBase):
16+
"""Platform-specific PSUutil class"""
17+
18+
SYSFS_PSU_DIR = ["/sys/bus/i2c/devices/i2c-3/3-0051",
19+
"/sys/bus/i2c/devices/i2c-4/4-0051"]
20+
21+
def __init__(self):
22+
PsuBase.__init__(self)
23+
24+
25+
# Get sysfs attribute
26+
def get_attr_value(self, attr_path):
27+
28+
retval = 'ERR'
29+
if (not os.path.isfile(attr_path)):
30+
return retval
31+
32+
try:
33+
with open(attr_path, 'r') as fd:
34+
retval = fd.read()
35+
except Exception as error:
36+
logging.error("Unable to open ", attr_path, " file !")
37+
38+
retval = retval.rstrip('\r\n')
39+
return retval
40+
41+
def get_num_psus(self):
42+
"""
43+
Retrieves the number of PSUs available on the device
44+
:return: An integer, the number of PSUs available on the device
45+
"""
46+
MAX_PSUS = 2
47+
return MAX_PSUS
48+
49+
def get_psu_status(self, index):
50+
"""
51+
Retrieves the oprational status of power supply unit (PSU) defined
52+
by index <index>
53+
:param index: An integer, index of the PSU of which to query status
54+
:return: Boolean, True if PSU is operating properly, False if PSU is\
55+
faulty
56+
"""
57+
status = 0
58+
attr_file = 'psu_pg'
59+
attr_path = self.SYSFS_PSU_DIR[index-1] +'/' + attr_file
60+
61+
attr_value = self.get_attr_value(attr_path)
62+
63+
if (attr_value != 'ERR'):
64+
attr_value = int(attr_value, 16)
65+
# Check for PSU status
66+
if (attr_value == 1):
67+
status = 1
68+
69+
return status
70+
71+
def get_psu_presence(self, index):
72+
"""
73+
Retrieves the presence status of power supply unit (PSU) defined
74+
by index <index>
75+
:param index: An integer, index of the PSU of which to query status
76+
:return: Boolean, True if PSU is plugged, False if not
77+
"""
78+
status = 0
79+
psu_absent = 0
80+
attr_file ='psu_abs'
81+
attr_path = self.SYSFS_PSU_DIR[index-1] +'/' + attr_file
82+
83+
attr_value = self.get_attr_value(attr_path)
84+
85+
if (attr_value != 'ERR'):
86+
attr_value = int(attr_value, 16)
87+
# Check for PSU presence
88+
if (attr_value == 0):
89+
status = 1
90+
91+
return status
92+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#
2+
# psuutil.py
3+
# Platform-specific PSU status interface for SONiC
4+
#
5+
6+
7+
import os.path
8+
9+
try:
10+
from sonic_psu.psu_base import PsuBase
11+
except ImportError as e:
12+
raise ImportError(str(e) + "- required module not found")
13+
14+
15+
class PsuUtil(PsuBase):
16+
"""Platform-specific PSUutil class"""
17+
18+
PSU_CPLD_DIR = "/sys/bus/i2c/devices/0-0033"
19+
20+
def __init__(self):
21+
PsuBase.__init__(self)
22+
23+
24+
# Get sysfs attribute
25+
def get_attr_value(self, attr_path):
26+
27+
retval = 'ERR'
28+
if (not os.path.isfile(attr_path)):
29+
return retval
30+
31+
try:
32+
with open(attr_path, 'r') as fd:
33+
retval = fd.read()
34+
except Exception as error:
35+
logging.error("Unable to open ", attr_path, " file !")
36+
37+
retval = retval.rstrip('\r\n')
38+
return retval
39+
40+
def get_num_psus(self):
41+
"""
42+
Retrieves the number of PSUs available on the device
43+
:return: An integer, the number of PSUs available on the device
44+
"""
45+
MAX_PSUS = 2
46+
return MAX_PSUS
47+
48+
def get_psu_status(self, index):
49+
"""
50+
Retrieves the oprational status of power supply unit (PSU) defined
51+
by index <index>
52+
:param index: An integer, index of the PSU of which to query status
53+
:return: Boolean, True if PSU is operating properly, False if PSU is\
54+
faulty
55+
"""
56+
status = 0
57+
mask = [ 0x08, 0x10 ]
58+
attr_file = 'cpld_pw_good'
59+
attr_path = self.PSU_CPLD_DIR +'/'+ attr_file
60+
61+
attr_value = self.get_attr_value(attr_path)
62+
63+
if (attr_value != 'ERR'):
64+
attr_value = int(attr_value, 16)
65+
# Check for PSU status
66+
if (attr_value & mask[index-1]):
67+
status = 1
68+
69+
return status
70+
71+
def get_psu_presence(self, index):
72+
"""
73+
Retrieves the presence status of power supply unit (PSU) defined
74+
by index <index>
75+
:param index: An integer, index of the PSU of which to query status
76+
:return: Boolean, True if PSU is plugged, False if not
77+
"""
78+
status = 0
79+
mask = [ 0x01, 0x02 ]
80+
attr_file ='cpld_pw_abs'
81+
attr_path = self.PSU_CPLD_DIR +'/'+ attr_file
82+
83+
attr_value = self.get_attr_value(attr_path)
84+
85+
if (attr_value != 'ERR'):
86+
attr_value = int(attr_value, 16)
87+
# Check for PSU presence
88+
if (~attr_value & mask[index-1]):
89+
status = 1
90+
91+
return status
92+

device/ingrasys/x86_64-ingrasys_s9100-r0/sensors.conf

+10
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,24 @@ chip "jc42-*"
99

1010
chip "w83795adg-*"
1111
label in0 "1.0V"
12+
set in0_min 1.00 * 0.97
13+
set in0_max 1.00 * 1.03
1214
label in1 "1.0V_ROV"
15+
set in1_min 1.00 * 0.98
16+
set in1_max 1.00 * 1.02
1317
label in2 "1.25V"
18+
set in2_min 1.25 * 0.97
19+
set in2_max 1.25 * 1.03
1420
label in3 "1.8V"
21+
set in3_min 1.80 * 0.97
22+
set in3_max 1.80 * 1.03
1523
ignore in4
1624
ignore in5
1725
ignore in6
1826
ignore in7
1927
label in12 "+3.3V"
28+
set in12_min 3.30 * 0.97
29+
set in12_max 3.30 * 1.03
2030
ignore in14
2131
ignore in15
2232
ignore in16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
#
2+
# psuutil.py
3+
# Platform-specific PSU status interface for SONiC
4+
#
5+
6+
7+
import os.path
8+
9+
try:
10+
from sonic_psu.psu_base import PsuBase
11+
except ImportError as e:
12+
raise ImportError(str(e) + "- required module not found")
13+
14+
15+
class PsuUtil(PsuBase):
16+
"""Platform-specific PSUutil class"""
17+
18+
SYSFS_PSU_DIR = ["/sys/bus/i2c/devices/i2c-18/18-0050",
19+
"/sys/bus/i2c/devices/i2c-17/17-0050"]
20+
21+
def __init__(self):
22+
PsuBase.__init__(self)
23+
24+
25+
# Get sysfs attribute
26+
def get_attr_value(self, attr_path):
27+
28+
retval = 'ERR'
29+
if (not os.path.isfile(attr_path)):
30+
return retval
31+
32+
try:
33+
with open(attr_path, 'r') as fd:
34+
retval = fd.read()
35+
except Exception as error:
36+
logging.error("Unable to open ", attr_path, " file !")
37+
38+
retval = retval.rstrip('\r\n')
39+
return retval
40+
41+
def get_num_psus(self):
42+
"""
43+
Retrieves the number of PSUs available on the device
44+
:return: An integer, the number of PSUs available on the device
45+
"""
46+
MAX_PSUS = 2
47+
return MAX_PSUS
48+
49+
def get_psu_status(self, index):
50+
"""
51+
Retrieves the oprational status of power supply unit (PSU) defined
52+
by index <index>
53+
:param index: An integer, index of the PSU of which to query status
54+
:return: Boolean, True if PSU is operating properly, False if PSU is\
55+
faulty
56+
"""
57+
status = 0
58+
attr_file = 'psu_pg'
59+
attr_path = self.SYSFS_PSU_DIR[index-1] +'/' + attr_file
60+
61+
attr_value = self.get_attr_value(attr_path)
62+
63+
if (attr_value != 'ERR'):
64+
attr_value = int(attr_value, 16)
65+
# Check for PSU status
66+
if (attr_value == 1):
67+
status = 1
68+
69+
return status
70+
71+
def get_psu_presence(self, index):
72+
"""
73+
Retrieves the presence status of power supply unit (PSU) defined
74+
by index <index>
75+
:param index: An integer, index of the PSU of which to query status
76+
:return: Boolean, True if PSU is plugged, False if not
77+
"""
78+
status = 0
79+
psu_absent = 0
80+
attr_file ='psu_abs'
81+
attr_path = self.SYSFS_PSU_DIR[index-1] +'/' + attr_file
82+
83+
attr_value = self.get_attr_value(attr_path)
84+
85+
if (attr_value != 'ERR'):
86+
attr_value = int(attr_value, 16)
87+
# Check for PSU presence
88+
if (attr_value == 0):
89+
status = 1
90+
91+
return status
92+

device/ingrasys/x86_64-ingrasys_s9200_64x-r0/sensors.conf

+13-3
Original file line numberDiff line numberDiff line change
@@ -49,20 +49,30 @@ chip "w83795adg-*"
4949
ignore temp3
5050
ignore temp4
5151
ignore intrusion0
52+
53+
chip "tmp75-i2c-*-4A"
54+
label temp1 "BMC Board Temp"
55+
set temp1_max 50
56+
set temp1_max_hyst 45
57+
58+
chip "tmp75-i2c-*-4F"
59+
label temp1 "x86 CPU Board Temp"
60+
set temp1_max 50
61+
set temp1_max_hyst 45
62+
5263
bus "i2c-6" "i2c-0-mux (chan_id 5)"
5364
chip "lm75-i2c-6-4E"
5465
label temp1 "MAC Temp"
5566
set temp1_max 50
5667
set temp1_max_hyst 45
5768

58-
bus "i2c-6" "i2c-0-mux (chan_id 5)"
5969
chip "lm75-i2c-6-4D"
60-
label temp1 "REAR Temp"
70+
label temp1 "REAR MAC Temp"
6171
set temp1_max 50
6272
set temp1_max_hyst 45
6373

6474
bus "i2c-7" "i2c-0-mux (chan_id 6)"
6575
chip "lm75-i2c-7-4D"
66-
label temp1 "Front Temp"
76+
label temp1 "Front MAC Temp"
6777
set temp1_max 50
6878
set temp1_max_hyst 45

0 commit comments

Comments
 (0)