sonic-buildimage/device/accton/x86_64-accton_as9716_32d-r0/plugins/eeprom.py
jostar-yang c9059992a0
[AS9716-32D]:Support 0x57 and 0x56 eeprom (#4103)
* [AS9716-32D]:Support 0x57 and 0x56 eeprom

* Add checking sysfs use 0x57 or 0x56

Co-authored-by: Jostar Yang <jostar_yang@accton.com.tw>
2020-03-21 14:26:55 -07:00

35 lines
927 B
Python

#!/usr/bin/env python
try:
import exceptions
import binascii
import time
import optparse
import warnings
import os
import sys
from sonic_eeprom import eeprom_base
from sonic_eeprom import eeprom_tlvinfo
import subprocess
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):
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)