Skip to content

Commit

Permalink
[devices/accton]:bugfix: potential i2c fault from IC IR3570a (#2966)
Browse files Browse the repository at this point in the history
Disabling i2c function of ir3507a which may failed i2c tranfer to others.
Signed-off-by: roy_lee <[email protected]>
  • Loading branch information
roylee123 authored and lguohan committed Jun 5, 2019
1 parent bd51932 commit 4f85c7c
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def driver_inserted():
kos = [
'depmod -ae',
'modprobe i2c_dev',
'modprobe i2c_mux_pca954x',
'modprobe i2c_mux_pca954x force_deselect_on_exit=1',
'modprobe optoe',
'modprobe i2c-mux-accton_as5712_54x_cpld',
'modprobe cpr_4011_4mxx',
Expand All @@ -273,7 +273,15 @@ def driver_install():
def driver_uninstall():
global FORCE
for i in range(0,len(kos)):
rm = kos[-(i+1)].replace("modprobe", "modprobe -rq")
#remove parameter if any
rm = kos[-(i+1)]
lst = rm.split(" ")
if len(lst) > 2:
del(lst[2:])
rm = " ".join(lst)

#Change to removing commands
rm = rm.replace("modprobe", "modprobe -rq")
rm = rm.replace("insmod", "rmmod")
status, output = log_os_system(rm, 1)
if status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ def driver_inserted():
kos = [
'depmod -ae',
'modprobe i2c_dev',
'modprobe i2c_mux_pca954x',
'modprobe i2c_mux_pca954x force_deselect_on_exit=1',
'modprobe optoe',
'modprobe i2c-mux-accton_as5812_54x_cpld',
'modprobe cpr_4011_4mxx',
Expand All @@ -273,7 +273,15 @@ def driver_install():
def driver_uninstall():
global FORCE
for i in range(0,len(kos)):
rm = kos[-(i+1)].replace("modprobe", "modprobe -rq")
#remove parameter if any
rm = kos[-(i+1)]
lst = rm.split(" ")
if len(lst) > 2:
del(lst[2:])
rm = " ".join(lst)

#Change to removing commands
rm = rm.replace("modprobe", "modprobe -rq")
rm = rm.replace("insmod", "rmmod")
status, output = log_os_system(rm, 1)
if status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,7 @@ def driver_inserted():
kos = [
'depmod -ae',
'modprobe i2c_dev',
'modprobe i2c_mux_pca954x',
'modprobe i2c_mux_pca954x force_deselect_on_exit=1',
'modprobe optoe',
'modprobe accton_as6712_32x_cpld',
'modprobe cpr_4011_4mxx',
Expand All @@ -281,7 +281,15 @@ def driver_install():
def driver_uninstall():
global FORCE
for i in range(0,len(kos)):
rm = kos[-(i+1)].replace("modprobe", "modprobe -rq")
#remove parameter if any
rm = kos[-(i+1)]
lst = rm.split(" ")
if len(lst) > 2:
del(lst[2:])
rm = " ".join(lst)

#Change to removing commands
rm = rm.replace("modprobe", "modprobe -rq")
rm = rm.replace("insmod", "rmmod")
status, output = log_os_system(rm, 1)
if status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,29 @@ def show_set_help():
print " use \""+ cmd + " sfp 1-32 {0|1}\" to set sfp# tx_disable"
sys.exit(0)

def diss_i2c_ir3507a(addr):
cmd = "i2cset -y 0 0x%x 0xE5 0x01" % addr
status, output = commands.getstatusoutput(cmd)
cmd = "i2cset -y 0 0x%x 0x12 0x02" % addr
status, output = commands.getstatusoutput(cmd)
return status

def ir3507_check():
cmd = "i2cdump -y 0 0x42 s 0x9a"
try:
status, output = commands.getstatusoutput(cmd)
lines = output.split('\n')
hn = re.findall(r'\w+', lines[-1])
version = int(hn[1], 16)
if version == 0x24: #only for ir3507a
ret = diss_i2c_ir3507a(4)
else:
ret = 0
except Exception as e:
print "Error on ir3507_check() e:" + str(e)
return -1
return ret

def show_eeprom_help():
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
print " use \""+ cmd + " 1-32 \" to dump sfp# eeprom"
Expand Down Expand Up @@ -256,7 +279,7 @@ def driver_inserted():
kos = [
'depmod -ae',
'modprobe i2c_dev',
'modprobe i2c_mux_pca954x',
'modprobe i2c_mux_pca954x force_deselect_on_exit=1',
'modprobe accton_i2c_cpld',
'modprobe cpr_4011_4mxx',
'modprobe ym2651y',
Expand All @@ -277,7 +300,15 @@ def driver_install():
def driver_uninstall():
global FORCE
for i in range(0,len(kos)):
rm = kos[-(i+1)].replace("modprobe", "modprobe -rq")
#remove parameter if any
rm = kos[-(i+1)]
lst = rm.split(" ")
if len(lst) > 2:
del(lst[2:])
rm = " ".join(lst)

#Change to removing commands
rm = rm.replace("modprobe", "modprobe -rq")
rm = rm.replace("insmod", "rmmod")
status, output = log_os_system(rm, 1)
if status:
Expand Down Expand Up @@ -378,6 +409,9 @@ def do_install():
return status
else:
print PROJECT_NAME.upper()+" drivers detected...."

ir3507_check()

if not device_exist():
status = device_install()
if status:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,29 @@ def show_set_help():
print " use \""+ cmd + " sfp 1-32 {0|1}\" to set sfp# tx_disable"
sys.exit(0)

def diss_i2c_ir3507a(addr):
cmd = "i2cset -y 0 0x%x 0xE5 0x01" % addr
status, output = commands.getstatusoutput(cmd)
cmd = "i2cset -y 0 0x%x 0x12 0x02" % addr
status, output = commands.getstatusoutput(cmd)
return status

def ir3507_check():
cmd = "i2cdump -y 0 0x42 s 0x9a"
try:
status, output = commands.getstatusoutput(cmd)
lines = output.split('\n')
hn = re.findall(r'\w+', lines[-1])
version = int(hn[1], 16)
if version == 0x24: #only for ir3507a
ret = diss_i2c_ir3507a(4)
else:
ret = 0
except Exception as e:
print "Error on ir3507_check() e:" + str(e)
return -1
return ret

def show_eeprom_help():
cmd = sys.argv[0].split("/")[-1]+ " " + args[0]
print " use \""+ cmd + " 1-32 \" to dump sfp# eeprom"
Expand Down Expand Up @@ -156,7 +179,7 @@ def driver_check():

kos = [
'modprobe i2c_dev',
'modprobe i2c_mux_pca954x',
'modprobe i2c_mux_pca954x force_deselect_on_exit=1',
'modprobe accton_i2c_cpld' ,
'modprobe ym2651y' ,
'modprobe x86-64-accton-as7816-64x-fan' ,
Expand All @@ -177,7 +200,15 @@ def driver_install():
def driver_uninstall():
global FORCE
for i in range(0,len(kos)):
rm = kos[-(i+1)].replace("modprobe", "modprobe -rq")
#remove parameter if any
rm = kos[-(i+1)]
lst = rm.split(" ")
if len(lst) > 2:
del(lst[2:])
rm = " ".join(lst)

#Change to removing commands
rm = rm.replace("modprobe", "modprobe -rq")
rm = rm.replace("insmod", "rmmod")
status, output = log_os_system(rm, 1)
if status:
Expand Down Expand Up @@ -304,6 +335,9 @@ def do_install():
return status
else:
print PROJECT_NAME.upper()+" drivers detected...."

ir3507_check()

if not device_exist():
print "No device, installing...."
status = device_install()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,6 @@ def driver_inserted():
'depmod -ae',
'modprobe i2c_dev',
'modprobe i2c_mux_pca954x force_deselect_on_exit=1',
#'modprobe i2c_mux_pca954x',
'modprobe optoe',
'modprobe minipack_psensor']

Expand All @@ -207,7 +206,15 @@ def driver_install():

def driver_uninstall():
for i in range(0,len(kos)):
rm = kos[-(i+1)].replace("modprobe", "modprobe -rq")
#remove parameter if any
rm = kos[-(i+1)]
lst = rm.split(" ")
if len(lst) > 2:
del(lst[2:])
rm = " ".join(lst)

#Change to removing commands
rm = rm.replace("modprobe", "modprobe -rq")
rm = rm.replace("insmod", "rmmod")
status, output = log_os_system(rm, 1)
if status:
Expand Down

0 comments on commit 4f85c7c

Please sign in to comment.