-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dell S6100 Port I2C changes to 201811 branch (#5150)
* Dell S6100 Port I2C changes to 201811 branch * Update s6100_i2c_enumeration.sh
- Loading branch information
1 parent
e1e9719
commit a2cb920
Showing
9 changed files
with
424 additions
and
234 deletions.
There are no files selected for viewing
This file contains 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
6 changes: 6 additions & 0 deletions
6
platform/broadcom/sonic-platform-modules-dell/debian/platform-modules-s6100.install
This file contains 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 |
---|---|---|
@@ -1,15 +1,21 @@ | ||
s6100/scripts/iom_power_*.sh usr/local/bin | ||
s6100/scripts/s6100_platform.sh usr/local/bin | ||
s6100/scripts/s6100_i2c_enumeration.sh usr/local/bin | ||
s6100/scripts/s6100_bitbang_reset.sh usr/local/bin | ||
s6100/scripts/pcisysfs.py usr/bin | ||
common/dell_i2c_utils.sh usr/local/bin | ||
common/io_rd_wr.py usr/local/bin | ||
common/fstrim.timer etc/systemd/system | ||
common/fstrim.service etc/systemd/system | ||
s6100/scripts/fast-reboot_plugin usr/share/sonic/device/x86_64-dell_s6100_c2538-r0 | ||
s6100/scripts/warm-reboot_plugin usr/share/sonic/device/x86_64-dell_s6100_c2538-r0 | ||
common/dell_lpc_mon.sh usr/local/bin | ||
s6100/scripts/platform_sensors.py usr/local/bin | ||
s6100/scripts/platform_watchdog_enable.sh usr/local/bin | ||
s6100/scripts/platform_watchdog_disable.sh usr/local/bin | ||
s6100/scripts/sensors usr/bin | ||
s6100/systemd/platform-modules-s6100.service etc/systemd/system | ||
s6100/systemd/s6100-i2c-enumerate.service etc/systemd/system | ||
s6100/modules/sonic_platform-1.0-py2-none-any.whl usr/share/sonic/device/x86_64-dell_s6100_c2538-r0 | ||
s6100/systemd/s6100-lpc-monitor.service etc/systemd/system | ||
tools/flashrom/flashrom usr/local/bin/ |
3 changes: 3 additions & 0 deletions
3
platform/broadcom/sonic-platform-modules-dell/s6100/scripts/fast-reboot_plugin
This file contains 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,3 @@ | ||
#!/bin/bash | ||
|
||
/usr/local/bin/s6100_i2c_enumeration.sh deinit & > /dev/null |
91 changes: 91 additions & 0 deletions
91
platform/broadcom/sonic-platform-modules-dell/s6100/scripts/pcisysfs.py
This file contains 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:]) | ||
|
59 changes: 59 additions & 0 deletions
59
platform/broadcom/sonic-platform-modules-dell/s6100/scripts/s6100_bitbang_reset.sh
This file contains 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,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 |
Oops, something went wrong.