-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Platform] Add psuutil and update submodule for Ingrasys S9100-32X, S…
…8810-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 <chihen.he@gmail.com> * [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 <chihen.he@gmail.com>
- Loading branch information
Showing
6 changed files
with
300 additions
and
4 deletions.
There are no files selected for viewing
92 changes: 92 additions & 0 deletions
92
device/ingrasys/x86_64-ingrasys_s8810_32q-r0/plugins/psuutil.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# | ||
# psuutil.py | ||
# Platform-specific PSU status interface for SONiC | ||
# | ||
|
||
|
||
import os.path | ||
|
||
try: | ||
from sonic_psu.psu_base import PsuBase | ||
except ImportError as e: | ||
raise ImportError(str(e) + "- required module not found") | ||
|
||
|
||
class PsuUtil(PsuBase): | ||
"""Platform-specific PSUutil class""" | ||
|
||
SYSFS_PSU_DIR = ["/sys/bus/i2c/devices/i2c-3/3-0051", | ||
"/sys/bus/i2c/devices/i2c-4/4-0051"] | ||
|
||
def __init__(self): | ||
PsuBase.__init__(self) | ||
|
||
|
||
# Get sysfs attribute | ||
def get_attr_value(self, attr_path): | ||
|
||
retval = 'ERR' | ||
if (not os.path.isfile(attr_path)): | ||
return retval | ||
|
||
try: | ||
with open(attr_path, 'r') as fd: | ||
retval = fd.read() | ||
except Exception as error: | ||
logging.error("Unable to open ", attr_path, " file !") | ||
|
||
retval = retval.rstrip('\r\n') | ||
return retval | ||
|
||
def get_num_psus(self): | ||
""" | ||
Retrieves the number of PSUs available on the device | ||
:return: An integer, the number of PSUs available on the device | ||
""" | ||
MAX_PSUS = 2 | ||
return MAX_PSUS | ||
|
||
def get_psu_status(self, index): | ||
""" | ||
Retrieves the oprational status of power supply unit (PSU) defined | ||
by index <index> | ||
:param index: An integer, index of the PSU of which to query status | ||
:return: Boolean, True if PSU is operating properly, False if PSU is\ | ||
faulty | ||
""" | ||
status = 0 | ||
attr_file = 'psu_pg' | ||
attr_path = self.SYSFS_PSU_DIR[index-1] +'/' + attr_file | ||
|
||
attr_value = self.get_attr_value(attr_path) | ||
|
||
if (attr_value != 'ERR'): | ||
attr_value = int(attr_value, 16) | ||
# Check for PSU status | ||
if (attr_value == 1): | ||
status = 1 | ||
|
||
return status | ||
|
||
def get_psu_presence(self, index): | ||
""" | ||
Retrieves the presence status of power supply unit (PSU) defined | ||
by index <index> | ||
:param index: An integer, index of the PSU of which to query status | ||
:return: Boolean, True if PSU is plugged, False if not | ||
""" | ||
status = 0 | ||
psu_absent = 0 | ||
attr_file ='psu_abs' | ||
attr_path = self.SYSFS_PSU_DIR[index-1] +'/' + attr_file | ||
|
||
attr_value = self.get_attr_value(attr_path) | ||
|
||
if (attr_value != 'ERR'): | ||
attr_value = int(attr_value, 16) | ||
# Check for PSU presence | ||
if (attr_value == 0): | ||
status = 1 | ||
|
||
return status | ||
|
92 changes: 92 additions & 0 deletions
92
device/ingrasys/x86_64-ingrasys_s9100-r0/plugins/psuutil.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# | ||
# psuutil.py | ||
# Platform-specific PSU status interface for SONiC | ||
# | ||
|
||
|
||
import os.path | ||
|
||
try: | ||
from sonic_psu.psu_base import PsuBase | ||
except ImportError as e: | ||
raise ImportError(str(e) + "- required module not found") | ||
|
||
|
||
class PsuUtil(PsuBase): | ||
"""Platform-specific PSUutil class""" | ||
|
||
PSU_CPLD_DIR = "/sys/bus/i2c/devices/0-0033" | ||
|
||
def __init__(self): | ||
PsuBase.__init__(self) | ||
|
||
|
||
# Get sysfs attribute | ||
def get_attr_value(self, attr_path): | ||
|
||
retval = 'ERR' | ||
if (not os.path.isfile(attr_path)): | ||
return retval | ||
|
||
try: | ||
with open(attr_path, 'r') as fd: | ||
retval = fd.read() | ||
except Exception as error: | ||
logging.error("Unable to open ", attr_path, " file !") | ||
|
||
retval = retval.rstrip('\r\n') | ||
return retval | ||
|
||
def get_num_psus(self): | ||
""" | ||
Retrieves the number of PSUs available on the device | ||
:return: An integer, the number of PSUs available on the device | ||
""" | ||
MAX_PSUS = 2 | ||
return MAX_PSUS | ||
|
||
def get_psu_status(self, index): | ||
""" | ||
Retrieves the oprational status of power supply unit (PSU) defined | ||
by index <index> | ||
:param index: An integer, index of the PSU of which to query status | ||
:return: Boolean, True if PSU is operating properly, False if PSU is\ | ||
faulty | ||
""" | ||
status = 0 | ||
mask = [ 0x08, 0x10 ] | ||
attr_file = 'cpld_pw_good' | ||
attr_path = self.PSU_CPLD_DIR +'/'+ attr_file | ||
|
||
attr_value = self.get_attr_value(attr_path) | ||
|
||
if (attr_value != 'ERR'): | ||
attr_value = int(attr_value, 16) | ||
# Check for PSU status | ||
if (attr_value & mask[index-1]): | ||
status = 1 | ||
|
||
return status | ||
|
||
def get_psu_presence(self, index): | ||
""" | ||
Retrieves the presence status of power supply unit (PSU) defined | ||
by index <index> | ||
:param index: An integer, index of the PSU of which to query status | ||
:return: Boolean, True if PSU is plugged, False if not | ||
""" | ||
status = 0 | ||
mask = [ 0x01, 0x02 ] | ||
attr_file ='cpld_pw_abs' | ||
attr_path = self.PSU_CPLD_DIR +'/'+ attr_file | ||
|
||
attr_value = self.get_attr_value(attr_path) | ||
|
||
if (attr_value != 'ERR'): | ||
attr_value = int(attr_value, 16) | ||
# Check for PSU presence | ||
if (~attr_value & mask[index-1]): | ||
status = 1 | ||
|
||
return status | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
device/ingrasys/x86_64-ingrasys_s9200_64x-r0/plugins/psuutil.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
# | ||
# psuutil.py | ||
# Platform-specific PSU status interface for SONiC | ||
# | ||
|
||
|
||
import os.path | ||
|
||
try: | ||
from sonic_psu.psu_base import PsuBase | ||
except ImportError as e: | ||
raise ImportError(str(e) + "- required module not found") | ||
|
||
|
||
class PsuUtil(PsuBase): | ||
"""Platform-specific PSUutil class""" | ||
|
||
SYSFS_PSU_DIR = ["/sys/bus/i2c/devices/i2c-18/18-0050", | ||
"/sys/bus/i2c/devices/i2c-17/17-0050"] | ||
|
||
def __init__(self): | ||
PsuBase.__init__(self) | ||
|
||
|
||
# Get sysfs attribute | ||
def get_attr_value(self, attr_path): | ||
|
||
retval = 'ERR' | ||
if (not os.path.isfile(attr_path)): | ||
return retval | ||
|
||
try: | ||
with open(attr_path, 'r') as fd: | ||
retval = fd.read() | ||
except Exception as error: | ||
logging.error("Unable to open ", attr_path, " file !") | ||
|
||
retval = retval.rstrip('\r\n') | ||
return retval | ||
|
||
def get_num_psus(self): | ||
""" | ||
Retrieves the number of PSUs available on the device | ||
:return: An integer, the number of PSUs available on the device | ||
""" | ||
MAX_PSUS = 2 | ||
return MAX_PSUS | ||
|
||
def get_psu_status(self, index): | ||
""" | ||
Retrieves the oprational status of power supply unit (PSU) defined | ||
by index <index> | ||
:param index: An integer, index of the PSU of which to query status | ||
:return: Boolean, True if PSU is operating properly, False if PSU is\ | ||
faulty | ||
""" | ||
status = 0 | ||
attr_file = 'psu_pg' | ||
attr_path = self.SYSFS_PSU_DIR[index-1] +'/' + attr_file | ||
|
||
attr_value = self.get_attr_value(attr_path) | ||
|
||
if (attr_value != 'ERR'): | ||
attr_value = int(attr_value, 16) | ||
# Check for PSU status | ||
if (attr_value == 1): | ||
status = 1 | ||
|
||
return status | ||
|
||
def get_psu_presence(self, index): | ||
""" | ||
Retrieves the presence status of power supply unit (PSU) defined | ||
by index <index> | ||
:param index: An integer, index of the PSU of which to query status | ||
:return: Boolean, True if PSU is plugged, False if not | ||
""" | ||
status = 0 | ||
psu_absent = 0 | ||
attr_file ='psu_abs' | ||
attr_path = self.SYSFS_PSU_DIR[index-1] +'/' + attr_file | ||
|
||
attr_value = self.get_attr_value(attr_path) | ||
|
||
if (attr_value != 'ERR'): | ||
attr_value = int(attr_value, 16) | ||
# Check for PSU presence | ||
if (attr_value == 0): | ||
status = 1 | ||
|
||
return status | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule sonic-platform-modules-ingrasys
updated
12 files
+1 −0 | s8810-32q/modules/Makefile | |
+148 −0 | s8810-32q/modules/ingrasys_s8810_32q_platform.h | |
+412 −0 | s8810-32q/modules/ingrasys_s8810_32q_psu.c | |
+115 −90 | s8810-32q/utils/i2c_utils.sh | |
+1 −0 | s9100/modules/Makefile | |
+448 −0 | s9100/modules/i2c_cpld.c | |
+199 −0 | s9100/modules/i2c_cpld.h | |
+43 −47 | s9100/utils/i2c_utils.sh | |
+2 −1 | s9200-64x/modules/Makefile | |
+148 −0 | s9200-64x/modules/ingrasys_s9200_64x_platform.h | |
+408 −0 | s9200-64x/modules/ingrasys_s9200_64x_psu.c | |
+44 −31 | s9200-64x/utils/i2c_utils.sh |