Skip to content

Commit

Permalink
[Author]: jersyang@celestica.com [Jira ID]:N/A fix the i2c controller…
Browse files Browse the repository at this point in the history
… initialize sequence
  • Loading branch information
nicwu-cel committed Apr 28, 2022
1 parent 318e5ea commit 6f31f8b
Show file tree
Hide file tree
Showing 6 changed files with 65 additions and 57 deletions.
2 changes: 1 addition & 1 deletion device/celestica/x86_64-cel_belgite-r0/installer.conf
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CONSOLE_PORT=0x3f8
CONSOLE_DEV=0
CONSOLE_SPEED=9600
ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="intel_iommu=off module_blacklist=gpio_ich crashkernel=0M-2G:256M,2G-4G:320M,4G-8G:384M,8G-:448M acpi_no_watchdog"
ONIE_PLATFORM_EXTRA_CMDLINE_LINUX="intel_iommu=off module_blacklist=gpio_ich,i2c-ismt,i2c_ismt,i2c-i801,i2c_i801 crashkernel=0M-2G:256M,2G-4G:320M,4G-8G:384M,8G-:448M acpi_no_watchdog"
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,63 @@

class Eeprom(PddfEeprom):

_TLV_DISPLAY_VENDOR_EXT = True
_TLV_INFO_MAX_LEN = 256
pddf_obj = {}
plugin_data = {}

def __init__(self, pddf_data=None, pddf_plugin_data=None):
PddfEeprom.__init__(self, pddf_data, pddf_plugin_data)
if not pddf_data or not pddf_plugin_data:
raise ValueError('PDDF JSON data error')

self.pddf_obj = pddf_data
self.plugin_data = pddf_plugin_data

# system EEPROM always has device name EEPROM1
self.eeprom_path = self.pddf_obj.get_path("EEPROM1", "eeprom")
if self.eeprom_path is None:
return

super(PddfEeprom, self).__init__(self.eeprom_path, 0, '', True)
#super().__init__(self.pddf_obj, self.plugin_data)
self.eeprom_tlv_dict = dict()
try:
self.eeprom_data = self.read_eeprom()
except Exception as e:
self.eeprom_data = "N/A"
raise RuntimeError("PddfEeprom is not Programmed - Error: {}".format(str(e)))
else:
eeprom = self.eeprom_data

if not self.is_valid_tlvinfo_header(eeprom):
return

total_length = ((eeprom[9]) << 8) | (eeprom[10])
tlv_index = self._TLV_INFO_HDR_LEN
tlv_end = self._TLV_INFO_HDR_LEN + total_length

while (tlv_index + 2) < self._TLV_INFO_MAX_LEN and tlv_index < tlv_end:
if not self.is_valid_tlv(eeprom[tlv_index:]):
break

tlv = eeprom[tlv_index:tlv_index + 2
+ (eeprom[tlv_index + 1])]
code = "0x%02X" % ((tlv[0]))

if (tlv[0]) == self._TLV_CODE_VENDOR_EXT:
name = "Vendor Extension" #lgtm [py/multiple-definition]
value = ""
if self._TLV_DISPLAY_VENDOR_EXT:
for c in tlv[2:2 + tlv[1]]:
value += "0x%02X " % c
else:
name, value = self.decoder(None, tlv)

self.eeprom_tlv_dict[code] = value
if (eeprom[tlv_index]) == self._TLV_CODE_CRC_32:
break

tlv_index += (eeprom[tlv_index+1]) + 2

def vendor_ext_str(self):
"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,5 @@ sudo i2cset -y -f 6 0x49 0x1 0x2
sleep 0.1
#Set LM75 shutdown enable
sudo i2cset -y -f 2 0x32 0x45 0x1


echo -2 | tee /sys/bus/i2c/drivers/pca954x/*-00*/idle_state
4 changes: 2 additions & 2 deletions platform/pddf/i2c/utils/pddf_util.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import shutil
import subprocess
import sys

from sonic_py_common import device_info
import pddfparse

PLATFORM_ROOT_PATH = '/usr/share/sonic/device'
Expand Down Expand Up @@ -139,7 +139,7 @@ def driver_check():

def get_path_to_device():
# Get platform and hwsku
(platform, hwsku) = pddf_obj.get_platform_and_hwsku()
(platform, hwsku) = device_info.get_platform_and_hwsku()

# Load platform module from source
platform_path = "/".join([PLATFORM_ROOT_PATH, platform])
Expand Down
28 changes: 2 additions & 26 deletions platform/pddf/i2c/utils/pddfparse.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import sys
import time
import unicodedata
from sonic_py_common import device_info

bmc_cache = {}
cache = {}
Expand All @@ -33,7 +34,7 @@
class PddfParse():
def __init__(self):
if not os.path.exists("/usr/share/sonic/platform"):
platform, hwsku = self.get_platform_and_hwsku()
platform, hwsku = device_info.get_platform_and_hwsku()
os.symlink("/usr/share/sonic/device/"+platform, "/usr/share/sonic/platform")

try:
Expand All @@ -47,31 +48,6 @@ def __init__(self):
self.data_sysfs_obj = {}
self.sysfs_obj = {}

# Returns platform and HW SKU
def get_platform_and_hwsku(self):
try:
proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-H', '-v', PLATFORM_KEY],
stdout=subprocess.PIPE,
shell=False,
universal_newlines=True,
stderr=subprocess.STDOUT)
stdout = proc.communicate()[0]
proc.wait()
platform = stdout.rstrip('\n')

proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-d', '-v', HWSKU_KEY],
stdout=subprocess.PIPE,
shell=False,
universal_newlines=True,
stderr=subprocess.STDOUT)
stdout = proc.communicate()[0]
proc.wait()
hwsku = stdout.rstrip('\n')
except OSError as e:
raise OSError("Cannot detect platform")

return (platform, hwsku)

###################################################################################################################
# GENERIC DEFS
###################################################################################################################
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import subprocess
import time
import unicodedata
from sonic_py_common import device_info

bmc_cache = {}
cache = {}
Expand All @@ -31,7 +32,7 @@
class PddfApi():
def __init__(self):
if not os.path.exists("/usr/share/sonic/platform"):
self.platform, self.hwsku = self.get_platform_and_hwsku()
self.platform, self.hwsku = device_info.get_platform_and_hwsku()
os.symlink("/usr/share/sonic/device/"+self.platform, "/usr/share/sonic/platform")

try:
Expand All @@ -44,31 +45,6 @@ def __init__(self):
self.data_sysfs_obj = {}
self.sysfs_obj = {}

# Returns platform and HW SKU
def get_platform_and_hwsku(self):
try:
proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-H', '-v', PLATFORM_KEY],
stdout=subprocess.PIPE,
shell=False,
universal_newlines=True,
stderr=subprocess.STDOUT)
stdout = proc.communicate()[0]
proc.wait()
platform = stdout.rstrip('\n')

proc = subprocess.Popen([SONIC_CFGGEN_PATH, '-d', '-v', HWSKU_KEY],
stdout=subprocess.PIPE,
shell=False,
universal_newlines=True,
stderr=subprocess.STDOUT)
stdout = proc.communicate()[0]
proc.wait()
hwsku = stdout.rstrip('\n')
except OSError as e:
raise OSError("Cannot detect platform")

return (platform, hwsku)

#################################################################################################################
# GENERIC DEFS
#################################################################################################################
Expand Down

0 comments on commit 6f31f8b

Please sign in to comment.