[DellEMC] S6100-Fix i2C ISMT issue (#4330)
* [DellEMC] S6100-Fix i2C ISMT issue * Modified the retry condition for bit bang
This commit is contained in:
parent
0409a32abe
commit
a40fe3ba15
@ -4,3 +4,4 @@ if [[ -d /sys/devices/platform/SMF.512/hwmon/ ]]; then
|
|||||||
cd /sys/devices/platform/SMF.512/hwmon/*
|
cd /sys/devices/platform/SMF.512/hwmon/*
|
||||||
echo 0xcc > mb_poweron_reason
|
echo 0xcc > mb_poweron_reason
|
||||||
fi
|
fi
|
||||||
|
/usr/local/bin/s6100_i2c_enumeration.sh deinit & > /dev/null
|
||||||
|
91
platform/broadcom/sonic-platform-modules-dell/s6100/scripts/pcisysfs.py
Executable file
91
platform/broadcom/sonic-platform-modules-dell/s6100/scripts/pcisysfs.py
Executable file
@ -0,0 +1,91 @@
|
|||||||
|
#! /usr/bin/python
|
||||||
|
|
||||||
|
import struct
|
||||||
|
import sys
|
||||||
|
import getopt
|
||||||
|
from os import *
|
||||||
|
from mmap import *
|
||||||
|
|
||||||
|
def usage():
|
||||||
|
''' This is the Usage Method '''
|
||||||
|
|
||||||
|
print '\t\t pcisysfs.py --get --offset <offset> --res <resource>'
|
||||||
|
print '\t\t pcisysfs.py --set --val <val> --offset <offset> --res <resource>'
|
||||||
|
sys.exit(1)
|
||||||
|
|
||||||
|
def pci_mem_read(mm,offset):
|
||||||
|
mm.seek(offset)
|
||||||
|
read_data_stream=mm.read(4)
|
||||||
|
print ""
|
||||||
|
reg_val=struct.unpack('I',read_data_stream)
|
||||||
|
print "reg_val read:%x"%reg_val
|
||||||
|
return reg_val
|
||||||
|
|
||||||
|
def pci_mem_write(mm,offset,data):
|
||||||
|
mm.seek(offset)
|
||||||
|
#print "data to write:%x"%data
|
||||||
|
mm.write(struct.pack('I',data))
|
||||||
|
|
||||||
|
def pci_set_value(resource,val,offset):
|
||||||
|
fd=open(resource,O_RDWR)
|
||||||
|
mm=mmap(fd,0)
|
||||||
|
pci_mem_write(mm,offset,val)
|
||||||
|
close(fd)
|
||||||
|
|
||||||
|
def pci_get_value(resource,offset):
|
||||||
|
fd=open(resource,O_RDWR)
|
||||||
|
mm=mmap(fd,0)
|
||||||
|
pci_mem_read(mm,offset)
|
||||||
|
close(fd)
|
||||||
|
|
||||||
|
def main(argv):
|
||||||
|
|
||||||
|
''' The main function will read the user input from the
|
||||||
|
command line argument and process the request '''
|
||||||
|
|
||||||
|
opts = ''
|
||||||
|
val = ''
|
||||||
|
choice = ''
|
||||||
|
resource = ''
|
||||||
|
offset = ''
|
||||||
|
|
||||||
|
try:
|
||||||
|
opts, args = getopt.getopt(argv, "hgsv:" , \
|
||||||
|
["val=","res=","offset=","help", "get", "set"])
|
||||||
|
|
||||||
|
except getopt.GetoptError:
|
||||||
|
usage()
|
||||||
|
|
||||||
|
for opt,arg in opts:
|
||||||
|
|
||||||
|
if opt in ('-h','--help'):
|
||||||
|
choice = 'help'
|
||||||
|
|
||||||
|
elif opt in ('-g', '--get'):
|
||||||
|
choice = 'get'
|
||||||
|
|
||||||
|
elif opt in ('-s', '--set'):
|
||||||
|
choice = 'set'
|
||||||
|
|
||||||
|
elif opt == '--res':
|
||||||
|
resource = arg
|
||||||
|
|
||||||
|
elif opt == '--val':
|
||||||
|
val = int(arg,16)
|
||||||
|
|
||||||
|
elif opt == '--offset':
|
||||||
|
offset = int(arg,16)
|
||||||
|
|
||||||
|
if choice == 'set' and val != '' and offset !='' and resource !='':
|
||||||
|
pci_set_value(resource,val,offset)
|
||||||
|
|
||||||
|
elif choice == 'get' and offset != '' and resource !='':
|
||||||
|
pci_get_value(resource,offset)
|
||||||
|
|
||||||
|
else:
|
||||||
|
usage()
|
||||||
|
|
||||||
|
#Calling the main method
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main(sys.argv[1:])
|
||||||
|
|
@ -0,0 +1,59 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Script to unfreeze a stuck I2C controller, by bit-banging a STOP cycle on the bus
|
||||||
|
|
||||||
|
bit_bang_recovery()
|
||||||
|
{
|
||||||
|
|
||||||
|
# Clear the ERRSTS
|
||||||
|
pcisysfs.py --set --val 0xffffffff --offset 0x018 --res /sys/devices/pci0000\:00/0000\:00\:13.0/resource0
|
||||||
|
|
||||||
|
#Enable I2C bit-banging
|
||||||
|
pcisysfs.py --set --val 0x80000000 --offset 0x388 --res /sys/devices/pci0000\:00/0000\:00\:13.0/resource0
|
||||||
|
|
||||||
|
count=1
|
||||||
|
while [ $count -le 9 ];
|
||||||
|
do
|
||||||
|
# Bit-bang an I2C STOP cycle
|
||||||
|
|
||||||
|
# SCL=0, SDA=0
|
||||||
|
pcisysfs.py --set --val 0x80000000 --offset 0x388 --res /sys/devices/pci0000\:00/0000\:00\:13.0/resource0
|
||||||
|
|
||||||
|
sleep 0.01
|
||||||
|
|
||||||
|
# SCL=1, SDA=0
|
||||||
|
pcisysfs.py --set --val 0x80000002 --offset 0x388 --res /sys/devices/pci0000\:00/0000\:00\:13.0/resource0
|
||||||
|
|
||||||
|
sleep 0.01
|
||||||
|
|
||||||
|
# SCL=1, SDA=1
|
||||||
|
pcisysfs.py --set --val 0x80000003 --offset 0x388 --res /sys/devices/pci0000\:00/0000\:00\:13.0/resource0
|
||||||
|
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
# Check I2C DBSTS register
|
||||||
|
mctrl=$((`pcisysfs.py --get --offset 0x108 --res /sys/devices/pci0000\:00/0000\:00\:13.0/resource0 | sed 's/^.*:/0x/'`))
|
||||||
|
msts=$((`pcisysfs.py --get --offset 0x10c --res /sys/devices/pci0000\:00/0000\:00\:13.0/resource0 | sed 's/^.*:/0x/'`))
|
||||||
|
dbsts=$((`pcisysfs.py --get --offset 0x38c --res /sys/devices/pci0000\:00/0000\:00\:13.0/resource0 | sed 's/^.*:/0x/'`))
|
||||||
|
msts_ip=$((msts&0x1))
|
||||||
|
|
||||||
|
mctrl=$((10#$mctrl))
|
||||||
|
if [ $msts_ip = 0 ]; then
|
||||||
|
logger -p NOTICE "I2C_bitbang-Bit banging done on I2C bus"
|
||||||
|
logger -p NOTICE "After I2C_bitbang- MCTRL:$(printf "0x%x" $mctrl)","MSTS:$(printf "0x%x" $msts)","DBSTS:$(printf "0x%x" $dbsts)"
|
||||||
|
break
|
||||||
|
fi
|
||||||
|
count=$(( $count + 1 ))
|
||||||
|
done
|
||||||
|
|
||||||
|
#Disable I2C bit-banging
|
||||||
|
pcisysfs.py --set --val 0x00000003 --offset 0x388 --res /sys/devices/pci0000\:00/0000\:00\:13.0/resource0
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
mctrl=$((`pcisysfs.py --get --offset 0x108 --res /sys/devices/pci0000\:00/0000\:00\:13.0/resource0 | sed 's/^.*:/0x/'`))
|
||||||
|
msts=$((`pcisysfs.py --get --offset 0x10c --res /sys/devices/pci0000\:00/0000\:00\:13.0/resource0 | sed 's/^.*:/0x/'`))
|
||||||
|
dbsts=$((`pcisysfs.py --get --offset 0x38c --res /sys/devices/pci0000\:00/0000\:00\:13.0/resource0 | sed 's/^.*:/0x/'`))
|
||||||
|
logger -p NOTICE "Before I2C_bitbang- MCTRL:$(printf "0x%x" $mctrl)","MSTS:$(printf "0x%x" $msts)","DBSTS:$(printf "0x%x" $dbsts)"
|
||||||
|
sleep 2
|
||||||
|
bit_bang_recovery
|
@ -245,6 +245,7 @@ if [[ "$1" == "init" ]]; then
|
|||||||
sys_eeprom "new_device"
|
sys_eeprom "new_device"
|
||||||
switch_board_eeprom "new_device"
|
switch_board_eeprom "new_device"
|
||||||
switch_board_cpld "new_device"
|
switch_board_cpld "new_device"
|
||||||
|
/usr/local/bin/s6100_bitbang_reset.sh
|
||||||
switch_board_qsfp_mux "new_device"
|
switch_board_qsfp_mux "new_device"
|
||||||
switch_board_sfp "new_device"
|
switch_board_sfp "new_device"
|
||||||
switch_board_qsfp "new_device"
|
switch_board_qsfp "new_device"
|
||||||
|
Reference in New Issue
Block a user