From ff8e34463d73b87ce3c79ec7bdaca155ab8fb920 Mon Sep 17 00:00:00 2001 From: Roy Lee Date: Thu, 1 Aug 2019 02:28:03 +0800 Subject: [PATCH] [device/Accton] Fix i2c fault from ir3570a on 3 models (#3245) I2c burst read may failed due to misoperation of ir3570a(A DC-to-DC converter IC). As #2966, there are 3 more models have this symptom, as7326-56x, as7726-32x, and as9716-32d. Also correct typo of naming on as7816-64x and as7716-32x. Signed-off-by: roy_lee roy_lee@accton.com What I did Disabling i2c function of ir3570a which may failed i2c tranfer to others. Close channel of mux after data transfered. How I did it Identify version of ir3570, if it's ir3570a, disable its alias i2c address. Enable parameter of driver i2c_mux_pca954x to close channel on after every access. How to verify it Write 08 to offset 0xcf of systom eeprom and execute i2c block read. It will return error. plug-in several transceivers and run "show interfaces transceiver presence" and "sfputil show presence". You may see the different result. (But doing this requires updated xcvrd). Signed-off-by: roy_lee --- .../as7326-56x/utils/accton_as7326_util.py | 27 +++++++++++++++++++ .../as7716-32x/utils/accton_as7716_util.py | 12 ++++----- .../utils/accton_as7726_32x_util.py | 27 +++++++++++++++++++ .../as7816-64x/utils/accton_as7816_util.py | 12 ++++----- .../utils/accton_as9716_32d_util.py | 27 +++++++++++++++++++ 5 files changed, 93 insertions(+), 12 deletions(-) diff --git a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/accton_as7326_util.py b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/accton_as7326_util.py index 02f98a4667..0e08f0b62a 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/accton_as7326_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7326-56x/utils/accton_as7326_util.py @@ -133,6 +133,30 @@ def show_set_help(): print " use \""+ cmd + " sfp 1-56 {0|1}\" to set sfp# tx_disable" sys.exit(0) +def dis_i2c_ir3570a(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 ir3570_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 ir3570a + ret = dis_i2c_ir3570a(4) + else: + ret = 0 + except Exception as e: + print "Error on ir3570_check() e:" + str(e) + return -1 + return ret + + def show_eeprom_help(): cmd = sys.argv[0].split("/")[-1]+ " " + args[0] print " use \""+ cmd + " 1-56 \" to dump sfp# eeprom" @@ -359,6 +383,9 @@ def do_install(): return status else: print PROJECT_NAME.upper()+" drivers detected...." + + ir3570_check() + if not device_exist(): print "No device, installing...." status = device_install() diff --git a/platform/broadcom/sonic-platform-modules-accton/as7716-32x/utils/accton_as7716_util.py b/platform/broadcom/sonic-platform-modules-accton/as7716-32x/utils/accton_as7716_util.py index faf0dfc308..b195165337 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7716-32x/utils/accton_as7716_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7716-32x/utils/accton_as7716_util.py @@ -221,26 +221,26 @@ 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): +def dis_i2c_ir3570a(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(): +def ir3570_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) + if version == 0x24: #only for ir3570a + ret = dis_i2c_ir3570a(4) else: ret = 0 except Exception as e: - print "Error on ir3507_check() e:" + str(e) + print "Error on ir3570_check() e:" + str(e) return -1 return ret @@ -410,7 +410,7 @@ def do_install(): else: print PROJECT_NAME.upper()+" drivers detected...." - ir3507_check() + ir3570_check() if not device_exist(): status = device_install() diff --git a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/utils/accton_as7726_32x_util.py b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/utils/accton_as7726_32x_util.py index 89643edd62..acb0319f5f 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7726-32x/utils/accton_as7726_32x_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7726-32x/utils/accton_as7726_32x_util.py @@ -206,6 +206,30 @@ def show_eeprom_help(): print " use \""+ cmd + " 1-32 \" to dump sfp# eeprom" sys.exit(0) +def dis_i2c_ir3570a(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 ir3570_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 ir3570a + ret = dis_i2c_ir3570a(4) + else: + ret = 0 + except Exception as e: + print "Error on ir3570_check() e:" + str(e) + return -1 + return ret + + def my_log(txt): if DEBUG == True: print "[ACCTON DBG]: "+txt @@ -355,6 +379,9 @@ def do_install(): return status else: print PROJECT_NAME.upper()+" drivers detected...." + + ir3570_check() + if not device_exist(): status = device_install() if status: diff --git a/platform/broadcom/sonic-platform-modules-accton/as7816-64x/utils/accton_as7816_util.py b/platform/broadcom/sonic-platform-modules-accton/as7816-64x/utils/accton_as7816_util.py index 8db2ecc485..ab5e52cb85 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as7816-64x/utils/accton_as7816_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as7816-64x/utils/accton_as7816_util.py @@ -124,26 +124,26 @@ def show_set_help(): print " use \""+ cmd + " sfp 1-64 {0|1}\" to set sfp# tx_disable" sys.exit(0) -def diss_i2c_ir3507a(addr): +def dis_i2c_ir3570a(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(): +def ir3570_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) + if version == 0x24: #only for ir3570a + ret = dis_i2c_ir3570a(4) else: ret = 0 except Exception as e: - print "Error on ir3507_check() e:" + str(e) + print "Error on ir3570_check() e:" + str(e) return -1 return ret @@ -338,7 +338,7 @@ def do_install(): else: print PROJECT_NAME.upper()+" drivers detected...." - ir3507_check() + ir3570_check() if not device_exist(): print "No device, installing...." diff --git a/platform/broadcom/sonic-platform-modules-accton/as9716-32d/utils/accton_as9716_32d_util.py b/platform/broadcom/sonic-platform-modules-accton/as9716-32d/utils/accton_as9716_32d_util.py index e9779db01d..7ccf05a798 100755 --- a/platform/broadcom/sonic-platform-modules-accton/as9716-32d/utils/accton_as9716_32d_util.py +++ b/platform/broadcom/sonic-platform-modules-accton/as9716-32d/utils/accton_as9716_32d_util.py @@ -206,6 +206,30 @@ def show_set_help(): print " use \""+ cmd + " sfp 1-32 {0|1}\" to set sfp# tx_disable" sys.exit(0) +def dis_i2c_ir3570a(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 ir3570_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 ir3570a + ret = dis_i2c_ir3570a(4) + else: + ret = 0 + except Exception as e: + print "Error on ir3570_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" @@ -352,6 +376,9 @@ def do_install(): return status else: print PROJECT_NAME.upper()+" drivers detected...." + + ir3570_check() + if not device_exist(): status = device_install() if status: