sonic-buildimage/device/dell/x86_64-dell_s6100_c2538-r0/platform_reboot
Santhosh Kumar T a2cb92056a
Dell S6100 Port I2C changes to 201811 branch (#5150)
* Dell S6100 Port I2C changes to 201811 branch

* Update s6100_i2c_enumeration.sh
2020-08-18 14:38:28 -07:00

35 lines
995 B
Python
Executable File

#!/usr/bin/python
import sys
import os
import subprocess
import struct
PORT_RES = '/dev/port'
POWER_CYCLE = '/tmp/powercycle'
def portio_reg_write(resource, offset, val):
fd = os.open(resource, os.O_RDWR)
if(fd < 0):
print 'file open failed %s" % resource'
return
if(os.lseek(fd, offset, os.SEEK_SET) != offset):
print 'lseek failed on %s' % resource
return
ret = os.write(fd, struct.pack('B', val))
if(ret != 1):
print 'write failed %d' % ret
return
os.close(fd)
if __name__ == "__main__":
# power-cycle the switch
if os.path.exists(POWER_CYCLE):
print "CPLD upgrade detected. Power-cycling the unit.."
os.system('io_rd_wr.py --set --val 05 --offset 210; io_rd_wr.py --set --val 00 --offset 211; io_rd_wr.py --set --val 03 --offset 213')
subprocess.check_output(['/usr/share/sonic/device/x86_64-dell_s6100_c2538-r0/fast-reboot_plugin'])
portio_reg_write(PORT_RES, 0xcf9, 0xe)