Skip to content

Commit

Permalink
[Platform] Add Psuutil and update sensors.conf for S9100-32X, S8810-3…
Browse files Browse the repository at this point in the history
…2Q and S9200-64X (#1272)

* Add I2C CPLD kernel module for psuutil.
 * Support psuutil script.
 * Add voltage min and max threshold.
 * Update sensors.conf for tmp75.

Signed-off-by: Wade He <[email protected]>
  • Loading branch information
wadelnn authored and lguohan committed Dec 29, 2017
1 parent 0b6deb9 commit a1d06d7
Show file tree
Hide file tree
Showing 6 changed files with 300 additions and 4 deletions.
92 changes: 92 additions & 0 deletions device/ingrasys/x86_64-ingrasys_s8810_32q-r0/plugins/psuutil.py
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 device/ingrasys/x86_64-ingrasys_s9100-r0/plugins/psuutil.py
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

10 changes: 10 additions & 0 deletions device/ingrasys/x86_64-ingrasys_s9100-r0/sensors.conf
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,24 @@ chip "jc42-*"

chip "w83795adg-*"
label in0 "1.0V"
set in0_min 1.00 * 0.97
set in0_max 1.00 * 1.03
label in1 "1.0V_ROV"
set in1_min 1.00 * 0.98
set in1_max 1.00 * 1.02
label in2 "1.25V"
set in2_min 1.25 * 0.97
set in2_max 1.25 * 1.03
label in3 "1.8V"
set in3_min 1.80 * 0.97
set in3_max 1.80 * 1.03
ignore in4
ignore in5
ignore in6
ignore in7
label in12 "+3.3V"
set in12_min 3.30 * 0.97
set in12_max 3.30 * 1.03
ignore in14
ignore in15
ignore in16
Expand Down
92 changes: 92 additions & 0 deletions device/ingrasys/x86_64-ingrasys_s9200_64x-r0/plugins/psuutil.py
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

16 changes: 13 additions & 3 deletions device/ingrasys/x86_64-ingrasys_s9200_64x-r0/sensors.conf
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,30 @@ chip "w83795adg-*"
ignore temp3
ignore temp4
ignore intrusion0

chip "tmp75-i2c-*-4A"
label temp1 "BMC Board Temp"
set temp1_max 50
set temp1_max_hyst 45

chip "tmp75-i2c-*-4F"
label temp1 "x86 CPU Board Temp"
set temp1_max 50
set temp1_max_hyst 45

bus "i2c-6" "i2c-0-mux (chan_id 5)"
chip "lm75-i2c-6-4E"
label temp1 "MAC Temp"
set temp1_max 50
set temp1_max_hyst 45

bus "i2c-6" "i2c-0-mux (chan_id 5)"
chip "lm75-i2c-6-4D"
label temp1 "REAR Temp"
label temp1 "REAR MAC Temp"
set temp1_max 50
set temp1_max_hyst 45

bus "i2c-7" "i2c-0-mux (chan_id 6)"
chip "lm75-i2c-7-4D"
label temp1 "Front Temp"
label temp1 "Front MAC Temp"
set temp1_max 50
set temp1_max_hyst 45

0 comments on commit a1d06d7

Please sign in to comment.