[Accton AS7712] Add sfp reset in driver and sfputil.py. (#1241)

Signed-off-by: roylee123 <roy_lee@accton.com>
This commit is contained in:
Roy Lee 2017-12-15 16:59:41 +08:00 committed by lguohan
parent 1c0c3ff7a9
commit db7f173f23
2 changed files with 28 additions and 8 deletions

View File

@ -1,6 +1,7 @@
#!/usr/bin/env python #!/usr/bin/env python
try: try:
import time
from sonic_sfp.sfputilbase import SfpUtilBase from sonic_sfp.sfputilbase import SfpUtilBase
except ImportError, e: except ImportError, e:
raise ImportError (str(e) + "- required module not found") raise ImportError (str(e) + "- required module not found")
@ -59,14 +60,33 @@ class SfpUtil(SfpUtilBase):
SfpUtilBase.__init__(self) SfpUtilBase.__init__(self)
def reset(self, port_num): def reset(self, port_num):
return True # Check for invalid port_num
def set_low_power_mode(self, port_nuM, lpmode): if port_num < self._port_start or port_num > self._port_end:
return True return False
def get_low_power_mode(self, port_num):
return True
# def get_presence(self, port_num): path = "/sys/bus/i2c/devices/{0}-0050/sfp_port_reset"
# return True port_ps = path.format(self.port_to_i2c_mapping[port_num+1])
try:
reg_file = open(port_ps, 'w')
except IOError as e:
print "Error: unable to open file: %s" % str(e)
return False
#toggle reset
reg_file.seek(0)
reg_file.write('1')
time.sleep(1)
reg_file.seek(0)
reg_file.write('0')
reg_file.close()
return True
def set_low_power_mode(self, port_nuM, lpmode):
raise NotImplementedErro
def get_low_power_mode(self, port_num):
raise NotImplementedErro
def get_presence(self, port_num): def get_presence(self, port_num):
# Check for invalid port_num # Check for invalid port_num

@ -1 +1 @@
Subproject commit edfb5b2c1285cbfd30d8a662ab738aee53a80439 Subproject commit 7ba26ec403c7f0d0acb958f794311ac3fd1af9a1