-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[DellEMC] S6100-Fix i2C ISMT issue #4330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
91 changes: 91 additions & 0 deletions
91
platform/broadcom/sonic-platform-modules-dell/s6100/scripts/pcisysfs.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -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:]) | ||
|
|
56 changes: 56 additions & 0 deletions
56
platform/broadcom/sonic-platform-modules-dell/s6100/scripts/s6100_bitbang_reset.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,56 @@ | ||
| #!/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 | ||
|
|
||
| while true;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 | ||
| 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.