Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
merged 1 commit into from
Aug 2, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
70 changes: 46 additions & 24 deletions device/marvell/armhf-marvell_et6448m_52x-r0/plugins/psuutil.py
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -21,34 +32,45 @@ def get_num_psus(self):
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
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
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

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

19 changes: 16 additions & 3 deletions device/marvell/armhf-marvell_et6448m_52x-r0/plugins/sfputil.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@
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"""
Expand Down Expand Up @@ -37,14 +43,21 @@ def __init__(self):

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):
Expand Down