[device][platform] Update Inventec platform porting to support stretch (#2010)
* [device][platform] d6254qs d6556 platform porting [device][platform] sensor and status led support for d7032q28b d7254q28b d7264q28b d6254qs d6556 [device][platform] qos support for d7032q28b d7254q28b [device][platform] service configuration files for d7032q28b d7254q28b d7264q28b d6254qs d6556 * remove binary files and remove non-supported attributes in config.bcm * remove gpio-ich here. file a PR in sonic-linux-kernel instead. * remove unnecessary comments * add GPL license
This commit is contained in:
parent
0c2472a040
commit
6f496bda20
@ -0,0 +1,74 @@
|
||||
# name lanes alias
|
||||
Ethernet0 16 Ethernet0
|
||||
Ethernet4 15 Ethernet4
|
||||
Ethernet8 14 Ethernet8
|
||||
Ethernet12 13 Ethernet12
|
||||
Ethernet16 24 Ethernet16
|
||||
Ethernet20 23 Ethernet20
|
||||
Ethernet24 22 Ethernet24
|
||||
Ethernet28 21 Ethernet28
|
||||
Ethernet32 28 Ethernet32
|
||||
Ethernet36 27 Ethernet36
|
||||
Ethernet40 26 Ethernet40
|
||||
Ethernet44 25 Ethernet44
|
||||
Ethernet48 32 Ethernet48
|
||||
Ethernet52 31 Ethernet52
|
||||
Ethernet56 30 Ethernet56
|
||||
Ethernet60 29 Ethernet60
|
||||
Ethernet64 48 Ethernet64
|
||||
Ethernet68 47 Ethernet68
|
||||
Ethernet72 46 Ethernet72
|
||||
Ethernet76 45 Ethernet76
|
||||
Ethernet80 52 Ethernet80
|
||||
Ethernet84 51 Ethernet84
|
||||
Ethernet88 50 Ethernet88
|
||||
Ethernet92 49 Ethernet92
|
||||
Ethernet96 56 Ethernet96
|
||||
Ethernet100 55 Ethernet100
|
||||
Ethernet104 54 Ethernet104
|
||||
Ethernet108 53 Ethernet108
|
||||
Ethernet112 60 Ethernet112
|
||||
Ethernet116 59 Ethernet116
|
||||
Ethernet120 58 Ethernet120
|
||||
Ethernet124 57 Ethernet124
|
||||
Ethernet128 64 Ethernet128
|
||||
Ethernet132 63 Ethernet132
|
||||
Ethernet136 62 Ethernet136
|
||||
Ethernet140 61 Ethernet140
|
||||
Ethernet144 68 Ethernet144
|
||||
Ethernet148 67 Ethernet148
|
||||
Ethernet152 66 Ethernet152
|
||||
Ethernet156 65 Ethernet156
|
||||
Ethernet160 72 Ethernet160
|
||||
Ethernet164 71 Ethernet164
|
||||
Ethernet168 70 Ethernet168
|
||||
Ethernet172 69 Ethernet172
|
||||
Ethernet176 76 Ethernet176
|
||||
Ethernet180 75 Ethernet180
|
||||
Ethernet184 74 Ethernet184
|
||||
Ethernet188 73 Ethernet188
|
||||
Ethernet192 82 Ethernet192
|
||||
Ethernet196 84 Ethernet196
|
||||
Ethernet200 81 Ethernet200
|
||||
Ethernet204 83 Ethernet204
|
||||
Ethernet208 78 Ethernet208
|
||||
Ethernet212 80 Ethernet212
|
||||
Ethernet216 77 Ethernet216
|
||||
Ethernet220 79 Ethernet220
|
||||
Ethernet224 98 Ethernet224
|
||||
Ethernet228 100 Ethernet228
|
||||
Ethernet232 97 Ethernet232
|
||||
Ethernet236 99 Ethernet236
|
||||
Ethernet240 104 Ethernet240
|
||||
Ethernet244 102 Ethernet244
|
||||
Ethernet248 103 Ethernet248
|
||||
Ethernet252 101 Ethernet252
|
||||
Ethernet256 108 Ethernet256
|
||||
Ethernet260 106 Ethernet260
|
||||
Ethernet264 107 Ethernet264
|
||||
Ethernet268 105 Ethernet268
|
||||
Ethernet272 112 Ethernet272
|
||||
Ethernet276 110 Ethernet276
|
||||
Ethernet280 111 Ethernet280
|
||||
Ethernet284 109 Ethernet284
|
||||
|
@ -0,0 +1,2 @@
|
||||
SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/td2-d6254qs-72x10G.config
|
||||
SAI_NUM_ECMP_MEMBERS=32
|
@ -0,0 +1,160 @@
|
||||
os=unix
|
||||
parity_enable=0
|
||||
pbmp_xport_xe.0=0x1fffffffffffffffffffffffffffffffe
|
||||
miim_intr_enable=0
|
||||
schan_intr_enable=0
|
||||
bcm_stat_interval=2000000
|
||||
serdes_firmware_mode_xe=0x2
|
||||
|
||||
portmap_1=16:10
|
||||
portmap_2=15:10
|
||||
portmap_3=14:10
|
||||
portmap_4=13:10
|
||||
portmap_5=24:10
|
||||
portmap_6=23:10
|
||||
portmap_7=22:10
|
||||
portmap_8=21:10
|
||||
portmap_9=28:10
|
||||
portmap_10=27:10
|
||||
portmap_11=26:10
|
||||
portmap_12=25:10
|
||||
portmap_13=32:10
|
||||
portmap_14=31:10
|
||||
portmap_15=30:10
|
||||
portmap_16=29:10
|
||||
portmap_17=48:10
|
||||
portmap_18=47:10
|
||||
portmap_19=46:10
|
||||
portmap_20=45:10
|
||||
portmap_21=52:10
|
||||
portmap_22=51:10
|
||||
portmap_23=50:10
|
||||
portmap_24=49:10
|
||||
portmap_25=56:10
|
||||
portmap_26=55:10
|
||||
portmap_27=54:10
|
||||
portmap_28=53:10
|
||||
portmap_29=60:10
|
||||
portmap_30=59:10
|
||||
portmap_31=58:10
|
||||
portmap_32=57:10
|
||||
portmap_33=64:10
|
||||
portmap_34=63:10
|
||||
portmap_35=62:10
|
||||
portmap_36=61:10
|
||||
portmap_37=68:10
|
||||
portmap_38=67:10
|
||||
portmap_39=66:10
|
||||
portmap_40=65:10
|
||||
portmap_41=72:10
|
||||
portmap_42=71:10
|
||||
portmap_43=70:10
|
||||
portmap_44=69:10
|
||||
portmap_45=76:10
|
||||
portmap_46=75:10
|
||||
portmap_47=74:10
|
||||
portmap_48=73:10
|
||||
|
||||
portmap_49=82:10
|
||||
portmap_50=84:10
|
||||
portmap_51=81:10
|
||||
portmap_52=83:10
|
||||
|
||||
portmap_53=78:10
|
||||
portmap_54=80:10
|
||||
portmap_55=77:10
|
||||
portmap_56=79:10
|
||||
|
||||
portmap_57=98:10
|
||||
portmap_58=100:10
|
||||
portmap_59=97:10
|
||||
portmap_60=99:10
|
||||
|
||||
portmap_61=104:10
|
||||
portmap_62=102:10
|
||||
portmap_63=103:10
|
||||
portmap_64=101:10
|
||||
|
||||
portmap_65=108:10
|
||||
portmap_66=106:10
|
||||
portmap_67=107:10
|
||||
portmap_68=105:10
|
||||
|
||||
portmap_69=112:10
|
||||
portmap_70=110:10
|
||||
portmap_71=111:10
|
||||
portmap_72=109:10
|
||||
|
||||
xgxs_rx_lane_map_xe0=0x0123
|
||||
xgxs_rx_lane_map_xe1=0x0123
|
||||
xgxs_rx_lane_map_xe2=0x0123
|
||||
xgxs_rx_lane_map_xe3=0x0123
|
||||
xgxs_rx_lane_map_xe4=0x0123
|
||||
xgxs_rx_lane_map_xe5=0x0123
|
||||
xgxs_rx_lane_map_xe6=0x0123
|
||||
xgxs_rx_lane_map_xe7=0x0123
|
||||
xgxs_rx_lane_map_xe8=0x0123
|
||||
xgxs_rx_lane_map_xe9=0x0123
|
||||
xgxs_rx_lane_map_xe10=0x0123
|
||||
xgxs_rx_lane_map_xe11=0x0123
|
||||
xgxs_rx_lane_map_xe12=0x0123
|
||||
xgxs_rx_lane_map_xe13=0x0123
|
||||
xgxs_rx_lane_map_xe14=0x0123
|
||||
xgxs_rx_lane_map_xe15=0x0123
|
||||
xgxs_rx_lane_map_xe16=0x0123
|
||||
xgxs_rx_lane_map_xe17=0x0123
|
||||
xgxs_rx_lane_map_xe18=0x0123
|
||||
xgxs_rx_lane_map_xe19=0x0123
|
||||
xgxs_rx_lane_map_xe20=0x0123
|
||||
xgxs_rx_lane_map_xe21=0x0123
|
||||
xgxs_rx_lane_map_xe22=0x0123
|
||||
xgxs_rx_lane_map_xe23=0x0123
|
||||
xgxs_rx_lane_map_xe24=0x0123
|
||||
xgxs_rx_lane_map_xe25=0x0123
|
||||
xgxs_rx_lane_map_xe26=0x0123
|
||||
xgxs_rx_lane_map_xe27=0x0123
|
||||
xgxs_rx_lane_map_xe28=0x0123
|
||||
xgxs_rx_lane_map_xe29=0x0123
|
||||
xgxs_rx_lane_map_xe30=0x0123
|
||||
xgxs_rx_lane_map_xe31=0x0123
|
||||
xgxs_rx_lane_map_xe32=0x0123
|
||||
xgxs_rx_lane_map_xe33=0x0123
|
||||
xgxs_rx_lane_map_xe34=0x0123
|
||||
xgxs_rx_lane_map_xe35=0x0123
|
||||
xgxs_rx_lane_map_xe36=0x0123
|
||||
xgxs_rx_lane_map_xe37=0x0123
|
||||
xgxs_rx_lane_map_xe38=0x0123
|
||||
xgxs_rx_lane_map_xe39=0x0123
|
||||
xgxs_rx_lane_map_xe40=0x0123
|
||||
xgxs_rx_lane_map_xe41=0x0123
|
||||
xgxs_rx_lane_map_xe42=0x0123
|
||||
xgxs_rx_lane_map_xe43=0x0123
|
||||
xgxs_rx_lane_map_xe44=0x0123
|
||||
xgxs_rx_lane_map_xe45=0x0123
|
||||
xgxs_rx_lane_map_xe46=0x0123
|
||||
xgxs_rx_lane_map_xe47=0x0123
|
||||
xgxs_rx_lane_map_xe48=0x0123
|
||||
xgxs_rx_lane_map_xe49=0x0123
|
||||
xgxs_rx_lane_map_xe50=0x0123
|
||||
xgxs_rx_lane_map_xe51=0x0123
|
||||
xgxs_rx_lane_map_xe52=0x0123
|
||||
xgxs_rx_lane_map_xe53=0x0123
|
||||
xgxs_rx_lane_map_xe54=0x0123
|
||||
xgxs_rx_lane_map_xe55=0x0123
|
||||
xgxs_rx_lane_map_xe56=0x0123
|
||||
xgxs_rx_lane_map_xe57=0x0123
|
||||
xgxs_rx_lane_map_xe58=0x0123
|
||||
xgxs_rx_lane_map_xe59=0x0123
|
||||
xgxs_rx_lane_map_xe60=0x0123
|
||||
xgxs_rx_lane_map_xe61=0x0123
|
||||
xgxs_rx_lane_map_xe62=0x0123
|
||||
xgxs_rx_lane_map_xe63=0x0123
|
||||
xgxs_rx_lane_map_xe64=0x0123
|
||||
xgxs_rx_lane_map_xe65=0x0123
|
||||
xgxs_rx_lane_map_xe66=0x0123
|
||||
xgxs_rx_lane_map_xe67=0x0123
|
||||
xgxs_rx_lane_map_xe68=0x0123
|
||||
xgxs_rx_lane_map_xe69=0x0123
|
||||
xgxs_rx_lane_map_xe70=0x0123
|
||||
xgxs_rx_lane_map_xe71=0x0123
|
||||
|
@ -0,0 +1,4 @@
|
||||
CONSOLE_PORT=0x2f8
|
||||
CONSOLE_DEV=1
|
||||
CONSOLE_SPEED=115200
|
||||
VAR_LOG_SIZE=1024
|
136
device/inventec/x86_64-inventec_d6254qs-r0/led_proc_init.soc
Normal file
136
device/inventec/x86_64-inventec_d6254qs-r0/led_proc_init.soc
Normal file
@ -0,0 +1,136 @@
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_0_3 REMAP_PORT_0=31
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_0_3 REMAP_PORT_1=30
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_0_3 REMAP_PORT_2=29
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_0_3 REMAP_PORT_3=28
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_4_7 REMAP_PORT_4=27
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_4_7 REMAP_PORT_5=26
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_4_7 REMAP_PORT_6=25
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_4_7 REMAP_PORT_7=24
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_8_11 REMAP_PORT_8=23
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_8_11 REMAP_PORT_9=22
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_8_11 REMAP_PORT_10=21
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_8_11 REMAP_PORT_11=20
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_12_15 REMAP_PORT_12=19
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_12_15 REMAP_PORT_13=18
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_12_15 REMAP_PORT_14=17
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_12_15 REMAP_PORT_15=16
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_16_19 REMAP_PORT_16=15
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_16_19 REMAP_PORT_17=14
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_16_19 REMAP_PORT_18=13
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_16_19 REMAP_PORT_19=12
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_20_23 REMAP_PORT_20=11
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_20_23 REMAP_PORT_21=10
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_20_23 REMAP_PORT_22=9
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_20_23 REMAP_PORT_23=8
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_24_27 REMAP_PORT_24=7
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_24_27 REMAP_PORT_25=6
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_24_27 REMAP_PORT_26=5
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_24_27 REMAP_PORT_27=4
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_28_31 REMAP_PORT_28=3
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_28_31 REMAP_PORT_29=2
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_28_31 REMAP_PORT_30=1
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_28_31 REMAP_PORT_31=0
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_32_35 REMAP_PORT_32=63
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_32_35 REMAP_PORT_33=62
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_32_35 REMAP_PORT_34=61
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_32_35 REMAP_PORT_35=60
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_36_39 REMAP_PORT_36=59
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_36_39 REMAP_PORT_37=58
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_36_39 REMAP_PORT_38=57
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_36_39 REMAP_PORT_39=56
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_40_43 REMAP_PORT_40=55
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_40_43 REMAP_PORT_41=54
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_40_43 REMAP_PORT_42=53
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_40_43 REMAP_PORT_43=52
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_44_47 REMAP_PORT_44=51
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_44_47 REMAP_PORT_45=50
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_44_47 REMAP_PORT_46=49
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_44_47 REMAP_PORT_47=48
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_48_51 REMAP_PORT_48=47
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_48_51 REMAP_PORT_49=46
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_48_51 REMAP_PORT_50=45
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_48_51 REMAP_PORT_51=44
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_52_55 REMAP_PORT_52=43
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_52_55 REMAP_PORT_53=42
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_52_55 REMAP_PORT_54=41
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_52_55 REMAP_PORT_55=40
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_56_59 REMAP_PORT_56=39
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_56_59 REMAP_PORT_57=38
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_56_59 REMAP_PORT_58=37
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_56_59 REMAP_PORT_59=36
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_60_63 REMAP_PORT_60=35
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_60_63 REMAP_PORT_61=34
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_60_63 REMAP_PORT_62=33
|
||||
m CMIC_LEDUP0_PORT_ORDER_REMAP_60_63 REMAP_PORT_63=32
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_0_3 REMAP_PORT_0=3
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_0_3 REMAP_PORT_1=2
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_0_3 REMAP_PORT_2=1
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_0_3 REMAP_PORT_3=0
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_4_7 REMAP_PORT_4=7
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_4_7 REMAP_PORT_5=6
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_4_7 REMAP_PORT_6=5
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_4_7 REMAP_PORT_7=4
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_8_11 REMAP_PORT_8=11
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_8_11 REMAP_PORT_9=10
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_8_11 REMAP_PORT_10=9
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_8_11 REMAP_PORT_11=8
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_12_15 REMAP_PORT_12=15
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_12_15 REMAP_PORT_13=14
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_12_15 REMAP_PORT_14=13
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_12_15 REMAP_PORT_15=12
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_16_19 REMAP_PORT_16=19
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_16_19 REMAP_PORT_17=18
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_16_19 REMAP_PORT_18=17
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_16_19 REMAP_PORT_19=16
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_20_23 REMAP_PORT_20=23
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_20_23 REMAP_PORT_21=22
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_20_23 REMAP_PORT_22=21
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_20_23 REMAP_PORT_23=20
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_24_27 REMAP_PORT_24=27
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_24_27 REMAP_PORT_25=26
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_24_27 REMAP_PORT_26=25
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_24_27 REMAP_PORT_27=24
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_28_31 REMAP_PORT_28=31
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_28_31 REMAP_PORT_29=30
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_28_31 REMAP_PORT_30=29
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_28_31 REMAP_PORT_31=28
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_32_35 REMAP_PORT_32=35
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_32_35 REMAP_PORT_33=34
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_32_35 REMAP_PORT_34=33
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_32_35 REMAP_PORT_35=32
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_36_39 REMAP_PORT_36=39
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_36_39 REMAP_PORT_37=38
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_36_39 REMAP_PORT_38=37
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_36_39 REMAP_PORT_39=36
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_40_43 REMAP_PORT_40=43
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_40_43 REMAP_PORT_41=42
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_40_43 REMAP_PORT_42=41
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_40_43 REMAP_PORT_43=40
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_44_47 REMAP_PORT_44=47
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_44_47 REMAP_PORT_45=46
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_44_47 REMAP_PORT_46=45
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_44_47 REMAP_PORT_47=44
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_48_51 REMAP_PORT_48=51
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_48_51 REMAP_PORT_49=50
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_48_51 REMAP_PORT_50=49
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_48_51 REMAP_PORT_51=48
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_52_55 REMAP_PORT_52=55
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_52_55 REMAP_PORT_53=54
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_52_55 REMAP_PORT_54=53
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_52_55 REMAP_PORT_55=52
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_56_59 REMAP_PORT_56=59
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_56_59 REMAP_PORT_57=58
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_56_59 REMAP_PORT_58=57
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_56_59 REMAP_PORT_59=56
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_60_63 REMAP_PORT_60=63
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_60_63 REMAP_PORT_61=62
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_60_63 REMAP_PORT_62=61
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_60_63 REMAP_PORT_63=60
|
||||
|
||||
led 0 stop
|
||||
led 0 prog 02 00 60 F1 12 00 DA 0F 70 10 67 47 67 42 77 06 02 A0 60 F0 12 00 06 F0 4A 04 27 67 42 4A 03 27 67 42 4A 07 27 67 42 4A 00 27 67 42 DA 80 70 34 86 F0 77 16 12 00 DA 03 70 40 67 4A 67 42 77 36 3E F1 87 86 F1 81 57 17 27 57 07 27 57
|
||||
led 0 start
|
||||
|
||||
led 1 stop
|
||||
led 1 prog 02 00 60 F1 12 00 DA 0F 70 10 67 47 67 42 77 06 02 A0 60 F0 12 00 06 F0 4A 04 27 67 42 4A 03 27 67 42 4A 07 27 67 42 4A 00 27 67 42 DA 80 70 34 86 F0 77 16 12 00 DA 03 70 40 67 4A 67 42 77 36 3E F1 87 86 F1 81 57 17 27 57 07 27 57
|
||||
led 1 start
|
144
device/inventec/x86_64-inventec_d6254qs-r0/minigraph.xml
Normal file
144
device/inventec/x86_64-inventec_d6254qs-r0/minigraph.xml
Normal file
@ -0,0 +1,144 @@
|
||||
<DeviceMiniGraph xmlns="Microsoft.Search.Autopilot.Evolution" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<CpgDec>
|
||||
<IsisRouters xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
|
||||
<PeeringSessions>
|
||||
<BGPSession>
|
||||
<StartRouter>OCPSCH0104001MS</StartRouter>
|
||||
<StartPeer>10.10.1.26</StartPeer>
|
||||
<EndRouter>SONiC-Inventec-d6254qs</EndRouter>
|
||||
<EndPeer>10.10.1.25</EndPeer>
|
||||
<Multihop>1</Multihop>
|
||||
<HoldTime>10</HoldTime>
|
||||
<KeepAliveTime>3</KeepAliveTime>
|
||||
</BGPSession>
|
||||
<BGPSession>
|
||||
<StartRouter>OCPSCH0104002MS</StartRouter>
|
||||
<StartPeer>10.10.2.26</StartPeer>
|
||||
<EndRouter>SONiC-Inventec-d6254qs</EndRouter>
|
||||
<EndPeer>10.10.2.25</EndPeer>
|
||||
<Multihop>1</Multihop>
|
||||
<HoldTime>10</HoldTime>
|
||||
<KeepAliveTime>3</KeepAliveTime>
|
||||
</BGPSession>
|
||||
</PeeringSessions>
|
||||
<Routers xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
|
||||
<a:BGPRouterDeclaration>
|
||||
<a:ASN>64536</a:ASN>
|
||||
<a:Hostname>SONiC-Inventec-d6254qs</a:Hostname>
|
||||
<a:Peers>
|
||||
<BGPPeer>
|
||||
<Address>10.10.1.26</Address>
|
||||
<RouteMapIn i:nil="true"/>
|
||||
<RouteMapOut i:nil="true"/>
|
||||
</BGPPeer>
|
||||
<BGPPeer>
|
||||
<Address>10.10.2.26</Address>
|
||||
<RouteMapIn i:nil="true"/>
|
||||
<RouteMapOut i:nil="true"/>
|
||||
</BGPPeer>
|
||||
</a:Peers>
|
||||
<a:RouteMaps/>
|
||||
</a:BGPRouterDeclaration>
|
||||
<a:BGPRouterDeclaration>
|
||||
<a:ASN>64542</a:ASN>
|
||||
<a:Hostname>OCPSCH0104001MS</a:Hostname>
|
||||
<a:RouteMaps/>
|
||||
</a:BGPRouterDeclaration>
|
||||
<a:BGPRouterDeclaration>
|
||||
<a:ASN>64543</a:ASN>
|
||||
<a:Hostname>OCPSCH0104002MS</a:Hostname>
|
||||
<a:RouteMaps/>
|
||||
</a:BGPRouterDeclaration>
|
||||
</Routers>
|
||||
</CpgDec>
|
||||
<DpgDec>
|
||||
<DeviceDataPlaneInfo>
|
||||
<IPSecTunnels/>
|
||||
<LoopbackIPInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
|
||||
<a:LoopbackIPInterface>
|
||||
<Name>HostIP</Name>
|
||||
<AttachTo>Loopback0</AttachTo>
|
||||
<a:Prefix xmlns:b="Microsoft.Search.Autopilot.NetMux">
|
||||
<b:IPPrefix>100.0.0.9/32</b:IPPrefix>
|
||||
</a:Prefix>
|
||||
<a:PrefixStr>100.0.0.9/32</a:PrefixStr>
|
||||
</a:LoopbackIPInterface>
|
||||
</LoopbackIPInterfaces>
|
||||
<ManagementIPInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
|
||||
</ManagementIPInterfaces>
|
||||
<MplsInterfaces/>
|
||||
<MplsTeInterfaces/>
|
||||
<RsvpInterfaces/>
|
||||
<Hostname>SONiC-Inventec-d6254qs</Hostname>
|
||||
<PortChannelInterfaces/>
|
||||
<VlanInterfaces/>
|
||||
<IPInterfaces>
|
||||
<IPInterface>
|
||||
<Name i:nil="true"/>
|
||||
<AttachTo>Ethernet0</AttachTo>
|
||||
<Prefix>10.10.1.25/30</Prefix>
|
||||
</IPInterface>
|
||||
<IPInterface>
|
||||
<Name i:nil="true"/>
|
||||
<AttachTo>Ethernet4</AttachTo>
|
||||
<Prefix>10.10.2.25/30</Prefix>
|
||||
</IPInterface>
|
||||
</IPInterfaces>
|
||||
<DataAcls/>
|
||||
<AclInterfaces/>
|
||||
<DownstreamSummaries/>
|
||||
<DownstreamSummarySet xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
|
||||
</DeviceDataPlaneInfo>
|
||||
</DpgDec>
|
||||
<PngDec>
|
||||
<DeviceInterfaceLinks>
|
||||
<DeviceLinkBase i:type="DeviceInterfaceLink">
|
||||
<ElementType>DeviceInterfaceLink</ElementType>
|
||||
<EndDevice>OCPSCH0104001MS</EndDevice>
|
||||
<EndPort>Ethernet24</EndPort>
|
||||
<StartDevice>SONiC-Inventec-d6254qs</StartDevice>
|
||||
<StartPort>Ethernet0</StartPort>
|
||||
</DeviceLinkBase>
|
||||
<DeviceLinkBase i:type="DeviceInterfaceLink">
|
||||
<ElementType>DeviceInterfaceLink</ElementType>
|
||||
<EndDevice>OCPSCH0104002MS</EndDevice>
|
||||
<EndPort>Ethernet24</EndPort>
|
||||
<StartDevice>SONiC-Inventec-d6254qs</StartDevice>
|
||||
<StartPort>Ethernet4</StartPort>
|
||||
</DeviceLinkBase>
|
||||
</DeviceInterfaceLinks>
|
||||
<Devices>
|
||||
<Device i:type="LeafRouter">
|
||||
<Hostname>SONiC-Inventec-d6254qs</Hostname>
|
||||
<HwSku>INVENTEC-D6254QS</HwSku>
|
||||
</Device>
|
||||
</Devices>
|
||||
</PngDec>
|
||||
<MetadataDeclaration>
|
||||
<Devices xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
|
||||
<a:DeviceMetadata>
|
||||
<a:Name>SONiC-Inventec-d6254qs</a:Name>
|
||||
<a:Properties>
|
||||
<a:DeviceProperty>
|
||||
<a:Name>DhcpResources</a:Name>
|
||||
<a:Reference i:nil="true"/>
|
||||
<a:Value></a:Value>
|
||||
</a:DeviceProperty>
|
||||
<a:DeviceProperty>
|
||||
<a:Name>NtpResources</a:Name>
|
||||
<a:Reference i:nil="true"/>
|
||||
<a:Value>0.debian.pool.ntp.org;1.debian.pool.ntp.org;2.debian.pool.ntp.org;3.debian.pool.ntp.org</a:Value>
|
||||
</a:DeviceProperty>
|
||||
<a:DeviceProperty>
|
||||
<a:Name>SyslogResources</a:Name>
|
||||
<a:Reference i:nil="true"/>
|
||||
<a:Value></a:Value>
|
||||
</a:DeviceProperty>
|
||||
</a:Properties>
|
||||
</a:DeviceMetadata>
|
||||
</Devices>
|
||||
<Properties xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
|
||||
</MetadataDeclaration>
|
||||
<Hostname>SONiC-Inventec-d6254qs</Hostname>
|
||||
<HwSku>INVENTEC-D6254QS</HwSku>
|
||||
</DeviceMiniGraph>
|
22
device/inventec/x86_64-inventec_d6254qs-r0/plugins/eeprom.py
Normal file
22
device/inventec/x86_64-inventec_d6254qs-r0/plugins/eeprom.py
Normal file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Inventec d7032q28b
|
||||
#
|
||||
# Platform and model specific eeprom subclass, inherits from the base class,
|
||||
# and provides the followings:
|
||||
# - the eeprom format definition
|
||||
# - specific encoder/decoder if there is special need
|
||||
#############################################################################
|
||||
|
||||
try:
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
self.eeprom_path = "/sys/class/i2c-adapter/i2c-0/0-0053/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
@ -0,0 +1,84 @@
|
||||
#
|
||||
# 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"""
|
||||
|
||||
PSU_DIR = "/sys/bus/i2c/devices/0-0066"
|
||||
|
||||
def __init__(self):
|
||||
PsuBase.__init__(self)
|
||||
|
||||
# Get sysfs attribute
|
||||
def get_attr_value(self, attr_path):
|
||||
|
||||
retval = 'ERR'
|
||||
if (not os.path.isfile(attr_path)):
|
||||
return retval
|
||||
|
||||
try:
|
||||
with open(attr_path, 'r') as fd:
|
||||
retval = fd.read()
|
||||
except Exception as error:
|
||||
logging.error("Unable to open ", attr_path, " file !")
|
||||
|
||||
retval = retval.rstrip(' \t\n\r')
|
||||
return retval
|
||||
|
||||
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 = 0
|
||||
attr_file = 'psoc_psu'+ str(index) + '_iout'
|
||||
attr_path = self.PSU_DIR +'/' + attr_file
|
||||
|
||||
attr_value = self.get_attr_value(attr_path)
|
||||
if (attr_value != 'ERR'):
|
||||
# Check for PSU status
|
||||
if (attr_value != 0):
|
||||
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 = 0
|
||||
psu_absent = 0
|
||||
ind = index-1
|
||||
attr_file ='psu'+ str(ind)
|
||||
attr_path = self.PSU_DIR +'/' + attr_file
|
||||
normal_attr_value = '0 : normal'
|
||||
attr_value = self.get_attr_value(attr_path)
|
||||
if (attr_value != 'ERR'):
|
||||
# Check for PSU presence
|
||||
if (attr_value == normal_attr_value):
|
||||
status = 1
|
||||
return status
|
209
device/inventec/x86_64-inventec_d6254qs-r0/plugins/sfputil.py
Normal file
209
device/inventec/x86_64-inventec_d6254qs-r0/plugins/sfputil.py
Normal file
@ -0,0 +1,209 @@
|
||||
# sfputil.py
|
||||
#
|
||||
# Platform-specific SFP transceiver interface for SONiC
|
||||
#
|
||||
|
||||
try:
|
||||
import time
|
||||
from sonic_sfp.sfputilbase import SfpUtilBase
|
||||
except ImportError as e:
|
||||
raise ImportError("%s - required module not found" % str(e))
|
||||
|
||||
|
||||
class SfpUtil(SfpUtilBase):
|
||||
"""Platform-specific SfpUtil class"""
|
||||
|
||||
PORT_START = 0
|
||||
PORT_END = 53
|
||||
PORTS_IN_BLOCK = 54
|
||||
QSFP_PORT_START = 48
|
||||
QSFP_PORT_END = 53
|
||||
|
||||
_port_to_eeprom_mapping = {}
|
||||
port_to_i2c_mapping = {
|
||||
0: 10,
|
||||
1: 11,
|
||||
2: 12,
|
||||
3: 13,
|
||||
4: 14,
|
||||
5: 15,
|
||||
6: 16,
|
||||
7: 17,
|
||||
8: 18,
|
||||
9: 19,
|
||||
10: 20,
|
||||
11: 21,
|
||||
12: 22,
|
||||
13: 23,
|
||||
14: 24,
|
||||
15: 25,
|
||||
16: 26,
|
||||
17: 27,
|
||||
18: 28,
|
||||
19: 29,
|
||||
20: 30,
|
||||
21: 31,
|
||||
22: 32,
|
||||
23: 33,
|
||||
24: 34,
|
||||
25: 35,
|
||||
26: 36,
|
||||
27: 37,
|
||||
28: 38,
|
||||
29: 39,
|
||||
30: 40,
|
||||
31: 41,
|
||||
32: 42,
|
||||
33: 43,
|
||||
34: 44,
|
||||
35: 45,
|
||||
36: 46,
|
||||
37: 47,
|
||||
38: 48,
|
||||
39: 49,
|
||||
40: 50,
|
||||
41: 51,
|
||||
42: 52,
|
||||
43: 53,
|
||||
44: 54,
|
||||
45: 55,
|
||||
46: 56,
|
||||
47: 57,
|
||||
48: 58,
|
||||
49: 59,
|
||||
50: 60,
|
||||
51: 61,
|
||||
52: 62,
|
||||
53: 63
|
||||
}
|
||||
|
||||
@property
|
||||
def port_start(self):
|
||||
return self.PORT_START
|
||||
|
||||
@property
|
||||
def port_end(self):
|
||||
return self.PORT_END
|
||||
|
||||
@property
|
||||
def qsfp_port_start(self):
|
||||
return self.QSFP_PORT_START
|
||||
|
||||
@property
|
||||
def qsfp_port_end(self):
|
||||
return self.QSFP_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):
|
||||
port_eeprom_path = eeprom_path.format(self.port_to_i2c_mapping[x])
|
||||
self.port_to_eeprom_mapping[x] = port_eeprom_path
|
||||
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:
|
||||
reg_file = open("/sys/class/swps/port"+str(port_num)+"/present")
|
||||
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 True
|
||||
|
||||
return False
|
||||
|
||||
def get_low_power_mode(self, port_num):
|
||||
# Check for invalid port_num
|
||||
if port_num < self.port_start or port_num > self.port_end:
|
||||
return False
|
||||
if port_num < self.qsfp_port_start or port_num > self.qsfp_port_end:
|
||||
return False
|
||||
|
||||
try:
|
||||
reg_file = open("/sys/class/swps/port"+str(port_num)+"/lpmod")
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
|
||||
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.port_start or port_num > self.port_end:
|
||||
return False
|
||||
if port_num < self.qsfp_port_start or port_num > self.qsfp_port_end:
|
||||
print "\nError:SFP's don't support this property"
|
||||
return False
|
||||
|
||||
try:
|
||||
reg_file = open("/sys/class/swps/port"+str(port_num)+"/lpmod", "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):
|
||||
QSFP_RESET_REGISTER_DEVICE_FILE = "/sys/class/swps/port"+str(port_num)+"/reset"
|
||||
# Check for invalid port_num
|
||||
if port_num < self.port_start or port_num > self.port_end:
|
||||
return False
|
||||
if port_num < self.qsfp_port_start or port_num > self.qsfp_port_end:
|
||||
print "\nError:SFP's don't support this property"
|
||||
return False
|
||||
|
||||
try:
|
||||
reg_file = open(QSFP_RESET_REGISTER_DEVICE_FILE, "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(QSFP_RESET_REGISTER_DEVICE_FILE, "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
|
15
device/inventec/x86_64-inventec_d6254qs-r0/sensors.conf
Normal file
15
device/inventec/x86_64-inventec_d6254qs-r0/sensors.conf
Normal file
@ -0,0 +1,15 @@
|
||||
# libsensors configuration file
|
||||
chip "inv_psoc-*"
|
||||
ignore temp3
|
||||
ignore temp4
|
||||
label temp1 "CPU Board Temperature"
|
||||
label temp2 "SW Board I Temperature"
|
||||
label temp5 "SW Board II Temperature"
|
||||
label temp6 "ASIC Temperature"
|
||||
label in1 "PSU1 Voltage"
|
||||
label in2 "PSU2 Voltage"
|
||||
label curr1 "PSU1 Current"
|
||||
label curr2 "PSU2 Current"
|
||||
label power1 "PSU1 Power"
|
||||
label power2 "PSU2 Power"
|
||||
|
@ -0,0 +1,57 @@
|
||||
# name lanes alias
|
||||
Ethernet0 1 Ethernet0
|
||||
Ethernet4 2 Ethernet4
|
||||
Ethernet8 3 Ethernet8
|
||||
Ethernet12 4 Ethernet12
|
||||
Ethernet16 5 Ethernet16
|
||||
Ethernet20 6 Ethernet20
|
||||
Ethernet24 7 Ethernet24
|
||||
Ethernet28 8 Ethernet28
|
||||
Ethernet32 13 Ethernet32
|
||||
Ethernet36 14 Ethernet36
|
||||
Ethernet40 15 Ethernet40
|
||||
Ethernet44 16 Ethernet44
|
||||
Ethernet48 21 Ethernet48
|
||||
Ethernet52 22 Ethernet52
|
||||
Ethernet56 23 Ethernet56
|
||||
Ethernet60 24 Ethernet60
|
||||
Ethernet64 29 Ethernet64
|
||||
Ethernet68 30 Ethernet68
|
||||
Ethernet72 31 Ethernet72
|
||||
Ethernet76 32 Ethernet76
|
||||
Ethernet80 33 Ethernet80
|
||||
Ethernet84 34 Ethernet84
|
||||
Ethernet88 35 Ethernet88
|
||||
Ethernet92 36 Ethernet92
|
||||
Ethernet96 41 Ethernet96
|
||||
Ethernet100 42 Ethernet100
|
||||
Ethernet104 43 Ethernet104
|
||||
Ethernet108 44 Ethernet108
|
||||
Ethernet112 49 Ethernet112
|
||||
Ethernet116 50 Ethernet116
|
||||
Ethernet120 51 Ethernet120
|
||||
Ethernet124 52 Ethernet124
|
||||
Ethernet128 57 Ethernet128
|
||||
Ethernet132 58 Ethernet132
|
||||
Ethernet136 59 Ethernet136
|
||||
Ethernet140 60 Ethernet140
|
||||
Ethernet144 61 Ethernet144
|
||||
Ethernet148 62 Ethernet148
|
||||
Ethernet152 63 Ethernet152
|
||||
Ethernet156 64 Ethernet156
|
||||
Ethernet160 65 Ethernet160
|
||||
Ethernet164 66 Ethernet164
|
||||
Ethernet168 67 Ethernet168
|
||||
Ethernet172 68 Ethernet172
|
||||
Ethernet176 69 Ethernet176
|
||||
Ethernet180 70 Ethernet180
|
||||
Ethernet184 71 Ethernet184
|
||||
Ethernet188 72 Ethernet188
|
||||
Ethernet192 77,78,79,80 Ethernet192
|
||||
Ethernet196 85,86,87,88 Ethernet196
|
||||
Ethernet200 93,94,95,96 Ethernet200
|
||||
Ethernet204 97,98,99,100 Ethernet204
|
||||
Ethernet208 105,106,107,108 Ethernet208
|
||||
Ethernet212 113,114,115,116 Ethernet212
|
||||
Ethernet216 121,122,123,124 Ethernet216
|
||||
Ethernet220 125,126,127,128 Ethernet220
|
@ -0,0 +1,2 @@
|
||||
SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/td3-d6556-48x25G-8x100G.config.bcm.inventec
|
||||
SAI_NUM_ECMP_MEMBERS=32
|
4
device/inventec/x86_64-inventec_d6556-r0/installer.conf
Normal file
4
device/inventec/x86_64-inventec_d6556-r0/installer.conf
Normal file
@ -0,0 +1,4 @@
|
||||
CONSOLE_PORT=0x3f8
|
||||
CONSOLE_DEV=0
|
||||
CONSOLE_SPEED=115200
|
||||
VAR_LOG_SIZE=1024
|
@ -0,0 +1,6 @@
|
||||
led auto off
|
||||
led stop
|
||||
m0 load 0 0x0 /usr/share/sonic/platform/linkscan_led_fw.bin
|
||||
m0 load 0 0x3800 /usr/share/sonic/platform/custom_led.bin
|
||||
led auto on
|
||||
led start
|
144
device/inventec/x86_64-inventec_d6556-r0/minigraph.xml
Normal file
144
device/inventec/x86_64-inventec_d6556-r0/minigraph.xml
Normal file
@ -0,0 +1,144 @@
|
||||
<DeviceMiniGraph xmlns="Microsoft.Search.Autopilot.Evolution" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">
|
||||
<CpgDec>
|
||||
<IsisRouters xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
|
||||
<PeeringSessions>
|
||||
<BGPSession>
|
||||
<StartRouter>OCPSCH0104001MS</StartRouter>
|
||||
<StartPeer>10.10.1.26</StartPeer>
|
||||
<EndRouter>SONiC-Inventec-d6556</EndRouter>
|
||||
<EndPeer>10.10.1.25</EndPeer>
|
||||
<Multihop>1</Multihop>
|
||||
<HoldTime>10</HoldTime>
|
||||
<KeepAliveTime>3</KeepAliveTime>
|
||||
</BGPSession>
|
||||
<BGPSession>
|
||||
<StartRouter>OCPSCH0104002MS</StartRouter>
|
||||
<StartPeer>10.10.2.26</StartPeer>
|
||||
<EndRouter>SONiC-Inventec-d6556</EndRouter>
|
||||
<EndPeer>10.10.2.25</EndPeer>
|
||||
<Multihop>1</Multihop>
|
||||
<HoldTime>10</HoldTime>
|
||||
<KeepAliveTime>3</KeepAliveTime>
|
||||
</BGPSession>
|
||||
</PeeringSessions>
|
||||
<Routers xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
|
||||
<a:BGPRouterDeclaration>
|
||||
<a:ASN>64536</a:ASN>
|
||||
<a:Hostname>SONiC-Inventec-d6556</a:Hostname>
|
||||
<a:Peers>
|
||||
<BGPPeer>
|
||||
<Address>10.10.1.26</Address>
|
||||
<RouteMapIn i:nil="true"/>
|
||||
<RouteMapOut i:nil="true"/>
|
||||
</BGPPeer>
|
||||
<BGPPeer>
|
||||
<Address>10.10.2.26</Address>
|
||||
<RouteMapIn i:nil="true"/>
|
||||
<RouteMapOut i:nil="true"/>
|
||||
</BGPPeer>
|
||||
</a:Peers>
|
||||
<a:RouteMaps/>
|
||||
</a:BGPRouterDeclaration>
|
||||
<a:BGPRouterDeclaration>
|
||||
<a:ASN>64542</a:ASN>
|
||||
<a:Hostname>OCPSCH0104001MS</a:Hostname>
|
||||
<a:RouteMaps/>
|
||||
</a:BGPRouterDeclaration>
|
||||
<a:BGPRouterDeclaration>
|
||||
<a:ASN>64543</a:ASN>
|
||||
<a:Hostname>OCPSCH0104002MS</a:Hostname>
|
||||
<a:RouteMaps/>
|
||||
</a:BGPRouterDeclaration>
|
||||
</Routers>
|
||||
</CpgDec>
|
||||
<DpgDec>
|
||||
<DeviceDataPlaneInfo>
|
||||
<IPSecTunnels/>
|
||||
<LoopbackIPInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
|
||||
<a:LoopbackIPInterface>
|
||||
<Name>HostIP</Name>
|
||||
<AttachTo>Loopback0</AttachTo>
|
||||
<a:Prefix xmlns:b="Microsoft.Search.Autopilot.NetMux">
|
||||
<b:IPPrefix>100.0.0.9/32</b:IPPrefix>
|
||||
</a:Prefix>
|
||||
<a:PrefixStr>100.0.0.9/32</a:PrefixStr>
|
||||
</a:LoopbackIPInterface>
|
||||
</LoopbackIPInterfaces>
|
||||
<ManagementIPInterfaces xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
|
||||
</ManagementIPInterfaces>
|
||||
<MplsInterfaces/>
|
||||
<MplsTeInterfaces/>
|
||||
<RsvpInterfaces/>
|
||||
<Hostname>SONiC-Inventec-d6556</Hostname>
|
||||
<PortChannelInterfaces/>
|
||||
<VlanInterfaces/>
|
||||
<IPInterfaces>
|
||||
<IPInterface>
|
||||
<Name i:nil="true"/>
|
||||
<AttachTo>Ethernet0</AttachTo>
|
||||
<Prefix>10.10.1.25/30</Prefix>
|
||||
</IPInterface>
|
||||
<IPInterface>
|
||||
<Name i:nil="true"/>
|
||||
<AttachTo>Ethernet4</AttachTo>
|
||||
<Prefix>10.10.2.25/30</Prefix>
|
||||
</IPInterface>
|
||||
</IPInterfaces>
|
||||
<DataAcls/>
|
||||
<AclInterfaces/>
|
||||
<DownstreamSummaries/>
|
||||
<DownstreamSummarySet xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
|
||||
</DeviceDataPlaneInfo>
|
||||
</DpgDec>
|
||||
<PngDec>
|
||||
<DeviceInterfaceLinks>
|
||||
<DeviceLinkBase i:type="DeviceInterfaceLink">
|
||||
<ElementType>DeviceInterfaceLink</ElementType>
|
||||
<EndDevice>OCPSCH0104001MS</EndDevice>
|
||||
<EndPort>Ethernet24</EndPort>
|
||||
<StartDevice>SONiC-Inventec-d6556</StartDevice>
|
||||
<StartPort>Ethernet0</StartPort>
|
||||
</DeviceLinkBase>
|
||||
<DeviceLinkBase i:type="DeviceInterfaceLink">
|
||||
<ElementType>DeviceInterfaceLink</ElementType>
|
||||
<EndDevice>OCPSCH0104002MS</EndDevice>
|
||||
<EndPort>Ethernet24</EndPort>
|
||||
<StartDevice>SONiC-Inventec-d6556</StartDevice>
|
||||
<StartPort>Ethernet4</StartPort>
|
||||
</DeviceLinkBase>
|
||||
</DeviceInterfaceLinks>
|
||||
<Devices>
|
||||
<Device i:type="LeafRouter">
|
||||
<Hostname>SONiC-Inventec-d6556</Hostname>
|
||||
<HwSku>INVENTEC-D6556</HwSku>
|
||||
</Device>
|
||||
</Devices>
|
||||
</PngDec>
|
||||
<MetadataDeclaration>
|
||||
<Devices xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution">
|
||||
<a:DeviceMetadata>
|
||||
<a:Name>SONiC-Inventec-d6556</a:Name>
|
||||
<a:Properties>
|
||||
<a:DeviceProperty>
|
||||
<a:Name>DhcpResources</a:Name>
|
||||
<a:Reference i:nil="true"/>
|
||||
<a:Value></a:Value>
|
||||
</a:DeviceProperty>
|
||||
<a:DeviceProperty>
|
||||
<a:Name>NtpResources</a:Name>
|
||||
<a:Reference i:nil="true"/>
|
||||
<a:Value>0.debian.pool.ntp.org;1.debian.pool.ntp.org;2.debian.pool.ntp.org;3.debian.pool.ntp.org</a:Value>
|
||||
</a:DeviceProperty>
|
||||
<a:DeviceProperty>
|
||||
<a:Name>SyslogResources</a:Name>
|
||||
<a:Reference i:nil="true"/>
|
||||
<a:Value></a:Value>
|
||||
</a:DeviceProperty>
|
||||
</a:Properties>
|
||||
</a:DeviceMetadata>
|
||||
</Devices>
|
||||
<Properties xmlns:a="http://schemas.datacontract.org/2004/07/Microsoft.Search.Autopilot.Evolution"/>
|
||||
</MetadataDeclaration>
|
||||
<Hostname>SONiC-Inventec-d6556</Hostname>
|
||||
<HwSku>INVENTEC-D6556</HwSku>
|
||||
</DeviceMiniGraph>
|
22
device/inventec/x86_64-inventec_d6556-r0/plugins/eeprom.py
Normal file
22
device/inventec/x86_64-inventec_d6556-r0/plugins/eeprom.py
Normal file
@ -0,0 +1,22 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
#############################################################################
|
||||
# Inventec d7032q28b
|
||||
#
|
||||
# Platform and model specific eeprom subclass, inherits from the base class,
|
||||
# and provides the followings:
|
||||
# - the eeprom format definition
|
||||
# - specific encoder/decoder if there is special need
|
||||
#############################################################################
|
||||
|
||||
try:
|
||||
from sonic_eeprom import eeprom_tlvinfo
|
||||
except ImportError, e:
|
||||
raise ImportError (str(e) + "- required module not found")
|
||||
|
||||
|
||||
class board(eeprom_tlvinfo.TlvInfoDecoder):
|
||||
|
||||
def __init__(self, name, path, cpld_root, ro):
|
||||
self.eeprom_path = "/sys/class/i2c-adapter/i2c-0/0-0053/eeprom"
|
||||
super(board, self).__init__(self.eeprom_path, 0, '', True)
|
84
device/inventec/x86_64-inventec_d6556-r0/plugins/psuutil.py
Normal file
84
device/inventec/x86_64-inventec_d6556-r0/plugins/psuutil.py
Normal file
@ -0,0 +1,84 @@
|
||||
#
|
||||
# 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"""
|
||||
|
||||
PSU_DIR = "/sys/class/hwmon/hwmon1"
|
||||
|
||||
def __init__(self):
|
||||
PsuBase.__init__(self)
|
||||
|
||||
# Get sysfs attribute
|
||||
def get_attr_value(self, attr_path):
|
||||
|
||||
retval = 'ERR'
|
||||
if (not os.path.isfile(attr_path)):
|
||||
return retval
|
||||
|
||||
try:
|
||||
with open(attr_path, 'r') as fd:
|
||||
retval = fd.read()
|
||||
except Exception as error:
|
||||
logging.error("Unable to open ", attr_path, " file !")
|
||||
|
||||
retval = retval.rstrip(' \t\n\r')
|
||||
return retval
|
||||
|
||||
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 = 0
|
||||
attr_file = 'psoc_psu'+ str(index) + '_iout'
|
||||
attr_path = self.PSU_DIR +'/' + attr_file
|
||||
|
||||
attr_value = self.get_attr_value(attr_path)
|
||||
if (attr_value != 'ERR'):
|
||||
# Check for PSU status
|
||||
if (attr_value != 0):
|
||||
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 = 0
|
||||
psu_absent = 0
|
||||
ind = index-1
|
||||
attr_file ='psu'+ str(ind)
|
||||
attr_path = self.PSU_DIR +'/' + attr_file
|
||||
normal_attr_value = '0 : normal'
|
||||
attr_value = self.get_attr_value(attr_path)
|
||||
if (attr_value != 'ERR'):
|
||||
# Check for PSU presence
|
||||
if (attr_value == normal_attr_value):
|
||||
status = 1
|
||||
return status
|
211
device/inventec/x86_64-inventec_d6556-r0/plugins/sfputil.py
Normal file
211
device/inventec/x86_64-inventec_d6556-r0/plugins/sfputil.py
Normal file
@ -0,0 +1,211 @@
|
||||
# sfputil.py
|
||||
#
|
||||
# Platform-specific SFP transceiver interface for SONiC
|
||||
#
|
||||
|
||||
try:
|
||||
import time
|
||||
from sonic_sfp.sfputilbase import SfpUtilBase
|
||||
except ImportError as e:
|
||||
raise ImportError("%s - required module not found" % str(e))
|
||||
|
||||
|
||||
class SfpUtil(SfpUtilBase):
|
||||
"""Platform-specific SfpUtil class"""
|
||||
|
||||
PORT_START = 0
|
||||
PORT_END = 55
|
||||
PORTS_IN_BLOCK = 56
|
||||
QSFP_PORT_START = 48
|
||||
QSFP_PORT_END = 55
|
||||
|
||||
_port_to_eeprom_mapping = {}
|
||||
port_to_i2c_mapping = {
|
||||
0: 18,
|
||||
1: 19,
|
||||
2: 20,
|
||||
3: 21,
|
||||
4: 22,
|
||||
5: 23,
|
||||
6: 24,
|
||||
7: 25,
|
||||
8: 26,
|
||||
9: 27,
|
||||
10: 28,
|
||||
11: 29,
|
||||
12: 30,
|
||||
13: 31,
|
||||
14: 32,
|
||||
15: 33,
|
||||
16: 34,
|
||||
17: 35,
|
||||
18: 36,
|
||||
19: 37,
|
||||
20: 38,
|
||||
21: 39,
|
||||
22: 40,
|
||||
23: 41,
|
||||
24: 42,
|
||||
25: 43,
|
||||
26: 44,
|
||||
27: 45,
|
||||
28: 46,
|
||||
29: 47,
|
||||
30: 48,
|
||||
31: 49,
|
||||
32: 50,
|
||||
33: 51,
|
||||
34: 52,
|
||||
35: 53,
|
||||
36: 54,
|
||||
37: 55,
|
||||
38: 56,
|
||||
39: 57,
|
||||
40: 58,
|
||||
41: 59,
|
||||
42: 60,
|
||||
43: 61,
|
||||
44: 62,
|
||||
45: 63,
|
||||
46: 64,
|
||||
47: 65,
|
||||
48: 10,
|
||||
49: 11,
|
||||
50: 12,
|
||||
51: 13,
|
||||
52: 14,
|
||||
53: 15,
|
||||
54: 16,
|
||||
55: 17
|
||||
}
|
||||
|
||||
@property
|
||||
def port_start(self):
|
||||
return self.PORT_START
|
||||
|
||||
@property
|
||||
def port_end(self):
|
||||
return self.PORT_END
|
||||
|
||||
@property
|
||||
def qsfp_port_start(self):
|
||||
return self.QSFP_PORT_START
|
||||
|
||||
@property
|
||||
def qsfp_port_end(self):
|
||||
return self.QSFP_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):
|
||||
port_eeprom_path = eeprom_path.format(self.port_to_i2c_mapping[x])
|
||||
self.port_to_eeprom_mapping[x] = port_eeprom_path
|
||||
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:
|
||||
reg_file = open("/sys/class/swps/port"+str(port_num)+"/present")
|
||||
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 True
|
||||
|
||||
return False
|
||||
|
||||
def get_low_power_mode(self, port_num):
|
||||
# Check for invalid port_num
|
||||
if port_num < self.port_start or port_num > self.port_end:
|
||||
return False
|
||||
if port_num < self.qsfp_port_start or port_num > self.qsfp_port_end:
|
||||
return False
|
||||
|
||||
try:
|
||||
reg_file = open("/sys/class/swps/port"+str(port_num)+"/lpmod")
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
|
||||
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.port_start or port_num > self.port_end:
|
||||
return False
|
||||
if port_num < self.qsfp_port_start or port_num > self.qsfp_port_end:
|
||||
print "\nError:SFP's don't support this property"
|
||||
return False
|
||||
|
||||
try:
|
||||
reg_file = open("/sys/class/swps/port"+str(port_num)+"/lpmod", "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):
|
||||
QSFP_RESET_REGISTER_DEVICE_FILE = "/sys/class/swps/port"+str(port_num)+"/reset"
|
||||
# Check for invalid port_num
|
||||
if port_num < self.port_start or port_num > self.port_end:
|
||||
return False
|
||||
if port_num < self.qsfp_port_start or port_num > self.qsfp_port_end:
|
||||
print "\nError:SFP's don't support this property"
|
||||
return False
|
||||
|
||||
try:
|
||||
reg_file = open(QSFP_RESET_REGISTER_DEVICE_FILE, "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(QSFP_RESET_REGISTER_DEVICE_FILE, "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
|
44
device/inventec/x86_64-inventec_d6556-r0/sensors.conf
Normal file
44
device/inventec/x86_64-inventec_d6556-r0/sensors.conf
Normal file
@ -0,0 +1,44 @@
|
||||
# libsensors configuration file
|
||||
chip "inv_psoc-*"
|
||||
label temp1 "FrontSide Temperature"
|
||||
label temp2 "FanBoard Temperature"
|
||||
label temp3 "NearASIC Temperature"
|
||||
label temp4 "Center Temperature"
|
||||
|
||||
label temp5 "CPU Board Temperature"
|
||||
label temp6 "ASIC Temperature"
|
||||
label temp7 "PSU1 Temperature1"
|
||||
label temp8 "PSU2 Temperature1"
|
||||
label temp9 "PSU1 Temperature2"
|
||||
label temp10 "PSU2 Temperature2"
|
||||
label fan1 "FanModule1 Front RPM"
|
||||
label fan2 "FanModule1 Rear RPM"
|
||||
label fan3 "FanModule2 Front RPM"
|
||||
label fan4 "FanModule2 Rear RPM"
|
||||
label fan5 "FanModule3 Front RPM"
|
||||
label fan6 "FanModule3 Rear RPM"
|
||||
label fan7 "FanModule4 Front RPM"
|
||||
label fan8 "FanModule4 Rear RPM"
|
||||
label fan9 "FanModule5 Front RPM"
|
||||
label fan10 "FanModule5 Rear RPM"
|
||||
label pwm1 "FanModule1 PWM"
|
||||
label pwm2 "FanModule2 PWM"
|
||||
label pwm3 "FanModule3 PWM"
|
||||
label pwm4 "FanModule4 PWM"
|
||||
label pwm5 "FanModule5 PWM"
|
||||
label pwm6 "PSU1 FAN PWM"
|
||||
label pwm7 "PSU2 FAN PWM"
|
||||
label fan11 "PSU1 FAN RPM"
|
||||
label fan12 "PSU2 FAN RPM"
|
||||
label in1 "PSU1 Input Voltage"
|
||||
label in2 "PSU2 Input Voltage"
|
||||
label curr1 "PSU1 Input Current"
|
||||
label curr2 "PSU2 Input Current"
|
||||
label power1 "PSU1 Input Power"
|
||||
label power2 "PSU2 Input Power"
|
||||
label in3 "PSU1 Output Voltage"
|
||||
label in4 "PSU2 Output Voltage"
|
||||
label curr3 "PSU1 Output Current"
|
||||
label curr4 "PSU2 Output Current"
|
||||
label power3 "PSU1 Output Power"
|
||||
label power4 "PSU2 Output Power"
|
@ -0,0 +1,128 @@
|
||||
{# Default values which will be used if no actual configura available #}
|
||||
{% set default_cable = '300m' %}
|
||||
{% set default_speed = '100G' %}
|
||||
{% set default_ports_num = 32 -%}
|
||||
|
||||
{# Port configuration to cable length look-up table #}
|
||||
{# Each record describes mapping of DUT (DUT port) role and neighbor role to cable length #}
|
||||
{# Roles described in the minigraph #}
|
||||
{% set ports2cable = {
|
||||
'torrouter_server' : '5m',
|
||||
'leafrouter_torrouter' : '40m',
|
||||
'spinerouter_leafrouter' : '300m'
|
||||
}
|
||||
%}
|
||||
|
||||
{%- macro cable_length(port_name) -%}
|
||||
{%- set cable_len = [] -%}
|
||||
{%- for local_port in DEVICE_NEIGHBOR -%}
|
||||
{%- if local_port == port_name -%}
|
||||
{%- if DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%}
|
||||
{%- set neighbor = DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%}
|
||||
{%- set neighbor_role = neighbor.type -%}
|
||||
{%- set roles1 = switch_role + '_' + neighbor_role %}
|
||||
{%- set roles2 = neighbor_role + '_' + switch_role -%}
|
||||
{%- set roles1 = roles1 | lower -%}
|
||||
{%- set roles2 = roles2 | lower -%}
|
||||
{%- if roles1 in ports2cable -%}
|
||||
{%- if cable_len.append(ports2cable[roles1]) -%}{%- endif -%}
|
||||
{%- elif roles2 in ports2cable -%}
|
||||
{%- if cable_len.append(ports2cable[roles2]) -%}{%- endif -%}
|
||||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- if cable_len -%}
|
||||
{{ cable_len.0 }}
|
||||
{%- else -%}
|
||||
{{ default_cable }}
|
||||
{%- endif -%}
|
||||
{% endmacro %}
|
||||
|
||||
{%- if DEVICE_METADATA is defined %}
|
||||
{%- set switch_role = DEVICE_METADATA['localhost']['type'] %}
|
||||
{%- endif -%}
|
||||
|
||||
{# Generate list of ports if not defined #}
|
||||
{% if PORT is not defined %}
|
||||
{% set PORT = [] %}
|
||||
{% for port_idx in range(0,default_ports_num) %}
|
||||
{% if PORT.append("Ethernet%d" % (port_idx*4)) %}{% endif %}
|
||||
{% endfor %}
|
||||
{% endif -%}
|
||||
|
||||
{% set port_names_list = [] %}
|
||||
{% for port in PORT %}
|
||||
{%- if port_names_list.append(port) %}{% endif %}
|
||||
{% endfor %}
|
||||
{% set port_names = port_names_list | join(',') -%}
|
||||
|
||||
{
|
||||
"CABLE_LENGTH": {
|
||||
"AZURE": {
|
||||
{% for port in PORT %}
|
||||
{% set cable = cable_length(port) -%}
|
||||
"{{ port }}": "{{ cable }}"{%- if not loop.last -%},{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
}
|
||||
},
|
||||
"BUFFER_POOL": {
|
||||
"ingress_lossless_pool": {
|
||||
"size": "12766208",
|
||||
"type": "ingress",
|
||||
"mode": "dynamic"
|
||||
},
|
||||
"egress_lossless_pool": {
|
||||
"size": "6000000",
|
||||
"type": "egress",
|
||||
"mode": "static"
|
||||
},
|
||||
"egress_lossy_pool": {
|
||||
"size": "8072396",
|
||||
"type": "egress",
|
||||
"mode": "dynamic"
|
||||
}
|
||||
},
|
||||
"BUFFER_PROFILE": {
|
||||
"ingress_lossless_profile": {
|
||||
"pool":"[BUFFER_POOL|ingress_lossless_pool]",
|
||||
"xon":"18432",
|
||||
"xoff":"40560",
|
||||
"size":"41808",
|
||||
"dynamic_th":"-4",
|
||||
"xon_offset":"2496"
|
||||
},
|
||||
"ingress_lossy_profile": {
|
||||
"pool":"[BUFFER_POOL|ingress_lossless_pool]",
|
||||
"size":"0",
|
||||
"dynamic_th":"3"
|
||||
},
|
||||
"egress_lossless_profile": {
|
||||
"pool":"[BUFFER_POOL|egress_lossless_pool]",
|
||||
"size":"0",
|
||||
"static_th":"6000000"
|
||||
},
|
||||
"egress_lossy_profile": {
|
||||
"pool":"[BUFFER_POOL|egress_lossy_pool]",
|
||||
"size":"1518",
|
||||
"dynamic_th":"3"
|
||||
}
|
||||
},
|
||||
"BUFFER_PG": {
|
||||
"{{ port_names }}|3-4": {
|
||||
"profile" : "[BUFFER_PROFILE|ingress_lossless_profile]"
|
||||
},
|
||||
"{{ port_names }}|0-1": {
|
||||
"profile" : "[BUFFER_PROFILE|ingress_lossy_profile]"
|
||||
}
|
||||
},
|
||||
"BUFFER_QUEUE": {
|
||||
"{{ port_names }}|3-4": {
|
||||
"profile" : "[BUFFER_PROFILE|egress_lossless_profile]"
|
||||
},
|
||||
"{{ port_names }}|0-1": {
|
||||
"profile" : "[BUFFER_PROFILE|egress_lossy_profile]"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
{
|
||||
"TC_TO_PRIORITY_GROUP_MAP": {
|
||||
"AZURE": {
|
||||
"0": "0",
|
||||
"1": "1",
|
||||
"3": "3",
|
||||
"4": "4"
|
||||
}
|
||||
},
|
||||
"MAP_PFC_PRIORITY_TO_QUEUE": {
|
||||
"AZURE": {
|
||||
"0": "0",
|
||||
"1": "1",
|
||||
"3": "3",
|
||||
"4": "4"
|
||||
}
|
||||
},
|
||||
"TC_TO_QUEUE_MAP": {
|
||||
"AZURE": {
|
||||
"0": "0",
|
||||
"1": "1",
|
||||
"3": "3",
|
||||
"4": "4"
|
||||
}
|
||||
},
|
||||
"DSCP_TO_TC_MAP": {
|
||||
"AZURE": {
|
||||
"0":"0",
|
||||
"1":"0",
|
||||
"2":"0",
|
||||
"3":"3",
|
||||
"4":"4",
|
||||
"5":"0",
|
||||
"6":"0",
|
||||
"7":"0",
|
||||
"8":"1",
|
||||
"9":"0",
|
||||
"10":"0",
|
||||
"11":"0",
|
||||
"12":"0",
|
||||
"13":"0",
|
||||
"14":"0",
|
||||
"15":"0",
|
||||
"16":"0",
|
||||
"17":"0",
|
||||
"18":"0",
|
||||
"19":"0",
|
||||
"20":"0",
|
||||
"21":"0",
|
||||
"22":"0",
|
||||
"23":"0",
|
||||
"24":"0",
|
||||
"25":"0",
|
||||
"26":"0",
|
||||
"27":"0",
|
||||
"28":"0",
|
||||
"29":"0",
|
||||
"30":"0",
|
||||
"31":"0",
|
||||
"32":"0",
|
||||
"33":"0",
|
||||
"34":"0",
|
||||
"35":"0",
|
||||
"36":"0",
|
||||
"37":"0",
|
||||
"38":"0",
|
||||
"39":"0",
|
||||
"40":"0",
|
||||
"41":"0",
|
||||
"42":"0",
|
||||
"43":"0",
|
||||
"44":"0",
|
||||
"45":"0",
|
||||
"46":"0",
|
||||
"47":"0",
|
||||
"48":"0",
|
||||
"49":"0",
|
||||
"50":"0",
|
||||
"51":"0",
|
||||
"52":"0",
|
||||
"53":"0",
|
||||
"54":"0",
|
||||
"55":"0",
|
||||
"56":"0",
|
||||
"57":"0",
|
||||
"58":"0",
|
||||
"59":"0",
|
||||
"60":"0",
|
||||
"61":"0",
|
||||
"62":"0",
|
||||
"63":"0"
|
||||
}
|
||||
},
|
||||
"SCHEDULER": {
|
||||
"scheduler.0" : {
|
||||
"type":"DWRR",
|
||||
"weight": "25"
|
||||
},
|
||||
"scheduler.1" : {
|
||||
"type":"DWRR",
|
||||
"weight": "30"
|
||||
},
|
||||
"scheduler.2" : {
|
||||
"type":"DWRR",
|
||||
"weight": "20"
|
||||
}
|
||||
},
|
||||
"PORT_QOS_MAP": {
|
||||
"Ethernet0,Ethernet4,Ethernet8,Ethernet12,Ethernet16,Ethernet20,Ethernet24,Ethernet28,Ethernet32,Ethernet36,Ethernet40,Ethernet44,Ethernet48,Ethernet52,Ethernet56,Ethernet60,Ethernet64,Ethernet68,Ethernet72,Ethernet76,Ethernet80,Ethernet84,Ethernet88,Ethernet92,Ethernet96,Ethernet100,Ethernet104,Ethernet108,Ethernet112,Ethernet116,Ethernet120,Ethernet124": {
|
||||
"dscp_to_tc_map" : "[DSCP_TO_TC_MAP|AZURE]",
|
||||
"tc_to_queue_map" : "[TC_TO_QUEUE_MAP|AZURE]",
|
||||
"tc_to_pg_map" : "[TC_TO_PRIORITY_GROUP_MAP|AZURE]",
|
||||
"pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]",
|
||||
"pfc_enable": "3,4"
|
||||
}
|
||||
},
|
||||
"WRED_PROFILE": {
|
||||
"AZURE_LOSSLESS" : {
|
||||
"wred_green_enable":"true",
|
||||
"wred_yellow_enable":"true",
|
||||
"wred_red_enable":"true",
|
||||
"ecn":"ecn_all",
|
||||
"red_max_threshold":"312000",
|
||||
"red_min_threshold":"104000",
|
||||
"yellow_max_threshold":"312000",
|
||||
"yellow_min_threshold":"104000",
|
||||
"green_max_threshold":"312000",
|
||||
"green_min_threshold":"104000"
|
||||
}
|
||||
},
|
||||
"QUEUE": {
|
||||
"Ethernet0,Ethernet4,Ethernet8,Ethernet12,Ethernet16,Ethernet20,Ethernet24,Ethernet28,Ethernet32,Ethernet36,Ethernet40,Ethernet44,Ethernet48,Ethernet52,Ethernet56,Ethernet60,Ethernet64,Ethernet68,Ethernet72,Ethernet76,Ethernet80,Ethernet84,Ethernet88,Ethernet92,Ethernet96,Ethernet100,Ethernet104,Ethernet108,Ethernet112,Ethernet116,Ethernet120,Ethernet124|3-4" : {
|
||||
"scheduler" : "[SCHEDULER|scheduler.0]",
|
||||
"wred_profile" : "[WRED_PROFILE|AZURE_LOSSLESS]"
|
||||
},
|
||||
"Ethernet0,Ethernet4,Ethernet8,Ethernet12,Ethernet16,Ethernet20,Ethernet24,Ethernet28,Ethernet32,Ethernet36,Ethernet40,Ethernet44,Ethernet48,Ethernet52,Ethernet56,Ethernet60,Ethernet64,Ethernet68,Ethernet72,Ethernet76,Ethernet80,Ethernet84,Ethernet88,Ethernet92,Ethernet96,Ethernet100,Ethernet104,Ethernet108,Ethernet112,Ethernet116,Ethernet120,Ethernet124|0" : {
|
||||
"scheduler" : "[SCHEDULER|scheduler.1]"
|
||||
},
|
||||
"Ethernet0,Ethernet4,Ethernet8,Ethernet12,Ethernet16,Ethernet20,Ethernet24,Ethernet28,Ethernet32,Ethernet36,Ethernet40,Ethernet44,Ethernet48,Ethernet52,Ethernet56,Ethernet60,Ethernet64,Ethernet68,Ethernet72,Ethernet76,Ethernet80,Ethernet84,Ethernet88,Ethernet92,Ethernet96,Ethernet100,Ethernet104,Ethernet108,Ethernet112,Ethernet116,Ethernet120,Ethernet124|1" : {
|
||||
"scheduler" : "[SCHEDULER|scheduler.2]"
|
||||
}
|
||||
}
|
||||
}
|
@ -128,9 +128,9 @@ m CMIC_LEDUP1_PORT_ORDER_REMAP_60_63 REMAP_PORT_62=61
|
||||
m CMIC_LEDUP1_PORT_ORDER_REMAP_60_63 REMAP_PORT_63=60
|
||||
|
||||
led 0 stop
|
||||
led 0 prog 02 00 60 F1 12 00 DE F6 70 10 67 47 67 42 77 06 06 F2 60 F0 12 00 06 F0 4A 04 27 67 42 4A 03 27 67 42 4A 07 27 67 42 4A 00 27 67 42 DE F4 70 34 86 F0 77 16 12 00 DE F8 70 40 67 4A 67 42 77 36 3E F1 87 86 F1 81 57 17 27 57 07 27 57 00 00 00
|
||||
led 0 prog 02 00 60 F1 12 00 DA 0F 70 10 67 47 67 42 77 06 02 A0 60 F0 12 00 06 F0 4A 04 27 67 42 4A 03 27 67 42 4A 07 27 67 42 4A 00 27 67 42 DA 80 70 34 86 F0 77 16 12 00 DA 03 70 40 67 4A 67 42 77 36 3E F1 87 86 F1 81 57 17 27 57 07 27 57
|
||||
led 0 start
|
||||
|
||||
led 1 stop
|
||||
led 1 prog 02 00 60 F1 12 00 DE F6 70 10 67 47 67 42 77 06 06 F2 60 F0 12 00 06 F0 4A 04 27 67 42 4A 03 27 67 42 4A 07 27 67 42 4A 00 27 67 42 DE F4 70 34 86 F0 77 16 12 00 DE F8 70 40 67 4A 67 42 77 36 3E F1 87 86 F1 81 57 17 27 57 07 27 57 00 00 00
|
||||
led 1 prog 02 00 60 F1 12 00 DA 0F 70 10 67 47 67 42 77 06 02 A0 60 F0 12 00 06 F0 4A 04 27 67 42 4A 03 27 67 42 4A 07 27 67 42 4A 00 27 67 42 DA 80 70 34 86 F0 77 16 12 00 DA 03 70 40 67 4A 67 42 77 36 3E F1 87 86 F1 81 57 17 27 57 07 27 57
|
||||
led 1 start
|
||||
|
@ -93,7 +93,6 @@
|
||||
<PngDec>
|
||||
<DeviceInterfaceLinks>
|
||||
<DeviceLinkBase i:type="DeviceInterfaceLink">
|
||||
<Bandwidth>40000</Bandwidth>
|
||||
<ElementType>DeviceInterfaceLink</ElementType>
|
||||
<EndDevice>OCPSCH0104001MS</EndDevice>
|
||||
<EndPort>Ethernet24</EndPort>
|
||||
@ -101,7 +100,6 @@
|
||||
<StartPort>Ethernet0</StartPort>
|
||||
</DeviceLinkBase>
|
||||
<DeviceLinkBase i:type="DeviceInterfaceLink">
|
||||
<Bandwidth>40000</Bandwidth>
|
||||
<ElementType>DeviceInterfaceLink</ElementType>
|
||||
<EndDevice>OCPSCH0104002MS</EndDevice>
|
||||
<EndPort>Ethernet24</EndPort>
|
||||
|
15
device/inventec/x86_64-inventec_d7032q28b-r0/sensors.conf
Normal file
15
device/inventec/x86_64-inventec_d7032q28b-r0/sensors.conf
Normal file
@ -0,0 +1,15 @@
|
||||
# libsensors configuration file
|
||||
chip "inv_psoc-*"
|
||||
ignore temp3
|
||||
ignore temp4
|
||||
label temp1 "CPU Board Temperature"
|
||||
label temp2 "SW Board I Temperature"
|
||||
label temp5 "SW Board II Temperature"
|
||||
label temp6 "ASIC Temperature"
|
||||
label in1 "PSU1 Voltage"
|
||||
label in2 "PSU2 Voltage"
|
||||
label curr1 "PSU1 Current"
|
||||
label curr2 "PSU2 Current"
|
||||
label power1 "PSU1 Power"
|
||||
label power2 "PSU2 Power"
|
||||
|
@ -0,0 +1,128 @@
|
||||
{# Default values which will be used if no actual configura available #}
|
||||
{% set default_cable = '300m' %}
|
||||
{% set default_speed = '100G' %}
|
||||
{% set default_ports_num = 54 -%}
|
||||
|
||||
{# Port configuration to cable length look-up table #}
|
||||
{# Each record describes mapping of DUT (DUT port) role and neighbor role to cable length #}
|
||||
{# Roles described in the minigraph #}
|
||||
{% set ports2cable = {
|
||||
'torrouter_server' : '5m',
|
||||
'leafrouter_torrouter' : '40m',
|
||||
'spinerouter_leafrouter' : '300m'
|
||||
}
|
||||
%}
|
||||
|
||||
{%- macro cable_length(port_name) -%}
|
||||
{%- set cable_len = [] -%}
|
||||
{%- for local_port in DEVICE_NEIGHBOR -%}
|
||||
{%- if local_port == port_name -%}
|
||||
{%- if DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%}
|
||||
{%- set neighbor = DEVICE_NEIGHBOR_METADATA[DEVICE_NEIGHBOR[local_port].name] -%}
|
||||
{%- set neighbor_role = neighbor.type -%}
|
||||
{%- set roles1 = switch_role + '_' + neighbor_role %}
|
||||
{%- set roles2 = neighbor_role + '_' + switch_role -%}
|
||||
{%- set roles1 = roles1 | lower -%}
|
||||
{%- set roles2 = roles2 | lower -%}
|
||||
{%- if roles1 in ports2cable -%}
|
||||
{%- if cable_len.append(ports2cable[roles1]) -%}{%- endif -%}
|
||||
{%- elif roles2 in ports2cable -%}
|
||||
{%- if cable_len.append(ports2cable[roles2]) -%}{%- endif -%}
|
||||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
{%- endif -%}
|
||||
{%- endfor -%}
|
||||
{%- if cable_len -%}
|
||||
{{ cable_len.0 }}
|
||||
{%- else -%}
|
||||
{{ default_cable }}
|
||||
{%- endif -%}
|
||||
{% endmacro %}
|
||||
|
||||
{%- if DEVICE_METADATA is defined %}
|
||||
{%- set switch_role = DEVICE_METADATA['localhost']['type'] %}
|
||||
{%- endif -%}
|
||||
|
||||
{# Generate list of ports if not defined #}
|
||||
{% if PORT is not defined %}
|
||||
{% set PORT = [] %}
|
||||
{% for port_idx in range(0,default_ports_num) %}
|
||||
{% if PORT.append("Ethernet%d" % (port_idx*4)) %}{% endif %}
|
||||
{% endfor %}
|
||||
{% endif -%}
|
||||
|
||||
{% set port_names_list = [] %}
|
||||
{% for port in PORT %}
|
||||
{%- if port_names_list.append(port) %}{% endif %}
|
||||
{% endfor %}
|
||||
{% set port_names = port_names_list | join(',') -%}
|
||||
|
||||
{
|
||||
"CABLE_LENGTH": {
|
||||
"AZURE": {
|
||||
{% for port in PORT %}
|
||||
{% set cable = cable_length(port) -%}
|
||||
"{{ port }}": "{{ cable }}"{%- if not loop.last -%},{% endif %}
|
||||
|
||||
{% endfor %}
|
||||
}
|
||||
},
|
||||
"BUFFER_POOL": {
|
||||
"ingress_lossless_pool": {
|
||||
"size": "12766208",
|
||||
"type": "ingress",
|
||||
"mode": "dynamic"
|
||||
},
|
||||
"egress_lossless_pool": {
|
||||
"size": "6000000",
|
||||
"type": "egress",
|
||||
"mode": "static"
|
||||
},
|
||||
"egress_lossy_pool": {
|
||||
"size": "8072396",
|
||||
"type": "egress",
|
||||
"mode": "dynamic"
|
||||
}
|
||||
},
|
||||
"BUFFER_PROFILE": {
|
||||
"ingress_lossless_profile": {
|
||||
"pool":"[BUFFER_POOL|ingress_lossless_pool]",
|
||||
"xon":"18432",
|
||||
"xoff":"40560",
|
||||
"size":"41808",
|
||||
"dynamic_th":"-4",
|
||||
"xon_offset":"2496"
|
||||
},
|
||||
"ingress_lossy_profile": {
|
||||
"pool":"[BUFFER_POOL|ingress_lossless_pool]",
|
||||
"size":"0",
|
||||
"dynamic_th":"3"
|
||||
},
|
||||
"egress_lossless_profile": {
|
||||
"pool":"[BUFFER_POOL|egress_lossless_pool]",
|
||||
"size":"0",
|
||||
"static_th":"6000000"
|
||||
},
|
||||
"egress_lossy_profile": {
|
||||
"pool":"[BUFFER_POOL|egress_lossy_pool]",
|
||||
"size":"1518",
|
||||
"dynamic_th":"3"
|
||||
}
|
||||
},
|
||||
"BUFFER_PG": {
|
||||
"{{ port_names }}|3-4": {
|
||||
"profile" : "[BUFFER_PROFILE|ingress_lossless_profile]"
|
||||
},
|
||||
"{{ port_names }}|0-1": {
|
||||
"profile" : "[BUFFER_PROFILE|ingress_lossy_profile]"
|
||||
}
|
||||
},
|
||||
"BUFFER_QUEUE": {
|
||||
"{{ port_names }}|3-4": {
|
||||
"profile" : "[BUFFER_PROFILE|egress_lossless_profile]"
|
||||
},
|
||||
"{{ port_names }}|0-1": {
|
||||
"profile" : "[BUFFER_PROFILE|egress_lossy_profile]"
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,143 @@
|
||||
{
|
||||
"TC_TO_PRIORITY_GROUP_MAP": {
|
||||
"AZURE": {
|
||||
"0": "0",
|
||||
"1": "1",
|
||||
"3": "3",
|
||||
"4": "4"
|
||||
}
|
||||
},
|
||||
"MAP_PFC_PRIORITY_TO_QUEUE": {
|
||||
"AZURE": {
|
||||
"0": "0",
|
||||
"1": "1",
|
||||
"3": "3",
|
||||
"4": "4"
|
||||
}
|
||||
},
|
||||
"TC_TO_QUEUE_MAP": {
|
||||
"AZURE": {
|
||||
"0": "0",
|
||||
"1": "1",
|
||||
"3": "3",
|
||||
"4": "4"
|
||||
}
|
||||
},
|
||||
"DSCP_TO_TC_MAP": {
|
||||
"AZURE": {
|
||||
"0":"0",
|
||||
"1":"0",
|
||||
"2":"0",
|
||||
"3":"3",
|
||||
"4":"4",
|
||||
"5":"0",
|
||||
"6":"0",
|
||||
"7":"0",
|
||||
"8":"1",
|
||||
"9":"0",
|
||||
"10":"0",
|
||||
"11":"0",
|
||||
"12":"0",
|
||||
"13":"0",
|
||||
"14":"0",
|
||||
"15":"0",
|
||||
"16":"0",
|
||||
"17":"0",
|
||||
"18":"0",
|
||||
"19":"0",
|
||||
"20":"0",
|
||||
"21":"0",
|
||||
"22":"0",
|
||||
"23":"0",
|
||||
"24":"0",
|
||||
"25":"0",
|
||||
"26":"0",
|
||||
"27":"0",
|
||||
"28":"0",
|
||||
"29":"0",
|
||||
"30":"0",
|
||||
"31":"0",
|
||||
"32":"0",
|
||||
"33":"0",
|
||||
"34":"0",
|
||||
"35":"0",
|
||||
"36":"0",
|
||||
"37":"0",
|
||||
"38":"0",
|
||||
"39":"0",
|
||||
"40":"0",
|
||||
"41":"0",
|
||||
"42":"0",
|
||||
"43":"0",
|
||||
"44":"0",
|
||||
"45":"0",
|
||||
"46":"0",
|
||||
"47":"0",
|
||||
"48":"0",
|
||||
"49":"0",
|
||||
"50":"0",
|
||||
"51":"0",
|
||||
"52":"0",
|
||||
"53":"0",
|
||||
"54":"0",
|
||||
"55":"0",
|
||||
"56":"0",
|
||||
"57":"0",
|
||||
"58":"0",
|
||||
"59":"0",
|
||||
"60":"0",
|
||||
"61":"0",
|
||||
"62":"0",
|
||||
"63":"0"
|
||||
}
|
||||
},
|
||||
"SCHEDULER": {
|
||||
"scheduler.0" : {
|
||||
"type":"DWRR",
|
||||
"weight": "25"
|
||||
},
|
||||
"scheduler.1" : {
|
||||
"type":"DWRR",
|
||||
"weight": "30"
|
||||
},
|
||||
"scheduler.2" : {
|
||||
"type":"DWRR",
|
||||
"weight": "20"
|
||||
}
|
||||
},
|
||||
"PORT_QOS_MAP": {
|
||||
"Ethernet0,Ethernet4,Ethernet8,Ethernet12,Ethernet16,Ethernet20,Ethernet24,Ethernet28,Ethernet32,Ethernet36,Ethernet40,Ethernet44,Ethernet48,Ethernet52,Ethernet56,Ethernet60,Ethernet64,Ethernet68,Ethernet72,Ethernet76,Ethernet80,Ethernet84,Ethernet88,Ethernet92,Ethernet96,Ethernet100,Ethernet104,Ethernet108,Ethernet112,Ethernet116,Ethernet120,Ethernet124,Ethernet128,Ethernet132,Ethernet136,Ethernet140,Ethernet144,Ethernet148,Ethernet152,Ethernet156,Ethernet160,Ethernet164,Ethernet168,Ethernet172,Ethernet176,Ethernet180,Ethernet184,Ethernet188,Ethernet192,Ethernet196,Ethernet200,Ethernet204,Ethernet208,Ethernet212": {
|
||||
"dscp_to_tc_map" : "[DSCP_TO_TC_MAP|AZURE]",
|
||||
"tc_to_queue_map" : "[TC_TO_QUEUE_MAP|AZURE]",
|
||||
"tc_to_pg_map" : "[TC_TO_PRIORITY_GROUP_MAP|AZURE]",
|
||||
"pfc_to_queue_map": "[MAP_PFC_PRIORITY_TO_QUEUE|AZURE]",
|
||||
"pfc_enable": "3,4"
|
||||
}
|
||||
},
|
||||
"WRED_PROFILE": {
|
||||
"AZURE_LOSSLESS" : {
|
||||
"wred_green_enable":"true",
|
||||
"wred_yellow_enable":"true",
|
||||
"wred_red_enable":"true",
|
||||
"ecn":"ecn_all",
|
||||
"red_max_threshold":"312000",
|
||||
"red_min_threshold":"104000",
|
||||
"yellow_max_threshold":"312000",
|
||||
"yellow_min_threshold":"104000",
|
||||
"green_max_threshold":"312000",
|
||||
"green_min_threshold":"104000"
|
||||
}
|
||||
},
|
||||
"QUEUE": {
|
||||
"Ethernet0,Ethernet4,Ethernet8,Ethernet12,Ethernet16,Ethernet20,Ethernet24,Ethernet28,Ethernet32,Ethernet36,Ethernet40,Ethernet44,Ethernet48,Ethernet52,Ethernet56,Ethernet60,Ethernet64,Ethernet68,Ethernet72,Ethernet76,Ethernet80,Ethernet84,Ethernet88,Ethernet92,Ethernet96,Ethernet100,Ethernet104,Ethernet108,Ethernet112,Ethernet116,Ethernet120,Ethernet124,Ethernet128,Ethernet132,Ethernet136,Ethernet140,Ethernet144,Ethernet148,Ethernet152,Ethernet156,Ethernet160,Ethernet164,Ethernet168,Ethernet172,Ethernet176,Ethernet180,Ethernet184,Ethernet188,Ethernet192,Ethernet196,Ethernet200,Ethernet204,Ethernet208,Ethernet212|3-4" : {
|
||||
"scheduler" : "[SCHEDULER|scheduler.0]",
|
||||
"wred_profile" : "[WRED_PROFILE|AZURE_LOSSLESS]"
|
||||
},
|
||||
"Ethernet0,Ethernet4,Ethernet8,Ethernet12,Ethernet16,Ethernet20,Ethernet24,Ethernet28,Ethernet32,Ethernet36,Ethernet40,Ethernet44,Ethernet48,Ethernet52,Ethernet56,Ethernet60,Ethernet64,Ethernet68,Ethernet72,Ethernet76,Ethernet80,Ethernet84,Ethernet88,Ethernet92,Ethernet96,Ethernet100,Ethernet104,Ethernet108,Ethernet112,Ethernet116,Ethernet120,Ethernet124,Ethernet128,Ethernet132,Ethernet136,Ethernet140,Ethernet144,Ethernet148,Ethernet152,Ethernet156,Ethernet160,Ethernet164,Ethernet168,Ethernet172,Ethernet176,Ethernet180,Ethernet184,Ethernet188,Ethernet192,Ethernet196,Ethernet200,Ethernet204,Ethernet208,Ethernet212|0" : {
|
||||
"scheduler" : "[SCHEDULER|scheduler.1]"
|
||||
},
|
||||
"Ethernet0,Ethernet4,Ethernet8,Ethernet12,Ethernet16,Ethernet20,Ethernet24,Ethernet28,Ethernet32,Ethernet36,Ethernet40,Ethernet44,Ethernet48,Ethernet52,Ethernet56,Ethernet60,Ethernet64,Ethernet68,Ethernet72,Ethernet76,Ethernet80,Ethernet84,Ethernet88,Ethernet92,Ethernet96,Ethernet100,Ethernet104,Ethernet108,Ethernet112,Ethernet116,Ethernet120,Ethernet124,Ethernet128,Ethernet132,Ethernet136,Ethernet140,Ethernet144,Ethernet148,Ethernet152,Ethernet156,Ethernet160,Ethernet164,Ethernet168,Ethernet172,Ethernet176,Ethernet180,Ethernet184,Ethernet188,Ethernet192,Ethernet196,Ethernet200,Ethernet204,Ethernet208,Ethernet212|1" : {
|
||||
"scheduler" : "[SCHEDULER|scheduler.2]"
|
||||
}
|
||||
}
|
||||
}
|
@ -93,7 +93,6 @@
|
||||
<PngDec>
|
||||
<DeviceInterfaceLinks>
|
||||
<DeviceLinkBase i:type="DeviceInterfaceLink">
|
||||
<Bandwidth>40000</Bandwidth>
|
||||
<ElementType>DeviceInterfaceLink</ElementType>
|
||||
<EndDevice>OCPSCH0104001MS</EndDevice>
|
||||
<EndPort>Ethernet24</EndPort>
|
||||
@ -101,7 +100,6 @@
|
||||
<StartPort>Ethernet0</StartPort>
|
||||
</DeviceLinkBase>
|
||||
<DeviceLinkBase i:type="DeviceInterfaceLink">
|
||||
<Bandwidth>40000</Bandwidth>
|
||||
<ElementType>DeviceInterfaceLink</ElementType>
|
||||
<EndDevice>OCPSCH0104002MS</EndDevice>
|
||||
<EndPort>Ethernet24</EndPort>
|
||||
|
44
device/inventec/x86_64-inventec_d7054q28b-r0/sensors.conf
Normal file
44
device/inventec/x86_64-inventec_d7054q28b-r0/sensors.conf
Normal file
@ -0,0 +1,44 @@
|
||||
# libsensors configuration file
|
||||
chip "inv_psoc-*"
|
||||
label temp1 "FrontSide Temperature"
|
||||
label temp2 "FanBoard Temperature"
|
||||
label temp3 "NearASIC Temperature"
|
||||
label temp4 "NearPSU Temperature"
|
||||
label temp5 "CPU Board Temperature"
|
||||
label temp6 "ASIC Temperature"
|
||||
label temp7 "PSU1 Temperature1"
|
||||
label temp8 "PSU2 Temperature1"
|
||||
label temp9 "PSU1 Temperature2"
|
||||
label temp10 "PSU2 Temperature2"
|
||||
label fan1 "FanModule1 Front RPM"
|
||||
label fan2 "FanModule1 Rear RPM"
|
||||
label fan3 "FanModule2 Front RPM"
|
||||
label fan4 "FanModule2 Rear RPM"
|
||||
label fan5 "FanModule3 Front RPM"
|
||||
label fan6 "FanModule3 Rear RPM"
|
||||
label fan7 "FanModule4 Front RPM"
|
||||
label fan8 "FanModule4 Rear RPM"
|
||||
label fan9 "FanModule5 Front RPM"
|
||||
label fan10 "FanModule5 Rear RPM"
|
||||
label pwm1 "FanModule1 PWM"
|
||||
label pwm2 "FanModule2 PWM"
|
||||
label pwm3 "FanModule3 PWM"
|
||||
label pwm4 "FanModule4 PWM"
|
||||
label pwm5 "FanModule5 PWM"
|
||||
label pwm6 "PSU1 FAN PWM"
|
||||
label pwm7 "PSU2 FAN PWM"
|
||||
label fan11 "PSU1 FAN RPM"
|
||||
label fan12 "PSU2 FAN RPM"
|
||||
label in1 "PSU1 Input Voltage"
|
||||
label in2 "PSU2 Input Voltage"
|
||||
label curr1 "PSU1 Input Current"
|
||||
label curr2 "PSU2 Input Current"
|
||||
label power1 "PSU1 Input Power"
|
||||
label power2 "PSU2 Input Power"
|
||||
label in3 "PSU1 Output Voltage"
|
||||
label in4 "PSU2 Output Voltage"
|
||||
label curr3 "PSU1 Output Current"
|
||||
label curr4 "PSU2 Output Current"
|
||||
label power3 "PSU1 Output Power"
|
||||
label power4 "PSU2 Output Power"
|
||||
|
@ -15,12 +15,12 @@ portmap_135=263:10
|
||||
|
||||
# 64 ports config for 100G
|
||||
# For Tomahawk FalconCore:
|
||||
# Physical ports in FalconCore[0 - 15] must map to logical port[1 - 32] at any order
|
||||
# Physical ports in FalconCore[16 - 31] must map to logical port[34 - 65] at any order
|
||||
# Physical ports in FalconCore[32 - 47] must map to logical port[68 - 99] at any order
|
||||
# Physical ports in FalconCore[48 - 63] must map to logical port[102 - 133] at any order
|
||||
#Physical ports in FalconCore[0-15] must map to logical port[1-32] at any order
|
||||
#Physical ports in FalconCore[16-31] must map to logical port[34-65] at any order
|
||||
#Physical ports in FalconCore[32-47] must map to logical port[68-99] at any order
|
||||
#Physical ports in FalconCore[48-63] must map to logical port[102-133] at any order
|
||||
|
||||
## FalconCore[0 - 15]
|
||||
## FalconCore[0-15]
|
||||
portmap_1=9:100
|
||||
portmap_2=1:100
|
||||
portmap_3=13:100
|
||||
@ -38,7 +38,7 @@ portmap_14=49:100
|
||||
portmap_15=61:100
|
||||
portmap_16=53:100
|
||||
|
||||
## FalconCore[16 - 31]
|
||||
## FalconCore[16-31]
|
||||
portmap_34=73:100
|
||||
portmap_35=65:100
|
||||
portmap_36=77:100
|
||||
@ -839,3 +839,72 @@ dport_map_port_112=114
|
||||
dport_map_port_113=115
|
||||
dport_map_port_114=48
|
||||
dport_map_port_115=49
|
||||
|
||||
## ce
|
||||
## POST: 24(18) MAIN: 62(3E) PRE: 8(08)
|
||||
serdes_preemphasis_1=0x183E08
|
||||
serdes_preemphasis_2=0x193E08
|
||||
serdes_preemphasis_5=0x173E08
|
||||
serdes_preemphasis_6=0x173E08
|
||||
serdes_preemphasis_9=0x163E07
|
||||
serdes_preemphasis_10=0x173E08
|
||||
serdes_preemphasis_13=0x154007
|
||||
serdes_preemphasis_14=0x154007
|
||||
serdes_preemphasis_34=0x134007
|
||||
serdes_preemphasis_35=0x144007
|
||||
serdes_preemphasis_38=0x133F07
|
||||
serdes_preemphasis_39=0x133F07
|
||||
serdes_preemphasis_42=0x133F07
|
||||
serdes_preemphasis_43=0x133F06
|
||||
serdes_preemphasis_46=0x113E06
|
||||
serdes_preemphasis_47=0x113E05
|
||||
serdes_preemphasis_68=0x103F06
|
||||
serdes_preemphasis_69=0x103F06
|
||||
serdes_preemphasis_72=0x113F06
|
||||
serdes_preemphasis_73=0x103F06
|
||||
serdes_preemphasis_76=0x124006
|
||||
serdes_preemphasis_77=0x124006
|
||||
serdes_preemphasis_80=0x144007
|
||||
serdes_preemphasis_81=0x144007
|
||||
serdes_preemphasis_102=0x144007
|
||||
serdes_preemphasis_103=0x144007
|
||||
serdes_preemphasis_106=0x153F08
|
||||
serdes_preemphasis_107=0x153F08
|
||||
serdes_preemphasis_110=0x164008
|
||||
serdes_preemphasis_111=0x164008
|
||||
serdes_preemphasis_114=0x184008
|
||||
serdes_preemphasis_115=0x184008
|
||||
serdes_preemphasis_3=0x184108
|
||||
serdes_preemphasis_4=0x184108
|
||||
serdes_preemphasis_7=0x173F08
|
||||
serdes_preemphasis_8=0x174108
|
||||
serdes_preemphasis_11=0x154007
|
||||
serdes_preemphasis_12=0x154007
|
||||
serdes_preemphasis_15=0x144007
|
||||
serdes_preemphasis_16=0x144007
|
||||
serdes_preemphasis_36=0x133F07
|
||||
serdes_preemphasis_37=0x133F07
|
||||
serdes_preemphasis_40=0x133F07
|
||||
serdes_preemphasis_41=0x123F07
|
||||
serdes_preemphasis_44=0x113F07
|
||||
serdes_preemphasis_45=0x113F07
|
||||
serdes_preemphasis_48=0x113F06
|
||||
serdes_preemphasis_49=0x103F06
|
||||
serdes_preemphasis_70=0x113F06
|
||||
serdes_preemphasis_71=0x103F06
|
||||
serdes_preemphasis_74=0x113F06
|
||||
serdes_preemphasis_75=0x113F06
|
||||
serdes_preemphasis_78=0x123F07
|
||||
serdes_preemphasis_79=0x134007
|
||||
serdes_preemphasis_82=0x144007
|
||||
serdes_preemphasis_83=0x144007
|
||||
serdes_preemphasis_104=0x164007
|
||||
serdes_preemphasis_105=0x154107
|
||||
serdes_preemphasis_108=0x174107
|
||||
serdes_preemphasis_109=0x163F07
|
||||
serdes_preemphasis_112=0x194107
|
||||
serdes_preemphasis_113=0x174107
|
||||
serdes_preemphasis_116=0x1B4108
|
||||
serdes_preemphasis_117=0x194108
|
||||
|
||||
|
||||
|
44
device/inventec/x86_64-inventec_d7264q28b-r0/sensors.conf
Normal file
44
device/inventec/x86_64-inventec_d7264q28b-r0/sensors.conf
Normal file
@ -0,0 +1,44 @@
|
||||
# libsensors configuration file
|
||||
chip "inv_psoc-*"
|
||||
label temp1 "FrontSide Temperature"
|
||||
label temp2 "FanBoard Temperature"
|
||||
label temp3 "NearASIC Temperature"
|
||||
label temp4 "Center(U10) Temperature"
|
||||
label temp5 "CPU Board Temperature"
|
||||
label temp6 "ASIC Temperature"
|
||||
label temp7 "PSU1 Temperature1"
|
||||
label temp8 "PSU2 Temperature1"
|
||||
label temp9 "PSU1 Temperature2"
|
||||
label temp10 "PSU2 Temperature2"
|
||||
label fan1 "FanModule1 Front RPM"
|
||||
label fan2 "FanModule1 Rear RPM"
|
||||
label fan3 "FanModule2 Front RPM"
|
||||
label fan4 "FanModule2 Rear RPM"
|
||||
label fan5 "FanModule3 Front RPM"
|
||||
label fan6 "FanModule3 Rear RPM"
|
||||
label fan7 "FanModule4 Front RPM"
|
||||
label fan8 "FanModule4 Rear RPM"
|
||||
label fan9 "FanModule5 Front RPM"
|
||||
label fan10 "FanModule5 Rear RPM"
|
||||
label pwm1 "FanModule1 PWM"
|
||||
label pwm2 "FanModule2 PWM"
|
||||
label pwm3 "FanModule3 PWM"
|
||||
label pwm4 "FanModule4 PWM"
|
||||
label pwm5 "FanModule5 PWM"
|
||||
label pwm6 "PSU1 FAN PWM"
|
||||
label pwm7 "PSU2 FAN PWM"
|
||||
label fan11 "PSU1 FAN RPM"
|
||||
label fan12 "PSU2 FAN RPM"
|
||||
label in1 "PSU1 Input Voltage"
|
||||
label in2 "PSU2 Input Voltage"
|
||||
label curr1 "PSU1 Input Current"
|
||||
label curr2 "PSU2 Input Current"
|
||||
label power1 "PSU1 Input Power"
|
||||
label power2 "PSU2 Input Power"
|
||||
label in3 "PSU1 Output Voltage"
|
||||
label in4 "PSU2 Output Voltage"
|
||||
label curr3 "PSU1 Output Current"
|
||||
label curr4 "PSU2 Output Current"
|
||||
label power3 "PSU1 Output Power"
|
||||
label power4 "PSU2 Output Power"
|
||||
|
@ -1,11 +1,15 @@
|
||||
# Inventec d7032q28b , d7054q28b and d7264q28b Platform modules
|
||||
# Inventec platform modules
|
||||
|
||||
INVENTEC_D7032Q28B_PLATFORM_MODULE_VERSION = 1.1.0
|
||||
INVENTEC_D7054Q28B_PLATFORM_MODULE_VERSION = 1.1.0
|
||||
INVENTEC_D6254QS_PLATFORM_MODULE_VERSION = 1.1.0
|
||||
INVENTEC_D6556_PLATFORM_MODULE_VERSION = 1.1.0
|
||||
INVENTEC_D7264Q28B_PLATFORM_MODULE_VERSION = 1.1.0
|
||||
|
||||
export INVENTEC_D7032Q28B_PLATFORM_MODULE_VERSION
|
||||
export INVENTEC_D7054Q28B_PLATFORM_MODULE_VERSION
|
||||
export INVENTEC_D6254QS_PLATFORM_MODULE_VERSION
|
||||
export INVENTEC_D6556_PLATFORM_MODULE_VERSION
|
||||
export INVENTEC_D7264Q28B_PLATFORM_MODULE_VERSION
|
||||
|
||||
INVENTEC_D7032Q28B_PLATFORM_MODULE = platform-modules-d7032q28b_$(INVENTEC_D7032Q28B_PLATFORM_MODULE_VERSION)_amd64.deb
|
||||
@ -18,6 +22,14 @@ INVENTEC_D7054Q28B_PLATFORM_MODULE = platform-modules-d7054q28b_$(INVENTEC_D7054
|
||||
$(INVENTEC_D7054Q28B_PLATFORM_MODULE)_PLATFORM = x86_64-inventec_d7054q28b-r0
|
||||
$(eval $(call add_extra_package,$(INVENTEC_D7032Q28B_PLATFORM_MODULE),$(INVENTEC_D7054Q28B_PLATFORM_MODULE)))
|
||||
|
||||
INVENTEC_D6254QS_PLATFORM_MODULE = platform-modules-d6254qs_$(INVENTEC_D6254QS_PLATFORM_MODULE_VERSION)_amd64.deb
|
||||
$(INVENTEC_D6254QS_PLATFORM_MODULE)_PLATFORM = x86_64-inventec_d6254qs-r0
|
||||
$(eval $(call add_extra_package,$(INVENTEC_D7032Q28B_PLATFORM_MODULE),$(INVENTEC_D6254QS_PLATFORM_MODULE)))
|
||||
|
||||
INVENTEC_D6556_PLATFORM_MODULE = platform-modules-d6556_$(INVENTEC_D6556_PLATFORM_MODULE_VERSION)_amd64.deb
|
||||
$(INVENTEC_D6556_PLATFORM_MODULE)_PLATFORM = x86_64-inventec_d6556-r0
|
||||
$(eval $(call add_extra_package,$(INVENTEC_D7032Q28B_PLATFORM_MODULE),$(INVENTEC_D6556_PLATFORM_MODULE)))
|
||||
|
||||
INVENTEC_D7264Q28B_PLATFORM_MODULE = platform-modules-d7264q28b_$(INVENTEC_D7264Q28B_PLATFORM_MODULE_VERSION)_amd64.deb
|
||||
$(INVENTEC_D7264Q28B_PLATFORM_MODULE)_PLATFORM = x86_64-inventec_d7264q28b-r0
|
||||
$(eval $(call add_extra_package,$(INVENTEC_D7032Q28B_PLATFORM_MODULE),$(INVENTEC_D7264Q28B_PLATFORM_MODULE)))
|
||||
|
126
platform/broadcom/sonic-platform-modules-inventec/common/utils/asic_monitor.py
Executable file
126
platform/broadcom/sonic-platform-modules-inventec/common/utils/asic_monitor.py
Executable file
@ -0,0 +1,126 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (C) 2018 Inventec, Inc.
|
||||
#
|
||||
# Editor: James Huang ( Huang.James@inventec.com )
|
||||
#
|
||||
"""
|
||||
Usage: %(scriptName)s [options] command object
|
||||
|
||||
Auto detecting the Chipset temperature and update
|
||||
|
||||
options:
|
||||
-h | --help : this help message
|
||||
-d | --debug : run with debug mode
|
||||
|
||||
"""
|
||||
|
||||
try:
|
||||
import os
|
||||
import commands
|
||||
import sys, getopt
|
||||
import logging
|
||||
import re
|
||||
import time
|
||||
import syslog
|
||||
from sonic_sfp.bcmshell import bcmshell
|
||||
|
||||
except ImportError as e:
|
||||
raise ImportError("%s - required module not found" % str(e))
|
||||
|
||||
args = []
|
||||
INV_REDWOOD_PLATFORM = "SONiC-Inventec-d7032-100"
|
||||
INV_CYPRESS_PLATFORM = "SONiC-Inventec-d7054"
|
||||
INV_SEQUOIA_PLATFORM = "SONiC-Inventec-d7264"
|
||||
INV_MAPLE_PLATFORM = "SONiC-Inventec-d6556"
|
||||
INV_MAGNOLIA_PLATFORM = "SONiC-Inventec-d6254qs"
|
||||
|
||||
PSOC_NAME = "name"
|
||||
HWMON_PATH = "/sys/class/hwmon/"
|
||||
SWITCH_TEMP_FILE_NAME = "switch_tmp"
|
||||
|
||||
def log_message( level, string ):
|
||||
syslog.openlog("asic_monitor", syslog.LOG_PID, facility=syslog.LOG_DAEMON)
|
||||
syslog.syslog( level, string )
|
||||
|
||||
def initialLoop():
|
||||
|
||||
global bcm_obj
|
||||
initialNotOK = True
|
||||
|
||||
while initialNotOK :
|
||||
try:
|
||||
bcm_obj = BCMUtil()
|
||||
bcm_obj.execute_command("echo")
|
||||
initialNotOK = False
|
||||
print bcm_obj
|
||||
log_message( syslog.LOG_INFO, "BCMUtil Object initialed successfully" )
|
||||
except Exception, e:
|
||||
print "Exception. The warning is {0}".format(str(e))
|
||||
time.sleep(10)
|
||||
|
||||
class BCMUtil(bcmshell):
|
||||
|
||||
asic_temperature = 0
|
||||
platform = None
|
||||
|
||||
def get_platform(self):
|
||||
if self.platform is None:
|
||||
self.platform = os.popen("uname -n").read().strip()
|
||||
return self.platform
|
||||
|
||||
def get_asic_temperature( self ):
|
||||
return self.asic_temperature
|
||||
|
||||
def set_asic_temperature( self, temp ):
|
||||
self.asic_temperature = temp
|
||||
|
||||
def parsing_asic_temp(self):
|
||||
content = self.run("show temp")
|
||||
for line in content.split("\n"):
|
||||
TempObject = re.search(r"(average current temperature is)\s+(?P<temperature_high>\d+)\.(?P<temperature_low>\d+)",line)
|
||||
if TempObject is not None:
|
||||
self.set_asic_temperature( int( TempObject.group("temperature_high") ) )
|
||||
|
||||
def execute_command(self, cmd):
|
||||
return self.run(cmd)
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
global bcm_obj
|
||||
initialLoop()
|
||||
log_message( syslog.LOG_INFO, "Object initialed successfully" )
|
||||
|
||||
while 1 :
|
||||
try:
|
||||
bcm_obj.parsing_asic_temp()
|
||||
for index in os.listdir(HWMON_PATH):
|
||||
file_list = os.listdir("{0}/{1}/device/".format(HWMON_PATH,index))
|
||||
if PSOC_NAME in file_list :
|
||||
with open( "{0}/{1}/device/{2}".format(HWMON_PATH, index, PSOC_NAME), 'rb') as readPtr:
|
||||
content = readPtr.read().strip()
|
||||
if bcm_obj.get_platform() == INV_SEQUOIA_PLATFORM :
|
||||
if content == "inv_bmc" and SWITCH_TEMP_FILE_NAME in file_list :
|
||||
os.system("echo {0} > {1}/{2}/device/{3}".format( ( bcm_obj.get_asic_temperature() * 1000 ), HWMON_PATH, index, SWITCH_TEMP_FILE_NAME ))
|
||||
break
|
||||
else :
|
||||
if content == "inv_psoc" and SWITCH_TEMP_FILE_NAME in file_list :
|
||||
print "echo {0} > {1}/{2}/device/{3}".format( ( bcm_obj.get_asic_temperature() * 1000 ), HWMON_PATH, index, SWITCH_TEMP_FILE_NAME )
|
||||
os.system("echo {0} > {1}/{2}/device/{3}".format( ( bcm_obj.get_asic_temperature() * 1000 ), HWMON_PATH, index, SWITCH_TEMP_FILE_NAME ))
|
||||
break
|
||||
except Exception, e:
|
||||
log_message( syslog.LOG_WARNING, "Exception. The warning is {0}".format(str(e)) )
|
||||
initialLoop()
|
||||
time.sleep(5)
|
||||
|
||||
syslog.closelog()
|
||||
del bcm_obj
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -1,5 +1,19 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (C) 2018 Inventec, 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/>.
|
||||
|
||||
import os
|
||||
import time
|
||||
@ -7,20 +21,28 @@ import syslog
|
||||
import re
|
||||
from sonic_sfp.bcmshell import bcmshell
|
||||
|
||||
|
||||
# =====================================================================
|
||||
# global variable init
|
||||
# =====================================================================
|
||||
|
||||
# port object
|
||||
PORT_LIST = []
|
||||
# object is to execute bcm shell command
|
||||
BCM_SHELL = None
|
||||
SHELL_READY = False
|
||||
# port status that is auto update by chip in data ram
|
||||
STATUS_RX = 1<<0
|
||||
STATUS_TX = 1<<1
|
||||
# define data ram address
|
||||
PORT_DATA_OFFSET_ADDR = 0xA0
|
||||
PORT_DATA_START_ADDR = 0xF2
|
||||
TOTAL_SCAN_BITS_ADDR = 0xF4
|
||||
SYNC_START_LEN_ADDR = 0xF6
|
||||
SYNC_STOP_LEN_ADDR = 0xF8
|
||||
# bit streaming rule for CPLD decode
|
||||
TOTAL_SCAN_BITS = None
|
||||
SYNC_S = None
|
||||
SYNC_P = None
|
||||
# define board type
|
||||
INV_MAGNOLIA = "SONiC-Inventec-d6254qs"
|
||||
INV_REDWOOD = "SONiC-Inventec-d7032-100"
|
||||
INV_CYPRESS = "SONiC-Inventec-d7054"
|
||||
INV_MAPLE = "SONiC-Inventec-d6556"
|
||||
INV_SEQUOIA = ""
|
||||
BOARD_TPYE = ""
|
||||
EAGLE_CORE = []
|
||||
# define port data for bit streaming
|
||||
BIT_LINK = None
|
||||
BIT_FAULT = None
|
||||
@ -33,86 +55,41 @@ SPEED_100G = 100
|
||||
SPEED_40G = 40
|
||||
SPEED_25G = 25
|
||||
SPEED_10G = 10
|
||||
# the amount of LED processor
|
||||
AMOUNT_LED_UP = None
|
||||
# define board type
|
||||
INV_REDWOOD = "SONiC-Inventec-d7032-100"
|
||||
INV_CYPRESS = "SONiC-Inventec-d7054"
|
||||
INV_SEQUOIA = ""
|
||||
BOARD_TPYE = ""
|
||||
EAGLE_CORE = []
|
||||
|
||||
PORT_LIST = []
|
||||
|
||||
# port status that is auto update by chip in data ram
|
||||
# there are two byte to indicate each port status
|
||||
'''
|
||||
RX equ 0x0 ; received packet
|
||||
TX equ 0x1 ; transmitted packet
|
||||
COLL equ 0x2 ; collision indicator
|
||||
SPEED_C equ 0x3 ; 100 Mbps
|
||||
SPEED_M equ 0x4 ; 1000 Mbps
|
||||
DUPLEX equ 0x5 ; half/full duplex
|
||||
FLOW equ 0x6 ; flow control capable
|
||||
LINKUP equ 0x7 ; link down/up status
|
||||
LINKEN equ 0x8 ; link disabled/enabled status
|
||||
ZERO equ 0xE ; always 0
|
||||
ONE equ 0xF ; always 1
|
||||
'''
|
||||
STATUS_ENABLE = 1<<0
|
||||
STATUS_RX = 1<<0
|
||||
STATUS_TX = 1<<1
|
||||
|
||||
# object is to execute bcm shell command
|
||||
BCM_SHELL = None
|
||||
|
||||
|
||||
|
||||
# =====================================================================
|
||||
# class object
|
||||
# =====================================================================
|
||||
class Led():
|
||||
class Port():
|
||||
|
||||
up = None
|
||||
pfw = None
|
||||
port_num = None
|
||||
name = None
|
||||
bcm_id = None
|
||||
led_up = None
|
||||
s_addr = None
|
||||
write2_up = None
|
||||
led_index = None
|
||||
link_status = None
|
||||
speed = None
|
||||
|
||||
def __init__(self, led_number, program_fw):
|
||||
self.up = led_number
|
||||
self.pfw = program_fw
|
||||
def write_data_ram(self, data):
|
||||
BCM_SHELL.cmd("setreg CMIC_LEDUP{0}_DATA_RAM({1}) {2}".format(self.write2_up, self.led_index, data))
|
||||
|
||||
def led_start(self):
|
||||
BCM_SHELL.cmd("led {0} start".format(self.up))
|
||||
syslog.syslog(syslog.LOG_INFO, "Start Led({0})".format(self.up))
|
||||
|
||||
def led_stop(self):
|
||||
BCM_SHELL.cmd("led {0} stop".format(self.up))
|
||||
syslog.syslog(syslog.LOG_INFO, "Stop Led({0})".format(self.up))
|
||||
|
||||
def load_prog(self):
|
||||
BCM_SHELL.cmd("led {0} prog {1}".format(self.up, self.pfw))
|
||||
syslog.syslog(syslog.LOG_INFO, "Load Led({0}) program firmware".format(self.up))
|
||||
|
||||
def write_port_data(self, addr, data):
|
||||
BCM_SHELL.cmd("setreg CMIC_LEDUP{0}_DATA_RAM({1}) {2}".format(self.up, addr, data))
|
||||
#syslog.syslog(syslog.LOG_DEBUG, "Write Led({0}) data_ram({1}): {2}".format(self.up, addr, data))
|
||||
|
||||
def read_data_ram(self, offset):
|
||||
return_string = BCM_SHELL.run("getreg CMIC_LEDUP{0}_DATA_RAM({1})".format(self.up, offset))
|
||||
for line in return_string.split("\n"):
|
||||
re_obj = re.search(r"\<DATA\=(?P<data>.+)\>",line)
|
||||
def read_data_ram(self):
|
||||
r_string = BCM_SHELL.run("getreg CMIC_LEDUP{0}_DATA_RAM({1})".format(self.led_up, self.s_addr))
|
||||
for line in r_string.split("\n"):
|
||||
re_obj = re.search(r"\<DATA\=(?P<data>.+)\>", line)
|
||||
if re_obj is not None:
|
||||
#syslog.syslog(syslog.LOG_DEBUG, "Read Led({0}) data_ram({1}): {2}".format(self.up, offset, re_obj.group("data")))
|
||||
#syslog.syslog(syslog.LOG_DEBUG, "Read Led({0}) data_ram({1}): {2}".format(self.up, addr, re_obj.group("data")))
|
||||
return int(re_obj.group("data"), 16)
|
||||
|
||||
return None
|
||||
|
||||
|
||||
# =====================================================================
|
||||
# Function
|
||||
# =====================================================================
|
||||
def _remap_registers():
|
||||
def _remap_registers(fp):
|
||||
|
||||
fp = open('/usr/share/sonic/device/x86_64-inventec_d7032q28b-r0/led_proc_init.soc', "r")
|
||||
content = fp.readlines()
|
||||
fp.close()
|
||||
err = False
|
||||
@ -125,60 +102,13 @@ def _remap_registers():
|
||||
syslog.syslog(syslog.LOG_ERR, "remap register abnormal: {0}".format(str(e)))
|
||||
|
||||
if not err:
|
||||
pass
|
||||
#syslog.syslog(syslog.LOG_DEBUG, "remap Led registers successfully")
|
||||
syslog.syslog(syslog.LOG_INFO, "remap Led registers successfully")
|
||||
|
||||
|
||||
|
||||
def _update_port_list():
|
||||
|
||||
global PORT_LIST
|
||||
PORT_LIST = []
|
||||
number = 0
|
||||
count = 0
|
||||
|
||||
content = BCM_SHELL.run("ps")
|
||||
for line in content.split("\n"):
|
||||
re_obj = re.search(r"(?P<port_name>(xe|ce)\d+)\(\s*(?P<bcm_id>\d+)\)\s+(?P<link>(up|down|!ena)).+\s+(?P<speed>\d+)G",line)
|
||||
if re_obj is not None:
|
||||
if int(re_obj.group("bcm_id")) not in EAGLE_CORE:
|
||||
PORT_LIST.append({"port_id":number, "name":re_obj.group("port_name"), "bcm_id":int(re_obj.group("bcm_id")), "link":re_obj.group("link"), "speed":int(re_obj.group("speed"))})
|
||||
number += 1
|
||||
|
||||
content = BCM_SHELL.run("led status")
|
||||
for line in content.split("\n"):
|
||||
re_obj = re.search(r"(?P<bcm_id>\d+).+(?P<led_up>\d)\:(?P<offset>\d+)",line)
|
||||
if re_obj is not None:
|
||||
if int(re_obj.group("bcm_id")) not in EAGLE_CORE:
|
||||
PORT_LIST[count]["led_up"] = int(re_obj.group("led_up"))
|
||||
PORT_LIST[count]["offset"] = int(re_obj.group("offset"))
|
||||
count += 1
|
||||
|
||||
if number is not count:
|
||||
PORT_LIST = []
|
||||
syslog.syslog(syslog.LOG_ERR, "The amount of port is not match")
|
||||
else:
|
||||
pass
|
||||
#syslog.syslog(syslog.LOG_DEBUG, "update port list successfully")
|
||||
|
||||
|
||||
|
||||
def _lookup_led_index(p):
|
||||
|
||||
index = 0
|
||||
for port in PORT_LIST:
|
||||
if p["bcm_id"] == port["bcm_id"]:
|
||||
break
|
||||
if p["led_up"] == port["led_up"]:
|
||||
index += 1
|
||||
return index + PORT_DATA_OFFSET_ADDR
|
||||
|
||||
|
||||
|
||||
def _led_init():
|
||||
def _board_init():
|
||||
|
||||
global BOARD_TPYE
|
||||
global AMOUNT_LED_UP
|
||||
global BIT_LINK
|
||||
global BIT_FAULT
|
||||
global BIT_TX
|
||||
@ -193,24 +123,29 @@ def _led_init():
|
||||
cmd = "uname -n"
|
||||
platform = os.popen(cmd).read()
|
||||
|
||||
if platform.rstrip() == INV_REDWOOD:
|
||||
if platform.rstrip() == INV_MAGNOLIA:
|
||||
BOARD_TPYE = "inventec_d6254qs"
|
||||
BIT_RX = 1<<0 #0x01
|
||||
BIT_TX = 1<<1 #0x02
|
||||
BIT_SPEED1 = 1<<4 #0x10
|
||||
BIT_LINK = 1<<7 #0x80
|
||||
fp = open('/usr/share/sonic/device/x86_64-inventec_d6254qs-r0/led_proc_init.soc', "r")
|
||||
_remap_registers(fp)
|
||||
|
||||
elif platform.rstrip() == INV_REDWOOD:
|
||||
BOARD_TPYE = "inventec_d7032q28b"
|
||||
AMOUNT_LED_UP = 2
|
||||
BIT_RX = 1<<0 #0x01
|
||||
BIT_TX = 1<<1 #0x02
|
||||
BIT_SPEED0 = 1<<3 #0x08
|
||||
BIT_SPEED1 = 1<<4 #0x10
|
||||
BIT_FAULT = 1<<6 #0x40
|
||||
BIT_LINK = 1<<7 #0x80
|
||||
TOTAL_SCAN_BITS = 32*1*4
|
||||
SYNC_S = 15
|
||||
SYNC_P = 3
|
||||
EAGLE_CORE = [66, 100]
|
||||
_remap_registers()
|
||||
fp = open('/usr/share/sonic/device/x86_64-inventec_d7032q28b-r0/led_proc_init.soc', "r")
|
||||
_remap_registers(fp)
|
||||
|
||||
elif platform.rstrip() == INV_CYPRESS:
|
||||
BOARD_TPYE = "inventec_d7054q28b"
|
||||
AMOUNT_LED_UP = 2
|
||||
BIT_LINK = 1<<0 #0x01
|
||||
BIT_FAULT = 1<<1 #0x02
|
||||
BIT_SPEED0 = 1<<2 #0x04
|
||||
@ -218,97 +153,220 @@ def _led_init():
|
||||
|
||||
elif platform.rstrip() == INV_SEQUOIA:
|
||||
BOARD_TPYE = "inventec_d7264q28b"
|
||||
AMOUNT_LED_UP = 4
|
||||
|
||||
elif platform.rstrip() == INV_MAPLE:
|
||||
BOARD_TPYE = "inventec_d6556"
|
||||
fp = open('/usr/share/sonic/device/x86_64-inventec_d6556-r0/led_proc_init.soc', "r")
|
||||
_remap_registers(fp)
|
||||
#led process: m0 led process that is controlled by linkscan_led_fw.bin and custom_led.bin
|
||||
syslog.syslog(syslog.LOG_INFO, "Found device: {0}".format(BOARD_TPYE))
|
||||
exit(0)
|
||||
|
||||
else:
|
||||
BOARD_TPYE = "not found"
|
||||
syslog.syslog(syslog.LOG_ERR, "Found device: {0}".format(BOARD_TPYE))
|
||||
exit(0)
|
||||
|
||||
syslog.syslog(syslog.LOG_INFO, "Device: {0}".format(BOARD_TPYE))
|
||||
#syslog.syslog(syslog.LOG_DEBUG, "led_amount: {0}".format(AMOUNT_LED_UP))
|
||||
syslog.syslog(syslog.LOG_INFO, "Found device: {0}".format(BOARD_TPYE))
|
||||
|
||||
|
||||
|
||||
def _lookup_led_index(p):
|
||||
|
||||
index = 0
|
||||
if BOARD_TPYE == "inventec_d6254qs":
|
||||
if 0 <= p.port_num <= 47:
|
||||
index = p.port_num + (p.port_num / 4)
|
||||
p.write2_up = 0
|
||||
elif 48 <= p.port_num <= 71:
|
||||
index = p.port_num - 48
|
||||
p.write2_up = 1
|
||||
if p.led_up == 0:
|
||||
p.s_addr = p.port_num * 2
|
||||
elif p.led_up == 1:
|
||||
p.s_addr = (p.port_num - 36) * 2
|
||||
|
||||
elif BOARD_TPYE == "inventec_d7032q28b":
|
||||
p.write2_up = 0
|
||||
index = p.port_num
|
||||
if 0 <= p.port_num <= 7:
|
||||
p.s_addr = p.port_num * 8
|
||||
elif 8 <= p.port_num <= 23:
|
||||
p.s_addr = (p.port_num - 8) * 8
|
||||
elif 24 <= p.port_num <= 31:
|
||||
p.s_addr = (p.port_num - 16) * 8
|
||||
|
||||
else:
|
||||
p.write2_up = p.led_up
|
||||
for port in PORT_LIST:
|
||||
if p.bcm_id == port.bcm_id:
|
||||
break
|
||||
if p.led_up == port.led_up:
|
||||
index += 1
|
||||
|
||||
return PORT_DATA_OFFSET_ADDR + index
|
||||
|
||||
|
||||
def _update_port_list(only_update):
|
||||
|
||||
global PORT_LIST
|
||||
number = 0
|
||||
count = 0
|
||||
|
||||
content = BCM_SHELL.run("ps")
|
||||
for line in content.split("\n"):
|
||||
re_obj = re.search(r"(?P<port_name>(xe|ce)\d+)\(\s*(?P<bcm_id>\d+)\)\s+(?P<link>(up|down|!ena)).+\s+(?P<speed>\d+)G", line)
|
||||
if re_obj is not None:
|
||||
if int(re_obj.group("bcm_id")) not in EAGLE_CORE:
|
||||
if only_update:
|
||||
PORT_LIST[number].link_status = re_obj.group("link")
|
||||
else:
|
||||
# create port object while first time
|
||||
port_obj = Port()
|
||||
port_obj.port_num = number
|
||||
port_obj.name = re_obj.group("port_name")
|
||||
port_obj.bcm_id = int(re_obj.group("bcm_id"))
|
||||
port_obj.link_status = re_obj.group("link")
|
||||
port_obj.speed = int(re_obj.group("speed"))
|
||||
PORT_LIST.append(port_obj)
|
||||
number += 1
|
||||
|
||||
if not only_update:
|
||||
content = BCM_SHELL.run("led status")
|
||||
for line in content.split("\n"):
|
||||
re_obj = re.search(r"(?P<bcm_id>\d+).+(?P<led_up>\d)\:", line)
|
||||
if re_obj is not None:
|
||||
if int(re_obj.group("bcm_id")) not in EAGLE_CORE:
|
||||
PORT_LIST[count].led_up = int(re_obj.group("led_up"))
|
||||
PORT_LIST[count].led_index = _lookup_led_index(PORT_LIST[count])
|
||||
count += 1
|
||||
|
||||
if number is not count:
|
||||
PORT_LIST = []
|
||||
syslog.syslog(syslog.LOG_ERR, "The amount of port is not match")
|
||||
|
||||
|
||||
|
||||
def sync_bcmsh_socket():
|
||||
|
||||
global BCM_SHELL
|
||||
global SHELL_READY
|
||||
waitSyncd = True
|
||||
retryCount = 0
|
||||
|
||||
while waitSyncd:
|
||||
time.sleep(10)
|
||||
try:
|
||||
BCM_SHELL = bcmshell()
|
||||
BCM_SHELL.run("Echo")
|
||||
waitSyncd = False
|
||||
except Exception, e:
|
||||
print "{0}, Retry times({1})".format(str(e),retryCount)
|
||||
#syslog.syslog(syslog.LOG_DEBUG, "{0}, Retry times({1})".format(str(e),retryCount))
|
||||
retryCount += 1
|
||||
|
||||
syslog.syslog(syslog.LOG_INFO, "bcmshell socket create successfully")
|
||||
|
||||
if SHELL_READY is False:
|
||||
SHELL_READY = True
|
||||
return
|
||||
elif SHELL_READY is True:
|
||||
update_led_status()
|
||||
|
||||
|
||||
|
||||
def update_led_status():
|
||||
|
||||
led_thread = True # True/False (gate to turn on/off)
|
||||
reset_sec = 2
|
||||
count_down = 0
|
||||
queue_active = []
|
||||
port_data = None
|
||||
s_byte = None
|
||||
|
||||
|
||||
# thread for keeping update port status in data ram
|
||||
while led_thread:
|
||||
try:
|
||||
if count_down == 0:
|
||||
queue_active = []
|
||||
_update_port_list(1)
|
||||
for port in PORT_LIST:
|
||||
if port.link_status == "up":
|
||||
queue_active.append(port)
|
||||
else:
|
||||
port_data = 0
|
||||
port.write_data_ram(port_data)
|
||||
count_down = reset_sec
|
||||
else:
|
||||
for port in queue_active:
|
||||
port_data = 0
|
||||
|
||||
if BOARD_TPYE == "inventec_d6254qs":
|
||||
s_byte = port.read_data_ram()
|
||||
if s_byte&STATUS_RX:
|
||||
port_data |= BIT_RX
|
||||
if s_byte&STATUS_TX:
|
||||
port_data |= BIT_TX
|
||||
port_data |= BIT_LINK
|
||||
|
||||
elif BOARD_TPYE == "inventec_d7032q28b":
|
||||
s_byte = port.read_data_ram()
|
||||
if s_byte&STATUS_RX:
|
||||
port_data |= BIT_RX
|
||||
if s_byte&STATUS_TX:
|
||||
port_data |= BIT_TX
|
||||
if port.speed == SPEED_100G:
|
||||
port_data |= BIT_SPEED0
|
||||
port_data |= BIT_SPEED1
|
||||
elif port.speed == SPEED_40G:
|
||||
port_data |= BIT_SPEED1
|
||||
elif port.speed == SPEED_25G:
|
||||
port_data |= BIT_SPEED0
|
||||
else:
|
||||
pass
|
||||
port_data |= BIT_LINK
|
||||
|
||||
elif BOARD_TPYE == "inventec_d7054q28b":
|
||||
if port.speed != SPEED_100G and port.speed != SPEED_25G:
|
||||
port_data |= BIT_SPEED0
|
||||
|
||||
# write data to update data ram for specific port
|
||||
port.write_data_ram(port_data)
|
||||
|
||||
time.sleep(0.5)
|
||||
count_down -= 1
|
||||
|
||||
except Exception, e:
|
||||
syslog.syslog(syslog.LOG_WARNING, "{0}".format(str(e)))
|
||||
sync_bcmsh_socket()
|
||||
|
||||
|
||||
|
||||
def debug_print():
|
||||
|
||||
for port in PORT_LIST:
|
||||
output = ""
|
||||
output += "name:{0} | ".format(port.name)
|
||||
output += "port_num:{0} | ".format(port.port_num)
|
||||
output += "bcm_id:{0} | ".format(port.bcm_id)
|
||||
output += "link_status:{0} | ".format(port.link_status)
|
||||
output += "speed:{0} | ".format(port.speed)
|
||||
output += "led_up:{0} | ".format(port.led_up)
|
||||
output += "s_addr:{0} | ".format(port.s_addr)
|
||||
output += "write2_up:{0} | ".format(port.write2_up)
|
||||
output += "led_index:{0} | ".format(port.led_index)
|
||||
print output
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
waitSyncd = True
|
||||
retryCount = 0
|
||||
syslog.openlog("led_proc", syslog.LOG_PID, facility=syslog.LOG_DAEMON)
|
||||
|
||||
while waitSyncd:
|
||||
try:
|
||||
BCM_SHELL = bcmshell()
|
||||
waitSyncd = False
|
||||
except Exception, e:
|
||||
syslog.syslog(syslog.LOG_WARNING, "{0}, Retry times({1})".format(str(e),retryCount))
|
||||
retryCount += 1
|
||||
time.sleep(5)
|
||||
|
||||
|
||||
_led_init()
|
||||
led_obj = []
|
||||
for idx in range(AMOUNT_LED_UP):
|
||||
led_obj.append(Led(idx, ""))
|
||||
#syslog.syslog(syslog.LOG_DEBUG, "create object led({0}) successfully".format(idx))
|
||||
|
||||
if BOARD_TPYE == "inventec_d7032q28b":
|
||||
led_obj[idx].write_port_data(PORT_DATA_START_ADDR, PORT_DATA_OFFSET_ADDR)
|
||||
led_obj[idx].write_port_data(TOTAL_SCAN_BITS_ADDR, TOTAL_SCAN_BITS)
|
||||
led_obj[idx].write_port_data(SYNC_START_LEN_ADDR, SYNC_S)
|
||||
led_obj[idx].write_port_data(SYNC_STOP_LEN_ADDR, SYNC_P)
|
||||
|
||||
|
||||
reset_sec = 2
|
||||
count_down = 0
|
||||
queue_active = []
|
||||
port_data = None
|
||||
while True:
|
||||
if count_down == 0:
|
||||
queue_active = []
|
||||
_update_port_list()
|
||||
for port in PORT_LIST:
|
||||
if port["link"] == "up":
|
||||
queue_active.append(port)
|
||||
else:
|
||||
port_data = 0
|
||||
# redwood bit streaming for CPLD decode is only use led up0
|
||||
led_obj[0].write_port_data(PORT_DATA_OFFSET_ADDR + port["port_id"], port_data)
|
||||
count_down = reset_sec
|
||||
else:
|
||||
for port in queue_active:
|
||||
port_data = 0
|
||||
|
||||
if BOARD_TPYE == "inventec_d7032q28b":
|
||||
port_data |= BIT_LINK
|
||||
addr = 2*(port["offset"]-1)
|
||||
byte1 = led_obj[port["led_up"]].read_data_ram(addr)
|
||||
byte2 = led_obj[port["led_up"]].read_data_ram(addr+1)
|
||||
if byte1&STATUS_RX:
|
||||
port_data |= BIT_RX
|
||||
if byte1&STATUS_TX:
|
||||
port_data |= BIT_TX
|
||||
if port["speed"] == SPEED_100G:
|
||||
port_data |= BIT_SPEED0
|
||||
port_data |= BIT_SPEED1
|
||||
elif port["speed"] == SPEED_40G:
|
||||
port_data |= BIT_SPEED1
|
||||
elif port["speed"] == SPEED_25G:
|
||||
port_data |= BIT_SPEED0
|
||||
else:
|
||||
pass
|
||||
|
||||
# redwood bit streaming for CPLD decode is only use led up0
|
||||
led_obj[0].write_port_data(PORT_DATA_OFFSET_ADDR + port["port_id"], port_data)
|
||||
continue
|
||||
|
||||
elif BOARD_TPYE == "inventec_d7054q28b":
|
||||
if port["speed"] != SPEED_100G and port["speed"] != SPEED_25G:
|
||||
port_data |= BIT_SPEED0
|
||||
|
||||
led_index = _lookup_led_index(port)
|
||||
led_obj[port["led_up"]].write_port_data(led_index, port_data)
|
||||
|
||||
time.sleep(0.5)
|
||||
count_down -= 1
|
||||
sync_bcmsh_socket()
|
||||
_board_init()
|
||||
_update_port_list(0)
|
||||
#debug_print()
|
||||
update_led_status()
|
||||
|
||||
syslog.closelog()
|
||||
|
||||
|
@ -0,0 +1,64 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import socket
|
||||
from collections import OrderedDict
|
||||
|
||||
# Purpose: Shutdown DUT upon receiving thermaltrip event from kernel (inv_pthread)
|
||||
|
||||
NETLINK_KOBJECT_UEVENT = 15
|
||||
|
||||
class KernelEventMonitor(object):
|
||||
|
||||
def __init__(self):
|
||||
self.received_events = OrderedDict()
|
||||
self.socket = socket.socket(socket.AF_NETLINK, socket.SOCK_DGRAM, NETLINK_KOBJECT_UEVENT)
|
||||
|
||||
def start(self):
|
||||
self.socket.bind((os.getpid(), -1))
|
||||
|
||||
def stop(self):
|
||||
self.socket.close()
|
||||
|
||||
def __enter__(self):
|
||||
self.start()
|
||||
return self
|
||||
|
||||
def __exit__(self, exc_type, exc_value, traceback):
|
||||
self.stop()
|
||||
|
||||
def __iter__(self):
|
||||
while True:
|
||||
for item in monitor.next_events():
|
||||
yield item
|
||||
|
||||
def next_events(self):
|
||||
data = self.socket.recv(16384)
|
||||
event = {}
|
||||
for item in data.split(b'\x00'):
|
||||
if not item:
|
||||
#check if we have an event and if we already received it
|
||||
if event and event['SEQNUM'] not in self.received_events:
|
||||
self.received_events[event['SEQNUM']] = None
|
||||
if (len(self.received_events) > 100):
|
||||
self.received_events.popitem(last=False)
|
||||
yield event
|
||||
event = {}
|
||||
else:
|
||||
try:
|
||||
k, v = item.split(b'=', 1)
|
||||
event[k.decode('ascii')] = v.decode('ascii')
|
||||
except ValueError:
|
||||
pass
|
||||
|
||||
if __name__ == '__main__':
|
||||
with KernelEventMonitor() as monitor:
|
||||
for event in monitor:
|
||||
if event['SUBSYSTEM'] == 'platform_status':
|
||||
print('subsystem is platform_status')
|
||||
|
||||
# Receive thermaltrip event
|
||||
if event['ACTION'] == 'remove' and event['DEVPATH'] == '/kernel/platform_status/fan':
|
||||
os.system("shutdown -h now")
|
||||
|
||||
|
@ -1,5 +1,10 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (C) 2018 Inventec, Inc.
|
||||
#
|
||||
# Editor: James Huang ( Huang.James@inventec.com )
|
||||
#
|
||||
#
|
||||
|
||||
"""
|
||||
Usage: %(scriptName)s [options] command object
|
||||
@ -32,6 +37,8 @@ args = []
|
||||
INV_REDWOOD_PLATFORM = "SONiC-Inventec-d7032-100"
|
||||
INV_CYPRESS_PLATFORM = "SONiC-Inventec-d7054"
|
||||
INV_SEQUOIA_PLATFORM = "SONiC-Inventec-d7264"
|
||||
INV_MAPLE_PLATFORM = "SONiC-Inventec-d6556"
|
||||
INV_MAGNOLIA_PLATFORM = "SONiC-Inventec-d6254qs"
|
||||
|
||||
transceiver_type_dict = {
|
||||
"FCBG110SD1C03": "SR",
|
||||
@ -76,7 +83,29 @@ transceiver_type_dict = {
|
||||
"L0HSF006-SD-R": "KR",
|
||||
"L0HSF007-SD-R": "KR",
|
||||
"L0HSF008-SD-R": "KR",
|
||||
"L0HQF009-SD-R": "KR4"
|
||||
"L0HQF009-SD-R": "KR4",
|
||||
"FSPP-H7-M85-X3D": "SR",
|
||||
"PT0-M3-4D33K-C2": "SR",
|
||||
"RTXM228-551": "SR",
|
||||
"RTXM330-003": "SR",
|
||||
"RTXM330-030": "SR",
|
||||
"MFA2P10-A005": "SR",
|
||||
"QAB-OA03MC": "SR4",
|
||||
"QAB-OA05MC": "SR4",
|
||||
"RTXM320-571": "SR4",
|
||||
"AFBR-89CDDZ": "SR4",
|
||||
"RTXM420-550": "SR4",
|
||||
"MMA1B00-C100D": "SR4",
|
||||
"RTXM420-551": "SR4",
|
||||
"E04025QTXA000": "SR4",
|
||||
"LQ210PR-Oxxx": "SR4",
|
||||
"TR-FC13L-N00": "SR4",
|
||||
"SPQ-CE-LR-CDFL": "SR4",
|
||||
"FIM37700/170": "SR4",
|
||||
"FCBN425QE1C03": "SR4",
|
||||
"TQS-Q14H8-XCAXX": "SR4",
|
||||
"FPD-203R008-10/3": "SR4",
|
||||
"LTA8531-PC+": "SR4"
|
||||
}
|
||||
|
||||
initial_command = []
|
||||
@ -107,8 +136,9 @@ class BCMUtil(bcmshell):
|
||||
else:
|
||||
return self.port_to_bcm_mapping
|
||||
|
||||
def show_port_to_bcm_mapping(self):
|
||||
print self.port_to_bcm_mapping
|
||||
def show_port_to_bcm_mapping(self):
|
||||
for key,value in self.port_to_bcm_mapping.iteritems():
|
||||
print "{0}---{1}".format(key, value)
|
||||
|
||||
def get_eagle_port(self):
|
||||
return self.eagle_list
|
||||
@ -122,6 +152,8 @@ class BCMUtil(bcmshell):
|
||||
self.eagle_list = [66,100]
|
||||
elif name == INV_SEQUOIA_PLATFORM:
|
||||
self.eagle_list = [66,100]
|
||||
elif name == INV_MAPLE_PLATFORM:
|
||||
self.eagle_list = [66,130]
|
||||
else:
|
||||
self.eagle_list = []
|
||||
|
||||
@ -129,7 +161,8 @@ class BCMUtil(bcmshell):
|
||||
return self.sal_config_list
|
||||
|
||||
def show_sal_config_list(self):
|
||||
print self.sal_config_list
|
||||
for key,value in self.sal_config_list.iteritems():
|
||||
print "{0}---{1}".format(key, value)
|
||||
|
||||
def initial_sal_config_list( self ):
|
||||
content = self.run("config")
|
||||
@ -164,7 +197,8 @@ class TransceiverUtil(SfpUtil):
|
||||
return self.transceiver_port_mapping
|
||||
|
||||
def show_transceiver_port_mapping(self):
|
||||
print self.transceiver_port_mapping
|
||||
for key,value in self.transceiver_port_mapping.iteritems():
|
||||
print "{0}---{1}".format(key, value)
|
||||
|
||||
def get_bcm_port_name(self, index):
|
||||
if self.transceiver_port_mapping.has_key(index) and bcm_obj.get_sal_config_list().has_key(self.transceiver_port_mapping[index]["bcm"]):
|
||||
@ -179,7 +213,8 @@ class TransceiverUtil(SfpUtil):
|
||||
return self.port_to_i2c_mapping
|
||||
|
||||
def show_port_to_i2c_mapping(self):
|
||||
print self.port_to_i2c_mapping
|
||||
for key,value in self.port_to_i2c_mapping.iteritems():
|
||||
print "{0}---{1}".format(key, value)
|
||||
|
||||
def get_eeprom_partNum(self, portNum):
|
||||
tempdict = dict()
|
||||
@ -210,12 +245,12 @@ class TransceiverUtil(SfpUtil):
|
||||
def set_transceiver_type( self, portNum, pn ):
|
||||
type = self.get_transceiver_type( pn )
|
||||
if type is not None:
|
||||
if bcm_obj.get_platform() == INV_SEQUOIA_PLATFORM:
|
||||
if bcm_obj.get_platform() == INV_SEQUOIA_PLATFORM or bcm_obj.get_platform() == INV_MAPLE_PLATFORM :
|
||||
speed = bcm_obj.get_sal_config_list()[self.transceiver_port_mapping[portNum]["bcm"]]["speed"]
|
||||
bcm_obj.execute_command( "port %s if=%s speed=%d" % ( self.get_bcm_port_name(portNum), type, speed ) )
|
||||
else:
|
||||
bcm_obj.execute_command( "port %s if=%s" % ( self.get_bcm_port_name(portNum), type ) )
|
||||
#print "Detecting port {0} need to change interface type {1} ({2})".format(self.get_bcm_port_name(portNum), type, self.get_transceiver_port_mapping()[portNum]["pn"])
|
||||
print "Detecting port {0}({1}) need to change interface type {2} ({3})".format( self.get_bcm_port_name(portNum), portNum, type, self.get_transceiver_port_mapping()[portNum]["pn"])
|
||||
log_message("Detecting port {0} need to change interface type {1} ({2})".format(self.get_bcm_port_name(portNum), type, self.get_transceiver_port_mapping()[portNum]["pn"]) )
|
||||
|
||||
def initial_transceiver_port_mapping(self):
|
||||
@ -229,57 +264,90 @@ class TransceiverUtil(SfpUtil):
|
||||
for index in self.get_port_to_i2c_mapping().keys():
|
||||
if index >= self.qsfp_port_start and index <= self.qsfp_port_end :
|
||||
self.set_low_power_mode(index, False)
|
||||
|
||||
def main():
|
||||
try:
|
||||
global DEBUG
|
||||
global transceiver_obj
|
||||
global bcm_obj
|
||||
|
||||
initalNotOK = True
|
||||
retestCount = 0
|
||||
while initalNotOK :
|
||||
try:
|
||||
transceiver_obj = TransceiverUtil()
|
||||
bcm_obj = BCMUtil()
|
||||
initalNotOK = False
|
||||
except Exception, e:
|
||||
log_message("Exception. The warning is {0}, Retry again ({1})".format(str(e),retestCount) )
|
||||
retestCount = retestCount + 1
|
||||
time.sleep(5)
|
||||
|
||||
log_message( "Object initialed successfully" )
|
||||
|
||||
options, args = getopt.getopt(sys.argv[1:], 'hd', ['help',
|
||||
'debug'
|
||||
])
|
||||
for opt, arg in options:
|
||||
if opt in ('-h', '--help'):
|
||||
show_help()
|
||||
elif opt in ('-d', '--debug'):
|
||||
DEBUG = True
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
else:
|
||||
logging.info("no option")
|
||||
|
||||
# Before loop, You could execute specific command to initial chip
|
||||
for cmd_index in initial_command :
|
||||
bcm_obj.execute_command(cmd_index)
|
||||
|
||||
# Initial the sal config list
|
||||
bcm_obj.parsing_eagle_port()
|
||||
bcm_obj.initial_sal_config_list()
|
||||
bcm_obj.parsing_port_list()
|
||||
# bcm_obj.show_port_to_bcm_mapping()
|
||||
# bcm_obj.show_sal_config_list()
|
||||
|
||||
# Initial the transceiver_obj
|
||||
transceiver_obj.initial_transceiver_port_mapping()
|
||||
# transceiver_obj.show_transceiver_port_mapping()
|
||||
|
||||
transceiver_obj.set_power_mode_for_QSFP()
|
||||
# To set tx_disable
|
||||
self.set_tx_disable(index)
|
||||
|
||||
while 1 :
|
||||
def set_tx_disable(self, port_num):
|
||||
if port_num >= self.qsfp_port_start and port_num <= self.qsfp_port_end :
|
||||
pass
|
||||
else:
|
||||
try:
|
||||
tx_file = open("/sys/class/swps/port"+str(port_num)+"/tx_disable", "r+")
|
||||
except IOError as e:
|
||||
print "Error: unable to open file: %s" % str(e)
|
||||
return False
|
||||
|
||||
reg_value = int(tx_file.readline().rstrip())
|
||||
|
||||
# always set 0 to tx_disable field
|
||||
if reg_value == 1 :
|
||||
reg_value = 0
|
||||
tx_file.write(hex(reg_value))
|
||||
tx_file.close()
|
||||
|
||||
|
||||
def main():
|
||||
|
||||
global DEBUG
|
||||
global transceiver_obj
|
||||
global bcm_obj
|
||||
|
||||
initalNotOK = True
|
||||
retestCount = 0
|
||||
while initalNotOK :
|
||||
try:
|
||||
transceiver_obj = TransceiverUtil()
|
||||
bcm_obj = BCMUtil()
|
||||
initalNotOK = False
|
||||
except Exception, e:
|
||||
log_message("Exception. The warning is {0}, Retry again ({1})".format(str(e),retestCount) )
|
||||
retestCount = retestCount + 1
|
||||
time.sleep(5)
|
||||
|
||||
log_message( "Object initialed successfully" )
|
||||
options, args = getopt.getopt(sys.argv[1:], 'hd', ['help',
|
||||
'debug'
|
||||
])
|
||||
for opt, arg in options:
|
||||
if opt in ('-h', '--help'):
|
||||
show_help()
|
||||
elif opt in ('-d', '--debug'):
|
||||
DEBUG = True
|
||||
logging.basicConfig(level=logging.INFO)
|
||||
else:
|
||||
logging.info("no option")
|
||||
|
||||
initalNotOK = True
|
||||
while initalNotOK :
|
||||
try :
|
||||
# Before loop, You could execute specific command to initial chip
|
||||
for cmd_index in initial_command :
|
||||
bcm_obj.execute_command(cmd_index)
|
||||
|
||||
# Initial the sal config list
|
||||
bcm_obj.parsing_eagle_port()
|
||||
bcm_obj.initial_sal_config_list()
|
||||
# bcm_obj.show_sal_config_list()
|
||||
bcm_obj.parsing_port_list()
|
||||
#bcm_obj.show_port_to_bcm_mapping()
|
||||
#bcm_obj.show_sal_config_list()
|
||||
# transceiver_obj.show_port_to_i2c_mapping()
|
||||
|
||||
# Initial the transceiver_obj
|
||||
transceiver_obj.initial_transceiver_port_mapping()
|
||||
# transceiver_obj.show_transceiver_port_mapping()
|
||||
|
||||
initalNotOK = False
|
||||
except Exception, e:
|
||||
log_message("Exception. The warning is {0}".format(str(e)) )
|
||||
time.sleep(5)
|
||||
|
||||
# Improve the power mode for QSFP ports
|
||||
transceiver_obj.set_power_mode_for_QSFP()
|
||||
|
||||
while 1 :
|
||||
try:
|
||||
if bcm_obj.get_platform() == INV_SEQUOIA_PLATFORM:
|
||||
bcm_obj.parsing_port_list()
|
||||
for index in transceiver_obj.get_port_to_i2c_mapping().keys():
|
||||
@ -287,15 +355,17 @@ def main():
|
||||
value = transceiver_obj.get_eeprom_partNum_from_parser_eeprom_dict(info)
|
||||
if transceiver_obj.get_transceiver_port_mapping().has_key(index) is not False and transceiver_obj.get_transceiver_port_mapping()[index]["pn"] <> value:
|
||||
transceiver_obj.get_transceiver_port_mapping()[index]["pn"] = value
|
||||
transceiver_obj.set_transceiver_type(index,value)
|
||||
#transceiver_obj.show_transceiver_port_mapping()
|
||||
time.sleep(1)
|
||||
transceiver_obj.set_transceiver_type(index,value)
|
||||
transceiver_obj.set_tx_disable(index)
|
||||
#transceiver_obj.show_transceiver_port_mapping()
|
||||
# transceiver_obj.show_transceiver_port_mapping()
|
||||
except Exception, e:
|
||||
log_message("Exception. The warning is {0}".format(str(e)) )
|
||||
time.sleep(1)
|
||||
|
||||
except (Exception, KeyboardInterrupt) as e:
|
||||
log_message("Terminating this python daemon ({0})".format(e))
|
||||
syslog.closelog()
|
||||
del transceiver_obj
|
||||
del bcm_obj
|
||||
syslog.closelog()
|
||||
del transceiver_obj
|
||||
del bcm_obj
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@ -303,3 +373,6 @@ if __name__ == "__main__":
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,7 @@
|
||||
obj-m += inv_cpld.o inv_psoc.o
|
||||
obj-m += inv_platform.o
|
||||
obj-m += inv_eeprom.o
|
||||
obj-m += swps.o
|
||||
obj-m += inv_pthread.o
|
||||
swps-objs := inv_swps.o io_expander.o transceiver.o
|
||||
|
@ -0,0 +1,415 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/hwmon.h>
|
||||
#include <linux/hwmon-sysfs.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/mutex.h>
|
||||
|
||||
//#include "I2CHostCommunication.h"
|
||||
|
||||
#define USE_SMBUS 1
|
||||
|
||||
/* definition */
|
||||
#define CPLD_INFO_OFFSET 0x00
|
||||
#define CPLD_PSU_OFFSET 0x08
|
||||
#define CPLD_LED_OFFSET 0x0E
|
||||
#define CPLD_LED_STATU_OFFSET 0x0D
|
||||
#define CPLD_CTL_OFFSET 0x0C
|
||||
|
||||
|
||||
|
||||
/* Each client has this additional data */
|
||||
struct cpld_data {
|
||||
struct device *hwmon_dev;
|
||||
struct mutex update_lock;
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
static ssize_t cpld_i2c_read(struct i2c_client *client, u8 *buf, u8 offset, size_t count)
|
||||
{
|
||||
#if USE_SMBUS
|
||||
int i;
|
||||
|
||||
for(i=0; i<count; i++) {
|
||||
buf[i] = i2c_smbus_read_byte_data(client, offset+i);
|
||||
}
|
||||
return count;
|
||||
#else
|
||||
struct i2c_msg msg[2];
|
||||
char msgbuf[2];
|
||||
int status;
|
||||
|
||||
memset(msg, 0, sizeof(msg));
|
||||
|
||||
msgbuf[0] = offset;
|
||||
|
||||
msg[0].addr = client->addr;
|
||||
msg[0].buf = msgbuf;
|
||||
msg[0].len = 1;
|
||||
|
||||
msg[1].addr = client->addr;
|
||||
msg[1].flags = I2C_M_RD;
|
||||
msg[1].buf = buf;
|
||||
msg[1].len = count;
|
||||
|
||||
status = i2c_transfer(client->adapter, msg, 2);
|
||||
|
||||
if(status == 2)
|
||||
status = count;
|
||||
|
||||
return status;
|
||||
#endif
|
||||
}
|
||||
|
||||
static ssize_t cpld_i2c_write(struct i2c_client *client, char *buf, unsigned offset, size_t count)
|
||||
{
|
||||
#if USE_SMBUS
|
||||
int i;
|
||||
|
||||
for(i=0; i<count; i++) {
|
||||
i2c_smbus_write_byte_data(client, offset+i, buf[i]);
|
||||
}
|
||||
return count;
|
||||
#else
|
||||
struct i2c_msg msg;
|
||||
int status;
|
||||
u8 writebuf[64];
|
||||
|
||||
int i = 0;
|
||||
|
||||
msg.addr = client->addr;
|
||||
msg.flags = 0;
|
||||
|
||||
/* msg.buf is u8 and casts will mask the values */
|
||||
msg.buf = writebuf;
|
||||
|
||||
msg.buf[i++] = offset;
|
||||
memcpy(&msg.buf[i], buf, count);
|
||||
msg.len = i + count;
|
||||
|
||||
status = i2c_transfer(client->adapter, &msg, 1);
|
||||
if (status == 1)
|
||||
status = count;
|
||||
|
||||
return status;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
/* sysfs attributes for hwmon */
|
||||
|
||||
static ssize_t show_info(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
u32 status;
|
||||
//struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct cpld_data *data = i2c_get_clientdata(client);
|
||||
u8 b[4];
|
||||
|
||||
memset(b, 0, 4);
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
status = cpld_i2c_read(client, b, CPLD_INFO_OFFSET, 4);
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
if(status != 4) return sprintf(buf, "read cpld info fail\n");
|
||||
|
||||
status = sprintf (buf, "The CPLD release date is %02d/%02d/%d.\n", b[2] & 0xf, (b[3] & 0x1f), 2014+(b[2] >> 4)); /* mm/dd/yyyy*/
|
||||
status = sprintf (buf, "%sThe PCB version is %X%X\n", buf, b[0]>>4, b[0]&0xf);
|
||||
status = sprintf (buf, "%sThe CPLD version is %d.%d\n", buf, b[1]>>4, b[1]&0xf);
|
||||
|
||||
return strlen(buf);
|
||||
}
|
||||
|
||||
|
||||
static ssize_t show_ctl(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
u32 status;
|
||||
//struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct cpld_data *data = i2c_get_clientdata(client);
|
||||
u8 b[1];
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
|
||||
status = cpld_i2c_read(client, b, CPLD_CTL_OFFSET, 1);
|
||||
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
if(status != 1) return sprintf(buf, "read cpld ctl fail\n");
|
||||
|
||||
|
||||
status = sprintf (buf, "0x%X\n", b[0]);
|
||||
|
||||
return strlen(buf);
|
||||
}
|
||||
|
||||
static ssize_t set_ctl(struct device *dev,
|
||||
struct device_attribute *devattr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
//struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct cpld_data *data = i2c_get_clientdata(client);
|
||||
u8 byte;
|
||||
|
||||
u8 temp = simple_strtol(buf, NULL, 10);
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
cpld_i2c_read(client, &byte, CPLD_CTL_OFFSET, 1);
|
||||
if(temp) byte |= (1<<0);
|
||||
else byte &= ~(1<<0);
|
||||
cpld_i2c_write(client, &byte, CPLD_CTL_OFFSET, 1);
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
static char* led_str[] = {
|
||||
"OFF", //000
|
||||
"0.5 Hz", //001
|
||||
"1 Hz", //010
|
||||
"2 Hz", //011
|
||||
"NA", //100
|
||||
"NA", //101
|
||||
"NA", //110
|
||||
"ON", //111
|
||||
};
|
||||
|
||||
static ssize_t show_led(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
u32 status;
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct cpld_data *data = i2c_get_clientdata(client);
|
||||
u8 byte;
|
||||
int shift = (attr->index == 0)?3:0;
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
status = cpld_i2c_read(client, &byte, CPLD_LED_OFFSET, 1);
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
if(status != 1) return sprintf(buf, "read cpld offset 0x%x\n", CPLD_LED_OFFSET);
|
||||
|
||||
byte = (byte >> shift) & 0x7;
|
||||
|
||||
/*
|
||||
0: off
|
||||
1: 0.5hz
|
||||
2: 1 hz
|
||||
3: 2 hz
|
||||
4~6: not define
|
||||
7: on
|
||||
*/
|
||||
|
||||
status = sprintf (buf, "%d: %s\n", byte, led_str[byte]);
|
||||
|
||||
return strlen(buf);
|
||||
}
|
||||
|
||||
static ssize_t set_led(struct device *dev,
|
||||
struct device_attribute *devattr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct cpld_data *data = i2c_get_clientdata(client);
|
||||
|
||||
u8 temp = simple_strtol(buf, NULL, 16);
|
||||
u8 byte;
|
||||
int shift = (attr->index == 0)?3:0;
|
||||
|
||||
temp &= 0x7;
|
||||
//validate temp value: 0,1,2,3,7, TBD
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
cpld_i2c_read(client, &byte, CPLD_LED_OFFSET, 1);
|
||||
byte &= ~(0x7<<shift);
|
||||
byte |= (temp<<shift);
|
||||
cpld_i2c_write(client, &byte, CPLD_LED_OFFSET, 1);
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/*
|
||||
CPLD report the PSU0 status
|
||||
000 = PSU normal operation
|
||||
100 = PSU fault
|
||||
010 = PSU unpowered
|
||||
111 = PSU not installed
|
||||
|
||||
7 6 | 5 4 3 | 2 1 0
|
||||
----------------------
|
||||
| psu0 | psu1
|
||||
*/
|
||||
static char* psu_str[] = {
|
||||
"normal", //000
|
||||
"NA", //001
|
||||
"unpowered", //010
|
||||
"NA", //011
|
||||
"fault", //100
|
||||
"NA", //101
|
||||
"NA", //110
|
||||
"not installed", //111
|
||||
};
|
||||
|
||||
static ssize_t show_psu(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
u32 status;
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct cpld_data *data = i2c_get_clientdata(client);
|
||||
u8 byte;
|
||||
int shift = (attr->index == 1)?0:3;
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
status = cpld_i2c_read(client, &byte, CPLD_PSU_OFFSET, 1);
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
byte = (byte >> shift) & 0x7;
|
||||
|
||||
status = sprintf (buf, "%d : %s\n", byte, psu_str[byte]);
|
||||
|
||||
return strlen(buf);
|
||||
}
|
||||
|
||||
|
||||
static SENSOR_DEVICE_ATTR(info, S_IRUGO, show_info, 0, 0);
|
||||
static SENSOR_DEVICE_ATTR(ctl, S_IWUSR|S_IRUGO, show_ctl, set_ctl, 0);
|
||||
|
||||
static SENSOR_DEVICE_ATTR(grn_led, S_IWUSR|S_IRUGO, show_led, set_led, 0);
|
||||
static SENSOR_DEVICE_ATTR(red_led, S_IWUSR|S_IRUGO, show_led, set_led, 1);
|
||||
|
||||
static SENSOR_DEVICE_ATTR(psu0, S_IRUGO, show_psu, 0, 0);
|
||||
static SENSOR_DEVICE_ATTR(psu1, S_IRUGO, show_psu, 0, 1);
|
||||
|
||||
static struct attribute *cpld_attributes[] = {
|
||||
//info
|
||||
&sensor_dev_attr_info.dev_attr.attr,
|
||||
&sensor_dev_attr_ctl.dev_attr.attr,
|
||||
|
||||
&sensor_dev_attr_grn_led.dev_attr.attr,
|
||||
&sensor_dev_attr_red_led.dev_attr.attr,
|
||||
|
||||
&sensor_dev_attr_psu0.dev_attr.attr,
|
||||
&sensor_dev_attr_psu1.dev_attr.attr,
|
||||
|
||||
NULL
|
||||
};
|
||||
|
||||
static const struct attribute_group cpld_group = {
|
||||
.attrs = cpld_attributes,
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
/* device probe and removal */
|
||||
|
||||
static int
|
||||
cpld_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||
{
|
||||
struct cpld_data *data;
|
||||
int status;
|
||||
|
||||
printk("+%s\n", __func__);
|
||||
|
||||
if (!i2c_check_functionality(client->adapter,
|
||||
I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA))
|
||||
return -EIO;
|
||||
|
||||
data = kzalloc(sizeof(struct cpld_data), GFP_KERNEL);
|
||||
if (!data)
|
||||
return -ENOMEM;
|
||||
|
||||
i2c_set_clientdata(client, data);
|
||||
mutex_init(&data->update_lock);
|
||||
|
||||
/* Register sysfs hooks */
|
||||
status = sysfs_create_group(&client->dev.kobj, &cpld_group);
|
||||
if (status)
|
||||
goto exit_free;
|
||||
|
||||
data->hwmon_dev = hwmon_device_register(&client->dev);
|
||||
if (IS_ERR(data->hwmon_dev)) {
|
||||
status = PTR_ERR(data->hwmon_dev);
|
||||
goto exit_remove;
|
||||
}
|
||||
|
||||
dev_info(&client->dev, "%s: sensor '%s'\n",
|
||||
dev_name(data->hwmon_dev), client->name);
|
||||
|
||||
return 0;
|
||||
|
||||
exit_remove:
|
||||
sysfs_remove_group(&client->dev.kobj, &cpld_group);
|
||||
exit_free:
|
||||
i2c_set_clientdata(client, NULL);
|
||||
kfree(data);
|
||||
return status;
|
||||
}
|
||||
|
||||
static int cpld_remove(struct i2c_client *client)
|
||||
{
|
||||
struct cpld_data *data = i2c_get_clientdata(client);
|
||||
|
||||
hwmon_device_unregister(data->hwmon_dev);
|
||||
sysfs_remove_group(&client->dev.kobj, &cpld_group);
|
||||
i2c_set_clientdata(client, NULL);
|
||||
kfree(data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct i2c_device_id cpld_ids[] = {
|
||||
{ "inv_cpld", 0, },
|
||||
{ /* LIST END */ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, cpld_ids);
|
||||
|
||||
static struct i2c_driver cpld_driver = {
|
||||
.class = I2C_CLASS_HWMON,
|
||||
.driver = {
|
||||
.name = "inv_cpld",
|
||||
},
|
||||
.probe = cpld_probe,
|
||||
.remove = cpld_remove,
|
||||
.id_table = cpld_ids,
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
/* module glue */
|
||||
|
||||
static int __init inv_cpld_init(void)
|
||||
{
|
||||
return i2c_add_driver(&cpld_driver);
|
||||
}
|
||||
|
||||
static void __exit inv_cpld_exit(void)
|
||||
{
|
||||
i2c_del_driver(&cpld_driver);
|
||||
}
|
||||
|
||||
MODULE_AUTHOR("eddie.lan <eddie.lan@inventec>");
|
||||
MODULE_DESCRIPTION("inv cpld driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
module_init(inv_cpld_init);
|
||||
module_exit(inv_cpld_exit);
|
@ -0,0 +1,181 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/mutex.h>
|
||||
|
||||
|
||||
/* Size of EEPROM in bytes */
|
||||
#define EEPROM_SIZE 256
|
||||
|
||||
#define SLICE_BITS (6)
|
||||
#define SLICE_SIZE (1 << SLICE_BITS)
|
||||
#define SLICE_NUM (EEPROM_SIZE/SLICE_SIZE)
|
||||
|
||||
/* Each client has this additional data */
|
||||
struct eeprom_data {
|
||||
struct mutex update_lock;
|
||||
u8 valid; /* bitfield, bit!=0 if slice is valid */
|
||||
unsigned long last_updated[SLICE_NUM]; /* In jiffies, 8 slices */
|
||||
u8 data[EEPROM_SIZE]; /* Register values */
|
||||
};
|
||||
|
||||
|
||||
static void inv_eeprom_update_client(struct i2c_client *client, u8 slice)
|
||||
{
|
||||
struct eeprom_data *data = i2c_get_clientdata(client);
|
||||
int i, j;
|
||||
int ret;
|
||||
int addr;
|
||||
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
|
||||
if (!(data->valid & (1 << slice)) ||
|
||||
time_after(jiffies, data->last_updated[slice] + 300 * HZ)) {
|
||||
dev_dbg(&client->dev, "Starting eeprom update, slice %u\n", slice);
|
||||
|
||||
addr = slice << SLICE_BITS;
|
||||
|
||||
ret = i2c_smbus_write_byte_data(client, ((u8)addr >> 8) & 0xFF, (u8)addr & 0xFF);
|
||||
/* select the eeprom address */
|
||||
if (ret < 0) {
|
||||
dev_err(&client->dev, "address set failed\n");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BYTE)) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
for (i = slice << SLICE_BITS; i < (slice + 1) << SLICE_BITS; i+= SLICE_SIZE) {
|
||||
for (j = i; j < (i+SLICE_SIZE); j++) {
|
||||
int res;
|
||||
|
||||
res = i2c_smbus_read_byte(client);
|
||||
if (res < 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
data->data[j] = res & 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
data->last_updated[slice] = jiffies;
|
||||
data->valid |= (1 << slice);
|
||||
}
|
||||
|
||||
exit:
|
||||
mutex_unlock(&data->update_lock);
|
||||
}
|
||||
|
||||
static ssize_t inv_eeprom_read(struct file *filp, struct kobject *kobj,
|
||||
struct bin_attribute *bin_attr,
|
||||
char *buf, loff_t off, size_t count)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj));
|
||||
struct eeprom_data *data = i2c_get_clientdata(client);
|
||||
u8 slice;
|
||||
|
||||
|
||||
if (off > EEPROM_SIZE) {
|
||||
return 0;
|
||||
}
|
||||
if (off + count > EEPROM_SIZE) {
|
||||
count = EEPROM_SIZE - off;
|
||||
}
|
||||
if (count == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Only refresh slices which contain requested bytes */
|
||||
for (slice = off >> SLICE_BITS; slice <= (off + count - 1) >> SLICE_BITS; slice++) {
|
||||
inv_eeprom_update_client(client, slice);
|
||||
}
|
||||
|
||||
memcpy(buf, &data->data[off], count);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static struct bin_attribute inv_eeprom_attr = {
|
||||
.attr = {
|
||||
.name = "eeprom",
|
||||
.mode = S_IRUGO,
|
||||
},
|
||||
.size = EEPROM_SIZE,
|
||||
.read = inv_eeprom_read,
|
||||
};
|
||||
|
||||
static int inv_eeprom_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct eeprom_data *data;
|
||||
int err;
|
||||
|
||||
if (!(data = kzalloc(sizeof(struct eeprom_data), GFP_KERNEL))) {
|
||||
err = -ENOMEM;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
memset(data->data, 0xff, EEPROM_SIZE);
|
||||
i2c_set_clientdata(client, data);
|
||||
mutex_init(&data->update_lock);
|
||||
|
||||
/* create the sysfs eeprom file */
|
||||
err = sysfs_create_bin_file(&client->dev.kobj, &inv_eeprom_attr);
|
||||
if (err) {
|
||||
goto exit_kfree;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
exit_kfree:
|
||||
kfree(data);
|
||||
exit:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int inv_eeprom_remove(struct i2c_client *client)
|
||||
{
|
||||
sysfs_remove_bin_file(&client->dev.kobj, &inv_eeprom_attr);
|
||||
kfree(i2c_get_clientdata(client));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct i2c_device_id inv_eeprom_id[] = {
|
||||
{ "inv_eeprom", 0 },
|
||||
{ }
|
||||
};
|
||||
|
||||
static struct i2c_driver inv_eeprom_driver = {
|
||||
.driver = {
|
||||
.name = "inv_eeprom",
|
||||
},
|
||||
.probe = inv_eeprom_probe,
|
||||
.remove = inv_eeprom_remove,
|
||||
.id_table = inv_eeprom_id,
|
||||
};
|
||||
|
||||
module_i2c_driver(inv_eeprom_driver);
|
||||
|
||||
MODULE_AUTHOR("Inventec");
|
||||
MODULE_DESCRIPTION("Inventec D7054 Mother Board EEPROM driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
|
@ -0,0 +1,280 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#include <asm/io.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include "io_expander.h"
|
||||
#include "inv_mux.h"
|
||||
|
||||
static struct mux_obj_s *mux_head_p = NULL;
|
||||
|
||||
|
||||
/* ========== MUX object functions ==========
|
||||
*/
|
||||
int
|
||||
_common_force_pull_gpio(int mem_addr,
|
||||
int input,
|
||||
int bit_offset){
|
||||
|
||||
unsigned int val = 0;
|
||||
unsigned int targ = 0;
|
||||
|
||||
/* Get current value */
|
||||
val = inl(mem_addr);
|
||||
if (val == 0) {
|
||||
SWPS_ERR("%s: inl:%d fail!\n", __func__, val);
|
||||
return -1;
|
||||
}
|
||||
/* Count target value */
|
||||
switch (input) {
|
||||
case 0: /* Pull Low */
|
||||
targ = (val & (~(1 << bit_offset)));
|
||||
break;
|
||||
case 1: /* Pull high */
|
||||
targ = (val | (1 << bit_offset));
|
||||
break;
|
||||
default:
|
||||
SWPS_ERR("%s: input state:%d incorrect!\n",
|
||||
__func__, input);
|
||||
return -1;
|
||||
}
|
||||
/* Setup gpio */
|
||||
outl(targ, mem_addr);
|
||||
if (targ != inl(mem_addr)){
|
||||
SWPS_ERR("%s: outl:%d fail!\n", __func__, targ);
|
||||
return -1;
|
||||
}
|
||||
SWPS_DEBUG("%s: done.\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
rangeley_force_pull_high(struct mux_obj_s *self){
|
||||
SWPS_ERR("%s: not ready!\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
rangeley_force_pull_low(struct mux_obj_s *self){
|
||||
SWPS_ERR("%s: not ready!\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
hedera_force_pull_high(struct mux_obj_s *self){
|
||||
return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 1, 5);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
hedera_force_pull_low(struct mux_obj_s *self){
|
||||
return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 0, 5);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
normal_gpio_pull_high(struct mux_obj_s *self){
|
||||
return gpio_direction_output(self->gpio_num, 1);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
normal_gpio_pull_low(struct mux_obj_s *self){
|
||||
return gpio_direction_output(self->gpio_num, 0);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
pca9548_reset_mux_all(struct mux_obj_s *self){
|
||||
/* [Note] Power-on reset (PCA9548A-NXP)
|
||||
* When power is applied to VDD, an internal Power-On Reset (POR)
|
||||
* holds the PCA9548A in a reset condition until VDD has reached
|
||||
* VPOR. At this point, the reset condition is released and the
|
||||
* PCA9548A register and I2C-bus state machine are initialized to
|
||||
* their default states (all zeroes) causing all the channels to
|
||||
* be deselected. Thereafter, VDD must be lowered below 0.2 V for
|
||||
* at least 5 us in order to reset the device.
|
||||
*/
|
||||
if (self->_pull_low(self) < 0) {
|
||||
SWPS_ERR("%s: _pull_low fail!\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
mdelay(MUX_RST_WAIT_MS);
|
||||
if (self->_pull_high(self) < 0) {
|
||||
SWPS_ERR("%s: _pull_high fail!\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
mdelay(MUX_RST_WAIT_MS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
common_reset_mux_all(struct mux_obj_s *self){
|
||||
SWPS_ERR("%s: not ready!\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
init_gpio_4_force(struct mux_obj_s *self){
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
init_gpio_4_normal(struct mux_obj_s *self){
|
||||
|
||||
int err = 0;
|
||||
|
||||
if (!gpio_is_valid(self->gpio_num)) {
|
||||
SWPS_ERR("%s: GIPO:%d isn't valid\n", __func__, self->gpio_num);
|
||||
return -1;
|
||||
}
|
||||
err = gpio_request(self->gpio_num, MUX_GPIO_LABEL);
|
||||
if (err < 0) {
|
||||
SWPS_ERR("%s: gpio_request fail <err>:%d <gpio>:%d\n",
|
||||
__func__, err, self->gpio_num);
|
||||
return -1;
|
||||
}
|
||||
SWPS_DEBUG("%s: gpio_request:%d ok.\n", __func__, self->gpio_num);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
_setup_muxctl_cb(struct mux_obj_s *self,
|
||||
unsigned gpio){
|
||||
|
||||
char mod_dsc[32] = "ERR";
|
||||
|
||||
switch (gpio) {
|
||||
case MUX_RST_GPIO_FORCE_RANGELEY:
|
||||
self->gpio_num = gpio;
|
||||
self->_pull_low = rangeley_force_pull_low;
|
||||
self->_pull_high = rangeley_force_pull_high;
|
||||
self->_init = init_gpio_4_force;
|
||||
self->reset = pca9548_reset_mux_all;
|
||||
memset(mod_dsc, 0, 32);
|
||||
snprintf(mod_dsc, 31, "Rangeley force mode");
|
||||
goto ok_setup_muxctl_cb;
|
||||
|
||||
case MUX_RST_GPIO_FORCE_HEDERA:
|
||||
self->gpio_num = gpio;
|
||||
self->_pull_low = hedera_force_pull_low;
|
||||
self->_pull_high = hedera_force_pull_high;
|
||||
self->_init = init_gpio_4_force;
|
||||
self->reset = pca9548_reset_mux_all;
|
||||
memset(mod_dsc, 0, 32);
|
||||
snprintf(mod_dsc, 31, "Hedera force mode");
|
||||
goto ok_setup_muxctl_cb;
|
||||
|
||||
case MUX_RST_GPIO_48_PAC9548:
|
||||
case MUX_RST_GPIO_69_PAC9548:
|
||||
case MUX_RST_GPIO_249_PCA9548:
|
||||
case MUX_RST_GPIO_505_PCA9548:
|
||||
self->gpio_num = gpio;
|
||||
self->_pull_low = normal_gpio_pull_low;
|
||||
self->_pull_high = normal_gpio_pull_high;
|
||||
self->_init = init_gpio_4_normal;
|
||||
self->reset = pca9548_reset_mux_all;
|
||||
memset(mod_dsc, 0, 32);
|
||||
snprintf(mod_dsc, 31, "Normal mode <gpio>:%d", (int)gpio);
|
||||
goto ok_setup_muxctl_cb;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
SWPS_ERR("%s: Unexpected GPIO:%d\n", __func__, gpio);
|
||||
return -1;
|
||||
|
||||
ok_setup_muxctl_cb:
|
||||
SWPS_INFO("muxctl: %s.\n", mod_dsc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* ========== MUX public functions ==========
|
||||
*/
|
||||
void
|
||||
clean_mux_gpio(void){
|
||||
|
||||
if (!mux_head_p) {
|
||||
SWPS_DEBUG("%s: mux_head_p is NULL\n", __func__);
|
||||
return;
|
||||
}
|
||||
if (gpio_is_valid(mux_head_p->gpio_num)) {
|
||||
gpio_free(mux_head_p->gpio_num);
|
||||
}
|
||||
kfree(mux_head_p);
|
||||
mux_head_p = NULL;
|
||||
SWPS_DEBUG("%s: done.\n", __func__);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
reset_mux_gpio(void){
|
||||
|
||||
if (!mux_head_p) {
|
||||
SWPS_ERR("%s: MUX ctl object doesn't exist!\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
if (mux_head_p->reset(mux_head_p) < 0){
|
||||
SWPS_ERR("%s: reset fail!\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
init_mux_gpio(unsigned gpio){
|
||||
|
||||
/* Create MUX control object */
|
||||
if (mux_head_p) {
|
||||
SWPS_DEBUG("%s: mux_head_p is not NULL!\n", __func__);
|
||||
clean_mux_gpio();
|
||||
}
|
||||
/* Currently, it is using single muxctl architecture.
|
||||
* In the future, it may use the multi-muxctl if HW add new features.
|
||||
* (Ex: Port power-status control)
|
||||
*/
|
||||
mux_head_p = kzalloc(sizeof(struct mux_obj_s), GFP_KERNEL);
|
||||
if (!mux_head_p) {
|
||||
SWPS_ERR("%s: kzalloc fail!\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
/* Initial MUX controller */
|
||||
if (_setup_muxctl_cb(mux_head_p, gpio) < 0){
|
||||
SWPS_ERR("%s: _setup_muxctl_cb fail!\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
if (mux_head_p->_init(mux_head_p) < 0) {
|
||||
SWPS_ERR("%s: init() fail\n", __func__);
|
||||
goto err_init_mux_gpio;
|
||||
}
|
||||
/* Setup default value */
|
||||
if (mux_head_p->_pull_high(mux_head_p) < 0) {
|
||||
SWPS_ERR("%s: setup default fail!\n", __func__);
|
||||
goto err_init_mux_gpio;
|
||||
}
|
||||
return 0;
|
||||
|
||||
err_init_mux_gpio:
|
||||
clean_mux_gpio();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#ifndef INV_MUX_H
|
||||
#define INV_MUX_H
|
||||
|
||||
|
||||
/* MUX basic information */
|
||||
#define MUX_GPIO_LABEL "SWPS_RST_MUX"
|
||||
|
||||
/* MUX reset GPIO define */
|
||||
#define MUX_RST_GPIO_FORCE (30100)
|
||||
#define MUX_RST_GPIO_FORCE_RANGELEY (30101)
|
||||
#define MUX_RST_GPIO_FORCE_HEDERA (30102)
|
||||
#define MUX_RST_GPIO_48_PAC9548 (48)
|
||||
#define MUX_RST_GPIO_69_PAC9548 (69)
|
||||
#define MUX_RST_GPIO_249_PCA9548 (249)
|
||||
#define MUX_RST_GPIO_505_PCA9548 (505)
|
||||
|
||||
/* MUX relate value define */
|
||||
#define MUX_RST_WAIT_MS (1)
|
||||
#define MUX_RST_MEM_ADDR_RANGELEY (0) // TBD
|
||||
#define MUX_RST_MEM_ADDR_HEDERA (0x548)
|
||||
|
||||
struct mux_obj_s {
|
||||
unsigned gpio_num;
|
||||
int (*_pull_high)(struct mux_obj_s *self);
|
||||
int (*_pull_low)(struct mux_obj_s *self);
|
||||
int (*_init)(struct mux_obj_s *self);
|
||||
int (*reset)(struct mux_obj_s *self);
|
||||
};
|
||||
|
||||
|
||||
void clean_mux_gpio(void);
|
||||
int reset_mux_gpio(void);
|
||||
int init_mux_gpio(unsigned gpio);
|
||||
|
||||
|
||||
#endif /* INV_MUX_H */
|
||||
|
||||
|
||||
|
@ -0,0 +1,243 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/i2c-gpio.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/platform_device.h>
|
||||
|
||||
#include <linux/i2c/pca954x.h>
|
||||
|
||||
struct inv_i2c_board_info {
|
||||
int ch;
|
||||
int size;
|
||||
struct i2c_board_info *board_info;
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
static struct pca954x_platform_mode mux_modes_0[] = {
|
||||
{.adap_id = 2,}, {.adap_id = 3,},
|
||||
{.adap_id = 4,}, {.adap_id = 5,},
|
||||
{.adap_id = 6,}, {.adap_id = 7,},
|
||||
{.adap_id = 8,}, {.adap_id = 9,},
|
||||
};
|
||||
static struct pca954x_platform_mode mux_modes_0_0[] = {
|
||||
{.adap_id = 10,}, {.adap_id = 11,},
|
||||
{.adap_id = 12,}, {.adap_id = 13,},
|
||||
{.adap_id = 14,}, {.adap_id = 15,},
|
||||
{.adap_id = 16,}, {.adap_id = 17,},
|
||||
};
|
||||
|
||||
static struct pca954x_platform_mode mux_modes_0_1[] = {
|
||||
{.adap_id = 18,}, {.adap_id = 19,},
|
||||
{.adap_id = 20,}, {.adap_id = 21,},
|
||||
{.adap_id = 22,}, {.adap_id = 23,},
|
||||
{.adap_id = 24,}, {.adap_id = 25,},
|
||||
};
|
||||
|
||||
static struct pca954x_platform_mode mux_modes_0_2[] = {
|
||||
{.adap_id = 26,}, {.adap_id = 27,},
|
||||
{.adap_id = 28,}, {.adap_id = 29,},
|
||||
{.adap_id = 30,}, {.adap_id = 31,},
|
||||
{.adap_id = 32,}, {.adap_id = 33,},
|
||||
};
|
||||
|
||||
static struct pca954x_platform_mode mux_modes_0_3[] = {
|
||||
{.adap_id = 34,}, {.adap_id = 35,},
|
||||
{.adap_id = 36,}, {.adap_id = 37,},
|
||||
{.adap_id = 38,}, {.adap_id = 39,},
|
||||
{.adap_id = 40,}, {.adap_id = 41,},
|
||||
};
|
||||
|
||||
static struct pca954x_platform_mode mux_modes_0_4[] = {
|
||||
{.adap_id = 42,}, {.adap_id = 43,},
|
||||
{.adap_id = 44,}, {.adap_id = 45,},
|
||||
{.adap_id = 46,}, {.adap_id = 47,},
|
||||
{.adap_id = 48,}, {.adap_id = 49,},
|
||||
};
|
||||
|
||||
static struct pca954x_platform_mode mux_modes_0_5[] = {
|
||||
{.adap_id = 50,}, {.adap_id = 51,},
|
||||
{.adap_id = 52,}, {.adap_id = 53,},
|
||||
{.adap_id = 54,}, {.adap_id = 55,},
|
||||
{.adap_id = 56,}, {.adap_id = 57,},
|
||||
};
|
||||
|
||||
static struct pca954x_platform_mode mux_modes_0_6[] = {
|
||||
{.adap_id = 58,}, {.adap_id = 59,},
|
||||
{.adap_id = 60,}, {.adap_id = 61,},
|
||||
{.adap_id = 62,}, {.adap_id = 63,},
|
||||
{.adap_id = 64,}, {.adap_id = 65,},
|
||||
};
|
||||
|
||||
//no i2c device driver attach to mux 7
|
||||
|
||||
|
||||
static struct pca954x_platform_data mux_data_0 = {
|
||||
.modes = mux_modes_0,
|
||||
.num_modes = 8,
|
||||
};
|
||||
static struct pca954x_platform_data mux_data_0_0 = {
|
||||
.modes = mux_modes_0_0,
|
||||
.num_modes = 8,
|
||||
};
|
||||
static struct pca954x_platform_data mux_data_0_1 = {
|
||||
.modes = mux_modes_0_1,
|
||||
.num_modes = 8,
|
||||
};
|
||||
static struct pca954x_platform_data mux_data_0_2 = {
|
||||
.modes = mux_modes_0_2,
|
||||
.num_modes = 8,
|
||||
};
|
||||
static struct pca954x_platform_data mux_data_0_3 = {
|
||||
.modes = mux_modes_0_3,
|
||||
.num_modes = 8,
|
||||
};
|
||||
static struct pca954x_platform_data mux_data_0_4 = {
|
||||
.modes = mux_modes_0_4,
|
||||
.num_modes = 8,
|
||||
};
|
||||
static struct pca954x_platform_data mux_data_0_5 = {
|
||||
.modes = mux_modes_0_5,
|
||||
.num_modes = 8,
|
||||
};
|
||||
static struct pca954x_platform_data mux_data_0_6 = {
|
||||
.modes = mux_modes_0_6,
|
||||
.num_modes = 8,
|
||||
};
|
||||
|
||||
|
||||
static struct i2c_board_info xlp_i2c_device_info0[] __initdata = {
|
||||
{"inv_psoc", 0, 0x66, 0, 0, 0},//psoc
|
||||
{"inv_cpld", 0, 0x55, 0, 0, 0},//cpld
|
||||
{"pca9548", 0, 0x71, &mux_data_0, 0, 0},
|
||||
};
|
||||
|
||||
static struct i2c_board_info xlp_i2c_device_info1[] __initdata = {
|
||||
{"inv_psoc", 0, 0x66, 0, 0, 0},//psoc
|
||||
{"inv_cpld", 0, 0x55, 0, 0, 0},//cpld
|
||||
};
|
||||
|
||||
static struct i2c_board_info xlp_i2c_device_info2[] __initdata = {
|
||||
{"pca9548", 0, 0x72, &mux_data_0_0, 0, 0},
|
||||
};
|
||||
|
||||
static struct i2c_board_info xlp_i2c_device_info3[] __initdata = {
|
||||
{"pca9548", 0, 0x72, &mux_data_0_1, 0, 0},
|
||||
};
|
||||
|
||||
static struct i2c_board_info xlp_i2c_device_info4[] __initdata = {
|
||||
{"pca9548", 0, 0x72, &mux_data_0_2, 0, 0},
|
||||
};
|
||||
|
||||
static struct i2c_board_info xlp_i2c_device_info5[] __initdata = {
|
||||
{"pca9548", 0, 0x72, &mux_data_0_3, 0, 0},
|
||||
};
|
||||
static struct i2c_board_info xlp_i2c_device_info6[] __initdata = {
|
||||
{"pca9548", 0, 0x72, &mux_data_0_4, 0, 0},
|
||||
};
|
||||
static struct i2c_board_info xlp_i2c_device_info7[] __initdata = {
|
||||
{"pca9548", 0, 0x72, &mux_data_0_5, 0, 0},
|
||||
};
|
||||
static struct i2c_board_info xlp_i2c_device_info8[] __initdata = {
|
||||
{"pca9548", 0, 0x72, &mux_data_0_6, 0, 0},
|
||||
};
|
||||
|
||||
|
||||
static struct inv_i2c_board_info i2cdev_list[] = {
|
||||
{0, ARRAY_SIZE(xlp_i2c_device_info0), xlp_i2c_device_info0 }, //smbus 0
|
||||
|
||||
{2, ARRAY_SIZE(xlp_i2c_device_info2), xlp_i2c_device_info2 }, //mux 0
|
||||
{3, ARRAY_SIZE(xlp_i2c_device_info3), xlp_i2c_device_info3 }, //mux 1
|
||||
{4, ARRAY_SIZE(xlp_i2c_device_info4), xlp_i2c_device_info4 }, //mux 2
|
||||
{5, ARRAY_SIZE(xlp_i2c_device_info5), xlp_i2c_device_info5 }, //mux 3
|
||||
{6, ARRAY_SIZE(xlp_i2c_device_info6), xlp_i2c_device_info6 }, //mux 4
|
||||
{7, ARRAY_SIZE(xlp_i2c_device_info7), xlp_i2c_device_info7 }, //mux 5
|
||||
{8, ARRAY_SIZE(xlp_i2c_device_info8), xlp_i2c_device_info8 }, //mux 6
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
static struct i2c_gpio_platform_data i2c_gpio_platdata = {
|
||||
.scl_pin = 8,
|
||||
.sda_pin = 9,
|
||||
|
||||
.udelay = 5, //5:100kHz
|
||||
.sda_is_open_drain = 0,
|
||||
.scl_is_open_drain = 0,
|
||||
.scl_is_output_only = 0
|
||||
};
|
||||
|
||||
static struct platform_device magnolia_device_i2c_gpio = {
|
||||
.name = "i2c-gpio",
|
||||
.id = 0, // adapter number
|
||||
.dev.platform_data = &i2c_gpio_platdata,
|
||||
};
|
||||
|
||||
#define PLAT_MAX_I2C_CLIENTS 32
|
||||
static struct i2c_client *plat_i2c_client[PLAT_MAX_I2C_CLIENTS];
|
||||
static int num_i2c_clients = 0;
|
||||
static int plat_i2c_client_add(struct i2c_client *e)
|
||||
{
|
||||
if (num_i2c_clients >= PLAT_MAX_I2C_CLIENTS)
|
||||
return -1;
|
||||
|
||||
plat_i2c_client[num_i2c_clients] = e;
|
||||
num_i2c_clients++;
|
||||
return num_i2c_clients;
|
||||
}
|
||||
|
||||
static void plat_i2c_client_remove_all(void)
|
||||
{
|
||||
int i;
|
||||
for (i = num_i2c_clients-1; i >= 0; i--)
|
||||
i2c_unregister_device(plat_i2c_client[i]);
|
||||
}
|
||||
|
||||
static int __init plat_magnolia_init(void)
|
||||
{
|
||||
struct i2c_adapter *adap = NULL;
|
||||
struct i2c_client *e = NULL;
|
||||
int ret = 0;
|
||||
int i,j;
|
||||
|
||||
for(i=0; i<ARRAY_SIZE(i2cdev_list); i++) {
|
||||
|
||||
adap = i2c_get_adapter( i2cdev_list[i].ch );
|
||||
if (adap == NULL) {
|
||||
printk("magnolia get channel %d adapter fail\n", i);
|
||||
continue;
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
i2c_put_adapter(adap);
|
||||
for(j=0; j<i2cdev_list[i].size; j++) {
|
||||
e = i2c_new_device(adap, &i2cdev_list[i].board_info[j] );
|
||||
|
||||
if (plat_i2c_client_add(e)<0) {
|
||||
printk("too many i2c clients added (PLAT_MAX_I2C_CLIENTS=%d)\n", PLAT_MAX_I2C_CLIENTS);
|
||||
plat_i2c_client_remove_all();
|
||||
return -ENODEV;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void __exit plat_magnolia_exit(void)
|
||||
{
|
||||
plat_i2c_client_remove_all();
|
||||
}
|
||||
|
||||
module_init(plat_magnolia_init);
|
||||
module_exit(plat_magnolia_exit);
|
||||
|
||||
MODULE_AUTHOR("Inventec");
|
||||
MODULE_DESCRIPTION("Magnolia Platform devices");
|
||||
MODULE_LICENSE("GPL");
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,183 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef IO_EXPANDER_H
|
||||
#define IO_EXPANDER_H
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
|
||||
/* IOEXP type define (SFP series) */
|
||||
#define IOEXP_TYPE_MAGINOLIA_NAB (10101)
|
||||
#define IOEXP_TYPE_MAGINOLIA_4AB (10102)
|
||||
#define IOEXP_TYPE_CYPRESS_NABC (10103)
|
||||
|
||||
/* IOEXP type define (QSFP series) */
|
||||
#define IOEXP_TYPE_MAGINOLIA_7AB (10201)
|
||||
#define IOEXP_TYPE_REDWOOD_P01P08 (10202)
|
||||
#define IOEXP_TYPE_REDWOOD_P09P16 (10203)
|
||||
#define IOEXP_TYPE_HUDSON32IGA_P01P08 (10204)
|
||||
#define IOEXP_TYPE_HUDSON32IGA_P09P16 (10205)
|
||||
#define IOEXP_TYPE_SPRUCE_7AB (10206)
|
||||
#define IOEXP_TYPE_CYPRESS_7ABC (10207)
|
||||
#define IOEXP_TYPE_TAHOE_5A (10208)
|
||||
#define IOEXP_TYPE_TAHOE_6ABC (10209)
|
||||
#define IOEXP_TYPE_SEQUOIA_NABC (10210)
|
||||
#define IOEXP_TYPE_LAVENDER_P65 (10211)
|
||||
|
||||
/* IOEXP mode define */
|
||||
#define IOEXP_MODE_POLLING (19000)
|
||||
#define IOEXP_MODE_DIRECT (19001)
|
||||
|
||||
/* IOEXP state define */
|
||||
#define STATE_IOEXP_NORMAL (0)
|
||||
#define STATE_IOEXP_INIT (-1)
|
||||
#define STATE_IOEXP_ABNORMAL (-2)
|
||||
|
||||
/* IOEXP error code define */
|
||||
#define ERR_IOEXP_NOTSUPPORT (-100)
|
||||
#define ERR_IOEXP_UNINIT (-101)
|
||||
#define ERR_IOEXP_BADCONF (-102)
|
||||
#define ERR_IOEXP_ABNORMAL (-103)
|
||||
#define ERR_IOEXP_NOSTATE (-104)
|
||||
#define ERR_IOEXP_BADINPUT (-105)
|
||||
#define ERR_IOEXP_UNEXCPT (-199)
|
||||
|
||||
|
||||
#define SWPS_INFO(fmt, args...) printk( KERN_INFO "[SWPS] " fmt, ##args)
|
||||
#define SWPS_WARN(fmt, args...) printk( KERN_WARNING "[SWPS] " fmt, ##args)
|
||||
#define SWPS_ERR(fmt, args...) printk( KERN_ERR "[SWPS] " fmt, ##args)
|
||||
|
||||
#ifdef DEBUG_SWPS
|
||||
# define SWPS_DEBUG(fmt, args...) printk( KERN_DEBUG "[SWPS] " fmt, ##args)
|
||||
#else
|
||||
# define SWPS_DEBUG(fmt, args...)
|
||||
#endif
|
||||
|
||||
|
||||
struct ioexp_addr_s {
|
||||
int chan_id;
|
||||
int chip_addr;
|
||||
int read_offset[8];
|
||||
int write_offset[8];
|
||||
int conf_offset[8];
|
||||
uint8_t data_default[8];
|
||||
uint8_t conf_default[8];
|
||||
};
|
||||
|
||||
struct ioexp_i2c_s {
|
||||
int chip_id;
|
||||
struct i2c_client *i2c_client_p;
|
||||
struct ioexp_i2c_s *next;
|
||||
};
|
||||
|
||||
|
||||
struct ioexp_bitmap_s {
|
||||
int chip_id; /* IOEXP chip id */
|
||||
int ioexp_voffset; /* IOEXP virtual offset */
|
||||
int bit_shift;
|
||||
};
|
||||
|
||||
struct ioexp_map_s {
|
||||
int chip_amount; /* Number of chips that IOEXP object content */
|
||||
int data_width; /* Number of (Read/Write/Config) bytes */
|
||||
struct ioexp_addr_s *map_addr; /* Chip address info */
|
||||
struct ioexp_bitmap_s map_present[10]; /* IOEXP for SFP / QSFP */
|
||||
struct ioexp_bitmap_s map_tx_disable[10]; /* IOEXP for SFP */
|
||||
struct ioexp_bitmap_s map_tx_fault[10]; /* IOEXP for SFP */
|
||||
struct ioexp_bitmap_s map_rxlos[10]; /* IOEXP for SFP */
|
||||
struct ioexp_bitmap_s map_reset[10]; /* IOEXP for QSFP */
|
||||
struct ioexp_bitmap_s map_lpmod[10]; /* IOEXP for QSFP */
|
||||
struct ioexp_bitmap_s map_modsel[10]; /* IOEXP for QSFP */
|
||||
struct ioexp_bitmap_s map_hard_rs0[10]; /* IOEXP for QSFP */
|
||||
struct ioexp_bitmap_s map_hard_rs1[10]; /* IOEXP for QSFP */
|
||||
};
|
||||
|
||||
struct ioexp_data_s {
|
||||
uint8_t data[8];
|
||||
};
|
||||
|
||||
struct ioexp_obj_s {
|
||||
|
||||
/* ============================
|
||||
* Object public property
|
||||
* ============================
|
||||
*/
|
||||
int ioexp_id;
|
||||
int ioexp_type;
|
||||
|
||||
/* ============================
|
||||
* Object private property
|
||||
* ============================
|
||||
*/
|
||||
struct ioexp_data_s chip_data[16]; /* Max: 8-ioexp in one virt-ioexp(ioexp_obj) */
|
||||
struct ioexp_map_s *ioexp_map_p;
|
||||
struct ioexp_obj_s *next;
|
||||
struct ioexp_i2c_s *i2c_head_p;
|
||||
struct mutex lock;
|
||||
int mode;
|
||||
int state;
|
||||
|
||||
/* ===========================================
|
||||
* Object public functions
|
||||
* ===========================================
|
||||
*/
|
||||
int (*get_present)(struct ioexp_obj_s *self, int virt_offset);
|
||||
int (*get_tx_fault)(struct ioexp_obj_s *self, int virt_offset);
|
||||
int (*get_rxlos)(struct ioexp_obj_s *self, int virt_offset);
|
||||
int (*get_tx_disable)(struct ioexp_obj_s *self, int virt_offset);
|
||||
int (*get_reset)(struct ioexp_obj_s *self, int virt_offset);
|
||||
int (*get_lpmod)(struct ioexp_obj_s *self, int virt_offset);
|
||||
int (*get_modsel)(struct ioexp_obj_s *self, int virt_offset);
|
||||
int (*get_hard_rs0)(struct ioexp_obj_s *self, int virt_offset);
|
||||
int (*get_hard_rs1)(struct ioexp_obj_s *self, int virt_offset);
|
||||
int (*set_tx_disable)(struct ioexp_obj_s *self, int virt_offset, int input_val);
|
||||
int (*set_reset)(struct ioexp_obj_s *self, int virt_offset, int input_val);
|
||||
int (*set_lpmod)(struct ioexp_obj_s *self, int virt_offset, int input_val);
|
||||
int (*set_modsel)(struct ioexp_obj_s *self, int virt_offset, int input_val);
|
||||
int (*set_hard_rs0)(struct ioexp_obj_s *self, int virt_offset, int input_val);
|
||||
int (*set_hard_rs1)(struct ioexp_obj_s *self, int virt_offset, int input_val);
|
||||
|
||||
/* ===========================================
|
||||
* Object private functions
|
||||
* ===========================================
|
||||
*/
|
||||
int (*init)(struct ioexp_obj_s *self);
|
||||
int (*check)(struct ioexp_obj_s *self);
|
||||
int (*update_all)(struct ioexp_obj_s *self, int show_err, char *caller_name);
|
||||
int (*fsm_4_direct)(struct ioexp_obj_s* self);
|
||||
int (*fsm_4_polling)(struct ioexp_obj_s* self);
|
||||
};
|
||||
|
||||
|
||||
struct ioexp_obj_s* get_ioexp_obj(int ioexp_id);
|
||||
int create_ioexp_obj(int ioexp_id,
|
||||
int ioexp_type,
|
||||
struct ioexp_addr_s *addr_map_p,
|
||||
int run_mode);
|
||||
int init_ioexp_objs(void);
|
||||
int check_ioexp_objs(void);
|
||||
void clean_ioexp_objs(void);
|
||||
|
||||
void unlock_ioexp_all(void);
|
||||
int lock_ioexp_all(void);
|
||||
|
||||
int check_channel_tier_1(void);
|
||||
int resync_channel_tier_1(void);
|
||||
|
||||
/* Macro for bit control */
|
||||
#define SWP_BIT_SET(byte_val,bit_shift) ((byte_val) |= (1<<(bit_shift)))
|
||||
#define SWP_BIT_CLEAR(byte_val,bit_shift) ((byte_val) &= ~(1<<(bit_shift)))
|
||||
|
||||
|
||||
#endif /* IO_EXPANDER_H */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,814 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef TRANSCEIVER_H
|
||||
#define TRANSCEIVER_H
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
/* advanced features control */
|
||||
#define TRANSVR_INFO_DUMP_ENABLE (1)
|
||||
#define TRANSVR_INFO_CACHE_ENABLE (1)
|
||||
#define TRANSVR_UEVENT_ENABLE (1)
|
||||
|
||||
/* Transceiver type define */
|
||||
#define TRANSVR_TYPE_UNKNOW_1 (0x00)
|
||||
#define TRANSVR_TYPE_UNKNOW_2 (0xff)
|
||||
#define TRANSVR_TYPE_SFP (0x03) /* Define for SFP, SFP+, SFP28 */
|
||||
#define TRANSVR_TYPE_QSFP (0x0c)
|
||||
#define TRANSVR_TYPE_QSFP_PLUS (0x0d)
|
||||
#define TRANSVR_TYPE_QSFP_28 (0x11)
|
||||
#define TRANSVR_TYPE_UNPLUGGED (0xfa) /* Define for ERROR handle */
|
||||
#define TRANSVR_TYPE_FAKE (0xfc) /* Define for ERROR handle */
|
||||
#define TRANSVR_TYPE_INCONSISTENT (0xfd) /* Define for ERROR handle */
|
||||
#define TRANSVR_TYPE_ERROR (0xfe) /* Define for ERROR handle */
|
||||
|
||||
/* Transceiver class for base info */
|
||||
#define TRANSVR_CLASS_UNSPECIFIED (0)
|
||||
#define TRANSVR_CLASS_ERROR (-26001)
|
||||
#define TRANSVR_CLASS_1G (26001)
|
||||
#define TRANSVR_CLASS_10G (26011)
|
||||
#define TRANSVR_CLASS_25G (26021)
|
||||
#define TRANSVR_CLASS_40G (26041)
|
||||
#define TRANSVR_CLASS_100G (26101)
|
||||
#define TRANSVR_CLASS_NO_SPERARABLE (26901)
|
||||
#define TRANSVR_CLASS_EXTEND_COMP (26902)
|
||||
/* Transceiver class for Optical 1G */
|
||||
#define TRANSVR_CLASS_OPTICAL (27000)
|
||||
#define TRANSVR_CLASS_OPTICAL_100 (27001)
|
||||
#define TRANSVR_CLASS_OPTICAL_1G (27002)
|
||||
#define TRANSVR_CLASS_OPTICAL_1G_AOC (27003)
|
||||
#define TRANSVR_CLASS_OPTICAL_1G_SX (27004)
|
||||
#define TRANSVR_CLASS_OPTICAL_1G_LX (27005)
|
||||
#define TRANSVR_CLASS_OPTICAL_1G_EX (27006)
|
||||
/* Transceiver class for Optical 10G */
|
||||
#define TRANSVR_CLASS_OPTICAL_10G (27010)
|
||||
#define TRANSVR_CLASS_OPTICAL_10G_S_AOC (27011)
|
||||
#define TRANSVR_CLASS_OPTICAL_10G_S_SR (27012)
|
||||
#define TRANSVR_CLASS_OPTICAL_10G_S_LR (27013)
|
||||
#define TRANSVR_CLASS_OPTICAL_10G_S_ER (27014)
|
||||
#define TRANSVR_CLASS_OPTICAL_10G_Q_AOC (27015)
|
||||
#define TRANSVR_CLASS_OPTICAL_10G_Q_SR (27016)
|
||||
#define TRANSVR_CLASS_OPTICAL_10G_Q_LR (27017)
|
||||
#define TRANSVR_CLASS_OPTICAL_10G_Q_ER (27018)
|
||||
/* Transceiver class for Optical 25G */
|
||||
#define TRANSVR_CLASS_OPTICAL_25G (27020)
|
||||
#define TRANSVR_CLASS_OPTICAL_25G_AOC (27021)
|
||||
#define TRANSVR_CLASS_OPTICAL_25G_SR (27022)
|
||||
#define TRANSVR_CLASS_OPTICAL_25G_LR (27023)
|
||||
#define TRANSVR_CLASS_OPTICAL_25G_ER (27024)
|
||||
/* Transceiver class for Optical 40G */
|
||||
#define TRANSVR_CLASS_OPTICAL_40G (27040)
|
||||
#define TRANSVR_CLASS_OPTICAL_40G_AOC (27041)
|
||||
#define TRANSVR_CLASS_OPTICAL_40G_SR4 (27042)
|
||||
#define TRANSVR_CLASS_OPTICAL_40G_LR4 (27043)
|
||||
#define TRANSVR_CLASS_OPTICAL_40G_ER4 (27044)
|
||||
/* Transceiver class for Optical 100G */
|
||||
#define TRANSVR_CLASS_OPTICAL_100G (27100)
|
||||
#define TRANSVR_CLASS_OPTICAL_100G_AOC (27101)
|
||||
#define TRANSVR_CLASS_OPTICAL_100G_SR4 (27102)
|
||||
#define TRANSVR_CLASS_OPTICAL_100G_LR4 (27103)
|
||||
#define TRANSVR_CLASS_OPTICAL_100G_ER4 (27104)
|
||||
#define TRANSVR_CLASS_OPTICAL_100G_PSM4 (27105)
|
||||
/* Transceiver class for Copper */
|
||||
#define TRANSVR_CLASS_COPPER (28000)
|
||||
#define TRANSVR_CLASS_COPPER_L1_1G (28001)
|
||||
#define TRANSVR_CLASS_COPPER_L1_10G (28011)
|
||||
#define TRANSVR_CLASS_COPPER_L4_10G (28012)
|
||||
#define TRANSVR_CLASS_COPPER_L1_25G (28021)
|
||||
#define TRANSVR_CLASS_COPPER_L4_40G (28041)
|
||||
#define TRANSVR_CLASS_COPPER_L4_100G (28101)
|
||||
/* Transceiver class for Base-T */
|
||||
#define TRANSVR_CLASS_BASE_T_1000 (29001)
|
||||
#define TRANSVR_CLASS_BASE_T_1000_up (29002)
|
||||
/* For uevent message */
|
||||
#define TRANSVR_UEVENT_KEY_IF "IF_TYPE"
|
||||
#define TRANSVR_UEVENT_KEY_SP "IF_SPEED"
|
||||
#define TRANSVR_UEVENT_KEY_LANE "IF_LANE"
|
||||
#define TRANSVR_UEVENT_UNKNOW "UNKNOW"
|
||||
#define TRANSVR_IF_KR "KR"
|
||||
#define TRANSVR_IF_KR4 "KR4"
|
||||
#define TRANSVR_IF_SR "SR"
|
||||
#define TRANSVR_IF_SR4 "SR4"
|
||||
#define TRANSVR_IF_SFI "SFI"
|
||||
#define TRANSVR_IF_IF_GMII "GMII"
|
||||
#define TRANSVR_IF_IF_XGMII "XGMII"
|
||||
#define TRANSVR_IF_SP_100 "100"
|
||||
#define TRANSVR_IF_SP_1G "1000"
|
||||
#define TRANSVR_IF_SP_10G "10000"
|
||||
#define TRANSVR_IF_SP_25G "25000"
|
||||
#define TRANSVR_IF_SP_40G "40000"
|
||||
#define TRANSVR_IF_SP_100G "100000"
|
||||
|
||||
/* Transceiver mode define */
|
||||
#define TRANSVR_MODE_DIRECT (21000)
|
||||
#define TRANSVR_MODE_POLLING (21001)
|
||||
|
||||
/* Transceiver state define
|
||||
* [Note]
|
||||
* 1. State is used to represent the state of "Transceiver" and "Object".
|
||||
* 2. State for different target has different means. The description as following:
|
||||
*/
|
||||
#define STATE_TRANSVR_CONNECTED (0) /* [Transvr]:Be plugged in. [Obj]:Link up, and work normally. */
|
||||
#define STATE_TRANSVR_NEW (-100) /* [Transvr]:(Not used) [Obj]:Create */
|
||||
#define STATE_TRANSVR_INIT (-101) /* [Transvr]:Be plugged in. [Obj]:Link up, and in initial process. */
|
||||
#define STATE_TRANSVR_ISOLATED (-102) /* [Transvr]:Be plugged in. [Obj]:Isolate, and not provide service. */
|
||||
#define STATE_TRANSVR_SWAPPED (-200) /* [Transvr]:Be plugged in. [Obj]:(Not used) */
|
||||
#define STATE_TRANSVR_DISCONNECTED (-300) /* [Transvr]:Un-plugged. [Obj]:Link down, and not provide service. */
|
||||
#define STATE_TRANSVR_UNEXCEPTED (-901) /* [Transvr]:Any [Obj]:Any, and not in expect case. */
|
||||
|
||||
/* Task state define */
|
||||
#define STATE_T_TASK_WAIT (110)
|
||||
#define STATE_T_TASK_DONE (0)
|
||||
#define STATE_T_TASK_INIT (-110)
|
||||
#define STATE_T_TASK_FAIL (-410)
|
||||
|
||||
|
||||
/* Event for task handling */
|
||||
#define EVENT_TRANSVR_TASK_WAIT (2101)
|
||||
#define EVENT_TRANSVR_TASK_DONE (0)
|
||||
#define EVENT_TRANSVR_TASK_FAIL (-2101)
|
||||
/* Event for initial handling */
|
||||
#define EVENT_TRANSVR_INIT_UP (2201)
|
||||
#define EVENT_TRANSVR_INIT_DOWN (1)
|
||||
#define EVENT_TRANSVR_INIT_REINIT (-2201)
|
||||
#define EVENT_TRANSVR_INIT_FAIL (-2202)
|
||||
/* Event for others */
|
||||
#define EVENT_TRANSVR_RELOAD_FAIL (-2301)
|
||||
#define EVENT_TRANSVR_EXCEP_INIT (-2401)
|
||||
#define EVENT_TRANSVR_EXCEP_UP (-2402)
|
||||
#define EVENT_TRANSVR_EXCEP_DOWN (-2403)
|
||||
#define EVENT_TRANSVR_EXCEP_SWAP (-2404)
|
||||
#define EVENT_TRANSVR_EXCEP_EXCEP (-2405)
|
||||
#define EVENT_TRANSVR_EXCEP_ISOLATED (-2406)
|
||||
#define EVENT_TRANSVR_I2C_CRASH (-2501)
|
||||
|
||||
/* Transceiver error code define */
|
||||
#define ERR_TRANSVR_UNINIT (-201)
|
||||
#define ERR_TRANSVR_UNPLUGGED (-202)
|
||||
#define ERR_TRANSVR_ABNORMAL (-203)
|
||||
#define ERR_TRANSVR_NOSTATE (-204)
|
||||
#define ERR_TRANSVR_NOTSUPPORT (-205)
|
||||
#define ERR_TRANSVR_BADINPUT (-206)
|
||||
#define ERR_TRANSVR_UPDATE_FAIL (-207)
|
||||
#define ERR_TRANSVR_RELOAD_FAIL (-208)
|
||||
#define ERR_TRANSVR_INIT_FAIL (-209)
|
||||
#define ERR_TRANSVR_UNDEFINED (-210)
|
||||
#define ERR_TRANSVR_TASK_FAIL (-211)
|
||||
#define ERR_TRANSVR_TASK_BUSY (-212)
|
||||
#define ERR_TRANSVR_UEVENT_FAIL (-213)
|
||||
#define ERR_TRANSVR_FUNC_DISABLE (-214)
|
||||
#define ERR_TRANSVR_I2C_CRASH (-297)
|
||||
#define ERR_TRNASVR_BE_ISOLATED (-298)
|
||||
#define ERR_TRANSVR_UNEXCPT (-299)
|
||||
|
||||
/* For debug */
|
||||
#define DEBUG_TRANSVR_INT_VAL (-99)
|
||||
#define DEBUG_TRANSVR_HEX_VAL (0xfe)
|
||||
#define DEBUG_TRANSVR_STR_VAL "ERROR"
|
||||
|
||||
/* For system internal */
|
||||
#define VAL_TRANSVR_COMID_ARREESS (0x50)
|
||||
#define VAL_TRANSVR_COMID_OFFSET (0x00)
|
||||
#define VAL_TRANSVR_EXTPHY_ADDR_56 (0x56)
|
||||
#define VAL_TRANSVR_8472_READY_ADDR (0x51)
|
||||
#define VAL_TRANSVR_8472_READY_PAGE (-1)
|
||||
#define VAL_TRANSVR_8472_READY_OFFSET (110)
|
||||
#define VAL_TRANSVR_8472_READY_BIT (0)
|
||||
#define VAL_TRANSVR_8472_READY_VALUE (0)
|
||||
#define VAL_TRANSVR_8472_READY_ABNORMAL (0xff)
|
||||
#define VAL_TRANSVR_8436_READY_ADDR (0x50)
|
||||
#define VAL_TRANSVR_8436_READY_PAGE (-1)
|
||||
#define VAL_TRANSVR_8436_READY_OFFSET (2)
|
||||
#define VAL_TRANSVR_8436_READY_BIT (0)
|
||||
#define VAL_TRANSVR_8436_READY_VALUE (0)
|
||||
#define VAL_TRANSVR_8436_READY_ABNORMAL (0xff)
|
||||
#define VAL_TRANSVR_8436_PWD_ADDR (0x50)
|
||||
#define VAL_TRANSVR_8436_PWD_PAGE (-1)
|
||||
#define VAL_TRANSVR_8436_PWD_OFFSET (123)
|
||||
#define VAL_TRANSVR_PAGE_FREE (-99)
|
||||
#define VAL_TRANSVR_PAGE_SELECT_OFFSET (127)
|
||||
#define VAL_TRANSVR_PAGE_SELECT_DELAY (5)
|
||||
#define VAL_TRANSVR_TASK_RETRY_FOREVER (-999)
|
||||
#define VAL_TRANSVR_FUNCTION_DISABLE (-1)
|
||||
#define STR_TRANSVR_SFP "SFP"
|
||||
#define STR_TRANSVR_QSFP "QSFP"
|
||||
#define STR_TRANSVR_QSFP_PLUS "QSFP+"
|
||||
#define STR_TRANSVR_QSFP28 "QSFP28"
|
||||
|
||||
/* For transvr buf len */
|
||||
#define LEN_TRANSVR_S_STR (16)
|
||||
#define LEN_TRANSVR_M_STR (32)
|
||||
#define LEN_TRANSVR_L_STR (64)
|
||||
|
||||
/* Optical wavelength */
|
||||
#define VAL_OPTICAL_WAVELENGTH_SR (850)
|
||||
#define VAL_OPTICAL_WAVELENGTH_LR (1310)
|
||||
#define VAL_OPTICAL_WAVELENGTH_ER (1550)
|
||||
|
||||
/* BCM chip type define */
|
||||
#define BCM_CHIP_TYPE_TRIDENT_2 (31001) /* Magnolia, Hudson32i, Spruce */
|
||||
#define BCM_CHIP_TYPE_TOMAHAWK (31002) /* Redwood, Cypress, Sequoia */
|
||||
|
||||
#define BF_CHIP_TYPE_TOFINO (31011) /* Lavender */
|
||||
|
||||
/* Info from transceiver EEPROM */
|
||||
struct eeprom_map_s {
|
||||
int addr_br; int page_br; int offset_br; int length_br;
|
||||
int addr_cdr; int page_cdr; int offset_cdr; int length_cdr;
|
||||
int addr_comp_rev; int page_comp_rev; int offset_comp_rev; int length_comp_rev;
|
||||
int addr_connector; int page_connector; int offset_connector; int length_connector;
|
||||
int addr_diag_type; int page_diag_type; int offset_diag_type; int length_diag_type;
|
||||
int addr_extbr; int page_extbr; int offset_extbr; int length_extbr;
|
||||
int addr_ext_id; int page_ext_id; int offset_ext_id; int length_ext_id;
|
||||
int addr_id; int page_id; int offset_id; int length_id;
|
||||
int addr_len_sm; int page_len_sm; int offset_len_sm; int length_len_sm;
|
||||
int addr_len_smf; int page_len_smf; int offset_len_smf; int length_len_smf;
|
||||
int addr_len_om1; int page_len_om1; int offset_len_om1; int length_len_om1;
|
||||
int addr_len_om2; int page_len_om2; int offset_len_om2; int length_len_om2;
|
||||
int addr_len_om3; int page_len_om3; int offset_len_om3; int length_len_om3;
|
||||
int addr_len_om4; int page_len_om4; int offset_len_om4; int length_len_om4;
|
||||
int addr_option; int page_option; int offset_option; int length_option;
|
||||
int addr_rate_id; int page_rate_id; int offset_rate_id; int length_rate_id;
|
||||
int addr_rx_am; int page_rx_am; int offset_rx_am; int length_rx_am;
|
||||
int addr_rx_em; int page_rx_em; int offset_rx_em; int length_rx_em;
|
||||
int addr_rx_los; int page_rx_los; int offset_rx_los; int length_rx_los;
|
||||
int addr_rx_power; int page_rx_power; int offset_rx_power; int length_rx_power;
|
||||
int addr_soft_rs0; int page_soft_rs0; int offset_soft_rs0; int length_soft_rs0;
|
||||
int addr_soft_rs1; int page_soft_rs1; int offset_soft_rs1; int length_soft_rs1;
|
||||
int addr_temp; int page_temp; int offset_temp; int length_temp;
|
||||
int addr_trancomp; int page_trancomp; int offset_trancomp; int length_trancomp;
|
||||
int addr_trancomp_ext; int page_trancomp_ext; int offset_trancomp_ext; int length_trancomp_ext;
|
||||
int addr_tx_bias; int page_tx_bias; int offset_tx_bias; int length_tx_bias;
|
||||
int addr_tx_disable; int page_tx_disable; int offset_tx_disable; int length_tx_disable;
|
||||
int addr_tx_eq; int page_tx_eq; int offset_tx_eq; int length_tx_eq;
|
||||
int addr_tx_fault; int page_tx_fault; int offset_tx_fault; int length_tx_fault;
|
||||
int addr_tx_power; int page_tx_power; int offset_tx_power; int length_tx_power;
|
||||
int addr_vendor_name; int page_vendor_name; int offset_vendor_name; int length_vendor_name;
|
||||
int addr_vendor_pn; int page_vendor_pn; int offset_vendor_pn; int length_vendor_pn;
|
||||
int addr_vendor_rev; int page_vendor_rev; int offset_vendor_rev; int length_vendor_rev;
|
||||
int addr_vendor_sn; int page_vendor_sn; int offset_vendor_sn; int length_vendor_sn;
|
||||
int addr_voltage; int page_voltage; int offset_voltage; int length_voltage;
|
||||
int addr_wavelength; int page_wavelength; int offset_wavelength; int length_wavelength;
|
||||
};
|
||||
|
||||
|
||||
struct transvr_worker_s;
|
||||
|
||||
/* Class of transceiver object */
|
||||
struct transvr_obj_s {
|
||||
|
||||
/* ========== Object private property ==========
|
||||
* [Prop]: id
|
||||
* [Desc]: Type of serial transceiver.
|
||||
* [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh /QSFP28:11h
|
||||
*/
|
||||
uint8_t id;
|
||||
|
||||
/* [Prop]: connector
|
||||
* [Desc]: Connector type.
|
||||
* [Note]: SFP : A0h / 2
|
||||
* QSFP: 00h / 130
|
||||
*/
|
||||
uint8_t connector;
|
||||
|
||||
/* [Prop]: transvr_comp
|
||||
* [Desc]: Transceiver compliance code.
|
||||
* [Note]: SFP: SFF-8472
|
||||
* - Normal : A0h / offset 3-10
|
||||
* - Extended: A0h / offset 36
|
||||
* QSFP: SFF-8436 & SFF-8636
|
||||
* - Normal : 00h / offset 131-138
|
||||
* - Extended: 00h / offset 192
|
||||
*/
|
||||
uint8_t transvr_comp[8];
|
||||
uint8_t transvr_comp_ext;
|
||||
|
||||
/* [Prop]: vendor_name
|
||||
* [Desc]: SFP vendor name (ASCII 16 byte char).
|
||||
* [Note]: ex:FINISAR CORP.
|
||||
*/
|
||||
char *vendor_name;
|
||||
|
||||
/* [Prop]: vendor_pn
|
||||
* [Desc]: Part number provided by SFP vendor (ASCII 16 byte char).
|
||||
* [Note]:
|
||||
*/
|
||||
char *vendor_pn;
|
||||
|
||||
/* [Prop]: vendor_rev
|
||||
* [Desc]: Revision level for part number provided by vendor (ASCII 4 byte char).
|
||||
* [Note]:
|
||||
*/
|
||||
char *vendor_rev;
|
||||
|
||||
/* [Prop]: vendor_sn
|
||||
* [Desc]: Serial number provided by vendor (ASCII 16 byte char).
|
||||
* [Note]:
|
||||
*/
|
||||
char *vendor_sn;
|
||||
|
||||
/* [Prop]: Extended identifier
|
||||
* [Desc]: SFP:
|
||||
* => None
|
||||
*
|
||||
* QSFP:
|
||||
* => This byte contained two information:
|
||||
* (1) Power consumption class
|
||||
* (2) CDR function present
|
||||
* [Note]: Bit description as below:
|
||||
* [SFP]
|
||||
* None
|
||||
*
|
||||
* [QSFP]
|
||||
* (1) Power consumption class:
|
||||
* Class 1: 1.5W (Bit6-7 = 00:)
|
||||
* Class 2: 2.0W (Bit6-7 = 01:)
|
||||
* Class 3: 2.5W (Bit6-7 = 10:)
|
||||
* Class 4: 3.5W (Bit6-7 = 11:)
|
||||
* Class 5: 4.0W (Bit0-1 = 01:)
|
||||
* Class 6: 4.5W (Bit0-1 = 10:)
|
||||
* Class 7: 5.0W (Bit0-1 = 11:)
|
||||
* (2) CDR function present:
|
||||
* Bit2: 0 = No CDR in RX
|
||||
* 1 = CDR present in RX
|
||||
* Bit3: 0 = No CDR in TX
|
||||
* 1 = CDR present in TX
|
||||
*/
|
||||
uint8_t ext_id;
|
||||
|
||||
/* [Prop]: br
|
||||
* [Desc]: Nominal bit rate, units of 100 MBits/sec.
|
||||
* [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh
|
||||
* has val: 0x67
|
||||
* no val :
|
||||
*/
|
||||
uint8_t br;
|
||||
|
||||
/* [Prop]: extbr
|
||||
* [Desc]: Extended br (00h/222)
|
||||
* [Desc]: Nominal bit rate per channel, units of 250 Mbps.
|
||||
* Complements. Byte 140. See Table 32A.
|
||||
*/
|
||||
uint8_t extbr;
|
||||
|
||||
/* [Prop]: len_sm
|
||||
* [Desc]: Length (single mode)-(100's)m
|
||||
* [Note]: This value specifies the link length that is supported by the transceiver
|
||||
* while operating in compliance with the applicable standards using single mode
|
||||
* fiber. The value is in units of 100 meters. A value of 255 means that the
|
||||
* transceiver supports a link length greater than 25.4 km. A value of zero means
|
||||
* that the transceiver does not support single mode fiber or that the length
|
||||
* information must be determined from the transceiver technology.
|
||||
*/
|
||||
int len_sm;
|
||||
|
||||
/* [Prop]: len_smf
|
||||
* [Desc]: Length (single mode)-km
|
||||
* [Note]: Addition to EEPROM data from original GBIC definition. This value specifies
|
||||
* the link length that is supported by the transceiver while operating in
|
||||
* compliance with the applicable standards using single mode fiber. The value
|
||||
* is in units of kilometers. A value of 255 means that the transceiver supports
|
||||
* a link length greater than 254 km. A value of zero means that the transceiver
|
||||
* does not support single mode fiber or that the length information must be
|
||||
* determined from the transceiver technology.
|
||||
*/
|
||||
int len_smf;
|
||||
|
||||
/* [Prop]: len_om1
|
||||
* [Desc]: Link length supported for 62.5 um OM1 fiber, units of 10 m
|
||||
* [Note]: The value is in units of 10 meters. A value of 255 means that the
|
||||
* transceiver supports a link length greater than 2.54 km. A value of
|
||||
* zero means that the transceiver does not support 50 micron multi-mode
|
||||
* fiber or that the length information must be determined from the transceiver
|
||||
* technology.
|
||||
*/
|
||||
int len_om1;
|
||||
|
||||
/* [Prop]: len_om2
|
||||
* [Desc]: Link length supported for 50 um OM2 fiber, units of 10 m
|
||||
* [Note]: The value is in units of 10 meters. A value of 255 means that the
|
||||
* transceiver supports a link length greater than 2.54 km. A value of
|
||||
* zero means that the transceiver does not support 50 micron multi-mode
|
||||
* fiber or that the length information must be determined from the transceiver
|
||||
* technology.
|
||||
*/
|
||||
int len_om2;
|
||||
|
||||
/* [Prop]: len_om3
|
||||
* [Desc]: Length (50um, OM3)
|
||||
* [Note]: This value specifies link length that is supported by the transceiver while
|
||||
* operating in compliance with applicable standards using 50 micron multimode
|
||||
* OM3 [2000 MHz*km] fiber. The value is in units of 10 meters. A value of 255
|
||||
* means that the transceiver supports a link length greater than 2.54 km. A value
|
||||
* of zero means that the transceiver does not support 50 micron multimode fiber
|
||||
* or that the length information must be determined from the transceiver technology.
|
||||
*/
|
||||
int len_om3;
|
||||
|
||||
/* [Prop]: len_om4
|
||||
* [Desc]: Length (50um, OM4) and Length (Active Cable or Copper)
|
||||
* [Note]: For optical links, this value specifies link length that is supported by the
|
||||
* transceiver while operating in compliance with applicable standards using 50 micron
|
||||
* multimode OM4 [4700 MHz*km] fiber. The value is in units of 10 meters. A value of
|
||||
* 255 means that the transceiver supports a link length greater than 2.54 km. A value
|
||||
* of zero means that the transceiver does not support 50 micron multimode fiber or that
|
||||
* the length information must be determined from the transceiver codes specified in Table 5-3.
|
||||
*
|
||||
* For copper links, this value specifies minimum link length supported by the transceiver
|
||||
* while operating in compliance with applicable standards using copper cable. For active
|
||||
* cable, this value represents actual length. The value is in units of 1 meter. A value of 255
|
||||
* means the transceiver supports a link length greater than 254 meters. A value of zero means
|
||||
* the transceiver does not support copper or active cables or the length information must be
|
||||
* determined from transceiver technology. Further information about cable design, equalization,
|
||||
* and connectors is usually required to guarantee meeting a particular length requirement.
|
||||
*/
|
||||
int len_om4;
|
||||
|
||||
/* [Prop]: comp_rev
|
||||
* [Desc]: SFF spec revision compliance
|
||||
* [Note]: Indicates which revision of SFF SFF-8472 (SFP) / SFF-8636 (QSFP) the transceiver
|
||||
* complies with. (unsigned integer)
|
||||
*/
|
||||
uint8_t comp_rev;
|
||||
|
||||
/* [Prop]: CDR
|
||||
* [Desc]: For transceivers with CDR capability, setting the CDR to ON engages the internal
|
||||
* retiming function. Setting the CDR to OFF enables an internal bypassing mode ,which
|
||||
* directs traffic around the internal CDR. (Reference: SFF-8636)
|
||||
* [Note]: value=0xff: ON.
|
||||
* value=0x00: OFF.
|
||||
*/
|
||||
uint8_t cdr;
|
||||
|
||||
/* [Prop]: rate_id
|
||||
* [Desc]: Soft Rate Select 0(RX).
|
||||
* [Note]: 1. Addr: A0h / Offset: 13
|
||||
* 2. Value description:
|
||||
* 00h Unspecified
|
||||
* 01h SFF-8079 (4/2/1G Rate_Select & AS0/AS1)
|
||||
* 02h SFF-8431 (8/4/2G Rx Rate_Select only)
|
||||
* 03h Unspecified *
|
||||
* 04h SFF-8431 (8/4/2G Tx Rate_Select only)
|
||||
* 05h Unspecified *
|
||||
* 06h SFF-8431 (8/4/2G Independent Rx & Tx Rate_select)
|
||||
* 07h Unspecified *
|
||||
* 08h FC-PI-5 (16/8/4G Rx Rate_select only) High=16G only, Low=8G/4G
|
||||
* 09h Unspecified *
|
||||
* 0Ah FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) High=16G only,
|
||||
* Low=8G/4G
|
||||
* 0Bh Unspecified *
|
||||
* 0Ch FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select)
|
||||
* High=32G only, Low = 16G/8G
|
||||
* 0Dh Unspecified *
|
||||
* 0Eh 10/8G Rx and Tx Rate_Select controlling the operation or locking
|
||||
* modes of the internal signal conditioner, retimer or CDR, according
|
||||
* to the logic table defined in Table 10-2, High Bit Rate
|
||||
* (10G) =9.95-11.3 Gb/s; Low Bit Rate (8G) = 8.5 Gb/s. In this mode,
|
||||
* the default value of bit 110.3 (Soft Rate Select RS(0), Table 9-11)
|
||||
* and of bit 118.3 (Soft Rate Select RS(1), Table 10-1) is 1.
|
||||
* 0Fh Unspecified *
|
||||
* 10h-FFh Unallocated
|
||||
*/
|
||||
int rate_id;
|
||||
|
||||
/* [Prop]: soft_rs0
|
||||
* [Desc]: Soft Rate Select 0(RX).
|
||||
* [Note]: 1. Writing '1' selects full bandwidth operation.
|
||||
* 2. This bit is "OR'd with the hard Rate_Select, AS(0) or RS(0) pin value.
|
||||
* 3. Default at power up is logic zero/low
|
||||
* 4. Addr: A2h / Offset: 110 / Bit: 3
|
||||
*/
|
||||
uint8_t soft_rs0;
|
||||
|
||||
/* [Prop]: soft_rs1
|
||||
* [Desc]: Soft Rate Select 1(TX).
|
||||
* [Note]: 1. Writing '1' selects full bandwidth TX operation.
|
||||
* 2. This bit is "OR'd with the hard Rate_Select, AS(1) or RS(1) pin value.
|
||||
* 3. Default at power up is logic zero/low
|
||||
* 4. Addr: A2h / Offset: 118 / Bit: 3
|
||||
*/
|
||||
uint8_t soft_rs1;
|
||||
|
||||
/* [Prop]: diag_type
|
||||
* [Desc]: DIAGNOSTIC MONITORING TYPE (A0h/92)
|
||||
* [Note]: Description in SFF-8472 as below:
|
||||
* Bit7: Reserved for legacy diagnostic implementations. Must be '0' for compliance
|
||||
* with this document.
|
||||
* Bit6: Digital diagnostic monitoring implemented (described in this document).
|
||||
* Must be '1' for compliance with this document.
|
||||
* Bit5 Internally calibrated
|
||||
* Bit4 Externally calibrated
|
||||
* Bit3 Received power measurement type.0 = OMA, 1 = average power
|
||||
* Bit2 Address change required see section above, "addressing modes"
|
||||
* Bit1-0 Unallocated
|
||||
*/
|
||||
uint8_t diag_type;
|
||||
|
||||
/* [Prop]: curr_temp
|
||||
* [Desc]: Transceiver Current Temperature (A2h/96-97)
|
||||
* [Note]: 1. Dependent on diag_type.
|
||||
* 2. 96: High byte
|
||||
* 3. 97: Low byte
|
||||
* 4. This feature only for SFP
|
||||
*/
|
||||
uint8_t curr_temp[2];
|
||||
|
||||
/* [Prop]: curr_vol
|
||||
* [Desc]: Transceiver Current Voltage (SFP:A2h/108-109; QSFP:00h/22-23)
|
||||
* [Note]: 1. Dependent on diag_type.
|
||||
* 2. 98: High byte
|
||||
* 3. 99: Low byte
|
||||
* 4. This feature only for SFP
|
||||
* 5. Internally measured transceiver supply voltage. Represented
|
||||
* as a 16 bit unsigned integer with the voltage defined as the
|
||||
* full 16 bit value (0-65535) with LSB equal to 100 uVolt,
|
||||
* yielding a total range of 0 to +6.55 Volts
|
||||
*/
|
||||
uint8_t curr_voltage[2];
|
||||
|
||||
/* [Prop]: curr_tx_bias
|
||||
* [Desc]: Transceiver TX Bias Current (SFP:A2h/100-101; QSFP:00h/26-27)
|
||||
* [Note]: 1. Dependent on diag_type.
|
||||
* 2. 100: High byte
|
||||
* 3. 101: Low byte
|
||||
* 4. This feature only for SFP
|
||||
* 5. Measured TX bias current in uA. Represented as a 16 bit unsigned
|
||||
* integer with the current defined as the full 16 bit value (0-65535)
|
||||
* with LSB equal to 2 uA, yielding a total range of 0 to 131 mA.
|
||||
* Accuracy is vendor specific but must be better than 10% of the
|
||||
* manufacturer's nominal value over specified operating temperature
|
||||
* and voltage.
|
||||
*/
|
||||
uint8_t curr_tx_bias[8];
|
||||
|
||||
/* [Prop]: curr_tx_power
|
||||
* [Desc]: Transceiver TX Output Power (A2h/102-103)
|
||||
* [Note]: 1. Dependent on diag_type.
|
||||
* 2. 102: High byte
|
||||
* 3. 103: Low byte
|
||||
* 4. This feature only for SFP
|
||||
* 5. Measured TX output power in mW. Represented as a 16 bit unsigned
|
||||
* integer with the power defined as the full 16 bit value (0-65535)
|
||||
* with LSB equal to 0.1 uW, yielding a total range of 0 to 6.5535 mW
|
||||
* (~ -40 to +8.2 dBm). Data is assumed to be based on measurement of
|
||||
* laser monitor photodiode current. It is factory calibrated to absolute
|
||||
* units using the most representative fiber output type. Accuracy is
|
||||
* vendor specific but must be better than 3dB over specified temperature
|
||||
* and voltage. Data is not valid when the transmitter is disabled.
|
||||
*/
|
||||
uint8_t curr_tx_power[8];
|
||||
|
||||
/* [Prop]: curr_tx_power
|
||||
* [Desc]: Transceiver TX Output Power (A2h/102-103)
|
||||
* [Note]: 1. Dependent on diag_type.
|
||||
* 2. 102: High byte
|
||||
* 3. 103: Low byte
|
||||
* 4. This feature only for SFP
|
||||
* 5. Measured RX received optical power in mW. Value can represent either
|
||||
* average received power or OMA depending upon how bit 3 of byte 92 (A0h)
|
||||
* is set. Represented as a 16 bit unsigned integer with the power defined
|
||||
* as the full 16 bit value (0-65535) with LSB equal to 0.1 uW, yielding a
|
||||
* total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm). Absolute accuracy is
|
||||
* dependent upon the exact optical wavelength. For the vendor specified
|
||||
* wavelength, accuracy shall be better than 3dB over specified temperature
|
||||
* and voltage.
|
||||
*/
|
||||
uint8_t curr_rx_power[8];
|
||||
|
||||
/* [Prop]: wavelength
|
||||
* [Desc]: Wavelength or Copper Cable Attenuation
|
||||
* [Note]: (Following is info from SFF-8636)
|
||||
* For optical free side devices, this parameter identifies the nominal
|
||||
* transmitter output wavelength at room temperature. This parameter is a
|
||||
* 16-bit hex value with Byte 186 as high order byte and Byte 187 as low
|
||||
* order byte. The laser wavelength is equal to the 16-bit integer value
|
||||
* divided by 20 in nm (units of 0.05 nm). This resolution should be adequate
|
||||
* to cover all relevant wavelengths yet provide enough resolution for all
|
||||
* expected DWDM applications. For accurate representation of controlled
|
||||
* wavelength applications, this value should represent the center of the
|
||||
* guaranteed wavelength range. If the free side device is identified as
|
||||
* copper cable these registers will be used to define the cable attenuation.
|
||||
* An indication of 0 dB attenuation refers to the case where the attenuation
|
||||
* is not known or is unavailable.
|
||||
* Byte 186 (00-FFh) is the copper cable attenuation at 2.5 GHz in units of 1 dB.
|
||||
* Byte 187 (00-FFh) is the copper cable attenuation at 5.0 GHz in units of 1 dB.
|
||||
*/
|
||||
uint8_t wavelength[2];
|
||||
|
||||
/* [Prop]: Amplitude control
|
||||
* [Desc]: Amplitude control
|
||||
* [Note]: QSFP28 => SFF-8636 03H Byte-238/239
|
||||
*/
|
||||
uint8_t rx_am[2];
|
||||
|
||||
/* [Prop]: Emphasis control
|
||||
* [Desc]: Emphasis control
|
||||
* [Note]: SFP+/28 => SFF-8472 A2H Byte-115
|
||||
* QSFP28 => SFF-8636 03H Byte-236/237
|
||||
*/
|
||||
uint8_t rx_em[2];
|
||||
|
||||
/* [Prop]: Soft Rx LOS
|
||||
* [Desc]: Soft Rx LOS which provide by transceiver
|
||||
* [Note]: (Following is info from SFF-8636)
|
||||
* Byte 3:
|
||||
* - Bit 0: L-Rx1 LOS
|
||||
* - Bit 1: L-Rx2 LOS
|
||||
* - Bit 2: L-Rx3 LOS
|
||||
* - Bit 3: L-Rx4 LOS
|
||||
*/
|
||||
uint8_t rx_los;
|
||||
|
||||
/* [Prop]: Soft Tx Disable
|
||||
* [Desc]: Soft Tx Disable which provide by transceiver
|
||||
* [Note]: (Following is info from SFF-8636)
|
||||
* Byte 86:
|
||||
* - Bit 0: Tx1 Disable
|
||||
* - Bit 1: Tx2 Disable
|
||||
* - Bit 2: Tx3 Disable
|
||||
* - Bit 3: Tx4 Disable
|
||||
*/
|
||||
uint8_t tx_disable;
|
||||
|
||||
/* [Prop]: Soft Tx Fault
|
||||
* [Desc]: Soft Tx Fault which provide by transceiver
|
||||
* [Note]: (Following is info from SFF-8636)
|
||||
* Byte 86:
|
||||
* - Bit 0: Tx1 Fault
|
||||
* - Bit 1: Tx2 Fault
|
||||
* - Bit 2: Tx3 Fault
|
||||
* - Bit 3: Tx4 Fault
|
||||
*/
|
||||
uint8_t tx_fault;
|
||||
|
||||
/* [Prop]: Transceiver EQUALIZATION
|
||||
* [Desc]: Transceiver EQUALIZATION
|
||||
* [Note]: SFP+/28 => SFF-8472 A2H Byte-114
|
||||
* QSFP28 => SFF-8636 03H Byte-234/235
|
||||
*/
|
||||
uint8_t tx_eq[2];
|
||||
|
||||
/* [Prop]: OPTION VALUES
|
||||
* [Desc]: The bits in the option field shall specify the options implemented in the transceiver.
|
||||
* [Note]: SFP+/28 => SFF-8472 A0H Byte-64/65
|
||||
* QSFP+/28 => SFF-8636 00H Byte-193/195
|
||||
*/
|
||||
uint8_t option[3];
|
||||
|
||||
/* [Prop]: External PHY offset
|
||||
* [Desc]: It needs to be setup first if you want to access transceiver external phy.
|
||||
* [Note]: This feature dependent on transceiver.
|
||||
* Currently, only 1G-RJ45 transceiver supported it.
|
||||
*/
|
||||
uint8_t extphy_offset;
|
||||
|
||||
/* ========== Object private property ==========
|
||||
*/
|
||||
struct device *transvr_dev_p;
|
||||
struct eeprom_map_s *eeprom_map_p;
|
||||
struct i2c_client *i2c_client_p;
|
||||
struct ioexp_obj_s *ioexp_obj_p;
|
||||
struct transvr_worker_s *worker_p;
|
||||
struct mutex lock;
|
||||
char swp_name[32];
|
||||
int auto_config;
|
||||
int auto_tx_disable;
|
||||
int chan_id;
|
||||
int chipset_type;
|
||||
int curr_page;
|
||||
int info;
|
||||
int ioexp_virt_offset;
|
||||
int lane_id[8];
|
||||
int layout;
|
||||
int mode;
|
||||
int retry;
|
||||
int state;
|
||||
int temp;
|
||||
int type;
|
||||
|
||||
/* ========== Object public functions ==========
|
||||
*/
|
||||
int (*get_id)(struct transvr_obj_s *self);
|
||||
int (*get_ext_id)(struct transvr_obj_s *self);
|
||||
int (*get_connector)(struct transvr_obj_s *self);
|
||||
int (*get_vendor_name)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_vendor_pn)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_vendor_rev)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_vendor_sn)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_power_cls)(struct transvr_obj_s *self);
|
||||
int (*get_br)(struct transvr_obj_s *self);
|
||||
int (*get_len_sm)(struct transvr_obj_s *self);
|
||||
int (*get_len_smf)(struct transvr_obj_s *self);
|
||||
int (*get_len_om1)(struct transvr_obj_s *self);
|
||||
int (*get_len_om2)(struct transvr_obj_s *self);
|
||||
int (*get_len_om3)(struct transvr_obj_s *self);
|
||||
int (*get_len_om4)(struct transvr_obj_s *self);
|
||||
int (*get_comp_rev)(struct transvr_obj_s *self);
|
||||
int (*get_comp_eth_1)(struct transvr_obj_s *self);
|
||||
int (*get_comp_eth_10)(struct transvr_obj_s *self);
|
||||
int (*get_comp_eth_10_40)(struct transvr_obj_s *self);
|
||||
int (*get_comp_extend)(struct transvr_obj_s *self);
|
||||
int (*get_cdr)(struct transvr_obj_s *self);
|
||||
int (*get_rate_id)(struct transvr_obj_s *self);
|
||||
int (*get_soft_rs0)(struct transvr_obj_s *self);
|
||||
int (*get_soft_rs1)(struct transvr_obj_s *self);
|
||||
int (*get_info)(struct transvr_obj_s *self);
|
||||
int (*get_if_type)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_if_speed)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_if_lane)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_curr_temp)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_curr_vol)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_soft_rx_los)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_soft_tx_disable)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_soft_tx_fault)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_auto_tx_disable)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_tx_bias)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_tx_power)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_rx_power)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_tx_eq)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_rx_am)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_rx_em)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_wavelength)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_extphy_offset)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_extphy_reg)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*set_cdr)(struct transvr_obj_s *self, int input_val);
|
||||
int (*set_soft_rs0)(struct transvr_obj_s *self, int input_val);
|
||||
int (*set_soft_rs1)(struct transvr_obj_s *self, int input_val);
|
||||
int (*set_soft_tx_disable)(struct transvr_obj_s *self, int input_val);
|
||||
int (*set_auto_tx_disable)(struct transvr_obj_s *self, int input_val);
|
||||
int (*set_tx_eq)(struct transvr_obj_s *self, int input_val);
|
||||
int (*set_rx_am)(struct transvr_obj_s *self, int input_val);
|
||||
int (*set_rx_em)(struct transvr_obj_s *self, int input_val);
|
||||
int (*set_extphy_offset)(struct transvr_obj_s *self, int input_val);
|
||||
int (*set_extphy_reg)(struct transvr_obj_s *self, int input_val);
|
||||
|
||||
/* ========== Object private functions ==========
|
||||
*/
|
||||
int (*init)(struct transvr_obj_s *self);
|
||||
int (*clean)(struct transvr_obj_s *self);
|
||||
int (*check)(struct transvr_obj_s *self);
|
||||
int (*update_all)(struct transvr_obj_s *self, int show_err);
|
||||
int (*fsm_4_direct)(struct transvr_obj_s* self, char *caller_name);
|
||||
int (*fsm_4_polling)(struct transvr_obj_s* self, char *caller_name);
|
||||
int (*send_uevent)(struct transvr_obj_s* self, enum kobject_action u_action);
|
||||
int (*dump_all)(struct transvr_obj_s* self);
|
||||
};
|
||||
|
||||
|
||||
/* For AVL Mapping */
|
||||
struct transvr_avl_s {
|
||||
char vendor_name[32];
|
||||
char vendor_pn[32];
|
||||
int (*init)(struct transvr_obj_s *self);
|
||||
};
|
||||
|
||||
|
||||
/* Worker for long term task of transceiver */
|
||||
struct transvr_worker_s {
|
||||
/* Task Parameter */
|
||||
struct transvr_obj_s *transvr_p;
|
||||
struct transvr_worker_s *next_p;
|
||||
struct transvr_worker_s *pre_p;
|
||||
unsigned long trigger_time;
|
||||
char func_name[64];
|
||||
int retry;
|
||||
int state;
|
||||
|
||||
/* Task private data */
|
||||
void *p_data;
|
||||
|
||||
/* Call back function */
|
||||
int (*main_task)(struct transvr_worker_s *task);
|
||||
int (*post_task)(struct transvr_worker_s *task);
|
||||
};
|
||||
|
||||
|
||||
struct transvr_obj_s *
|
||||
create_transvr_obj(char *swp_name,
|
||||
int chan_id,
|
||||
struct ioexp_obj_s *ioexp_obj_p,
|
||||
int ioexp_virt_offset,
|
||||
int transvr_type,
|
||||
int chipset_type,
|
||||
int run_mode);
|
||||
|
||||
void lock_transvr_obj(struct transvr_obj_s *self);
|
||||
void unlock_transvr_obj(struct transvr_obj_s *self);
|
||||
int isolate_transvr_obj(struct transvr_obj_s *self);
|
||||
|
||||
int resync_channel_tier_2(struct transvr_obj_s *self);
|
||||
|
||||
void alarm_msg_2_user(struct transvr_obj_s *self, char *emsg);
|
||||
|
||||
#endif /* TRANSCEIVER_H */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,239 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (C) 2017 Inventec, 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 "[D6254]"+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 =[
|
||||
#'echo pca9548 0x71> /sys/bus/i2c/devices/i2c-0/new_device',
|
||||
#'echo pca9548 0x72> /sys/bus/i2c/devices/i2c-0/i2c-2/new_device',
|
||||
#'echo pca9548 0x72> /sys/bus/i2c/devices/i2c-0/i2c-3/new_device',
|
||||
#'echo pca9548 0x72> /sys/bus/i2c/devices/i2c-0/i2c-4/new_device',
|
||||
#'echo pca9548 0x72> /sys/bus/i2c/devices/i2c-0/i2c-5/new_device',
|
||||
#'echo pca9548 0x72> /sys/bus/i2c/devices/i2c-0/i2c-6/new_device',
|
||||
#'echo pca9548 0x72> /sys/bus/i2c/devices/i2c-0/i2c-7/new_device',
|
||||
#'echo pca9548 0x72> /sys/bus/i2c/devices/i2c-0/i2c-8/new_device',
|
||||
'echo inv_eeprom 0x53 > /sys/bus/i2c/devices/i2c-0/new_device']
|
||||
#'echo inv_psoc 0x66> /sys/bus/i2c/devices/i2c-0/new_device',
|
||||
#'echo inv_cpld 0x55> /sys/bus/i2c/devices/i2c-0/new_device']
|
||||
|
||||
drivers =[
|
||||
'gpio_ich',
|
||||
'lpc_ich',
|
||||
'i2c-i801',
|
||||
'i2c-mux',
|
||||
'i2c-mux-pca954x',
|
||||
'i2c-dev',
|
||||
'inv_eeprom',
|
||||
'inv_platform',
|
||||
'inv_psoc',
|
||||
'inv_cpld',
|
||||
'swps',
|
||||
'inv_pthread']
|
||||
|
||||
|
||||
|
||||
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)
|
||||
#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
|
||||
|
||||
#instantiate devices
|
||||
for i in range(0,len(instantiate)):
|
||||
#time.sleep(1)
|
||||
status, output = exec_cmd(instantiate[i], 1)
|
||||
if status:
|
||||
print output
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
for i in range(10,18):
|
||||
status, output =exec_cmd("echo sff8436 0x50 > /sys/bus/i2c/devices/i2c-0/i2c-2/i2c-"+str(i)+"/new_device", 1)
|
||||
if status:
|
||||
print output
|
||||
if FORCE == 0:
|
||||
return status
|
||||
for i in range(18,26):
|
||||
status, output =exec_cmd("echo sff8436 0x50 > /sys/bus/i2c/devices/i2c-0/i2c-3/i2c-"+str(i)+"/new_device", 1)
|
||||
if status:
|
||||
print output
|
||||
if FORCE == 0:
|
||||
return status
|
||||
for i in range(26,34):
|
||||
status, output =exec_cmd("echo sff8436 0x50 > /sys/bus/i2c/devices/i2c-0/i2c-4/i2c-"+str(i)+"/new_device", 1)
|
||||
if status:
|
||||
print output
|
||||
if FORCE == 0:
|
||||
return status
|
||||
for i in range(34,42):
|
||||
status, output =exec_cmd("echo sff8436 0x50 > /sys/bus/i2c/devices/i2c-0/i2c-5/i2c-"+str(i)+"/new_device", 1)
|
||||
if status:
|
||||
print output
|
||||
if FORCE == 0:
|
||||
return status
|
||||
for i in range(42,50):
|
||||
status, output =exec_cmd("echo sff8436 0x50 > /sys/bus/i2c/devices/i2c-0/i2c-6/i2c-"+str(i)+"/new_device", 1)
|
||||
if status:
|
||||
print output
|
||||
if FORCE == 0:
|
||||
return status
|
||||
for i in range(50,58):
|
||||
status, output =exec_cmd("echo sff8436 0x50 > /sys/bus/i2c/devices/i2c-0/i2c-7/i2c-"+str(i)+"/new_device", 1)
|
||||
if status:
|
||||
print output
|
||||
if FORCE == 0:
|
||||
return status
|
||||
for i in range(58,64):
|
||||
status, output =exec_cmd("echo sff8436 0x50 > /sys/bus/i2c/devices/i2c-0/i2c-8/i2c-"+str(i)+"/new_device", 1)
|
||||
if status:
|
||||
print output
|
||||
if FORCE == 0:
|
||||
return status
|
||||
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 " D6254 devices detected...."
|
||||
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+"*0072", 0)
|
||||
ret2, log = exec_cmd("ls "+i2c_prefix+"i2c-2", 0)
|
||||
return not(ret1 or ret2)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
@ -0,0 +1,6 @@
|
||||
obj-m += inv_cpld.o inv_psoc.o
|
||||
obj-m += inv_platform.o
|
||||
obj-m += inv_eeprom.o
|
||||
obj-m += swps.o
|
||||
obj-m += inv_pthread.o
|
||||
swps-objs := inv_swps.o inv_mux.o io_expander.o transceiver.o
|
@ -0,0 +1,526 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/hwmon.h>
|
||||
#include <linux/hwmon-sysfs.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/mutex.h>
|
||||
|
||||
//#include "I2CHostCommunication.h"
|
||||
|
||||
#define USE_SMBUS 1
|
||||
|
||||
/* definition */
|
||||
#define CPLD_INFO_OFFSET 0x00
|
||||
#define CPLD_PSU_OFFSET 0x08
|
||||
#define CPLD_LED_OFFSET 0x0E
|
||||
#define CPLD_LED_STATU_OFFSET 0x0D
|
||||
#define CPLD_CTL_OFFSET 0x0C
|
||||
#define CPLD_BIOSCS_OFFSET 0x04
|
||||
#define CPLD_PSUFANLED_OFFSET 0x75
|
||||
|
||||
/* Each client has this additional data */
|
||||
struct cpld_data {
|
||||
struct device *hwmon_dev;
|
||||
struct mutex update_lock;
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
static ssize_t cpld_i2c_read(struct i2c_client *client, u8 *buf, u8 offset, size_t count)
|
||||
{
|
||||
#if USE_SMBUS
|
||||
int i;
|
||||
|
||||
for(i=0; i<count; i++) {
|
||||
buf[i] = i2c_smbus_read_byte_data(client, offset+i);
|
||||
}
|
||||
return count;
|
||||
#else
|
||||
struct i2c_msg msg[2];
|
||||
char msgbuf[2];
|
||||
int status;
|
||||
|
||||
memset(msg, 0, sizeof(msg));
|
||||
|
||||
msgbuf[0] = offset;
|
||||
|
||||
msg[0].addr = client->addr;
|
||||
msg[0].buf = msgbuf;
|
||||
msg[0].len = 1;
|
||||
|
||||
msg[1].addr = client->addr;
|
||||
msg[1].flags = I2C_M_RD;
|
||||
msg[1].buf = buf;
|
||||
msg[1].len = count;
|
||||
|
||||
status = i2c_transfer(client->adapter, msg, 2);
|
||||
|
||||
if(status == 2)
|
||||
status = count;
|
||||
|
||||
return status;
|
||||
#endif
|
||||
}
|
||||
|
||||
static ssize_t cpld_i2c_write(struct i2c_client *client, char *buf, unsigned offset, size_t count)
|
||||
{
|
||||
#if USE_SMBUS
|
||||
int i;
|
||||
|
||||
for(i=0; i<count; i++) {
|
||||
i2c_smbus_write_byte_data(client, offset+i, buf[i]);
|
||||
}
|
||||
return count;
|
||||
#else
|
||||
struct i2c_msg msg;
|
||||
int status;
|
||||
u8 writebuf[64];
|
||||
|
||||
int i = 0;
|
||||
|
||||
msg.addr = client->addr;
|
||||
msg.flags = 0;
|
||||
|
||||
/* msg.buf is u8 and casts will mask the values */
|
||||
msg.buf = writebuf;
|
||||
|
||||
msg.buf[i++] = offset;
|
||||
memcpy(&msg.buf[i], buf, count);
|
||||
msg.len = i + count;
|
||||
|
||||
status = i2c_transfer(client->adapter, &msg, 1);
|
||||
if (status == 1)
|
||||
status = count;
|
||||
|
||||
return status;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
/* sysfs attributes for hwmon */
|
||||
|
||||
static ssize_t show_info(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
u32 status;
|
||||
//struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct cpld_data *data = i2c_get_clientdata(client);
|
||||
u8 b[4];
|
||||
|
||||
memset(b, 0, 4);
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
status = cpld_i2c_read(client, b, CPLD_INFO_OFFSET, 4);
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
if(status != 4) return sprintf(buf, "read cpld info fail\n");
|
||||
|
||||
status = sprintf (buf, "The CPLD release date is %02d/%02d/%d.\n", b[2] & 0xf, (b[3] & 0x1f), 2014+(b[2] >> 4)); /* mm/dd/yyyy*/
|
||||
status = sprintf (buf, "%sThe PCB version is %X%X\n", buf, b[0]>>4, b[0]&0xf);
|
||||
status = sprintf (buf, "%sThe CPLD version is %d.%d\n", buf, b[1]>>4, b[1]&0xf);
|
||||
|
||||
return strlen(buf);
|
||||
}
|
||||
|
||||
|
||||
static ssize_t show_ctl(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
u32 status;
|
||||
//struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct cpld_data *data = i2c_get_clientdata(client);
|
||||
u8 b[1];
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
|
||||
status = cpld_i2c_read(client, b, CPLD_CTL_OFFSET, 1);
|
||||
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
if(status != 1) return sprintf(buf, "read cpld ctl fail\n");
|
||||
|
||||
|
||||
status = sprintf (buf, "0x%X\n", b[0]);
|
||||
|
||||
return strlen(buf);
|
||||
}
|
||||
|
||||
static ssize_t set_ctl(struct device *dev,
|
||||
struct device_attribute *devattr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
//struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct cpld_data *data = i2c_get_clientdata(client);
|
||||
u8 byte;
|
||||
|
||||
u8 temp = simple_strtol(buf, NULL, 10);
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
cpld_i2c_read(client, &byte, CPLD_CTL_OFFSET, 1);
|
||||
if(temp) byte |= (1<<0);
|
||||
else byte &= ~(1<<0);
|
||||
cpld_i2c_write(client, &byte, CPLD_CTL_OFFSET, 1);
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t show_bios_cs(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
u32 status;
|
||||
//struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct cpld_data *data = i2c_get_clientdata(client);
|
||||
u8 b[1];
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
|
||||
status = cpld_i2c_read(client, b, CPLD_BIOSCS_OFFSET, 1);
|
||||
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
if(status != 1) return sprintf(buf, "read cpld BIOS_CS fail\n");
|
||||
|
||||
|
||||
status = sprintf (buf, "0x%X\n", b[0] & 0x01);
|
||||
|
||||
return strlen(buf);
|
||||
}
|
||||
|
||||
static ssize_t set_bios_cs(struct device *dev,
|
||||
struct device_attribute *devattr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
//struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct cpld_data *data = i2c_get_clientdata(client);
|
||||
u8 byte;
|
||||
|
||||
u8 temp = simple_strtol(buf, NULL, 10);
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
cpld_i2c_read(client, &byte, CPLD_BIOSCS_OFFSET, 1);
|
||||
if(temp) byte |= 0x01;
|
||||
else byte &= ~(0x01);
|
||||
cpld_i2c_write(client, &byte, CPLD_BIOSCS_OFFSET, 1);
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
static char* led_str[] = {
|
||||
"OFF", //000
|
||||
"0.5 Hz", //001
|
||||
"1 Hz", //010
|
||||
"2 Hz", //011
|
||||
"4 Hz", //100
|
||||
"NA", //101
|
||||
"NA", //110
|
||||
"ON", //111
|
||||
};
|
||||
|
||||
static ssize_t show_led(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
u32 status;
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct cpld_data *data = i2c_get_clientdata(client);
|
||||
u8 byte;
|
||||
int shift = (attr->index == 0)?3:0;
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
status = cpld_i2c_read(client, &byte, CPLD_LED_OFFSET, 1);
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
if(status != 1) return sprintf(buf, "read cpld offset 0x%x\n", CPLD_LED_OFFSET);
|
||||
|
||||
byte = (byte >> shift) & 0x7;
|
||||
|
||||
status = sprintf (buf, "%d: %s\n", byte, led_str[byte]);
|
||||
|
||||
return strlen(buf);
|
||||
}
|
||||
|
||||
static ssize_t set_led(struct device *dev,
|
||||
struct device_attribute *devattr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct cpld_data *data = i2c_get_clientdata(client);
|
||||
|
||||
u8 temp = simple_strtol(buf, NULL, 16);
|
||||
u8 byte;
|
||||
int shift = (attr->index == 0)?3:0;
|
||||
|
||||
temp &= 0x7;
|
||||
//validate temp value: 0,1,2,3,7, TBD
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
cpld_i2c_read(client, &byte, CPLD_LED_OFFSET, 1);
|
||||
byte &= ~(0x7<<shift);
|
||||
byte |= (temp<<shift);
|
||||
cpld_i2c_write(client, &byte, CPLD_LED_OFFSET, 1);
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
/*
|
||||
CPLD report the PSU0 status
|
||||
000 = PSU normal operation
|
||||
100 = PSU fault
|
||||
010 = PSU unpowered
|
||||
111 = PSU not installed
|
||||
|
||||
7 6 | 5 4 3 | 2 1 0
|
||||
----------------------
|
||||
| psu0 | psu1
|
||||
*/
|
||||
static char* psu_str[] = {
|
||||
"normal", //000
|
||||
"NA", //001
|
||||
"unpowered", //010
|
||||
"NA", //011
|
||||
"fault", //100
|
||||
"NA", //101
|
||||
"NA", //110
|
||||
"not installed", //111
|
||||
};
|
||||
|
||||
static ssize_t show_psu(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
u32 status;
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct cpld_data *data = i2c_get_clientdata(client);
|
||||
u8 byte;
|
||||
int shift = (attr->index == 1)?0:3;
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
status = cpld_i2c_read(client, &byte, CPLD_PSU_OFFSET, 1);
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
byte = (byte >> shift) & 0x7;
|
||||
|
||||
status = sprintf (buf, "%d : %s\n", byte, psu_str[byte]);
|
||||
|
||||
return strlen(buf);
|
||||
}
|
||||
|
||||
static char* status_psufan_str[] = {
|
||||
"OFF", //00
|
||||
"ON", //01
|
||||
"1 Hz", //10
|
||||
"2 Hz", //11
|
||||
};
|
||||
|
||||
static ssize_t show_psufan_led(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
u32 status;
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct cpld_data *data = i2c_get_clientdata(client);
|
||||
u8 red_status, grn_status, byte;
|
||||
int shift = (attr->index == 0)?0:2;
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
status = cpld_i2c_read(client, &byte, CPLD_PSUFANLED_OFFSET, 1);
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
byte = (byte>>shift) & 0x33;
|
||||
grn_status = byte >> 4;
|
||||
red_status = byte & 0x03;
|
||||
|
||||
return sprintf (buf, "0x%02x: Green %s , Red %s\n", byte, status_psufan_str[grn_status],status_psufan_str[red_status]);
|
||||
}
|
||||
|
||||
static ssize_t set_psufan_led(struct device *dev, struct device_attribute *da,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
struct i2c_client *client = to_i2c_client(dev);
|
||||
struct cpld_data *data = i2c_get_clientdata(client);
|
||||
int shift = (attr->index == 0)?0:2;
|
||||
int mask = (attr->index == 0)?0xcc:0x33;
|
||||
u8 temp = simple_strtol(buf, NULL, 16) & 0x33;
|
||||
u8 byte = 0;
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
cpld_i2c_read(client, &byte, CPLD_PSUFANLED_OFFSET, 1);
|
||||
byte &= mask;
|
||||
byte |= (temp<<shift);
|
||||
cpld_i2c_write(client, &byte, CPLD_PSUFANLED_OFFSET, 1);
|
||||
mutex_unlock(&data->update_lock);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
static SENSOR_DEVICE_ATTR(info, S_IRUGO, show_info, 0, 0);
|
||||
static SENSOR_DEVICE_ATTR(ctl, S_IWUSR|S_IRUGO, show_ctl, set_ctl, 0);
|
||||
|
||||
static SENSOR_DEVICE_ATTR(grn_led, S_IWUSR|S_IRUGO, show_led, set_led, 0);
|
||||
static SENSOR_DEVICE_ATTR(red_led, S_IWUSR|S_IRUGO, show_led, set_led, 1);
|
||||
|
||||
static SENSOR_DEVICE_ATTR(psu0, S_IRUGO, show_psu, 0, 0);
|
||||
static SENSOR_DEVICE_ATTR(psu1, S_IRUGO, show_psu, 0, 1);
|
||||
|
||||
static SENSOR_DEVICE_ATTR(fan_led, S_IWUSR|S_IRUGO, show_psufan_led, set_psufan_led, 0);
|
||||
static SENSOR_DEVICE_ATTR(psu_led, S_IWUSR|S_IRUGO, show_psufan_led, set_psufan_led, 1);
|
||||
|
||||
static SENSOR_DEVICE_ATTR(bios_cs, S_IWUSR|S_IRUGO, show_bios_cs, set_bios_cs, 0);
|
||||
|
||||
static struct attribute *cpld_attributes[] = {
|
||||
//info
|
||||
&sensor_dev_attr_info.dev_attr.attr,
|
||||
&sensor_dev_attr_ctl.dev_attr.attr,
|
||||
|
||||
&sensor_dev_attr_grn_led.dev_attr.attr,
|
||||
&sensor_dev_attr_red_led.dev_attr.attr,
|
||||
|
||||
&sensor_dev_attr_psu0.dev_attr.attr,
|
||||
&sensor_dev_attr_psu1.dev_attr.attr,
|
||||
|
||||
&sensor_dev_attr_fan_led.dev_attr.attr,
|
||||
&sensor_dev_attr_psu_led.dev_attr.attr,
|
||||
|
||||
&sensor_dev_attr_bios_cs.dev_attr.attr,
|
||||
|
||||
NULL
|
||||
};
|
||||
|
||||
static const struct attribute_group cpld_group = {
|
||||
.attrs = cpld_attributes,
|
||||
};
|
||||
|
||||
static struct attribute *cpld2_attributes[] = {
|
||||
//info
|
||||
&sensor_dev_attr_info.dev_attr.attr,
|
||||
|
||||
NULL
|
||||
};
|
||||
|
||||
static const struct attribute_group cpld2_group = {
|
||||
.attrs = cpld2_attributes,
|
||||
};
|
||||
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
/* device probe and removal */
|
||||
|
||||
static int
|
||||
cpld_probe(struct i2c_client *client, const struct i2c_device_id *id)
|
||||
{
|
||||
struct cpld_data *data;
|
||||
int status;
|
||||
|
||||
// printk("+%s \n", __func__);
|
||||
|
||||
if (!i2c_check_functionality(client->adapter,
|
||||
I2C_FUNC_SMBUS_BYTE_DATA | I2C_FUNC_SMBUS_WORD_DATA))
|
||||
return -EIO;
|
||||
|
||||
data = kzalloc(sizeof(struct cpld_data), GFP_KERNEL);
|
||||
if (!data)
|
||||
return -ENOMEM;
|
||||
|
||||
i2c_set_clientdata(client, data);
|
||||
mutex_init(&data->update_lock);
|
||||
|
||||
/* Register sysfs hooks */
|
||||
if(id->driver_data==1) // CPLD2
|
||||
status = sysfs_create_group(&client->dev.kobj, &cpld2_group);
|
||||
else // default CPLD1
|
||||
status = sysfs_create_group(&client->dev.kobj, &cpld_group);
|
||||
|
||||
if (status)
|
||||
goto exit_free;
|
||||
|
||||
data->hwmon_dev = hwmon_device_register(&client->dev);
|
||||
if (IS_ERR(data->hwmon_dev)) {
|
||||
status = PTR_ERR(data->hwmon_dev);
|
||||
goto exit_remove;
|
||||
}
|
||||
|
||||
dev_info(&client->dev, "%s: sensor '%s'\n",
|
||||
dev_name(data->hwmon_dev), client->name);
|
||||
|
||||
return 0;
|
||||
|
||||
exit_remove:
|
||||
sysfs_remove_group(&client->dev.kobj, &cpld_group);
|
||||
exit_free:
|
||||
i2c_set_clientdata(client, NULL);
|
||||
kfree(data);
|
||||
return status;
|
||||
}
|
||||
|
||||
static int cpld_remove(struct i2c_client *client)
|
||||
{
|
||||
struct cpld_data *data = i2c_get_clientdata(client);
|
||||
|
||||
hwmon_device_unregister(data->hwmon_dev);
|
||||
sysfs_remove_group(&client->dev.kobj, &cpld_group);
|
||||
i2c_set_clientdata(client, NULL);
|
||||
kfree(data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct i2c_device_id cpld_ids[] = {
|
||||
{ "inv_cpld" , 0, },
|
||||
{ "inv_cpld2", 1, },
|
||||
{ /* LIST END */ }
|
||||
};
|
||||
MODULE_DEVICE_TABLE(i2c, cpld_ids);
|
||||
|
||||
static struct i2c_driver cpld_driver = {
|
||||
.class = I2C_CLASS_HWMON,
|
||||
.driver = {
|
||||
.name = "inv_cpld",
|
||||
},
|
||||
.probe = cpld_probe,
|
||||
.remove = cpld_remove,
|
||||
.id_table = cpld_ids,
|
||||
};
|
||||
|
||||
/*-----------------------------------------------------------------------*/
|
||||
|
||||
/* module glue */
|
||||
|
||||
static int __init inv_cpld_init(void)
|
||||
{
|
||||
return i2c_add_driver(&cpld_driver);
|
||||
}
|
||||
|
||||
static void __exit inv_cpld_exit(void)
|
||||
{
|
||||
i2c_del_driver(&cpld_driver);
|
||||
}
|
||||
|
||||
MODULE_AUTHOR("eddie.lan <eddie.lan@inventec>");
|
||||
MODULE_DESCRIPTION("inv cpld driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
module_init(inv_cpld_init);
|
||||
module_exit(inv_cpld_exit);
|
@ -0,0 +1,181 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/mutex.h>
|
||||
|
||||
|
||||
/* Size of EEPROM in bytes */
|
||||
#define EEPROM_SIZE 256
|
||||
|
||||
#define SLICE_BITS (6)
|
||||
#define SLICE_SIZE (1 << SLICE_BITS)
|
||||
#define SLICE_NUM (EEPROM_SIZE/SLICE_SIZE)
|
||||
|
||||
/* Each client has this additional data */
|
||||
struct eeprom_data {
|
||||
struct mutex update_lock;
|
||||
u8 valid; /* bitfield, bit!=0 if slice is valid */
|
||||
unsigned long last_updated[SLICE_NUM]; /* In jiffies, 8 slices */
|
||||
u8 data[EEPROM_SIZE]; /* Register values */
|
||||
};
|
||||
|
||||
|
||||
static void inv_eeprom_update_client(struct i2c_client *client, u8 slice)
|
||||
{
|
||||
struct eeprom_data *data = i2c_get_clientdata(client);
|
||||
int i, j;
|
||||
int ret;
|
||||
int addr;
|
||||
|
||||
|
||||
mutex_lock(&data->update_lock);
|
||||
|
||||
if (!(data->valid & (1 << slice)) ||
|
||||
time_after(jiffies, data->last_updated[slice] + 300 * HZ)) {
|
||||
dev_dbg(&client->dev, "Starting eeprom update, slice %u\n", slice);
|
||||
|
||||
addr = slice << SLICE_BITS;
|
||||
|
||||
ret = i2c_smbus_write_byte_data(client, ((u8)addr >> 8) & 0xFF, (u8)addr & 0xFF);
|
||||
/* select the eeprom address */
|
||||
if (ret < 0) {
|
||||
dev_err(&client->dev, "address set failed\n");
|
||||
goto exit;
|
||||
}
|
||||
|
||||
if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_READ_BYTE)) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
for (i = slice << SLICE_BITS; i < (slice + 1) << SLICE_BITS; i+= SLICE_SIZE) {
|
||||
for (j = i; j < (i+SLICE_SIZE); j++) {
|
||||
int res;
|
||||
|
||||
res = i2c_smbus_read_byte(client);
|
||||
if (res < 0) {
|
||||
goto exit;
|
||||
}
|
||||
|
||||
data->data[j] = res & 0xFF;
|
||||
}
|
||||
}
|
||||
|
||||
data->last_updated[slice] = jiffies;
|
||||
data->valid |= (1 << slice);
|
||||
}
|
||||
|
||||
exit:
|
||||
mutex_unlock(&data->update_lock);
|
||||
}
|
||||
|
||||
static ssize_t inv_eeprom_read(struct file *filp, struct kobject *kobj,
|
||||
struct bin_attribute *bin_attr,
|
||||
char *buf, loff_t off, size_t count)
|
||||
{
|
||||
struct i2c_client *client = to_i2c_client(container_of(kobj, struct device, kobj));
|
||||
struct eeprom_data *data = i2c_get_clientdata(client);
|
||||
u8 slice;
|
||||
|
||||
|
||||
if (off > EEPROM_SIZE) {
|
||||
return 0;
|
||||
}
|
||||
if (off + count > EEPROM_SIZE) {
|
||||
count = EEPROM_SIZE - off;
|
||||
}
|
||||
if (count == 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Only refresh slices which contain requested bytes */
|
||||
for (slice = off >> SLICE_BITS; slice <= (off + count - 1) >> SLICE_BITS; slice++) {
|
||||
inv_eeprom_update_client(client, slice);
|
||||
}
|
||||
|
||||
memcpy(buf, &data->data[off], count);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static struct bin_attribute inv_eeprom_attr = {
|
||||
.attr = {
|
||||
.name = "eeprom",
|
||||
.mode = S_IRUGO,
|
||||
},
|
||||
.size = EEPROM_SIZE,
|
||||
.read = inv_eeprom_read,
|
||||
};
|
||||
|
||||
static int inv_eeprom_probe(struct i2c_client *client,
|
||||
const struct i2c_device_id *id)
|
||||
{
|
||||
struct eeprom_data *data;
|
||||
int err;
|
||||
|
||||
if (!(data = kzalloc(sizeof(struct eeprom_data), GFP_KERNEL))) {
|
||||
err = -ENOMEM;
|
||||
goto exit;
|
||||
}
|
||||
|
||||
memset(data->data, 0xff, EEPROM_SIZE);
|
||||
i2c_set_clientdata(client, data);
|
||||
mutex_init(&data->update_lock);
|
||||
|
||||
/* create the sysfs eeprom file */
|
||||
err = sysfs_create_bin_file(&client->dev.kobj, &inv_eeprom_attr);
|
||||
if (err) {
|
||||
goto exit_kfree;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
exit_kfree:
|
||||
kfree(data);
|
||||
exit:
|
||||
return err;
|
||||
}
|
||||
|
||||
static int inv_eeprom_remove(struct i2c_client *client)
|
||||
{
|
||||
sysfs_remove_bin_file(&client->dev.kobj, &inv_eeprom_attr);
|
||||
kfree(i2c_get_clientdata(client));
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct i2c_device_id inv_eeprom_id[] = {
|
||||
{ "inv_eeprom", 0 },
|
||||
{ }
|
||||
};
|
||||
|
||||
static struct i2c_driver inv_eeprom_driver = {
|
||||
.driver = {
|
||||
.name = "inv_eeprom",
|
||||
},
|
||||
.probe = inv_eeprom_probe,
|
||||
.remove = inv_eeprom_remove,
|
||||
.id_table = inv_eeprom_id,
|
||||
};
|
||||
|
||||
module_i2c_driver(inv_eeprom_driver);
|
||||
|
||||
MODULE_AUTHOR("Inventec");
|
||||
MODULE_DESCRIPTION("Inventec D6556 Mother Board EEPROM driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
|
@ -0,0 +1,281 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#include <asm/io.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/gpio.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include "io_expander.h"
|
||||
#include "inv_mux.h"
|
||||
|
||||
static struct mux_obj_s *mux_head_p = NULL;
|
||||
|
||||
|
||||
/* ========== MUX object functions ==========
|
||||
*/
|
||||
int
|
||||
_common_force_pull_gpio(int mem_addr,
|
||||
int input,
|
||||
int bit_offset){
|
||||
|
||||
unsigned int val = 0;
|
||||
unsigned int targ = 0;
|
||||
|
||||
/* Get current value */
|
||||
val = inl(mem_addr);
|
||||
if (val == 0) {
|
||||
SWPS_ERR("%s: inl:%d fail!\n", __func__, val);
|
||||
return -1;
|
||||
}
|
||||
/* Count target value */
|
||||
switch (input) {
|
||||
case 0: /* Pull Low */
|
||||
targ = (val & (~(1 << bit_offset)));
|
||||
break;
|
||||
case 1: /* Pull high */
|
||||
targ = (val | (1 << bit_offset));
|
||||
break;
|
||||
default:
|
||||
SWPS_ERR("%s: input state:%d incorrect!\n",
|
||||
__func__, input);
|
||||
return -1;
|
||||
}
|
||||
/* Setup gpio */
|
||||
outl(targ, mem_addr);
|
||||
if (targ != inl(mem_addr)){
|
||||
SWPS_ERR("%s: outl:%d fail!\n", __func__, targ);
|
||||
return -1;
|
||||
}
|
||||
SWPS_DEBUG("%s: done.\n", __func__);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
rangeley_force_pull_high(struct mux_obj_s *self){
|
||||
SWPS_ERR("%s: not ready!\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
rangeley_force_pull_low(struct mux_obj_s *self){
|
||||
SWPS_ERR("%s: not ready!\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
hedera_force_pull_high(struct mux_obj_s *self){
|
||||
return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 1, 5);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
hedera_force_pull_low(struct mux_obj_s *self){
|
||||
return _common_force_pull_gpio(MUX_RST_MEM_ADDR_HEDERA, 0, 5);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
normal_gpio_pull_high(struct mux_obj_s *self){
|
||||
return gpio_direction_output(self->gpio_num, 1);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
normal_gpio_pull_low(struct mux_obj_s *self){
|
||||
return gpio_direction_output(self->gpio_num, 0);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
pca9548_reset_mux_all(struct mux_obj_s *self){
|
||||
/* [Note] Power-on reset (PCA9548A-NXP)
|
||||
* When power is applied to VDD, an internal Power-On Reset (POR)
|
||||
* holds the PCA9548A in a reset condition until VDD has reached
|
||||
* VPOR. At this point, the reset condition is released and the
|
||||
* PCA9548A register and I2C-bus state machine are initialized to
|
||||
* their default states (all zeroes) causing all the channels to
|
||||
* be deselected. Thereafter, VDD must be lowered below 0.2 V for
|
||||
* at least 5 us in order to reset the device.
|
||||
*/
|
||||
if (self->_pull_low(self) < 0) {
|
||||
SWPS_ERR("%s: _pull_low fail!\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
mdelay(MUX_RST_WAIT_MS);
|
||||
if (self->_pull_high(self) < 0) {
|
||||
SWPS_ERR("%s: _pull_high fail!\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
mdelay(MUX_RST_WAIT_MS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
common_reset_mux_all(struct mux_obj_s *self){
|
||||
SWPS_ERR("%s: not ready!\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
init_gpio_4_force(struct mux_obj_s *self){
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
init_gpio_4_normal(struct mux_obj_s *self){
|
||||
|
||||
int err = 0;
|
||||
|
||||
if (!gpio_is_valid(self->gpio_num)) {
|
||||
SWPS_ERR("%s: GIPO:%d isn't valid\n", __func__, self->gpio_num);
|
||||
return -1;
|
||||
}
|
||||
err = gpio_request(self->gpio_num, MUX_GPIO_LABEL);
|
||||
if (err < 0) {
|
||||
SWPS_ERR("%s: gpio_request fail <err>:%d <gpio>:%d\n",
|
||||
__func__, err, self->gpio_num);
|
||||
return -1;
|
||||
}
|
||||
SWPS_DEBUG("%s: gpio_request:%d ok.\n", __func__, self->gpio_num);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
static int
|
||||
_setup_muxctl_cb(struct mux_obj_s *self,
|
||||
unsigned gpio){
|
||||
|
||||
char mod_dsc[32] = "ERR";
|
||||
|
||||
switch (gpio) {
|
||||
case MUX_RST_GPIO_FORCE_RANGELEY:
|
||||
self->gpio_num = gpio;
|
||||
self->_pull_low = rangeley_force_pull_low;
|
||||
self->_pull_high = rangeley_force_pull_high;
|
||||
self->_init = init_gpio_4_force;
|
||||
self->reset = pca9548_reset_mux_all;
|
||||
memset(mod_dsc, 0, 32);
|
||||
snprintf(mod_dsc, 31, "Rangeley force mode");
|
||||
goto ok_setup_muxctl_cb;
|
||||
|
||||
case MUX_RST_GPIO_FORCE_HEDERA:
|
||||
self->gpio_num = gpio;
|
||||
self->_pull_low = hedera_force_pull_low;
|
||||
self->_pull_high = hedera_force_pull_high;
|
||||
self->_init = init_gpio_4_force;
|
||||
self->reset = pca9548_reset_mux_all;
|
||||
memset(mod_dsc, 0, 32);
|
||||
snprintf(mod_dsc, 31, "Hedera force mode");
|
||||
goto ok_setup_muxctl_cb;
|
||||
|
||||
case MUX_RST_GPIO_48_PAC9548:
|
||||
case MUX_RST_GPIO_69_PAC9548:
|
||||
case MUX_RST_GPIO_249_PCA9548:
|
||||
case MUX_RST_GPIO_500_PAC9548:
|
||||
case MUX_RST_GPIO_505_PCA9548:
|
||||
self->gpio_num = gpio;
|
||||
self->_pull_low = normal_gpio_pull_low;
|
||||
self->_pull_high = normal_gpio_pull_high;
|
||||
self->_init = init_gpio_4_normal;
|
||||
self->reset = pca9548_reset_mux_all;
|
||||
memset(mod_dsc, 0, 32);
|
||||
snprintf(mod_dsc, 31, "Normal mode <gpio>:%d", (int)gpio);
|
||||
goto ok_setup_muxctl_cb;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
SWPS_ERR("%s: Unexpected GPIO:%d\n", __func__, gpio);
|
||||
return -1;
|
||||
|
||||
ok_setup_muxctl_cb:
|
||||
SWPS_INFO("muxctl: %s.\n", mod_dsc);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/* ========== MUX public functions ==========
|
||||
*/
|
||||
void
|
||||
clean_mux_gpio(void){
|
||||
|
||||
if (!mux_head_p) {
|
||||
SWPS_DEBUG("%s: mux_head_p is NULL\n", __func__);
|
||||
return;
|
||||
}
|
||||
if (gpio_is_valid(mux_head_p->gpio_num)) {
|
||||
gpio_free(mux_head_p->gpio_num);
|
||||
}
|
||||
kfree(mux_head_p);
|
||||
mux_head_p = NULL;
|
||||
SWPS_DEBUG("%s: done.\n", __func__);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
reset_mux_gpio(void){
|
||||
|
||||
if (!mux_head_p) {
|
||||
SWPS_ERR("%s: MUX ctl object doesn't exist!\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
if (mux_head_p->reset(mux_head_p) < 0){
|
||||
SWPS_ERR("%s: reset fail!\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
init_mux_gpio(unsigned gpio){
|
||||
|
||||
/* Create MUX control object */
|
||||
if (mux_head_p) {
|
||||
SWPS_DEBUG("%s: mux_head_p is not NULL!\n", __func__);
|
||||
clean_mux_gpio();
|
||||
}
|
||||
/* Currently, it is using single muxctl architecture.
|
||||
* In the future, it may use the multi-muxctl if HW add new features.
|
||||
* (Ex: Port power-status control)
|
||||
*/
|
||||
mux_head_p = kzalloc(sizeof(struct mux_obj_s), GFP_KERNEL);
|
||||
if (!mux_head_p) {
|
||||
SWPS_ERR("%s: kzalloc fail!\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
/* Initial MUX controller */
|
||||
if (_setup_muxctl_cb(mux_head_p, gpio) < 0){
|
||||
SWPS_ERR("%s: _setup_muxctl_cb fail!\n", __func__);
|
||||
return -1;
|
||||
}
|
||||
if (mux_head_p->_init(mux_head_p) < 0) {
|
||||
SWPS_ERR("%s: init() fail\n", __func__);
|
||||
goto err_init_mux_gpio;
|
||||
}
|
||||
/* Setup default value */
|
||||
if (mux_head_p->_pull_high(mux_head_p) < 0) {
|
||||
SWPS_ERR("%s: setup default fail!\n", __func__);
|
||||
goto err_init_mux_gpio;
|
||||
}
|
||||
return 0;
|
||||
|
||||
err_init_mux_gpio:
|
||||
clean_mux_gpio();
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,47 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef INV_MUX_H
|
||||
#define INV_MUX_H
|
||||
|
||||
|
||||
/* MUX basic information */
|
||||
#define MUX_GPIO_LABEL "SWPS_RST_MUX"
|
||||
|
||||
/* MUX reset GPIO define */
|
||||
#define MUX_RST_GPIO_FORCE (30100)
|
||||
#define MUX_RST_GPIO_FORCE_RANGELEY (30101)
|
||||
#define MUX_RST_GPIO_FORCE_HEDERA (30102)
|
||||
#define MUX_RST_GPIO_48_PAC9548 (48)
|
||||
#define MUX_RST_GPIO_69_PAC9548 (69)
|
||||
#define MUX_RST_GPIO_249_PCA9548 (249)
|
||||
#define MUX_RST_GPIO_500_PAC9548 (500)
|
||||
#define MUX_RST_GPIO_505_PCA9548 (505)
|
||||
|
||||
/* MUX relate value define */
|
||||
#define MUX_RST_WAIT_MS (1)
|
||||
#define MUX_RST_MEM_ADDR_RANGELEY (0) // TBD
|
||||
#define MUX_RST_MEM_ADDR_HEDERA (0x548)
|
||||
|
||||
struct mux_obj_s {
|
||||
unsigned gpio_num;
|
||||
int (*_pull_high)(struct mux_obj_s *self);
|
||||
int (*_pull_low)(struct mux_obj_s *self);
|
||||
int (*_init)(struct mux_obj_s *self);
|
||||
int (*reset)(struct mux_obj_s *self);
|
||||
};
|
||||
|
||||
|
||||
void clean_mux_gpio(void);
|
||||
int reset_mux_gpio(void);
|
||||
int init_mux_gpio(unsigned gpio);
|
||||
|
||||
|
||||
#endif /* INV_MUX_H */
|
||||
|
||||
|
||||
|
@ -0,0 +1,215 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
#include <linux/i2c.h>
|
||||
#include <linux/i2c-gpio.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/platform_device.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/i2c/pca954x.h>
|
||||
|
||||
struct inv_i2c_board_info {
|
||||
int ch;
|
||||
int size;
|
||||
struct i2c_board_info *board_info;
|
||||
};
|
||||
|
||||
#define bus_id(id) (id)
|
||||
static struct pca954x_platform_mode mux_modes_0[] = {
|
||||
{.adap_id = bus_id(2),}, {.adap_id = bus_id(3),},
|
||||
{.adap_id = bus_id(4),}, {.adap_id = bus_id(5),},
|
||||
{.adap_id = bus_id(6),}, {.adap_id = bus_id(7),},
|
||||
{.adap_id = bus_id(8),}, {.adap_id = bus_id(9),},
|
||||
};
|
||||
static struct pca954x_platform_mode mux_modes_0_0[] = {
|
||||
{.adap_id = bus_id(10),}, {.adap_id = bus_id(11),},
|
||||
{.adap_id = bus_id(12),}, {.adap_id = bus_id(13),},
|
||||
{.adap_id = bus_id(14),}, {.adap_id = bus_id(15),},
|
||||
{.adap_id = bus_id(16),}, {.adap_id = bus_id(17),},
|
||||
};
|
||||
|
||||
static struct pca954x_platform_mode mux_modes_0_1[] = {
|
||||
{.adap_id = bus_id(18),}, {.adap_id = bus_id(19),},
|
||||
{.adap_id = bus_id(20),}, {.adap_id = bus_id(21),},
|
||||
{.adap_id = bus_id(22),}, {.adap_id = bus_id(23),},
|
||||
{.adap_id = bus_id(24),}, {.adap_id = bus_id(25),},
|
||||
};
|
||||
|
||||
static struct pca954x_platform_mode mux_modes_0_2[] = {
|
||||
{.adap_id = bus_id(26),}, {.adap_id = bus_id(27),},
|
||||
{.adap_id = bus_id(28),}, {.adap_id = bus_id(29),},
|
||||
{.adap_id = bus_id(30),}, {.adap_id = bus_id(31),},
|
||||
{.adap_id = bus_id(32),}, {.adap_id = bus_id(33),},
|
||||
};
|
||||
|
||||
static struct pca954x_platform_mode mux_modes_0_3[] = {
|
||||
{.adap_id = bus_id(34),}, {.adap_id = bus_id(35),},
|
||||
{.adap_id = bus_id(36),}, {.adap_id = bus_id(37),},
|
||||
{.adap_id = bus_id(38),}, {.adap_id = bus_id(39),},
|
||||
{.adap_id = bus_id(40),}, {.adap_id = bus_id(41),},
|
||||
};
|
||||
|
||||
static struct pca954x_platform_mode mux_modes_0_4[] = {
|
||||
{.adap_id = bus_id(42),}, {.adap_id = bus_id(43),},
|
||||
{.adap_id = bus_id(44),}, {.adap_id = bus_id(45),},
|
||||
{.adap_id = bus_id(46),}, {.adap_id = bus_id(47),},
|
||||
{.adap_id = bus_id(48),}, {.adap_id = bus_id(49),},
|
||||
};
|
||||
|
||||
static struct pca954x_platform_mode mux_modes_0_5[] = {
|
||||
{.adap_id = bus_id(50),}, {.adap_id = bus_id(51),},
|
||||
{.adap_id = bus_id(52),}, {.adap_id = bus_id(53),},
|
||||
{.adap_id = bus_id(54),}, {.adap_id = bus_id(55),},
|
||||
{.adap_id = bus_id(56),}, {.adap_id = bus_id(57),},
|
||||
};
|
||||
|
||||
static struct pca954x_platform_mode mux_modes_0_6[] = {
|
||||
{.adap_id = bus_id(58),}, {.adap_id = bus_id(59),},
|
||||
{.adap_id = bus_id(60),}, {.adap_id = bus_id(61),},
|
||||
{.adap_id = bus_id(62),}, {.adap_id = bus_id(63),},
|
||||
{.adap_id = bus_id(64),}, {.adap_id = bus_id(65),},
|
||||
};
|
||||
|
||||
//no i2c device driver attach to mux 7
|
||||
|
||||
|
||||
static struct pca954x_platform_data mux_data_0 = {
|
||||
.modes = mux_modes_0,
|
||||
.num_modes = 8,
|
||||
};
|
||||
static struct pca954x_platform_data mux_data_0_0 = {
|
||||
.modes = mux_modes_0_0,
|
||||
.num_modes = 8,
|
||||
};
|
||||
static struct pca954x_platform_data mux_data_0_1 = {
|
||||
.modes = mux_modes_0_1,
|
||||
.num_modes = 8,
|
||||
};
|
||||
static struct pca954x_platform_data mux_data_0_2 = {
|
||||
.modes = mux_modes_0_2,
|
||||
.num_modes = 8,
|
||||
};
|
||||
static struct pca954x_platform_data mux_data_0_3 = {
|
||||
.modes = mux_modes_0_3,
|
||||
.num_modes = 8,
|
||||
};
|
||||
static struct pca954x_platform_data mux_data_0_4 = {
|
||||
.modes = mux_modes_0_4,
|
||||
.num_modes = 8,
|
||||
};
|
||||
static struct pca954x_platform_data mux_data_0_5 = {
|
||||
.modes = mux_modes_0_5,
|
||||
.num_modes = 8,
|
||||
};
|
||||
static struct pca954x_platform_data mux_data_0_6 = {
|
||||
.modes = mux_modes_0_6,
|
||||
.num_modes = 8,
|
||||
};
|
||||
|
||||
static struct i2c_board_info i2c_device_info0[] __initdata = {
|
||||
{"pca9548", 0, 0x70, &mux_data_0, 0, 0},
|
||||
};
|
||||
|
||||
static struct i2c_board_info i2c_device_info2[] __initdata = {
|
||||
{"pca9548", 0, 0x72, &mux_data_0_0, 0, 0},
|
||||
};
|
||||
static struct i2c_board_info i2c_device_info3[] __initdata = {
|
||||
{"pca9548", 0, 0x72, &mux_data_0_1, 0, 0},
|
||||
};
|
||||
static struct i2c_board_info i2c_device_info4[] __initdata = {
|
||||
{"pca9548", 0, 0x72, &mux_data_0_2, 0, 0},
|
||||
};
|
||||
static struct i2c_board_info i2c_device_info5[] __initdata = {
|
||||
{"pca9548", 0, 0x72, &mux_data_0_3, 0, 0},
|
||||
};
|
||||
static struct i2c_board_info i2c_device_info6[] __initdata = {
|
||||
{"pca9548", 0, 0x72, &mux_data_0_4, 0, 0},
|
||||
};
|
||||
static struct i2c_board_info i2c_device_info7[] __initdata = {
|
||||
{"pca9548", 0, 0x72, &mux_data_0_5, 0, 0},
|
||||
};
|
||||
static struct i2c_board_info i2c_device_info8[] __initdata = {
|
||||
{"pca9548", 0, 0x72, &mux_data_0_6, 0, 0},
|
||||
};
|
||||
|
||||
|
||||
static struct inv_i2c_board_info i2cdev_list[] = {
|
||||
{bus_id(1), ARRAY_SIZE(i2c_device_info0), i2c_device_info0 }, //mux root
|
||||
|
||||
{bus_id(2), ARRAY_SIZE(i2c_device_info2), i2c_device_info2 }, //mux 0
|
||||
{bus_id(3), ARRAY_SIZE(i2c_device_info3), i2c_device_info3 }, //mux 1
|
||||
{bus_id(4), ARRAY_SIZE(i2c_device_info4), i2c_device_info4 }, //mux 2
|
||||
{bus_id(5), ARRAY_SIZE(i2c_device_info5), i2c_device_info5 }, //mux 3
|
||||
{bus_id(6), ARRAY_SIZE(i2c_device_info6), i2c_device_info6 }, //mux 4
|
||||
{bus_id(7), ARRAY_SIZE(i2c_device_info7), i2c_device_info7 }, //mux 5
|
||||
{bus_id(8), ARRAY_SIZE(i2c_device_info8), i2c_device_info8 }, //mux 6
|
||||
};
|
||||
|
||||
/////////////////////////////////////////////////////////////////////////////////////////
|
||||
static struct i2c_gpio_platform_data i2c_gpio_platdata0 = {
|
||||
.scl_pin = 238,
|
||||
.sda_pin = 255,
|
||||
|
||||
.udelay = 5, //5:100kHz
|
||||
.sda_is_open_drain = 0,
|
||||
.scl_is_open_drain = 0,
|
||||
.scl_is_output_only = 0
|
||||
};
|
||||
|
||||
static struct platform_device device_i2c_gpio0 = {
|
||||
.name = "i2c-gpio",
|
||||
.id = 1, // adapter number
|
||||
.dev.platform_data = &i2c_gpio_platdata0,
|
||||
};
|
||||
|
||||
static int __init inv_platform_init(void)
|
||||
{
|
||||
struct i2c_adapter *adap = NULL;
|
||||
struct i2c_client *e = NULL;
|
||||
int ret = 0;
|
||||
int i,j,k;
|
||||
|
||||
//use i2c-gpio
|
||||
//register i2c gpio
|
||||
//config gpio58,75 to gpio function 58=32+3*8+2 75=32*2+8*1+3 gpio69=32*2+8*0+5
|
||||
outl( inl(0x533) | (1<<2), 0x533);
|
||||
outl( inl(0x541) | (1<<3), 0x541);
|
||||
outl( inl(0x540) | (1<<5), 0x540); //RST_I2C_MUX_N (GPIO69)
|
||||
outl( inl(0x500) | (1<<7), 0x500); //SYS_RDY_N (GPIO7)
|
||||
outl( inl(0x501) | (1<<7), 0x501); //BMC_HEART_BEAT (GPIO15)
|
||||
outl( inl(0x503) | (1<<2)|(1<<3), 0x503); //PSOC_HEART_BEAT(26),CPLD_HEART_BEAT(27)
|
||||
|
||||
|
||||
ret = platform_device_register(&device_i2c_gpio0);
|
||||
if (ret) {
|
||||
printk(KERN_ERR "i2c-gpio: device_i2c_gpio0 register fail %d\n", ret);
|
||||
}
|
||||
mdelay(500); //wait for device_i2c_gpio register successfully
|
||||
|
||||
for(i=0; i<ARRAY_SIZE(i2cdev_list); i++) {
|
||||
adap = i2c_get_adapter( i2cdev_list[i].ch );
|
||||
if (adap == NULL) {
|
||||
printk("platform get channel %d adapter fail\n", i);
|
||||
continue;
|
||||
}
|
||||
i2c_put_adapter(adap);
|
||||
for(j=0; j<i2cdev_list[i].size; j++) {
|
||||
for(k=0; k<300; k++) {
|
||||
e = i2c_new_device(adap, &i2cdev_list[i].board_info[j] );
|
||||
if(e == NULL) msleep(10); else break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
module_init(inv_platform_init);
|
||||
|
||||
MODULE_AUTHOR("Inventec");
|
||||
MODULE_DESCRIPTION("Maple Platform devices");
|
||||
MODULE_LICENSE("GPL");
|
@ -0,0 +1,994 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#include <linux/module.h>
|
||||
#include <linux/init.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/jiffies.h>
|
||||
#include <linux/hwmon.h>
|
||||
#include <linux/hwmon-sysfs.h>
|
||||
#include <linux/err.h>
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/kthread.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/fs.h>
|
||||
#include <asm/uaccess.h>
|
||||
#define SWITCH_TEMPERATURE_SOCK "/proc/switch/temp"
|
||||
#define PSOC_POLLING_PERIOD 1000
|
||||
|
||||
#include <linux/mutex.h>
|
||||
#include <linux/completion.h>
|
||||
#include <linux/ipmi.h>
|
||||
#include <linux/ipmi_smi.h>
|
||||
|
||||
#define IPMI_MAX_INTF (4)
|
||||
#define NETFN_OEM 0x30
|
||||
#define CMD_GETDATA 0x31
|
||||
#define CMD_SETDATA 0x32
|
||||
#define FAN_NUM 4
|
||||
#define PSU_NUM 2
|
||||
|
||||
#define FAN_CLEI_SUPPORT 1
|
||||
#define PSU_CLEI_SUPPORT 0
|
||||
|
||||
#define PSU1 0x5800
|
||||
#define PSU2 0x5900
|
||||
#define BMC_PMBusNumber 3
|
||||
#define PMBus_Vendor 0x99
|
||||
#define PMBus_Serial 0x9E
|
||||
#define PMBus_Temp2 0x8E
|
||||
#define PMBus_Version 0x9B
|
||||
#define MaxLeng_Result 0x40
|
||||
|
||||
#define BMC_FanCLEIBusNumber 9
|
||||
#define DEVICE_CLEI_ADDR 0x52,0x53,0x54,0x55,0x56,0x50,0x51
|
||||
|
||||
#define MAX_IPMI_RECV_LENGTH 0xff
|
||||
static char CLEI_ADDR[]={DEVICE_CLEI_ADDR};
|
||||
struct task_struct *kthread_auto_update;
|
||||
static long pmbus_reg2data_linear(int data, int linear16);
|
||||
struct ipmi_result{
|
||||
char result[MAX_IPMI_RECV_LENGTH];
|
||||
int result_length;
|
||||
};
|
||||
|
||||
DEFINE_MUTEX(ipmi_mutex);
|
||||
DEFINE_MUTEX(ipmi2_mutex);
|
||||
static struct ipmi_result ipmiresult;
|
||||
static struct device *hwmon_dev;
|
||||
static struct kobject *device_kobj;
|
||||
static ipmi_user_t ipmi_mh_user = NULL;
|
||||
static void msg_handler(struct ipmi_recv_msg *msg,void* handler_data);
|
||||
static struct ipmi_user_hndl ipmi_hndlrs = { .ipmi_recv_hndl = msg_handler,};
|
||||
|
||||
static atomic_t dummy_count = ATOMIC_INIT(0);
|
||||
static void dummy_smi_free(struct ipmi_smi_msg *msg)
|
||||
{
|
||||
atomic_dec(&dummy_count);
|
||||
}
|
||||
static void dummy_recv_free(struct ipmi_recv_msg *msg)
|
||||
{
|
||||
atomic_dec(&dummy_count);
|
||||
}
|
||||
static struct ipmi_smi_msg halt_smi_msg = {
|
||||
.done = dummy_smi_free
|
||||
};
|
||||
static struct ipmi_recv_msg halt_recv_msg = {
|
||||
.done = dummy_recv_free
|
||||
};
|
||||
|
||||
struct __attribute__ ((__packed__)) psoc_psu_layout {
|
||||
u16 psu1_iin;
|
||||
u16 psu2_iin;
|
||||
u16 psu1_iout;
|
||||
u16 psu2_iout;
|
||||
|
||||
u16 psu1_pin;
|
||||
u16 psu2_pin;
|
||||
u16 psu1_pout;
|
||||
u16 psu2_pout;
|
||||
|
||||
u16 psu1_vin;
|
||||
u16 psu2_vin;
|
||||
u16 psu1_vout;
|
||||
u16 psu2_vout;
|
||||
};
|
||||
|
||||
struct __attribute__ ((__packed__)) clei {
|
||||
u8 issue_number[3];
|
||||
u8 abbreviation_number[9];
|
||||
u8 fc_number[10];
|
||||
u8 clei_code[10];
|
||||
u8 product_year_and_month[5];
|
||||
u8 label_location_code[2];
|
||||
u8 serial_number[5];
|
||||
u8 pcb_revision[5];
|
||||
u8 vendor_name[10];
|
||||
u8 reserved[5];
|
||||
};
|
||||
|
||||
struct __attribute__ ((__packed__)) psoc_layout {
|
||||
u8 ctl; //offset: 0
|
||||
u16 switch_temp; //offset: 1
|
||||
|
||||
// BYTE[03:20] - voltage
|
||||
u16 voltage[15]; //offset: 0x03-0x20
|
||||
|
||||
// BYTE[21:27] - ExtFan
|
||||
u8 led_ctl2; //offset: 21
|
||||
u8 ext_pwm; //offset: 22
|
||||
u16 ext_rpm[2]; //offset: 23
|
||||
u8 gpi_fan2; //offset: 27
|
||||
|
||||
//gpo
|
||||
u8 led_ctl; //offset: 28
|
||||
|
||||
u8 gpio; //offset: 29
|
||||
|
||||
//pwm duty
|
||||
u8 pwm[4]; //offset: 2a
|
||||
u8 pwm_psu[2]; //offset: 2e
|
||||
|
||||
//fan rpm
|
||||
u16 fan[4*2]; //offset: 30
|
||||
|
||||
u8 reserve1[4]; //offset: 40
|
||||
|
||||
//gpi
|
||||
u8 gpi_fan; //offset: 44
|
||||
|
||||
//psu state
|
||||
u8 psu_state; //offset: 45
|
||||
|
||||
//temperature
|
||||
u16 temp[5]; //offset: 46
|
||||
u16 temp_psu[2]; //offset: 50
|
||||
|
||||
//version
|
||||
u8 version[2]; //offset: 54
|
||||
|
||||
u8 reserve2[4]; //offset: 56
|
||||
struct psoc_psu_layout psu_info; //offset: 5a
|
||||
};
|
||||
|
||||
/* definition */
|
||||
#define PSOC_OFF(m) offsetof(struct psoc_layout, m)
|
||||
#define PSOC_PSU_OFF(m) offsetof(struct psoc_psu_layout, m)
|
||||
|
||||
#define SWITCH_TMP_OFFSET PSOC_OFF(switch_temp)
|
||||
#define PWM_OFFSET PSOC_OFF(pwm)
|
||||
#define THERMAL_OFFSET PSOC_OFF(temp)
|
||||
#define RPM_OFFSET PSOC_OFF(fan)
|
||||
#define DIAG_FLAG_OFFSET PSOC_OFF(ctl)
|
||||
#define FAN_LED_OFFSET PSOC_OFF(led_ctl)
|
||||
#define FAN_GPI_OFFSET PSOC_OFF(gpi_fan)
|
||||
#define PSOC_PSU_OFFSET PSOC_OFF(psu_state)
|
||||
#define VERSION_OFFSET PSOC_OFF(version)
|
||||
#define PSU_INFO_OFFSET PSOC_OFF(psu_info)
|
||||
|
||||
#define PWM2_OFFSET PSOC_OFF(ext_pwm)
|
||||
#define RPM2_OFFSET PSOC_OFF(ext_rpm)
|
||||
#define FAN_LED2_OFFSET PSOC_OFF(led_ctl2)
|
||||
#define FAN_GPI2_OFFSET PSOC_OFF(gpi_fan2)
|
||||
|
||||
#define CLEI_OFF(m) offsetof(struct clei, m)
|
||||
#define FAN1_CLEI_INDEX 0
|
||||
#define FAN2_CLEI_INDEX 1
|
||||
#define FAN3_CLEI_INDEX 2
|
||||
#define FAN4_CLEI_INDEX 3
|
||||
#define FAN5_CLEI_INDEX 4
|
||||
#define PSU1_CLEI_INDEX 5
|
||||
#define PSU2_CLEI_INDEX 6
|
||||
|
||||
static void msg_handler(struct ipmi_recv_msg *recv_msg,void* handler_data)
|
||||
{
|
||||
struct ipmi_result *msg_result = recv_msg->user_msg_data;
|
||||
|
||||
if(recv_msg->msg.data[0]==0 && recv_msg->msg.data_len>0) {
|
||||
msg_result->result_length=recv_msg->msg.data_len-1;
|
||||
memcpy(msg_result->result, &recv_msg->msg.data[1], recv_msg->msg.data_len-1);
|
||||
}
|
||||
ipmi_free_recv_msg(recv_msg);
|
||||
mutex_unlock(&ipmi_mutex);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
int start_ipmi_command(char NetFn, char cmd,char *data,int data_length, char* result, int* result_length)
|
||||
{
|
||||
int rv=0,i;
|
||||
int timeout;
|
||||
|
||||
//wait previous command finish at least 50msec
|
||||
timeout=50;
|
||||
while((mutex_is_locked(&ipmi_mutex) == 1 || (mutex_is_locked(&ipmi2_mutex) == 1)) && (--timeout)>0) { usleep_range(1000,1010); }
|
||||
if(timeout==0) { return -1; }
|
||||
mutex_lock(&ipmi_mutex);
|
||||
mutex_lock(&ipmi2_mutex);
|
||||
|
||||
if(ipmi_mh_user == NULL) {
|
||||
for (i=0,rv=1; i<IPMI_MAX_INTF && rv; i++) {
|
||||
rv = ipmi_create_user(i, &ipmi_hndlrs, NULL, &ipmi_mh_user);
|
||||
}
|
||||
}
|
||||
|
||||
if (rv < 0) {
|
||||
mutex_unlock(&ipmi_mutex);
|
||||
mutex_unlock(&ipmi2_mutex);
|
||||
return rv;
|
||||
}
|
||||
else {
|
||||
struct ipmi_system_interface_addr addr;
|
||||
struct kernel_ipmi_msg msg;
|
||||
uint8_t msg_data[data_length];
|
||||
|
||||
memcpy(msg_data,data,data_length);
|
||||
addr.addr_type = IPMI_SYSTEM_INTERFACE_ADDR_TYPE;
|
||||
addr.channel = IPMI_BMC_CHANNEL;
|
||||
addr.lun = 0;
|
||||
|
||||
msg.netfn = NetFn;
|
||||
msg.cmd = cmd;
|
||||
msg.data = msg_data;
|
||||
msg.data_len = data_length;
|
||||
|
||||
rv = ipmi_request_supply_msgs(ipmi_mh_user, (struct ipmi_addr*)&addr, 0,&msg, &ipmiresult, &halt_smi_msg, &halt_recv_msg, 0);
|
||||
if (rv) {
|
||||
mutex_unlock(&ipmi_mutex);
|
||||
mutex_unlock(&ipmi2_mutex);
|
||||
return -6;
|
||||
}
|
||||
|
||||
//skip command if 1sec no response from remote
|
||||
timeout=1000;
|
||||
while(mutex_is_locked(&ipmi_mutex) == 1 && (--timeout)>0) { usleep_range(1000,1100);}
|
||||
if(timeout==0) {
|
||||
mutex_unlock(&ipmi2_mutex);
|
||||
return -1;
|
||||
}
|
||||
else {
|
||||
*result_length=ipmiresult.result_length;
|
||||
memcpy(result,ipmiresult.result,*result_length);
|
||||
mutex_unlock(&ipmi2_mutex);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(start_ipmi_command);
|
||||
|
||||
static ssize_t psoc_ipmi_read(u8 *buf, u8 offset, size_t count)
|
||||
{
|
||||
uint8_t data[2];
|
||||
int result_len=0;
|
||||
int rv;
|
||||
|
||||
data[0] = offset;
|
||||
data[1] = count;
|
||||
|
||||
rv=start_ipmi_command(NETFN_OEM, CMD_GETDATA,data,2, buf, &result_len);
|
||||
|
||||
return result_len;
|
||||
}
|
||||
|
||||
static ssize_t psoc_ipmi_write(char *buf, unsigned offset, size_t count)
|
||||
{
|
||||
uint8_t data[count+1],result[1];
|
||||
int result_len;
|
||||
|
||||
data[0] = offset;
|
||||
memcpy(&data[1],buf,count);
|
||||
|
||||
start_ipmi_command(NETFN_OEM, CMD_SETDATA,data,count+1, result, &result_len);
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
static u16 psoc_read16(u8 offset)
|
||||
{
|
||||
u16 value = 0;
|
||||
u8 buf[]={0,0};
|
||||
|
||||
if(psoc_ipmi_read(buf, offset, 2) == 2)
|
||||
value = (buf[0]<<8 | buf[1]<<0);
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
static u8 psoc_read8(u8 offset)
|
||||
{
|
||||
u8 value = 0;
|
||||
u8 buf = 0;
|
||||
|
||||
if(psoc_ipmi_read(&buf, offset, 1) == 1)
|
||||
value = buf;
|
||||
|
||||
return value;
|
||||
}
|
||||
|
||||
/*
|
||||
CPLD report the PSU0 status
|
||||
000 = PSU normal operation
|
||||
100 = PSU fault
|
||||
010 = PSU unpowered
|
||||
111 = PSU not installed
|
||||
|
||||
7 6 | 5 4 3 | 2 1 0
|
||||
----------------------
|
||||
| psu1 | psu0
|
||||
*/
|
||||
static char* psu_str[] = {
|
||||
"normal", //000
|
||||
"NA", //001
|
||||
"unpowered", //010
|
||||
"NA", //011
|
||||
"fault", //100
|
||||
"NA", //101
|
||||
"NA", //110
|
||||
"not installed", //111
|
||||
};
|
||||
|
||||
static ssize_t show_psu_st(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
u32 status=0;
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
u8 byte=0;
|
||||
int shift = (attr->index == 0)?3:0;
|
||||
|
||||
status = psoc_ipmi_read(&byte, PSOC_PSU_OFFSET, 1);
|
||||
|
||||
byte = (byte >> shift) & 0x7;
|
||||
|
||||
status = sprintf (buf, "%d : %s\n", byte, psu_str[byte]);
|
||||
|
||||
return strlen(buf);
|
||||
}
|
||||
|
||||
static ssize_t show_ipmi_pmbus(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
uint8_t data[4],result[MaxLeng_Result];
|
||||
int result_len=0;
|
||||
|
||||
data[0] = BMC_PMBusNumber;
|
||||
data[1] = (attr->index & 0xFF00 ) >>7;
|
||||
data[3] = attr->index & 0xff;
|
||||
if(data[3]==PMBus_Temp2)
|
||||
{data[2]=2;}
|
||||
else
|
||||
{data[2]=MaxLeng_Result;}
|
||||
|
||||
if(start_ipmi_command(0x06, 0x52,data,4, result, &result_len)==0)
|
||||
{
|
||||
if(data[3]==PMBus_Temp2)
|
||||
{
|
||||
return sprintf(buf, "%ld \n", pmbus_reg2data_linear(result[0] | (result[1]<<8), 0 ));
|
||||
}
|
||||
result[result[0]+1]='\0';
|
||||
return sprintf(buf, "%s\n",&result[1] );
|
||||
}
|
||||
else
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
static ssize_t show_clei(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
u8 device_index = attr->index & 0xFF;
|
||||
|
||||
uint8_t data[5],result[MaxLeng_Result];
|
||||
int result_len=0;
|
||||
|
||||
data[0] = (device_index<=FAN5_CLEI_INDEX) ? BMC_FanCLEIBusNumber:BMC_PMBusNumber;
|
||||
data[1] = CLEI_ADDR[device_index]<<1;
|
||||
data[2] = sizeof(struct clei);
|
||||
data[3] = (device_index<=FAN5_CLEI_INDEX) ? 0x00 : 0x01; //PSU CLEI will start from 0x0100
|
||||
data[4] = 0;
|
||||
|
||||
if(start_ipmi_command(0x06, 0x52,data,5, result, &result_len)==0)
|
||||
{
|
||||
if(result_len < sizeof(struct clei)) memset(result, 0, sizeof(struct clei));
|
||||
sprintf (buf, "Issue Number: %.3s\n", &result[CLEI_OFF(issue_number)]);
|
||||
sprintf (buf, "%sAbbreviation Number: %.9s\n", buf, &result[CLEI_OFF(abbreviation_number)]);
|
||||
sprintf (buf, "%sFC Number: %.10s\n", buf, &result[CLEI_OFF(fc_number)]);
|
||||
sprintf (buf, "%sCLEI Code: %.10s\n", buf, &result[CLEI_OFF(clei_code)]);
|
||||
sprintf (buf, "%sProduct Year and Month: %.5s\n", buf, &result[CLEI_OFF(product_year_and_month)]);
|
||||
sprintf (buf, "%s2D Label Location Code: %.2s\n", buf, &result[CLEI_OFF(label_location_code)]);
|
||||
sprintf (buf, "%sSerial Number: %.5s\n", buf, &result[CLEI_OFF(serial_number)]);
|
||||
sprintf (buf, "%sPCB Revision: %.5s\n", buf, &result[CLEI_OFF(pcb_revision)]);
|
||||
sprintf (buf, "%sVendor Name: %.10s\n", buf, &result[CLEI_OFF(vendor_name)]);
|
||||
return strlen(buf);
|
||||
}
|
||||
else
|
||||
{
|
||||
return sprintf(buf, "NONE\n");
|
||||
}
|
||||
}
|
||||
|
||||
static ssize_t show_thermal(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
int status=0;
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
u8 offset = attr->index * 2 + THERMAL_OFFSET;
|
||||
|
||||
status = psoc_read16(offset);
|
||||
|
||||
return sprintf(buf, "%d\n",
|
||||
(s8)(status>>8) * 1000 );
|
||||
}
|
||||
|
||||
static ssize_t show_pwm(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
int status=0;
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
u8 offset = attr->index;
|
||||
|
||||
status = psoc_read8(offset);
|
||||
|
||||
return sprintf(buf, "%d\n",
|
||||
status);
|
||||
}
|
||||
|
||||
static ssize_t set_pwm(struct device *dev,
|
||||
struct device_attribute *da,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
u8 offset = attr->index;
|
||||
u8 pwm = simple_strtol(buf, NULL, 10);
|
||||
if(pwm > 255) pwm = 255;
|
||||
psoc_ipmi_write(&pwm, offset, 1);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
|
||||
static ssize_t show_rpm(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
int status=0;
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
u8 offset = attr->index;
|
||||
status = psoc_read16(offset);
|
||||
|
||||
return sprintf(buf, "%d\n",
|
||||
status);
|
||||
}
|
||||
|
||||
static ssize_t show_switch_tmp(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
u16 status=0;
|
||||
u16 temp = 0;
|
||||
|
||||
status = psoc_ipmi_read((u8*)&temp, SWITCH_TMP_OFFSET, 2);
|
||||
|
||||
status = sprintf (buf, "%d\n", (s8)(temp>>8) * 1000 );
|
||||
|
||||
return strlen(buf);
|
||||
}
|
||||
|
||||
static ssize_t set_switch_tmp(struct device *dev,
|
||||
struct device_attribute *devattr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
long temp = simple_strtol(buf, NULL, 10);
|
||||
u16 temp2 = ( (temp/1000) <<8 ) & 0xFF00 ;
|
||||
|
||||
psoc_ipmi_write((u8*)&temp2, SWITCH_TMP_OFFSET, 2);
|
||||
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t show_diag(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
u16 status=0;
|
||||
u8 diag_flag = 0;
|
||||
|
||||
status = psoc_ipmi_read((u8*)&diag_flag, DIAG_FLAG_OFFSET, 1);
|
||||
|
||||
status = sprintf (buf, "%d\n", ((diag_flag & 0x80)?1:0));
|
||||
|
||||
return strlen(buf);
|
||||
}
|
||||
|
||||
static ssize_t set_diag(struct device *dev,
|
||||
struct device_attribute *devattr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
u8 value = 0;
|
||||
u8 diag = simple_strtol(buf, NULL, 10);
|
||||
|
||||
diag = diag?1:0;
|
||||
|
||||
psoc_ipmi_read((u8*)&value, DIAG_FLAG_OFFSET, 1);
|
||||
if(diag) value |= (1<<7);
|
||||
else value &= ~(1<<7);
|
||||
psoc_ipmi_write((u8*)&value, DIAG_FLAG_OFFSET, 1);
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t show_version(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
u16 status=0;
|
||||
|
||||
status = psoc_read16(VERSION_OFFSET);
|
||||
|
||||
return sprintf(buf, "ver: %x.%x\n", (status & 0xFF00)>>8, (status & 0xFF) );
|
||||
}
|
||||
|
||||
|
||||
static ssize_t show_fan_led(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
int status=0;
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
u8 bit = attr->index;
|
||||
|
||||
if(bit < 8) { status = psoc_read8(FAN_LED_OFFSET); }
|
||||
#if FAN_NUM>4
|
||||
if(bit >= 8) { status = psoc_read8(FAN_LED2_OFFSET); bit-=8; }
|
||||
#endif
|
||||
|
||||
return sprintf(buf, "%d\n",
|
||||
(status & (1<<bit))?1:0 );
|
||||
}
|
||||
|
||||
static ssize_t set_fan_led(struct device *dev,
|
||||
struct device_attribute *devattr,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(devattr);
|
||||
u8 bit = attr->index;
|
||||
u8 led_state = 0;
|
||||
|
||||
u8 v = simple_strtol(buf, NULL, 10);
|
||||
|
||||
if(attr->index < 8) { led_state = psoc_read8(FAN_LED_OFFSET ); }
|
||||
#if FAN_NUM>4
|
||||
if(attr->index >= 8) { led_state = psoc_read8(FAN_LED2_OFFSET); bit-=8; }
|
||||
#endif
|
||||
if(v) led_state |= (1<<bit);
|
||||
else led_state &= ~(1<<bit);
|
||||
|
||||
if(attr->index < 8) { psoc_ipmi_write(&led_state, FAN_LED_OFFSET, 1);}
|
||||
#if FAN_NUM>4
|
||||
if(attr->index >= 8) { psoc_ipmi_write(&led_state, FAN_LED2_OFFSET,1);}
|
||||
#endif
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t show_value8(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
int status=0;
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
u8 offset = attr->index;
|
||||
|
||||
status = psoc_read8(offset);
|
||||
|
||||
return sprintf(buf, "0x%02X\n", status );
|
||||
}
|
||||
|
||||
static long pmbus_reg2data_linear(int data, int linear16)
|
||||
{
|
||||
s16 exponent;
|
||||
s32 mantissa;
|
||||
long val;
|
||||
|
||||
if (linear16) { /* LINEAR16 */
|
||||
exponent = -9;
|
||||
mantissa = (u16) data;
|
||||
} else { /* LINEAR11 */
|
||||
exponent = ((s16)data) >> 11;
|
||||
exponent = ((s16)( data & 0xF800) ) >> 11;
|
||||
mantissa = ((s32)((data & 0x7ff) << 5)) >> 5;
|
||||
}
|
||||
|
||||
//printk("data=%d, m=%d, e=%d\n", data, exponent, mantissa);
|
||||
val = mantissa;
|
||||
|
||||
/* scale result to micro-units for power sensors */
|
||||
val = val * 1000L;
|
||||
|
||||
if (exponent >= 0)
|
||||
val <<= exponent;
|
||||
else
|
||||
val >>= -exponent;
|
||||
|
||||
return val;
|
||||
}
|
||||
|
||||
static ssize_t show_psu_psoc(struct device *dev, struct device_attribute *da,
|
||||
char *buf)
|
||||
{
|
||||
u16 status=0;
|
||||
struct sensor_device_attribute *attr = to_sensor_dev_attr(da);
|
||||
u8 offset = attr->index + PSU_INFO_OFFSET;
|
||||
|
||||
status = psoc_read16(offset);
|
||||
|
||||
if((strstr(attr->dev_attr.attr.name, "vout")!=NULL)|(strstr(attr->dev_attr.attr.name, "in3")!=NULL)|(strstr(attr->dev_attr.attr.name, "in4")!=NULL)) {
|
||||
offset=1;
|
||||
}
|
||||
else {
|
||||
offset=0;
|
||||
}
|
||||
|
||||
return sprintf(buf, "%ld \n", pmbus_reg2data_linear(status, offset ));
|
||||
}
|
||||
|
||||
static ssize_t show_name(struct device *dev,
|
||||
struct device_attribute *devattr, char *buf)
|
||||
{
|
||||
return sprintf(buf, "inv_psoc\n");
|
||||
}
|
||||
|
||||
static DEVICE_ATTR(name, S_IRUGO, show_name, NULL);
|
||||
static SENSOR_DEVICE_ATTR(temp1_input, S_IRUGO, show_thermal, 0, 0);
|
||||
static SENSOR_DEVICE_ATTR(temp2_input, S_IRUGO, show_thermal, 0, 1);
|
||||
static SENSOR_DEVICE_ATTR(temp3_input, S_IRUGO, show_thermal, 0, 2);
|
||||
static SENSOR_DEVICE_ATTR(temp4_input, S_IRUGO, show_thermal, 0, 3);
|
||||
static SENSOR_DEVICE_ATTR(temp5_input, S_IRUGO, show_thermal, 0, 4);
|
||||
static SENSOR_DEVICE_ATTR(thermal_psu1, S_IRUGO, show_thermal, 0, 5);
|
||||
static SENSOR_DEVICE_ATTR(thermal_psu2, S_IRUGO, show_thermal, 0, 6);
|
||||
static SENSOR_DEVICE_ATTR(temp7_input, S_IRUGO, show_thermal, 0, 5);
|
||||
static SENSOR_DEVICE_ATTR(temp8_input, S_IRUGO, show_thermal, 0, 6);
|
||||
|
||||
static SENSOR_DEVICE_ATTR(pwm1, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 0 + PWM_OFFSET);
|
||||
static SENSOR_DEVICE_ATTR(pwm2, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 1 + PWM_OFFSET);
|
||||
static SENSOR_DEVICE_ATTR(pwm3, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 2 + PWM_OFFSET);
|
||||
static SENSOR_DEVICE_ATTR(pwm4, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 3 + PWM_OFFSET);
|
||||
#if FAN_NUM > 4
|
||||
static SENSOR_DEVICE_ATTR(pwm5, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 0 + PWM2_OFFSET);
|
||||
#endif
|
||||
static SENSOR_DEVICE_ATTR(pwm_psu1, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 4 + PWM_OFFSET);
|
||||
static SENSOR_DEVICE_ATTR(pwm_psu2, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 5 + PWM_OFFSET);
|
||||
static SENSOR_DEVICE_ATTR(pwm6, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 4 + PWM_OFFSET);
|
||||
static SENSOR_DEVICE_ATTR(pwm7, S_IWUSR|S_IRUGO, show_pwm, set_pwm, 5 + PWM_OFFSET);
|
||||
|
||||
static SENSOR_DEVICE_ATTR(psu1, S_IRUGO, show_psu_st, 0, 0);
|
||||
static SENSOR_DEVICE_ATTR(psu2, S_IRUGO, show_psu_st, 0, 1);
|
||||
|
||||
static SENSOR_DEVICE_ATTR(fan1_input, S_IRUGO, show_rpm, 0, 0*2 + RPM_OFFSET);
|
||||
static SENSOR_DEVICE_ATTR(fan2_input, S_IRUGO, show_rpm, 0, 1*2 + RPM_OFFSET);
|
||||
static SENSOR_DEVICE_ATTR(fan3_input, S_IRUGO, show_rpm, 0, 2*2 + RPM_OFFSET);
|
||||
static SENSOR_DEVICE_ATTR(fan4_input, S_IRUGO, show_rpm, 0, 3*2 + RPM_OFFSET);
|
||||
static SENSOR_DEVICE_ATTR(fan5_input, S_IRUGO, show_rpm, 0, 4*2 + RPM_OFFSET);
|
||||
static SENSOR_DEVICE_ATTR(fan6_input, S_IRUGO, show_rpm, 0, 5*2 + RPM_OFFSET);
|
||||
static SENSOR_DEVICE_ATTR(fan7_input, S_IRUGO, show_rpm, 0, 6*2 + RPM_OFFSET);
|
||||
static SENSOR_DEVICE_ATTR(fan8_input, S_IRUGO, show_rpm, 0, 7*2 + RPM_OFFSET);
|
||||
static SENSOR_DEVICE_ATTR(rpm_psu1, S_IRUGO, show_rpm, 0, 8*2 + RPM_OFFSET);
|
||||
static SENSOR_DEVICE_ATTR(rpm_psu2, S_IRUGO, show_rpm, 0, 9*2 + RPM_OFFSET);
|
||||
static SENSOR_DEVICE_ATTR(fan11_input, S_IRUGO, show_rpm, 0, 8*2 + RPM_OFFSET);
|
||||
static SENSOR_DEVICE_ATTR(fan12_input, S_IRUGO, show_rpm, 0, 9*2 + RPM_OFFSET);
|
||||
|
||||
#if FAN_NUM > 4
|
||||
static SENSOR_DEVICE_ATTR(fan9_input , S_IRUGO, show_rpm, 0,0*2 + RPM2_OFFSET);
|
||||
static SENSOR_DEVICE_ATTR(fan10_input, S_IRUGO, show_rpm, 0,1*2 + RPM2_OFFSET);
|
||||
#endif
|
||||
|
||||
static SENSOR_DEVICE_ATTR(switch_tmp, S_IWUSR|S_IRUGO, show_switch_tmp, set_switch_tmp, 0);
|
||||
static SENSOR_DEVICE_ATTR(temp6_input, S_IWUSR|S_IRUGO, show_switch_tmp, set_switch_tmp, 0);
|
||||
|
||||
static SENSOR_DEVICE_ATTR(diag, S_IWUSR|S_IRUGO, show_diag, set_diag, 0);
|
||||
static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, 0, 0);
|
||||
|
||||
static SENSOR_DEVICE_ATTR(fan_led_grn1, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 0);
|
||||
static SENSOR_DEVICE_ATTR(fan_led_grn2, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 1);
|
||||
static SENSOR_DEVICE_ATTR(fan_led_grn3, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 2);
|
||||
static SENSOR_DEVICE_ATTR(fan_led_grn4, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 3);
|
||||
static SENSOR_DEVICE_ATTR(fan_led_red1, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 4);
|
||||
static SENSOR_DEVICE_ATTR(fan_led_red2, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 5);
|
||||
static SENSOR_DEVICE_ATTR(fan_led_red3, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 6);
|
||||
static SENSOR_DEVICE_ATTR(fan_led_red4, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 7);
|
||||
|
||||
#if FAN_NUM>4
|
||||
static SENSOR_DEVICE_ATTR(fan_led_grn5, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 8);
|
||||
static SENSOR_DEVICE_ATTR(fan_led_red5, S_IWUSR|S_IRUGO, show_fan_led, set_fan_led, 12);
|
||||
static SENSOR_DEVICE_ATTR(fan_gpi2, S_IRUGO, show_value8, 0, FAN_GPI2_OFFSET);
|
||||
#endif
|
||||
|
||||
static SENSOR_DEVICE_ATTR(fan_gpi, S_IRUGO, show_value8, 0, FAN_GPI_OFFSET);
|
||||
static SENSOR_DEVICE_ATTR(psoc_psu1_vin, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_vin));
|
||||
static SENSOR_DEVICE_ATTR(psoc_psu1_vout, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_vout));
|
||||
static SENSOR_DEVICE_ATTR(psoc_psu1_iin, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_iin));
|
||||
static SENSOR_DEVICE_ATTR(psoc_psu1_iout, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_iout));
|
||||
static SENSOR_DEVICE_ATTR(psoc_psu1_pin, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_pin));
|
||||
static SENSOR_DEVICE_ATTR(psoc_psu1_pout, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_pout));
|
||||
|
||||
static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_vin));
|
||||
static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_iin));
|
||||
static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_pin));
|
||||
static SENSOR_DEVICE_ATTR(in3_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_vout));
|
||||
static SENSOR_DEVICE_ATTR(curr3_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_iout));
|
||||
static SENSOR_DEVICE_ATTR(power3_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_pout));
|
||||
|
||||
static SENSOR_DEVICE_ATTR(psoc_psu2_vin, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_vin));
|
||||
static SENSOR_DEVICE_ATTR(psoc_psu2_vout, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_vout));
|
||||
static SENSOR_DEVICE_ATTR(psoc_psu2_iin, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_iin));
|
||||
static SENSOR_DEVICE_ATTR(psoc_psu2_iout, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_iout));
|
||||
static SENSOR_DEVICE_ATTR(psoc_psu2_pin, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_pin));
|
||||
static SENSOR_DEVICE_ATTR(psoc_psu2_pout, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_pout));
|
||||
|
||||
static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_vin));
|
||||
static SENSOR_DEVICE_ATTR(curr2_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_iin));
|
||||
static SENSOR_DEVICE_ATTR(power2_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_pin));
|
||||
static SENSOR_DEVICE_ATTR(in4_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_vout));
|
||||
static SENSOR_DEVICE_ATTR(curr4_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_iout));
|
||||
static SENSOR_DEVICE_ATTR(power4_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_pout));
|
||||
|
||||
//IPMI
|
||||
static SENSOR_DEVICE_ATTR(thermal2_psu1, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Temp2);
|
||||
static SENSOR_DEVICE_ATTR(temp9_input, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Temp2);
|
||||
|
||||
static SENSOR_DEVICE_ATTR(psoc_psu1_vendor, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Vendor);
|
||||
static SENSOR_DEVICE_ATTR(psoc_psu1_serial, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Serial);
|
||||
static SENSOR_DEVICE_ATTR(psoc_psu1_version, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Version);
|
||||
|
||||
static SENSOR_DEVICE_ATTR(thermal2_psu2, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Temp2);
|
||||
static SENSOR_DEVICE_ATTR(temp10_input, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Temp2);
|
||||
static SENSOR_DEVICE_ATTR(psoc_psu2_vendor, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Vendor);
|
||||
static SENSOR_DEVICE_ATTR(psoc_psu2_serial, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Serial);
|
||||
static SENSOR_DEVICE_ATTR(psoc_psu2_version, S_IRUGO, show_ipmi_pmbus, 0, PSU2 | PMBus_Version);
|
||||
|
||||
//CLEI
|
||||
#if FAN_CLEI_SUPPORT
|
||||
static SENSOR_DEVICE_ATTR(fan1_clei, S_IRUGO, show_clei, 0, FAN1_CLEI_INDEX );
|
||||
static SENSOR_DEVICE_ATTR(fan2_clei, S_IRUGO, show_clei, 0, FAN2_CLEI_INDEX );
|
||||
static SENSOR_DEVICE_ATTR(fan3_clei, S_IRUGO, show_clei, 0, FAN3_CLEI_INDEX );
|
||||
static SENSOR_DEVICE_ATTR(fan4_clei, S_IRUGO, show_clei, 0, FAN4_CLEI_INDEX );
|
||||
#if FAN_NUM > 4
|
||||
static SENSOR_DEVICE_ATTR(fan5_clei, S_IRUGO, show_clei, 0, FAN5_CLEI_INDEX );
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if PSU_CLEI_SUPPORT
|
||||
static SENSOR_DEVICE_ATTR(psu1_clei, S_IRUGO, show_clei, 0, PSU1_CLEI_INDEX );
|
||||
static SENSOR_DEVICE_ATTR(psu2_clei, S_IRUGO, show_clei, 0, PSU2_CLEI_INDEX );
|
||||
#endif
|
||||
|
||||
static struct attribute *psoc_attributes[] = {
|
||||
//name
|
||||
&dev_attr_name.attr,
|
||||
//thermal
|
||||
&sensor_dev_attr_temp1_input.dev_attr.attr,
|
||||
&sensor_dev_attr_temp2_input.dev_attr.attr,
|
||||
&sensor_dev_attr_temp3_input.dev_attr.attr,
|
||||
&sensor_dev_attr_temp4_input.dev_attr.attr,
|
||||
&sensor_dev_attr_temp5_input.dev_attr.attr,
|
||||
&sensor_dev_attr_thermal_psu1.dev_attr.attr,
|
||||
&sensor_dev_attr_thermal_psu2.dev_attr.attr,
|
||||
|
||||
&sensor_dev_attr_temp7_input.dev_attr.attr,
|
||||
&sensor_dev_attr_temp8_input.dev_attr.attr,
|
||||
|
||||
//pwm
|
||||
&sensor_dev_attr_pwm1.dev_attr.attr,
|
||||
&sensor_dev_attr_pwm2.dev_attr.attr,
|
||||
&sensor_dev_attr_pwm3.dev_attr.attr,
|
||||
&sensor_dev_attr_pwm4.dev_attr.attr,
|
||||
#if FAN_NUM > 4
|
||||
&sensor_dev_attr_pwm5.dev_attr.attr,
|
||||
#endif
|
||||
&sensor_dev_attr_pwm_psu1.dev_attr.attr,
|
||||
&sensor_dev_attr_pwm_psu2.dev_attr.attr,
|
||||
&sensor_dev_attr_pwm6.dev_attr.attr,
|
||||
&sensor_dev_attr_pwm7.dev_attr.attr,
|
||||
|
||||
//rpm
|
||||
&sensor_dev_attr_fan1_input.dev_attr.attr,
|
||||
&sensor_dev_attr_fan2_input.dev_attr.attr,
|
||||
&sensor_dev_attr_fan3_input.dev_attr.attr,
|
||||
&sensor_dev_attr_fan4_input.dev_attr.attr,
|
||||
&sensor_dev_attr_fan5_input.dev_attr.attr,
|
||||
&sensor_dev_attr_fan6_input.dev_attr.attr,
|
||||
&sensor_dev_attr_fan7_input.dev_attr.attr,
|
||||
&sensor_dev_attr_fan8_input.dev_attr.attr,
|
||||
#if FAN_NUM > 4
|
||||
&sensor_dev_attr_fan9_input.dev_attr.attr,
|
||||
&sensor_dev_attr_fan10_input.dev_attr.attr,
|
||||
#endif
|
||||
&sensor_dev_attr_rpm_psu1.dev_attr.attr,
|
||||
&sensor_dev_attr_rpm_psu2.dev_attr.attr,
|
||||
&sensor_dev_attr_fan11_input.dev_attr.attr,
|
||||
&sensor_dev_attr_fan12_input.dev_attr.attr,
|
||||
//switch temperature
|
||||
&sensor_dev_attr_switch_tmp.dev_attr.attr,
|
||||
&sensor_dev_attr_temp6_input.dev_attr.attr,
|
||||
|
||||
//diag flag
|
||||
&sensor_dev_attr_diag.dev_attr.attr,
|
||||
|
||||
//version
|
||||
&sensor_dev_attr_version.dev_attr.attr,
|
||||
|
||||
//fan led
|
||||
&sensor_dev_attr_fan_led_grn1.dev_attr.attr,
|
||||
&sensor_dev_attr_fan_led_grn2.dev_attr.attr,
|
||||
&sensor_dev_attr_fan_led_grn3.dev_attr.attr,
|
||||
&sensor_dev_attr_fan_led_grn4.dev_attr.attr,
|
||||
&sensor_dev_attr_fan_led_red1.dev_attr.attr,
|
||||
&sensor_dev_attr_fan_led_red2.dev_attr.attr,
|
||||
&sensor_dev_attr_fan_led_red3.dev_attr.attr,
|
||||
&sensor_dev_attr_fan_led_red4.dev_attr.attr,
|
||||
#if FAN_NUM >4
|
||||
&sensor_dev_attr_fan_led_grn5.dev_attr.attr,
|
||||
&sensor_dev_attr_fan_led_red5.dev_attr.attr,
|
||||
&sensor_dev_attr_fan_gpi2.dev_attr.attr,
|
||||
#endif
|
||||
//fan GPI
|
||||
&sensor_dev_attr_fan_gpi.dev_attr.attr,
|
||||
&sensor_dev_attr_psu1.dev_attr.attr,
|
||||
&sensor_dev_attr_psu2.dev_attr.attr,
|
||||
|
||||
|
||||
//psu_psoc
|
||||
&sensor_dev_attr_psoc_psu1_vin.dev_attr.attr,
|
||||
&sensor_dev_attr_psoc_psu1_vout.dev_attr.attr,
|
||||
&sensor_dev_attr_psoc_psu1_iin.dev_attr.attr,
|
||||
&sensor_dev_attr_psoc_psu1_iout.dev_attr.attr,
|
||||
&sensor_dev_attr_psoc_psu1_pin.dev_attr.attr,
|
||||
&sensor_dev_attr_psoc_psu1_pout.dev_attr.attr,
|
||||
&sensor_dev_attr_psoc_psu2_vin.dev_attr.attr,
|
||||
&sensor_dev_attr_psoc_psu2_vout.dev_attr.attr,
|
||||
&sensor_dev_attr_psoc_psu2_iin.dev_attr.attr,
|
||||
&sensor_dev_attr_psoc_psu2_iout.dev_attr.attr,
|
||||
&sensor_dev_attr_psoc_psu2_pin.dev_attr.attr,
|
||||
&sensor_dev_attr_psoc_psu2_pout.dev_attr.attr,
|
||||
|
||||
&sensor_dev_attr_in1_input.dev_attr.attr,
|
||||
&sensor_dev_attr_curr1_input.dev_attr.attr,
|
||||
&sensor_dev_attr_power1_input.dev_attr.attr,
|
||||
&sensor_dev_attr_in2_input.dev_attr.attr,
|
||||
&sensor_dev_attr_curr2_input.dev_attr.attr,
|
||||
&sensor_dev_attr_power2_input.dev_attr.attr,
|
||||
&sensor_dev_attr_in3_input.dev_attr.attr,
|
||||
&sensor_dev_attr_curr3_input.dev_attr.attr,
|
||||
&sensor_dev_attr_power3_input.dev_attr.attr,
|
||||
&sensor_dev_attr_in4_input.dev_attr.attr,
|
||||
&sensor_dev_attr_curr4_input.dev_attr.attr,
|
||||
&sensor_dev_attr_power4_input.dev_attr.attr,
|
||||
|
||||
//ipmi_i2c_command
|
||||
&sensor_dev_attr_thermal2_psu1.dev_attr.attr,
|
||||
&sensor_dev_attr_temp9_input.dev_attr.attr,
|
||||
&sensor_dev_attr_psoc_psu1_vendor.dev_attr.attr,
|
||||
&sensor_dev_attr_psoc_psu1_serial.dev_attr.attr,
|
||||
&sensor_dev_attr_psoc_psu1_version.dev_attr.attr,
|
||||
|
||||
&sensor_dev_attr_thermal2_psu2.dev_attr.attr,
|
||||
&sensor_dev_attr_temp10_input.dev_attr.attr,
|
||||
&sensor_dev_attr_psoc_psu2_vendor.dev_attr.attr,
|
||||
&sensor_dev_attr_psoc_psu2_serial.dev_attr.attr,
|
||||
&sensor_dev_attr_psoc_psu2_version.dev_attr.attr,
|
||||
|
||||
//clei
|
||||
#if FAN_CLEI_SUPPORT
|
||||
&sensor_dev_attr_fan1_clei.dev_attr.attr,
|
||||
&sensor_dev_attr_fan2_clei.dev_attr.attr,
|
||||
&sensor_dev_attr_fan3_clei.dev_attr.attr,
|
||||
&sensor_dev_attr_fan4_clei.dev_attr.attr,
|
||||
#if FAN_NUM > 4
|
||||
&sensor_dev_attr_fan5_clei.dev_attr.attr,
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if PSU_CLEI_SUPPORT
|
||||
&sensor_dev_attr_psu1_clei.dev_attr.attr,
|
||||
&sensor_dev_attr_psu2_clei.dev_attr.attr,
|
||||
#endif
|
||||
NULL
|
||||
};
|
||||
|
||||
static const struct attribute_group psoc_group = {
|
||||
.attrs = psoc_attributes,
|
||||
};
|
||||
|
||||
//=================================
|
||||
static void check_switch_temp(void)
|
||||
{
|
||||
static struct file *f;
|
||||
mm_segment_t old_fs;
|
||||
|
||||
set_fs(get_ds());
|
||||
f = filp_open(SWITCH_TEMPERATURE_SOCK,O_RDONLY,0644);
|
||||
if(IS_ERR(f)) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
char temp_str[]={0,0,0,0,0,0,0};
|
||||
loff_t pos = 0;
|
||||
u16 temp2 = 0;
|
||||
old_fs = get_fs();
|
||||
set_fs(KERNEL_DS);
|
||||
vfs_read(f, temp_str,6,&pos);
|
||||
temp2 = ((simple_strtoul(temp_str,NULL,10)/1000) <<8 ) & 0xFF00 ;
|
||||
psoc_ipmi_write((u8*)&temp2, SWITCH_TMP_OFFSET, 2);
|
||||
}
|
||||
filp_close(f,NULL);
|
||||
set_fs(old_fs);
|
||||
}
|
||||
|
||||
static int psoc_polling_thread(void *p)
|
||||
{
|
||||
while (!kthread_should_stop())
|
||||
{
|
||||
check_switch_temp();
|
||||
set_current_state(TASK_INTERRUPTIBLE);
|
||||
if(kthread_should_stop())
|
||||
break;
|
||||
|
||||
schedule_timeout(msecs_to_jiffies(PSOC_POLLING_PERIOD));
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int __init inv_psoc_init(void)
|
||||
{
|
||||
int ret;
|
||||
|
||||
hwmon_dev = hwmon_device_register(NULL);
|
||||
if (IS_ERR(hwmon_dev)) {
|
||||
goto fail_hwmon_device_register;
|
||||
}
|
||||
|
||||
device_kobj = kobject_create_and_add("device", &hwmon_dev->kobj);
|
||||
if(!device_kobj) {
|
||||
goto fail_hwmon_device_register;
|
||||
}
|
||||
|
||||
ret = sysfs_create_group(device_kobj, &psoc_group);
|
||||
if (ret) {
|
||||
goto fail_create_group_hwmon;
|
||||
}
|
||||
|
||||
ret = sysfs_create_group(&hwmon_dev->kobj, &psoc_group);
|
||||
if (ret) {
|
||||
goto fail_create_group_hwmon;
|
||||
}
|
||||
|
||||
kthread_auto_update = kthread_run(psoc_polling_thread,NULL,"BMC_DRIVER");
|
||||
if (IS_ERR(kthread_auto_update)) {
|
||||
goto fail_create_group_hwmon;
|
||||
}
|
||||
return ret;
|
||||
|
||||
fail_create_group_hwmon:
|
||||
hwmon_device_unregister(hwmon_dev);
|
||||
fail_hwmon_device_register:
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
static void __exit inv_psoc_exit(void)
|
||||
{
|
||||
kthread_stop(kthread_auto_update);
|
||||
if(ipmi_mh_user!=NULL) {ipmi_destroy_user(ipmi_mh_user);}
|
||||
if(hwmon_dev != NULL) hwmon_device_unregister(hwmon_dev);
|
||||
sysfs_remove_group(device_kobj, &psoc_group);
|
||||
}
|
||||
|
||||
MODULE_AUTHOR("Ting.Jack <ting.jack@inventec>");
|
||||
MODULE_DESCRIPTION("inv psoc driver");
|
||||
MODULE_LICENSE("GPL");
|
||||
|
||||
module_init(inv_psoc_init);
|
||||
module_exit(inv_psoc_exit);
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,187 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef IO_EXPANDER_H
|
||||
#define IO_EXPANDER_H
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
|
||||
/* IOEXP type define (SFP series) */
|
||||
#define IOEXP_TYPE_MAGINOLIA_NAB (10101)
|
||||
#define IOEXP_TYPE_MAGINOLIA_4AB (10102)
|
||||
#define IOEXP_TYPE_CYPRESS_NABC (10103)
|
||||
#define IOEXP_TYPE_MAPLE_NABC (10104)
|
||||
|
||||
/* IOEXP type define (QSFP series) */
|
||||
#define IOEXP_TYPE_MAGINOLIA_7AB (10201)
|
||||
#define IOEXP_TYPE_REDWOOD_P01P08 (10202)
|
||||
#define IOEXP_TYPE_REDWOOD_P09P16 (10203)
|
||||
#define IOEXP_TYPE_HUDSON32IGA_P01P08 (10204)
|
||||
#define IOEXP_TYPE_HUDSON32IGA_P09P16 (10205)
|
||||
#define IOEXP_TYPE_SPRUCE_7AB (10206)
|
||||
#define IOEXP_TYPE_CYPRESS_7ABC (10207)
|
||||
#define IOEXP_TYPE_TAHOE_5A (10208)
|
||||
#define IOEXP_TYPE_TAHOE_6ABC (10209)
|
||||
#define IOEXP_TYPE_SEQUOIA_NABC (10210)
|
||||
#define IOEXP_TYPE_LAVENDER_P65 (10211)
|
||||
#define IOEXP_TYPE_MAPLE_0ABC (10212)
|
||||
|
||||
/* CPLD type define */
|
||||
#define CPLD_TYPE_COTTONWOOD (10301)
|
||||
|
||||
/* IOEXP mode define */
|
||||
#define IOEXP_MODE_POLLING (19000)
|
||||
#define IOEXP_MODE_DIRECT (19001)
|
||||
|
||||
/* IOEXP state define */
|
||||
#define STATE_IOEXP_NORMAL (0)
|
||||
#define STATE_IOEXP_INIT (-1)
|
||||
#define STATE_IOEXP_ABNORMAL (-2)
|
||||
|
||||
/* IOEXP error code define */
|
||||
#define ERR_IOEXP_NOTSUPPORT (-100)
|
||||
#define ERR_IOEXP_UNINIT (-101)
|
||||
#define ERR_IOEXP_BADCONF (-102)
|
||||
#define ERR_IOEXP_ABNORMAL (-103)
|
||||
#define ERR_IOEXP_NOSTATE (-104)
|
||||
#define ERR_IOEXP_BADINPUT (-105)
|
||||
#define ERR_IOEXP_UNEXCPT (-199)
|
||||
|
||||
#define SWPS_INFO(fmt, args...) printk( KERN_INFO "[SWPS] " fmt, ##args)
|
||||
#define SWPS_WARN(fmt, args...) printk( KERN_WARNING "[SWPS] " fmt, ##args)
|
||||
#define SWPS_ERR(fmt, args...) printk( KERN_ERR "[SWPS] " fmt, ##args)
|
||||
|
||||
#ifdef DEBUG_SWPS
|
||||
# define SWPS_DEBUG(fmt, args...) printk( KERN_DEBUG "[SWPS] " fmt, ##args)
|
||||
#else
|
||||
# define SWPS_DEBUG(fmt, args...)
|
||||
#endif
|
||||
|
||||
|
||||
struct ioexp_addr_s {
|
||||
int chan_id;
|
||||
int chip_addr;
|
||||
int read_offset[8];
|
||||
int write_offset[8];
|
||||
int conf_offset[8];
|
||||
uint8_t data_default[8];
|
||||
uint8_t conf_default[8];
|
||||
};
|
||||
|
||||
struct ioexp_i2c_s {
|
||||
int chip_id;
|
||||
struct i2c_client *i2c_client_p;
|
||||
struct ioexp_i2c_s *next;
|
||||
};
|
||||
|
||||
|
||||
struct ioexp_bitmap_s {
|
||||
int chip_id; /* IOEXP chip id */
|
||||
int ioexp_voffset; /* IOEXP virtual offset */
|
||||
int bit_shift;
|
||||
};
|
||||
|
||||
struct ioexp_map_s {
|
||||
int chip_amount; /* Number of chips that IOEXP object content */
|
||||
int data_width; /* Number of (Read/Write/Config) bytes */
|
||||
struct ioexp_addr_s *map_addr; /* Chip address info */
|
||||
struct ioexp_bitmap_s map_present[10]; /* IOEXP for SFP / QSFP */
|
||||
struct ioexp_bitmap_s map_tx_disable[10]; /* IOEXP for SFP */
|
||||
struct ioexp_bitmap_s map_tx_fault[10]; /* IOEXP for SFP */
|
||||
struct ioexp_bitmap_s map_rxlos[10]; /* IOEXP for SFP */
|
||||
struct ioexp_bitmap_s map_reset[10]; /* IOEXP for QSFP */
|
||||
struct ioexp_bitmap_s map_lpmod[10]; /* IOEXP for QSFP */
|
||||
struct ioexp_bitmap_s map_modsel[10]; /* IOEXP for QSFP */
|
||||
struct ioexp_bitmap_s map_hard_rs0[10]; /* IOEXP for QSFP */
|
||||
struct ioexp_bitmap_s map_hard_rs1[10]; /* IOEXP for QSFP */
|
||||
};
|
||||
|
||||
struct ioexp_data_s {
|
||||
uint8_t data[8];
|
||||
};
|
||||
|
||||
struct ioexp_obj_s {
|
||||
|
||||
/* ============================
|
||||
* Object public property
|
||||
* ============================
|
||||
*/
|
||||
int ioexp_id;
|
||||
int ioexp_type;
|
||||
|
||||
/* ============================
|
||||
* Object private property
|
||||
* ============================
|
||||
*/
|
||||
struct ioexp_data_s chip_data[16]; /* Max: 8-ioexp in one virt-ioexp(ioexp_obj) */
|
||||
struct ioexp_map_s *ioexp_map_p;
|
||||
struct ioexp_obj_s *next;
|
||||
struct ioexp_i2c_s *i2c_head_p;
|
||||
struct mutex lock;
|
||||
int mode;
|
||||
int state;
|
||||
|
||||
/* ===========================================
|
||||
* Object public functions
|
||||
* ===========================================
|
||||
*/
|
||||
int (*get_present)(struct ioexp_obj_s *self, int virt_offset);
|
||||
int (*get_tx_fault)(struct ioexp_obj_s *self, int virt_offset);
|
||||
int (*get_rxlos)(struct ioexp_obj_s *self, int virt_offset);
|
||||
int (*get_tx_disable)(struct ioexp_obj_s *self, int virt_offset);
|
||||
int (*get_reset)(struct ioexp_obj_s *self, int virt_offset);
|
||||
int (*get_lpmod)(struct ioexp_obj_s *self, int virt_offset);
|
||||
int (*get_modsel)(struct ioexp_obj_s *self, int virt_offset);
|
||||
int (*get_hard_rs0)(struct ioexp_obj_s *self, int virt_offset);
|
||||
int (*get_hard_rs1)(struct ioexp_obj_s *self, int virt_offset);
|
||||
int (*set_tx_disable)(struct ioexp_obj_s *self, int virt_offset, int input_val);
|
||||
int (*set_reset)(struct ioexp_obj_s *self, int virt_offset, int input_val);
|
||||
int (*set_lpmod)(struct ioexp_obj_s *self, int virt_offset, int input_val);
|
||||
int (*set_modsel)(struct ioexp_obj_s *self, int virt_offset, int input_val);
|
||||
int (*set_hard_rs0)(struct ioexp_obj_s *self, int virt_offset, int input_val);
|
||||
int (*set_hard_rs1)(struct ioexp_obj_s *self, int virt_offset, int input_val);
|
||||
|
||||
/* ===========================================
|
||||
* Object private functions
|
||||
* ===========================================
|
||||
*/
|
||||
int (*init)(struct ioexp_obj_s *self);
|
||||
int (*check)(struct ioexp_obj_s *self);
|
||||
int (*update_all)(struct ioexp_obj_s *self, int show_err, char *caller_name);
|
||||
int (*fsm_4_direct)(struct ioexp_obj_s* self);
|
||||
int (*fsm_4_polling)(struct ioexp_obj_s* self);
|
||||
};
|
||||
|
||||
|
||||
struct ioexp_obj_s* get_ioexp_obj(int ioexp_id);
|
||||
int create_ioexp_obj(int ioexp_id,
|
||||
int ioexp_type,
|
||||
struct ioexp_addr_s *addr_map_p,
|
||||
int run_mode);
|
||||
int init_ioexp_objs(void);
|
||||
int check_ioexp_objs(void);
|
||||
void clean_ioexp_objs(void);
|
||||
|
||||
void unlock_ioexp_all(void);
|
||||
int lock_ioexp_all(void);
|
||||
|
||||
int check_channel_tier_1(void);
|
||||
int resync_channel_tier_1(void);
|
||||
|
||||
/* Macro for bit control */
|
||||
#define SWP_BIT_SET(byte_val,bit_shift) ((byte_val) |= (1<<(bit_shift)))
|
||||
#define SWP_BIT_CLEAR(byte_val,bit_shift) ((byte_val) &= ~(1<<(bit_shift)))
|
||||
|
||||
|
||||
#endif /* IO_EXPANDER_H */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -0,0 +1,815 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#ifndef TRANSCEIVER_H
|
||||
#define TRANSCEIVER_H
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
/* advanced features control */
|
||||
#define TRANSVR_INFO_DUMP_ENABLE (1)
|
||||
#define TRANSVR_INFO_CACHE_ENABLE (1)
|
||||
#define TRANSVR_UEVENT_ENABLE (1)
|
||||
|
||||
/* Transceiver type define */
|
||||
#define TRANSVR_TYPE_UNKNOW_1 (0x00)
|
||||
#define TRANSVR_TYPE_UNKNOW_2 (0xff)
|
||||
#define TRANSVR_TYPE_SFP (0x03) /* Define for SFP, SFP+, SFP28 */
|
||||
#define TRANSVR_TYPE_QSFP (0x0c)
|
||||
#define TRANSVR_TYPE_QSFP_PLUS (0x0d)
|
||||
#define TRANSVR_TYPE_QSFP_28 (0x11)
|
||||
#define TRANSVR_TYPE_UNPLUGGED (0xfa) /* Define for ERROR handle */
|
||||
#define TRANSVR_TYPE_FAKE (0xfc) /* Define for ERROR handle */
|
||||
#define TRANSVR_TYPE_INCONSISTENT (0xfd) /* Define for ERROR handle */
|
||||
#define TRANSVR_TYPE_ERROR (0xfe) /* Define for ERROR handle */
|
||||
|
||||
/* Transceiver class for base info */
|
||||
#define TRANSVR_CLASS_UNSPECIFIED (0)
|
||||
#define TRANSVR_CLASS_ERROR (-26001)
|
||||
#define TRANSVR_CLASS_1G (26001)
|
||||
#define TRANSVR_CLASS_10G (26011)
|
||||
#define TRANSVR_CLASS_25G (26021)
|
||||
#define TRANSVR_CLASS_40G (26041)
|
||||
#define TRANSVR_CLASS_100G (26101)
|
||||
#define TRANSVR_CLASS_NO_SPERARABLE (26901)
|
||||
#define TRANSVR_CLASS_EXTEND_COMP (26902)
|
||||
/* Transceiver class for Optical 1G */
|
||||
#define TRANSVR_CLASS_OPTICAL (27000)
|
||||
#define TRANSVR_CLASS_OPTICAL_100 (27001)
|
||||
#define TRANSVR_CLASS_OPTICAL_1G (27002)
|
||||
#define TRANSVR_CLASS_OPTICAL_1G_AOC (27003)
|
||||
#define TRANSVR_CLASS_OPTICAL_1G_SX (27004)
|
||||
#define TRANSVR_CLASS_OPTICAL_1G_LX (27005)
|
||||
#define TRANSVR_CLASS_OPTICAL_1G_EX (27006)
|
||||
/* Transceiver class for Optical 10G */
|
||||
#define TRANSVR_CLASS_OPTICAL_10G (27010)
|
||||
#define TRANSVR_CLASS_OPTICAL_10G_S_AOC (27011)
|
||||
#define TRANSVR_CLASS_OPTICAL_10G_S_SR (27012)
|
||||
#define TRANSVR_CLASS_OPTICAL_10G_S_LR (27013)
|
||||
#define TRANSVR_CLASS_OPTICAL_10G_S_ER (27014)
|
||||
#define TRANSVR_CLASS_OPTICAL_10G_Q_AOC (27015)
|
||||
#define TRANSVR_CLASS_OPTICAL_10G_Q_SR (27016)
|
||||
#define TRANSVR_CLASS_OPTICAL_10G_Q_LR (27017)
|
||||
#define TRANSVR_CLASS_OPTICAL_10G_Q_ER (27018)
|
||||
/* Transceiver class for Optical 25G */
|
||||
#define TRANSVR_CLASS_OPTICAL_25G (27020)
|
||||
#define TRANSVR_CLASS_OPTICAL_25G_AOC (27021)
|
||||
#define TRANSVR_CLASS_OPTICAL_25G_SR (27022)
|
||||
#define TRANSVR_CLASS_OPTICAL_25G_LR (27023)
|
||||
#define TRANSVR_CLASS_OPTICAL_25G_ER (27024)
|
||||
/* Transceiver class for Optical 40G */
|
||||
#define TRANSVR_CLASS_OPTICAL_40G (27040)
|
||||
#define TRANSVR_CLASS_OPTICAL_40G_AOC (27041)
|
||||
#define TRANSVR_CLASS_OPTICAL_40G_SR4 (27042)
|
||||
#define TRANSVR_CLASS_OPTICAL_40G_LR4 (27043)
|
||||
#define TRANSVR_CLASS_OPTICAL_40G_ER4 (27044)
|
||||
/* Transceiver class for Optical 100G */
|
||||
#define TRANSVR_CLASS_OPTICAL_100G (27100)
|
||||
#define TRANSVR_CLASS_OPTICAL_100G_AOC (27101)
|
||||
#define TRANSVR_CLASS_OPTICAL_100G_SR4 (27102)
|
||||
#define TRANSVR_CLASS_OPTICAL_100G_LR4 (27103)
|
||||
#define TRANSVR_CLASS_OPTICAL_100G_ER4 (27104)
|
||||
#define TRANSVR_CLASS_OPTICAL_100G_PSM4 (27105)
|
||||
/* Transceiver class for Copper */
|
||||
#define TRANSVR_CLASS_COPPER (28000)
|
||||
#define TRANSVR_CLASS_COPPER_L1_1G (28001)
|
||||
#define TRANSVR_CLASS_COPPER_L1_10G (28011)
|
||||
#define TRANSVR_CLASS_COPPER_L4_10G (28012)
|
||||
#define TRANSVR_CLASS_COPPER_L1_25G (28021)
|
||||
#define TRANSVR_CLASS_COPPER_L4_40G (28041)
|
||||
#define TRANSVR_CLASS_COPPER_L4_100G (28101)
|
||||
/* Transceiver class for Base-T */
|
||||
#define TRANSVR_CLASS_BASE_T_1000 (29001)
|
||||
#define TRANSVR_CLASS_BASE_T_1000_up (29002)
|
||||
/* For uevent message */
|
||||
#define TRANSVR_UEVENT_KEY_IF "IF_TYPE"
|
||||
#define TRANSVR_UEVENT_KEY_SP "IF_SPEED"
|
||||
#define TRANSVR_UEVENT_KEY_LANE "IF_LANE"
|
||||
#define TRANSVR_UEVENT_UNKNOW "UNKNOW"
|
||||
#define TRANSVR_IF_KR "KR"
|
||||
#define TRANSVR_IF_KR4 "KR4"
|
||||
#define TRANSVR_IF_SR "SR"
|
||||
#define TRANSVR_IF_SR4 "SR4"
|
||||
#define TRANSVR_IF_SFI "SFI"
|
||||
#define TRANSVR_IF_IF_GMII "GMII"
|
||||
#define TRANSVR_IF_IF_XGMII "XGMII"
|
||||
#define TRANSVR_IF_SP_100 "100"
|
||||
#define TRANSVR_IF_SP_1G "1000"
|
||||
#define TRANSVR_IF_SP_10G "10000"
|
||||
#define TRANSVR_IF_SP_25G "25000"
|
||||
#define TRANSVR_IF_SP_40G "40000"
|
||||
#define TRANSVR_IF_SP_100G "100000"
|
||||
|
||||
/* Transceiver mode define */
|
||||
#define TRANSVR_MODE_DIRECT (21000)
|
||||
#define TRANSVR_MODE_POLLING (21001)
|
||||
|
||||
/* Transceiver state define
|
||||
* [Note]
|
||||
* 1. State is used to represent the state of "Transceiver" and "Object".
|
||||
* 2. State for different target has different means. The description as following:
|
||||
*/
|
||||
#define STATE_TRANSVR_CONNECTED (0) /* [Transvr]:Be plugged in. [Obj]:Link up, and work normally. */
|
||||
#define STATE_TRANSVR_NEW (-100) /* [Transvr]:(Not used) [Obj]:Create */
|
||||
#define STATE_TRANSVR_INIT (-101) /* [Transvr]:Be plugged in. [Obj]:Link up, and in initial process. */
|
||||
#define STATE_TRANSVR_ISOLATED (-102) /* [Transvr]:Be plugged in. [Obj]:Isolate, and not provide service. */
|
||||
#define STATE_TRANSVR_SWAPPED (-200) /* [Transvr]:Be plugged in. [Obj]:(Not used) */
|
||||
#define STATE_TRANSVR_DISCONNECTED (-300) /* [Transvr]:Un-plugged. [Obj]:Link down, and not provide service. */
|
||||
#define STATE_TRANSVR_UNEXCEPTED (-901) /* [Transvr]:Any [Obj]:Any, and not in expect case. */
|
||||
|
||||
/* Task state define */
|
||||
#define STATE_T_TASK_WAIT (110)
|
||||
#define STATE_T_TASK_DONE (0)
|
||||
#define STATE_T_TASK_INIT (-110)
|
||||
#define STATE_T_TASK_FAIL (-410)
|
||||
|
||||
|
||||
/* Event for task handling */
|
||||
#define EVENT_TRANSVR_TASK_WAIT (2101)
|
||||
#define EVENT_TRANSVR_TASK_DONE (0)
|
||||
#define EVENT_TRANSVR_TASK_FAIL (-2101)
|
||||
/* Event for initial handling */
|
||||
#define EVENT_TRANSVR_INIT_UP (2201)
|
||||
#define EVENT_TRANSVR_INIT_DOWN (1)
|
||||
#define EVENT_TRANSVR_INIT_REINIT (-2201)
|
||||
#define EVENT_TRANSVR_INIT_FAIL (-2202)
|
||||
/* Event for others */
|
||||
#define EVENT_TRANSVR_RELOAD_FAIL (-2301)
|
||||
#define EVENT_TRANSVR_EXCEP_INIT (-2401)
|
||||
#define EVENT_TRANSVR_EXCEP_UP (-2402)
|
||||
#define EVENT_TRANSVR_EXCEP_DOWN (-2403)
|
||||
#define EVENT_TRANSVR_EXCEP_SWAP (-2404)
|
||||
#define EVENT_TRANSVR_EXCEP_EXCEP (-2405)
|
||||
#define EVENT_TRANSVR_EXCEP_ISOLATED (-2406)
|
||||
#define EVENT_TRANSVR_I2C_CRASH (-2501)
|
||||
|
||||
/* Transceiver error code define */
|
||||
#define ERR_TRANSVR_UNINIT (-201)
|
||||
#define ERR_TRANSVR_UNPLUGGED (-202)
|
||||
#define ERR_TRANSVR_ABNORMAL (-203)
|
||||
#define ERR_TRANSVR_NOSTATE (-204)
|
||||
#define ERR_TRANSVR_NOTSUPPORT (-205)
|
||||
#define ERR_TRANSVR_BADINPUT (-206)
|
||||
#define ERR_TRANSVR_UPDATE_FAIL (-207)
|
||||
#define ERR_TRANSVR_RELOAD_FAIL (-208)
|
||||
#define ERR_TRANSVR_INIT_FAIL (-209)
|
||||
#define ERR_TRANSVR_UNDEFINED (-210)
|
||||
#define ERR_TRANSVR_TASK_FAIL (-211)
|
||||
#define ERR_TRANSVR_TASK_BUSY (-212)
|
||||
#define ERR_TRANSVR_UEVENT_FAIL (-213)
|
||||
#define ERR_TRANSVR_FUNC_DISABLE (-214)
|
||||
#define ERR_TRANSVR_I2C_CRASH (-297)
|
||||
#define ERR_TRNASVR_BE_ISOLATED (-298)
|
||||
#define ERR_TRANSVR_UNEXCPT (-299)
|
||||
|
||||
/* For debug */
|
||||
#define DEBUG_TRANSVR_INT_VAL (-99)
|
||||
#define DEBUG_TRANSVR_HEX_VAL (0xfe)
|
||||
#define DEBUG_TRANSVR_STR_VAL "ERROR"
|
||||
|
||||
/* For system internal */
|
||||
#define VAL_TRANSVR_COMID_ARREESS (0x50)
|
||||
#define VAL_TRANSVR_COMID_OFFSET (0x00)
|
||||
#define VAL_TRANSVR_EXTPHY_ADDR_56 (0x56)
|
||||
#define VAL_TRANSVR_8472_READY_ADDR (0x51)
|
||||
#define VAL_TRANSVR_8472_READY_PAGE (-1)
|
||||
#define VAL_TRANSVR_8472_READY_OFFSET (110)
|
||||
#define VAL_TRANSVR_8472_READY_BIT (0)
|
||||
#define VAL_TRANSVR_8472_READY_VALUE (0)
|
||||
#define VAL_TRANSVR_8472_READY_ABNORMAL (0xff)
|
||||
#define VAL_TRANSVR_8436_READY_ADDR (0x50)
|
||||
#define VAL_TRANSVR_8436_READY_PAGE (-1)
|
||||
#define VAL_TRANSVR_8436_READY_OFFSET (2)
|
||||
#define VAL_TRANSVR_8436_READY_BIT (0)
|
||||
#define VAL_TRANSVR_8436_READY_VALUE (0)
|
||||
#define VAL_TRANSVR_8436_READY_ABNORMAL (0xff)
|
||||
#define VAL_TRANSVR_8436_PWD_ADDR (0x50)
|
||||
#define VAL_TRANSVR_8436_PWD_PAGE (-1)
|
||||
#define VAL_TRANSVR_8436_PWD_OFFSET (123)
|
||||
#define VAL_TRANSVR_PAGE_FREE (-99)
|
||||
#define VAL_TRANSVR_PAGE_SELECT_OFFSET (127)
|
||||
#define VAL_TRANSVR_PAGE_SELECT_DELAY (5)
|
||||
#define VAL_TRANSVR_TASK_RETRY_FOREVER (-999)
|
||||
#define VAL_TRANSVR_FUNCTION_DISABLE (-1)
|
||||
#define STR_TRANSVR_SFP "SFP"
|
||||
#define STR_TRANSVR_QSFP "QSFP"
|
||||
#define STR_TRANSVR_QSFP_PLUS "QSFP+"
|
||||
#define STR_TRANSVR_QSFP28 "QSFP28"
|
||||
|
||||
/* For transvr buf len */
|
||||
#define LEN_TRANSVR_S_STR (16)
|
||||
#define LEN_TRANSVR_M_STR (32)
|
||||
#define LEN_TRANSVR_L_STR (64)
|
||||
|
||||
/* Optical wavelength */
|
||||
#define VAL_OPTICAL_WAVELENGTH_SR (850)
|
||||
#define VAL_OPTICAL_WAVELENGTH_LR (1310)
|
||||
#define VAL_OPTICAL_WAVELENGTH_ER (1550)
|
||||
|
||||
/* BCM chip type define */
|
||||
#define BCM_CHIP_TYPE_TRIDENT_2 (31001) /* Magnolia, Hudson32i, Spruce */
|
||||
#define BCM_CHIP_TYPE_TOMAHAWK (31002) /* Redwood, Cypress, Sequoia */
|
||||
#define BCM_CHIP_TYPE_TRIDENT_3 (31003) /* Maple */
|
||||
|
||||
#define BF_CHIP_TYPE_TOFINO (31011) /* Lavender */
|
||||
|
||||
/* Info from transceiver EEPROM */
|
||||
struct eeprom_map_s {
|
||||
int addr_br; int page_br; int offset_br; int length_br;
|
||||
int addr_cdr; int page_cdr; int offset_cdr; int length_cdr;
|
||||
int addr_comp_rev; int page_comp_rev; int offset_comp_rev; int length_comp_rev;
|
||||
int addr_connector; int page_connector; int offset_connector; int length_connector;
|
||||
int addr_diag_type; int page_diag_type; int offset_diag_type; int length_diag_type;
|
||||
int addr_extbr; int page_extbr; int offset_extbr; int length_extbr;
|
||||
int addr_ext_id; int page_ext_id; int offset_ext_id; int length_ext_id;
|
||||
int addr_id; int page_id; int offset_id; int length_id;
|
||||
int addr_len_sm; int page_len_sm; int offset_len_sm; int length_len_sm;
|
||||
int addr_len_smf; int page_len_smf; int offset_len_smf; int length_len_smf;
|
||||
int addr_len_om1; int page_len_om1; int offset_len_om1; int length_len_om1;
|
||||
int addr_len_om2; int page_len_om2; int offset_len_om2; int length_len_om2;
|
||||
int addr_len_om3; int page_len_om3; int offset_len_om3; int length_len_om3;
|
||||
int addr_len_om4; int page_len_om4; int offset_len_om4; int length_len_om4;
|
||||
int addr_option; int page_option; int offset_option; int length_option;
|
||||
int addr_rate_id; int page_rate_id; int offset_rate_id; int length_rate_id;
|
||||
int addr_rx_am; int page_rx_am; int offset_rx_am; int length_rx_am;
|
||||
int addr_rx_em; int page_rx_em; int offset_rx_em; int length_rx_em;
|
||||
int addr_rx_los; int page_rx_los; int offset_rx_los; int length_rx_los;
|
||||
int addr_rx_power; int page_rx_power; int offset_rx_power; int length_rx_power;
|
||||
int addr_soft_rs0; int page_soft_rs0; int offset_soft_rs0; int length_soft_rs0;
|
||||
int addr_soft_rs1; int page_soft_rs1; int offset_soft_rs1; int length_soft_rs1;
|
||||
int addr_temp; int page_temp; int offset_temp; int length_temp;
|
||||
int addr_trancomp; int page_trancomp; int offset_trancomp; int length_trancomp;
|
||||
int addr_trancomp_ext; int page_trancomp_ext; int offset_trancomp_ext; int length_trancomp_ext;
|
||||
int addr_tx_bias; int page_tx_bias; int offset_tx_bias; int length_tx_bias;
|
||||
int addr_tx_disable; int page_tx_disable; int offset_tx_disable; int length_tx_disable;
|
||||
int addr_tx_eq; int page_tx_eq; int offset_tx_eq; int length_tx_eq;
|
||||
int addr_tx_fault; int page_tx_fault; int offset_tx_fault; int length_tx_fault;
|
||||
int addr_tx_power; int page_tx_power; int offset_tx_power; int length_tx_power;
|
||||
int addr_vendor_name; int page_vendor_name; int offset_vendor_name; int length_vendor_name;
|
||||
int addr_vendor_pn; int page_vendor_pn; int offset_vendor_pn; int length_vendor_pn;
|
||||
int addr_vendor_rev; int page_vendor_rev; int offset_vendor_rev; int length_vendor_rev;
|
||||
int addr_vendor_sn; int page_vendor_sn; int offset_vendor_sn; int length_vendor_sn;
|
||||
int addr_voltage; int page_voltage; int offset_voltage; int length_voltage;
|
||||
int addr_wavelength; int page_wavelength; int offset_wavelength; int length_wavelength;
|
||||
};
|
||||
|
||||
|
||||
struct transvr_worker_s;
|
||||
|
||||
/* Class of transceiver object */
|
||||
struct transvr_obj_s {
|
||||
|
||||
/* ========== Object private property ==========
|
||||
* [Prop]: id
|
||||
* [Desc]: Type of serial transceiver.
|
||||
* [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh /QSFP28:11h
|
||||
*/
|
||||
uint8_t id;
|
||||
|
||||
/* [Prop]: connector
|
||||
* [Desc]: Connector type.
|
||||
* [Note]: SFP : A0h / 2
|
||||
* QSFP: 00h / 130
|
||||
*/
|
||||
uint8_t connector;
|
||||
|
||||
/* [Prop]: transvr_comp
|
||||
* [Desc]: Transceiver compliance code.
|
||||
* [Note]: SFP: SFF-8472
|
||||
* - Normal : A0h / offset 3-10
|
||||
* - Extended: A0h / offset 36
|
||||
* QSFP: SFF-8436 & SFF-8636
|
||||
* - Normal : 00h / offset 131-138
|
||||
* - Extended: 00h / offset 192
|
||||
*/
|
||||
uint8_t transvr_comp[8];
|
||||
uint8_t transvr_comp_ext;
|
||||
|
||||
/* [Prop]: vendor_name
|
||||
* [Desc]: SFP vendor name (ASCII 16 byte char).
|
||||
* [Note]: ex:FINISAR CORP.
|
||||
*/
|
||||
char *vendor_name;
|
||||
|
||||
/* [Prop]: vendor_pn
|
||||
* [Desc]: Part number provided by SFP vendor (ASCII 16 byte char).
|
||||
* [Note]:
|
||||
*/
|
||||
char *vendor_pn;
|
||||
|
||||
/* [Prop]: vendor_rev
|
||||
* [Desc]: Revision level for part number provided by vendor (ASCII 4 byte char).
|
||||
* [Note]:
|
||||
*/
|
||||
char *vendor_rev;
|
||||
|
||||
/* [Prop]: vendor_sn
|
||||
* [Desc]: Serial number provided by vendor (ASCII 16 byte char).
|
||||
* [Note]:
|
||||
*/
|
||||
char *vendor_sn;
|
||||
|
||||
/* [Prop]: Extended identifier
|
||||
* [Desc]: SFP:
|
||||
* => None
|
||||
*
|
||||
* QSFP:
|
||||
* => This byte contained two information:
|
||||
* (1) Power consumption class
|
||||
* (2) CDR function present
|
||||
* [Note]: Bit description as below:
|
||||
* [SFP]
|
||||
* None
|
||||
*
|
||||
* [QSFP]
|
||||
* (1) Power consumption class:
|
||||
* Class 1: 1.5W (Bit6-7 = 00:)
|
||||
* Class 2: 2.0W (Bit6-7 = 01:)
|
||||
* Class 3: 2.5W (Bit6-7 = 10:)
|
||||
* Class 4: 3.5W (Bit6-7 = 11:)
|
||||
* Class 5: 4.0W (Bit0-1 = 01:)
|
||||
* Class 6: 4.5W (Bit0-1 = 10:)
|
||||
* Class 7: 5.0W (Bit0-1 = 11:)
|
||||
* (2) CDR function present:
|
||||
* Bit2: 0 = No CDR in RX
|
||||
* 1 = CDR present in RX
|
||||
* Bit3: 0 = No CDR in TX
|
||||
* 1 = CDR present in TX
|
||||
*/
|
||||
uint8_t ext_id;
|
||||
|
||||
/* [Prop]: br
|
||||
* [Desc]: Nominal bit rate, units of 100 MBits/sec.
|
||||
* [Note]: SFP:03h / QSFP:0Ch / QSPF+:0Dh
|
||||
* has val: 0x67
|
||||
* no val :
|
||||
*/
|
||||
uint8_t br;
|
||||
|
||||
/* [Prop]: extbr
|
||||
* [Desc]: Extended br (00h/222)
|
||||
* [Desc]: Nominal bit rate per channel, units of 250 Mbps.
|
||||
* Complements. Byte 140. See Table 32A.
|
||||
*/
|
||||
uint8_t extbr;
|
||||
|
||||
/* [Prop]: len_sm
|
||||
* [Desc]: Length (single mode)-(100's)m
|
||||
* [Note]: This value specifies the link length that is supported by the transceiver
|
||||
* while operating in compliance with the applicable standards using single mode
|
||||
* fiber. The value is in units of 100 meters. A value of 255 means that the
|
||||
* transceiver supports a link length greater than 25.4 km. A value of zero means
|
||||
* that the transceiver does not support single mode fiber or that the length
|
||||
* information must be determined from the transceiver technology.
|
||||
*/
|
||||
int len_sm;
|
||||
|
||||
/* [Prop]: len_smf
|
||||
* [Desc]: Length (single mode)-km
|
||||
* [Note]: Addition to EEPROM data from original GBIC definition. This value specifies
|
||||
* the link length that is supported by the transceiver while operating in
|
||||
* compliance with the applicable standards using single mode fiber. The value
|
||||
* is in units of kilometers. A value of 255 means that the transceiver supports
|
||||
* a link length greater than 254 km. A value of zero means that the transceiver
|
||||
* does not support single mode fiber or that the length information must be
|
||||
* determined from the transceiver technology.
|
||||
*/
|
||||
int len_smf;
|
||||
|
||||
/* [Prop]: len_om1
|
||||
* [Desc]: Link length supported for 62.5 um OM1 fiber, units of 10 m
|
||||
* [Note]: The value is in units of 10 meters. A value of 255 means that the
|
||||
* transceiver supports a link length greater than 2.54 km. A value of
|
||||
* zero means that the transceiver does not support 50 micron multi-mode
|
||||
* fiber or that the length information must be determined from the transceiver
|
||||
* technology.
|
||||
*/
|
||||
int len_om1;
|
||||
|
||||
/* [Prop]: len_om2
|
||||
* [Desc]: Link length supported for 50 um OM2 fiber, units of 10 m
|
||||
* [Note]: The value is in units of 10 meters. A value of 255 means that the
|
||||
* transceiver supports a link length greater than 2.54 km. A value of
|
||||
* zero means that the transceiver does not support 50 micron multi-mode
|
||||
* fiber or that the length information must be determined from the transceiver
|
||||
* technology.
|
||||
*/
|
||||
int len_om2;
|
||||
|
||||
/* [Prop]: len_om3
|
||||
* [Desc]: Length (50um, OM3)
|
||||
* [Note]: This value specifies link length that is supported by the transceiver while
|
||||
* operating in compliance with applicable standards using 50 micron multimode
|
||||
* OM3 [2000 MHz*km] fiber. The value is in units of 10 meters. A value of 255
|
||||
* means that the transceiver supports a link length greater than 2.54 km. A value
|
||||
* of zero means that the transceiver does not support 50 micron multimode fiber
|
||||
* or that the length information must be determined from the transceiver technology.
|
||||
*/
|
||||
int len_om3;
|
||||
|
||||
/* [Prop]: len_om4
|
||||
* [Desc]: Length (50um, OM4) and Length (Active Cable or Copper)
|
||||
* [Note]: For optical links, this value specifies link length that is supported by the
|
||||
* transceiver while operating in compliance with applicable standards using 50 micron
|
||||
* multimode OM4 [4700 MHz*km] fiber. The value is in units of 10 meters. A value of
|
||||
* 255 means that the transceiver supports a link length greater than 2.54 km. A value
|
||||
* of zero means that the transceiver does not support 50 micron multimode fiber or that
|
||||
* the length information must be determined from the transceiver codes specified in Table 5-3.
|
||||
*
|
||||
* For copper links, this value specifies minimum link length supported by the transceiver
|
||||
* while operating in compliance with applicable standards using copper cable. For active
|
||||
* cable, this value represents actual length. The value is in units of 1 meter. A value of 255
|
||||
* means the transceiver supports a link length greater than 254 meters. A value of zero means
|
||||
* the transceiver does not support copper or active cables or the length information must be
|
||||
* determined from transceiver technology. Further information about cable design, equalization,
|
||||
* and connectors is usually required to guarantee meeting a particular length requirement.
|
||||
*/
|
||||
int len_om4;
|
||||
|
||||
/* [Prop]: comp_rev
|
||||
* [Desc]: SFF spec revision compliance
|
||||
* [Note]: Indicates which revision of SFF SFF-8472 (SFP) / SFF-8636 (QSFP) the transceiver
|
||||
* complies with. (unsigned integer)
|
||||
*/
|
||||
uint8_t comp_rev;
|
||||
|
||||
/* [Prop]: CDR
|
||||
* [Desc]: For transceivers with CDR capability, setting the CDR to ON engages the internal
|
||||
* retiming function. Setting the CDR to OFF enables an internal bypassing mode ,which
|
||||
* directs traffic around the internal CDR. (Reference: SFF-8636)
|
||||
* [Note]: value=0xff: ON.
|
||||
* value=0x00: OFF.
|
||||
*/
|
||||
uint8_t cdr;
|
||||
|
||||
/* [Prop]: rate_id
|
||||
* [Desc]: Soft Rate Select 0(RX).
|
||||
* [Note]: 1. Addr: A0h / Offset: 13
|
||||
* 2. Value description:
|
||||
* 00h Unspecified
|
||||
* 01h SFF-8079 (4/2/1G Rate_Select & AS0/AS1)
|
||||
* 02h SFF-8431 (8/4/2G Rx Rate_Select only)
|
||||
* 03h Unspecified *
|
||||
* 04h SFF-8431 (8/4/2G Tx Rate_Select only)
|
||||
* 05h Unspecified *
|
||||
* 06h SFF-8431 (8/4/2G Independent Rx & Tx Rate_select)
|
||||
* 07h Unspecified *
|
||||
* 08h FC-PI-5 (16/8/4G Rx Rate_select only) High=16G only, Low=8G/4G
|
||||
* 09h Unspecified *
|
||||
* 0Ah FC-PI-5 (16/8/4G Independent Rx, Tx Rate_select) High=16G only,
|
||||
* Low=8G/4G
|
||||
* 0Bh Unspecified *
|
||||
* 0Ch FC-PI-6 (32/16/8G Independent Rx, Tx Rate_Select)
|
||||
* High=32G only, Low = 16G/8G
|
||||
* 0Dh Unspecified *
|
||||
* 0Eh 10/8G Rx and Tx Rate_Select controlling the operation or locking
|
||||
* modes of the internal signal conditioner, retimer or CDR, according
|
||||
* to the logic table defined in Table 10-2, High Bit Rate
|
||||
* (10G) =9.95-11.3 Gb/s; Low Bit Rate (8G) = 8.5 Gb/s. In this mode,
|
||||
* the default value of bit 110.3 (Soft Rate Select RS(0), Table 9-11)
|
||||
* and of bit 118.3 (Soft Rate Select RS(1), Table 10-1) is 1.
|
||||
* 0Fh Unspecified *
|
||||
* 10h-FFh Unallocated
|
||||
*/
|
||||
int rate_id;
|
||||
|
||||
/* [Prop]: soft_rs0
|
||||
* [Desc]: Soft Rate Select 0(RX).
|
||||
* [Note]: 1. Writing '1' selects full bandwidth operation.
|
||||
* 2. This bit is "OR'd with the hard Rate_Select, AS(0) or RS(0) pin value.
|
||||
* 3. Default at power up is logic zero/low
|
||||
* 4. Addr: A2h / Offset: 110 / Bit: 3
|
||||
*/
|
||||
uint8_t soft_rs0;
|
||||
|
||||
/* [Prop]: soft_rs1
|
||||
* [Desc]: Soft Rate Select 1(TX).
|
||||
* [Note]: 1. Writing '1' selects full bandwidth TX operation.
|
||||
* 2. This bit is "OR'd with the hard Rate_Select, AS(1) or RS(1) pin value.
|
||||
* 3. Default at power up is logic zero/low
|
||||
* 4. Addr: A2h / Offset: 118 / Bit: 3
|
||||
*/
|
||||
uint8_t soft_rs1;
|
||||
|
||||
/* [Prop]: diag_type
|
||||
* [Desc]: DIAGNOSTIC MONITORING TYPE (A0h/92)
|
||||
* [Note]: Description in SFF-8472 as below:
|
||||
* Bit7: Reserved for legacy diagnostic implementations. Must be '0' for compliance
|
||||
* with this document.
|
||||
* Bit6: Digital diagnostic monitoring implemented (described in this document).
|
||||
* Must be '1' for compliance with this document.
|
||||
* Bit5 Internally calibrated
|
||||
* Bit4 Externally calibrated
|
||||
* Bit3 Received power measurement type.0 = OMA, 1 = average power
|
||||
* Bit2 Address change required see section above, "addressing modes"
|
||||
* Bit1-0 Unallocated
|
||||
*/
|
||||
uint8_t diag_type;
|
||||
|
||||
/* [Prop]: curr_temp
|
||||
* [Desc]: Transceiver Current Temperature (A2h/96-97)
|
||||
* [Note]: 1. Dependent on diag_type.
|
||||
* 2. 96: High byte
|
||||
* 3. 97: Low byte
|
||||
* 4. This feature only for SFP
|
||||
*/
|
||||
uint8_t curr_temp[2];
|
||||
|
||||
/* [Prop]: curr_vol
|
||||
* [Desc]: Transceiver Current Voltage (SFP:A2h/108-109; QSFP:00h/22-23)
|
||||
* [Note]: 1. Dependent on diag_type.
|
||||
* 2. 98: High byte
|
||||
* 3. 99: Low byte
|
||||
* 4. This feature only for SFP
|
||||
* 5. Internally measured transceiver supply voltage. Represented
|
||||
* as a 16 bit unsigned integer with the voltage defined as the
|
||||
* full 16 bit value (0-65535) with LSB equal to 100 uVolt,
|
||||
* yielding a total range of 0 to +6.55 Volts
|
||||
*/
|
||||
uint8_t curr_voltage[2];
|
||||
|
||||
/* [Prop]: curr_tx_bias
|
||||
* [Desc]: Transceiver TX Bias Current (SFP:A2h/100-101; QSFP:00h/26-27)
|
||||
* [Note]: 1. Dependent on diag_type.
|
||||
* 2. 100: High byte
|
||||
* 3. 101: Low byte
|
||||
* 4. This feature only for SFP
|
||||
* 5. Measured TX bias current in uA. Represented as a 16 bit unsigned
|
||||
* integer with the current defined as the full 16 bit value (0-65535)
|
||||
* with LSB equal to 2 uA, yielding a total range of 0 to 131 mA.
|
||||
* Accuracy is vendor specific but must be better than 10% of the
|
||||
* manufacturer's nominal value over specified operating temperature
|
||||
* and voltage.
|
||||
*/
|
||||
uint8_t curr_tx_bias[8];
|
||||
|
||||
/* [Prop]: curr_tx_power
|
||||
* [Desc]: Transceiver TX Output Power (A2h/102-103)
|
||||
* [Note]: 1. Dependent on diag_type.
|
||||
* 2. 102: High byte
|
||||
* 3. 103: Low byte
|
||||
* 4. This feature only for SFP
|
||||
* 5. Measured TX output power in mW. Represented as a 16 bit unsigned
|
||||
* integer with the power defined as the full 16 bit value (0-65535)
|
||||
* with LSB equal to 0.1 uW, yielding a total range of 0 to 6.5535 mW
|
||||
* (~ -40 to +8.2 dBm). Data is assumed to be based on measurement of
|
||||
* laser monitor photodiode current. It is factory calibrated to absolute
|
||||
* units using the most representative fiber output type. Accuracy is
|
||||
* vendor specific but must be better than 3dB over specified temperature
|
||||
* and voltage. Data is not valid when the transmitter is disabled.
|
||||
*/
|
||||
uint8_t curr_tx_power[8];
|
||||
|
||||
/* [Prop]: curr_tx_power
|
||||
* [Desc]: Transceiver TX Output Power (A2h/102-103)
|
||||
* [Note]: 1. Dependent on diag_type.
|
||||
* 2. 102: High byte
|
||||
* 3. 103: Low byte
|
||||
* 4. This feature only for SFP
|
||||
* 5. Measured RX received optical power in mW. Value can represent either
|
||||
* average received power or OMA depending upon how bit 3 of byte 92 (A0h)
|
||||
* is set. Represented as a 16 bit unsigned integer with the power defined
|
||||
* as the full 16 bit value (0-65535) with LSB equal to 0.1 uW, yielding a
|
||||
* total range of 0 to 6.5535 mW (~ -40 to +8.2 dBm). Absolute accuracy is
|
||||
* dependent upon the exact optical wavelength. For the vendor specified
|
||||
* wavelength, accuracy shall be better than 3dB over specified temperature
|
||||
* and voltage.
|
||||
*/
|
||||
uint8_t curr_rx_power[8];
|
||||
|
||||
/* [Prop]: wavelength
|
||||
* [Desc]: Wavelength or Copper Cable Attenuation
|
||||
* [Note]: (Following is info from SFF-8636)
|
||||
* For optical free side devices, this parameter identifies the nominal
|
||||
* transmitter output wavelength at room temperature. This parameter is a
|
||||
* 16-bit hex value with Byte 186 as high order byte and Byte 187 as low
|
||||
* order byte. The laser wavelength is equal to the 16-bit integer value
|
||||
* divided by 20 in nm (units of 0.05 nm). This resolution should be adequate
|
||||
* to cover all relevant wavelengths yet provide enough resolution for all
|
||||
* expected DWDM applications. For accurate representation of controlled
|
||||
* wavelength applications, this value should represent the center of the
|
||||
* guaranteed wavelength range. If the free side device is identified as
|
||||
* copper cable these registers will be used to define the cable attenuation.
|
||||
* An indication of 0 dB attenuation refers to the case where the attenuation
|
||||
* is not known or is unavailable.
|
||||
* Byte 186 (00-FFh) is the copper cable attenuation at 2.5 GHz in units of 1 dB.
|
||||
* Byte 187 (00-FFh) is the copper cable attenuation at 5.0 GHz in units of 1 dB.
|
||||
*/
|
||||
uint8_t wavelength[2];
|
||||
|
||||
/* [Prop]: Amplitude control
|
||||
* [Desc]: Amplitude control
|
||||
* [Note]: QSFP28 => SFF-8636 03H Byte-238/239
|
||||
*/
|
||||
uint8_t rx_am[2];
|
||||
|
||||
/* [Prop]: Emphasis control
|
||||
* [Desc]: Emphasis control
|
||||
* [Note]: SFP+/28 => SFF-8472 A2H Byte-115
|
||||
* QSFP28 => SFF-8636 03H Byte-236/237
|
||||
*/
|
||||
uint8_t rx_em[2];
|
||||
|
||||
/* [Prop]: Soft Rx LOS
|
||||
* [Desc]: Soft Rx LOS which provide by transceiver
|
||||
* [Note]: (Following is info from SFF-8636)
|
||||
* Byte 3:
|
||||
* - Bit 0: L-Rx1 LOS
|
||||
* - Bit 1: L-Rx2 LOS
|
||||
* - Bit 2: L-Rx3 LOS
|
||||
* - Bit 3: L-Rx4 LOS
|
||||
*/
|
||||
uint8_t rx_los;
|
||||
|
||||
/* [Prop]: Soft Tx Disable
|
||||
* [Desc]: Soft Tx Disable which provide by transceiver
|
||||
* [Note]: (Following is info from SFF-8636)
|
||||
* Byte 86:
|
||||
* - Bit 0: Tx1 Disable
|
||||
* - Bit 1: Tx2 Disable
|
||||
* - Bit 2: Tx3 Disable
|
||||
* - Bit 3: Tx4 Disable
|
||||
*/
|
||||
uint8_t tx_disable;
|
||||
|
||||
/* [Prop]: Soft Tx Fault
|
||||
* [Desc]: Soft Tx Fault which provide by transceiver
|
||||
* [Note]: (Following is info from SFF-8636)
|
||||
* Byte 86:
|
||||
* - Bit 0: Tx1 Fault
|
||||
* - Bit 1: Tx2 Fault
|
||||
* - Bit 2: Tx3 Fault
|
||||
* - Bit 3: Tx4 Fault
|
||||
*/
|
||||
uint8_t tx_fault;
|
||||
|
||||
/* [Prop]: Transceiver EQUALIZATION
|
||||
* [Desc]: Transceiver EQUALIZATION
|
||||
* [Note]: SFP+/28 => SFF-8472 A2H Byte-114
|
||||
* QSFP28 => SFF-8636 03H Byte-234/235
|
||||
*/
|
||||
uint8_t tx_eq[2];
|
||||
|
||||
/* [Prop]: OPTION VALUES
|
||||
* [Desc]: The bits in the option field shall specify the options implemented in the transceiver.
|
||||
* [Note]: SFP+/28 => SFF-8472 A0H Byte-64/65
|
||||
* QSFP+/28 => SFF-8636 00H Byte-193/195
|
||||
*/
|
||||
uint8_t option[3];
|
||||
|
||||
/* [Prop]: External PHY offset
|
||||
* [Desc]: It needs to be setup first if you want to access transceiver external phy.
|
||||
* [Note]: This feature dependent on transceiver.
|
||||
* Currently, only 1G-RJ45 transceiver supported it.
|
||||
*/
|
||||
uint8_t extphy_offset;
|
||||
|
||||
/* ========== Object private property ==========
|
||||
*/
|
||||
struct device *transvr_dev_p;
|
||||
struct eeprom_map_s *eeprom_map_p;
|
||||
struct i2c_client *i2c_client_p;
|
||||
struct ioexp_obj_s *ioexp_obj_p;
|
||||
struct transvr_worker_s *worker_p;
|
||||
struct mutex lock;
|
||||
char swp_name[32];
|
||||
int auto_config;
|
||||
int auto_tx_disable;
|
||||
int chan_id;
|
||||
int chipset_type;
|
||||
int curr_page;
|
||||
int info;
|
||||
int ioexp_virt_offset;
|
||||
int lane_id[8];
|
||||
int layout;
|
||||
int mode;
|
||||
int retry;
|
||||
int state;
|
||||
int temp;
|
||||
int type;
|
||||
|
||||
/* ========== Object public functions ==========
|
||||
*/
|
||||
int (*get_id)(struct transvr_obj_s *self);
|
||||
int (*get_ext_id)(struct transvr_obj_s *self);
|
||||
int (*get_connector)(struct transvr_obj_s *self);
|
||||
int (*get_vendor_name)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_vendor_pn)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_vendor_rev)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_vendor_sn)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_power_cls)(struct transvr_obj_s *self);
|
||||
int (*get_br)(struct transvr_obj_s *self);
|
||||
int (*get_len_sm)(struct transvr_obj_s *self);
|
||||
int (*get_len_smf)(struct transvr_obj_s *self);
|
||||
int (*get_len_om1)(struct transvr_obj_s *self);
|
||||
int (*get_len_om2)(struct transvr_obj_s *self);
|
||||
int (*get_len_om3)(struct transvr_obj_s *self);
|
||||
int (*get_len_om4)(struct transvr_obj_s *self);
|
||||
int (*get_comp_rev)(struct transvr_obj_s *self);
|
||||
int (*get_comp_eth_1)(struct transvr_obj_s *self);
|
||||
int (*get_comp_eth_10)(struct transvr_obj_s *self);
|
||||
int (*get_comp_eth_10_40)(struct transvr_obj_s *self);
|
||||
int (*get_comp_extend)(struct transvr_obj_s *self);
|
||||
int (*get_cdr)(struct transvr_obj_s *self);
|
||||
int (*get_rate_id)(struct transvr_obj_s *self);
|
||||
int (*get_soft_rs0)(struct transvr_obj_s *self);
|
||||
int (*get_soft_rs1)(struct transvr_obj_s *self);
|
||||
int (*get_info)(struct transvr_obj_s *self);
|
||||
int (*get_if_type)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_if_speed)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_if_lane)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_curr_temp)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_curr_vol)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_soft_rx_los)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_soft_tx_disable)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_soft_tx_fault)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_auto_tx_disable)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_tx_bias)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_tx_power)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_rx_power)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_tx_eq)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_rx_am)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_rx_em)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_wavelength)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_extphy_offset)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*get_extphy_reg)(struct transvr_obj_s *self, char *buf_p);
|
||||
int (*set_cdr)(struct transvr_obj_s *self, int input_val);
|
||||
int (*set_soft_rs0)(struct transvr_obj_s *self, int input_val);
|
||||
int (*set_soft_rs1)(struct transvr_obj_s *self, int input_val);
|
||||
int (*set_soft_tx_disable)(struct transvr_obj_s *self, int input_val);
|
||||
int (*set_auto_tx_disable)(struct transvr_obj_s *self, int input_val);
|
||||
int (*set_tx_eq)(struct transvr_obj_s *self, int input_val);
|
||||
int (*set_rx_am)(struct transvr_obj_s *self, int input_val);
|
||||
int (*set_rx_em)(struct transvr_obj_s *self, int input_val);
|
||||
int (*set_extphy_offset)(struct transvr_obj_s *self, int input_val);
|
||||
int (*set_extphy_reg)(struct transvr_obj_s *self, int input_val);
|
||||
|
||||
/* ========== Object private functions ==========
|
||||
*/
|
||||
int (*init)(struct transvr_obj_s *self);
|
||||
int (*clean)(struct transvr_obj_s *self);
|
||||
int (*check)(struct transvr_obj_s *self);
|
||||
int (*update_all)(struct transvr_obj_s *self, int show_err);
|
||||
int (*fsm_4_direct)(struct transvr_obj_s* self, char *caller_name);
|
||||
int (*fsm_4_polling)(struct transvr_obj_s* self, char *caller_name);
|
||||
int (*send_uevent)(struct transvr_obj_s* self, enum kobject_action u_action);
|
||||
int (*dump_all)(struct transvr_obj_s* self);
|
||||
};
|
||||
|
||||
|
||||
/* For AVL Mapping */
|
||||
struct transvr_avl_s {
|
||||
char vendor_name[32];
|
||||
char vendor_pn[32];
|
||||
int (*init)(struct transvr_obj_s *self);
|
||||
};
|
||||
|
||||
|
||||
/* Worker for long term task of transceiver */
|
||||
struct transvr_worker_s {
|
||||
/* Task Parameter */
|
||||
struct transvr_obj_s *transvr_p;
|
||||
struct transvr_worker_s *next_p;
|
||||
struct transvr_worker_s *pre_p;
|
||||
unsigned long trigger_time;
|
||||
char func_name[64];
|
||||
int retry;
|
||||
int state;
|
||||
|
||||
/* Task private data */
|
||||
void *p_data;
|
||||
|
||||
/* Call back function */
|
||||
int (*main_task)(struct transvr_worker_s *task);
|
||||
int (*post_task)(struct transvr_worker_s *task);
|
||||
};
|
||||
|
||||
|
||||
struct transvr_obj_s *
|
||||
create_transvr_obj(char *swp_name,
|
||||
int chan_id,
|
||||
struct ioexp_obj_s *ioexp_obj_p,
|
||||
int ioexp_virt_offset,
|
||||
int transvr_type,
|
||||
int chipset_type,
|
||||
int run_mode);
|
||||
|
||||
void lock_transvr_obj(struct transvr_obj_s *self);
|
||||
void unlock_transvr_obj(struct transvr_obj_s *self);
|
||||
int isolate_transvr_obj(struct transvr_obj_s *self);
|
||||
|
||||
int resync_channel_tier_2(struct transvr_obj_s *self);
|
||||
|
||||
void alarm_msg_2_user(struct transvr_obj_s *self, char *emsg);
|
||||
|
||||
#endif /* TRANSCEIVER_H */
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,238 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (C) 2017 Inventec, 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 "[D6556]"+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 = [
|
||||
'echo inv_eeprom 0x53 > /sys/bus/i2c/devices/i2c-0/new_device',
|
||||
'echo inv_cpld 0x55 > /sys/bus/i2c/devices/i2c-0/new_device']
|
||||
|
||||
|
||||
drivers =[
|
||||
'gpio_ich',
|
||||
'lpc_ich',
|
||||
'i2c-i801',
|
||||
'i2c-mux',
|
||||
'i2c-mux-pca954x',
|
||||
'i2c-dev',
|
||||
'inv_eeprom',
|
||||
'inv_platform',
|
||||
'inv_psoc',
|
||||
'inv_cpld',
|
||||
'swps',
|
||||
'inv_pthread']
|
||||
|
||||
|
||||
|
||||
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)
|
||||
status, output = exec_cmd("rmmod gpio_ich ", 1)
|
||||
status, output = exec_cmd("rmmod lpc_ich ", 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
|
||||
|
||||
#instantiate devices
|
||||
for i in range(0,len(instantiate)):
|
||||
#time.sleep(1)
|
||||
status, output = exec_cmd(instantiate[i], 1)
|
||||
if status:
|
||||
print output
|
||||
if FORCE == 0:
|
||||
return status
|
||||
|
||||
|
||||
for i in range(10,18):
|
||||
status, output =exec_cmd("echo sff8436 0x50 > /sys/bus/i2c/devices/i2c-1/i2c-2/i2c-"+str(i)+"/new_device", 1)
|
||||
if status:
|
||||
print output
|
||||
if FORCE == 0:
|
||||
return status
|
||||
for i in range(18,26):
|
||||
status, output =exec_cmd("echo sff8436 0x50 > /sys/bus/i2c/devices/i2c-1/i2c-3/i2c-"+str(i)+"/new_device", 1)
|
||||
if status:
|
||||
print output
|
||||
if FORCE == 0:
|
||||
return status
|
||||
for i in range(26,34):
|
||||
status, output =exec_cmd("echo sff8436 0x50 > /sys/bus/i2c/devices/i2c-1/i2c-4/i2c-"+str(i)+"/new_device", 1)
|
||||
if status:
|
||||
print output
|
||||
if FORCE == 0:
|
||||
return status
|
||||
for i in range(34,42):
|
||||
status, output =exec_cmd("echo sff8436 0x50 > /sys/bus/i2c/devices/i2c-1/i2c-5/i2c-"+str(i)+"/new_device", 1)
|
||||
if status:
|
||||
print output
|
||||
if FORCE == 0:
|
||||
return status
|
||||
for i in range(42,50):
|
||||
status, output =exec_cmd("echo sff8436 0x50 > /sys/bus/i2c/devices/i2c-1/i2c-6/i2c-"+str(i)+"/new_device", 1)
|
||||
if status:
|
||||
print output
|
||||
if FORCE == 0:
|
||||
return status
|
||||
for i in range(50,58):
|
||||
status, output =exec_cmd("echo sff8436 0x50 > /sys/bus/i2c/devices/i2c-1/i2c-7/i2c-"+str(i)+"/new_device", 1)
|
||||
if status:
|
||||
print output
|
||||
if FORCE == 0:
|
||||
return status
|
||||
for i in range(58,66):
|
||||
status, output =exec_cmd("echo sff8436 0x50 > /sys/bus/i2c/devices/i2c-1/i2c-8/i2c-"+str(i)+"/new_device", 1)
|
||||
if status:
|
||||
print output
|
||||
if FORCE == 0:
|
||||
return status
|
||||
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 "D6556 devices detected...."
|
||||
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+"*0072", 0)
|
||||
ret2, log = exec_cmd("ls "+i2c_prefix+"i2c-2", 0)
|
||||
return not(ret1 or ret2)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
|
||||
|
@ -2,6 +2,7 @@ obj-m += inv_cpld.o inv_psoc.o
|
||||
obj-m += inv_platform.o
|
||||
obj-m += inv_eeprom.o
|
||||
obj-m += swps.o
|
||||
obj-m += inv_pthread.o
|
||||
swps-objs := inv_swps.o io_expander.o transceiver.o
|
||||
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -124,7 +124,8 @@ drivers =[
|
||||
'inv_platform',
|
||||
'inv_psoc',
|
||||
'inv_cpld',
|
||||
'swps']
|
||||
'swps',
|
||||
'inv_pthread']
|
||||
|
||||
|
||||
|
||||
@ -134,6 +135,9 @@ def system_install():
|
||||
#remove default drivers to avoid modprobe order conflicts
|
||||
status, output = exec_cmd("rmmod i2c_ismt ", 1)
|
||||
status, output = exec_cmd("rmmod i2c-i801 ", 1)
|
||||
status, output = exec_cmd("rmmod gpio_ich",1)
|
||||
status, output = exec_cmd("insmod /lib/modules/3.16.0-5-amd64/extra/gpio-ich.ko gpiobase=0",1)
|
||||
|
||||
#install drivers
|
||||
for i in range(0,len(drivers)):
|
||||
status, output = exec_cmd("modprobe "+drivers[i], 1)
|
||||
@ -196,6 +200,7 @@ def install():
|
||||
|
||||
def uninstall():
|
||||
global FORCE
|
||||
exec_cmd("rmmod gpio_ich",1)
|
||||
#uninstall drivers
|
||||
for i in range(len(drivers)-1,-1,-1):
|
||||
status, output = exec_cmd("rmmod "+drivers[i], 1)
|
||||
|
@ -1,5 +1,6 @@
|
||||
obj-m += inv_cpld.o inv_psoc.o
|
||||
obj-m += inv_platform.o
|
||||
obj-m += inv_pthread.o
|
||||
obj-m += inv_eeprom.o
|
||||
obj-m += swps.o
|
||||
swps-objs := inv_swps.o io_expander.o transceiver.o
|
||||
|
@ -802,6 +802,7 @@ static SENSOR_DEVICE_ATTR(rpm_psu1, S_IRUGO, show_rpm, 0, 8);
|
||||
static SENSOR_DEVICE_ATTR(rpm_psu2, S_IRUGO, show_rpm, 0, 9);
|
||||
|
||||
static SENSOR_DEVICE_ATTR(switch_tmp, S_IWUSR|S_IRUGO, show_switch_tmp, set_switch_tmp, 0);
|
||||
static SENSOR_DEVICE_ATTR(temp6_input, S_IWUSR|S_IRUGO, show_switch_tmp, set_switch_tmp, 0);
|
||||
|
||||
static SENSOR_DEVICE_ATTR(diag, S_IWUSR|S_IRUGO, show_diag, set_diag, 0);
|
||||
static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, 0, 0);
|
||||
@ -831,6 +832,14 @@ static SENSOR_DEVICE_ATTR(psoc_psu2_iout, S_IRUGO, show_psu_psoc,
|
||||
static SENSOR_DEVICE_ATTR(psoc_psu2_pin, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_pin));
|
||||
static SENSOR_DEVICE_ATTR(psoc_psu2_pout, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_pout));
|
||||
|
||||
static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_vin));
|
||||
static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_vin));
|
||||
static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_iin));
|
||||
static SENSOR_DEVICE_ATTR(curr2_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_iin));
|
||||
static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_pin));
|
||||
static SENSOR_DEVICE_ATTR(power2_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_pin));
|
||||
|
||||
|
||||
//IPMI
|
||||
static SENSOR_DEVICE_ATTR(thermal2_psu1, S_IRUGO, show_ipmi_i2c, 0, PSU1 | PMBus_Temp2);
|
||||
static SENSOR_DEVICE_ATTR(psoc_psu1_vender, S_IRUGO, show_ipmi_i2c, 0, PSU1 | PMBus_Vender);
|
||||
@ -880,6 +889,7 @@ static struct attribute *psoc_attributes[] = {
|
||||
|
||||
//switch temperature
|
||||
&sensor_dev_attr_switch_tmp.dev_attr.attr,
|
||||
&sensor_dev_attr_temp6_input.dev_attr.attr,
|
||||
|
||||
//diag flag
|
||||
&sensor_dev_attr_diag.dev_attr.attr,
|
||||
@ -917,6 +927,14 @@ static struct attribute *psoc_attributes[] = {
|
||||
&sensor_dev_attr_psoc_psu2_pin.dev_attr.attr,
|
||||
&sensor_dev_attr_psoc_psu2_pout.dev_attr.attr,
|
||||
|
||||
// Add new fields which matching standard
|
||||
&sensor_dev_attr_in1_input.dev_attr.attr,
|
||||
&sensor_dev_attr_in2_input.dev_attr.attr,
|
||||
&sensor_dev_attr_curr1_input.dev_attr.attr,
|
||||
&sensor_dev_attr_curr2_input.dev_attr.attr,
|
||||
&sensor_dev_attr_power1_input.dev_attr.attr,
|
||||
&sensor_dev_attr_power2_input.dev_attr.attr,
|
||||
|
||||
//ipmi_command
|
||||
&sensor_dev_attr_thermal2_psu1.dev_attr.attr,
|
||||
&sensor_dev_attr_psoc_psu1_vender.dev_attr.attr,
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -127,13 +127,14 @@ drivers =[
|
||||
'inv_platform',
|
||||
'inv_psoc',
|
||||
'inv_cpld',
|
||||
'inv_pthread',
|
||||
'swps']
|
||||
|
||||
|
||||
|
||||
def system_install():
|
||||
global FORCE
|
||||
|
||||
|
||||
#install drivers
|
||||
for i in range(0,len(drivers)):
|
||||
status, output = exec_cmd("modprobe "+drivers[i], 1)
|
||||
@ -209,7 +210,7 @@ def install():
|
||||
if FORCE == 0:
|
||||
return status
|
||||
else:
|
||||
print " D7032 devices detected...."
|
||||
print " D7054 devices detected...."
|
||||
return
|
||||
|
||||
def uninstall():
|
||||
|
@ -1,5 +1,6 @@
|
||||
obj-m += inv_cpld.o inv_psoc.o
|
||||
obj-m += inv_platform.o
|
||||
obj-m += inv_pthread.o
|
||||
obj-m += inv_eeprom.o
|
||||
obj-m += swps.o
|
||||
swps-objs := inv_swps.o io_expander.o transceiver.o
|
||||
|
@ -50,7 +50,6 @@ DEFINE_MUTEX(ipmi_mutex);
|
||||
DEFINE_MUTEX(ipmi2_mutex);
|
||||
static struct ipmi_result ipmiresult;
|
||||
static struct device *hwmon_dev;
|
||||
static struct kobject *device_kobj;
|
||||
static ipmi_user_t ipmi_mh_user = NULL;
|
||||
static void msg_handler(struct ipmi_recv_msg *msg,void* handler_data);
|
||||
static struct ipmi_user_hndl ipmi_hndlrs = { .ipmi_recv_hndl = msg_handler,};
|
||||
@ -588,6 +587,7 @@ static SENSOR_DEVICE_ATTR(rpm_psu1, S_IRUGO, show_rpm, 0, 8);
|
||||
static SENSOR_DEVICE_ATTR(rpm_psu2, S_IRUGO, show_rpm, 0, 9);
|
||||
|
||||
static SENSOR_DEVICE_ATTR(switch_tmp, S_IWUSR|S_IRUGO, show_switch_tmp, set_switch_tmp, 0);
|
||||
static SENSOR_DEVICE_ATTR(temp6_input, S_IWUSR|S_IRUGO, show_switch_tmp, set_switch_tmp, 0);
|
||||
|
||||
static SENSOR_DEVICE_ATTR(diag, S_IWUSR|S_IRUGO, show_diag, set_diag, 0);
|
||||
static SENSOR_DEVICE_ATTR(version, S_IRUGO, show_version, 0, 0);
|
||||
@ -618,6 +618,13 @@ static SENSOR_DEVICE_ATTR(psoc_psu2_iout, S_IRUGO, show_psu_psoc,
|
||||
static SENSOR_DEVICE_ATTR(psoc_psu2_pin, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_pin));
|
||||
static SENSOR_DEVICE_ATTR(psoc_psu2_pout, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_pout));
|
||||
|
||||
static SENSOR_DEVICE_ATTR(in1_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_vin));
|
||||
static SENSOR_DEVICE_ATTR(in2_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_vin));
|
||||
static SENSOR_DEVICE_ATTR(curr1_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_iin));
|
||||
static SENSOR_DEVICE_ATTR(curr2_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_iin));
|
||||
static SENSOR_DEVICE_ATTR(power1_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu1_pin));
|
||||
static SENSOR_DEVICE_ATTR(power2_input, S_IRUGO, show_psu_psoc, 0, PSOC_PSU_OFF(psu2_pin));
|
||||
|
||||
//IPMI
|
||||
static SENSOR_DEVICE_ATTR(thermal2_psu1, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Temp2);
|
||||
static SENSOR_DEVICE_ATTR(psoc_psu1_vender, S_IRUGO, show_ipmi_pmbus, 0, PSU1 | PMBus_Vender);
|
||||
@ -665,7 +672,7 @@ static struct attribute *psoc_attributes[] = {
|
||||
|
||||
//switch temperature
|
||||
&sensor_dev_attr_switch_tmp.dev_attr.attr,
|
||||
|
||||
&sensor_dev_attr_temp6_input.dev_attr.attr,
|
||||
//diag flag
|
||||
&sensor_dev_attr_diag.dev_attr.attr,
|
||||
|
||||
@ -702,6 +709,14 @@ static struct attribute *psoc_attributes[] = {
|
||||
&sensor_dev_attr_psoc_psu2_pin.dev_attr.attr,
|
||||
&sensor_dev_attr_psoc_psu2_pout.dev_attr.attr,
|
||||
|
||||
// Add new fields which matching standard
|
||||
&sensor_dev_attr_in1_input.dev_attr.attr,
|
||||
&sensor_dev_attr_in2_input.dev_attr.attr,
|
||||
&sensor_dev_attr_curr1_input.dev_attr.attr,
|
||||
&sensor_dev_attr_curr2_input.dev_attr.attr,
|
||||
&sensor_dev_attr_power1_input.dev_attr.attr,
|
||||
&sensor_dev_attr_power2_input.dev_attr.attr,
|
||||
|
||||
//ipmi_i2c_command
|
||||
&sensor_dev_attr_thermal2_psu1.dev_attr.attr,
|
||||
&sensor_dev_attr_psoc_psu1_vender.dev_attr.attr,
|
||||
@ -732,13 +747,8 @@ static int __init inv_psoc_init(void)
|
||||
if (IS_ERR(hwmon_dev)) {
|
||||
goto fail_hwmon_device_register;
|
||||
}
|
||||
|
||||
device_kobj = kobject_create_and_add("device", &hwmon_dev->kobj);
|
||||
if(!device_kobj) {
|
||||
goto fail_hwmon_device_register;
|
||||
}
|
||||
|
||||
ret = sysfs_create_group(device_kobj, &psoc_group);
|
||||
|
||||
ret = sysfs_create_group(&hwmon_dev->kobj, &psoc_group);
|
||||
if (ret) {
|
||||
goto fail_create_group_hwmon;
|
||||
}
|
||||
@ -754,9 +764,10 @@ fail_hwmon_device_register:
|
||||
|
||||
static void __exit inv_psoc_exit(void)
|
||||
{
|
||||
sysfs_remove_group(&hwmon_dev->kobj, &psoc_group);
|
||||
|
||||
if(ipmi_mh_user!=NULL) {ipmi_destroy_user(ipmi_mh_user);}
|
||||
if(hwmon_dev != NULL) hwmon_device_unregister(hwmon_dev);
|
||||
sysfs_remove_group(device_kobj, &psoc_group);
|
||||
}
|
||||
|
||||
MODULE_AUTHOR("Ting.Jack <ting.jack@inventec>");
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -115,6 +115,7 @@ instantiate =[
|
||||
'echo inv_eeprom 0x53> /sys/bus/i2c/devices/i2c-0/new_device']
|
||||
|
||||
drivers =[
|
||||
'gpio-ich',
|
||||
'lpc_ich',
|
||||
'i2c-i801',
|
||||
'i2c-mux',
|
||||
@ -124,9 +125,9 @@ drivers =[
|
||||
'inv_platform',
|
||||
'inv_psoc',
|
||||
'inv_cpld',
|
||||
'inv_pthread',
|
||||
'swps']
|
||||
|
||||
|
||||
|
||||
def system_install():
|
||||
global FORCE
|
||||
@ -213,7 +214,7 @@ def install():
|
||||
status = system_install()
|
||||
if status:
|
||||
if FORCE == 0:
|
||||
return status
|
||||
return status
|
||||
else:
|
||||
print " D7264 devices detected...."
|
||||
return
|
||||
|
@ -1,7 +1,17 @@
|
||||
sonic-inventec-platform-modules (1.1.0) unstable; urgency=low
|
||||
* Add support for Inventec d7264
|
||||
|
||||
-- developer <swsp@inventec.com> Tue, 17 Apr 2018 15:27:30 +0800
|
||||
-- alvin lin <lin.alvin@inventec.com> Thu, 12 Jul 2018 16:00:00 +0800
|
||||
|
||||
sonic-inventec-platform-modules (1.1.0) unstable; urgency=low
|
||||
* Add support for Inventec d6556
|
||||
|
||||
-- alvin lin <lin.alvin@inventec.com> Thu, 12 Jul 2018 16:00:00 +0800
|
||||
|
||||
sonic-inventec-platform-modules (1.1.0) unstable; urgency=low
|
||||
* Add support for Inventec d6254
|
||||
|
||||
-- alvin lin <lin.alvin@inventec.com> Wed, 09 May 2018 16:00:00 +0800
|
||||
|
||||
sonic-inventec-platform-modules (1.1.0) unstable; urgency=low
|
||||
* Add support for Inventec d7054
|
||||
|
@ -6,16 +6,26 @@ Build-Depends: debhelper (>= 8.0.0), bzip2
|
||||
Standards-Version: 3.9.3
|
||||
|
||||
Package: platform-modules-d7032q28b
|
||||
Architecture: amd64
|
||||
Depends: linux-image-3.16.0-5-amd64
|
||||
Architecture: amd64
|
||||
Depends: linux-image-4.9.0-7-amd64
|
||||
Description: kernel modules for platform devices such as fan, led
|
||||
|
||||
Package: platform-modules-d7054q28b
|
||||
Architecture: amd64
|
||||
Depends: linux-image-3.16.0-5-amd64
|
||||
Depends: linux-image-4.9.0-7-amd64
|
||||
Description: kernel modules for platform devices such as fan, led
|
||||
|
||||
Package: platform-modules-d6254qs
|
||||
Architecture: amd64
|
||||
Depends: linux-image-4.9.0-7-amd64
|
||||
Description: kernel modules for platform devices such as fan, led
|
||||
|
||||
Package: platform-modules-d6556
|
||||
Architecture: amd64
|
||||
Depends: linux-image-4.9.0-7-amd64
|
||||
Description: kernel modules for platform devices such as fan, led
|
||||
|
||||
Package: platform-modules-d7264q28b
|
||||
Architecture: amd64
|
||||
Depends: linux-image-3.16.0-5-amd64
|
||||
Depends: linux-image-4.9.0-7-amd64
|
||||
Description: kernel modules for platform devices such as fan, led
|
||||
|
@ -0,0 +1,73 @@
|
||||
#!/bin/bash
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: setup-board
|
||||
# Required-Start:
|
||||
# Required-Stop:
|
||||
# Should-Start:
|
||||
# Should-Stop:
|
||||
# Default-Start: S
|
||||
# Default-Stop: 0 6
|
||||
# Short-Description: Setup Inventec d6254qs board.
|
||||
### END INIT INFO
|
||||
|
||||
DIR=/usr/share/sonic/device/x86_64-inventec_d6254qs-r0/plugins
|
||||
MONITOR_DAEMON=$DIR/transceiver_monitor.py
|
||||
MONITOR_DAEMON_NAME=transceiver_monitor
|
||||
LED_DAEMON=$DIR/led_proc.py
|
||||
LED_DAEMON_NAME=led_proc
|
||||
ASIC_DAEMON=$DIR/asic_monitor.py
|
||||
ASIC_DAEMON_NAME=asic_monitor
|
||||
ASIC_DAEMON_NAM=asic_monitor
|
||||
PLATFORM_STATUS_DAEMON=$DIR/platform_status.py
|
||||
PLATFORM_STATUS_DAEMON_NAME=platform_status
|
||||
|
||||
# The process ID of the script when it runs is stored here:
|
||||
MONITOR_PIDFILE=/var/run/$MONITOR_DAEMON_NAME.pid
|
||||
LED_PIDFILE=/var/run/$LED_DAEMON_NAME.pid
|
||||
ASIC_PIDFILE=/var/run/$ASIC_DAEMON_NAME.pid
|
||||
PLATFORM_STATUS_PIDFILE=/var/run/$PLATFORM_STATUS_DAEMON_NAME.pid
|
||||
|
||||
do_monitor_start() {
|
||||
/sbin/start-stop-daemon --quiet --oknodo --pidfile $LED_PIDFILE --make-pidfile --startas $LED_DAEMON --start --background -- $DAEMON_OPTS
|
||||
/sbin/start-stop-daemon --quiet --oknodo --pidfile $MONITOR_PIDFILE --make-pidfile --startas $MONITOR_DAEMON --start --background -- $DAEMON_OPTS
|
||||
/sbin/start-stop-daemon --quiet --oknodo --pidfile $ASIC_PIDFILE --make-pidfile --startas $ASIC_DAEMON --start --background -- $DAEMON_OPTS
|
||||
/sbin/start-stop-daemon --quiet --oknodo --pidfile $PLATFORM_STATUS_PIDFILE --make-pidfile --startas $PLATFORM_STATUS_DAEMON --start --background -- $DAEMON_OPTS
|
||||
}
|
||||
|
||||
do_monitor_stop() {
|
||||
/sbin/start-stop-daemon --quiet --oknodo --stop --pidfile $MONITOR_PIDFILE --retry 10
|
||||
/sbin/start-stop-daemon --quiet --oknodo --stop --pidfile $LED_PIDFILE --retry 10
|
||||
/sbin/start-stop-daemon --quiet --oknodo --stop --pidfile $ASIC_PIDFILE --retry 10
|
||||
/sbin/start-stop-daemon --quiet --oknodo --stop --pidfile $PLATFORM_STATUS_PIDFILE --retry 10
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "Setting up board... "
|
||||
|
||||
depmod -a
|
||||
/usr/local/bin/inventec_d6254_util.py -f install
|
||||
do_monitor_${1}
|
||||
echo "done."
|
||||
;;
|
||||
|
||||
stop)
|
||||
|
||||
/usr/local/bin/inventec_d6254_util.py -f clean
|
||||
do_monitor_${1}
|
||||
echo "done."
|
||||
|
||||
;;
|
||||
|
||||
force-reload|restart)
|
||||
echo "Not supported"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: /etc/init.d/platform-modules-d6254qs.init {start|stop}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
@ -0,0 +1,6 @@
|
||||
d6254qs/utils/inventec_d6254_util.py usr/local/bin
|
||||
common/utils/transceiver_monitor.py usr/share/sonic/device/x86_64-inventec_d6254qs-r0/plugins
|
||||
common/utils/led_proc.py usr/share/sonic/device/x86_64-inventec_d6254qs-r0/plugins
|
||||
common/utils/asic_monitor.py usr/share/sonic/device/x86_64-inventec_d6254qs-r0/plugins
|
||||
common/utils/platform_status.py usr/share/sonic/device/x86_64-inventec_d6254qs-r0/plugins
|
||||
systemd/platform-modules-d6254qs.service lib/systemd/system
|
@ -0,0 +1,72 @@
|
||||
#!/bin/bash
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: setup-board
|
||||
# Required-Start:
|
||||
# Required-Stop:
|
||||
# Should-Start:
|
||||
# Should-Stop:
|
||||
# Default-Start: S
|
||||
# Default-Stop: 0 6
|
||||
# Short-Description: Setup Inventec d6556 board.
|
||||
### END INIT INFO
|
||||
|
||||
DIR=/usr/share/sonic/device/x86_64-inventec_d6556-r0/plugins
|
||||
MONITOR_DAEMON=$DIR/transceiver_monitor.py
|
||||
MONITOR_DAEMON_NAME=transceiver_monitor
|
||||
LED_DAEMON=$DIR/led_proc.py
|
||||
LED_DAEMON_NAME=led_proc
|
||||
ASIC_DAEMON=$DIR/asic_monitor.py
|
||||
ASIC_DAEMON_NAME=asic_monitor
|
||||
PLATFORM_STATUS_DAEMON=$DIR/platform_status.py
|
||||
PLATFORM_STATUS_DAEMON_NAME=platform_status
|
||||
|
||||
# The process ID of the script when it runs is stored here:
|
||||
MONITOR_PIDFILE=/var/run/$MONITOR_DAEMON_NAME.pid
|
||||
LED_PIDFILE=/var/run/$LED_DAEMON_NAME.pid
|
||||
ASIC_PIDFILE=/var/run/$ASIC_DAEMON_NAME.pid
|
||||
PLATFORM_STATUS_PIDFILE=/var/run/$PLATFORM_STATUS_DAEMON_NAME.pid
|
||||
|
||||
do_monitor_start() {
|
||||
/sbin/start-stop-daemon --quiet --oknodo --pidfile $LED_PIDFILE --make-pidfile --startas $LED_DAEMON --start --background -- $DAEMON_OPTS
|
||||
/sbin/start-stop-daemon --quiet --oknodo --pidfile $MONITOR_PIDFILE --make-pidfile --startas $MONITOR_DAEMON --start --background -- $DAEMON_OPTS
|
||||
/sbin/start-stop-daemon --quiet --oknodo --pidfile $ASIC_PIDFILE --make-pidfile --startas $ASIC_DAEMON --start --background -- $DAEMON_OPTS
|
||||
/sbin/start-stop-daemon --quiet --oknodo --pidfile $PLATFORM_STATUS_PIDFILE --make-pidfile --startas $PLATFORM_STATUS_DAEMON --start --background -- $DAEMON_OPTS
|
||||
}
|
||||
|
||||
do_monitor_stop() {
|
||||
/sbin/start-stop-daemon --quiet --oknodo --stop --pidfile $MONITOR_PIDFILE --retry 10
|
||||
/sbin/start-stop-daemon --quiet --oknodo --stop --pidfile $LED_PIDFILE --retry 10
|
||||
/sbin/start-stop-daemon --quiet --oknodo --stop --pidfile $ASIC_PIDFILE --retry 10
|
||||
/sbin/start-stop-daemon --quiet --oknodo --stop --pidfile $PLATFORM_STATUS_PIDFILE --retry 10
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "Setting up board... "
|
||||
|
||||
depmod -a
|
||||
/usr/local/bin/inventec_d6556_util.py -f install
|
||||
do_monitor_${1}
|
||||
echo "done."
|
||||
;;
|
||||
|
||||
stop)
|
||||
|
||||
/usr/local/bin/inventec_d6556_util.py -f clean
|
||||
do_monitor_${1}
|
||||
echo "done."
|
||||
|
||||
;;
|
||||
|
||||
force-reload|restart)
|
||||
echo "Not supported"
|
||||
;;
|
||||
|
||||
*)
|
||||
echo "Usage: /etc/init.d/platform-modules-d6556.init {start|stop}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
@ -0,0 +1,6 @@
|
||||
d6556/utils/inventec_d6556_util.py usr/local/bin
|
||||
common/utils/transceiver_monitor.py usr/share/sonic/device/x86_64-inventec_d6556-r0/plugins
|
||||
common/utils/led_proc.py usr/share/sonic/device/x86_64-inventec_d6556-r0/plugins
|
||||
common/utils/asic_monitor.py usr/share/sonic/device/x86_64-inventec_d6556-r0/plugins
|
||||
common/utils/platform_status.py usr/share/sonic/device/x86_64-inventec_d6556-r0/plugins
|
||||
systemd/platform-modules-d6556.service lib/systemd/system
|
@ -16,19 +16,29 @@ MONITOR_DAEMON=$DIR/transceiver_monitor.py
|
||||
MONITOR_DAEMON_NAME=transceiver_monitor
|
||||
LED_DAEMON=$DIR/led_proc.py
|
||||
LED_DAEMON_NAME=led_proc
|
||||
ASIC_DAEMON=$DIR/asic_monitor.py
|
||||
ASIC_DAEMON_NAME=asic_monitor
|
||||
PLATFORM_STATUS_DAEMON=$DIR/platform_status.py
|
||||
PLATFORM_STATUS_DAEMON_NAME=platform_status
|
||||
|
||||
# The process ID of the script when it runs is stored here:
|
||||
MONITOR_PIDFILE=/var/run/$MONITOR_DAEMON_NAME.pid
|
||||
LED_PIDFILE=/var/run/$LED_DAEMON_NAME.pid
|
||||
ASIC_PIDFILE=/var/run/$ASIC_DAEMON_NAME.pid
|
||||
PLATFORM_STATUS_PIDFILE=/var/run/$PLATFORM_STATUS_DAEMON_NAME.pid
|
||||
|
||||
do_monitor_start() {
|
||||
/sbin/start-stop-daemon --quiet --oknodo --pidfile $LED_PIDFILE --make-pidfile --startas $LED_DAEMON --start --background -- $DAEMON_OPTS
|
||||
/sbin/start-stop-daemon --quiet --oknodo --pidfile $MONITOR_PIDFILE --make-pidfile --startas $MONITOR_DAEMON --start --background -- $DAEMON_OPTS
|
||||
/sbin/start-stop-daemon --quiet --oknodo --pidfile $ASIC_PIDFILE --make-pidfile --startas $ASIC_DAEMON --start --background -- $DAEMON_OPTS
|
||||
/sbin/start-stop-daemon --quiet --oknodo --pidfile $PLATFORM_STATUS_PIDFILE --make-pidfile --startas $PLATFORM_STATUS_DAEMON --start --background -- $DAEMON_OPTS
|
||||
}
|
||||
|
||||
do_monitor_stop() {
|
||||
/sbin/start-stop-daemon --quiet --oknodo --stop --pidfile $MONITOR_PIDFILE --retry 10
|
||||
/sbin/start-stop-daemon --quiet --oknodo --stop --pidfile $LED_PIDFILE --retry 10
|
||||
/sbin/start-stop-daemon --quiet --oknodo --stop --pidfile $ASIC_PIDFILE --retry 10
|
||||
/sbin/start-stop-daemon --quiet --oknodo --stop --pidfile $PLATFORM_STATUS_PIDFILE --retry 10
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
|
@ -1,3 +1,6 @@
|
||||
d7032q28b/utils/inventec_d7032_util.py usr/local/bin
|
||||
common/utils/transceiver_monitor.py usr/share/sonic/device/x86_64-inventec_d7032q28b-r0/plugins
|
||||
common/utils/led_proc.py usr/share/sonic/device/x86_64-inventec_d7032q28b-r0/plugins
|
||||
common/utils/asic_monitor.py usr/share/sonic/device/x86_64-inventec_d7032q28b-r0/plugins
|
||||
common/utils/platform_status.py usr/share/sonic/device/x86_64-inventec_d7032q28b-r0/plugins
|
||||
systemd/platform-modules-d7032q28b.service lib/systemd/system
|
||||
|
@ -16,19 +16,29 @@ MONITOR_DAEMON=$DIR/transceiver_monitor.py
|
||||
MONITOR_DAEMON_NAME=transceiver_monitor
|
||||
LED_DAEMON=$DIR/led_proc.py
|
||||
LED_DAEMON_NAME=led_proc
|
||||
ASIC_DAEMON=$DIR/asic_monitor.py
|
||||
ASIC_DAEMON_NAME=asic_monitor
|
||||
PLATFORM_STATUS_DAEMON=$DIR/platform_status.py
|
||||
PLATFORM_STATUS_DAEMON_NAME=platform_status
|
||||
|
||||
# The process ID of the script when it runs is stored here:
|
||||
MONITOR_PIDFILE=/var/run/$MONITOR_DAEMON_NAME.pid
|
||||
LED_PIDFILE=/var/run/$LED_DAEMON_NAME.pid
|
||||
ASIC_PIDFILE=/var/run/$ASIC_DAEMON_NAME.pid
|
||||
PLATFORM_STATUS_PIDFILE=/var/run/$PLATFORM_STATUS_DAEMON_NAME.pid
|
||||
|
||||
do_monitor_start() {
|
||||
/sbin/start-stop-daemon --quiet --oknodo --pidfile $LED_PIDFILE --make-pidfile --startas $LED_DAEMON --start --background -- $DAEMON_OPTS
|
||||
/sbin/start-stop-daemon --quiet --oknodo --pidfile $MONITOR_PIDFILE --make-pidfile --startas $MONITOR_DAEMON --start --background -- $DAEMON_OPTS
|
||||
/sbin/start-stop-daemon --quiet --oknodo --pidfile $ASIC_PIDFILE --make-pidfile --startas $ASIC_DAEMON --start --background -- $DAEMON_OPTS
|
||||
/sbin/start-stop-daemon --quiet --oknodo --pidfile $PLATFORM_STATUS_PIDFILE --make-pidfile --startas $PLATFORM_STATUS_DAEMON --start --background -- $DAEMON_OPTS
|
||||
}
|
||||
|
||||
do_monitor_stop() {
|
||||
/sbin/start-stop-daemon --quiet --oknodo --stop --pidfile $MONITOR_PIDFILE --retry 10
|
||||
/sbin/start-stop-daemon --quiet --oknodo --stop --pidfile $LED_PIDFILE --retry 10
|
||||
/sbin/start-stop-daemon --quiet --oknodo --stop --pidfile $ASIC_PIDFILE --retry 10
|
||||
/sbin/start-stop-daemon --quiet --oknodo --stop --pidfile $PLATFORM_STATUS_PIDFILE --retry 10
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
|
@ -1,4 +1,6 @@
|
||||
d7054q28b/utils/inventec_d7054_util.py usr/local/bin
|
||||
common/utils/transceiver_monitor.py usr/share/sonic/device/x86_64-inventec_d7054q28b-r0/plugins
|
||||
common/utils/led_proc.py usr/share/sonic/device/x86_64-inventec_d7054q28b-r0/plugins
|
||||
|
||||
common/utils/asic_monitor.py usr/share/sonic/device/x86_64-inventec_d7054q28b-r0/plugins
|
||||
common/utils/platform_status.py usr/share/sonic/device/x86_64-inventec_d7054q28b-r0/plugins
|
||||
systemd/platform-modules-d7054q28b.service lib/systemd/system
|
||||
|
@ -8,21 +8,48 @@
|
||||
# Should-Stop:
|
||||
# Default-Start: S
|
||||
# Default-Stop: 0 6
|
||||
# Short-Description: Setup Inventec d7054q28b board.
|
||||
# Short-Description: Setup Inventec d7264q28b board.
|
||||
### END INIT INFO
|
||||
|
||||
DIR=/usr/share/sonic/device/x86_64-inventec_d7264q28b-r0/plugins
|
||||
MONITOR_DAEMON=$DIR/transceiver_monitor.py
|
||||
MONITOR_DAEMON_NAME=transceiver_monitor
|
||||
ASIC_DAEMON=$DIR/asic_monitor.py
|
||||
ASIC_DAEMON_NAME=asic_monitor
|
||||
PLATFORM_STATUS_DAEMON=$DIR/platform_status.py
|
||||
PLATFORM_STATUS_DAEMON_NAME=platform_status
|
||||
|
||||
# The process ID of the script when it runs is stored here:
|
||||
MONITOR_PIDFILE=/var/run/$MONITOR_DAEMON_NAME.pid
|
||||
ASIC_PIDFILE=/var/run/$ASIC_DAEMON_NAME.pid
|
||||
PLATFORM_STATUS_PIDFILE=/var/run/$PLATFORM_STATUS_DAEMON_NAME.pid
|
||||
|
||||
do_monitor_start() {
|
||||
/sbin/start-stop-daemon --quiet --oknodo --pidfile $MONITOR_PIDFILE --make-pidfile --startas $MONITOR_DAEMON --start --background -- $DAEMON_OPTS
|
||||
/sbin/start-stop-daemon --quiet --oknodo --pidfile $ASIC_PIDFILE --make-pidfile --startas $ASIC_DAEMON --start --background -- $DAEMON_OPTS
|
||||
/sbin/start-stop-daemon --quiet --oknodo --pidfile $PLATFORM_STATUS_PIDFILE --make-pidfile --startas $PLATFORM_STATUS_DAEMON --start --background -- $DAEMON_OPTS
|
||||
}
|
||||
|
||||
do_monitor_stop() {
|
||||
/sbin/start-stop-daemon --quiet --oknodo --stop --pidfile $MONITOR_PIDFILE --retry 10
|
||||
/sbin/start-stop-daemon --quiet --oknodo --stop --pidfile $ASIC_PIDFILE --retry 10
|
||||
/sbin/start-stop-daemon --quiet --oknodo --stop --pidfile $PLATFORM_STATUS_PIDFILE --retry 10
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
echo -n "Setting up board... "
|
||||
|
||||
depmod -a
|
||||
/usr/local/bin/inventec_d7264_util.py -f install
|
||||
do_monitor_${1}
|
||||
echo "done."
|
||||
;;
|
||||
|
||||
stop)
|
||||
|
||||
/usr/local/bin/inventec_d7264_util.py -f clean
|
||||
do_monitor_${1}
|
||||
echo "done."
|
||||
|
||||
;;
|
||||
|
@ -1 +1,5 @@
|
||||
d7264q28b/utils/inventec_d7264_util.py usr/local/bin
|
||||
common/utils/transceiver_monitor.py usr/share/sonic/device/x86_64-inventec_d7264q28b-r0/plugins
|
||||
common/utils/asic_monitor.py usr/share/sonic/device/x86_64-inventec_d7264q28b-r0/plugins
|
||||
common/utils/platform_status.py usr/share/sonic/device/x86_64-inventec_d7264q28b-r0/plugins
|
||||
systemd/platform-modules-d7264q28b.service lib/systemd/system
|
||||
|
@ -1,5 +0,0 @@
|
||||
description "SONiC platform service"
|
||||
|
||||
respawn
|
||||
|
||||
exec /usr/local/bin/inventec_d7264_util.py -f install
|
@ -14,10 +14,10 @@ export INSTALL_MOD_DIR:=extra
|
||||
KVERSION ?= $(shell uname -r)
|
||||
KERNEL_SRC := /lib/modules/$(KVERSION)
|
||||
MOD_SRC_DIR:= $(shell pwd)
|
||||
MODULE_DIRS:= d7032q28b d7054q28b d7264q28b
|
||||
MODULE_DIRS:= d7032q28b d7054q28b d6254qs d6556 d7264q28b
|
||||
|
||||
%:
|
||||
dh $@
|
||||
dh $@ --with=systemd
|
||||
|
||||
override_dh_auto_build:
|
||||
(for mod in $(MODULE_DIRS); do \
|
||||
|
@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=Inventec d6254qs Platform modules
|
||||
After=local-fs.target
|
||||
Before=pmon.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=-/etc/init.d/platform-modules-d6254qs start
|
||||
ExecStop=-/etc/init.d/platform-modules-d6254qs stop
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=Inventec d7032q28b Platform modules
|
||||
After=local-fs.target
|
||||
Before=pmon.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=-/etc/init.d/platform-modules-d6556 start
|
||||
ExecStop=-/etc/init.d/platform-modules-d6556 stop
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=Inventec d7032q28b Platform modules
|
||||
After=local-fs.target
|
||||
Before=pmon.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=-/etc/init.d/platform-modules-d7032q28b start
|
||||
ExecStop=-/etc/init.d/platform-modules-d7032q28b stop
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=Inventec d7054q28b Platform modules
|
||||
After=local-fs.target
|
||||
Before=pmon.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=-/etc/init.d/platform-modules-d7054q28b start
|
||||
ExecStop=-/etc/init.d/platform-modules-d7054q28b stop
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
@ -0,0 +1,13 @@
|
||||
[Unit]
|
||||
Description=Inventec d7032q28b Platform modules
|
||||
After=local-fs.target
|
||||
Before=pmon.service
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStart=-/etc/init.d/platform-modules-d7264q28b start
|
||||
ExecStop=-/etc/init.d/platform-modules-d7264q28b stop
|
||||
RemainAfterExit=yes
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
Loading…
Reference in New Issue
Block a user