Skip to content
Snippets Groups Projects

Modified the scripts to run on Raspberry Pi.

1 file
+ 33
25
Compare changes
  • Side-by-side
  • Inline
+ 33
25
@@ -95,7 +95,7 @@ def write_switch_bytes(page, addr, data):
@@ -95,7 +95,7 @@ def write_switch_bytes(page, addr, data):
read_register(0xfe)
read_register(0xfe)
read_register(addr)
read_register(addr)
def read_link_status(ports=4):
def read_link_status(ports=16):
print("links status register")
print("links status register")
ret = read_switch(0x01,0x00, pr_stri=False)
ret = read_switch(0x01,0x00, pr_stri=False)
stri = "|15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |"
stri = "|15 |14 |13 |12 |11 |10 | 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |"
@@ -206,32 +206,40 @@ if len(sys.argv) < 2:
@@ -206,32 +206,40 @@ if len(sys.argv) < 2:
read_switch(0x01,0x70)
read_switch(0x01,0x70)
read_link_status(4)
read_link_status(4)
elif sys.argv[1] == "stat":
elif sys.argv[1] == "stat":
read_link_status(4)
read_link_status(16)
elif sys.argv[1] == "set":
elif sys.argv[1] == "set":
print("write and read led register")
#b print("write and read led register")
write_switch_bytes(0x00, 0x24, [0x20, 0x02]) #LSB first
#b write_switch_bytes(0x00, 0x24, [0x20, 0x02]) #LSB first
read_switch(0x00,0x24)
#b read_switch(0x00,0x24)
print("write and read jumbo register")
#nth print("write and read jumbo register")
write_switch_bytes(0x40, 0x01, [0xff, 0xff, 0x00, 0x00])
#nth write_switch_bytes(0x40, 0x01, [0xff, 0xff, 0x00, 0x00])
read_switch(0x40,0x01)
#nth read_switch(0x40,0x01)
print("strap resistors")
#b print("strap resistors")
read_switch(0x01,0x70)
#b read_switch(0x01,0x70)
if 1:
if 1:
print("write and read SGMII register CH0")
# print("write and read SGMII register CH0, fifo size max")
write_switch_bytes(0x10, 0x24, [0x44, 0x00])
# write_switch_bytes(0x10, 0x24, [0x44, 0x00])
read_switch(0x10,0x24)
# read_switch(0x10,0x24)
print("write and read SGMII register CH3")
# print("write and read SGMII register CH3, fifo size max")
write_switch_bytes(0x13, 0x24, [0x44, 0x00])
# write_switch_bytes(0x13, 0x24, [0x44, 0x00])
read_switch(0x13,0x24)
# read_switch(0x13,0x24)
write_switch_bytes(0x0, 0x20, [0x06])
# write_switch_bytes(0x0, 0x20, [0x06]) #Switch mode)
for cnt in range(16):
# for cnt in range(16):
write_switch_bytes(0x0, 0x0+cnt, [0x00])
# write_switch_bytes(0x0, 0x0+cnt, [0x00]) #Overwrite strapping resistor unmanaged mode
for cnt in range(4):
print("Set PHY ch 0 and read back to 10 Mbit 0x01 100Mbit 0x21")
write_switch_bytes(0x80+cnt, 0x00, [0x00, 0x01])
write_switch_bytes(0x80+0, 0x00, [0x00, 0x01])
ret = read_switch(0x80+cnt,0x00)
#b ret = read_switch(0x80,0x00)
for cnt in range(16):
print("Set PHY ch 1 and read back to 10 Mbit 0x01 100Mbit 0x21")
write_switch_bytes(0x10+cnt, 0x00, [0x40, 0x11])
write_switch_bytes(0x00, 0x60+1, [0x8B])
write_switch_bytes(0x10+cnt, 0x20, [0xD0, 0x09])
write_switch_bytes(0x10+1, 0x00, [0x40, 0x11])
 
write_switch_bytes(0x80+1, 0x00, [0x40, 0x01])
 
#1 write_switch_bytes(0x10+1, 0x00, [0x00, 0x01])
 
#1 print("Set PHY ch 3 and read back to 10 Mbit 0x01 100Mbit 0x21")
 
#1 write_switch_bytes(0x80+3, 0x00, [0x00, 0x01])
 
#b ret = read_switch(0x80+3,0x00)
 
#1 write_switch_bytes(0x00, 0x86, [0xa0]) # no polling (make no difference)
 
for cnt in [15, 14, 13, 12, 11, 10, 9, 8]: #, 7, 6, 5, 4]:
 
write_switch_bytes(0x00, 0x60+cnt, [0x8B])
else:
else:
print("spi_switch_Unb2c stat for status")
print("spi_switch_Unb2c stat for status")
Loading