[Platform] Marvell hwsku ET6448M i2c slave access fixes (#3275)
Signed-off-by: Antony Rheneus <arheneus@marvell.com>
This commit is contained in:
parent
2bb58044c0
commit
7e98e3f461
@ -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,34 +32,45 @@ class PsuUtil(PsuBase):
|
||||
def get_psu_status(self, index):
|
||||
if index is None:
|
||||
return False
|
||||
if smbus_present == 0:
|
||||
cmdstatus, psustatus = cmd.getstatusoutput('i2cget -y 0 0x41 0xa') #need to verify the cpld register logic
|
||||
psustatus = int(psustatus, 16)
|
||||
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 :
|
||||
return True
|
||||
if index == 2:
|
||||
psustatus = psustatus&8
|
||||
if psustatus == 8 :
|
||||
return True
|
||||
|
||||
cmdstatus, psustatus = subprocess.getstatusoutput('i2cget -y 0 0x41 0xa') #need to verify the cpld register logic
|
||||
psustatus = int(psustatus, 16)
|
||||
if cmdstatus == 0:
|
||||
if index == 1:
|
||||
psustatus = psustatus&4
|
||||
if psustatus == 4 :
|
||||
return True
|
||||
if index == 2:
|
||||
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
|
||||
psustatus = int(psustatus, 16)
|
||||
if cmdstatus == 0:
|
||||
if index == 1:
|
||||
psustatus = psustatus&1
|
||||
if psustatus == 1 :
|
||||
return True
|
||||
if index == 2:
|
||||
psustatus = psustatus&2
|
||||
if psustatus == 2 :
|
||||
return True
|
||||
if smbus_present == 0:
|
||||
cmdstatus, psustatus = cmd.getstatusoutput('i2cget -y 0 0x41 0xa') #need to verify the cpld register logic
|
||||
psustatus = int(psustatus, 16)
|
||||
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 :
|
||||
return True
|
||||
if index == 2:
|
||||
psustatus = psustatus&2
|
||||
if psustatus == 2 :
|
||||
return True
|
||||
return False
|
||||
|
||||
|
@ -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):
|
||||
|
Loading…
Reference in New Issue
Block a user