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

[AS9716-32D]:Support 0x57 and 0x56 eeprom #4103

Merged
merged 2 commits into from
Mar 21, 2020
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
15 changes: 14 additions & 1 deletion device/accton/x86_64-accton_as9716_32d-r0/plugins/eeprom.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,21 @@
except ImportError, e:
raise ImportError (str(e) + "- required module not found")

def eeprom_check():
filepath="/sys/bus/i2c/devices/0-0057/eeprom"
if os.path.isfile(filepath):
return 1 #now board, 0x57
else:
return 0 #now board, 0x56

class board(eeprom_tlvinfo.TlvInfoDecoder):
_TLV_INFO_MAX_LEN = 256
def __init__(self, name, path, cpld_root, ro):
self.eeprom_path = "/sys/bus/i2c/devices/0-0056/eeprom"
ret=eeprom_check()
if ret==1:
self.eeprom_path = "/sys/bus/i2c/devices/0-0057/eeprom"
else:
self.eeprom_path = "/sys/bus/i2c/devices/0-0056/eeprom"

super(board, self).__init__(self.eeprom_path, 0, '', True)

Original file line number Diff line number Diff line change
Expand Up @@ -123,13 +123,14 @@
# PSU-2
'echo as9716_32d_psu2 0x51 > /sys/bus/i2c/devices/i2c-10/new_device',
'echo acbel_fsh082 0x59 > /sys/bus/i2c/devices/i2c-10/new_device',
]

#EERPOM
eeprom_mknod =[
'echo 24c02 0x57 > /sys/bus/i2c/devices/i2c-0/new_device',
'echo 24c02 0x56 > /sys/bus/i2c/devices/i2c-0/new_device',
]



FORCE = 0
logging.basicConfig(filename= PROJECT_NAME+'.log', filemode='w',level=logging.DEBUG)
logging.basicConfig(level=logging.INFO)
Expand Down Expand Up @@ -301,8 +302,14 @@ def driver_uninstall():
return status
return 0

def eeprom_check():
cmd = "i2cget -y -f 0 0x57"
status, output = commands.getstatusoutput(cmd)
return status

def device_install():
global FORCE
global use_57_eeprom

for i in range(0,len(mknod)):
#for pca954x need times to built new i2c buses
Expand All @@ -315,6 +322,12 @@ def device_install():
if FORCE == 0:
return status

ret=eeprom_check()
if ret==0:
log_os_system(eeprom_mknod[0], 1) #new board, 0x57 eeprom
else:
log_os_system(eeprom_mknod[1], 1) #old board, 0x56 eeprom

for i in range(0,len(sfp_map)):
status, output =log_os_system("echo optoe1 0x50 > /sys/bus/i2c/devices/i2c-"+str(sfp_map[i])+"/new_device", 1)
if status:
Expand Down Expand Up @@ -358,6 +371,17 @@ def device_uninstall():
if FORCE == 0:
return status

ret=eeprom_check()
if ret==0:
target = eeprom_mknod[0] #0x57
else:
target = eeprom_mknod[1] #0x56

temp = target.split()
del temp[1]
temp[-1] = temp[-1].replace('new_device', 'delete_device')
status, output = log_os_system(" ".join(temp), 1)

return

def system_ready():
Expand Down