[Platform] Marvell hwsku ET6448M i2c slave access fixes (#3275)

Signed-off-by: Antony Rheneus <arheneus@marvell.com>
This commit is contained in:
arheneus@marvell.com 2019-08-02 23:30:18 +05:30 committed by lguohan
parent 2bb58044c0
commit 7e98e3f461
2 changed files with 62 additions and 27 deletions

View File

@ -1,7 +1,18 @@
#!/usr/bin/env python
import sys
import os.path
import subprocess
if sys.version_info[0] < 3:
import commands as cmd
else:
import subprocess as cmd
smbus_present = 1
try:
import smbus
except ImportError as e:
smbus_present = 0
try:
from sonic_psu.psu_base import PsuBase
except ImportError as e:
@ -21,10 +32,14 @@ class PsuUtil(PsuBase):
def get_psu_status(self, index):
if index is None:
return False
cmdstatus, psustatus = subprocess.getstatusoutput('i2cget -y 0 0x41 0xa') #need to verify the cpld register logic
if smbus_present == 0:
cmdstatus, psustatus = cmd.getstatusoutput('i2cget -y 0 0x41 0xa') #need to verify the cpld register logic
psustatus = int(psustatus, 16)
if cmdstatus == 0:
else :
bus = smbus.SMBus(0)
DEVICE_ADDRESS = 0x41
DEVICE_REG = 0xa
psustatus = bus.read_byte_data(DEVICE_ADDRESS, DEVICE_REG)
if index == 1:
psustatus = psustatus&4
if psustatus == 4 :
@ -33,15 +48,22 @@ class PsuUtil(PsuBase):
psustatus = psustatus&8
if psustatus == 8 :
return True
return False
def get_psu_presence(self, index):
if index is None:
return False
cmdstatus , psustatus = subprocess.getstatusoutput('i2cget -y 0 0x41 0xa') #need to verify the cpld register logic
if smbus_present == 0:
cmdstatus, psustatus = cmd.getstatusoutput('i2cget -y 0 0x41 0xa') #need to verify the cpld register logic
psustatus = int(psustatus, 16)
if cmdstatus == 0:
else :
bus = smbus.SMBus(0)
DEVICE_ADDRESS = 0x41
DEVICE_REG = 0xa
psustatus = bus.read_byte_data(DEVICE_ADDRESS, DEVICE_REG)
if index == 1:
psustatus = psustatus&1
if psustatus == 1 :

View File

@ -8,6 +8,12 @@ try:
except ImportError, e:
raise ImportError (str(e) + "- required module not found")
smbus_present = 1
try:
import smbus
except ImportError, e:
smbus_present = 0
class SfpUtil(SfpUtilBase):
"""Platform specific sfputil class"""
@ -37,14 +43,21 @@ class SfpUtil(SfpUtilBase):
if not os.path.exists("/sys/bus/i2c/devices/0-0050") :
os.system("echo optoe2 0x50 > /sys/bus/i2c/devices/i2c-0/new_device")
#os.system("echo optoe 0x50 > /sys/bus/i2c/devices/i2c-0/new_device")
#enable optic
os.system("i2cset -y -m 0x0f 0 0x41 0x5 0x00")
eeprom_path = '/sys/bus/i2c/devices/0-0050/eeprom'
for x in range(self.port_start, self.port_end + 1):
port_eeprom_path = eeprom_path.format(self.port_to_i2c_mapping[x])
self.port_to_eeprom_mapping[x] = port_eeprom_path
# Enable optical SFP Tx
if smbus_present == 0 :
os.system("i2cset -y -m 0x0f 0 0x41 0x5 0x00")
else :
bus = smbus.SMBus(0)
DEVICE_ADDRESS = 0x41
DEVICEREG = 0x5
OPTIC_E = bus.read_byte_data(DEVICE_ADDRESS, DEVICEREG)
OPTIC_E = OPTIC_E & 0xf0
bus.write_byte_data(DEVICE_ADDRESS, DEVICEREG, OPTIC_E)
SfpUtilBase.__init__(self)
def reset(self, port_num):