[Quanta] Add a new supported device and platform, IX8C-56X (#3182)
* [Quanta] Add a new supported device and platform, IX8C-56X Switch Vendor: Quanta Switch SKU: IX8C-56X ASIC Vendor: Broadcom Switch ASIC: Trident3 Port Configuration: 48x25G + 8x100G Signed-off-by: Jonathan Tsai <jonathan.tsai@quantatw.com>
This commit is contained in:
parent
ca1534aadb
commit
2bb58044c0
@ -0,0 +1,57 @@
|
||||
# name lanes alias index speed
|
||||
Ethernet0 60 twentyfiveGigE1 0 25000
|
||||
Ethernet1 59 twentyfiveGigE2 1 25000
|
||||
Ethernet2 58 twentyfiveGigE3 2 25000
|
||||
Ethernet3 57 twentyfiveGigE4 3 25000
|
||||
Ethernet4 64 twentyfiveGigE5 4 25000
|
||||
Ethernet5 63 twentyfiveGigE6 5 25000
|
||||
Ethernet6 62 twentyfiveGigE7 6 25000
|
||||
Ethernet7 61 twentyfiveGigE8 7 25000
|
||||
Ethernet8 49 twentyfiveGigE9 8 25000
|
||||
Ethernet9 50 twentyfiveGigE10 9 25000
|
||||
Ethernet10 51 twentyfiveGigE11 10 25000
|
||||
Ethernet11 52 twentyfiveGigE12 11 25000
|
||||
Ethernet12 4 twentyfiveGigE13 12 25000
|
||||
Ethernet13 3 twentyfiveGigE14 13 25000
|
||||
Ethernet14 2 twentyfiveGigE15 14 25000
|
||||
Ethernet15 1 twentyfiveGigE16 15 25000
|
||||
Ethernet16 8 twentyfiveGigE17 16 25000
|
||||
Ethernet17 7 twentyfiveGigE18 17 25000
|
||||
Ethernet18 6 twentyfiveGigE19 18 25000
|
||||
Ethernet19 5 twentyfiveGigE20 19 25000
|
||||
Ethernet20 16 twentyfiveGigE21 20 25000
|
||||
Ethernet21 15 twentyfiveGigE22 21 25000
|
||||
Ethernet22 14 twentyfiveGigE23 22 25000
|
||||
Ethernet23 13 twentyfiveGigE24 23 25000
|
||||
Ethernet24 24 twentyfiveGigE25 24 25000
|
||||
Ethernet25 23 twentyfiveGigE26 25 25000
|
||||
Ethernet26 22 twentyfiveGigE27 26 25000
|
||||
Ethernet27 21 twentyfiveGigE28 27 25000
|
||||
Ethernet28 32 twentyfiveGigE29 28 25000
|
||||
Ethernet29 31 twentyfiveGigE30 29 25000
|
||||
Ethernet30 30 twentyfiveGigE31 30 25000
|
||||
Ethernet31 29 twentyfiveGigE32 31 25000
|
||||
Ethernet32 36 twentyfiveGigE33 32 25000
|
||||
Ethernet33 35 twentyfiveGigE34 33 25000
|
||||
Ethernet34 34 twentyfiveGigE35 34 25000
|
||||
Ethernet35 33 twentyfiveGigE36 35 25000
|
||||
Ethernet36 44 twentyfiveGigE37 36 25000
|
||||
Ethernet37 43 twentyfiveGigE38 37 25000
|
||||
Ethernet38 42 twentyfiveGigE39 38 25000
|
||||
Ethernet39 41 twentyfiveGigE40 39 25000
|
||||
Ethernet40 86 twentyfiveGigE41 40 25000
|
||||
Ethernet41 85 twentyfiveGigE42 41 25000
|
||||
Ethernet42 88 twentyfiveGigE43 42 25000
|
||||
Ethernet43 87 twentyfiveGigE44 43 25000
|
||||
Ethernet44 94 twentyfiveGigE45 44 25000
|
||||
Ethernet45 93 twentyfiveGigE46 45 25000
|
||||
Ethernet46 96 twentyfiveGigE47 46 25000
|
||||
Ethernet47 95 twentyfiveGigE48 47 25000
|
||||
Ethernet48 97,98,99,100 hundredGigE49 48 100000
|
||||
Ethernet52 105,106,107,108 hundredGigE50 49 100000
|
||||
Ethernet56 113,114,115,116 hundredGigE51 50 100000
|
||||
Ethernet60 121,122,123,124 hundredGigE52 51 100000
|
||||
Ethernet64 77,78,79,80 hundredGigE53 52 100000
|
||||
Ethernet68 65,66,67,68 hundredGigE54 53 100000
|
||||
Ethernet72 69,70,71,72 hundredGigE55 54 100000
|
||||
Ethernet76 125,126,127,128 hundredGigE56 55 100000
|
@ -0,0 +1 @@
|
||||
SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/td3-ix8c-48x25G+8x100G.config.bcm
|
@ -0,0 +1,480 @@
|
||||
bcm_tunnel_term_compatible_mode=1
|
||||
core_clock_frequency=1525
|
||||
dpp_clock_ratio=2:3
|
||||
parity_enable=0
|
||||
mem_cache_enable=0
|
||||
l2_mem_entries=40960
|
||||
l3_mem_entries=40960
|
||||
fpem_mem_entries=16384
|
||||
l2xmsg_mode=1
|
||||
|
||||
bcm_num_cos=8
|
||||
bcm_stat_interval=2000000
|
||||
cdma_timeout_usec=3000000
|
||||
|
||||
ifp_inports_support_enable=1
|
||||
ipv6_lpm_128b_enable=0x1
|
||||
l3_max_ecmp_mode=1
|
||||
l3_alpm_enable=2
|
||||
lpm_scaling_enable=0
|
||||
|
||||
miim_intr_enable=0
|
||||
module_64ports=1
|
||||
|
||||
schan_intr_enable=0
|
||||
skip_L2_USER_ENTRY=0
|
||||
stable_size=0x5500000
|
||||
tdma_timeout_usec=3000000
|
||||
|
||||
# portmap settings
|
||||
oversubscribe_mode=1
|
||||
pbmp_xport_xe=0x48808080f8780808dfe1e1e1fe1e1e1fe
|
||||
|
||||
port_flex_enable=1
|
||||
|
||||
portmap_1=1:25
|
||||
portmap_2=2:25
|
||||
portmap_3=3:25
|
||||
portmap_4=4:25
|
||||
portmap_5=5:25
|
||||
portmap_6=6:25
|
||||
portmap_7=7:25
|
||||
portmap_8=8:25
|
||||
portmap_13=13:25
|
||||
portmap_14=14:25
|
||||
portmap_15=15:25
|
||||
portmap_16=16:25
|
||||
portmap_21=21:25
|
||||
portmap_22=22:25
|
||||
portmap_23=23:25
|
||||
portmap_24=24:25
|
||||
portmap_29=29:25
|
||||
portmap_30=30:25
|
||||
portmap_31=31:25
|
||||
portmap_32=32:25
|
||||
portmap_33=33:25
|
||||
portmap_34=34:25
|
||||
portmap_35=35:25
|
||||
portmap_36=36:25
|
||||
portmap_41=41:25
|
||||
portmap_42=42:25
|
||||
portmap_43=43:25
|
||||
portmap_44=44:25
|
||||
portmap_49=49:25
|
||||
portmap_50=50:25
|
||||
portmap_51=51:25
|
||||
portmap_52=52:25
|
||||
portmap_57=57:25
|
||||
portmap_58=58:25
|
||||
portmap_59=59:25
|
||||
portmap_60=60:25
|
||||
portmap_61=61:25
|
||||
portmap_62=62:25
|
||||
portmap_63=63:25
|
||||
portmap_64=64:25
|
||||
portmap_67=65:100
|
||||
portmap_71=69:100
|
||||
portmap_79=77:100
|
||||
portmap_87=85:25
|
||||
portmap_88=86:25
|
||||
portmap_89=87:25
|
||||
portmap_90=88:25
|
||||
portmap_95=93:25
|
||||
portmap_96=94:25
|
||||
portmap_97=95:25
|
||||
portmap_98=96:25
|
||||
portmap_99=97:100
|
||||
portmap_107=105:100
|
||||
portmap_115=113:100
|
||||
portmap_123=121:100
|
||||
portmap_127=125:100
|
||||
|
||||
# datapath port -- MerlinCore
|
||||
portmap_66=129:10:m
|
||||
portmap_130=128:10:m
|
||||
|
||||
# loopback port
|
||||
portmap_65=130:10
|
||||
portmap_131=131:10
|
||||
|
||||
|
||||
### interface setting
|
||||
# TSCF / TSCE interface definition
|
||||
# NULL 1
|
||||
# GMII 3
|
||||
# SGMII 4
|
||||
# XGMII 6
|
||||
# SFI 9
|
||||
# XFI 10
|
||||
# KR 11
|
||||
# KR4 12
|
||||
# CR 13
|
||||
# CR4 14
|
||||
# XLAUI 15
|
||||
# SR 16
|
||||
# ILKN 21
|
||||
# CAUI 25
|
||||
# LR 26
|
||||
# LR4 27
|
||||
# SR4 28
|
||||
# SR2 38
|
||||
# KR2 39
|
||||
# CR2 40
|
||||
# XLAUI2 42
|
||||
# LR2 55
|
||||
# CAUI4 62
|
||||
###
|
||||
|
||||
serdes_if_type_1=13
|
||||
serdes_if_type_2=13
|
||||
serdes_if_type_3=13
|
||||
serdes_if_type_4=13
|
||||
serdes_if_type_5=13
|
||||
serdes_if_type_6=13
|
||||
serdes_if_type_7=13
|
||||
serdes_if_type_8=13
|
||||
serdes_if_type_13=13
|
||||
serdes_if_type_14=13
|
||||
serdes_if_type_15=13
|
||||
serdes_if_type_16=13
|
||||
serdes_if_type_21=13
|
||||
serdes_if_type_22=13
|
||||
serdes_if_type_23=13
|
||||
serdes_if_type_24=13
|
||||
serdes_if_type_29=13
|
||||
serdes_if_type_30=13
|
||||
serdes_if_type_31=13
|
||||
serdes_if_type_32=13
|
||||
serdes_if_type_33=13
|
||||
serdes_if_type_34=13
|
||||
serdes_if_type_35=13
|
||||
serdes_if_type_36=13
|
||||
serdes_if_type_41=13
|
||||
serdes_if_type_42=13
|
||||
serdes_if_type_43=13
|
||||
serdes_if_type_44=13
|
||||
serdes_if_type_49=13
|
||||
serdes_if_type_50=13
|
||||
serdes_if_type_51=13
|
||||
serdes_if_type_52=13
|
||||
serdes_if_type_57=13
|
||||
serdes_if_type_58=13
|
||||
serdes_if_type_59=13
|
||||
serdes_if_type_60=13
|
||||
serdes_if_type_61=13
|
||||
serdes_if_type_62=13
|
||||
serdes_if_type_63=13
|
||||
serdes_if_type_64=13
|
||||
serdes_if_type_67=14
|
||||
serdes_if_type_71=14
|
||||
serdes_if_type_79=14
|
||||
serdes_if_type_87=13
|
||||
serdes_if_type_88=13
|
||||
serdes_if_type_89=13
|
||||
serdes_if_type_90=13
|
||||
serdes_if_type_95=13
|
||||
serdes_if_type_96=13
|
||||
serdes_if_type_97=13
|
||||
serdes_if_type_98=13
|
||||
serdes_if_type_99=14
|
||||
serdes_if_type_107=14
|
||||
serdes_if_type_115=14
|
||||
serdes_if_type_123=14
|
||||
serdes_if_type_127=14
|
||||
serdes_if_type_66=11
|
||||
serdes_if_type_130=11
|
||||
|
||||
|
||||
dport_map_port_60=1
|
||||
dport_map_port_59=2
|
||||
dport_map_port_58=3
|
||||
dport_map_port_57=4
|
||||
dport_map_port_64=5
|
||||
dport_map_port_63=6
|
||||
dport_map_port_62=7
|
||||
dport_map_port_61=8
|
||||
dport_map_port_49=9
|
||||
dport_map_port_50=10
|
||||
dport_map_port_51=11
|
||||
dport_map_port_52=12
|
||||
dport_map_port_4=13
|
||||
dport_map_port_3=14
|
||||
dport_map_port_2=15
|
||||
dport_map_port_1=16
|
||||
dport_map_port_8=17
|
||||
dport_map_port_7=18
|
||||
dport_map_port_6=19
|
||||
dport_map_port_5=20
|
||||
dport_map_port_16=21
|
||||
dport_map_port_15=22
|
||||
dport_map_port_14=23
|
||||
dport_map_port_13=24
|
||||
dport_map_port_24=25
|
||||
dport_map_port_23=26
|
||||
dport_map_port_22=27
|
||||
dport_map_port_21=28
|
||||
dport_map_port_32=29
|
||||
dport_map_port_31=30
|
||||
dport_map_port_30=31
|
||||
dport_map_port_29=32
|
||||
dport_map_port_36=33
|
||||
dport_map_port_35=34
|
||||
dport_map_port_34=35
|
||||
dport_map_port_33=36
|
||||
dport_map_port_44=37
|
||||
dport_map_port_43=38
|
||||
dport_map_port_42=39
|
||||
dport_map_port_41=40
|
||||
dport_map_port_88=41
|
||||
dport_map_port_87=42
|
||||
dport_map_port_90=43
|
||||
dport_map_port_89=44
|
||||
dport_map_port_96=45
|
||||
dport_map_port_95=46
|
||||
dport_map_port_98=47
|
||||
dport_map_port_97=48
|
||||
dport_map_port_99=49
|
||||
dport_map_port_107=50
|
||||
dport_map_port_115=51
|
||||
dport_map_port_123=52
|
||||
dport_map_port_79=53
|
||||
dport_map_port_67=54
|
||||
dport_map_port_71=55
|
||||
dport_map_port_127=56
|
||||
|
||||
dport_map_port_66=57
|
||||
dport_map_port_130=58
|
||||
|
||||
|
||||
phy_chain_tx_lane_map_physical{1.0}=0x3210
|
||||
phy_chain_tx_polarity_flip_physical{1.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{2.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{3.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{4.0}=0x1
|
||||
phy_chain_rx_lane_map_physical{1.0}=0x3210
|
||||
phy_chain_rx_polarity_flip_physical{1.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{2.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{3.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{4.0}=0x0
|
||||
|
||||
phy_chain_tx_lane_map_physical{5.0}=0x3210
|
||||
phy_chain_tx_polarity_flip_physical{5.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{6.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{7.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{8.0}=0x1
|
||||
phy_chain_rx_lane_map_physical{5.0}=0x3210
|
||||
phy_chain_rx_polarity_flip_physical{5.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{6.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{7.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{8.0}=0x1
|
||||
|
||||
phy_chain_tx_lane_map_physical{13.0}=0x3210
|
||||
phy_chain_tx_polarity_flip_physical{13.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{14.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{15.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{16.0}=0x0
|
||||
phy_chain_rx_lane_map_physical{13.0}=0x3210
|
||||
phy_chain_rx_polarity_flip_physical{13.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{14.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{15.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{16.0}=0x1
|
||||
|
||||
phy_chain_tx_lane_map_physical{21.0}=0x3210
|
||||
phy_chain_tx_polarity_flip_physical{21.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{22.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{23.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{24.0}=0x0
|
||||
phy_chain_rx_lane_map_physical{21.0}=0x3210
|
||||
phy_chain_rx_polarity_flip_physical{21.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{22.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{23.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{24.0}=0x1
|
||||
|
||||
phy_chain_tx_lane_map_physical{29.0}=0x3210
|
||||
phy_chain_tx_polarity_flip_physical{29.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{30.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{31.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{32.0}=0x0
|
||||
phy_chain_rx_lane_map_physical{29.0}=0x3210
|
||||
phy_chain_rx_polarity_flip_physical{29.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{30.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{31.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{32.0}=0x0
|
||||
|
||||
phy_chain_tx_lane_map_physical{33.0}=0x3210
|
||||
phy_chain_tx_polarity_flip_physical{33.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{34.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{35.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{36.0}=0x0
|
||||
phy_chain_rx_lane_map_physical{33.0}=0x3210
|
||||
phy_chain_rx_polarity_flip_physical{33.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{34.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{35.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{36.0}=0x1
|
||||
|
||||
phy_chain_tx_lane_map_physical{41.0}=0x3210
|
||||
phy_chain_tx_polarity_flip_physical{41.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{42.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{43.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{44.0}=0x0
|
||||
phy_chain_rx_lane_map_physical{41.0}=0x3210
|
||||
phy_chain_rx_polarity_flip_physical{41.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{42.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{43.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{44.0}=0x1
|
||||
|
||||
phy_chain_tx_lane_map_physical{49.0}=0x3210
|
||||
phy_chain_tx_polarity_flip_physical{49.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{50.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{51.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{52.0}=0x1
|
||||
phy_chain_rx_lane_map_physical{49.0}=0x3210
|
||||
phy_chain_rx_polarity_flip_physical{49.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{50.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{51.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{52.0}=0x0
|
||||
|
||||
phy_chain_tx_lane_map_physical{57.0}=0x3210
|
||||
phy_chain_tx_polarity_flip_physical{57.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{58.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{59.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{60.0}=0x1
|
||||
phy_chain_rx_lane_map_physical{57.0}=0x3210
|
||||
phy_chain_rx_polarity_flip_physical{57.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{58.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{59.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{60.0}=0x1
|
||||
|
||||
phy_chain_tx_lane_map_physical{61.0}=0x3210
|
||||
phy_chain_tx_polarity_flip_physical{61.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{62.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{63.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{64.0}=0x1
|
||||
phy_chain_rx_lane_map_physical{61.0}=0x3210
|
||||
phy_chain_rx_polarity_flip_physical{61.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{62.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{63.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{64.0}=0x0
|
||||
|
||||
phy_chain_tx_lane_map_physical{65.0}=0x0123
|
||||
phy_chain_tx_polarity_flip_physical{65.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{66.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{67.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{68.0}=0x1
|
||||
phy_chain_rx_lane_map_physical{65.0}=0x0321
|
||||
phy_chain_rx_polarity_flip_physical{65.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{66.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{67.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{68.0}=0x0
|
||||
|
||||
phy_chain_tx_lane_map_physical{69.0}=0x3120
|
||||
phy_chain_tx_polarity_flip_physical{69.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{70.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{71.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{72.0}=0x1
|
||||
phy_chain_rx_lane_map_physical{69.0}=0x0123
|
||||
phy_chain_rx_polarity_flip_physical{69.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{70.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{71.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{72.0}=0x0
|
||||
|
||||
phy_chain_tx_lane_map_physical{77.0}=0x2130
|
||||
phy_chain_tx_polarity_flip_physical{77.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{78.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{79.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{80.0}=0x0
|
||||
phy_chain_rx_lane_map_physical{77.0}=0x3102
|
||||
phy_chain_rx_polarity_flip_physical{77.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{78.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{79.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{80.0}=0x0
|
||||
|
||||
phy_chain_tx_lane_map_physical{85.0}=0x3210
|
||||
phy_chain_tx_polarity_flip_physical{85.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{86.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{87.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{88.0}=0x1
|
||||
phy_chain_rx_lane_map_physical{85.0}=0x3210
|
||||
phy_chain_rx_polarity_flip_physical{85.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{86.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{87.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{88.0}=0x1
|
||||
|
||||
phy_chain_tx_lane_map_physical{93.0}=0x3210
|
||||
phy_chain_tx_polarity_flip_physical{93.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{94.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{95.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{96.0}=0x1
|
||||
phy_chain_rx_lane_map_physical{93.0}=0x3210
|
||||
phy_chain_rx_polarity_flip_physical{93.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{94.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{95.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{96.0}=0x1
|
||||
|
||||
phy_chain_tx_lane_map_physical{97.0}=0x0312
|
||||
phy_chain_tx_polarity_flip_physical{97.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{98.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{99.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{100.0}=0x1
|
||||
phy_chain_rx_lane_map_physical{97.0}=0x1023
|
||||
phy_chain_rx_polarity_flip_physical{97.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{98.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{99.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{100.0}=0x0
|
||||
|
||||
phy_chain_tx_lane_map_physical{105.0}=0x0123
|
||||
phy_chain_tx_polarity_flip_physical{105.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{106.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{107.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{108.0}=0x0
|
||||
phy_chain_rx_lane_map_physical{105.0}=0x0321
|
||||
phy_chain_rx_polarity_flip_physical{105.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{106.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{107.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{108.0}=0x1
|
||||
|
||||
phy_chain_tx_lane_map_physical{113.0}=0x3120
|
||||
phy_chain_tx_polarity_flip_physical{113.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{114.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{115.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{116.0}=0x0
|
||||
phy_chain_rx_lane_map_physical{113.0}=0x1023
|
||||
phy_chain_rx_polarity_flip_physical{113.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{114.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{115.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{116.0}=0x0
|
||||
|
||||
phy_chain_tx_lane_map_physical{121.0}=0x0132
|
||||
phy_chain_tx_polarity_flip_physical{121.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{122.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{123.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{124.0}=0x0
|
||||
phy_chain_rx_lane_map_physical{121.0}=0x0321
|
||||
phy_chain_rx_polarity_flip_physical{121.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{122.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{123.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{124.0}=0x1
|
||||
|
||||
phy_chain_tx_lane_map_physical{125.0}=0x0213
|
||||
phy_chain_tx_polarity_flip_physical{125.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{126.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{127.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{128.0}=0x1
|
||||
phy_chain_rx_lane_map_physical{125.0}=0x0321
|
||||
phy_chain_rx_polarity_flip_physical{125.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{126.0}=0x1
|
||||
phy_chain_rx_polarity_flip_physical{127.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{128.0}=0x0
|
||||
|
||||
### MerlinCore
|
||||
phy_chain_tx_lane_map_physical{129.0}=0x3210
|
||||
phy_chain_tx_polarity_flip_physical{129.0}=0x0
|
||||
phy_chain_tx_polarity_flip_physical{130.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{131.0}=0x1
|
||||
phy_chain_tx_polarity_flip_physical{132.0}=0x1
|
||||
phy_chain_rx_lane_map_physical{129.0}=0x3210
|
||||
phy_chain_rx_polarity_flip_physical{129.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{130.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{131.0}=0x0
|
||||
phy_chain_rx_polarity_flip_physical{132.0}=0x0
|
||||
|
1
device/quanta/x86_64-quanta_ix8c_bwde-r0/default_sku
Normal file
1
device/quanta/x86_64-quanta_ix8c_bwde-r0/default_sku
Normal file
@ -0,0 +1 @@
|
||||
Quanta-IX8C-56X t1
|
3
device/quanta/x86_64-quanta_ix8c_bwde-r0/installer.conf
Normal file
3
device/quanta/x86_64-quanta_ix8c_bwde-r0/installer.conf
Normal file
@ -0,0 +1,3 @@
|
||||
CONSOLE_PORT=0x3f8
|
||||
CONSOLE_DEV=0
|
||||
CONSOLE_SPEED=115200
|
@ -0,0 +1,6 @@
|
||||
sleep 10
|
||||
led stop
|
||||
sleep 3
|
||||
led start
|
||||
sleep 3
|
||||
led auto on
|
21
device/quanta/x86_64-quanta_ix8c_bwde-r0/plugins/eeprom.py
Normal file
21
device/quanta/x86_64-quanta_ix8c_bwde-r0/plugins/eeprom.py
Normal file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import exceptions
|
||||
import binascii
|
||||
import time
|
||||
import optparse
|
||||
import warnings
|
||||
import os
|
||||
import sys
|
||||
from sonic_eeprom import eeprom_base
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
import subprocess
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
_TLV_INFO_MAX_LEN = 256
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
self.eeprom_path = "/sys/bus/i2c/devices/18-0054/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
49
device/quanta/x86_64-quanta_ix8c_bwde-r0/plugins/psuutil.py
Normal file
49
device/quanta/x86_64-quanta_ix8c_bwde-r0/plugins/psuutil.py
Normal file
@ -0,0 +1,49 @@
|
||||
#
|
||||
# psuutil.py
|
||||
# Platform-specific PSU status interface for SONiC
|
||||
#
|
||||
|
||||
import os.path
|
||||
|
||||
try:
|
||||
from sonic_psu.psu_base import PsuBase
|
||||
except ImportError as e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
|
||||
class PsuUtil(PsuBase):
|
||||
"""Platform-specific PSUutil class"""
|
||||
|
||||
def __init__(self):
|
||||
PsuBase.__init__(self)
|
||||
|
||||
def get_num_psus(self):
|
||||
"""
|
||||
Retrieves the number of PSUs available on the device
|
||||
:return: An integer, the number of PSUs available on the device
|
||||
"""
|
||||
MAX_PSUS = 2
|
||||
|
||||
return MAX_PSUS
|
||||
|
||||
def get_psu_status(self, index):
|
||||
"""
|
||||
Retrieves the oprational status of power supply unit (PSU) defined
|
||||
by index <index>
|
||||
:param index: An integer, index of the PSU of which to query status
|
||||
:return: Boolean, True if PSU is operating properly, False if PSU is\
|
||||
faulty
|
||||
"""
|
||||
status = 1
|
||||
|
||||
return status
|
||||
|
||||
def get_psu_presence(self, index):
|
||||
"""
|
||||
Retrieves the presence status of power supply unit (PSU) defined
|
||||
by index <index>
|
||||
:param index: An integer, index of the PSU of which to query status
|
||||
:return: Boolean, True if PSU is plugged, False if not
|
||||
"""
|
||||
status = 1
|
||||
|
||||
return status
|
207
device/quanta/x86_64-quanta_ix8c_bwde-r0/plugins/sfputil.py
Normal file
207
device/quanta/x86_64-quanta_ix8c_bwde-r0/plugins/sfputil.py
Normal file
@ -0,0 +1,207 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
try:
|
||||
import time
|
||||
from sonic_sfp.sfputilbase import SfpUtilBase
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
|
||||
|
||||
class SfpUtil(SfpUtilBase):
|
||||
"""Platform specific SfpUtill class"""
|
||||
|
||||
PORT_START = 0
|
||||
PORT_END = 55
|
||||
QSFP_PORT_START = 48
|
||||
PORTS_IN_BLOCK = 56
|
||||
|
||||
_port_to_eeprom_mapping = {}
|
||||
_port_to_i2c_mapping = {
|
||||
0 : 32,
|
||||
1 : 33,
|
||||
2 : 34,
|
||||
3 : 35,
|
||||
4 : 36,
|
||||
5 : 37,
|
||||
6 : 38,
|
||||
7 : 39,
|
||||
8 : 40,
|
||||
9 : 41,
|
||||
10 : 42,
|
||||
11 : 43,
|
||||
12 : 44,
|
||||
13 : 45,
|
||||
14 : 46,
|
||||
15 : 47,
|
||||
16 : 48,
|
||||
17 : 49,
|
||||
18 : 50,
|
||||
19 : 51,
|
||||
20 : 52,
|
||||
21 : 53,
|
||||
22 : 54,
|
||||
23 : 55,
|
||||
24 : 56,
|
||||
25 : 57,
|
||||
26 : 58,
|
||||
27 : 59,
|
||||
28 : 60,
|
||||
29 : 61,
|
||||
30 : 62,
|
||||
31 : 63,
|
||||
32 : 64,
|
||||
33 : 65,
|
||||
34 : 66,
|
||||
35 : 67,
|
||||
36 : 68,
|
||||
37 : 69,
|
||||
38 : 70,
|
||||
39 : 71,
|
||||
40 : 72,
|
||||
41 : 73,
|
||||
42 : 74,
|
||||
43 : 75,
|
||||
44 : 76,
|
||||
45 : 77,
|
||||
46 : 78,
|
||||
47 : 79,
|
||||
48 : 80,#QSFP49
|
||||
49 : 81,#QSFP50
|
||||
50 : 82,#QSFP51
|
||||
51 : 83,#QSFP52
|
||||
52 : 84,#QSFP53
|
||||
53 : 85,#QSFP54
|
||||
54 : 86,#QSFP55
|
||||
55 : 87,#QSFP56
|
||||
}
|
||||
|
||||
@property
|
||||
def port_start(self):
|
||||
return self.PORT_START
|
||||
|
||||
@property
|
||||
def qsfp_port_start(self):
|
||||
return self.QSFP_PORT_START
|
||||
|
||||
@property
|
||||
def port_end(self):
|
||||
return self.PORT_END
|
||||
|
||||
@property
|
||||
def qsfp_ports(self):
|
||||
return range(self.QSFP_PORT_START, self.PORTS_IN_BLOCK + 1)
|
||||
|
||||
@property
|
||||
def port_to_eeprom_mapping(self):
|
||||
return self._port_to_eeprom_mapping
|
||||
|
||||
def __init__(self):
|
||||
eeprom_path = '/sys/bus/i2c/devices/{0}-0050/eeprom'
|
||||
for x in range(0, self.port_end+1):
|
||||
self.port_to_eeprom_mapping[x] = eeprom_path.format(self._port_to_i2c_mapping[x])
|
||||
SfpUtilBase.__init__(self)
|
||||
|
||||
def get_presence(self, port_num):
|
||||
# Check for invalid port_num
|
||||
if port_num < self.PORT_START or port_num > self.PORT_END:
|
||||
return False
|
||||
|
||||
try:
|
||||
if port_num < 48:
|
||||
reg_file = open("/sys/class/cpld-sfp28/port-"+str(port_num+1)+"/pre_n")
|
||||
else:
|
||||
reg_file = open("/sys/class/gpio/gpio"+str((port_num-48)*4+34)+"/value")
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
return False
|
||||
|
||||
reg_value = reg_file.readline().rstrip()
|
||||
if port_num < 48:
|
||||
if reg_value == '1':
|
||||
return True
|
||||
else:
|
||||
if reg_value == '0':
|
||||
return True
|
||||
|
||||
return False
|
||||
|
||||
def get_low_power_mode(self, port_num):
|
||||
# Check for invalid port_num
|
||||
if port_num < self.qsfp_port_start or port_num > self.port_end:
|
||||
return False
|
||||
|
||||
try:
|
||||
reg_file = open("/sys/class/gpio/gpio"+str((port_num-48)*4+35)+"/value")
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
return False
|
||||
|
||||
reg_value = int(reg_file.readline().rstrip())
|
||||
|
||||
if reg_value == 0:
|
||||
return False
|
||||
|
||||
return True
|
||||
|
||||
def set_low_power_mode(self, port_num, lpmode):
|
||||
# Check for invalid port_num
|
||||
if port_num < self.qsfp_port_start or port_num > self.port_end:
|
||||
return False
|
||||
|
||||
try:
|
||||
reg_file = open("/sys/class/gpio/gpio"+str((port_num-48)*4+35)+"/value", "r+")
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
return False
|
||||
|
||||
reg_value = int(reg_file.readline().rstrip())
|
||||
|
||||
# LPMode is active high; set or clear the bit accordingly
|
||||
if lpmode is True:
|
||||
reg_value = 1
|
||||
else:
|
||||
reg_value = 0
|
||||
|
||||
reg_file.write(hex(reg_value))
|
||||
reg_file.close()
|
||||
|
||||
return True
|
||||
|
||||
def reset(self, port_num):
|
||||
# Check for invalid port_num
|
||||
if port_num < self.qsfp_port_start or port_num > self.port_end:
|
||||
return False
|
||||
|
||||
try:
|
||||
reg_file = open("/sys/class/gpio/gpio"+str((port_num-48)*4+32)+"/value", "r+")
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
return False
|
||||
|
||||
reg_value = 0
|
||||
reg_file.write(hex(reg_value))
|
||||
reg_file.close()
|
||||
|
||||
# Sleep 2 second to allow it to settle
|
||||
time.sleep(2)
|
||||
|
||||
# Flip the value back write back to the register to take port out of reset
|
||||
try:
|
||||
reg_file = open("/sys/class/gpio/gpio"+str((port_num-48)*4+32)+"/value", "r+")
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
return False
|
||||
|
||||
reg_value = 1
|
||||
reg_file.write(hex(reg_value))
|
||||
reg_file.close()
|
||||
|
||||
return True
|
||||
|
||||
def get_transceiver_change_event(self):
|
||||
"""
|
||||
TODO: This function need to be implemented
|
||||
when decide to support monitoring SFP(Xcvrd)
|
||||
on this platform.
|
||||
"""
|
||||
raise NotImplementedError
|
1
platform/broadcom/one-image.mk
Executable file → Normal file
1
platform/broadcom/one-image.mk
Executable file → Normal file
@ -41,6 +41,7 @@ $(SONIC_ONE_IMAGE)_LAZY_INSTALLS += $(DELL_S6000_PLATFORM_MODULE) \
|
||||
$(DELTA_AG5648_PLATFORM_MODULE) \
|
||||
$(DELTA_ET6248BRB_PLATFORM_MODULE) \
|
||||
$(QUANTA_IX1B_32X_PLATFORM_MODULE) \
|
||||
$(QUANTA_IX8C_56X_PLATFORM_MODULE) \
|
||||
$(MITAC_LY1200_32X_PLATFORM_MODULE) \
|
||||
$(ALPHANETWORKS_SNH60A0_320FV2_PLATFORM_MODULE) \
|
||||
$(ALPHANETWORKS_SNH60B0_640F_PLATFORM_MODULE) \
|
||||
|
@ -1,8 +1,10 @@
|
||||
# Quanta Platform modules
|
||||
|
||||
QUANTA_IX1B_32X_PLATFORM_MODULE_VERSION = 1.0
|
||||
QUANTA_IX8C_56X_PLATFORM_MODULE_VERSION = 1.0
|
||||
|
||||
export QUANTA_IX1B_32X_PLATFORM_MODULE_VERSION
|
||||
export QUANTA_IX8C_56X_PLATFORM_MODULE_VERSION
|
||||
|
||||
QUANTA_IX1B_32X_PLATFORM_MODULE = sonic-platform-quanta-ix1b-32x_$(QUANTA_IX1B_32X_PLATFORM_MODULE_VERSION)_amd64.deb
|
||||
$(QUANTA_IX1B_32X_PLATFORM_MODULE)_SRC_PATH = $(PLATFORM_PATH)/sonic-platform-modules-quanta
|
||||
@ -10,4 +12,8 @@ $(QUANTA_IX1B_32X_PLATFORM_MODULE)_DEPENDS += $(LINUX_HEADERS) $(LINUX_HEADERS_C
|
||||
$(QUANTA_IX1B_32X_PLATFORM_MODULE)_PLATFORM = x86_64-quanta_ix1b_rglbmc-r0
|
||||
SONIC_DPKG_DEBS += $(QUANTA_IX1B_32X_PLATFORM_MODULE)
|
||||
|
||||
QUANTA_IX8C_56X_PLATFORM_MODULE = sonic-platform-quanta-ix8c-56x_$(QUANTA_IX8C_56X_PLATFORM_MODULE_VERSION)_amd64.deb
|
||||
$(QUANTA_IX8C_56X_PLATFORM_MODULE)_PLATFORM = x86_64-quanta_ix8c_bwde-r0
|
||||
$(eval $(call add_extra_package,$(QUANTA_IX1B_32X_PLATFORM_MODULE),$(QUANTA_IX8C_56X_PLATFORM_MODULE)))
|
||||
|
||||
SONIC_STRETCH_DEBS += $(QUANTA_IX1B_32X_PLATFORM_MODULE)
|
||||
|
7
platform/broadcom/sonic-platform-modules-quanta/debian/changelog
Executable file → Normal file
7
platform/broadcom/sonic-platform-modules-quanta/debian/changelog
Executable file → Normal file
@ -4,3 +4,10 @@ sonic-quanta-platform-modules (1.0) unstable; urgency=low
|
||||
* Initial release
|
||||
|
||||
-- Chih-Pei Chang <Chih-Pei.Chang@qct.io> Jonathan Tsai <jonathan.tsai@quantatw.com> Wed, 20 Dec 2017 09:26:01 +0800
|
||||
|
||||
sonic-quanta-platform-modules (1.0) unstable; urgency=low
|
||||
|
||||
* Add support for Quanta IX8C-56X
|
||||
* Initial release
|
||||
|
||||
-- Chih-Pei Chang <Chih-Pei.Chang@qct.io> Jonathan Tsai <jonathan.tsai@quantatw.com> Thu, 4 Jan 2018 13:50:01 +0800
|
||||
|
6
platform/broadcom/sonic-platform-modules-quanta/debian/control
Executable file → Normal file
6
platform/broadcom/sonic-platform-modules-quanta/debian/control
Executable file → Normal file
@ -2,11 +2,13 @@ Source: sonic-quanta-platform-modules
|
||||
Section: main
|
||||
Priority: extra
|
||||
Maintainer: Chih-Pei Chang <Chih-Pei.Chang@qct.io>, Jonathan Tsai <jonathan.tsai@quantatw.com>
|
||||
Build-Depends: debhelper (>= 8.0.0), bzip2
|
||||
Build-Depends: debhelper (>= 9), bzip2
|
||||
Standards-Version: 3.9.3
|
||||
|
||||
Package: sonic-platform-quanta-ix1b-32x
|
||||
Architecture: amd64
|
||||
Depends: linux-image-3.16.0-5-amd64
|
||||
Description: kernel modules for platform devices such as psu, led, sfp
|
||||
|
||||
Package: sonic-platform-quanta-ix8c-56x
|
||||
Architecture: amd64
|
||||
Description: kernel modules for platform devices such as psu, led, sfp
|
||||
|
8
platform/broadcom/sonic-platform-modules-quanta/debian/rules
Executable file → Normal file
8
platform/broadcom/sonic-platform-modules-quanta/debian/rules
Executable file → Normal file
@ -19,7 +19,7 @@ PACKAGE_PRE_NAME := sonic-platform-quanta
|
||||
KVERSION ?= $(shell uname -r)
|
||||
KERNEL_SRC := /lib/modules/$(KVERSION)
|
||||
MOD_SRC_DIR:= $(shell pwd)
|
||||
MODULE_DIRS:= ix1b-32x
|
||||
MODULE_DIRS:= ix1b-32x ix8c-56x
|
||||
MODULE_DIR := modules
|
||||
UTILS_DIR := utils
|
||||
SERVICE_DIR := service
|
||||
@ -59,9 +59,9 @@ binary-indep:
|
||||
|
||||
# Custom package commands
|
||||
(for mod in $(MODULE_DIRS); do \
|
||||
dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \
|
||||
dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod}/usr/local/bin; \
|
||||
dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod}/lib/systemd/system; \
|
||||
dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} $(KERNEL_SRC)/$(INSTALL_MOD_DIR); \
|
||||
dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} usr/local/bin; \
|
||||
dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} lib/systemd/system; \
|
||||
cp $(MOD_SRC_DIR)/$${mod}/$(MODULE_DIR)/*.ko debian/$(PACKAGE_PRE_NAME)-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \
|
||||
cp $(MOD_SRC_DIR)/$${mod}/$(UTILS_DIR)/* debian/$(PACKAGE_PRE_NAME)-$${mod}/usr/local/bin/; \
|
||||
cp $(MOD_SRC_DIR)/$${mod}/$(SERVICE_DIR)/*.service debian/$(PACKAGE_PRE_NAME)-$${mod}/lib/systemd/system/; \
|
||||
|
@ -0,0 +1,3 @@
|
||||
obj-m:=qci_cpld_sfp28.o qci_cpld_led.o qci_platform_ix8c.o
|
||||
|
||||
|
@ -0,0 +1,275 @@
|
||||
/*
|
||||
* A LED CPLD driver for Quanta Switch Platform
|
||||
*
|
||||
* The CPLD is customize by Quanta for decode led bit stream,
|
||||
* This driver modify from Quanta CPLD I/O driver.
|
||||
*
|
||||
* Copyright (C) 2015 Quanta Inc.
|
||||
*
|
||||
* Author: Luffy Cheng <luffy.cheng@quantatw.com>
|
||||
* Author: Roger Chang <Roger.Chang@quantatw.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/log2.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/kdev_t.h>
|
||||
#include <linux/idr.h>
|
||||
|
||||
static DEFINE_IDA(cpld_led_ida);
|
||||
|
||||
enum platform_type {
|
||||
IX7 = 0,
|
||||
IX8C,
|
||||
NONE
|
||||
};
|
||||
|
||||
static struct class *cpld_class = NULL;
|
||||
|
||||
struct cpld_data {
|
||||
struct i2c_client *cpld_client;
|
||||
char name[8];
|
||||
u8 cpld_id;
|
||||
};
|
||||
|
||||
struct cpld_led_data {
|
||||
struct mutex lock;
|
||||
struct device *port_dev;
|
||||
struct cpld_data *cpld_data;
|
||||
};
|
||||
|
||||
static int cpld_led_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id);
|
||||
static int cpld_led_remove(struct i2c_client *client);
|
||||
|
||||
static const struct i2c_device_id cpld_led_id[] = {
|
||||
{ "CPLDLED_IX7", IX7 },
|
||||
{ "CPLDLED_IX8C", IX8C },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, cpld_led_id);
|
||||
|
||||
static struct i2c_driver cpld_led_driver = {
|
||||
.class = I2C_CLASS_HWMON,
|
||||
.driver = {
|
||||
.name = "qci_cpld_led",
|
||||
},
|
||||
.probe = cpld_led_probe,
|
||||
.remove = cpld_led_remove,
|
||||
.id_table = cpld_led_id,
|
||||
// .address_list = normal_i2c,
|
||||
};
|
||||
|
||||
#define CPLD_LED_ID_PREFIX "CPLDLED-"
|
||||
#define CPLD_LED_ID_FORMAT CPLD_LED_ID_PREFIX "%d"
|
||||
|
||||
#define CPLD_DECODER_OFFSET 0x4
|
||||
#define CPLD_DECODER_MASK 0x1
|
||||
#define CPLD_USERCODE_START_OFFSET 0x0
|
||||
|
||||
static ssize_t get_led_decode(struct device *dev,
|
||||
struct device_attribute *devattr,
|
||||
char *buf)
|
||||
{
|
||||
struct cpld_data *data = dev_get_drvdata(dev);
|
||||
struct i2c_client *client = data->cpld_client;
|
||||
u8 offset = (u8)(CPLD_DECODER_OFFSET);
|
||||
s32 value;
|
||||
|
||||
value = i2c_smbus_read_byte_data(client, offset);
|
||||
if (value < 0)
|
||||
return -ENODEV;
|
||||
|
||||
dev_dbg(&client->dev, "read led decode value= %x\n", value);
|
||||
|
||||
value &= CPLD_DECODER_MASK;
|
||||
|
||||
return sprintf(buf, "%d\n", (value == 0) ? 1 : 0);
|
||||
}
|
||||
|
||||
static ssize_t get_usercode(struct device *dev,
|
||||
struct device_attribute *devattr,
|
||||
char *buf)
|
||||
{
|
||||
struct cpld_data *data = dev_get_drvdata(dev);
|
||||
struct i2c_client *client = data->cpld_client;
|
||||
u8 i = 0;
|
||||
s32 value = 0, reading = 0;
|
||||
|
||||
for (i = 0; i < 4; i++)
|
||||
{
|
||||
reading = i2c_smbus_read_byte_data(client, CPLD_USERCODE_START_OFFSET + i);
|
||||
if (reading < 0)
|
||||
return -ENODEV;
|
||||
|
||||
dev_dbg(&client->dev, "read led usercode reg %d value= %x\n", i, reading);
|
||||
|
||||
value |= reading << (24 - 8 * i);
|
||||
}
|
||||
|
||||
return sprintf(buf, "%X\n", value);
|
||||
}
|
||||
|
||||
static ssize_t set_led_decode(struct device *dev,
|
||||
struct device_attribute *devattr,
|
||||
const char *buf,
|
||||
size_t count)
|
||||
{
|
||||
struct cpld_data *data = dev_get_drvdata(dev);
|
||||
struct i2c_client *client = data->cpld_client;
|
||||
s32 value;
|
||||
long enable;
|
||||
|
||||
if (kstrtol(buf, 0, &enable))
|
||||
return -EINVAL;
|
||||
|
||||
if ((enable != 1) && (enable != 0))
|
||||
return -EINVAL;
|
||||
|
||||
// mutex_lock(&data->lock);
|
||||
value = i2c_smbus_read_byte_data(client, CPLD_DECODER_OFFSET);
|
||||
if (value < 0)
|
||||
return -ENODEV;
|
||||
|
||||
dev_dbg(&client->dev, "read led decode value= %x\n", value);
|
||||
|
||||
value |= CPLD_DECODER_MASK;
|
||||
if (enable)
|
||||
value &= ~CPLD_DECODER_MASK;
|
||||
|
||||
dev_dbg(&client->dev, "write led decode value= %x\n", value);
|
||||
|
||||
i2c_smbus_write_byte_data(client, CPLD_DECODER_OFFSET, (u8)value);
|
||||
// mutex_unlock(&data->lock);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(led_decode, S_IWUSR | S_IRUGO, get_led_decode, set_led_decode);
|
||||
static DEVICE_ATTR(usercode, S_IRUGO, get_usercode, NULL);
|
||||
|
||||
static const struct attribute *led_attrs[] = {
|
||||
&dev_attr_usercode.attr,
|
||||
&dev_attr_led_decode.attr,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct attribute_group led_attr_group = {
|
||||
.attrs = (struct attribute **) led_attrs,
|
||||
};
|
||||
|
||||
static int cpld_led_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct cpld_led_data *data;
|
||||
struct cpld_data *led_data;
|
||||
struct device *port_dev;
|
||||
int nr, err;
|
||||
|
||||
if (!cpld_class)
|
||||
{
|
||||
cpld_class = class_create(THIS_MODULE, "cpld-led");
|
||||
if (IS_ERR(cpld_class)) {
|
||||
pr_err("couldn't create sysfs class\n");
|
||||
return PTR_ERR(cpld_class);
|
||||
}
|
||||
}
|
||||
|
||||
data = devm_kzalloc(&client->dev, sizeof(struct cpld_led_data),
|
||||
GFP_KERNEL);
|
||||
if (!data)
|
||||
return -ENOMEM;
|
||||
|
||||
/* Test */
|
||||
nr = ida_simple_get(&cpld_led_ida, 1, 99, GFP_KERNEL);
|
||||
if (nr < 0)
|
||||
goto err_out;
|
||||
|
||||
led_data = kzalloc(sizeof(struct cpld_led_data), GFP_KERNEL);
|
||||
|
||||
port_dev = device_create(cpld_class, &client->dev, MKDEV(0,0), led_data, CPLD_LED_ID_FORMAT, nr);
|
||||
if (IS_ERR(port_dev)) {
|
||||
err = PTR_ERR(port_dev);
|
||||
// printk("err_status\n");
|
||||
}
|
||||
|
||||
data->port_dev = port_dev;
|
||||
data->cpld_data = led_data;
|
||||
|
||||
dev_info(&client->dev, "Register CPLDLED %d\n", nr);
|
||||
|
||||
sprintf(led_data->name, "LED%d-data", nr);
|
||||
led_data->cpld_id = nr;
|
||||
dev_set_drvdata(port_dev, led_data);
|
||||
port_dev->init_name = led_data->name;
|
||||
led_data->cpld_client = client;
|
||||
|
||||
err = sysfs_create_group(&port_dev->kobj, &led_attr_group);
|
||||
// if (status) printk("err status\n");
|
||||
/* end */
|
||||
|
||||
i2c_set_clientdata(client, data);
|
||||
mutex_init(&data->lock);
|
||||
|
||||
dev_info(&client->dev, "%s device found\n", client->name);
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
err_out:
|
||||
return nr;
|
||||
}
|
||||
|
||||
/* FIXME: for older kernel doesn't with idr_is_empty function, implement here */
|
||||
static int idr_has_entry(int id, void *p, void *data)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static bool cpld_idr_is_empty(struct idr *idp)
|
||||
{
|
||||
return !idr_for_each(idp, idr_has_entry, NULL);
|
||||
}
|
||||
|
||||
static int cpld_led_remove(struct i2c_client *client)
|
||||
{
|
||||
struct cpld_led_data *data = i2c_get_clientdata(client);
|
||||
|
||||
dev_info(data->port_dev, "Remove CPLDLED-%d\n", data->cpld_data->cpld_id);
|
||||
device_unregister(data->port_dev);
|
||||
ida_simple_remove(&cpld_led_ida, data->cpld_data->cpld_id);
|
||||
kfree(data->cpld_data);
|
||||
|
||||
if (cpld_idr_is_empty(&cpld_led_ida.idr))
|
||||
class_destroy(cpld_class);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
module_i2c_driver(cpld_led_driver);
|
||||
|
||||
MODULE_AUTHOR("Luffy Cheng <luffy.cheng@quantatw.com>");
|
||||
MODULE_AUTHOR("Roger Chang <Roger.Chang@quantatw.com>");
|
||||
MODULE_DESCRIPTION("Quanta Switch LED CPLD driver");
|
||||
MODULE_LICENSE("GPL");
|
@ -0,0 +1,398 @@
|
||||
/*
|
||||
* A CPLD driver for monitor SFP28 module I/O
|
||||
*
|
||||
* The CPLD is customize by Quanta for controlling SFP28 module signals,
|
||||
* they are TX_FAULT , TX_DIS , PRE_N , RX_LOS
|
||||
* Each CPLD control 16 modules, each module use 4 bits in register.
|
||||
*
|
||||
* Copyright (C) 2015 Quanta Inc.
|
||||
*
|
||||
* Author: Luffy Cheng <luffy.cheng@quantatw.com>
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*/
|
||||
|
||||
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/log2.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/kdev_t.h>
|
||||
#include <linux/idr.h>
|
||||
#include <linux/ctype.h>
|
||||
#include <linux/string.h>
|
||||
|
||||
static DEFINE_IDA(cpld_ida);
|
||||
|
||||
enum platform_type {
|
||||
SFP = 0,
|
||||
SFP28,
|
||||
NONE
|
||||
};
|
||||
|
||||
static struct class *cpld_class = NULL;
|
||||
|
||||
struct sfp_data {
|
||||
struct i2c_client *cpld_client;
|
||||
char name[8];
|
||||
char type[8];
|
||||
u8 port_id;
|
||||
u8 cpld_port;
|
||||
};
|
||||
|
||||
struct cpld_data {
|
||||
struct mutex lock;
|
||||
struct device *port_dev[16];
|
||||
struct sfp_data *port_data[16];
|
||||
};
|
||||
|
||||
static int cpld_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id);
|
||||
static int cpld_remove(struct i2c_client *client);
|
||||
|
||||
static const struct i2c_device_id cpld_id[] = {
|
||||
{ "CPLD-SFP", SFP },
|
||||
{ "CPLD-SFP28", SFP28 },
|
||||
{ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, cpld_id);
|
||||
|
||||
static struct i2c_driver cpld_driver = {
|
||||
.class = I2C_CLASS_HWMON,
|
||||
.driver = {
|
||||
.name = "qci_cpld_sfp28",
|
||||
},
|
||||
.probe = cpld_probe,
|
||||
.remove = cpld_remove,
|
||||
.id_table = cpld_id,
|
||||
// .address_list = normal_i2c,
|
||||
};
|
||||
|
||||
#define CPLD_ID_PREFIX "port-"
|
||||
#define CPLD_ID_FORMAT CPLD_ID_PREFIX "%d"
|
||||
|
||||
//SFP28
|
||||
#define TX_FAULT_MASK 0x08
|
||||
#define TX_DIS_MASK 0x04
|
||||
#define PRE_N_MASK 0x02
|
||||
#define RX_LOS_MASK 0x01
|
||||
|
||||
static inline u8 get_group_cmd(u8 group)
|
||||
{
|
||||
//FIXME: if group cmd change
|
||||
return (group + 1);
|
||||
}
|
||||
|
||||
static inline u8 port_remapping(u8 phy_port)
|
||||
{
|
||||
/* FIXME: implement by hardware design */
|
||||
/* The CPLD register port mapping is weird :
|
||||
* MSB -------- LSB (word data)
|
||||
* P3 P4 P1 P2 (per port 4 bits)
|
||||
* For easy coding bit shift, we treat it as hw port swap
|
||||
*/
|
||||
return (phy_port % 2) ? (phy_port - 1) : (phy_port + 1);
|
||||
}
|
||||
|
||||
//SFP
|
||||
static ssize_t get_tx_fault(struct device *dev,
|
||||
struct device_attribute *devattr,
|
||||
char *buf)
|
||||
{
|
||||
struct sfp_data *data = dev_get_drvdata(dev);
|
||||
struct i2c_client *client = data->cpld_client;
|
||||
u8 group = (u8)(data->cpld_port / 4);
|
||||
u8 group_port = data->cpld_port % 4;
|
||||
s32 value;
|
||||
|
||||
dev_dbg(&client->dev, "port_id %d => cpld_port %d, group %d(%d)\n", data->port_id,
|
||||
data->cpld_port + 1, group + 1, group_port + 1);
|
||||
|
||||
value = i2c_smbus_read_word_data(client, get_group_cmd(group));
|
||||
if (value < 0)
|
||||
return -ENODEV;
|
||||
|
||||
dev_dbg(&client->dev, "read group%d value= %x\n", group + 1, value);
|
||||
|
||||
value >>= (group_port * 4);
|
||||
value &= TX_FAULT_MASK;
|
||||
|
||||
return sprintf(buf, "%d\n", value ? 1 : 0);
|
||||
}
|
||||
|
||||
static ssize_t get_tx_dis(struct device *dev,
|
||||
struct device_attribute *devattr,
|
||||
char *buf)
|
||||
{
|
||||
struct sfp_data *data = dev_get_drvdata(dev);
|
||||
struct i2c_client *client = data->cpld_client;
|
||||
u8 group = (u8)(data->cpld_port / 4);
|
||||
u8 group_port = data->cpld_port % 4;
|
||||
s32 value;
|
||||
|
||||
dev_dbg(&client->dev, "port_id %d => cpld_port %d, group %d(%d)\n", data->port_id,
|
||||
data->cpld_port + 1, group + 1, group_port + 1);
|
||||
|
||||
value = i2c_smbus_read_word_data(client, get_group_cmd(group));
|
||||
if (value < 0)
|
||||
return -ENODEV;
|
||||
|
||||
dev_dbg(&client->dev, "read group%d value= %x\n", group + 1, value);
|
||||
|
||||
value >>= (group_port * 4);
|
||||
value &= TX_DIS_MASK;
|
||||
|
||||
return sprintf(buf, "%d\n", value ? 1 : 0);
|
||||
}
|
||||
|
||||
static ssize_t get_pre_n(struct device *dev,
|
||||
struct device_attribute *devattr,
|
||||
char *buf)
|
||||
{
|
||||
struct sfp_data *data = dev_get_drvdata(dev);
|
||||
struct i2c_client *client = data->cpld_client;
|
||||
u8 group = (u8)(data->cpld_port / 4);
|
||||
u8 group_port = data->cpld_port % 4;
|
||||
s32 value;
|
||||
|
||||
dev_dbg(&client->dev, "port_id %d => cpld_port %d, group %d(%d)\n", data->port_id,
|
||||
data->cpld_port + 1, group + 1, group_port + 1);
|
||||
|
||||
value = i2c_smbus_read_word_data(client, get_group_cmd(group));
|
||||
if (value < 0)
|
||||
return -ENODEV;
|
||||
|
||||
dev_dbg(&client->dev, "read group%d value= %x\n", group + 1, value);
|
||||
|
||||
value >>= (group_port * 4);
|
||||
value &= PRE_N_MASK;
|
||||
|
||||
//FIXME: if present is not low active
|
||||
return sprintf(buf, "%d\n", value ? 0 : 1);
|
||||
}
|
||||
|
||||
static ssize_t get_rx_los(struct device *dev,
|
||||
struct device_attribute *devattr,
|
||||
char *buf)
|
||||
{
|
||||
struct sfp_data *data = dev_get_drvdata(dev);
|
||||
struct i2c_client *client = data->cpld_client;
|
||||
u8 group = (u8)(data->cpld_port / 4);
|
||||
u8 group_port = data->cpld_port % 4;
|
||||
s32 value;
|
||||
|
||||
dev_dbg(&client->dev, "port_id %d => cpld_port %d, group %d(%d)\n", data->port_id,
|
||||
data->cpld_port + 1, group + 1, group_port + 1);
|
||||
|
||||
value = i2c_smbus_read_word_data(client, get_group_cmd(group));
|
||||
if (value < 0)
|
||||
return -ENODEV;
|
||||
|
||||
dev_dbg(&client->dev, "read group%d value= %x\n", group + 1, value);
|
||||
|
||||
value >>= (group_port * 4);
|
||||
value &= RX_LOS_MASK;
|
||||
|
||||
return sprintf(buf, "%d\n", value ? 1 : 0);
|
||||
}
|
||||
static ssize_t set_tx_dis(struct device *dev,
|
||||
struct device_attribute *devattr,
|
||||
const char *buf,
|
||||
size_t count)
|
||||
{
|
||||
struct sfp_data *data = dev_get_drvdata(dev);
|
||||
struct i2c_client *client = data->cpld_client;
|
||||
u8 group = (u8)(data->cpld_port / 4);
|
||||
u8 group_port = data->cpld_port % 4;
|
||||
s32 value;
|
||||
long disable;
|
||||
|
||||
dev_dbg(&client->dev, "port_id %d => cpld_port %d, group %d(%d)\n", data->port_id,
|
||||
data->cpld_port + 1, group + 1, group_port + 1);
|
||||
|
||||
if (kstrtol(buf, 0, &disable))
|
||||
return -EINVAL;
|
||||
|
||||
if ((disable != 1) && (disable != 0))
|
||||
return -EINVAL;
|
||||
|
||||
// mutex_lock(&data->lock);
|
||||
value = i2c_smbus_read_word_data(client, get_group_cmd(group));
|
||||
if (value < 0)
|
||||
return -ENODEV;
|
||||
|
||||
dev_dbg(&client->dev, "read group%d value= %x\n", group + 1, value);
|
||||
|
||||
value &= ~(TX_DIS_MASK << (group_port * 4));
|
||||
if (disable)
|
||||
value |= (TX_DIS_MASK << (group_port * 4));
|
||||
|
||||
dev_dbg(&client->dev, "write group%d value= %x\n", group + 1, value);
|
||||
|
||||
i2c_smbus_write_word_data(client, get_group_cmd(group), (u16)value);
|
||||
// mutex_unlock(&data->lock);
|
||||
|
||||
return count;
|
||||
}
|
||||
//SFP
|
||||
|
||||
//static DEVICE_ATTR(led_enable, S_IWUSR | S_IRUGO, get_led_enable, set_led_enable);
|
||||
//static DEVICE_ATTR(monitor_enable, S_IWUSR | S_IRUGO, get_monitor_enable, set_monitor_enable);
|
||||
//SFP
|
||||
static DEVICE_ATTR(tx_fault, S_IRUGO, get_tx_fault, NULL);
|
||||
static DEVICE_ATTR(tx_dis, S_IWUSR | S_IRUGO, get_tx_dis, set_tx_dis);
|
||||
static DEVICE_ATTR(pre_n, S_IRUGO, get_pre_n, NULL);
|
||||
static DEVICE_ATTR(rx_los, S_IRUGO, get_rx_los, NULL);
|
||||
|
||||
static const struct attribute *sfp_attrs[] = {
|
||||
// &dev_attr_led_enable.attr,
|
||||
&dev_attr_tx_fault.attr,
|
||||
&dev_attr_tx_dis.attr,
|
||||
&dev_attr_pre_n.attr,
|
||||
&dev_attr_rx_los.attr,
|
||||
NULL,
|
||||
};
|
||||
|
||||
static const struct attribute_group sfp_attr_group = {
|
||||
.attrs = (struct attribute **) sfp_attrs,
|
||||
};
|
||||
|
||||
static int cpld_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct cpld_data *data;
|
||||
struct sfp_data *port_data;
|
||||
// struct i2c_monitor_data *monitor_data;
|
||||
struct device *port_dev;
|
||||
// struct device *i2c_dev;
|
||||
int port_nr, i=0, err;
|
||||
char name[I2C_NAME_SIZE], type[I2C_NAME_SIZE];
|
||||
|
||||
printk("cpld cpld_probe\n");
|
||||
|
||||
while(id->name[i])
|
||||
{
|
||||
name[i]=tolower(id->name[i]);
|
||||
i++;
|
||||
}
|
||||
name[i]='\0';
|
||||
strncpy(type,name+5,strlen(name)-5);
|
||||
type[strlen(name)-5]='\0';
|
||||
|
||||
if (!cpld_class)
|
||||
{
|
||||
cpld_class = class_create(THIS_MODULE, name);
|
||||
if (IS_ERR(cpld_class)) {
|
||||
pr_err("couldn't create sysfs class\n");
|
||||
return PTR_ERR(cpld_class);
|
||||
}
|
||||
}
|
||||
|
||||
data = devm_kzalloc(&client->dev, sizeof(struct cpld_data),
|
||||
GFP_KERNEL);
|
||||
if (!data)
|
||||
return -ENOMEM;
|
||||
|
||||
/* register sfp port data to sysfs */
|
||||
for (i = 0; i < 16; i++)
|
||||
{
|
||||
port_nr = ida_simple_get(&cpld_ida, 1, 99, GFP_KERNEL);
|
||||
if (port_nr < 0)
|
||||
goto err_out;
|
||||
|
||||
port_data = kzalloc(sizeof(struct sfp_data), GFP_KERNEL);
|
||||
|
||||
port_dev = device_create(cpld_class, &client->dev, MKDEV(0,0), port_data, CPLD_ID_FORMAT, port_nr);
|
||||
if (IS_ERR(port_dev)) {
|
||||
err = PTR_ERR(port_dev);
|
||||
printk("err_status\n");
|
||||
}
|
||||
|
||||
data->port_dev[i] = port_dev;
|
||||
data->port_data[i] = port_data;
|
||||
|
||||
strcpy(port_data->type, type);
|
||||
|
||||
dev_info(&client->dev, "Register %s port-%d\n", port_data->type , port_nr);
|
||||
|
||||
/* FIXME: implement Logical/Physical port remapping */
|
||||
//port_data->cpld_port = i;
|
||||
port_data->cpld_port = port_remapping(i);
|
||||
sprintf(port_data->name, "port-%d", port_nr);
|
||||
port_data->port_id = port_nr;
|
||||
dev_set_drvdata(port_dev, port_data);
|
||||
port_dev->init_name = port_data->name;
|
||||
port_data->cpld_client = client;
|
||||
|
||||
err = sysfs_create_group(&port_dev->kobj, &sfp_attr_group);
|
||||
// if (status) printk("err status\n");
|
||||
}
|
||||
|
||||
i2c_set_clientdata(client, data);
|
||||
mutex_init(&data->lock);
|
||||
|
||||
dev_info(&client->dev, "%s device found\n", client->name);
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
err_out:
|
||||
return port_nr;
|
||||
}
|
||||
|
||||
/* FIXME: for older kernel doesn't with idr_is_empty function, implement here */
|
||||
#if 1
|
||||
static int idr_has_entry(int id, void *p, void *data)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static bool cpld_idr_is_empty(struct idr *idp)
|
||||
{
|
||||
return !idr_for_each(idp, idr_has_entry, NULL);
|
||||
}
|
||||
#endif
|
||||
|
||||
static int cpld_remove(struct i2c_client *client)
|
||||
{
|
||||
struct cpld_data *data = i2c_get_clientdata(client);
|
||||
int i;
|
||||
// int id;
|
||||
|
||||
for (i = 15; i >= 0; i--)
|
||||
{
|
||||
dev_info(data->port_dev[i], "Remove %s port-%d\n", data->port_data[i]->type , data->port_data[i]->port_id);
|
||||
device_unregister(data->port_dev[i]);
|
||||
ida_simple_remove(&cpld_ida, data->port_data[i]->port_id);
|
||||
kfree(data->port_data[i]);
|
||||
}
|
||||
|
||||
if (cpld_idr_is_empty(&cpld_ida.idr))
|
||||
class_destroy(cpld_class);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
module_i2c_driver(cpld_driver);
|
||||
|
||||
MODULE_AUTHOR("Jonathan Tsai <jonathan.tsai@quantatw.com>");
|
||||
MODULE_VERSION("1.0");
|
||||
MODULE_DESCRIPTION("Quanta Switch SFP28 CPLD driver");
|
||||
MODULE_LICENSE("GPL");
|
@ -0,0 +1,400 @@
|
||||
/*
|
||||
* Quanta IX8C platform driver
|
||||
*
|
||||
*
|
||||
* Copyright (C) 2017 Quanta Computer inc.
|
||||
*
|
||||
* This program is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation; either version 2 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
*
|
||||
*/
|
||||
|
||||
#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
|
||||
|
||||
#include <linux/version.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/proc_fs.h>
|
||||
#include <linux/backlight.h>
|
||||
#include <linux/fb.h>
|
||||
#include <linux/leds.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/uaccess.h>
|
||||
#include <linux/input.h>
|
||||
#include <linux/input/sparse-keymap.h>
|
||||
#include <linux/input-polldev.h>
|
||||
#include <linux/rfkill.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/i2c/pca954x.h>
|
||||
#if (LINUX_VERSION_CODE < KERNEL_VERSION(3,16,0))
|
||||
#include <linux/i2c/pca953x.h>
|
||||
#else
|
||||
#include <linux/platform_data/pca953x.h>
|
||||
#endif
|
||||
|
||||
#define MUX_INFO(bus, deselect) \
|
||||
{.adap_id = bus, .deselect_on_exit = deselect}
|
||||
|
||||
static struct pca954x_platform_mode pca9548sfp1_modes[] = {
|
||||
MUX_INFO(0x20, 1),
|
||||
MUX_INFO(0x21, 1),
|
||||
MUX_INFO(0x22, 1),
|
||||
MUX_INFO(0x23, 1),
|
||||
MUX_INFO(0x24, 1),
|
||||
MUX_INFO(0x25, 1),
|
||||
MUX_INFO(0x26, 1),
|
||||
MUX_INFO(0x27, 1),
|
||||
};
|
||||
|
||||
static struct pca954x_platform_data pca9548sfp1_data = {
|
||||
.modes = pca9548sfp1_modes,
|
||||
.num_modes = 8,
|
||||
};
|
||||
|
||||
static struct pca954x_platform_mode pca9548sfp2_modes[] = {
|
||||
MUX_INFO(0x28, 1),
|
||||
MUX_INFO(0x29, 1),
|
||||
MUX_INFO(0x2a, 1),
|
||||
MUX_INFO(0x2b, 1),
|
||||
MUX_INFO(0x2c, 1),
|
||||
MUX_INFO(0x2d, 1),
|
||||
MUX_INFO(0x2e, 1),
|
||||
MUX_INFO(0x2f, 1),
|
||||
};
|
||||
|
||||
static struct pca954x_platform_data pca9548sfp2_data = {
|
||||
.modes = pca9548sfp2_modes,
|
||||
.num_modes = 8,
|
||||
};
|
||||
static struct pca954x_platform_mode pca9548sfp3_modes[] = {
|
||||
MUX_INFO(0x30, 1),
|
||||
MUX_INFO(0x31, 1),
|
||||
MUX_INFO(0x32, 1),
|
||||
MUX_INFO(0x33, 1),
|
||||
MUX_INFO(0x34, 1),
|
||||
MUX_INFO(0x35, 1),
|
||||
MUX_INFO(0x36, 1),
|
||||
MUX_INFO(0x37, 1),
|
||||
};
|
||||
|
||||
static struct pca954x_platform_data pca9548sfp3_data = {
|
||||
.modes = pca9548sfp3_modes,
|
||||
.num_modes = 8,
|
||||
};
|
||||
|
||||
static struct pca954x_platform_mode pca9548sfp4_modes[] = {
|
||||
MUX_INFO(0x38, 1),
|
||||
MUX_INFO(0x39, 1),
|
||||
MUX_INFO(0x3a, 1),
|
||||
MUX_INFO(0x3b, 1),
|
||||
MUX_INFO(0x3c, 1),
|
||||
MUX_INFO(0x3d, 1),
|
||||
MUX_INFO(0x3e, 1),
|
||||
MUX_INFO(0x3f, 1),
|
||||
};
|
||||
|
||||
static struct pca954x_platform_data pca9548sfp4_data = {
|
||||
.modes = pca9548sfp4_modes,
|
||||
.num_modes = 8,
|
||||
};
|
||||
|
||||
static struct pca954x_platform_mode pca9548sfp5_modes[] = {
|
||||
MUX_INFO(0x40, 1),
|
||||
MUX_INFO(0x41, 1),
|
||||
MUX_INFO(0x42, 1),
|
||||
MUX_INFO(0x43, 1),
|
||||
MUX_INFO(0x44, 1),
|
||||
MUX_INFO(0x45, 1),
|
||||
MUX_INFO(0x46, 1),
|
||||
MUX_INFO(0x47, 1),
|
||||
};
|
||||
|
||||
static struct pca954x_platform_data pca9548sfp5_data = {
|
||||
.modes = pca9548sfp5_modes,
|
||||
.num_modes = 8,
|
||||
};
|
||||
|
||||
static struct pca954x_platform_mode pca9548sfp6_modes[] = {
|
||||
MUX_INFO(0x48, 1),
|
||||
MUX_INFO(0x49, 1),
|
||||
MUX_INFO(0x4a, 1),
|
||||
MUX_INFO(0x4b, 1),
|
||||
MUX_INFO(0x4c, 1),
|
||||
MUX_INFO(0x4d, 1),
|
||||
MUX_INFO(0x4e, 1),
|
||||
MUX_INFO(0x4f, 1),
|
||||
};
|
||||
|
||||
static struct pca954x_platform_data pca9548sfp6_data = {
|
||||
.modes = pca9548sfp6_modes,
|
||||
.num_modes = 8,
|
||||
};
|
||||
|
||||
//ZQSFP
|
||||
static struct pca954x_platform_mode pca9548sfp7_modes[] = {
|
||||
MUX_INFO(0x50, 1),
|
||||
MUX_INFO(0x51, 1),
|
||||
MUX_INFO(0x52, 1),
|
||||
MUX_INFO(0x53, 1),
|
||||
MUX_INFO(0x54, 1),
|
||||
MUX_INFO(0x55, 1),
|
||||
MUX_INFO(0x56, 1),
|
||||
MUX_INFO(0x57, 1),
|
||||
};
|
||||
|
||||
static struct pca954x_platform_data pca9548sfp7_data = {
|
||||
.modes = pca9548sfp7_modes,
|
||||
.num_modes = 8,
|
||||
};
|
||||
|
||||
// end port
|
||||
|
||||
static struct pca954x_platform_mode pca9546_modes[] = {
|
||||
MUX_INFO(0x10, 1),
|
||||
MUX_INFO(0x11, 1),
|
||||
MUX_INFO(0x12, 1),
|
||||
MUX_INFO(0x13, 1),
|
||||
};
|
||||
|
||||
static struct pca954x_platform_data pca9546_data = {
|
||||
.modes = pca9546_modes,
|
||||
.num_modes = 4,
|
||||
};
|
||||
|
||||
static struct pca954x_platform_mode pca9548_modes[] = {
|
||||
MUX_INFO(0x14, 1),
|
||||
MUX_INFO(0x15, 1),
|
||||
MUX_INFO(0x16, 1),
|
||||
MUX_INFO(0x17, 1),
|
||||
MUX_INFO(0x18, 1),
|
||||
MUX_INFO(0x19, 1),
|
||||
MUX_INFO(0x1a, 1),
|
||||
MUX_INFO(0x1b, 1),
|
||||
};
|
||||
|
||||
static struct pca954x_platform_data pca9548_data = {
|
||||
.modes = pca9548_modes,
|
||||
.num_modes = 8,
|
||||
};
|
||||
|
||||
//MB Board Data
|
||||
static struct pca953x_platform_data pca9555_1_data = {
|
||||
.gpio_base = 0x10,
|
||||
};
|
||||
//QSFP28 49-56 IO Expander
|
||||
static struct pca953x_platform_data pca9698_2_data = {
|
||||
.gpio_base = 0x20,
|
||||
};
|
||||
//CPU Linking Board at CPU's I2C Bus
|
||||
static struct pca953x_platform_data pca9555_CPU_data = {
|
||||
.gpio_base = 0x48,
|
||||
};
|
||||
static struct i2c_board_info ix8c_i2c_devices[] = {
|
||||
{
|
||||
I2C_BOARD_INFO("pca9546", 0x72), // 0
|
||||
.platform_data = &pca9546_data,
|
||||
},
|
||||
{
|
||||
I2C_BOARD_INFO("pca9548", 0x77), // 1
|
||||
.platform_data = &pca9548_data,
|
||||
},
|
||||
{
|
||||
I2C_BOARD_INFO("24c02", 0x54), // 2 eeprom
|
||||
},
|
||||
{
|
||||
I2C_BOARD_INFO("pca9548", 0x73), // 3 0x77 ch0
|
||||
.platform_data = &pca9548sfp1_data,
|
||||
},
|
||||
{
|
||||
I2C_BOARD_INFO("pca9548", 0x73), // 4 0x77 ch1
|
||||
.platform_data = &pca9548sfp2_data,
|
||||
},
|
||||
{
|
||||
I2C_BOARD_INFO("pca9548", 0x73), // 5 0x77 ch2
|
||||
.platform_data = &pca9548sfp3_data,
|
||||
},
|
||||
{
|
||||
I2C_BOARD_INFO("pca9548", 0x73), // 6 0x77 ch3
|
||||
.platform_data = &pca9548sfp4_data,
|
||||
},
|
||||
{
|
||||
I2C_BOARD_INFO("pca9548", 0x73), // 7 0x77 ch4
|
||||
.platform_data = &pca9548sfp5_data,
|
||||
},
|
||||
{
|
||||
I2C_BOARD_INFO("pca9548", 0x73), // 8 0x77 ch5
|
||||
.platform_data = &pca9548sfp6_data,
|
||||
},
|
||||
{
|
||||
I2C_BOARD_INFO("pca9548", 0x73), // 9 0x77 ch6
|
||||
.platform_data = &pca9548sfp7_data,
|
||||
},
|
||||
{
|
||||
I2C_BOARD_INFO("CPLD-SFP28", 0x38), // 10 0x72 ch0 CPLD1_:SFP28 1~16
|
||||
},
|
||||
{
|
||||
I2C_BOARD_INFO("CPLD-SFP28", 0x38), // 11 0x72 ch1 CPLD2_:SFP28 17~32
|
||||
},
|
||||
{
|
||||
I2C_BOARD_INFO("CPLD-SFP28", 0x38), // 12 0x72 ch2 CPLD_3:SFP28 33~48
|
||||
},
|
||||
{
|
||||
I2C_BOARD_INFO("pca9555", 0x23), // 13 0x72 ch3 MB Board Data
|
||||
.platform_data = &pca9555_1_data,
|
||||
},
|
||||
{
|
||||
I2C_BOARD_INFO("pca9698", 0x21), // 14 0x72 ch3 QSFP:49~52
|
||||
.platform_data = &pca9698_2_data,
|
||||
},
|
||||
{
|
||||
I2C_BOARD_INFO("optoe1", 0x50), // 15 0x50 QSFP EEPROM
|
||||
},
|
||||
{
|
||||
I2C_BOARD_INFO("pca9555", 0x22), // 16 CPU Linking Board at CPU's I2C Bus
|
||||
.platform_data = &pca9555_CPU_data,
|
||||
},
|
||||
{
|
||||
I2C_BOARD_INFO("CPLDLED_IX8C", 0x3a), // 17 0x72 ch0 CPLD4 LED function of SFP28 & QSFP28 (Port27~56)
|
||||
},
|
||||
{
|
||||
I2C_BOARD_INFO("CPLDLED_IX8C", 0x39), // 18 0x72 ch0 CPLD6 LED function of SFP28 & QSFP28 (Port1~26)
|
||||
},
|
||||
{
|
||||
I2C_BOARD_INFO("optoe2", 0x50), // 19 0x50 SFP28 EEPROM
|
||||
},
|
||||
};
|
||||
|
||||
static struct platform_driver ix8c_platform_driver = {
|
||||
.driver = {
|
||||
.name = "qci-ix8c",
|
||||
.owner = THIS_MODULE,
|
||||
},
|
||||
};
|
||||
|
||||
static struct platform_device *ix8c_device;
|
||||
|
||||
static int __init ix8c_platform_init(void)
|
||||
{
|
||||
struct i2c_client *client;
|
||||
struct i2c_adapter *adapter;
|
||||
int ret, i;
|
||||
|
||||
ret = platform_driver_register(&ix8c_platform_driver);
|
||||
if (ret < 0)
|
||||
return ret;
|
||||
|
||||
/* Register platform stuff */
|
||||
ix8c_device = platform_device_alloc("qci-ix8c", -1);
|
||||
if (!ix8c_device) {
|
||||
ret = -ENOMEM;
|
||||
goto fail_platform_driver;
|
||||
}
|
||||
|
||||
ret = platform_device_add(ix8c_device);
|
||||
if (ret)
|
||||
goto fail_platform_device;
|
||||
|
||||
adapter = i2c_get_adapter(0);
|
||||
client = i2c_new_device(adapter, &ix8c_i2c_devices[0]); // pca9546
|
||||
client = i2c_new_device(adapter, &ix8c_i2c_devices[1]); // pca9548
|
||||
client = i2c_new_device(adapter, &ix8c_i2c_devices[16]); // CPU Linking Board at CPU's I2C Bus
|
||||
i2c_put_adapter(adapter);
|
||||
|
||||
adapter = i2c_get_adapter(0x10);
|
||||
client = i2c_new_device(adapter, &ix8c_i2c_devices[10]); // CPLD_1
|
||||
client = i2c_new_device(adapter, &ix8c_i2c_devices[17]); // CPLD_4
|
||||
client = i2c_new_device(adapter, &ix8c_i2c_devices[18]); // CPLD_6
|
||||
i2c_put_adapter(adapter);
|
||||
|
||||
adapter = i2c_get_adapter(0x11);
|
||||
client = i2c_new_device(adapter, &ix8c_i2c_devices[11]); // CPLD_2
|
||||
i2c_put_adapter(adapter);
|
||||
|
||||
adapter = i2c_get_adapter(0x12);
|
||||
client = i2c_new_device(adapter, &ix8c_i2c_devices[12]); // CPLD_3
|
||||
client = i2c_new_device(adapter, &ix8c_i2c_devices[2]); // MB_BOARDINFO_EEPROM
|
||||
i2c_put_adapter(adapter);
|
||||
|
||||
adapter = i2c_get_adapter(0x13);
|
||||
client = i2c_new_device(adapter, &ix8c_i2c_devices[13]); // MB Board Data
|
||||
client = i2c_new_device(adapter, &ix8c_i2c_devices[14]); // QSFP:49~52
|
||||
i2c_put_adapter(adapter);
|
||||
|
||||
adapter = i2c_get_adapter(0x14);
|
||||
client = i2c_new_device(adapter, &ix8c_i2c_devices[3]); // pca9548_1 SFP
|
||||
i2c_put_adapter(adapter);
|
||||
|
||||
adapter = i2c_get_adapter(0x15);
|
||||
client = i2c_new_device(adapter, &ix8c_i2c_devices[4]); // pca9548_2 SFP
|
||||
i2c_put_adapter(adapter);
|
||||
|
||||
adapter = i2c_get_adapter(0x16);
|
||||
client = i2c_new_device(adapter, &ix8c_i2c_devices[5]); // pca9548_3 SFP
|
||||
i2c_put_adapter(adapter);
|
||||
|
||||
adapter = i2c_get_adapter(0x17);
|
||||
client = i2c_new_device(adapter, &ix8c_i2c_devices[6]); // pca9548_4 SFP
|
||||
i2c_put_adapter(adapter);
|
||||
|
||||
adapter = i2c_get_adapter(0x18);
|
||||
client = i2c_new_device(adapter, &ix8c_i2c_devices[7]); // pca9548_5 SFP
|
||||
i2c_put_adapter(adapter);
|
||||
|
||||
adapter = i2c_get_adapter(0x19);
|
||||
client = i2c_new_device(adapter, &ix8c_i2c_devices[8]); // pca9548_6 SFP
|
||||
i2c_put_adapter(adapter);
|
||||
|
||||
adapter = i2c_get_adapter(0x1a);
|
||||
client = i2c_new_device(adapter, &ix8c_i2c_devices[9]); // pca9548_7 QSFP
|
||||
i2c_put_adapter(adapter);
|
||||
|
||||
for(i = 80; i < 88; i ++){ // QSFP 49~56 EEPROM
|
||||
adapter = i2c_get_adapter(i);
|
||||
client = i2c_new_device(adapter, &ix8c_i2c_devices[15]);
|
||||
i2c_put_adapter(adapter);
|
||||
}
|
||||
|
||||
for(i = 32; i < 80; i ++){ // SFP28 1~48 EEPROM
|
||||
adapter = i2c_get_adapter(i);
|
||||
client = i2c_new_device(adapter, &ix8c_i2c_devices[19]);
|
||||
i2c_put_adapter(adapter);
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
fail_platform_device:
|
||||
platform_device_put(ix8c_device);
|
||||
|
||||
fail_platform_driver:
|
||||
platform_driver_unregister(&ix8c_platform_driver);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void __exit ix8c_platform_exit(void)
|
||||
{
|
||||
platform_device_unregister(ix8c_device);
|
||||
platform_driver_unregister(&ix8c_platform_driver);
|
||||
}
|
||||
|
||||
module_init(ix8c_platform_init);
|
||||
module_exit(ix8c_platform_exit);
|
||||
|
||||
|
||||
MODULE_AUTHOR("Jonathan Tsai <jonathan.tsai@quantatw.com>");
|
||||
MODULE_VERSION("1.0");
|
||||
MODULE_DESCRIPTION("Quanta IX8C Platform Driver");
|
||||
MODULE_LICENSE("GPL");
|
@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=Quanta IX8C-56X Platform initialization service
|
||||
Before=pmon.service
|
||||
DefaultDependencies=no
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=/usr/local/bin/quanta_ix8c_util.py install
|
||||
ExecStop=/usr/local/bin/quanta_ix8c_util.py clean
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import sys
|
||||
from setuptools import setup
|
||||
os.listdir
|
||||
|
||||
setup(
|
||||
name='ix8c_56x',
|
||||
version='1.0',
|
||||
description='Module to initialize Quanta IX8C-56X platforms',
|
||||
|
||||
packages=['ix8c_56x'],
|
||||
package_dir={'ix8c_56x': 'ix8c-56x/classes'},
|
||||
)
|
||||
|
@ -0,0 +1,329 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (C) 2018 Quanta Computer Inc.
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""
|
||||
Usage: %(scriptName)s [options] command object
|
||||
|
||||
options:
|
||||
-h | --help : this help message
|
||||
-d | --debug : run with debug mode
|
||||
-f | --force : ignore error during installation or clean
|
||||
command:
|
||||
install : install drivers and generate related sysfs nodes
|
||||
clean : uninstall drivers and remove related sysfs nodes
|
||||
"""
|
||||
|
||||
import os
|
||||
import commands
|
||||
import sys, getopt
|
||||
import logging
|
||||
import re
|
||||
import time
|
||||
from collections import namedtuple
|
||||
|
||||
DEBUG = False
|
||||
args = []
|
||||
FORCE = 0
|
||||
i2c_prefix = '/sys/bus/i2c/devices/'
|
||||
|
||||
|
||||
if DEBUG == True:
|
||||
print sys.argv[0]
|
||||
print 'ARGV :', sys.argv[1:]
|
||||
|
||||
|
||||
def main():
|
||||
global DEBUG
|
||||
global args
|
||||
global FORCE
|
||||
|
||||
if len(sys.argv)<2:
|
||||
show_help()
|
||||
|
||||
options, args = getopt.getopt(sys.argv[1:], 'hdf', ['help',
|
||||
'debug',
|
||||
'force',
|
||||
])
|
||||
if DEBUG == True:
|
||||
print options
|
||||
print args
|
||||
print len(sys.argv)
|
||||
|
||||
for opt, arg in options:
|
||||
if opt in ('-h', '--help'):
|
||||
show_help()
|
||||
elif opt in ('-d', '--debug'):
|
||||
DEBUG = True
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
elif opt in ('-f', '--force'):
|
||||
FORCE = 1
|
||||
else:
|
||||
logging.info('no option')
|
||||
for arg in args:
|
||||
if arg == 'install':
|
||||
install()
|
||||
elif arg == 'clean':
|
||||
uninstall()
|
||||
else:
|
||||
show_help()
|
||||
|
||||
|
||||
return 0
|
||||
|
||||
def show_help():
|
||||
print __doc__ % {'scriptName' : sys.argv[0].split("/")[-1]}
|
||||
sys.exit(0)
|
||||
|
||||
def show_log(txt):
|
||||
if DEBUG == True:
|
||||
print "[IX8C-56X]"+txt
|
||||
return
|
||||
|
||||
def exec_cmd(cmd, show):
|
||||
logging.info('Run :'+cmd)
|
||||
status, output = commands.getstatusoutput(cmd)
|
||||
show_log (cmd +"with result:" + str(status))
|
||||
show_log (" output:"+output)
|
||||
if status:
|
||||
logging.info('Failed :'+cmd)
|
||||
if show:
|
||||
print('Failed :'+cmd)
|
||||
return status, output
|
||||
|
||||
instantiate =[
|
||||
#turn on module power
|
||||
'echo 21 > /sys/class/gpio/export',
|
||||
'echo out > /sys/class/gpio/gpio21/direction',
|
||||
'echo 1 >/sys/class/gpio/gpio21/value',
|
||||
#export pca9698 for qsfp present
|
||||
'echo 34 > /sys/class/gpio/export',
|
||||
'echo in > /sys/class/gpio/gpio34/direction',
|
||||
'echo 38 > /sys/class/gpio/export',
|
||||
'echo in > /sys/class/gpio/gpio38/direction',
|
||||
'echo 42 > /sys/class/gpio/export',
|
||||
'echo in > /sys/class/gpio/gpio42/direction',
|
||||
'echo 46 > /sys/class/gpio/export',
|
||||
'echo in > /sys/class/gpio/gpio46/direction',
|
||||
'echo 50 > /sys/class/gpio/export',
|
||||
'echo in > /sys/class/gpio/gpio50/direction',
|
||||
'echo 54 > /sys/class/gpio/export',
|
||||
'echo in > /sys/class/gpio/gpio54/direction',
|
||||
'echo 58 > /sys/class/gpio/export',
|
||||
'echo in > /sys/class/gpio/gpio58/direction',
|
||||
'echo 62 > /sys/class/gpio/export',
|
||||
'echo in > /sys/class/gpio/gpio62/direction',
|
||||
#export pca9698 for qsfp reset
|
||||
'echo 32 > /sys/class/gpio/export',
|
||||
'echo out > /sys/class/gpio/gpio32/direction',
|
||||
'echo 1 >/sys/class/gpio/gpio32/value',
|
||||
'echo 36 > /sys/class/gpio/export',
|
||||
'echo out > /sys/class/gpio/gpio36/direction',
|
||||
'echo 1 >/sys/class/gpio/gpio36/value',
|
||||
'echo 40 > /sys/class/gpio/export',
|
||||
'echo out > /sys/class/gpio/gpio40/direction',
|
||||
'echo 1 >/sys/class/gpio/gpio40/value',
|
||||
'echo 44 > /sys/class/gpio/export',
|
||||
'echo out > /sys/class/gpio/gpio44/direction',
|
||||
'echo 1 >/sys/class/gpio/gpio44/value',
|
||||
'echo 48 > /sys/class/gpio/export',
|
||||
'echo out > /sys/class/gpio/gpio48/direction',
|
||||
'echo 1 >/sys/class/gpio/gpio48/value',
|
||||
'echo 52 > /sys/class/gpio/export',
|
||||
'echo out > /sys/class/gpio/gpio52/direction',
|
||||
'echo 1 >/sys/class/gpio/gpio52/value',
|
||||
'echo 56 > /sys/class/gpio/export',
|
||||
'echo out > /sys/class/gpio/gpio56/direction',
|
||||
'echo 1 >/sys/class/gpio/gpio56/value',
|
||||
'echo 60 > /sys/class/gpio/export',
|
||||
'echo out > /sys/class/gpio/gpio60/direction',
|
||||
'echo 1 >/sys/class/gpio/gpio60/value',
|
||||
#export pca9698 for qsfp lpmode
|
||||
'echo 35 > /sys/class/gpio/export',
|
||||
'echo out > /sys/class/gpio/gpio35/direction',
|
||||
'echo 0 >/sys/class/gpio/gpio35/value',
|
||||
'echo 39 > /sys/class/gpio/export',
|
||||
'echo out > /sys/class/gpio/gpio39/direction',
|
||||
'echo 0 >/sys/class/gpio/gpio39/value',
|
||||
'echo 43 > /sys/class/gpio/export',
|
||||
'echo out > /sys/class/gpio/gpio43/direction',
|
||||
'echo 0 >/sys/class/gpio/gpio43/value',
|
||||
'echo 47 > /sys/class/gpio/export',
|
||||
'echo out > /sys/class/gpio/gpio47/direction',
|
||||
'echo 0 >/sys/class/gpio/gpio47/value',
|
||||
'echo 51 > /sys/class/gpio/export',
|
||||
'echo out > /sys/class/gpio/gpio51/direction',
|
||||
'echo 0 >/sys/class/gpio/gpio51/value',
|
||||
'echo 55 > /sys/class/gpio/export',
|
||||
'echo out > /sys/class/gpio/gpio55/direction',
|
||||
'echo 0 >/sys/class/gpio/gpio55/value',
|
||||
'echo 59 > /sys/class/gpio/export',
|
||||
'echo out > /sys/class/gpio/gpio59/direction',
|
||||
'echo 0 >/sys/class/gpio/gpio59/value',
|
||||
'echo 63 > /sys/class/gpio/export',
|
||||
'echo out > /sys/class/gpio/gpio63/direction',
|
||||
'echo 0 >/sys/class/gpio/gpio63/value',
|
||||
#Reset fron-ports LED CPLD
|
||||
'echo 73 > /sys/class/gpio/export',
|
||||
'echo out > /sys/class/gpio/gpio73/direction',
|
||||
'echo 0 >/sys/class/gpio/gpio73/value',
|
||||
'echo 1 >/sys/class/gpio/gpio73/value',
|
||||
#Enable front-ports LED decoding
|
||||
'echo 1 > /sys/class/cpld-led/CPLDLED-1/led_decode',
|
||||
'echo 1 > /sys/class/cpld-led/CPLDLED-2/led_decode',
|
||||
#SFP28 Module TxEnable
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-1/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-2/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-3/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-4/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-5/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-6/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-7/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-8/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-9/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-10/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-11/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-12/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-13/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-14/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-15/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-16/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-17/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-18/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-19/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-20/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-21/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-22/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-23/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-24/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-25/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-26/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-27/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-28/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-29/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-30/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-31/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-32/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-33/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-34/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-35/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-36/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-37/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-38/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-39/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-40/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-41/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-42/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-43/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-44/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-45/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-46/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-47/tx_dis',
|
||||
'echo 0 > /sys/class/cpld-sfp28/port-48/tx_dis'
|
||||
]
|
||||
|
||||
drivers =[
|
||||
'lpc_ich',
|
||||
'i2c-i801',
|
||||
'i2c-dev',
|
||||
'i2c-mux-pca954x',
|
||||
'gpio-pca953x',
|
||||
'optoe',
|
||||
'qci_cpld_sfp28',
|
||||
'qci_cpld_led',
|
||||
'qci_platform_ix8c',
|
||||
'ipmi_devintf'
|
||||
]
|
||||
|
||||
|
||||
|
||||
def system_install():
|
||||
global FORCE
|
||||
|
||||
#remove default drivers to avoid modprobe order conflicts
|
||||
status, output = exec_cmd("rmmod i2c_ismt ", 1)
|
||||
status, output = exec_cmd("rmmod i2c-i801 ", 1)
|
||||
#setup driver dependency
|
||||
status, output = exec_cmd("depmod -a ", 1)
|
||||
#install drivers
|
||||
for i in range(0,len(drivers)):
|
||||
status, output = exec_cmd("modprobe "+drivers[i], 1)
|
||||
if status:
|
||||
print output
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
#remove net rules for generating new net rules
|
||||
status, output = exec_cmd("systemctl stop systemd-udevd.service ", 1)
|
||||
status, output = exec_cmd("rm /etc/udev/rules.d/70-persistent-net.rules ", 1)
|
||||
status, output = exec_cmd("rmmod ixgbe ", 1)
|
||||
status, output = exec_cmd("rmmod igb ", 1)
|
||||
status, output = exec_cmd("modprobe igb ", 1)
|
||||
status, output = exec_cmd("modprobe ixgbe ", 1)
|
||||
status, output = exec_cmd("systemctl start systemd-udevd.service ", 1)
|
||||
|
||||
#instantiate devices
|
||||
for i in range(0,len(instantiate)):
|
||||
status, output = exec_cmd(instantiate[i], 1)
|
||||
if status:
|
||||
print output
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
#QSFP for 1~56 port
|
||||
for port_number in range(1,57):
|
||||
bus_number = port_number + 31
|
||||
os.system("echo %d >/sys/bus/i2c/devices/%d-0050/port_name" % (port_number, bus_number))
|
||||
|
||||
return
|
||||
|
||||
|
||||
def system_ready():
|
||||
if not device_found():
|
||||
return False
|
||||
return True
|
||||
|
||||
def install():
|
||||
if not device_found():
|
||||
print "No device, installing...."
|
||||
status = system_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print " ix8c driver already installed...."
|
||||
return
|
||||
|
||||
def uninstall():
|
||||
global FORCE
|
||||
#uninstall drivers
|
||||
for i in range(len(drivers)-1,-1,-1):
|
||||
status, output = exec_cmd("rmmod "+drivers[i], 1)
|
||||
if status:
|
||||
print output
|
||||
if FORCE == 0:
|
||||
return status
|
||||
return
|
||||
|
||||
def device_found():
|
||||
ret1, log = exec_cmd("ls "+i2c_prefix+"i2c-0", 0)
|
||||
return ret1
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user