diff --git a/.gitmodules b/.gitmodules
index 9adb11eeb0..915b19cb13 100644
--- a/.gitmodules
+++ b/.gitmodules
@@ -53,9 +53,6 @@
[submodule "platform/p4/SAI-P4-BM"]
path = platform/p4/SAI-P4-BM
url = https://github.com/Mellanox/SAI-P4-BM.git
-[submodule "platform/nephos/sonic-platform-modules-ingrasys"]
- path = platform/nephos/sonic-platform-modules-ingrasys
- url = https://github.com/Ingrasys-sonic/sonic-platform-modules-ingrasys-nephos.git
[submodule "platform/barefoot/sonic-platform-modules-arista"]
path = platform/barefoot/sonic-platform-modules-arista
url = https://github.com/aristanetworks/sonic
diff --git a/device/ingrasys/x86_64-ingrasys_s8810_32q-r0/plugins/sfputil.py b/device/ingrasys/x86_64-ingrasys_s8810_32q-r0/plugins/sfputil.py
index f146b0e442..8d195f644e 100644
--- a/device/ingrasys/x86_64-ingrasys_s8810_32q-r0/plugins/sfputil.py
+++ b/device/ingrasys/x86_64-ingrasys_s8810_32q-r0/plugins/sfputil.py
@@ -3,6 +3,8 @@
# Platform-specific SFP transceiver interface for SONiC
#
+import os
+
try:
import time
from sonic_sfp.sfputilbase import SfpUtilBase
@@ -23,6 +25,7 @@ class SfpUtil(SfpUtilBase):
#INT_GPIO_BASE = 192
LP_GPIO_BASE = 160
RST_GPIO_BASE = 128
+ GPIO_OFFSET = 0
BASE_DIR_PATH = "/sys/class/gpio/gpio{0}/direction"
BASE_VAL_PATH = "/sys/class/gpio/gpio{0}/value"
@@ -45,7 +48,32 @@ class SfpUtil(SfpUtilBase):
def port_to_eeprom_mapping(self):
return self._port_to_eeprom_mapping
+ def set_gpio_offset(self):
+ sys_gpio_dir = "/sys/class/gpio"
+ self.GPIO_OFFSET = 0
+ gpiochip_no = 0
+ for d in os.listdir(sys_gpio_dir):
+ if "gpiochip" in d:
+ try:
+ gpiochip_no = int(d[8:],10)
+ except ValueError as e:
+ print "Error: %s" % str(e)
+ if gpiochip_no > 255:
+ self.GPIO_OFFSET=256
+ return True
+ return True
+
+ def update_gpio_base(self):
+ self.ABS_GPIO_BASE = 224 + self.GPIO_OFFSET
+ self.LP_GPIO_BASE = 160 + self.GPIO_OFFSET
+ self.RST_GPIO_BASE = 128 + self.GPIO_OFFSET
+ return True
+
def __init__(self):
+ # Update abs, lpmode, and reset gpio base
+ self.set_gpio_offset()
+ self.update_gpio_base()
+
# Override port_to_eeprom_mapping for class initialization
eeprom_path = "/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom"
diff --git a/device/ingrasys/x86_64-ingrasys_s8900_54xc-r0/INGRASYS-S8900-54XC/th-s8900-48x25G+6x100G.config.bcm b/device/ingrasys/x86_64-ingrasys_s8900_54xc-r0/INGRASYS-S8900-54XC/th-s8900-48x25G+6x100G.config.bcm
index 8440176b20..4485a77af2 100644
--- a/device/ingrasys/x86_64-ingrasys_s8900_54xc-r0/INGRASYS-S8900-54XC/th-s8900-48x25G+6x100G.config.bcm
+++ b/device/ingrasys/x86_64-ingrasys_s8900_54xc-r0/INGRASYS-S8900-54XC/th-s8900-48x25G+6x100G.config.bcm
@@ -1,12 +1,17 @@
-#2017/05/31
+#2018/03/31
os=unix
oversubscribe_mode=1
pbmp_xport_xe=0x7f00001fff4003ffffc0001fffe
-lpm_scaling_enable=1
-lpm_ipv6_128b_reserved=0
+l3_alpm_enable=2
+ipv6_lpm_128b_enable=1
+l3_mem_entries=40960
+l2_mem_entries=40960
+
+l2xmsg_mode=1
+mmu_lossless=0
#Parity
parity_correction=1
diff --git a/device/ingrasys/x86_64-ingrasys_s8900_54xc-r0/plugins/sfputil.py b/device/ingrasys/x86_64-ingrasys_s8900_54xc-r0/plugins/sfputil.py
index 5c0f4362ac..586e6e1897 100644
--- a/device/ingrasys/x86_64-ingrasys_s8900_54xc-r0/plugins/sfputil.py
+++ b/device/ingrasys/x86_64-ingrasys_s8900_54xc-r0/plugins/sfputil.py
@@ -3,6 +3,8 @@
# Platform-specific SFP transceiver interface for SONiC
#
+import os
+
try:
import time
from sonic_sfp.sfputilbase import SfpUtilBase
@@ -17,6 +19,7 @@ class SfpUtil(SfpUtilBase):
PORT_END = 53
QSFP_PORT_START = 48
PORTS_IN_BLOCK = 54
+ GPIO_OFFSET = 0
BASE_DIR_PATH = "/sys/class/gpio/gpio{0}/direction"
BASE_VAL_PATH = "/sys/class/gpio/gpio{0}/value"
@@ -79,80 +82,9 @@ class SfpUtil(SfpUtilBase):
53: 71
}
- abs_to_gpio_mapping = {
- 0: 192,
- 1: 193,
- 2: 194,
- 3: 195,
- 4: 196,
- 5: 197,
- 6: 198,
- 7: 199,
- 8: 200,
- 9: 201,
- 10: 202,
- 11: 203,
- 12: 204,
- 13: 205,
- 14: 206,
- 15: 207,
- 16: 176,
- 17: 177,
- 18: 178,
- 19: 179,
- 20: 180,
- 21: 181,
- 22: 182,
- 23: 183,
- 24: 184,
- 25: 185,
- 26: 186,
- 27: 187,
- 28: 188,
- 29: 189,
- 30: 190,
- 31: 191,
- 32: 160,
- 33: 161,
- 34: 162,
- 35: 163,
- 36: 164,
- 37: 165,
- 38: 166,
- 39: 167,
- 40: 168,
- 41: 169,
- 42: 170,
- 43: 171,
- 44: 172,
- 45: 173,
- 46: 174,
- 47: 175,
- 48: 240,
- 49: 241,
- 50: 242,
- 51: 243,
- 52: 244,
- 53: 245
- }
-
- lpmode_to_gpio_mapping = {
- 48: 224,
- 49: 225,
- 50: 226,
- 51: 227,
- 52: 228,
- 53: 229
- }
-
- reset_to_gpio_mapping = {
- 48: 208,
- 49: 209,
- 50: 210,
- 51: 211,
- 52: 212,
- 53: 213
- }
+ abs_to_gpio_mapping = {}
+ lpmode_to_gpio_mapping = {}
+ reset_to_gpio_mapping = {}
@property
def port_start(self):
@@ -174,7 +106,109 @@ class SfpUtil(SfpUtilBase):
def port_to_eeprom_mapping(self):
return self._port_to_eeprom_mapping
+ def set_gpio_offset(self):
+ sys_gpio_dir = "/sys/class/gpio"
+ self.GPIO_OFFSET = 0
+ gpiochip_no = 0
+ for d in os.listdir(sys_gpio_dir):
+ if "gpiochip" in d:
+ try:
+ gpiochip_no = int(d[8:],10)
+ except ValueError as e:
+ print "Error: %s" % str(e)
+ if gpiochip_no > 255:
+ self.GPIO_OFFSET=256
+ return True
+ return True
+
+ def init_abs_to_gpio_mapping(self):
+ self.abs_to_gpio_mapping = {
+ 0: 192+self.GPIO_OFFSET,
+ 1: 193+self.GPIO_OFFSET,
+ 2: 194+self.GPIO_OFFSET,
+ 3: 195+self.GPIO_OFFSET,
+ 4: 196+self.GPIO_OFFSET,
+ 5: 197+self.GPIO_OFFSET,
+ 6: 198+self.GPIO_OFFSET,
+ 7: 199+self.GPIO_OFFSET,
+ 8: 200+self.GPIO_OFFSET,
+ 9: 201+self.GPIO_OFFSET,
+ 10: 202+self.GPIO_OFFSET,
+ 11: 203+self.GPIO_OFFSET,
+ 12: 204+self.GPIO_OFFSET,
+ 13: 205+self.GPIO_OFFSET,
+ 14: 206+self.GPIO_OFFSET,
+ 15: 207+self.GPIO_OFFSET,
+ 16: 176+self.GPIO_OFFSET,
+ 17: 177+self.GPIO_OFFSET,
+ 18: 178+self.GPIO_OFFSET,
+ 19: 179+self.GPIO_OFFSET,
+ 20: 180+self.GPIO_OFFSET,
+ 21: 181+self.GPIO_OFFSET,
+ 22: 182+self.GPIO_OFFSET,
+ 23: 183+self.GPIO_OFFSET,
+ 24: 184+self.GPIO_OFFSET,
+ 25: 185+self.GPIO_OFFSET,
+ 26: 186+self.GPIO_OFFSET,
+ 27: 187+self.GPIO_OFFSET,
+ 28: 188+self.GPIO_OFFSET,
+ 29: 189+self.GPIO_OFFSET,
+ 30: 190+self.GPIO_OFFSET,
+ 31: 191+self.GPIO_OFFSET,
+ 32: 160+self.GPIO_OFFSET,
+ 33: 161+self.GPIO_OFFSET,
+ 34: 162+self.GPIO_OFFSET,
+ 35: 163+self.GPIO_OFFSET,
+ 36: 164+self.GPIO_OFFSET,
+ 37: 165+self.GPIO_OFFSET,
+ 38: 166+self.GPIO_OFFSET,
+ 39: 167+self.GPIO_OFFSET,
+ 40: 168+self.GPIO_OFFSET,
+ 41: 169+self.GPIO_OFFSET,
+ 42: 170+self.GPIO_OFFSET,
+ 43: 171+self.GPIO_OFFSET,
+ 44: 172+self.GPIO_OFFSET,
+ 45: 173+self.GPIO_OFFSET,
+ 46: 174+self.GPIO_OFFSET,
+ 47: 175+self.GPIO_OFFSET,
+ 48: 240+self.GPIO_OFFSET,
+ 49: 241+self.GPIO_OFFSET,
+ 50: 242+self.GPIO_OFFSET,
+ 51: 243+self.GPIO_OFFSET,
+ 52: 244+self.GPIO_OFFSET,
+ 53: 245+self.GPIO_OFFSET
+ }
+ return True
+
+ def init_lpmode_to_gpio_mapping(self):
+ self.lpmode_to_gpio_mapping = {
+ 48: 224+self.GPIO_OFFSET,
+ 49: 225+self.GPIO_OFFSET,
+ 50: 226+self.GPIO_OFFSET,
+ 51: 227+self.GPIO_OFFSET,
+ 52: 228+self.GPIO_OFFSET,
+ 53: 229+self.GPIO_OFFSET
+ }
+ return True
+
+ def init_reset_to_gpio_mapping(self):
+ self.reset_to_gpio_mapping = {
+ 48: 208+self.GPIO_OFFSET,
+ 49: 209+self.GPIO_OFFSET,
+ 50: 210+self.GPIO_OFFSET,
+ 51: 211+self.GPIO_OFFSET,
+ 52: 212+self.GPIO_OFFSET,
+ 53: 213+self.GPIO_OFFSET
+ }
+ return True
+
def __init__(self):
+ # Init abs, lpmode, and reset to gpio mapping
+ self.set_gpio_offset()
+ self.init_abs_to_gpio_mapping()
+ self.init_lpmode_to_gpio_mapping()
+ self.init_reset_to_gpio_mapping()
+
# Override port_to_eeprom_mapping for class initialization
eeprom_path = "/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom"
diff --git a/device/ingrasys/x86_64-ingrasys_s8900_64xc-r0/INGRASYS-S8900-64XC/th-s8900-48x25G+16x100G.config.bcm b/device/ingrasys/x86_64-ingrasys_s8900_64xc-r0/INGRASYS-S8900-64XC/th-s8900-48x25G+16x100G.config.bcm
index 562e584012..f30d4ea6dd 100644
--- a/device/ingrasys/x86_64-ingrasys_s8900_64xc-r0/INGRASYS-S8900-64XC/th-s8900-48x25G+16x100G.config.bcm
+++ b/device/ingrasys/x86_64-ingrasys_s8900_64xc-r0/INGRASYS-S8900-64XC/th-s8900-48x25G+16x100G.config.bcm
@@ -1,12 +1,17 @@
-#2017/05/31
+#2018/03/31
os=unix
oversubscribe_mode=1
-pbmp_xport_xe=0x3d000000ff4003ffffdfffffffe
+pbmp_xport_xe=0x3c000000ff0003ffffdfffffffe
-lpm_scaling_enable=1
-lpm_ipv6_128b_reserved=0
+l3_alpm_enable=2
+ipv6_lpm_128b_enable=1
+l3_mem_entries=40960
+l2_mem_entries=40960
+
+l2xmsg_mode=1
+mmu_lossless=0
#Parity
parity_correction=1
@@ -85,362 +90,359 @@ portmap_104=105:100
portmap_105=109:100
-portmap_66=129:10
-portmap_100=131:10
-
portmap_33=132:10
portmap_67=133:10
portmap_101=134:10
portmap_135=135:10
-serdes_driver_current_xe0=0x9
-serdes_preemphasis_xe0=0x304000
+serdes_driver_current_xe0=0xf
+serdes_preemphasis_xe0=0x003c14
serdes_if_type_xe0=14
-serdes_driver_current_xe1=0x9
-serdes_preemphasis_xe1=0x304000
+serdes_driver_current_xe1=0xf
+serdes_preemphasis_xe1=0x003c1c
serdes_if_type_xe1=14
-serdes_driver_current_xe2=0x9
-serdes_preemphasis_xe2=0x304000
+serdes_driver_current_xe2=0xf
+serdes_preemphasis_xe2=0x003c08
serdes_if_type_xe2=14
-serdes_driver_current_xe3=0x9
-serdes_preemphasis_xe3=0x2c4400
+serdes_driver_current_xe3=0xf
+serdes_preemphasis_xe3=0x003c08
serdes_if_type_xe3=14
-serdes_driver_current_xe4=0x9
-serdes_preemphasis_xe4=0x304000
+serdes_driver_current_xe4=0xf
+serdes_preemphasis_xe4=0x003c08
serdes_if_type_xe4=14
-serdes_driver_current_xe5=0x9
-serdes_preemphasis_xe5=0x304000
+serdes_driver_current_xe5=0xf
+serdes_preemphasis_xe5=0x003c10
serdes_if_type_xe5=14
-serdes_driver_current_xe6=0x9
-serdes_preemphasis_xe6=0x2c4400
+serdes_driver_current_xe6=0xf
+serdes_preemphasis_xe6=0x083c08
serdes_if_type_xe6=14
-serdes_driver_current_xe7=0x9
-serdes_preemphasis_xe7=0x2C4400
+serdes_driver_current_xe7=0xf
+serdes_preemphasis_xe7=0x043c10
serdes_if_type_xe7=14
serdes_driver_current_xe8=0x9
-serdes_preemphasis_xe8=0x2c4400
+serdes_preemphasis_xe8=0x003c08
serdes_if_type_xe8=14
serdes_driver_current_xe9=0x9
-serdes_preemphasis_xe9=0x284800
+serdes_preemphasis_xe9=0x003c08
serdes_if_type_xe9=14
serdes_driver_current_xe10=0x9
-serdes_preemphasis_xe10=0x2C4400
+serdes_preemphasis_xe10=0x003c08
serdes_if_type_xe10=14
serdes_driver_current_xe11=0x9
-serdes_preemphasis_xe11=0x2c4400
+serdes_preemphasis_xe11=0x003c08
serdes_if_type_xe11=14
serdes_driver_current_xe12=0x9
-serdes_preemphasis_xe12=0x2c4400
+serdes_preemphasis_xe12=0x2c4408
serdes_if_type_xe12=14
serdes_driver_current_xe13=0x9
-serdes_preemphasis_xe13=0x2c4400
+serdes_preemphasis_xe13=0x003c08
serdes_if_type_xe13=14
serdes_driver_current_xe14=0x9
-serdes_preemphasis_xe14=0x2c4400
+serdes_preemphasis_xe14=0x003c08
serdes_if_type_xe14=14
serdes_driver_current_xe15=0x9
-serdes_preemphasis_xe15=0x2c4400
+serdes_preemphasis_xe15=0x003c08
serdes_if_type_xe15=14
-serdes_driver_current_xe16=0x9
-serdes_preemphasis_xe16=0x2c4400
+serdes_driver_current_xe16=0xb
+serdes_preemphasis_xe16=0x0c3c08
serdes_if_type_xe16=14
-serdes_driver_current_xe17=0xB
-serdes_preemphasis_xe17=0x304000
+serdes_driver_current_xe17=0xb
+serdes_preemphasis_xe17=0x0c3c10
serdes_if_type_xe17=14
-serdes_driver_current_xe18=0xA
-serdes_preemphasis_xe18=0x2C4400
+serdes_driver_current_xe18=0xa
+serdes_preemphasis_xe18=0x083c08
serdes_if_type_xe18=14
serdes_driver_current_xe19=0x9
-serdes_preemphasis_xe19=0x2C4400
+serdes_preemphasis_xe19=0x0c3c10
serdes_if_type_xe19=14
-serdes_driver_current_xe20=0xA
-serdes_preemphasis_xe20=0x304000
+serdes_driver_current_xe20=0xc
+serdes_preemphasis_xe20=0x043c08
serdes_if_type_xe20=14
serdes_driver_current_xe21=0x9
-serdes_preemphasis_xe21=0x2C4400
+serdes_preemphasis_xe21=0x083c08
serdes_if_type_xe21=14
-serdes_driver_current_xe22=0x9
-serdes_preemphasis_xe22=0x2C4400
+serdes_driver_current_xe22=0xc
+serdes_preemphasis_xe22=0x083c08
serdes_if_type_xe22=14
-serdes_driver_current_xe23=0xC
-serdes_preemphasis_xe23=0x304000
+serdes_driver_current_xe23=0xa
+serdes_preemphasis_xe23=0x083c10
serdes_if_type_xe23=14
-serdes_driver_current_xe24=0xF
-serdes_preemphasis_xe24=0x005100
+serdes_driver_current_xe24=0x9
+serdes_preemphasis_xe24=0x083c08
serdes_if_type_xe24=14
serdes_driver_current_xe25=0x9
-serdes_preemphasis_xe25=0x2C4400
+serdes_preemphasis_xe25=0x043c08
serdes_if_type_xe25=14
serdes_driver_current_xe26=0x9
-serdes_preemphasis_xe26=0x304000
+serdes_preemphasis_xe26=0x003c08
serdes_if_type_xe26=14
-serdes_driver_current_xe27=0x9
-serdes_preemphasis_xe27=0x304000
+serdes_driver_current_xe27=0xc
+serdes_preemphasis_xe27=0x083c08
serdes_if_type_xe27=14
-serdes_driver_current_xe28=0xA
-serdes_preemphasis_xe28=0x2C4400
+serdes_driver_current_xe28=0xa
+serdes_preemphasis_xe28=0x003c10
serdes_if_type_xe28=14
serdes_driver_current_xe29=0x9
-serdes_preemphasis_xe29=0x284800
+serdes_preemphasis_xe29=0x043c10
serdes_if_type_xe29=14
serdes_driver_current_xe30=0x9
-serdes_preemphasis_xe30=0x2C4400
+serdes_preemphasis_xe30=0x003c14
serdes_if_type_xe30=14
-serdes_driver_current_xe31=0xA
-serdes_preemphasis_xe31=0x2C4400
+serdes_driver_current_xe31=0xa
+serdes_preemphasis_xe31=0x003c14
serdes_if_type_xe31=14
serdes_driver_current_xe32=0x9
-serdes_preemphasis_xe32=0x284800
+serdes_preemphasis_xe32=0x003c08
serdes_if_type_xe32=14
serdes_driver_current_xe33=0x7
-serdes_preemphasis_xe33=0x284800
+serdes_preemphasis_xe33=0x003c08
serdes_if_type_xe33=14
serdes_driver_current_xe34=0x9
-serdes_preemphasis_xe34=0x284800
+serdes_preemphasis_xe34=0x003c08
serdes_if_type_xe34=14
serdes_driver_current_xe35=0x9
-serdes_preemphasis_xe35=0x284800
+serdes_preemphasis_xe35=0x003c08
serdes_if_type_xe35=14
serdes_driver_current_xe36=0x9
-serdes_preemphasis_xe36=0x284800
+serdes_preemphasis_xe36=0x003c08
serdes_if_type_xe36=14
serdes_driver_current_xe37=0x9
-serdes_preemphasis_xe37=0x284800
+serdes_preemphasis_xe37=0x003c0c
serdes_if_type_xe37=14
serdes_driver_current_xe38=0x9
-serdes_preemphasis_xe38=0x2C4400
+serdes_preemphasis_xe38=0x003c08
serdes_if_type_xe38=14
serdes_driver_current_xe39=0x9
-serdes_preemphasis_xe39=0x284800
+serdes_preemphasis_xe39=0x003c08
serdes_if_type_xe39=14
-serdes_driver_current_xe40=0xA
-serdes_preemphasis_xe40=0x284800
+serdes_driver_current_xe40=0xa
+serdes_preemphasis_xe40=0x003c10
serdes_if_type_xe40=14
serdes_driver_current_xe41=0x9
-serdes_preemphasis_xe41=0x2C4400
+serdes_preemphasis_xe41=0x003c10
serdes_if_type_xe41=14
-serdes_driver_current_xe42=0x9
-serdes_preemphasis_xe42=0x2C4400
+serdes_driver_current_xe42=0xc
+serdes_preemphasis_xe42=0x083c08
serdes_if_type_xe42=14
-serdes_driver_current_xe43=0xA
-serdes_preemphasis_xe43=0x2E4200
+serdes_driver_current_xe43=0xa
+serdes_preemphasis_xe43=0x003c10
serdes_if_type_xe43=14
-serdes_driver_current_xe44=0xA
-serdes_preemphasis_xe44=0x2E4200
+serdes_driver_current_xe44=0xa
+serdes_preemphasis_xe44=0x003c08
serdes_if_type_xe44=14
-serdes_driver_current_xe45=0xA
-serdes_preemphasis_xe45=0x2C4400
+serdes_driver_current_xe45=0x9
+serdes_preemphasis_xe45=0x003c10
serdes_if_type_xe45=14
serdes_driver_current_xe46=0x9
-serdes_preemphasis_xe46=0x2C4400
+serdes_preemphasis_xe46=0x043c08
serdes_if_type_xe46=14
-serdes_driver_current_xe47=0x9
-serdes_preemphasis_xe47=0x2C4400
+serdes_driver_current_xe47=0xa
+serdes_preemphasis_xe47=0x003c08
serdes_if_type_xe47=14
serdes_driver_current_lane0_ce0=0x9
-serdes_driver_current_lane1_ce0=0xF
+serdes_driver_current_lane1_ce0=0xf
serdes_driver_current_lane2_ce0=0x9
serdes_driver_current_lane3_ce0=0x9
-serdes_preemphasis_lane0_ce0=0x2C4400
-serdes_preemphasis_lane1_ce0=0x343C00
-serdes_preemphasis_lane2_ce0=0x2C4400
-serdes_preemphasis_lane3_ce0=0x2C4400
+serdes_preemphasis_lane0_ce0=0x003c08
+serdes_preemphasis_lane1_ce0=0x003c08
+serdes_preemphasis_lane2_ce0=0x003c08
+serdes_preemphasis_lane3_ce0=0x003c08
serdes_if_type_ce0=14
serdes_driver_current_lane0_ce1=0x9
serdes_driver_current_lane1_ce1=0x9
serdes_driver_current_lane2_ce1=0x9
-serdes_driver_current_lane3_ce1=0xE
-serdes_preemphasis_lane0_ce1=0x284800
-serdes_preemphasis_lane1_ce1=0x284800
-serdes_preemphasis_lane2_ce1=0x2C4400
-serdes_preemphasis_lane3_ce1=0x2C4400
+serdes_driver_current_lane3_ce1=0xe
+serdes_preemphasis_lane0_ce1=0x003c08
+serdes_preemphasis_lane1_ce1=0x003c08
+serdes_preemphasis_lane2_ce1=0x003c08
+serdes_preemphasis_lane3_ce1=0x003c08
serdes_if_type_ce1=14
serdes_driver_current_lane0_ce2=0x9
-serdes_driver_current_lane1_ce2=0xF
+serdes_driver_current_lane1_ce2=0xf
serdes_driver_current_lane2_ce2=0x9
-serdes_driver_current_lane3_ce2=0xD
-serdes_preemphasis_lane0_ce2=0x284800
-serdes_preemphasis_lane1_ce2=0x343C00
-serdes_preemphasis_lane2_ce2=0x284800
-serdes_preemphasis_lane3_ce2=0x304000
+serdes_driver_current_lane3_ce2=0xd
+serdes_preemphasis_lane0_ce2=0x003c08
+serdes_preemphasis_lane1_ce2=0x003c08
+serdes_preemphasis_lane2_ce2=0x003c08
+serdes_preemphasis_lane3_ce2=0x003c08
serdes_if_type_ce2=14
serdes_driver_current_lane0_ce3=0x9
-serdes_driver_current_lane1_ce3=0xD
+serdes_driver_current_lane1_ce3=0xd
serdes_driver_current_lane2_ce3=0x9
-serdes_driver_current_lane3_ce3=0xD
-serdes_preemphasis_lane0_ce3=0x2C4400
-serdes_preemphasis_lane1_ce3=0x304000
-serdes_preemphasis_lane2_ce3=0x2C4400
-serdes_preemphasis_lane3_ce3=0x304000
+serdes_driver_current_lane3_ce3=0xd
+serdes_preemphasis_lane0_ce3=0x003c08
+serdes_preemphasis_lane1_ce3=0x003c08
+serdes_preemphasis_lane2_ce3=0x003c08
+serdes_preemphasis_lane3_ce3=0x003c08
serdes_if_type_ce3=14
serdes_driver_current_lane0_ce4=0x9
serdes_driver_current_lane1_ce4=0x9
serdes_driver_current_lane2_ce4=0x9
-serdes_driver_current_lane3_ce4=0xD
-serdes_preemphasis_lane0_ce4=0x2C4400
-serdes_preemphasis_lane1_ce4=0x2C4400
-serdes_preemphasis_lane2_ce4=0x2C4400
-serdes_preemphasis_lane3_ce4=0x304000
+serdes_driver_current_lane3_ce4=0xd
+serdes_preemphasis_lane0_ce4=0x003c08
+serdes_preemphasis_lane1_ce4=0x003c08
+serdes_preemphasis_lane2_ce4=0x003c08
+serdes_preemphasis_lane3_ce4=0x003c08
serdes_if_type_ce4=14
serdes_driver_current_lane0_ce5=0x9
-serdes_driver_current_lane1_ce5=0xF
+serdes_driver_current_lane1_ce5=0xf
serdes_driver_current_lane2_ce5=0x9
serdes_driver_current_lane3_ce5=0x9
-serdes_preemphasis_lane0_ce5=0x2C4400
-serdes_preemphasis_lane1_ce5=0x383800
-serdes_preemphasis_lane2_ce5=0x2C4400
-serdes_preemphasis_lane3_ce5=0x2C4400
+serdes_preemphasis_lane0_ce5=0x003c08
+serdes_preemphasis_lane1_ce5=0x003c08
+serdes_preemphasis_lane2_ce5=0x003c08
+serdes_preemphasis_lane3_ce5=0x003c08
serdes_if_type_ce5=14
serdes_driver_current_lane0_ce6=0x9
serdes_driver_current_lane1_ce6=0x9
serdes_driver_current_lane2_ce6=0x9
-serdes_driver_current_lane3_ce6=0xE
-serdes_preemphasis_lane0_ce6=0x2C4400
-serdes_preemphasis_lane1_ce6=0x2C4400
-serdes_preemphasis_lane2_ce6=0x2C4400
-serdes_preemphasis_lane3_ce6=0x304000
+serdes_driver_current_lane3_ce6=0xe
+serdes_preemphasis_lane0_ce6=0x003c08
+serdes_preemphasis_lane1_ce6=0x003c08
+serdes_preemphasis_lane2_ce6=0x003c08
+serdes_preemphasis_lane3_ce6=0x003c08
serdes_if_type_ce6=14
serdes_driver_current_lane0_ce7=0x9
-serdes_driver_current_lane1_ce7=0xA
+serdes_driver_current_lane1_ce7=0xa
serdes_driver_current_lane2_ce7=0x9
-serdes_driver_current_lane3_ce7=0XE
-serdes_preemphasis_lane0_ce7=0x284800
-serdes_preemphasis_lane1_ce7=0x304000
-serdes_preemphasis_lane2_ce7=0x2C4400
-serdes_preemphasis_lane3_ce7=0x343C00
+serdes_driver_current_lane3_ce7=0Xe
+serdes_preemphasis_lane0_ce7=0x003c08
+serdes_preemphasis_lane1_ce7=0x003c08
+serdes_preemphasis_lane2_ce7=0x003c08
+serdes_preemphasis_lane3_ce7=0x003c08
serdes_if_type_ce7=14
-serdes_driver_current_lane0_ce8=0x9
-serdes_driver_current_lane1_ce8=0xE
-serdes_driver_current_lane2_ce8=0xF
-serdes_driver_current_lane3_ce8=0xE
-serdes_preemphasis_lane0_ce8=0x2C4400
-serdes_preemphasis_lane1_ce8=0x304000
-serdes_preemphasis_lane2_ce8=0x343C00
-serdes_preemphasis_lane3_ce8=0x304000
+serdes_driver_current_lane0_ce8=0xf
+serdes_driver_current_lane1_ce8=0xf
+serdes_driver_current_lane2_ce8=0xf
+serdes_driver_current_lane3_ce8=0xf
+serdes_preemphasis_lane0_ce8=0x043c08
+serdes_preemphasis_lane1_ce8=0x003c08
+serdes_preemphasis_lane2_ce8=0x043c08
+serdes_preemphasis_lane3_ce8=0x003c08
serdes_if_type_ce8=14
-serdes_driver_current_lane0_ce9=0x9
-serdes_driver_current_lane1_ce9=0xD
-serdes_driver_current_lane2_ce9=0xD
-serdes_driver_current_lane3_ce9=0xF
-serdes_preemphasis_lane0_ce9=0x2C4400
-serdes_preemphasis_lane1_ce9=0x343C00
-serdes_preemphasis_lane2_ce9=0x343C00
-serdes_preemphasis_lane3_ce9=0x343C00
+serdes_driver_current_lane0_ce9=0xf
+serdes_driver_current_lane1_ce9=0xf
+serdes_driver_current_lane2_ce9=0xf
+serdes_driver_current_lane3_ce9=0xf
+serdes_preemphasis_lane0_ce9=0x043c08
+serdes_preemphasis_lane1_ce9=0x043c08
+serdes_preemphasis_lane2_ce9=0x043c08
+serdes_preemphasis_lane3_ce9=0x043c08
serdes_if_type_ce9=14
-serdes_driver_current_lane0_ce10=0xD
-serdes_driver_current_lane1_ce10=0xE
-serdes_driver_current_lane2_ce10=0xD
-serdes_driver_current_lane3_ce10=0xD
-serdes_preemphasis_lane0_ce10=0x343C00
-serdes_preemphasis_lane1_ce10=0x343C00
-serdes_preemphasis_lane2_ce10=0x343C00
-serdes_preemphasis_lane3_ce10=0x343C00
+serdes_driver_current_lane0_ce10=0xf
+serdes_driver_current_lane1_ce10=0xf
+serdes_driver_current_lane2_ce10=0xf
+serdes_driver_current_lane3_ce10=0xf
+serdes_preemphasis_lane0_ce10=0x043c08
+serdes_preemphasis_lane1_ce10=0x083c10
+serdes_preemphasis_lane2_ce10=0x043c08
+serdes_preemphasis_lane3_ce10=0x043c08
serdes_if_type_ce10=14
-serdes_driver_current_lane0_ce11=0xE
-serdes_driver_current_lane1_ce11=0xD
-serdes_driver_current_lane2_ce11=0xD
-serdes_driver_current_lane3_ce11=0xD
-serdes_preemphasis_lane0_ce11=0x343C00
-serdes_preemphasis_lane1_ce11=0x343C00
-serdes_preemphasis_lane2_ce11=0X343C00
-serdes_preemphasis_lane3_ce11=0X343C00
+serdes_driver_current_lane0_ce11=0xf
+serdes_driver_current_lane1_ce11=0xf
+serdes_driver_current_lane2_ce11=0xf
+serdes_driver_current_lane3_ce11=0xf
+serdes_preemphasis_lane0_ce11=0x083c08
+serdes_preemphasis_lane1_ce11=0x043c08
+serdes_preemphasis_lane2_ce11=0X043c08
+serdes_preemphasis_lane3_ce11=0X043c08
serdes_if_type_ce11=14
-serdes_driver_current_lane0_ce12=0xD
-serdes_driver_current_lane1_ce12=0xD
-serdes_driver_current_lane2_ce12=0xD
-serdes_driver_current_lane3_ce12=0xD
-serdes_preemphasis_lane0_ce12=0x343C00
-serdes_preemphasis_lane1_ce12=0x343C00
-serdes_preemphasis_lane2_ce12=0x343C00
-serdes_preemphasis_lane3_ce12=0x343C00
+serdes_driver_current_lane0_ce12=0xf
+serdes_driver_current_lane1_ce12=0xf
+serdes_driver_current_lane2_ce12=0xf
+serdes_driver_current_lane3_ce12=0xf
+serdes_preemphasis_lane0_ce12=0x0c3c08
+serdes_preemphasis_lane1_ce12=0x083c08
+serdes_preemphasis_lane2_ce12=0x0c3c08
+serdes_preemphasis_lane3_ce12=0x083c08
serdes_if_type_ce12=14
-serdes_driver_current_lane0_ce13=0xD
-serdes_driver_current_lane1_ce13=0xD
-serdes_driver_current_lane2_ce13=0xD
-serdes_driver_current_lane3_ce13=0xF
-serdes_preemphasis_lane0_ce13=0x343C00
-serdes_preemphasis_lane1_ce13=0x343C00
-serdes_preemphasis_lane2_ce13=0x343C00
-serdes_preemphasis_lane3_ce13=0x005800
+serdes_driver_current_lane0_ce13=0xf
+serdes_driver_current_lane1_ce13=0xf
+serdes_driver_current_lane2_ce13=0xf
+serdes_driver_current_lane3_ce13=0xf
+serdes_preemphasis_lane0_ce13=0x083c08
+serdes_preemphasis_lane1_ce13=0x0c3c08
+serdes_preemphasis_lane2_ce13=0x083c08
+serdes_preemphasis_lane3_ce13=0x0c3c08
serdes_if_type_ce13=14
-serdes_driver_current_lane0_ce14=0xE
-serdes_driver_current_lane1_ce14=0xD
-serdes_driver_current_lane2_ce14=0xD
-serdes_driver_current_lane3_ce14=0xE
-serdes_preemphasis_lane0_ce14=0x383800
-serdes_preemphasis_lane1_ce14=0x343C00
-serdes_preemphasis_lane2_ce14=0x343C00
-serdes_preemphasis_lane3_ce14=0x383800
+serdes_driver_current_lane0_ce14=0xf
+serdes_driver_current_lane1_ce14=0xf
+serdes_driver_current_lane2_ce14=0xf
+serdes_driver_current_lane3_ce14=0xf
+serdes_preemphasis_lane0_ce14=0x103c10
+serdes_preemphasis_lane1_ce14=0x0c3c08
+serdes_preemphasis_lane2_ce14=0x0c3c08
+serdes_preemphasis_lane3_ce14=0x0c3c08
serdes_if_type_ce14=14
-serdes_driver_current_lane0_ce15=0xD
-serdes_driver_current_lane1_ce15=0xC
-serdes_driver_current_lane2_ce15=0xC
-serdes_driver_current_lane3_ce15=0xF
-serdes_preemphasis_lane0_ce15=0x343C00
-serdes_preemphasis_lane1_ce15=0x304000
-serdes_preemphasis_lane2_ce15=0x304000
-serdes_preemphasis_lane3_ce15=0x005100
+serdes_driver_current_lane0_ce15=0xf
+serdes_driver_current_lane1_ce15=0xf
+serdes_driver_current_lane2_ce15=0xf
+serdes_driver_current_lane3_ce15=0xf
+serdes_preemphasis_lane0_ce15=0x143c08
+serdes_preemphasis_lane1_ce15=0x103c08
+serdes_preemphasis_lane2_ce15=0x103c08
+serdes_preemphasis_lane3_ce15=0x103c08
serdes_if_type_ce15=14
diff --git a/device/ingrasys/x86_64-ingrasys_s9100-r0/plugins/sfputil.py b/device/ingrasys/x86_64-ingrasys_s9100-r0/plugins/sfputil.py
index 377f4109db..849bd13d94 100644
--- a/device/ingrasys/x86_64-ingrasys_s9100-r0/plugins/sfputil.py
+++ b/device/ingrasys/x86_64-ingrasys_s9100-r0/plugins/sfputil.py
@@ -3,6 +3,8 @@
# Platform-specific SFP transceiver interface for SONiC
#
+import os
+
try:
import time
from sonic_sfp.sfputilbase import SfpUtilBase
@@ -16,6 +18,7 @@ class SfpUtil(SfpUtilBase):
PORT_START = 0
PORT_END = 31
PORTS_IN_BLOCK = 32
+ GPIO_OFFSET = 0
BASE_DIR_PATH = "/sys/class/gpio/gpio{0}/direction"
BASE_VAL_PATH = "/sys/class/gpio/gpio{0}/value"
@@ -56,110 +59,9 @@ class SfpUtil(SfpUtilBase):
31: 40
}
- abs_to_gpio_mapping = {
- 0: 241,
- 1: 240,
- 2: 243,
- 3: 242,
- 4: 245,
- 5: 244,
- 6: 247,
- 7: 246,
- 8: 249,
- 9: 248,
- 10: 251,
- 11: 250,
- 12: 253,
- 13: 252,
- 14: 255,
- 15: 254,
- 16: 225,
- 17: 224,
- 18: 227,
- 19: 226,
- 20: 229,
- 21: 228,
- 22: 231,
- 23: 230,
- 24: 233,
- 25: 232,
- 26: 235,
- 27: 234,
- 28: 237,
- 29: 236,
- 30: 239,
- 31: 238
- }
-
- lpmode_to_gpio_mapping = {
- 0: 177,
- 1: 176,
- 2: 179,
- 3: 178,
- 4: 181,
- 5: 180,
- 6: 183,
- 7: 182,
- 8: 185,
- 9: 184,
- 10: 187,
- 11: 186,
- 12: 189,
- 13: 188,
- 14: 191,
- 15: 190,
- 16: 161,
- 17: 160,
- 18: 163,
- 19: 162,
- 20: 165,
- 21: 164,
- 22: 167,
- 23: 166,
- 24: 169,
- 25: 168,
- 26: 171,
- 27: 170,
- 28: 173,
- 29: 172,
- 30: 175,
- 31: 174
- }
-
- reset_to_gpio_mapping = {
- 0: 145,
- 1: 144,
- 2: 147,
- 3: 146,
- 4: 149,
- 5: 148,
- 6: 151,
- 7: 150,
- 8: 153,
- 9: 152,
- 10: 155,
- 11: 154,
- 12: 157,
- 13: 156,
- 14: 159,
- 15: 158,
- 16: 129,
- 17: 128,
- 18: 131,
- 19: 130,
- 20: 133,
- 21: 132,
- 22: 135,
- 23: 134,
- 24: 137,
- 25: 136,
- 26: 139,
- 27: 138,
- 28: 141,
- 29: 140,
- 30: 143,
- 31: 142
- }
+ abs_to_gpio_mapping = {}
+ lpmode_to_gpio_mapping = {}
+ reset_to_gpio_mapping = {}
@property
def port_start(self):
@@ -177,7 +79,139 @@ class SfpUtil(SfpUtilBase):
def port_to_eeprom_mapping(self):
return self._port_to_eeprom_mapping
+ def set_gpio_offset(self):
+ sys_gpio_dir = "/sys/class/gpio"
+ self.GPIO_OFFSET = 0
+ gpiochip_no = 0
+ for d in os.listdir(sys_gpio_dir):
+ if "gpiochip" in d:
+ try:
+ gpiochip_no = int(d[8:],10)
+ except ValueError as e:
+ print "Error: %s" % str(e)
+ if gpiochip_no > 255:
+ self.GPIO_OFFSET=256
+ return True
+ return True
+
+ def init_abs_to_gpio_mapping(self):
+ self.abs_to_gpio_mapping = {
+ 0: 241+self.GPIO_OFFSET,
+ 1: 240+self.GPIO_OFFSET,
+ 2: 243+self.GPIO_OFFSET,
+ 3: 242+self.GPIO_OFFSET,
+ 4: 245+self.GPIO_OFFSET,
+ 5: 244+self.GPIO_OFFSET,
+ 6: 247+self.GPIO_OFFSET,
+ 7: 246+self.GPIO_OFFSET,
+ 8: 249+self.GPIO_OFFSET,
+ 9: 248+self.GPIO_OFFSET,
+ 10: 251+self.GPIO_OFFSET,
+ 11: 250+self.GPIO_OFFSET,
+ 12: 253+self.GPIO_OFFSET,
+ 13: 252+self.GPIO_OFFSET,
+ 14: 255+self.GPIO_OFFSET,
+ 15: 254+self.GPIO_OFFSET,
+ 16: 225+self.GPIO_OFFSET,
+ 17: 224+self.GPIO_OFFSET,
+ 18: 227+self.GPIO_OFFSET,
+ 19: 226+self.GPIO_OFFSET,
+ 20: 229+self.GPIO_OFFSET,
+ 21: 228+self.GPIO_OFFSET,
+ 22: 231+self.GPIO_OFFSET,
+ 23: 230+self.GPIO_OFFSET,
+ 24: 233+self.GPIO_OFFSET,
+ 25: 232+self.GPIO_OFFSET,
+ 26: 235+self.GPIO_OFFSET,
+ 27: 234+self.GPIO_OFFSET,
+ 28: 237+self.GPIO_OFFSET,
+ 29: 236+self.GPIO_OFFSET,
+ 30: 239+self.GPIO_OFFSET,
+ 31: 238+self.GPIO_OFFSET
+ }
+ return True
+
+ def init_lpmode_to_gpio_mapping(self):
+ self.lpmode_to_gpio_mapping = {
+ 0: 177+self.GPIO_OFFSET,
+ 1: 176+self.GPIO_OFFSET,
+ 2: 179+self.GPIO_OFFSET,
+ 3: 178+self.GPIO_OFFSET,
+ 4: 181+self.GPIO_OFFSET,
+ 5: 180+self.GPIO_OFFSET,
+ 6: 183+self.GPIO_OFFSET,
+ 7: 182+self.GPIO_OFFSET,
+ 8: 185+self.GPIO_OFFSET,
+ 9: 184+self.GPIO_OFFSET,
+ 10: 187+self.GPIO_OFFSET,
+ 11: 186+self.GPIO_OFFSET,
+ 12: 189+self.GPIO_OFFSET,
+ 13: 188+self.GPIO_OFFSET,
+ 14: 191+self.GPIO_OFFSET,
+ 15: 190+self.GPIO_OFFSET,
+ 16: 161+self.GPIO_OFFSET,
+ 17: 160+self.GPIO_OFFSET,
+ 18: 163+self.GPIO_OFFSET,
+ 19: 162+self.GPIO_OFFSET,
+ 20: 165+self.GPIO_OFFSET,
+ 21: 164+self.GPIO_OFFSET,
+ 22: 167+self.GPIO_OFFSET,
+ 23: 166+self.GPIO_OFFSET,
+ 24: 169+self.GPIO_OFFSET,
+ 25: 168+self.GPIO_OFFSET,
+ 26: 171+self.GPIO_OFFSET,
+ 27: 170+self.GPIO_OFFSET,
+ 28: 173+self.GPIO_OFFSET,
+ 29: 172+self.GPIO_OFFSET,
+ 30: 175+self.GPIO_OFFSET,
+ 31: 174+self.GPIO_OFFSET
+ }
+ return True
+
+ def init_reset_to_gpio_mapping(self):
+ self.reset_to_gpio_mapping = {
+ 0: 145+self.GPIO_OFFSET,
+ 1: 144+self.GPIO_OFFSET,
+ 2: 147+self.GPIO_OFFSET,
+ 3: 146+self.GPIO_OFFSET,
+ 4: 149+self.GPIO_OFFSET,
+ 5: 148+self.GPIO_OFFSET,
+ 6: 151+self.GPIO_OFFSET,
+ 7: 150+self.GPIO_OFFSET,
+ 8: 153+self.GPIO_OFFSET,
+ 9: 152+self.GPIO_OFFSET,
+ 10: 155+self.GPIO_OFFSET,
+ 11: 154+self.GPIO_OFFSET,
+ 12: 157+self.GPIO_OFFSET,
+ 13: 156+self.GPIO_OFFSET,
+ 14: 159+self.GPIO_OFFSET,
+ 15: 158+self.GPIO_OFFSET,
+ 16: 129+self.GPIO_OFFSET,
+ 17: 128+self.GPIO_OFFSET,
+ 18: 131+self.GPIO_OFFSET,
+ 19: 130+self.GPIO_OFFSET,
+ 20: 133+self.GPIO_OFFSET,
+ 21: 132+self.GPIO_OFFSET,
+ 22: 135+self.GPIO_OFFSET,
+ 23: 134+self.GPIO_OFFSET,
+ 24: 137+self.GPIO_OFFSET,
+ 25: 136+self.GPIO_OFFSET,
+ 26: 139+self.GPIO_OFFSET,
+ 27: 138+self.GPIO_OFFSET,
+ 28: 141+self.GPIO_OFFSET,
+ 29: 140+self.GPIO_OFFSET,
+ 30: 143+self.GPIO_OFFSET,
+ 31: 142+self.GPIO_OFFSET
+ }
+ return True
+
def __init__(self):
+ # Init abs, lpmode, and reset to gpio mapping
+ self.set_gpio_offset()
+ self.init_abs_to_gpio_mapping()
+ self.init_lpmode_to_gpio_mapping()
+ self.init_reset_to_gpio_mapping()
+
# Override port_to_eeprom_mapping for class initialization
eeprom_path = "/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom"
diff --git a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/plugins/sfputil.py b/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/plugins/sfputil.py
index fecb54bf08..72df5bd049 100644
--- a/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/plugins/sfputil.py
+++ b/device/ingrasys/x86_64-ingrasys_s9130_32x-r0/plugins/sfputil.py
@@ -3,6 +3,8 @@
# Platform-specific SFP transceiver interface for SONiC
#
+import os
+
try:
import time
from sonic_sfp.sfputilbase import SfpUtilBase
@@ -23,6 +25,7 @@ class SfpUtil(SfpUtilBase):
LP_MODE_GPIO_BASE_16_31 = 160
RST_GPIO_BASE_0_15 = 144
RST_GPIO_BASE_16_31 = 128
+ GPIO_OFFSET = 0
GPIO_VAL_PATH = "/sys/class/gpio/gpio{0}/value"
@@ -44,8 +47,35 @@ class SfpUtil(SfpUtilBase):
def port_to_eeprom_mapping(self):
return self._port_to_eeprom_mapping
+ def set_gpio_offset(self):
+ sys_gpio_dir = "/sys/class/gpio"
+ self.GPIO_OFFSET = 0
+ gpiochip_no = 0
+ for d in os.listdir(sys_gpio_dir):
+ if "gpiochip" in d:
+ try:
+ gpiochip_no = int(d[8:],10)
+ except ValueError as e:
+ print "Error: %s" % str(e)
+ if gpiochip_no > 255:
+ self.GPIO_OFFSET=256
+ return True
+ return True
+
+ def update_gpio_base(self):
+ self.ABS_GPIO_BASE_0_15 = 240 + self.GPIO_OFFSET
+ self.ABS_GPIO_BASE_16_31 = 224 + self.GPIO_OFFSET
+ self.LP_MODE_GPIO_BASE_0_15 = 176 + self.GPIO_OFFSET
+ self.LP_MODE_GPIO_BASE_16_31 = 160 + self.GPIO_OFFSET
+ self.RST_GPIO_BASE_0_15 = 144 + self.GPIO_OFFSET
+ self.RST_GPIO_BASE_16_31 = 128 + self.GPIO_OFFSET
+ return True
def __init__(self):
+ # Update abs, lpmode, and reset gpio base
+ self.set_gpio_offset()
+ self.update_gpio_base()
+
# Override port_to_eeprom_mapping for class initialization
eeprom_path = '/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom'
for x in range(self.port_start, self.port_end + 1):
diff --git a/device/ingrasys/x86_64-ingrasys_s9180_32x-r0/plugins/psuutil.py b/device/ingrasys/x86_64-ingrasys_s9180_32x-r0/plugins/psuutil.py
index 8a71938826..25cdfb0318 100644
--- a/device/ingrasys/x86_64-ingrasys_s9180_32x-r0/plugins/psuutil.py
+++ b/device/ingrasys/x86_64-ingrasys_s9180_32x-r0/plugins/psuutil.py
@@ -15,9 +15,26 @@ except ImportError as e:
class PsuUtil(PsuBase):
"""Platform-specific PSUutil class"""
+ GPIO_OFFSET = 0
SYS_GPIO_DIR = "/sys/class/gpio/"
+ def set_gpio_offset(self):
+ sys_gpio_dir = "/sys/class/gpio"
+ self.GPIO_OFFSET = 0
+ gpiochip_no = 0
+ for d in os.listdir(sys_gpio_dir):
+ if "gpiochip" in d:
+ try:
+ gpiochip_no = int(d[8:],10)
+ except ValueError as e:
+ print "Error: %s" % str(e)
+ if gpiochip_no > 255:
+ self.GPIO_OFFSET=256
+ return True
+ return True
+
def __init__(self):
+ self.set_gpio_offset()
PsuBase.__init__(self)
@@ -54,7 +71,7 @@ class PsuUtil(PsuBase):
faulty
"""
status = 0
- gpio_path = [ 'gpio99/value', 'gpio96/value' ]
+ gpio_path = [ 'gpio'+str(99+self.GPIO_OFFSET)+'/value', 'gpio'+str(96+self.GPIO_OFFSET)+'/value' ]
attr_path = self.SYS_GPIO_DIR + gpio_path[index-1]
attr_value = self.get_attr_value(attr_path)
@@ -75,7 +92,7 @@ class PsuUtil(PsuBase):
:return: Boolean, True if PSU is plugged, False if not
"""
status = 0
- gpio_path = [ 'gpio100/value', 'gpio97/value' ]
+ gpio_path = [ 'gpio'+str(100+self.GPIO_OFFSET)+'/value', 'gpio'+str(97+self.GPIO_OFFSET)+'/value' ]
attr_path = self.SYS_GPIO_DIR + gpio_path[index-1]
attr_value = self.get_attr_value(attr_path)
diff --git a/device/ingrasys/x86_64-ingrasys_s9180_32x-r0/plugins/sfputil.py b/device/ingrasys/x86_64-ingrasys_s9180_32x-r0/plugins/sfputil.py
index 45be2a0e46..00c5e10e0b 100644
--- a/device/ingrasys/x86_64-ingrasys_s9180_32x-r0/plugins/sfputil.py
+++ b/device/ingrasys/x86_64-ingrasys_s9180_32x-r0/plugins/sfputil.py
@@ -3,6 +3,8 @@
# Platform-specific SFP transceiver interface for SONiC
#
+import os
+
try:
import time
from sonic_sfp.sfputilbase import SfpUtilBase
@@ -17,6 +19,7 @@ class SfpUtil(SfpUtilBase):
PORT_END = 33
SFP_PORT_START = 32
PORTS_IN_BLOCK = 34
+ GPIO_OFFSET = 0
BASE_DIR_PATH = "/sys/class/gpio/gpio{0}/direction"
BASE_VAL_PATH = "/sys/class/gpio/gpio{0}/value"
@@ -59,112 +62,9 @@ class SfpUtil(SfpUtilBase):
33: 46
}
- abs_to_gpio_mapping = {
- 0: 241,
- 1: 240,
- 2: 243,
- 3: 242,
- 4: 245,
- 5: 244,
- 6: 247,
- 7: 246,
- 8: 249,
- 9: 248,
- 10: 251,
- 11: 250,
- 12: 253,
- 13: 252,
- 14: 255,
- 15: 254,
- 16: 225,
- 17: 224,
- 18: 227,
- 19: 226,
- 20: 229,
- 21: 228,
- 22: 231,
- 23: 230,
- 24: 233,
- 25: 232,
- 26: 235,
- 27: 234,
- 28: 237,
- 29: 236,
- 30: 239,
- 31: 238,
- 32: 177,
- 33: 176
- }
-
- lpmode_to_gpio_mapping = {
- 0: 161,
- 1: 160,
- 2: 163,
- 3: 162,
- 4: 165,
- 5: 164,
- 6: 167,
- 7: 166,
- 8: 169,
- 9: 168,
- 10: 171,
- 11: 170,
- 12: 173,
- 13: 172,
- 14: 175,
- 15: 174,
- 16: 145,
- 17: 144,
- 18: 147,
- 19: 146,
- 20: 149,
- 21: 148,
- 22: 151,
- 23: 150,
- 24: 153,
- 25: 152,
- 26: 155,
- 27: 154,
- 28: 157,
- 29: 156,
- 30: 159,
- 31: 158
- }
-
- reset_to_gpio_mapping = {
- 0: 129,
- 1: 128,
- 2: 131,
- 3: 130,
- 4: 133,
- 5: 132,
- 6: 135,
- 7: 134,
- 8: 137,
- 9: 136,
- 10: 139,
- 11: 138,
- 12: 141,
- 13: 140,
- 14: 143,
- 15: 142,
- 16: 113,
- 17: 112,
- 18: 115,
- 19: 114,
- 20: 117,
- 21: 116,
- 22: 119,
- 23: 118,
- 24: 121,
- 25: 120,
- 26: 123,
- 27: 122,
- 28: 125,
- 29: 124,
- 30: 127,
- 31: 126
- }
+ abs_to_gpio_mapping = {}
+ lpmode_to_gpio_mapping = {}
+ reset_to_gpio_mapping = {}
@property
def port_start(self):
@@ -185,7 +85,141 @@ class SfpUtil(SfpUtilBase):
def sfp_port_start(self):
return self.SFP_PORT_START
+ def set_gpio_offset(self):
+ sys_gpio_dir = "/sys/class/gpio"
+ self.GPIO_OFFSET = 0
+ gpiochip_no = 0
+ for d in os.listdir(sys_gpio_dir):
+ if "gpiochip" in d:
+ try:
+ gpiochip_no = int(d[8:],10)
+ except ValueError as e:
+ print "Error: %s" % str(e)
+ if gpiochip_no > 255:
+ self.GPIO_OFFSET=256
+ return True
+ return True
+
+ def init_abs_to_gpio_mapping(self):
+ self.abs_to_gpio_mapping = {
+ 0: 241+self.GPIO_OFFSET,
+ 1: 240+self.GPIO_OFFSET,
+ 2: 243+self.GPIO_OFFSET,
+ 3: 242+self.GPIO_OFFSET,
+ 4: 245+self.GPIO_OFFSET,
+ 5: 244+self.GPIO_OFFSET,
+ 6: 247+self.GPIO_OFFSET,
+ 7: 246+self.GPIO_OFFSET,
+ 8: 249+self.GPIO_OFFSET,
+ 9: 248+self.GPIO_OFFSET,
+ 10: 251+self.GPIO_OFFSET,
+ 11: 250+self.GPIO_OFFSET,
+ 12: 253+self.GPIO_OFFSET,
+ 13: 252+self.GPIO_OFFSET,
+ 14: 255+self.GPIO_OFFSET,
+ 15: 254+self.GPIO_OFFSET,
+ 16: 225+self.GPIO_OFFSET,
+ 17: 224+self.GPIO_OFFSET,
+ 18: 227+self.GPIO_OFFSET,
+ 19: 226+self.GPIO_OFFSET,
+ 20: 229+self.GPIO_OFFSET,
+ 21: 228+self.GPIO_OFFSET,
+ 22: 231+self.GPIO_OFFSET,
+ 23: 230+self.GPIO_OFFSET,
+ 24: 233+self.GPIO_OFFSET,
+ 25: 232+self.GPIO_OFFSET,
+ 26: 235+self.GPIO_OFFSET,
+ 27: 234+self.GPIO_OFFSET,
+ 28: 237+self.GPIO_OFFSET,
+ 29: 236+self.GPIO_OFFSET,
+ 30: 239+self.GPIO_OFFSET,
+ 31: 238+self.GPIO_OFFSET,
+ 32: 177+self.GPIO_OFFSET,
+ 33: 176+self.GPIO_OFFSET
+ }
+ return True
+
+ def init_lpmode_to_gpio_mapping(self):
+ self.lpmode_to_gpio_mapping = {
+ 0: 161+self.GPIO_OFFSET,
+ 1: 160+self.GPIO_OFFSET,
+ 2: 163+self.GPIO_OFFSET,
+ 3: 162+self.GPIO_OFFSET,
+ 4: 165+self.GPIO_OFFSET,
+ 5: 164+self.GPIO_OFFSET,
+ 6: 167+self.GPIO_OFFSET,
+ 7: 166+self.GPIO_OFFSET,
+ 8: 169+self.GPIO_OFFSET,
+ 9: 168+self.GPIO_OFFSET,
+ 10: 171+self.GPIO_OFFSET,
+ 11: 170+self.GPIO_OFFSET,
+ 12: 173+self.GPIO_OFFSET,
+ 13: 172+self.GPIO_OFFSET,
+ 14: 175+self.GPIO_OFFSET,
+ 15: 174+self.GPIO_OFFSET,
+ 16: 145+self.GPIO_OFFSET,
+ 17: 144+self.GPIO_OFFSET,
+ 18: 147+self.GPIO_OFFSET,
+ 19: 146+self.GPIO_OFFSET,
+ 20: 149+self.GPIO_OFFSET,
+ 21: 148+self.GPIO_OFFSET,
+ 22: 151+self.GPIO_OFFSET,
+ 23: 150+self.GPIO_OFFSET,
+ 24: 153+self.GPIO_OFFSET,
+ 25: 152+self.GPIO_OFFSET,
+ 26: 155+self.GPIO_OFFSET,
+ 27: 154+self.GPIO_OFFSET,
+ 28: 157+self.GPIO_OFFSET,
+ 29: 156+self.GPIO_OFFSET,
+ 30: 159+self.GPIO_OFFSET,
+ 31: 158+self.GPIO_OFFSET
+ }
+ return True
+
+ def init_reset_to_gpio_mapping(self):
+ self.reset_to_gpio_mapping = {
+ 0: 129+self.GPIO_OFFSET,
+ 1: 128+self.GPIO_OFFSET,
+ 2: 131+self.GPIO_OFFSET,
+ 3: 130+self.GPIO_OFFSET,
+ 4: 133+self.GPIO_OFFSET,
+ 5: 132+self.GPIO_OFFSET,
+ 6: 135+self.GPIO_OFFSET,
+ 7: 134+self.GPIO_OFFSET,
+ 8: 137+self.GPIO_OFFSET,
+ 9: 136+self.GPIO_OFFSET,
+ 10: 139+self.GPIO_OFFSET,
+ 11: 138+self.GPIO_OFFSET,
+ 12: 141+self.GPIO_OFFSET,
+ 13: 140+self.GPIO_OFFSET,
+ 14: 143+self.GPIO_OFFSET,
+ 15: 142+self.GPIO_OFFSET,
+ 16: 113+self.GPIO_OFFSET,
+ 17: 112+self.GPIO_OFFSET,
+ 18: 115+self.GPIO_OFFSET,
+ 19: 114+self.GPIO_OFFSET,
+ 20: 117+self.GPIO_OFFSET,
+ 21: 116+self.GPIO_OFFSET,
+ 22: 119+self.GPIO_OFFSET,
+ 23: 118+self.GPIO_OFFSET,
+ 24: 121+self.GPIO_OFFSET,
+ 25: 120+self.GPIO_OFFSET,
+ 26: 123+self.GPIO_OFFSET,
+ 27: 122+self.GPIO_OFFSET,
+ 28: 125+self.GPIO_OFFSET,
+ 29: 124+self.GPIO_OFFSET,
+ 30: 127+self.GPIO_OFFSET,
+ 31: 126+self.GPIO_OFFSET
+ }
+ return True
+
def __init__(self):
+ # Init abs, lpmode, and reset to gpio mapping
+ self.set_gpio_offset()
+ self.init_abs_to_gpio_mapping()
+ self.init_lpmode_to_gpio_mapping()
+ self.init_reset_to_gpio_mapping()
+
# Override port_to_eeprom_mapping for class initialization
eeprom_path = "/sys/class/i2c-adapter/i2c-{0}/{0}-0050/eeprom"
diff --git a/device/ingrasys/x86_64-ingrasys_s9200_64x-r0/INGRASYS-S9200-64X/port_config.ini b/device/ingrasys/x86_64-ingrasys_s9200_64x-r0/INGRASYS-S9200-64X/port_config.ini
index f1127a5aa0..c1d2642fab 100644
--- a/device/ingrasys/x86_64-ingrasys_s9200_64x-r0/INGRASYS-S9200-64X/port_config.ini
+++ b/device/ingrasys/x86_64-ingrasys_s9200_64x-r0/INGRASYS-S9200-64X/port_config.ini
@@ -1,48 +1,48 @@
# name lanes alias index
-Ethernet0 1,2,3,4 Ethernet1/1 0
-Ethernet4 5,6,7,8 Ethernet2/1 1
-Ethernet8 17,18,19,20 Ethernet3/1 2
-Ethernet12 21,22,23,24 Ethernet4/1 3
-Ethernet16 33,34,35,36 Ethernet5/1 4
-Ethernet20 37,38,39,40 Ethernet6/1 5
-Ethernet24 49,50,51,52 Ethernet7/1 6
-Ethernet28 53,54,55,56 Ethernet8/1 7
-Ethernet32 65,66,67,68 Ethernet9/1 8
-Ethernet36 69,70,71,72 Ethernet10/1 9
-Ethernet40 81,82,83,84 Ethernet11/1 10
-Ethernet44 85,86,87,88 Ethernet12/1 11
+Ethernet0 49,50,51,52 Ethernet1/1 0
+Ethernet4 53,54,55,56 Ethernet2/1 1
+Ethernet8 65,66,67,68 Ethernet3/1 2
+Ethernet12 69,70,71,72 Ethernet4/1 3
+Ethernet16 81,82,83,84 Ethernet5/1 4
+Ethernet20 85,86,87,88 Ethernet6/1 5
+Ethernet24 1,2,3,4 Ethernet7/1 6
+Ethernet28 5,6,7,8 Ethernet8/1 7
+Ethernet32 17,18,19,20 Ethernet9/1 8
+Ethernet36 21,22,23,24 Ethernet10/1 9
+Ethernet40 33,34,35,36 Ethernet11/1 10
+Ethernet44 37,38,39,40 Ethernet12/1 11
Ethernet48 97,98,99,100 Ethernet13/1 12
Ethernet52 101,102,103,104 Ethernet14/1 13
Ethernet56 113,114,115,116 Ethernet15/1 14
-Ethernet60 117,118,119,120 Ethernet16/1 15
+Ethernet60 117,118,119,120 Ethernet16/1 15
Ethernet64 129,130,131,132 Ethernet17/1 16
Ethernet68 133,134,135,136 Ethernet18/1 17
Ethernet72 145,146,147,148 Ethernet19/1 18
Ethernet76 149,150,151,152 Ethernet20/1 19
-Ethernet80 161,162,163,164 Ethernet21/1 20
-Ethernet84 165,166,167,168 Ethernet22/1 21
-Ethernet88 177,178,179,180 Ethernet23/1 22
-Ethernet92 181,182,183,184 Ethernet24/1 23
-Ethernet96 193,194,195,196 Ethernet25/1 24
-Ethernet100 197,198,199,200 Ethernet26/1 25
-Ethernet104 209,210,211,212 Ethernet27/1 26
-Ethernet108 213,214,215,216 Ethernet28/1 27
-Ethernet112 225,226,227,228 Ethernet29/1 28
-Ethernet116 229,230,231,232 Ethernet30/1 29
-Ethernet120 241,242,243,244 Ethernet31/1 30
-Ethernet124 245,246,247,248 Ethernet32/1 31
-Ethernet128 9,10,11,12 Ethernet33/1 32
-Ethernet132 13,14,15,16 Ethernet34/1 33
-Ethernet136 25,26,27,28 Ethernet35/1 34
-Ethernet140 29,30,31,32 Ethernet36/1 35
-Ethernet144 41,42,43,44 Ethernet37/1 36
-Ethernet148 45,46,47,48 Ethernet38/1 37
-Ethernet152 57,58,59,60 Ethernet39/1 38
-Ethernet156 61,62,63,64 Ethernet40/1 39
-Ethernet160 73,74,75,76 Ethernet41/1 40
-Ethernet164 77,78,79,80 Ethernet42/1 41
-Ethernet168 89,90,91,92 Ethernet43/1 42
-Ethernet172 93,94,95,96 Ethernet44/1 43
+Ethernet80 209,210,211,212 Ethernet21/1 20
+Ethernet84 213,214,215,216 Ethernet22/1 21
+Ethernet88 225,226,227,228 Ethernet23/1 22
+Ethernet92 229,230,231,232 Ethernet24/1 23
+Ethernet96 241,242,243,244 Ethernet25/1 24
+Ethernet100 245,246,247,248 Ethernet26/1 25
+Ethernet104 161,162,163,164 Ethernet27/1 26
+Ethernet108 165,166,167,168 Ethernet28/1 27
+Ethernet112 177,178,179,180 Ethernet29/1 28
+Ethernet116 181,182,183,184 Ethernet30/1 29
+Ethernet120 193,194,195,196 Ethernet31/1 30
+Ethernet124 197,198,199,200 Ethernet32/1 31
+Ethernet128 57,58,59,60 Ethernet33/1 32
+Ethernet132 61,62,63,64 Ethernet34/1 33
+Ethernet136 73,74,75,76 Ethernet35/1 34
+Ethernet140 77,78,79,80 Ethernet36/1 35
+Ethernet144 89,90,91,92 Ethernet37/1 36
+Ethernet148 93,94,95,96 Ethernet38/1 37
+Ethernet152 9,10,11,12 Ethernet39/1 38
+Ethernet156 13,14,15,16 Ethernet40/1 39
+Ethernet160 25,26,27,28 Ethernet41/1 40
+Ethernet164 29,30,31,32 Ethernet42/1 41
+Ethernet168 41,42,43,44 Ethernet43/1 42
+Ethernet172 45,46,47,48 Ethernet44/1 43
Ethernet176 105,106,107,108 Ethernet45/1 44
Ethernet180 109,110,111,112 Ethernet46/1 45
Ethernet184 121,122,123,124 Ethernet47/1 46
@@ -51,15 +51,15 @@ Ethernet192 137,138,139,140 Ethernet49/1 48
Ethernet196 141,142,143,144 Ethernet50/1 49
Ethernet200 153,154,155,156 Ethernet51/1 50
Ethernet204 157,158,159,160 Ethernet52/1 51
-Ethernet208 169,170,171,172 Ethernet53/1 52
-Ethernet212 173,174,175,176 Ethernet54/1 53
-Ethernet216 185,186,187,188 Ethernet55/1 54
-Ethernet220 189,190,191,192 Ethernet56/1 55
-Ethernet224 201,202,203,204 Ethernet57/1 56
-Ethernet228 205,206,207,208 Ethernet58/1 57
-Ethernet232 217,218,219,220 Ethernet59/1 58
-Ethernet236 221,222,223,224 Ethernet60/1 59
-Ethernet240 233,234,235,236 Ethernet61/1 60
-Ethernet244 237,238,239,240 Ethernet62/1 61
-Ethernet248 249,250,251,252 Ethernet63/1 62
-Ethernet252 253,254,255,256 Ethernet64/1 63
+Ethernet208 217,218,219,220 Ethernet53/1 52
+Ethernet212 221,222,223,224 Ethernet54/1 53
+Ethernet216 233,234,235,236 Ethernet55/1 54
+Ethernet220 237,238,239,240 Ethernet56/1 55
+Ethernet224 249,250,251,252 Ethernet57/1 56
+Ethernet228 253,254,255,256 Ethernet58/1 57
+Ethernet232 169,170,171,172 Ethernet59/1 58
+Ethernet236 173,174,175,176 Ethernet60/1 59
+Ethernet240 185,186,187,188 Ethernet61/1 60
+Ethernet244 189,190,191,192 Ethernet62/1 61
+Ethernet248 201,202,203,204 Ethernet63/1 62
+Ethernet252 205,206,207,208 Ethernet64/1 63
diff --git a/device/ingrasys/x86_64-ingrasys_s9200_64x-r0/INGRASYS-S9200-64X/sai.profile b/device/ingrasys/x86_64-ingrasys_s9200_64x-r0/INGRASYS-S9200-64X/sai.profile
index 20bbcc6a07..5404ca338f 100644
--- a/device/ingrasys/x86_64-ingrasys_s9200_64x-r0/INGRASYS-S9200-64X/sai.profile
+++ b/device/ingrasys/x86_64-ingrasys_s9200_64x-r0/INGRASYS-S9200-64X/sai.profile
@@ -1 +1 @@
-SAI_INIT_CONFIG_FILE=/etc/bcm/th2-s9200-64x100G.config.bcm
+SAI_INIT_CONFIG_FILE=/usr/share/sonic/hwsku/th2-s9200-64x100G.config.bcm
diff --git a/device/ingrasys/x86_64-ingrasys_s9200_64x-r0/INGRASYS-S9200-64X/th2-s9200-64x100G.config.bcm b/device/ingrasys/x86_64-ingrasys_s9200_64x-r0/INGRASYS-S9200-64X/th2-s9200-64x100G.config.bcm
new file mode 100644
index 0000000000..b143fb425b
--- /dev/null
+++ b/device/ingrasys/x86_64-ingrasys_s9200_64x-r0/INGRASYS-S9200-64X/th2-s9200-64x100G.config.bcm
@@ -0,0 +1,873 @@
+#2018/3/6
+
+os=unix
+
+oversubscribe_mode=1
+pbmp_xport_xe=0x3fffd0000ffff40003fffc0001fffe
+
+#ALPM enable
+l3_alpm_enable=2
+ipv6_lpm_128b_enable=1
+l3_mem_entries=40960
+l2_mem_entries=40960
+
+#Parity
+parity_correction=1
+parity_enable=1
+
+l2xmsg_mode=1
+mmu_lossless=0
+
+# core_clock_frequency can be 1125, 850, 765, 672, 645 or 545
+#core_clock_frequency=1125
+
+
+#PIPE-0
+#FC 0
+portmap_1=1:100
+phy_chain_tx_polarity_flip_physical{1.0}=0
+phy_chain_tx_polarity_flip_physical{2.0}=1
+phy_chain_tx_polarity_flip_physical{3.0}=0
+phy_chain_tx_polarity_flip_physical{4.0}=0
+phy_chain_rx_polarity_flip_physical{1.0}=1
+phy_chain_rx_polarity_flip_physical{2.0}=1
+phy_chain_rx_polarity_flip_physical{3.0}=0
+phy_chain_rx_polarity_flip_physical{4.0}=1
+phy_chain_tx_lane_map_physical{1.0}=0x3210
+phy_chain_rx_lane_map_physical{1.0}=0x0312
+
+#FC 1
+portmap_2=5:100
+phy_chain_tx_polarity_flip_physical{5.0}=1
+phy_chain_tx_polarity_flip_physical{6.0}=1
+phy_chain_tx_polarity_flip_physical{7.0}=0
+phy_chain_tx_polarity_flip_physical{8.0}=0
+phy_chain_rx_polarity_flip_physical{5.0}=1
+phy_chain_rx_polarity_flip_physical{6.0}=0
+phy_chain_rx_polarity_flip_physical{7.0}=1
+phy_chain_rx_polarity_flip_physical{8.0}=1
+phy_chain_tx_lane_map_physical{5.0}=0x1023
+phy_chain_rx_lane_map_physical{5.0}=0x2103
+
+#FC 2
+portmap_3=9:100
+phy_chain_tx_polarity_flip_physical{9.0}=0
+phy_chain_tx_polarity_flip_physical{10.0}=0
+phy_chain_tx_polarity_flip_physical{11.0}=1
+phy_chain_tx_polarity_flip_physical{12.0}=1
+phy_chain_rx_polarity_flip_physical{9.0}=1
+phy_chain_rx_polarity_flip_physical{10.0}=1
+phy_chain_rx_polarity_flip_physical{11.0}=0
+phy_chain_rx_polarity_flip_physical{12.0}=1
+phy_chain_tx_lane_map_physical{9.0}=0x3201
+phy_chain_rx_lane_map_physical{9.0}=0x1320
+
+#FC 3
+portmap_4=13:100
+phy_chain_tx_polarity_flip_physical{13.0}=0
+phy_chain_tx_polarity_flip_physical{14.0}=0
+phy_chain_tx_polarity_flip_physical{15.0}=0
+phy_chain_tx_polarity_flip_physical{16.0}=1
+phy_chain_rx_polarity_flip_physical{13.0}=0
+phy_chain_rx_polarity_flip_physical{14.0}=0
+phy_chain_rx_polarity_flip_physical{15.0}=0
+phy_chain_rx_polarity_flip_physical{16.0}=0
+phy_chain_tx_lane_map_physical{13.0}=0x2013
+phy_chain_rx_lane_map_physical{13.0}=0x2310
+
+#FC 4
+portmap_5=17:100
+phy_chain_tx_polarity_flip_physical{17.0}=1
+phy_chain_tx_polarity_flip_physical{18.0}=0
+phy_chain_tx_polarity_flip_physical{19.0}=0
+phy_chain_tx_polarity_flip_physical{20.0}=0
+phy_chain_rx_polarity_flip_physical{17.0}=0
+phy_chain_rx_polarity_flip_physical{18.0}=1
+phy_chain_rx_polarity_flip_physical{19.0}=1
+phy_chain_rx_polarity_flip_physical{20.0}=1
+phy_chain_tx_lane_map_physical{17.0}=0x0213
+phy_chain_rx_lane_map_physical{17.0}=0x0132
+
+#FC 5
+portmap_6=21:100
+phy_chain_tx_polarity_flip_physical{21.0}=1
+phy_chain_tx_polarity_flip_physical{22.0}=1
+phy_chain_tx_polarity_flip_physical{23.0}=0
+phy_chain_tx_polarity_flip_physical{24.0}=0
+phy_chain_rx_polarity_flip_physical{21.0}=1
+phy_chain_rx_polarity_flip_physical{22.0}=0
+phy_chain_rx_polarity_flip_physical{23.0}=0
+phy_chain_rx_polarity_flip_physical{24.0}=1
+phy_chain_tx_lane_map_physical{21.0}=0x3021
+phy_chain_rx_lane_map_physical{21.0}=0x0312
+
+#FC 6
+portmap_7=25:100
+phy_chain_tx_polarity_flip_physical{25.0}=0
+phy_chain_tx_polarity_flip_physical{26.0}=0
+phy_chain_tx_polarity_flip_physical{27.0}=0
+phy_chain_tx_polarity_flip_physical{28.0}=0
+phy_chain_rx_polarity_flip_physical{25.0}=0
+phy_chain_rx_polarity_flip_physical{26.0}=0
+phy_chain_rx_polarity_flip_physical{27.0}=0
+phy_chain_rx_polarity_flip_physical{28.0}=0
+phy_chain_tx_lane_map_physical{25.0}=0x2310
+phy_chain_rx_lane_map_physical{25.0}=0x1302
+
+#FC 7
+portmap_8=29:100
+phy_chain_tx_polarity_flip_physical{29.0}=0
+phy_chain_tx_polarity_flip_physical{30.0}=0
+phy_chain_tx_polarity_flip_physical{31.0}=0
+phy_chain_tx_polarity_flip_physical{32.0}=1
+phy_chain_rx_polarity_flip_physical{29.0}=0
+phy_chain_rx_polarity_flip_physical{30.0}=0
+phy_chain_rx_polarity_flip_physical{31.0}=1
+phy_chain_rx_polarity_flip_physical{32.0}=0
+phy_chain_tx_lane_map_physical{29.0}=0x2031
+phy_chain_rx_lane_map_physical{29.0}=0x2310
+
+#FC 8
+portmap_9=33:100
+phy_chain_tx_polarity_flip_physical{33.0}=1
+phy_chain_tx_polarity_flip_physical{34.0}=1
+phy_chain_tx_polarity_flip_physical{35.0}=0
+phy_chain_tx_polarity_flip_physical{36.0}=1
+phy_chain_rx_polarity_flip_physical{33.0}=1
+phy_chain_rx_polarity_flip_physical{34.0}=0
+phy_chain_rx_polarity_flip_physical{35.0}=0
+phy_chain_rx_polarity_flip_physical{36.0}=0
+phy_chain_tx_lane_map_physical{33.0}=0x3120
+phy_chain_rx_lane_map_physical{33.0}=0x2130
+
+#FC 9
+portmap_10=37:100
+phy_chain_tx_polarity_flip_physical{37.0}=1
+phy_chain_tx_polarity_flip_physical{38.0}=1
+phy_chain_tx_polarity_flip_physical{39.0}=1
+phy_chain_tx_polarity_flip_physical{40.0}=1
+phy_chain_rx_polarity_flip_physical{37.0}=0
+phy_chain_rx_polarity_flip_physical{38.0}=1
+phy_chain_rx_polarity_flip_physical{39.0}=0
+phy_chain_rx_polarity_flip_physical{40.0}=0
+phy_chain_tx_lane_map_physical{37.0}=0x0123
+phy_chain_rx_lane_map_physical{37.0}=0x1230
+
+#FC 10
+portmap_11=41:100
+phy_chain_tx_polarity_flip_physical{41.0}=1
+phy_chain_tx_polarity_flip_physical{42.0}=1
+phy_chain_tx_polarity_flip_physical{43.0}=0
+phy_chain_tx_polarity_flip_physical{44.0}=0
+phy_chain_rx_polarity_flip_physical{41.0}=1
+phy_chain_rx_polarity_flip_physical{42.0}=0
+phy_chain_rx_polarity_flip_physical{43.0}=0
+phy_chain_rx_polarity_flip_physical{44.0}=0
+phy_chain_tx_lane_map_physical{41.0}=0x3021
+phy_chain_rx_lane_map_physical{41.0}=0x1230
+
+#FC 11
+portmap_12=45:100
+phy_chain_tx_polarity_flip_physical{45.0}=0
+phy_chain_tx_polarity_flip_physical{46.0}=1
+phy_chain_tx_polarity_flip_physical{47.0}=1
+phy_chain_tx_polarity_flip_physical{48.0}=1
+phy_chain_rx_polarity_flip_physical{45.0}=0
+phy_chain_rx_polarity_flip_physical{46.0}=1
+phy_chain_rx_polarity_flip_physical{47.0}=1
+phy_chain_rx_polarity_flip_physical{48.0}=1
+phy_chain_tx_lane_map_physical{45.0}=0x0123
+phy_chain_rx_lane_map_physical{45.0}=0x0213
+
+#FC 12
+portmap_13=49:100
+phy_chain_tx_polarity_flip_physical{49.0}=1
+phy_chain_tx_polarity_flip_physical{50.0}=0
+phy_chain_tx_polarity_flip_physical{51.0}=1
+phy_chain_tx_polarity_flip_physical{52.0}=0
+phy_chain_rx_polarity_flip_physical{49.0}=1
+phy_chain_rx_polarity_flip_physical{50.0}=1
+phy_chain_rx_polarity_flip_physical{51.0}=1
+phy_chain_rx_polarity_flip_physical{52.0}=0
+phy_chain_tx_lane_map_physical{49.0}=0x0213
+phy_chain_rx_lane_map_physical{49.0}=0x0123
+
+#FC 13
+portmap_14=53:100
+phy_chain_tx_polarity_flip_physical{53.0}=1
+phy_chain_tx_polarity_flip_physical{54.0}=1
+phy_chain_tx_polarity_flip_physical{55.0}=0
+phy_chain_tx_polarity_flip_physical{56.0}=1
+phy_chain_rx_polarity_flip_physical{53.0}=0
+phy_chain_rx_polarity_flip_physical{54.0}=1
+phy_chain_rx_polarity_flip_physical{55.0}=1
+phy_chain_rx_polarity_flip_physical{56.0}=1
+phy_chain_tx_lane_map_physical{53.0}=0x2031
+phy_chain_rx_lane_map_physical{53.0}=0x0132
+
+#FC 14
+portmap_15=57:100
+phy_chain_tx_polarity_flip_physical{57.0}=1
+phy_chain_tx_polarity_flip_physical{58.0}=0
+phy_chain_tx_polarity_flip_physical{59.0}=0
+phy_chain_tx_polarity_flip_physical{60.0}=0
+phy_chain_rx_polarity_flip_physical{57.0}=0
+phy_chain_rx_polarity_flip_physical{58.0}=0
+phy_chain_rx_polarity_flip_physical{59.0}=0
+phy_chain_rx_polarity_flip_physical{60.0}=0
+phy_chain_tx_lane_map_physical{57.0}=0x3021
+phy_chain_rx_lane_map_physical{57.0}=0x2103
+
+#FC 15
+portmap_16=61:100
+phy_chain_tx_polarity_flip_physical{61.0}=0
+phy_chain_tx_polarity_flip_physical{62.0}=0
+phy_chain_tx_polarity_flip_physical{63.0}=0
+phy_chain_tx_polarity_flip_physical{64.0}=1
+phy_chain_rx_polarity_flip_physical{61.0}=0
+phy_chain_rx_polarity_flip_physical{62.0}=1
+phy_chain_rx_polarity_flip_physical{63.0}=1
+phy_chain_rx_polarity_flip_physical{64.0}=1
+phy_chain_tx_lane_map_physical{61.0}=0x0132
+phy_chain_rx_lane_map_physical{61.0}=0x1320
+
+#PIPE-1
+#FC 16
+portmap_34=65:100
+phy_chain_tx_polarity_flip_physical{65.0}=1
+phy_chain_tx_polarity_flip_physical{66.0}=1
+phy_chain_tx_polarity_flip_physical{67.0}=1
+phy_chain_tx_polarity_flip_physical{68.0}=1
+phy_chain_rx_polarity_flip_physical{65.0}=0
+phy_chain_rx_polarity_flip_physical{66.0}=0
+phy_chain_rx_polarity_flip_physical{67.0}=1
+phy_chain_rx_polarity_flip_physical{68.0}=0
+phy_chain_tx_lane_map_physical{65.0}=0x2031
+phy_chain_rx_lane_map_physical{65.0}=0x2031
+
+#FC 17
+portmap_35=69:100
+phy_chain_tx_polarity_flip_physical{69.0}=1
+phy_chain_tx_polarity_flip_physical{70.0}=0
+phy_chain_tx_polarity_flip_physical{71.0}=0
+phy_chain_tx_polarity_flip_physical{72.0}=1
+phy_chain_rx_polarity_flip_physical{69.0}=1
+phy_chain_rx_polarity_flip_physical{70.0}=0
+phy_chain_rx_polarity_flip_physical{71.0}=0
+phy_chain_rx_polarity_flip_physical{72.0}=1
+phy_chain_tx_lane_map_physical{69.0}=0x2031
+phy_chain_rx_lane_map_physical{69.0}=0x3201
+
+#FC 18
+portmap_36=73:100
+phy_chain_tx_polarity_flip_physical{73.0}=0
+phy_chain_tx_polarity_flip_physical{74.0}=0
+phy_chain_tx_polarity_flip_physical{75.0}=1
+phy_chain_tx_polarity_flip_physical{76.0}=0
+phy_chain_rx_polarity_flip_physical{73.0}=1
+phy_chain_rx_polarity_flip_physical{74.0}=1
+phy_chain_rx_polarity_flip_physical{75.0}=0
+phy_chain_rx_polarity_flip_physical{76.0}=0
+phy_chain_tx_lane_map_physical{73.0}=0x3120
+phy_chain_rx_lane_map_physical{73.0}=0x3201
+
+#FC 19
+portmap_37=77:100
+phy_chain_tx_polarity_flip_physical{77.0}=1
+phy_chain_tx_polarity_flip_physical{78.0}=0
+phy_chain_tx_polarity_flip_physical{79.0}=1
+phy_chain_tx_polarity_flip_physical{80.0}=0
+phy_chain_rx_polarity_flip_physical{77.0}=1
+phy_chain_rx_polarity_flip_physical{78.0}=0
+phy_chain_rx_polarity_flip_physical{79.0}=1
+phy_chain_rx_polarity_flip_physical{80.0}=0
+phy_chain_tx_lane_map_physical{77.0}=0x0132
+phy_chain_rx_lane_map_physical{77.0}=0x1032
+
+#FC 20
+portmap_38=81:100
+phy_chain_tx_polarity_flip_physical{81.0}=1
+phy_chain_tx_polarity_flip_physical{82.0}=0
+phy_chain_tx_polarity_flip_physical{83.0}=1
+phy_chain_tx_polarity_flip_physical{84.0}=0
+phy_chain_rx_polarity_flip_physical{81.0}=0
+phy_chain_rx_polarity_flip_physical{82.0}=1
+phy_chain_rx_polarity_flip_physical{83.0}=1
+phy_chain_rx_polarity_flip_physical{84.0}=1
+phy_chain_tx_lane_map_physical{81.0}=0x0213
+phy_chain_rx_lane_map_physical{81.0}=0x1203
+
+#FC 21
+portmap_39=85:100
+phy_chain_tx_polarity_flip_physical{85.0}=1
+phy_chain_tx_polarity_flip_physical{86.0}=1
+phy_chain_tx_polarity_flip_physical{87.0}=0
+phy_chain_tx_polarity_flip_physical{88.0}=0
+phy_chain_rx_polarity_flip_physical{85.0}=0
+phy_chain_rx_polarity_flip_physical{86.0}=1
+phy_chain_rx_polarity_flip_physical{87.0}=0
+phy_chain_rx_polarity_flip_physical{88.0}=1
+phy_chain_tx_lane_map_physical{85.0}=0x3021
+phy_chain_rx_lane_map_physical{85.0}=0x1230
+
+#FC 22
+portmap_40=89:100
+phy_chain_tx_polarity_flip_physical{89.0}=1
+phy_chain_tx_polarity_flip_physical{90.0}=0
+phy_chain_tx_polarity_flip_physical{91.0}=0
+phy_chain_tx_polarity_flip_physical{92.0}=0
+phy_chain_rx_polarity_flip_physical{89.0}=1
+phy_chain_rx_polarity_flip_physical{90.0}=1
+phy_chain_rx_polarity_flip_physical{91.0}=0
+phy_chain_rx_polarity_flip_physical{92.0}=0
+phy_chain_tx_lane_map_physical{89.0}=0x3021
+phy_chain_rx_lane_map_physical{89.0}=0x3201
+
+#FC 23
+portmap_41=93:100
+phy_chain_tx_polarity_flip_physical{93.0}=0
+phy_chain_tx_polarity_flip_physical{94.0}=0
+phy_chain_tx_polarity_flip_physical{95.0}=1
+phy_chain_tx_polarity_flip_physical{96.0}=0
+phy_chain_rx_polarity_flip_physical{93.0}=1
+phy_chain_rx_polarity_flip_physical{94.0}=0
+phy_chain_rx_polarity_flip_physical{95.0}=1
+phy_chain_rx_polarity_flip_physical{96.0}=0
+phy_chain_tx_lane_map_physical{93.0}=0x1023
+phy_chain_rx_lane_map_physical{93.0}=0x1032
+
+#FC 24
+portmap_42=97:100
+phy_chain_tx_polarity_flip_physical{97.0}=0
+phy_chain_tx_polarity_flip_physical{98.0}=1
+phy_chain_tx_polarity_flip_physical{99.0}=1
+phy_chain_tx_polarity_flip_physical{100.0}=0
+phy_chain_rx_polarity_flip_physical{97.0}=0
+phy_chain_rx_polarity_flip_physical{98.0}=0
+phy_chain_rx_polarity_flip_physical{99.0}=0
+phy_chain_rx_polarity_flip_physical{100.0}=1
+phy_chain_tx_lane_map_physical{97.0}=0x0132
+phy_chain_rx_lane_map_physical{97.0}=0x1320
+
+#FC 25
+portmap_43=101:100
+phy_chain_tx_polarity_flip_physical{101.0}=0
+phy_chain_tx_polarity_flip_physical{102.0}=1
+phy_chain_tx_polarity_flip_physical{103.0}=1
+phy_chain_tx_polarity_flip_physical{104.0}=1
+phy_chain_rx_polarity_flip_physical{101.0}=1
+phy_chain_rx_polarity_flip_physical{102.0}=1
+phy_chain_rx_polarity_flip_physical{103.0}=1
+phy_chain_rx_polarity_flip_physical{104.0}=1
+phy_chain_tx_lane_map_physical{101.0}=0x1023
+phy_chain_rx_lane_map_physical{101.0}=0x3120
+
+#FC 26
+portmap_44=105:100
+phy_chain_tx_polarity_flip_physical{105.0}=1
+phy_chain_tx_polarity_flip_physical{106.0}=0
+phy_chain_tx_polarity_flip_physical{107.0}=1
+phy_chain_tx_polarity_flip_physical{108.0}=1
+phy_chain_rx_polarity_flip_physical{105.0}=1
+phy_chain_rx_polarity_flip_physical{106.0}=1
+phy_chain_rx_polarity_flip_physical{107.0}=0
+phy_chain_rx_polarity_flip_physical{108.0}=0
+phy_chain_tx_lane_map_physical{105.0}=0x2103
+phy_chain_rx_lane_map_physical{105.0}=0x1203
+
+#FC 27
+portmap_45=109:100
+phy_chain_tx_polarity_flip_physical{109.0}=1
+phy_chain_tx_polarity_flip_physical{110.0}=1
+phy_chain_tx_polarity_flip_physical{111.0}=0
+phy_chain_tx_polarity_flip_physical{112.0}=1
+phy_chain_rx_polarity_flip_physical{109.0}=0
+phy_chain_rx_polarity_flip_physical{110.0}=0
+phy_chain_rx_polarity_flip_physical{111.0}=1
+phy_chain_rx_polarity_flip_physical{112.0}=0
+phy_chain_tx_lane_map_physical{109.0}=0x3201
+phy_chain_rx_lane_map_physical{109.0}=0x0123
+
+#FC 28
+portmap_46=113:100
+phy_chain_tx_polarity_flip_physical{113.0}=0
+phy_chain_tx_polarity_flip_physical{114.0}=1
+phy_chain_tx_polarity_flip_physical{115.0}=1
+phy_chain_tx_polarity_flip_physical{116.0}=0
+phy_chain_rx_polarity_flip_physical{113.0}=1
+phy_chain_rx_polarity_flip_physical{114.0}=0
+phy_chain_rx_polarity_flip_physical{115.0}=0
+phy_chain_rx_polarity_flip_physical{116.0}=1
+phy_chain_tx_lane_map_physical{113.0}=0x3012
+phy_chain_rx_lane_map_physical{113.0}=0x1302
+
+#FC 29
+portmap_47=117:100
+phy_chain_tx_polarity_flip_physical{117.0}=1
+phy_chain_tx_polarity_flip_physical{118.0}=1
+phy_chain_tx_polarity_flip_physical{119.0}=0
+phy_chain_tx_polarity_flip_physical{120.0}=0
+phy_chain_rx_polarity_flip_physical{117.0}=1
+phy_chain_rx_polarity_flip_physical{118.0}=0
+phy_chain_rx_polarity_flip_physical{119.0}=0
+phy_chain_rx_polarity_flip_physical{120.0}=1
+phy_chain_tx_lane_map_physical{117.0}=0x0312
+phy_chain_rx_lane_map_physical{117.0}=0x0132
+
+#FC 30
+portmap_48=121:100
+phy_chain_tx_polarity_flip_physical{121.0}=1
+phy_chain_tx_polarity_flip_physical{122.0}=0
+phy_chain_tx_polarity_flip_physical{123.0}=0
+phy_chain_tx_polarity_flip_physical{124.0}=0
+phy_chain_rx_polarity_flip_physical{121.0}=1
+phy_chain_rx_polarity_flip_physical{122.0}=1
+phy_chain_rx_polarity_flip_physical{123.0}=0
+phy_chain_rx_polarity_flip_physical{124.0}=0
+phy_chain_tx_lane_map_physical{121.0}=0x1023
+phy_chain_rx_lane_map_physical{121.0}=0x1203
+
+#FC 31
+portmap_49=125:100
+phy_chain_tx_polarity_flip_physical{125.0}=0
+phy_chain_tx_polarity_flip_physical{126.0}=1
+phy_chain_tx_polarity_flip_physical{127.0}=0
+phy_chain_tx_polarity_flip_physical{128.0}=1
+phy_chain_rx_polarity_flip_physical{125.0}=0
+phy_chain_rx_polarity_flip_physical{126.0}=0
+phy_chain_rx_polarity_flip_physical{127.0}=1
+phy_chain_rx_polarity_flip_physical{128.0}=0
+phy_chain_tx_lane_map_physical{125.0}=0x1320
+phy_chain_rx_lane_map_physical{125.0}=0x2103
+
+#PIPE-2
+#FC 32
+portmap_68=129:100
+phy_chain_tx_polarity_flip_physical{129.0}=0
+phy_chain_tx_polarity_flip_physical{130.0}=1
+phy_chain_tx_polarity_flip_physical{131.0}=1
+phy_chain_tx_polarity_flip_physical{132.0}=0
+phy_chain_rx_polarity_flip_physical{129.0}=0
+phy_chain_rx_polarity_flip_physical{130.0}=1
+phy_chain_rx_polarity_flip_physical{131.0}=1
+phy_chain_rx_polarity_flip_physical{132.0}=1
+phy_chain_tx_lane_map_physical{129.0}=0x0321
+phy_chain_rx_lane_map_physical{129.0}=0x2310
+
+#FC 33
+portmap_69=133:100
+phy_chain_tx_polarity_flip_physical{133.0}=1
+phy_chain_tx_polarity_flip_physical{134.0}=0
+phy_chain_tx_polarity_flip_physical{135.0}=0
+phy_chain_tx_polarity_flip_physical{136.0}=1
+phy_chain_rx_polarity_flip_physical{133.0}=1
+phy_chain_rx_polarity_flip_physical{134.0}=0
+phy_chain_rx_polarity_flip_physical{135.0}=0
+phy_chain_rx_polarity_flip_physical{136.0}=1
+phy_chain_tx_lane_map_physical{133.0}=0x2013
+phy_chain_rx_lane_map_physical{133.0}=0x1203
+
+#FC 34
+portmap_70=137:100
+phy_chain_tx_polarity_flip_physical{137.0}=0
+phy_chain_tx_polarity_flip_physical{138.0}=1
+phy_chain_tx_polarity_flip_physical{139.0}=0
+phy_chain_tx_polarity_flip_physical{140.0}=0
+phy_chain_rx_polarity_flip_physical{137.0}=0
+phy_chain_rx_polarity_flip_physical{138.0}=1
+phy_chain_rx_polarity_flip_physical{139.0}=1
+phy_chain_rx_polarity_flip_physical{140.0}=0
+phy_chain_tx_lane_map_physical{137.0}=0x2301
+phy_chain_rx_lane_map_physical{137.0}=0x0213
+
+#FC 35
+portmap_71=141:100
+phy_chain_tx_polarity_flip_physical{141.0}=0
+phy_chain_tx_polarity_flip_physical{142.0}=1
+phy_chain_tx_polarity_flip_physical{143.0}=0
+phy_chain_tx_polarity_flip_physical{144.0}=1
+phy_chain_rx_polarity_flip_physical{141.0}=0
+phy_chain_rx_polarity_flip_physical{142.0}=0
+phy_chain_rx_polarity_flip_physical{143.0}=0
+phy_chain_rx_polarity_flip_physical{144.0}=1
+phy_chain_tx_lane_map_physical{141.0}=0x2013
+phy_chain_rx_lane_map_physical{141.0}=0x2310
+
+#FC 36
+portmap_72=145:100
+phy_chain_tx_polarity_flip_physical{145.0}=1
+phy_chain_tx_polarity_flip_physical{146.0}=0
+phy_chain_tx_polarity_flip_physical{147.0}=1
+phy_chain_tx_polarity_flip_physical{148.0}=0
+phy_chain_rx_polarity_flip_physical{145.0}=1
+phy_chain_rx_polarity_flip_physical{146.0}=0
+phy_chain_rx_polarity_flip_physical{147.0}=0
+phy_chain_rx_polarity_flip_physical{148.0}=1
+phy_chain_tx_lane_map_physical{145.0}=0x2310
+phy_chain_rx_lane_map_physical{145.0}=0x0231
+
+#FC 37
+portmap_73=149:100
+phy_chain_tx_polarity_flip_physical{149.0}=1
+phy_chain_tx_polarity_flip_physical{150.0}=1
+phy_chain_tx_polarity_flip_physical{151.0}=0
+phy_chain_tx_polarity_flip_physical{152.0}=0
+phy_chain_rx_polarity_flip_physical{149.0}=1
+phy_chain_rx_polarity_flip_physical{150.0}=0
+phy_chain_rx_polarity_flip_physical{151.0}=0
+phy_chain_rx_polarity_flip_physical{152.0}=1
+phy_chain_tx_lane_map_physical{149.0}=0x3021
+phy_chain_rx_lane_map_physical{149.0}=0x1203
+
+#FC 38
+portmap_74=153:100
+phy_chain_tx_polarity_flip_physical{153.0}=1
+phy_chain_tx_polarity_flip_physical{154.0}=0
+phy_chain_tx_polarity_flip_physical{155.0}=1
+phy_chain_tx_polarity_flip_physical{156.0}=1
+phy_chain_rx_polarity_flip_physical{153.0}=0
+phy_chain_rx_polarity_flip_physical{154.0}=0
+phy_chain_rx_polarity_flip_physical{155.0}=0
+phy_chain_rx_polarity_flip_physical{156.0}=0
+phy_chain_tx_lane_map_physical{153.0}=0x1230
+phy_chain_rx_lane_map_physical{153.0}=0x3120
+
+#FC 39
+portmap_75=157:100
+phy_chain_tx_polarity_flip_physical{157.0}=1
+phy_chain_tx_polarity_flip_physical{158.0}=1
+phy_chain_tx_polarity_flip_physical{159.0}=1
+phy_chain_tx_polarity_flip_physical{160.0}=0
+phy_chain_rx_polarity_flip_physical{157.0}=0
+phy_chain_rx_polarity_flip_physical{158.0}=0
+phy_chain_rx_polarity_flip_physical{159.0}=1
+phy_chain_rx_polarity_flip_physical{160.0}=0
+phy_chain_tx_lane_map_physical{157.0}=0x3210
+phy_chain_rx_lane_map_physical{157.0}=0x3210
+
+#FC 40
+portmap_76=161:100
+phy_chain_tx_polarity_flip_physical{161.0}=1
+phy_chain_tx_polarity_flip_physical{162.0}=1
+phy_chain_tx_polarity_flip_physical{163.0}=0
+phy_chain_tx_polarity_flip_physical{164.0}=1
+phy_chain_rx_polarity_flip_physical{161.0}=1
+phy_chain_rx_polarity_flip_physical{162.0}=1
+phy_chain_rx_polarity_flip_physical{163.0}=1
+phy_chain_rx_polarity_flip_physical{164.0}=1
+phy_chain_tx_lane_map_physical{161.0}=0x2031
+phy_chain_rx_lane_map_physical{161.0}=0x1032
+
+#FC 41
+portmap_77=165:100
+phy_chain_tx_polarity_flip_physical{165.0}=0
+phy_chain_tx_polarity_flip_physical{166.0}=0
+phy_chain_tx_polarity_flip_physical{167.0}=1
+phy_chain_tx_polarity_flip_physical{168.0}=1
+phy_chain_rx_polarity_flip_physical{165.0}=0
+phy_chain_rx_polarity_flip_physical{166.0}=1
+phy_chain_rx_polarity_flip_physical{167.0}=0
+phy_chain_rx_polarity_flip_physical{168.0}=1
+phy_chain_tx_lane_map_physical{165.0}=0x2310
+phy_chain_rx_lane_map_physical{165.0}=0x1230
+
+#FC 42
+portmap_78=169:100
+phy_chain_tx_polarity_flip_physical{169.0}=1
+phy_chain_tx_polarity_flip_physical{170.0}=0
+phy_chain_tx_polarity_flip_physical{171.0}=1
+phy_chain_tx_polarity_flip_physical{172.0}=0
+phy_chain_rx_polarity_flip_physical{169.0}=0
+phy_chain_rx_polarity_flip_physical{170.0}=0
+phy_chain_rx_polarity_flip_physical{171.0}=0
+phy_chain_rx_polarity_flip_physical{172.0}=0
+phy_chain_tx_lane_map_physical{169.0}=0x1302
+phy_chain_rx_lane_map_physical{169.0}=0x3210
+
+#FC 43
+portmap_79=173:100
+phy_chain_tx_polarity_flip_physical{173.0}=1
+phy_chain_tx_polarity_flip_physical{174.0}=0
+phy_chain_tx_polarity_flip_physical{175.0}=0
+phy_chain_tx_polarity_flip_physical{176.0}=0
+phy_chain_rx_polarity_flip_physical{173.0}=0
+phy_chain_rx_polarity_flip_physical{174.0}=1
+phy_chain_rx_polarity_flip_physical{175.0}=0
+phy_chain_rx_polarity_flip_physical{176.0}=1
+phy_chain_tx_lane_map_physical{173.0}=0x0312
+phy_chain_rx_lane_map_physical{173.0}=0x3210
+
+#FC 44
+portmap_80=177:100
+phy_chain_tx_polarity_flip_physical{177.0}=0
+phy_chain_tx_polarity_flip_physical{178.0}=1
+phy_chain_tx_polarity_flip_physical{179.0}=0
+phy_chain_tx_polarity_flip_physical{180.0}=1
+phy_chain_rx_polarity_flip_physical{177.0}=1
+phy_chain_rx_polarity_flip_physical{178.0}=1
+phy_chain_rx_polarity_flip_physical{179.0}=0
+phy_chain_rx_polarity_flip_physical{180.0}=1
+phy_chain_tx_lane_map_physical{177.0}=0x2031
+phy_chain_rx_lane_map_physical{177.0}=0x1302
+
+#FC 45
+portmap_81=181:100
+phy_chain_tx_polarity_flip_physical{181.0}=0
+phy_chain_tx_polarity_flip_physical{182.0}=0
+phy_chain_tx_polarity_flip_physical{183.0}=0
+phy_chain_tx_polarity_flip_physical{184.0}=0
+phy_chain_rx_polarity_flip_physical{181.0}=0
+phy_chain_rx_polarity_flip_physical{182.0}=1
+phy_chain_rx_polarity_flip_physical{183.0}=0
+phy_chain_rx_polarity_flip_physical{184.0}=1
+phy_chain_tx_lane_map_physical{181.0}=0x1023
+phy_chain_rx_lane_map_physical{181.0}=0x2301
+
+#FC 46
+portmap_82=185:100
+phy_chain_tx_polarity_flip_physical{185.0}=0
+phy_chain_tx_polarity_flip_physical{186.0}=0
+phy_chain_tx_polarity_flip_physical{187.0}=1
+phy_chain_tx_polarity_flip_physical{188.0}=0
+phy_chain_rx_polarity_flip_physical{185.0}=0
+phy_chain_rx_polarity_flip_physical{186.0}=0
+phy_chain_rx_polarity_flip_physical{187.0}=0
+phy_chain_rx_polarity_flip_physical{188.0}=0
+phy_chain_tx_lane_map_physical{185.0}=0x1320
+phy_chain_rx_lane_map_physical{185.0}=0x3210
+
+#FC 47
+portmap_83=189:100
+phy_chain_tx_polarity_flip_physical{189.0}=1
+phy_chain_tx_polarity_flip_physical{190.0}=1
+phy_chain_tx_polarity_flip_physical{191.0}=0
+phy_chain_tx_polarity_flip_physical{192.0}=1
+phy_chain_rx_polarity_flip_physical{189.0}=0
+phy_chain_rx_polarity_flip_physical{190.0}=1
+phy_chain_rx_polarity_flip_physical{191.0}=0
+phy_chain_rx_polarity_flip_physical{192.0}=1
+phy_chain_tx_lane_map_physical{189.0}=0x3021
+phy_chain_rx_lane_map_physical{189.0}=0x3210
+
+#PIPE-3
+#FC 48
+portmap_102=193:100
+phy_chain_tx_polarity_flip_physical{193.0}=1
+phy_chain_tx_polarity_flip_physical{194.0}=0
+phy_chain_tx_polarity_flip_physical{195.0}=1
+phy_chain_tx_polarity_flip_physical{196.0}=0
+phy_chain_rx_polarity_flip_physical{193.0}=1
+phy_chain_rx_polarity_flip_physical{194.0}=1
+phy_chain_rx_polarity_flip_physical{195.0}=0
+phy_chain_rx_polarity_flip_physical{196.0}=1
+phy_chain_tx_lane_map_physical{193.0}=0x3021
+phy_chain_rx_lane_map_physical{193.0}=0x1302
+
+#FC 49
+portmap_103=197:100
+phy_chain_tx_polarity_flip_physical{197.0}=1
+phy_chain_tx_polarity_flip_physical{198.0}=0
+phy_chain_tx_polarity_flip_physical{199.0}=0
+phy_chain_tx_polarity_flip_physical{200.0}=1
+phy_chain_rx_polarity_flip_physical{197.0}=0
+phy_chain_rx_polarity_flip_physical{198.0}=1
+phy_chain_rx_polarity_flip_physical{199.0}=0
+phy_chain_rx_polarity_flip_physical{200.0}=1
+phy_chain_tx_lane_map_physical{197.0}=0x0132
+phy_chain_rx_lane_map_physical{197.0}=0x2301
+
+#FC 50
+portmap_104=201:100
+phy_chain_tx_polarity_flip_physical{201.0}=1
+phy_chain_tx_polarity_flip_physical{202.0}=0
+phy_chain_tx_polarity_flip_physical{203.0}=1
+phy_chain_tx_polarity_flip_physical{204.0}=1
+phy_chain_rx_polarity_flip_physical{201.0}=0
+phy_chain_rx_polarity_flip_physical{202.0}=0
+phy_chain_rx_polarity_flip_physical{203.0}=0
+phy_chain_rx_polarity_flip_physical{204.0}=0
+phy_chain_tx_lane_map_physical{201.0}=0x2301
+phy_chain_rx_lane_map_physical{201.0}=0x1230
+
+#FC 51
+portmap_105=205:100
+phy_chain_tx_polarity_flip_physical{205.0}=1
+phy_chain_tx_polarity_flip_physical{206.0}=1
+phy_chain_tx_polarity_flip_physical{207.0}=0
+phy_chain_tx_polarity_flip_physical{208.0}=0
+phy_chain_rx_polarity_flip_physical{205.0}=0
+phy_chain_rx_polarity_flip_physical{206.0}=0
+phy_chain_rx_polarity_flip_physical{207.0}=0
+phy_chain_rx_polarity_flip_physical{208.0}=1
+phy_chain_tx_lane_map_physical{205.0}=0x3021
+phy_chain_rx_lane_map_physical{205.0}=0x2130
+
+#FC 52
+portmap_106=209:100
+phy_chain_tx_polarity_flip_physical{209.0}=1
+phy_chain_tx_polarity_flip_physical{210.0}=1
+phy_chain_tx_polarity_flip_physical{211.0}=0
+phy_chain_tx_polarity_flip_physical{212.0}=1
+phy_chain_rx_polarity_flip_physical{209.0}=0
+phy_chain_rx_polarity_flip_physical{210.0}=0
+phy_chain_rx_polarity_flip_physical{211.0}=1
+phy_chain_rx_polarity_flip_physical{212.0}=1
+phy_chain_tx_lane_map_physical{209.0}=0x2031
+phy_chain_rx_lane_map_physical{209.0}=0x3021
+
+#FC 53
+portmap_107=213:100
+phy_chain_tx_polarity_flip_physical{213.0}=0
+phy_chain_tx_polarity_flip_physical{214.0}=1
+phy_chain_tx_polarity_flip_physical{215.0}=1
+phy_chain_tx_polarity_flip_physical{216.0}=0
+phy_chain_rx_polarity_flip_physical{213.0}=0
+phy_chain_rx_polarity_flip_physical{214.0}=1
+phy_chain_rx_polarity_flip_physical{215.0}=0
+phy_chain_rx_polarity_flip_physical{216.0}=1
+phy_chain_tx_lane_map_physical{213.0}=0x1302
+phy_chain_rx_lane_map_physical{213.0}=0x1032
+
+#FC 54
+portmap_108=217:100
+phy_chain_tx_polarity_flip_physical{217.0}=1
+phy_chain_tx_polarity_flip_physical{218.0}=0
+phy_chain_tx_polarity_flip_physical{219.0}=1
+phy_chain_tx_polarity_flip_physical{220.0}=1
+phy_chain_rx_polarity_flip_physical{217.0}=0
+phy_chain_rx_polarity_flip_physical{218.0}=0
+phy_chain_rx_polarity_flip_physical{219.0}=0
+phy_chain_rx_polarity_flip_physical{220.0}=0
+phy_chain_tx_lane_map_physical{217.0}=0x2301
+phy_chain_rx_lane_map_physical{217.0}=0x1230
+
+#FC 55
+portmap_109=221:100
+phy_chain_tx_polarity_flip_physical{221.0}=0
+phy_chain_tx_polarity_flip_physical{222.0}=0
+phy_chain_tx_polarity_flip_physical{223.0}=0
+phy_chain_tx_polarity_flip_physical{224.0}=0
+phy_chain_rx_polarity_flip_physical{221.0}=0
+phy_chain_rx_polarity_flip_physical{222.0}=1
+phy_chain_rx_polarity_flip_physical{223.0}=0
+phy_chain_rx_polarity_flip_physical{224.0}=1
+phy_chain_tx_lane_map_physical{221.0}=0x3210
+phy_chain_rx_lane_map_physical{221.0}=0x2310
+
+#FC 56
+portmap_110=225:100
+phy_chain_tx_polarity_flip_physical{225.0}=0
+phy_chain_tx_polarity_flip_physical{226.0}=0
+phy_chain_tx_polarity_flip_physical{227.0}=1
+phy_chain_tx_polarity_flip_physical{228.0}=0
+phy_chain_rx_polarity_flip_physical{225.0}=0
+phy_chain_rx_polarity_flip_physical{226.0}=1
+phy_chain_rx_polarity_flip_physical{227.0}=1
+phy_chain_rx_polarity_flip_physical{228.0}=1
+phy_chain_tx_lane_map_physical{225.0}=0x3120
+phy_chain_rx_lane_map_physical{225.0}=0x3021
+
+#FC 57
+portmap_111=229:100
+phy_chain_tx_polarity_flip_physical{229.0}=0
+phy_chain_tx_polarity_flip_physical{230.0}=0
+phy_chain_tx_polarity_flip_physical{231.0}=1
+phy_chain_tx_polarity_flip_physical{232.0}=0
+phy_chain_rx_polarity_flip_physical{229.0}=0
+phy_chain_rx_polarity_flip_physical{230.0}=0
+phy_chain_rx_polarity_flip_physical{231.0}=1
+phy_chain_rx_polarity_flip_physical{232.0}=1
+phy_chain_tx_lane_map_physical{229.0}=0x0231
+phy_chain_rx_lane_map_physical{229.0}=0x2031
+
+#FC 58
+portmap_112=233:100
+phy_chain_tx_polarity_flip_physical{233.0}=1
+phy_chain_tx_polarity_flip_physical{234.0}=0
+phy_chain_tx_polarity_flip_physical{235.0}=0
+phy_chain_tx_polarity_flip_physical{236.0}=0
+phy_chain_rx_polarity_flip_physical{233.0}=0
+phy_chain_rx_polarity_flip_physical{234.0}=0
+phy_chain_rx_polarity_flip_physical{235.0}=1
+phy_chain_rx_polarity_flip_physical{236.0}=1
+phy_chain_tx_lane_map_physical{233.0}=0x1023
+phy_chain_rx_lane_map_physical{233.0}=0x1203
+
+#FC 59
+portmap_113=237:100
+phy_chain_tx_polarity_flip_physical{237.0}=0
+phy_chain_tx_polarity_flip_physical{238.0}=0
+phy_chain_tx_polarity_flip_physical{239.0}=1
+phy_chain_tx_polarity_flip_physical{240.0}=0
+phy_chain_rx_polarity_flip_physical{237.0}=1
+phy_chain_rx_polarity_flip_physical{238.0}=0
+phy_chain_rx_polarity_flip_physical{239.0}=0
+phy_chain_rx_polarity_flip_physical{240.0}=0
+phy_chain_tx_lane_map_physical{237.0}=0x2013
+phy_chain_rx_lane_map_physical{237.0}=0x0213
+
+#FC 60
+portmap_114=241:100
+phy_chain_tx_polarity_flip_physical{241.0}=0
+phy_chain_tx_polarity_flip_physical{242.0}=1
+phy_chain_tx_polarity_flip_physical{243.0}=0
+phy_chain_tx_polarity_flip_physical{244.0}=0
+phy_chain_rx_polarity_flip_physical{241.0}=0
+phy_chain_rx_polarity_flip_physical{242.0}=0
+phy_chain_rx_polarity_flip_physical{243.0}=0
+phy_chain_rx_polarity_flip_physical{244.0}=0
+phy_chain_tx_lane_map_physical{241.0}=0x1032
+phy_chain_rx_lane_map_physical{241.0}=0x2310
+
+#FC 61
+portmap_115=245:100
+phy_chain_tx_polarity_flip_physical{245.0}=1
+phy_chain_tx_polarity_flip_physical{246.0}=0
+phy_chain_tx_polarity_flip_physical{247.0}=0
+phy_chain_tx_polarity_flip_physical{248.0}=1
+phy_chain_rx_polarity_flip_physical{245.0}=1
+phy_chain_rx_polarity_flip_physical{246.0}=1
+phy_chain_rx_polarity_flip_physical{247.0}=0
+phy_chain_rx_polarity_flip_physical{248.0}=1
+phy_chain_tx_lane_map_physical{245.0}=0x1302
+phy_chain_rx_lane_map_physical{245.0}=0x1302
+
+#FC 62
+portmap_116=249:100
+phy_chain_tx_polarity_flip_physical{249.0}=0
+phy_chain_tx_polarity_flip_physical{250.0}=1
+phy_chain_tx_polarity_flip_physical{251.0}=0
+phy_chain_tx_polarity_flip_physical{252.0}=0
+phy_chain_rx_polarity_flip_physical{249.0}=1
+phy_chain_rx_polarity_flip_physical{250.0}=1
+phy_chain_rx_polarity_flip_physical{251.0}=0
+phy_chain_rx_polarity_flip_physical{252.0}=0
+phy_chain_tx_lane_map_physical{249.0}=0x1032
+phy_chain_rx_lane_map_physical{249.0}=0x1203
+
+#FC 63
+portmap_117=253:100
+phy_chain_tx_polarity_flip_physical{253.0}=0
+phy_chain_tx_polarity_flip_physical{254.0}=0
+phy_chain_tx_polarity_flip_physical{255.0}=0
+phy_chain_tx_polarity_flip_physical{256.0}=1
+phy_chain_rx_polarity_flip_physical{253.0}=0
+phy_chain_rx_polarity_flip_physical{254.0}=1
+phy_chain_rx_polarity_flip_physical{255.0}=1
+phy_chain_rx_polarity_flip_physical{256.0}=0
+phy_chain_tx_lane_map_physical{253.0}=0x3210
+phy_chain_rx_lane_map_physical{253.0}=0x2103
+
+
+
+#MGMT
+portmap_66=257:10
+portmap_100=259:10
+#phy_chain_tx_lane_map_physical{257.0}=0x0123
+#phy_chain_rx_lane_map_physical{257.0}=0x0123
+
+#LPBK
+portmap_33=260:10
+portmap_67=261:10
+portmap_101=262:10
+portmap_135=263:10
diff --git a/device/ingrasys/x86_64-ingrasys_s9200_64x-r0/fancontrol b/device/ingrasys/x86_64-ingrasys_s9200_64x-r0/fancontrol
index 185ee3a2fc..489ebeaee9 100644
--- a/device/ingrasys/x86_64-ingrasys_s9200_64x-r0/fancontrol
+++ b/device/ingrasys/x86_64-ingrasys_s9200_64x-r0/fancontrol
@@ -1,7 +1,7 @@
INTERVAL=10
-DEVPATH=hwmon5=devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-002f hwmon1=devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-7/7-004d
+DEVPATH=hwmon5=devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-002f hwmon2=devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-7/7-004d
DEVNAME=hwmon5=w83795adg
-FCTEMPS=hwmon5/device/pwm2=hwmon1/temp1_input
+FCTEMPS=hwmon5/device/pwm2=hwmon2/temp1_input
FCFANS=hwmon5/device/pwm2=hwmon5/device/fan7_input hwmon5/device/pwm2=hwmon5/device/fan5_input hwmon5/device/pwm2=hwmon5/device/fan3_input hwmon5/device/pwm2=hwmon5/device/fan1_input
MINTEMP=hwmon5/device/pwm2=20
MAXTEMP=hwmon5/device/pwm2=60
diff --git a/device/ingrasys/x86_64-ingrasys_s9200_64x-r0/sensors.conf b/device/ingrasys/x86_64-ingrasys_s9200_64x-r0/sensors.conf
index 361a8b7326..25ab494e1f 100644
--- a/device/ingrasys/x86_64-ingrasys_s9200_64x-r0/sensors.conf
+++ b/device/ingrasys/x86_64-ingrasys_s9200_64x-r0/sensors.conf
@@ -10,8 +10,8 @@ chip "jc42-*"
chip "w83795adg-*"
ignore in0
label in1 "P0V9"
- set in1_min 0.90 * 0.97
- set in1_max 0.90 * 1.03
+ set in1_min 0.84 * 0.97
+ set in1_max 0.96 * 1.03
ignore in2
label in3 "P1V8"
set in3_min 1.8 * 0.97
@@ -20,8 +20,8 @@ chip "w83795adg-*"
set in4_min 1.0 * 0.97
set in4_max 1.0 * 1.03
label in5 "P0V8"
- set in5_min 0.8 * 0.97
- set in5_max 0.8 * 1.03
+ set in5_min 0.831 * 0.97
+ set in5_max 0.831 * 1.03
ignore in6
ignore in7
ignore in8
diff --git a/device/ingrasys/x86_64-ingrasys_s9280_64x-r0/fancontrol b/device/ingrasys/x86_64-ingrasys_s9280_64x-r0/fancontrol
index c131df9df3..427cc6561c 100644
--- a/device/ingrasys/x86_64-ingrasys_s9280_64x-r0/fancontrol
+++ b/device/ingrasys/x86_64-ingrasys_s9280_64x-r0/fancontrol
@@ -1,5 +1,5 @@
INTERVAL=10
-DEVPATH=hwmon1=devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-002f hwmon3=devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-6/6-004e
+DEVPATH=hwmon1=devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-16/16-002f hwmon3=devices/pci0000:00/0000:00:1f.3/i2c-0/i2c-6/6-004c
DEVNAME=hwmon1=w83795adg
FCTEMPS=hwmon1/device/pwm2=hwmon3/temp1_input
FCFANS=hwmon1/device/pwm2=hwmon1/device/fan7_input hwmon1/device/pwm2=hwmon1/device/fan5_input hwmon1/device/pwm2=hwmon1/device/fan3_input hwmon1/device/pwm2=hwmon1/device/fan1_input
diff --git a/device/ingrasys/x86_64-ingrasys_s9280_64x-r0/sensors.conf b/device/ingrasys/x86_64-ingrasys_s9280_64x-r0/sensors.conf
index ddc04a5f4a..0e9f5cd41b 100644
--- a/device/ingrasys/x86_64-ingrasys_s9280_64x-r0/sensors.conf
+++ b/device/ingrasys/x86_64-ingrasys_s9280_64x-r0/sensors.conf
@@ -66,20 +66,20 @@ chip "lm75-i2c-6-4D"
set temp1_max 50
set temp1_max_hyst 45
chip "lm75-i2c-6-4E"
- label temp1 "Rear MAC Temp"
+ label temp1 "Right Side MB Tetmp"
set temp1_max 50
set temp1_max_hyst 45
chip "lm86-i2c-6-4C"
- label temp1 "MB Temp"
+ label temp1 "Front Panel Temp"
set temp1_max 50
- label temp2 "MAC Temp"
+ label temp2 "Front MAC Temp"
set temp2_max 70
bus "i2c-7" "i2c-0-mux (chan_id 6)"
chip "lm75-i2c-7-4D"
- label temp1 "Front Panel Temp"
+ label temp1 "Left Side MB Temp"
set temp1_max 50
set temp1_max_hyst 45
chip "lm75-i2c-7-4E"
- label temp1 "Front MAC Temp"
+ label temp1 "Left Side MAC Temp"
set temp1_max 50
set temp1_max_hyst 45
diff --git a/platform/barefoot/bfn-platform-ingrasys.mk b/platform/barefoot/bfn-platform-ingrasys.mk
index 7f3ba47465..20dc5f866f 100644
--- a/platform/barefoot/bfn-platform-ingrasys.mk
+++ b/platform/barefoot/bfn-platform-ingrasys.mk
@@ -1,5 +1,5 @@
BFN_INGRASYS_PLATFORM = bfnplatform-ingrasys_8.2.0_amd64.deb
-$(BFN_INGRASYS_PLATFORM)_URL = "https://github.com/Ingrasys-sonic/packages/raw/master/lib/bfnplatform-ingrasys_8.2.0_amd64.deb"
+$(BFN_INGRASYS_PLATFORM)_URL = "https://github.com/Ingrasys-sonic/packages/raw/master/lib/bfnplatform-ingrasys_8.4.0_8.5.0_amd64.deb"
SONIC_ONLINE_DEBS += $(BFN_INGRASYS_PLATFORM) # $(BFN_SAI_DEV)
$(BFN_SAI_DEV)_DEPENDS += $(BFN_INGRASYS_PLATFORM)
diff --git a/platform/barefoot/sonic-platform-modules-ingrasys/s9180-32x/utils/i2c_utils.sh b/platform/barefoot/sonic-platform-modules-ingrasys/s9180-32x/utils/i2c_utils.sh
index 969ba09f84..d8e5778f4b 100755
--- a/platform/barefoot/sonic-platform-modules-ingrasys/s9180-32x/utils/i2c_utils.sh
+++ b/platform/barefoot/sonic-platform-modules-ingrasys/s9180-32x/utils/i2c_utils.sh
@@ -15,7 +15,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-VERSION="1.0.0"
+# trun on for more debug output
+#DEBUG="on"
+
+VERSION="1.1.0"
TRUE=200
FALSE=404
@@ -104,10 +107,14 @@ PSU_NOT_EXIST=0
rov_val_array=( 0.85 0.82 0.77 0.87 0.74 0.84 0.79 0.89 )
rov_reg_array=( 0x24 0x21 0x1c 0x26 0x19 0x23 0x1e 0x28 )
+#GPIO Offset
+GPIO_OFFSET=0
+
# Help usage function
function _help {
echo "========================================================="
echo "# Description: Help Function"
+ echo "# Version : ${VERSION}"
echo "========================================================="
echo "----------------------------------------------------"
echo "EX : ${0} help"
@@ -130,8 +137,10 @@ function _help {
echo " : ${0} i2c_psu_eeprom_init new|delete"
echo " : ${0} i2c_qsfp_status_get [1-34]"
echo " : ${0} i2c_qsfp_type_get [1-34]"
+ echo " : ${0} i2c_qsfp_ddm_get [1-34]"
echo " : ${0} i2c_board_type_get"
echo " : ${0} i2c_psu_status"
+ echo " : ${0} i2c_led_psu_status_set"
echo " : ${0} i2c_led_fan_status_set"
echo " : ${0} i2c_led_fan_tray_status_set"
echo " : ${0} i2c_cpld_version"
@@ -139,6 +148,8 @@ function _help {
echo " : ${0} i2c_test_all"
echo " : ${0} i2c_sys_led green|amber"
echo " : ${0} i2c_fan_led green|amber on|off"
+ echo " : ${0} i2c_psu1_led green|amber"
+ echo " : ${0} i2c_psu2_led green|amber"
echo " : ${0} i2c_fan_tray_led green|amber on|off [1-4]"
echo "----------------------------------------------------"
}
@@ -229,11 +240,14 @@ function _i2c_init {
_i2c_fan_speed_init
_i2c_temp_init
modprobe jc42
+ rmmod gpio_ich
_i2c_gpio_init
+ modprobe gpio_ich
_i2c_mb_eeprom_init "new"
_i2c_qsfp_eeprom_init "new"
_i2c_sfp_eeprom_init "new"
_i2c_psu_eeprom_init "new"
+ _i2c_led_psu_status_set
_i2c_led_fan_status_set
_i2c_led_fan_tray_status_set
@@ -486,12 +500,28 @@ function _i2c_fan_init {
echo "Done"
}
+# To set the global variable GPIO_OFFSET
+function _set_gpio_offset {
+ GPIO_OFFSET=0
+ for d in `ls /sys/class/gpio/ | grep gpiochip`
+ do
+ gpiochip_no=${d##gpiochip}
+ if [ $gpiochip_no -gt 255 ]; then
+ GPIO_OFFSET=256
+ break
+ fi
+ done
+ #echo "set GPIO_OFFSET=${GPIO_OFFSET}"
+}
+
#GPIO Init
function _i2c_gpio_init {
local i=0
#ABS Port 0-15
echo "pca9535 0x20" > /sys/bus/i2c/devices/i2c-${NUM_MUX1_CHAN4_DEVICE}/new_device
- for i in {240..255};
+ _set_gpio_offset
+ #for i in {240..255};
+ for((i=${GPIO_OFFSET}+240;i<=${GPIO_OFFSET}+255;i++));
do
echo $i > /sys/class/gpio/export
echo 1 > /sys/class/gpio/gpio${i}/active_low
@@ -499,7 +529,8 @@ function _i2c_gpio_init {
#ABS Port 16-31
echo "pca9535 0x21" > /sys/bus/i2c/devices/i2c-${NUM_MUX1_CHAN4_DEVICE}/new_device
- for i in {224..239};
+ #for i in {224..239};
+ for((i=${GPIO_OFFSET}+224;i<=${GPIO_OFFSET}+239;i++));
do
echo $i > /sys/class/gpio/export
echo 1 > /sys/class/gpio/gpio${i}/active_low
@@ -507,7 +538,8 @@ function _i2c_gpio_init {
#INT Port 0-15
echo "pca9535 0x22" > /sys/bus/i2c/devices/i2c-${NUM_MUX1_CHAN4_DEVICE}/new_device
- for i in {208..223};
+ #for i in {208..223};
+ for((i=${GPIO_OFFSET}+208;i<=${GPIO_OFFSET}+223;i++));
do
echo $i > /sys/class/gpio/export
echo 1 > /sys/class/gpio/gpio${i}/active_low
@@ -515,7 +547,8 @@ function _i2c_gpio_init {
#INT Port 16-31
echo "pca9535 0x23" > /sys/bus/i2c/devices/i2c-${NUM_MUX1_CHAN4_DEVICE}/new_device
- for i in {192..207};
+ #for i in {192..207};
+ for((i=${GPIO_OFFSET}+192;i<=${GPIO_OFFSET}+207;i++));
do
echo $i > /sys/class/gpio/export
echo 1 > /sys/class/gpio/gpio${i}/active_low
@@ -523,14 +556,31 @@ function _i2c_gpio_init {
#SFP+
echo "pca9535 0x27" > /sys/bus/i2c/devices/i2c-${NUM_MUX1_CHAN4_DEVICE}/new_device
- for i in {176..191};
+ #for i in {176..191};
+ for((i=${GPIO_OFFSET}+176;i<=${GPIO_OFFSET}+191;i++));
do
echo $i > /sys/class/gpio/export
case ${i} in
- 176|177|178|179|182|183|188|189|190|191)
+ #176|177|178|179|182|183|188|189|190|191)
+ $((${GPIO_OFFSET}+176)) | \
+ $((${GPIO_OFFSET}+177)) | \
+ $((${GPIO_OFFSET}+178)) | \
+ $((${GPIO_OFFSET}+179)) | \
+ $((${GPIO_OFFSET}+182)) | \
+ $((${GPIO_OFFSET}+183)) | \
+ $((${GPIO_OFFSET}+188)) | \
+ $((${GPIO_OFFSET}+189)) | \
+ $((${GPIO_OFFSET}+190)) | \
+ $((${GPIO_OFFSET}+191)) )
echo 1 > /sys/class/gpio/gpio${i}/active_low
;;
- 180|181|184|185|186|187)
+ #180|181|184|185|186|187)
+ $((${GPIO_OFFSET}+180)) | \
+ $((${GPIO_OFFSET}+181)) | \
+ $((${GPIO_OFFSET}+184)) | \
+ $((${GPIO_OFFSET}+185)) | \
+ $((${GPIO_OFFSET}+186)) | \
+ $((${GPIO_OFFSET}+187)) )
echo out > /sys/class/gpio/gpio${i}/direction
;;
esac
@@ -571,7 +621,8 @@ function _i2c_gpio_init {
#LP Mode Port 0-15
echo "pca9535 0x20" > /sys/bus/i2c/devices/i2c-${NUM_MUX1_CHAN5_DEVICE}/new_device
- for i in {160..175};
+ #for i in {160..175};
+ for((i=${GPIO_OFFSET}+160;i<=${GPIO_OFFSET}+175;i++));
do
echo $i > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio${i}/direction
@@ -579,7 +630,8 @@ function _i2c_gpio_init {
#LP Mode Port 16-31
echo "pca9535 0x21" > /sys/bus/i2c/devices/i2c-${NUM_MUX1_CHAN5_DEVICE}/new_device
- for i in {144..159};
+ #for i in {144..159};
+ for((i=${GPIO_OFFSET}+144;i<=${GPIO_OFFSET}+159;i++));
do
echo $i > /sys/class/gpio/export
echo out > /sys/class/gpio/gpio${i}/direction
@@ -587,34 +639,52 @@ function _i2c_gpio_init {
#RST Port 0-15
echo "pca9535 0x22" > /sys/bus/i2c/devices/i2c-${NUM_MUX1_CHAN5_DEVICE}/new_device
- for i in {128..143};
+ #for i in {128..143};
+ for((i=${GPIO_OFFSET}+128;i<=${GPIO_OFFSET}+143;i++));
do
echo $i > /sys/class/gpio/export
- echo out > /sys/class/gpio/gpio${i}/direction
echo 1 > /sys/class/gpio/gpio${i}/active_low
- echo 0 > /sys/class/gpio/gpio${i}/value
+ echo low > /sys/class/gpio/gpio${i}/direction
+ #echo out > /sys/class/gpio/gpio${i}/direction
+ #echo 0 > /sys/class/gpio/gpio${i}/value
done
#RST Port 16-31
echo "pca9535 0x23" > /sys/bus/i2c/devices/i2c-${NUM_MUX1_CHAN5_DEVICE}/new_device
- for i in {112..127};
+ #for i in {112..127};
+ for((i=${GPIO_OFFSET}+112;i<=${GPIO_OFFSET}+127;i++));
do
echo $i > /sys/class/gpio/export
- echo out > /sys/class/gpio/gpio${i}/direction
echo 1 > /sys/class/gpio/gpio${i}/active_low
- echo 0 > /sys/class/gpio/gpio${i}/value
+ echo low > /sys/class/gpio/gpio${i}/direction
+ #echo out > /sys/class/gpio/gpio${i}/direction
+ #echo 0 > /sys/class/gpio/gpio${i}/value
done
#PSU I/O on Dummy Board 0x25
echo "pca9535 0x25" > /sys/bus/i2c/devices/i2c-${NUM_I801_DEVICE}/new_device
- for i in {96..111};
+ #for i in {96..111};
+ for((i=${GPIO_OFFSET}+96;i<=${GPIO_OFFSET}+111;i++));
do
echo $i > /sys/class/gpio/export
case ${i} in
- 97|98|100|101|102|105|106|108)
+ #97|98|100|101|102|105|106|108)
+ $((${GPIO_OFFSET}+97)) | \
+ $((${GPIO_OFFSET}+98)) | \
+ $((${GPIO_OFFSET}+100)) | \
+ $((${GPIO_OFFSET}+101)) | \
+ $((${GPIO_OFFSET}+102)) | \
+ $((${GPIO_OFFSET}+105)) | \
+ $((${GPIO_OFFSET}+106)) | \
+ $((${GPIO_OFFSET}+108)) )
echo 1 > /sys/class/gpio/gpio${i}/active_low
;;
- 98|101|106|107|108)
+ #98|101|106|107|108)
+ $((${GPIO_OFFSET}+98)) | \
+ $((${GPIO_OFFSET}+101)) | \
+ $((${GPIO_OFFSET}+106)) | \
+ $((${GPIO_OFFSET}+107)) | \
+ $((${GPIO_OFFSET}+108)) )
echo out > /sys/class/gpio/gpio${i}/direction
;;
esac
@@ -623,6 +693,12 @@ function _i2c_gpio_init {
#GPIO DeInit
function _i2c_gpio_deinit {
+ for((i=${GPIO_OFFSET}+96;i<=${GPIO_OFFSET}+255;i++));
+ do
+ if [ -e "/sys/class/gpio/gpio${i}" ]; then
+ echo ${i} > /sys/class/gpio/unexport
+ fi
+ done
echo "0x20" > /sys/bus/i2c/devices/i2c-${NUM_MUX1_CHAN4_DEVICE}/delete_device
echo "0x21" > /sys/bus/i2c/devices/i2c-${NUM_MUX1_CHAN4_DEVICE}/delete_device
echo "0x22" > /sys/bus/i2c/devices/i2c-${NUM_MUX1_CHAN4_DEVICE}/delete_device
@@ -669,7 +745,7 @@ function _i2c_led_fan_tray_status_set {
if [ "${FAN1_ALARM}" == "0" ] && [ "${FAN2_ALARM}" == "0" ]; then
FAN_TRAY=1
- echo "FAN_TRAY${FAN_TRAY}..."
+ echo "FAN_TRAY${FAN_TRAY}..."
COLOR_SYS_LED="green"
ONOFF_LED="on"
echo "${COLOR_SYS_LED} ${ONOFF_LED}"
@@ -679,8 +755,8 @@ function _i2c_led_fan_tray_status_set {
echo "${COLOR_SYS_LED} ${ONOFF_LED}"
_i2c_fan_tray_led
else
- FAN_TRAY=1
- echo "FAN_TRAY${FAN_TRAY}..."
+ FAN_TRAY=1
+ echo "FAN_TRAY${FAN_TRAY}..."
COLOR_SYS_LED="green"
ONOFF_LED="off"
echo "${COLOR_SYS_LED} ${ONOFF_LED}"
@@ -692,8 +768,8 @@ function _i2c_led_fan_tray_status_set {
fi
if [ "${FAN3_ALARM}" == "0" ] && [ "${FAN4_ALARM}" == "0" ]; then
- FAN_TRAY=2
- echo "FAN_TRAY${FAN_TRAY}..."
+ FAN_TRAY=2
+ echo "FAN_TRAY${FAN_TRAY}..."
COLOR_SYS_LED="green"
ONOFF_LED="on"
echo "${COLOR_SYS_LED} ${ONOFF_LED}"
@@ -703,8 +779,8 @@ function _i2c_led_fan_tray_status_set {
echo "${COLOR_SYS_LED} ${ONOFF_LED}"
_i2c_fan_tray_led
else
- FAN_TRAY=2
- echo "FAN_TRAY${FAN_TRAY}..."
+ FAN_TRAY=2
+ echo "FAN_TRAY${FAN_TRAY}..."
COLOR_SYS_LED="green"
ONOFF_LED="off"
echo "${COLOR_SYS_LED} ${ONOFF_LED}"
@@ -716,8 +792,8 @@ function _i2c_led_fan_tray_status_set {
fi
if [ "${FAN5_ALARM}" == "0" ] && [ "${FAN6_ALARM}" == "0" ]; then
- FAN_TRAY=3
- echo "FAN_TRAY${FAN_TRAY}..."
+ FAN_TRAY=3
+ echo "FAN_TRAY${FAN_TRAY}..."
COLOR_SYS_LED="green"
ONOFF_LED="on"
echo "${COLOR_SYS_LED} ${ONOFF_LED}"
@@ -727,8 +803,8 @@ function _i2c_led_fan_tray_status_set {
echo "${COLOR_SYS_LED} ${ONOFF_LED}"
_i2c_fan_tray_led
else
- FAN_TRAY=3
- echo "FAN_TRAY${FAN_TRAY}..."
+ FAN_TRAY=3
+ echo "FAN_TRAY${FAN_TRAY}..."
COLOR_SYS_LED="green"
ONOFF_LED="off"
echo "${COLOR_SYS_LED} ${ONOFF_LED}"
@@ -740,8 +816,8 @@ function _i2c_led_fan_tray_status_set {
fi
if [ "${FAN7_ALARM}" == "0" ] && [ "${FAN8_ALARM}" == "0" ]; then
- FAN_TRAY=4
- echo "FAN_TRAY${FAN_TRAY}..."
+ FAN_TRAY=4
+ echo "FAN_TRAY${FAN_TRAY}..."
COLOR_SYS_LED="green"
ONOFF_LED="on"
echo "${COLOR_SYS_LED} ${ONOFF_LED}"
@@ -751,8 +827,8 @@ function _i2c_led_fan_tray_status_set {
echo "${COLOR_SYS_LED} ${ONOFF_LED}"
_i2c_fan_tray_led
else
- FAN_TRAY=4
- echo "FAN_TRAY${FAN_TRAY}..."
+ FAN_TRAY=4
+ echo "FAN_TRAY${FAN_TRAY}..."
COLOR_SYS_LED="green"
ONOFF_LED="off"
echo "${COLOR_SYS_LED} ${ONOFF_LED}"
@@ -814,43 +890,50 @@ function _qsfp_port_i2c_var_set {
regAddr=0x20
dataAddr=0
eeprombusbase=${NUM_MUX3_CHAN0_DEVICE}
- gpioBase=240
+ gpioBase=$((${GPIO_OFFSET}+240))
+ #gpioBase=240
;;
9|10|11|12|13|14|15|16)
i2cbus=${NUM_MUX1_CHAN4_DEVICE}
regAddr=0x20
dataAddr=1
eeprombusbase=${NUM_MUX4_CHAN0_DEVICE}
- gpioBase=240
+ gpioBase=$((${GPIO_OFFSET}+240))
+ #gpioBase=240
;;
17|18|19|20|21|22|23|24)
i2cbus=${NUM_MUX1_CHAN4_DEVICE}
regAddr=0x21
dataAddr=0
eeprombusbase=${NUM_MUX5_CHAN0_DEVICE}
- gpioBase=$((224 - 16))
+ gpioBase=$((${GPIO_OFFSET}+224-16))
+ #gpioBase=$((224 - 16))
;;
25|26|27|28|29|30|31|32)
i2cbus=${NUM_MUX1_CHAN4_DEVICE}
regAddr=0x21
dataAddr=1
eeprombusbase=${NUM_MUX6_CHAN0_DEVICE}
- gpioBase=$((224 - 16))
+ gpioBase=$((${GPIO_OFFSET}+224-16))
+ #gpioBase=$((224 - 16))
;;
33)
i2cbus=${NUM_MUX1_CHAN7_DEVICE}
regAddr=0x27
dataAddr=0
- gpioBase=145
+ gpioBase=$((${GPIO_OFFSET}+145))
+ #gpioBase=145
;;
34)
i2cbus=${NUM_MUX1_CHAN7_DEVICE}
regAddr=0x27
dataAddr=1
- gpioBase=143
+ gpioBase=$((${GPIO_OFFSET}+143))
+ #gpioBase=143
;;
*)
echo "Please input 1~34"
+ exit
;;
esac
}
@@ -1046,8 +1129,10 @@ function _i2c_sfp_eeprom_init {
if [ "${action}" == "new" ] && \
! [ -L ${PATH_SYS_I2C_DEVICES}/${NUM_SFP1_DEVICE}-0050 ] && \
! [ -L ${PATH_SYS_I2C_DEVICES}/${NUM_SFP2_DEVICE}-0050 ]; then
- echo "sff8436 0x50" > ${PATH_SYS_I2C_DEVICES}/i2c-${NUM_SFP1_DEVICE}/new_device
- echo "sff8436 0x50" > ${PATH_SYS_I2C_DEVICES}/i2c-${NUM_SFP2_DEVICE}/new_device
+ #echo "sff8436 0x50" > ${PATH_SYS_I2C_DEVICES}/i2c-${NUM_SFP1_DEVICE}/new_device
+ #echo "sff8436 0x50" > ${PATH_SYS_I2C_DEVICES}/i2c-${NUM_SFP2_DEVICE}/new_device
+ echo "optoe1 0x50" > ${PATH_SYS_I2C_DEVICES}/i2c-${NUM_SFP1_DEVICE}/new_device
+ echo "optoe1 0x50" > ${PATH_SYS_I2C_DEVICES}/i2c-${NUM_SFP2_DEVICE}/new_device
elif [ "${action}" == "delete" ] && \
[ -L ${PATH_SYS_I2C_DEVICES}/${NUM_SFP1_DEVICE}-0050 ] && \
[ -L ${PATH_SYS_I2C_DEVICES}/${NUM_SFP2_DEVICE}-0050 ]; then
@@ -1097,7 +1182,10 @@ function _i2c_qsfp_type_get {
_qsfp_eeprom_var_set ${QSFP_PORT}
#Get QSFP EEPROM info
- qsfp_info=$(base64 ${PATH_SYS_I2C_DEVICES}/$eeprombus-$(printf "%04x" $eepromAddr)/eeprom)
+ local size=255
+ eeprom_path="${PATH_SYS_I2C_DEVICES}/$eeprombus-$(printf "%04x" $eepromAddr)/eeprom"
+ #echo "get ${eeprom_path}"
+ qsfp_info=$(dd if=${eeprom_path} bs=${size} count=1 2>/dev/null | base64)
identifier=$(echo $qsfp_info | base64 -d -i | hexdump -s 128 -n 1 -e '"%x"')
connector=$(echo $qsfp_info | base64 -d -i | hexdump -s 130 -n 1 -e '"%x"')
@@ -1182,6 +1270,7 @@ function _i2c_port_led_set {
;;
*)
echo "Please input 1~34"
+ exit
;;
esac
@@ -1251,12 +1340,12 @@ function _i2c_psu_eeprom_get {
function _i2c_sys_led {
if [ "${COLOR_SYS_LED}" == "green" ]; then
- # set sys_led_g (0.7) = 1
+ # set sys_led_g (0.0) = 1
output_reg=2
mask=0x01
value=0x01
elif [ "${COLOR_SYS_LED}" == "amber" ]; then
- # set sys_led_g (0.7) = 0
+ # set sys_led_g (0.0) = 0
output_reg=2
mask=0x01
value=0x00
@@ -1353,24 +1442,186 @@ function _i2c_fan_led {
echo "done..."
}
+#Set PSU1 LED
+function _i2c_psu1_led {
+ local value=0
+ local mask=8
+
+ if [ "${COLOR_SYS_LED}" == "green" ]; then
+ value=0x00
+ elif [ "${COLOR_SYS_LED}" == "amber" ]; then
+ value=0xFF
+ else
+ echo "Invalid Parameters ${COLOR_SYS_LED}, Exit!!!"
+ _help
+ exit ${FALSE}
+ fi
+
+ i2cset -m ${mask} -y -r ${NUM_MAIN_MUX_CHAN1_DEVICE} 0x75 2 ${value}
+}
+
+#Set PSU2 LED
+function _i2c_psu2_led {
+ local value=0
+ local mask=16
+
+ if [ "${COLOR_SYS_LED}" == "green" ]; then
+ value=0x00
+ elif [ "${COLOR_SYS_LED}" == "amber" ]; then
+ value=0xFF
+ else
+ echo "Invalid Parameters ${COLOR_SYS_LED}, Exit!!!"
+ _help
+ exit ${FALSE}
+ fi
+
+ i2cset -m ${mask} -y -r ${NUM_MAIN_MUX_CHAN1_DEVICE} 0x75 2 ${value}
+}
#Get PSU Status
function _i2c_psu_status {
- psu2PwGood=`cat /sys/class/gpio/gpio96/value` # PSU0_PWROK (0.0)
- psu2Exist=`cat /sys/class/gpio/gpio97/value` # PSU0_PRSNT_L (0.1)
+ psu1_pwgood_gpio=$((${GPIO_OFFSET}+99))
+ psu1_exist_gpio=$((${GPIO_OFFSET}+100))
+ psu2_pwdgood_gpio=$((${GPIO_OFFSET}+96))
+ psu2_exist_gpio=$((${GPIO_OFFSET}+97))
- psu1PwGood=`cat /sys/class/gpio/gpio99/value` # PSU1_PWROK (0.3)
- psu1Exist=`cat /sys/class/gpio/gpio100/value` # PSU1_PRSNT_L (0.4)
+ psu2PwGood=`cat /sys/class/gpio/gpio${psu2_pwdgood_gpio}/value` # PSU0_PWROK (0.0)
+ psu2Exist=`cat /sys/class/gpio/gpio${psu2_exist_gpio}/value` # PSU0_PRSNT_L (0.1)
+
+ psu1PwGood=`cat /sys/class/gpio/gpio${psu1_pwgood_gpio}/value` # PSU1_PWROK (0.3)
+ psu1Exist=`cat /sys/class/gpio/gpio${psu1_exist_gpio}/value` # PSU1_PRSNT_L (0.4)
printf "PSU1 Exist:%d PSU1 PW Good:%d\n" $psu1Exist $psu1PwGood
printf "PSU2 Exist:%d PSU2 PW Good:%d\n" $psu2Exist $psu2PwGood
}
+# util function to get logx value
+function logx {
+ v=$1
+ n=$2
+ logx_res=$(echo "${v} ${n}" | awk '{printf "%f\n",log($1)/log($2)}')
+}
+
+#Set PSU LED on LED Board
+function _i2c_led_psu_status_set {
+
+ echo "========================================================="
+ echo "# Description: PSU LED Status Setup"
+ echo "========================================================="
+
+ #Get PSU Status
+ _i2c_psu_status
+
+ #PSU1 Status
+ echo "------------------------------"
+ if [ "${psu1Exist}" == ${PSU_EXIST} ]; then
+ if [ "${psu1PwGood}" == ${PSU_DC_ON} ]; then
+ COLOR_SYS_LED="green"
+ _i2c_psu1_led
+ else
+ COLOR_SYS_LED="amber"
+ _i2c_psu1_led
+ fi
+ else
+ COLOR_SYS_LED="amber"
+ _i2c_psu1_led
+ fi
+ echo "set [PSU1 LED] = ${COLOR_SYS_LED}"
+
+ #PSU2 Status
+ echo "------------------------------"
+ if [ "${psu2Exist}" == ${PSU_EXIST} ]; then
+ if [ "${psu2PwGood}" == ${PSU_DC_ON} ]; then
+ COLOR_SYS_LED="green"
+ _i2c_psu2_led
+ else
+ COLOR_SYS_LED="amber"
+ #ONOFF_LED="on"
+ _i2c_psu2_led
+ fi
+ else
+ COLOR_SYS_LED="amber"
+ _i2c_psu2_led
+ fi
+ echo "set [PSU2 LED] = ${COLOR_SYS_LED}"
+}
+
+# get qsfp ddm data
+function _i2c_qsfp_ddm_get {
+
+ _qsfp_port_i2c_var_set ${QSFP_PORT}
+
+ # check if port presence
+ #status: 0 -> Down, 1 -> Up
+ status=`cat /sys/class/gpio/gpio$(( $(($gpioBase + (${QSFP_PORT} - 1) ^ 1)) ))/value`
+ if [ "${status}" == "0" ]; then
+ echo "port ${QSFP_PORT} not presence"
+ return
+ fi
+
+ _qsfp_eeprom_var_set ${QSFP_PORT}
+
+ # Get QSFP EEPROM info
+ # only need first 128 bytes (page0) for ddm parsing
+ local size=128
+ eeprom_path="${PATH_SYS_I2C_DEVICES}/$eeprombus-$(printf "%04x" $eepromAddr)/eeprom"
+ #echo "get ${eeprom_path}"
+ qsfp_info=$(dd if=${eeprom_path} bs=${size} count=1 2>/dev/null | base64)
+
+ # temperature
+ temp_val1=$(echo $qsfp_info | base64 -d -i | hexdump -s 22 -n 1 -e '"%d"')
+ temp_val2=$(echo $qsfp_info | base64 -d -i | hexdump -s 23 -n 1 -e '"%d"')
+ temp=$(echo "$temp_val1 $temp_val2" | awk '{printf "%f\n", $1 + $2/256.0}')
+ #temp=$(( ${temp_val1} + ${temp_val2}/256.0 ))
+ echo "temp=$temp"
+ # voltage
+ volt_val1=$(echo $qsfp_info | base64 -d -i | hexdump -s 26 -n 1 -e '"%d"')
+ volt_val2=$(echo $qsfp_info | base64 -d -i | hexdump -s 27 -n 1 -e '"%d"')
+ #volt=$(((($volt_val1 << 8) | volt_val2) / 10000))
+ volt_val3=$(( ($volt_val1 << 8) | $volt_val2 ))
+ volt=$(echo "$volt_val3" | awk '{printf "%f\n", $1/10000.0}')
+ echo "volt=$volt"
+
+ # 4 channels
+ for i in {0..3};
+ do
+ echo "channel $i:"
+ # txBias
+ offset=$(( 42 + $i*2 ))
+ txBias_val1=$(echo $qsfp_info | base64 -d -i | hexdump -s $offset -n 1 -e '"%d"')
+ offset=$(( 43 + $i*2 ))
+ txBias_val2=$(echo $qsfp_info | base64 -d -i | hexdump -s $offset -n 1 -e '"%d"')
+ txBias_val3=$(( ($txBias_val1 << 8) | $txBias_val2 ))
+ txBias=$(echo "$txBias_val3" | awk '{printf "%f\n", (131.0*$1)/65535}')
+ echo " txBias=$txBias"
+ # txPower
+ offset=$(( 50 + $i*2 ))
+ txPower_val1=$(echo $qsfp_info | base64 -d -i | hexdump -s $offset -n 1 -e '"%d"')
+ offset=$(( 51 + $i*2 ))
+ txPower_val2=$(echo $qsfp_info | base64 -d -i | hexdump -s $offset -n 1 -e '"%d"')
+ txPower_val3=$(( ($txPower_val1 << 8) | $txPower_val2 ))
+ txPower_val4=$(echo "$txPower_val3" | awk '{printf "%f\n", $1*0.0001}')
+ logx $txPower_val4 10
+ txPower=$(echo "$logx_res" | awk '{printf "%f\n", $1*10}')
+ echo " txPower=$txPower"
+ # rxPower
+ offset=$(( 34 + $i*2 ))
+ rxPower_val1=$(echo $qsfp_info | base64 -d -i | hexdump -s $offset -n 1 -e '"%d"')
+ offset=$(( 35 + $i*2 ))
+ rxPower_val2=$(echo $qsfp_info | base64 -d -i | hexdump -s $offset -n 1 -e '"%d"')
+ rxPower_val3=$(( ($rxPower_val1 << 8) | $rxPower_val2 ))
+ rxPower_val4=$(echo "$rxPower_val3" | awk '{printf "%f\n", $1*0.0001}')
+ logx $rxPower_val4 10
+ rxPower=$(echo "$logx_res" | awk '{printf "%f\n", $1*10}')
+ echo " rxPower=$rxPower"
+ done
+}
#Main Function
function _main {
start_time_str=`date`
start_time_sec=$(date +%s)
+ _set_gpio_offset
if [ "${EXEC_FUNC}" == "help" ]; then
_help
elif [ "${EXEC_FUNC}" == "i2c_init" ]; then
@@ -1411,6 +1662,10 @@ function _main {
_i2c_qsfp_status_get
elif [ "${EXEC_FUNC}" == "i2c_qsfp_type_get" ]; then
_i2c_qsfp_type_get
+ elif [ "${EXEC_FUNC}" == "i2c_led_psu_status_set" ]; then
+ _i2c_led_psu_status_set
+ elif [ "${EXEC_FUNC}" == "i2c_qsfp_ddm_get" ]; then
+ _i2c_qsfp_ddm_get
elif [ "${EXEC_FUNC}" == "i2c_led_fan_status_set" ]; then
_i2c_led_fan_status_set
elif [ "${EXEC_FUNC}" == "i2c_led_fan_tray_status_set" ]; then
@@ -1421,6 +1676,10 @@ function _main {
_i2c_fan_led
elif [ "${EXEC_FUNC}" == "i2c_fan_tray_led" ]; then
_i2c_fan_tray_led
+ elif [ "${EXEC_FUNC}" == "i2c_psu1_led" ]; then
+ _i2c_psu1_led
+ elif [ "${EXEC_FUNC}" == "i2c_psu2_led" ]; then
+ _i2c_psu2_led
elif [ "${EXEC_FUNC}" == "i2c_board_type_get" ]; then
_i2c_board_type_get
elif [ "${EXEC_FUNC}" == "i2c_cpld_version" ]; then
@@ -1446,14 +1705,17 @@ function _main {
exit ${FALSE}
fi
- end_time_str=`date`
- end_time_sec=$(date +%s)
- diff_time=$[ ${end_time_sec} - ${start_time_sec} ]
- echo "Start Time: ${start_time_str} (${start_time_sec})"
- echo "End Time : ${end_time_str} (${end_time_sec})"
- echo "Total Execution Time: ${diff_time} sec"
+ if [ "$DEBUG" == "on" ]; then
+ echo "-----------------------------------------------------"
+ end_time_str=`date`
+ end_time_sec=$(date +%s)
+ diff_time=$[ ${end_time_sec} - ${start_time_sec} ]
+ echo "Start Time: ${start_time_str} (${start_time_sec})"
+ echo "End Time : ${end_time_str} (${end_time_sec})"
+ echo "Total Execution Time: ${diff_time} sec"
- echo "done!!!"
+ echo "done!!!"
+ fi
}
_main
diff --git a/platform/barefoot/sonic-platform-modules-ingrasys/s9280-64x/utils/i2c_utils.sh b/platform/barefoot/sonic-platform-modules-ingrasys/s9280-64x/utils/i2c_utils.sh
index fcb7b6372e..dcd7bf7173 100755
--- a/platform/barefoot/sonic-platform-modules-ingrasys/s9280-64x/utils/i2c_utils.sh
+++ b/platform/barefoot/sonic-platform-modules-ingrasys/s9280-64x/utils/i2c_utils.sh
@@ -322,6 +322,7 @@ function _help {
echo " : ${0} i2c_sfp_status_get [${MIN_SFP_PORT_NUM}-${MAX_SFP_PORT_NUM}]"
echo " : ${0} i2c_qsfp_type_get [${MIN_QSFP_PORT_NUM}-${MAX_QSFP_PORT_NUM}]"
echo " : ${0} i2c_sfp_type_get [${MIN_SFP_PORT_NUM}-${MAX_SFP_PORT_NUM}]"
+ echo " : ${0} i2c_qsfp_ddm_get [${MIN_QSFP_PORT_NUM}-${MAX_QSFP_PORT_NUM}]"
echo " : ${0} i2c_board_type_get"
echo " : ${0} i2c_bmc_board_type_get"
echo " : ${0} i2c_cpld_version"
@@ -945,7 +946,7 @@ function _i2c_led_test {
#Turn OFF All LED (can't trun off system led)
COLOR_LED="off"
- _i2c_sys_led
+ #_i2c_sys_led
_i2c_fan_led
_i2c_psu1_led
_i2c_psu2_led
@@ -962,7 +963,6 @@ function _qsfp_cpld_var_set {
local reg_port_base
local reg_port_shift
- echo "_qsfp_cpld_var_set port=$port"
if [[ $1 -le 12 && $1 -ge 1 ]]; then
cpld_index=1
reg_port_base=0
@@ -1068,7 +1068,7 @@ function _i2c_qsfp_eeprom_get {
local phy_port=0
# input parameter validation
- _util_input_check ${QSFP_PORT} ${MIN_QSFP_PORT_NUM} ${MAX_QSFP_PORT_NUM}
+ _util_input_check "${QSFP_PORT}" "${MIN_QSFP_PORT_NUM}" "${MAX_QSFP_PORT_NUM}"
#get physical port
phy_port=$(_port_fp2phy $QSFP_PORT)
@@ -1112,8 +1112,8 @@ function _i2c_qsfp_eeprom_init {
if [ "${action}" == "new" ] && \
! [ -L ${PATH_SYS_I2C_DEVICES}/$eepromBus-$(printf "%04x" $eepromAddr) ]; then
- echo "sff8436 $eepromAddr" > ${PATH_SYS_I2C_DEVICES}/i2c-$eepromBus/new_device
- #echo "optoe1 $eepromAddr" > ${PATH_SYS_I2C_DEVICES}/i2c-$eepromBus/new_device
+ #echo "sff8436 $eepromAddr" > ${PATH_SYS_I2C_DEVICES}/i2c-$eepromBus/new_device
+ echo "optoe1 $eepromAddr" > ${PATH_SYS_I2C_DEVICES}/i2c-$eepromBus/new_device
elif [ "${action}" == "delete" ] && \
[ -L ${PATH_SYS_I2C_DEVICES}/$eepromBus-$(printf "%04x" $eepromAddr) ]; then
echo "$eepromAddr" > ${PATH_SYS_I2C_DEVICES}/i2c-$eepromBus/delete_device
@@ -1126,7 +1126,7 @@ function _i2c_qsfp_eeprom_init {
function _i2c_sfp_eeprom_get {
# input parameter validation
- _util_input_check ${SFP_PORT} ${MIN_SFP_PORT_NUM} ${MAX_SFP_PORT_NUM}
+ _util_input_check "${SFP_PORT}" "${MIN_SFP_PORT_NUM}" "${MAX_SFP_PORT_NUM}"
_util_get_sfp_pres
if [ $status = 0 ]; then
@@ -1160,8 +1160,8 @@ function _i2c_sfp_eeprom_init {
if [ "${action}" == "new" ] && \
! [ -L ${PATH_SYS_I2C_DEVICES}/$eepromBus-$(printf "%04x" $eepromAddr) ]; then
- echo "sff8436 $eepromAddr" > ${PATH_SYS_I2C_DEVICES}/i2c-$eepromBus/new_device
- #echo "optoe1 $eepromAddr" > ${PATH_SYS_I2C_DEVICES}/i2c-$eepromBus/new_device
+ #echo "sff8436 $eepromAddr" > ${PATH_SYS_I2C_DEVICES}/i2c-$eepromBus/new_device
+ echo "optoe1 $eepromAddr" > ${PATH_SYS_I2C_DEVICES}/i2c-$eepromBus/new_device
elif [ "${action}" == "delete" ] && \
[ -L ${PATH_SYS_I2C_DEVICES}/$eepromBus-$(printf "%04x" $eepromAddr) ]; then
echo "$eepromAddr" > ${PATH_SYS_I2C_DEVICES}/i2c-$eepromBus/delete_device
@@ -1242,7 +1242,7 @@ function _i2c_psu_deinit {
function _i2c_qsfp_status_get {
# input parameter validation
- _util_input_check ${QSFP_PORT} ${MIN_QSFP_PORT_NUM} ${MAX_QSFP_PORT_NUM}
+ _util_input_check "${QSFP_PORT}" "${MIN_QSFP_PORT_NUM}" "${MAX_QSFP_PORT_NUM}"
local stat
_util_get_qsfp_abs
@@ -1256,12 +1256,15 @@ function _i2c_qsfp_type_get {
phy_port=$(_port_fp2phy ${QSFP_PORT})
# input parameter validation
- _util_input_check ${QSFP_PORT} ${MIN_QSFP_PORT_NUM} ${MAX_QSFP_PORT_NUM}
+ _util_input_check "${QSFP_PORT}" "${MIN_QSFP_PORT_NUM}" "${MAX_QSFP_PORT_NUM}"
_qsfp_eeprom_var_set ${phy_port}
#Get QSFP EEPROM info
- qsfp_info=$(base64 ${PATH_SYS_I2C_DEVICES}/$eepromBus-$(printf "%04x" $eepromAddr)/eeprom)
+ local size=255
+ eeprom_path="${PATH_SYS_I2C_DEVICES}/$eepromBus-$(printf "%04x" $eepromAddr)/eeprom"
+ #echo "get ${eeprom_path}"
+ qsfp_info=$(dd if=${eeprom_path} bs=${size} count=1 2>/dev/null | base64)
identifier=$(echo $qsfp_info | base64 -d -i | hexdump -s 128 -n 1 -e '"%x"')
connector=$(echo $qsfp_info | base64 -d -i | hexdump -s 130 -n 1 -e '"%x"')
@@ -1275,7 +1278,7 @@ function _i2c_qsfp_type_get {
function _i2c_sfp_status_get {
# input parameter validation
- _util_input_check ${SFP_PORT} ${MIN_SFP_PORT_NUM} ${MAX_SFP_PORT_NUM}
+ _util_input_check "${SFP_PORT}" "${MIN_SFP_PORT_NUM}" "${MAX_SFP_PORT_NUM}"
local stat
_util_get_sfp_pres
@@ -1292,7 +1295,7 @@ function _i2c_sfp_status_get {
function _i2c_sfp_type_get {
# input parameter validation
- _util_input_check ${SFP_PORT} ${MIN_SFP_PORT_NUM} ${MAX_SFP_PORT_NUM}
+ _util_input_check "${SFP_PORT}" "${MIN_SFP_PORT_NUM}" "${MAX_SFP_PORT_NUM}"
_sfp_eeprom_var_set ${SFP_PORT}
@@ -1653,8 +1656,6 @@ function _i2c_cpld_reg_read {
reg_file_path="${PATH_SYS_I2C_DEVICES}/${cpld_i2c_bus}-$(printf "%04x" ${cpld_i2c_addr})/${file_name}"
cpld_reg_val=`cat ${reg_file_path}`
- # TODO: debug
- echo "cat ${reg_file_path} => ${cpld_reg_val}"
}
#util functions
@@ -1688,7 +1689,6 @@ function _util_get_qsfp_abs {
#get physical port
phy_port=$(_port_fp2phy $QSFP_PORT)
- echo "fp port $QSFP_PORT => phy port $phy_port"
# read status from cpld
_qsfp_cpld_var_set ${phy_port}
cpld_reg_file_name="${CPLD_QSFP_STATUS_KEY}_${cpld_port_index}"
@@ -1743,6 +1743,88 @@ function _config_rmem {
echo "109430400" > /proc/sys/net/core/rmem_max
}
+# util function to get logx value
+function logx {
+ v=$1
+ n=$2
+ logx_res=$(echo "${v} ${n}" | awk '{printf "%f\n",log($1)/log($2)}')
+}
+
+# get qsfp ddm data
+function _i2c_qsfp_ddm_get {
+ local phy_port=0
+
+ phy_port=$(_port_fp2phy ${QSFP_PORT})
+
+ # input parameter validation
+ _util_input_check "${QSFP_PORT}" "${MIN_QSFP_PORT_NUM}" "${MAX_QSFP_PORT_NUM}"
+
+ # check if port presence
+ #status: 0 -> Down, 1 -> Up
+ _util_get_qsfp_abs
+ if [ "${status}" == "0" ]; then
+ echo "port ${QSFP_PORT} not presence"
+ return
+ fi
+
+ _qsfp_eeprom_var_set ${phy_port}
+
+ # Get QSFP EEPROM info
+ # only need first 128 bytes (page0) for ddm parsing
+ local size=128
+ eeprom_path="${PATH_SYS_I2C_DEVICES}/$eepromBus-$(printf "%04x" $eepromAddr)/eeprom"
+ #echo "get ${eeprom_path}"
+ qsfp_info=$(dd if=${eeprom_path} bs=${size} count=1 2>/dev/null | base64)
+
+ # temperature
+ temp_val1=$(echo $qsfp_info | base64 -d -i | hexdump -s 22 -n 1 -e '"%d"')
+ temp_val2=$(echo $qsfp_info | base64 -d -i | hexdump -s 23 -n 1 -e '"%d"')
+ temp=$(echo "$temp_val1 $temp_val2" | awk '{printf "%f\n", $1 + $2/256.0}')
+ #temp=$(( ${temp_val1} + ${temp_val2}/256.0 ))
+ echo "temp=$temp"
+ # voltage
+ volt_val1=$(echo $qsfp_info | base64 -d -i | hexdump -s 26 -n 1 -e '"%d"')
+ volt_val2=$(echo $qsfp_info | base64 -d -i | hexdump -s 27 -n 1 -e '"%d"')
+ #volt=$(((($volt_val1 << 8) | volt_val2) / 10000))
+ volt_val3=$(( ($volt_val1 << 8) | $volt_val2 ))
+ volt=$(echo "$volt_val3" | awk '{printf "%f\n", $1/10000.0}')
+ echo "volt=$volt"
+
+ # 4 channels
+ for i in {0..3};
+ do
+ echo "channel $i:"
+ # txBias
+ offset=$(( 42 + $i*2 ))
+ txBias_val1=$(echo $qsfp_info | base64 -d -i | hexdump -s $offset -n 1 -e '"%d"')
+ offset=$(( 43 + $i*2 ))
+ txBias_val2=$(echo $qsfp_info | base64 -d -i | hexdump -s $offset -n 1 -e '"%d"')
+ txBias_val3=$(( ($txBias_val1 << 8) | $txBias_val2 ))
+ txBias=$(echo "$txBias_val3" | awk '{printf "%f\n", (131.0*$1)/65535}')
+ echo " txBias=$txBias"
+ # txPower
+ offset=$(( 50 + $i*2 ))
+ txPower_val1=$(echo $qsfp_info | base64 -d -i | hexdump -s $offset -n 1 -e '"%d"')
+ offset=$(( 51 + $i*2 ))
+ txPower_val2=$(echo $qsfp_info | base64 -d -i | hexdump -s $offset -n 1 -e '"%d"')
+ txPower_val3=$(( ($txPower_val1 << 8) | $txPower_val2 ))
+ txPower_val4=$(echo "$txPower_val3" | awk '{printf "%f\n", $1*0.0001}')
+ logx $txPower_val4 10
+ txPower=$(echo "$logx_res" | awk '{printf "%f\n", $1*10}')
+ echo " txPower=$txPower"
+ # rxPower
+ offset=$(( 34 + $i*2 ))
+ rxPower_val1=$(echo $qsfp_info | base64 -d -i | hexdump -s $offset -n 1 -e '"%d"')
+ offset=$(( 35 + $i*2 ))
+ rxPower_val2=$(echo $qsfp_info | base64 -d -i | hexdump -s $offset -n 1 -e '"%d"')
+ rxPower_val3=$(( ($rxPower_val1 << 8) | $rxPower_val2 ))
+ rxPower_val4=$(echo "$rxPower_val3" | awk '{printf "%f\n", $1*0.0001}')
+ logx $rxPower_val4 10
+ rxPower=$(echo "$logx_res" | awk '{printf "%f\n", $1*10}')
+ echo " rxPower=$rxPower"
+ done
+}
+
#Main Function
function _main {
tart_time_str=`date`
@@ -1788,6 +1870,8 @@ function _main {
_i2c_qsfp_type_get
elif [ "${EXEC_FUNC}" == "i2c_sfp_type_get" ]; then
_i2c_sfp_type_get
+ elif [ "${EXEC_FUNC}" == "i2c_qsfp_ddm_get" ]; then
+ _i2c_qsfp_ddm_get
elif [ "${EXEC_FUNC}" == "i2c_led_psu_status_set" ]; then
_i2c_led_psu_status_set
elif [ "${EXEC_FUNC}" == "i2c_led_fan_status_set" ]; then
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/rules b/platform/broadcom/sonic-platform-modules-ingrasys/debian/rules
index 352dd55afb..759d26c5c4 100755
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/rules
+++ b/platform/broadcom/sonic-platform-modules-ingrasys/debian/rules
@@ -1,13 +1,4 @@
#!/usr/bin/make -f
-# -*- makefile -*-
-# Sample debian/rules that uses debhelper.
-# This file was originally written by Joey Hess and Craig Small.
-# As a special exception, when this file is copied by dh-make into a
-# dh-make output file, you may use that output file without restriction.
-# This special exception was added by Craig Small in version 0.37 of dh-make.
-
-# Uncomment this to turn on verbose mode.
-#export DH_VERBOSE=1
export INSTALL_MOD_DIR:=extra
@@ -15,7 +6,7 @@ PACKAGE_PRE_NAME := sonic-platform-ingrasys
KVERSION ?= $(shell uname -r)
KERNEL_SRC := /lib/modules/$(KVERSION)
MOD_SRC_DIR:= $(shell pwd)
-MODULE_DIRS:= s9100 s8900-64xc s8900-54xc s8810-32q s9200-64x
+MODULE_DIRS:= s9100 s8900-64xc s8900-54xc s8810-32q s9200-64x
MODULE_DIR := modules
UTILS_DIR := utils
SERVICE_DIR := service
@@ -24,57 +15,28 @@ CONF_DIR := conf
%:
dh $@ --with systemd
-clean:
- dh_testdir
- dh_testroot
- dh_clean
-
-build:
- #make modules -C $(KERNEL_SRC)/build M=$(MODULE_SRC)
+override_dh_auto_build:
(for mod in $(MODULE_DIRS); do \
make modules -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \
done)
-binary: binary-arch binary-indep
- # Nothing to do
-
-binary-arch:
- # Nothing to do
-
-#install: build
- #dh_testdir
- #dh_testroot
- #dh_clean -k
- #dh_installdirs
-
-binary-indep:
- dh_testdir
- dh_installdirs
-
- # Custom package commands
+override_dh_auto_install:
(for mod in $(MODULE_DIRS); do \
- mkdir debian/tmp/usr/sbin -p; \
- mkdir debian/tmp/lib/systemd/system -p; \
- mkdir debian/tmp/etc -p; \
- dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} $(KERNEL_SRC)/$(INSTALL_MOD_DIR); \
- cp $(MOD_SRC_DIR)/$${mod}/$(MODULE_DIR)/*.ko debian/$(PACKAGE_PRE_NAME)-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \
- cp $(MOD_SRC_DIR)/$${mod}/$(UTILS_DIR)/*.sh debian/$(PACKAGE_PRE_NAME)-$${mod}/usr/sbin/; \
- cp $(MOD_SRC_DIR)/$${mod}/$(SERVICE_DIR)/*.service debian/$(PACKAGE_PRE_NAME)-$${mod}/lib/systemd/system/; \
+ dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} \
+ $(KERNEL_SRC)/$(INSTALL_MOD_DIR); \
+ cp $(MOD_SRC_DIR)/$${mod}/$(MODULE_DIR)/*.ko \
+ debian/$(PACKAGE_PRE_NAME)-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \
+ dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} usr/sbin; \
+ cp $(MOD_SRC_DIR)/$${mod}/$(UTILS_DIR)/*.sh \
+ debian/$(PACKAGE_PRE_NAME)-$${mod}/usr/sbin; \
+ dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} lib/systemd/system; \
+ cp $(MOD_SRC_DIR)/$${mod}/$(SERVICE_DIR)/*.service \
+ debian/$(PACKAGE_PRE_NAME)-$${mod}/lib/systemd/system; \
done)
- # Resuming debhelper scripts
- dh_testroot
- dh_install
- dh_installchangelogs
- dh_installdocs
- dh_systemd_enable
- dh_installinit
- dh_systemd_start
- dh_link
- dh_fixperms
- dh_compress
- dh_strip
- dh_installdeb
- dh_gencontrol
- dh_md5sums
- dh_builddeb
-.PHONY: build binary binary-arch binary-indep clean
+
+override_dh_clean:
+ dh_clean
+ (for mod in $(MODULE_DIRS); do \
+ make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules clean; \
+ done)
+
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8810-32q.dirs b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8810-32q.dirs
deleted file mode 100644
index bec29f1957..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8810-32q.dirs
+++ /dev/null
@@ -1,3 +0,0 @@
-usr/sbin
-lib/systemd/system
-etc/
\ No newline at end of file
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8810-32q.init b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8810-32q.init
new file mode 100644
index 0000000000..19f51c0a96
--- /dev/null
+++ b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8810-32q.init
@@ -0,0 +1,41 @@
+#!/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 S8810-32Q board.
+### END INIT INFO
+
+case "$1" in
+start)
+ echo -n "Setting up board... "
+
+ depmod -a
+
+ echo "done."
+ ;;
+
+stop)
+
+ i2c_utils.sh i2c_deinit
+
+ echo "done."
+
+ ;;
+
+force-reload|restart)
+ echo "Not supported"
+ ;;
+
+*)
+ echo "Usage: /etc/init.d/sonic-platform-ingrasys-s8810-32q.init {start|stop}"
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8810-32q.install b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8810-32q.install
deleted file mode 100644
index 38efbef5d8..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8810-32q.install
+++ /dev/null
@@ -1,3 +0,0 @@
-lib/systemd/
-usr/sbin/
-etc/
\ No newline at end of file
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8810-32q.postinst b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8810-32q.postinst
deleted file mode 100644
index 6a94f83275..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8810-32q.postinst
+++ /dev/null
@@ -1,43 +0,0 @@
-# Automatically added by dh_systemd_enable
-# This will only remove masks created by d-s-h on package removal.
-deb-systemd-helper unmask s8810-32q-monitor.service >/dev/null || true
-deb-systemd-helper unmask qsfp-monitor.service >/dev/null || true
-# Generate kernel modules.dep and map files for add eeprom_mb.
-depmod -a || true
-# was-enabled defaults to true, so new installations run enable.
-if deb-systemd-helper --quiet was-enabled s8810-32q-monitor.service; then
- # Enables the unit on first installation, creates new
- # symlinks on upgrades if the unit file has changed.
- deb-systemd-helper enable s8810-32q-monitor.service >/dev/null || true
-else
- # Update the statefile to add new symlinks (if any), which need to be
- # cleaned up on purge. Also remove old symlinks.
- deb-systemd-helper update-state s8810-32q-monitor.service >/dev/null || true
-fi
-if deb-systemd-helper --quiet was-enabled qsfp-monitor.service; then
- # Enables the unit on first installation, creates new
- # symlinks on upgrades if the unit file has changed.
- deb-systemd-helper enable qsfp-monitor.service >/dev/null || true
-else
- # Update the statefile to add new symlinks (if any), which need to be
- # cleaned up on purge. Also remove old symlinks.
- deb-systemd-helper update-state qsfp-monitor.service >/dev/null || true
-fi
-# End automatically added section
-# Automatically added by dh_installinit
-if [ -x "/etc/init.d/s8810-32q-monitor" ]; then
- update-rc.d s8810-32q-monitor defaults >/dev/null
- invoke-rc.d s8810-32q-monitor start || exit $?
-fi
-if [ -x "/etc/init.d/qsfp-monitor" ]; then
- update-rc.d qsfp-monitor defaults >/dev/null
- invoke-rc.d qsfp-monitor start || exit $?
-fi
-# End automatically added section
-# Automatically added by dh_systemd_start
-if [ -d /run/systemd/system ]; then
- systemctl --system daemon-reload >/dev/null || true
- deb-systemd-invoke start s8810-32q-monitor.service >/dev/null || true
- deb-systemd-invoke start qsfp-monitor.service >/dev/null || true
-fi
-# End automatically added section
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8810-32q.postrm b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8810-32q.postrm
deleted file mode 100644
index a1049b153e..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8810-32q.postrm
+++ /dev/null
@@ -1,38 +0,0 @@
-# Automatically added by dh_systemd_start
-if [ -d /run/systemd/system ]; then
- systemctl --system daemon-reload >/dev/null || true
- fi
-# End automatically added section
-# Automatically added by dh_installinit
-if [ "$1" = "purge" ] ; then
- update-rc.d s8810-32q-monitor remove >/dev/null
- update-rc.d qsfp-monitor remove >/dev/null
-fi
-
-
-# In case this system is running systemd, we make systemd reload the unit files
-# to pick up changes.
-if [ -d /run/systemd/system ] ; then
- systemctl --system daemon-reload >/dev/null || true
-fi
-# End automatically added section
-# Automatically added by dh_systemd_enable
-if [ "$1" = "remove" ]; then
- if [ -x "/usr/bin/deb-systemd-helper" ]; then
- deb-systemd-helper mask s8810-32q-monitor.service >/dev/null
- deb-systemd-helper mask qsfp-monitor.service >/dev/null
- fi
-fi
-
-if [ "$1" = "purge" ]; then
- if [ -x "/usr/bin/deb-systemd-helper" ]; then
- deb-systemd-helper purge s8810-32q-monitor.service >/dev/null
- deb-systemd-helper unmask s8810-32q-monitor.service >/dev/null
- deb-systemd-helper purge qsfp-monitor.service >/dev/null
- deb-systemd-helper unmask qsfp-monitor.service >/dev/null
- fi
-fi
-# Generate kernel modules.dep and map files for remove eeprom_mb.
-depmod -a || true
-# End automatically added section
-
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8810-32q.prerm b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8810-32q.prerm
deleted file mode 100644
index 5a6581e5f4..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8810-32q.prerm
+++ /dev/null
@@ -1,17 +0,0 @@
-# Automatically added by dh_systemd_start
-if [ -d /run/systemd/system ]; then
- deb-systemd-invoke stop s8810-32q-monitor.service >/dev/null
- deb-systemd-invoke stop qsfp-monitor.service >/dev/null
-fi
-# End automatically added section
-# Automatically added by dh_installinit
-if [ -x "/etc/init.d/s8810-32q-monitor" ]; then
- invoke-rc.d s8810-32q-monitor stop || exit $?
-fi
-if [ -x "/etc/init.d/qsfp-monitor" ]; then
- invoke-rc.d qsfp-monitor stop || exit $?
-fi
-# Driver deinit
-/usr/sbin/i2c_utils.sh i2c_deinit
-# End automatically added section
-
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8810-32q.upstart b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8810-32q.upstart
deleted file mode 100644
index f907d1bb51..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8810-32q.upstart
+++ /dev/null
@@ -1,6 +0,0 @@
-description "SONiC platform service"
-
-respawn
-
-exec /usr/sbin/s8810_32q_monitor.sh
-exec /usr/sbin/qsfp_monitor.sh
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-54xc.dirs b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-54xc.dirs
deleted file mode 100644
index bec29f1957..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-54xc.dirs
+++ /dev/null
@@ -1,3 +0,0 @@
-usr/sbin
-lib/systemd/system
-etc/
\ No newline at end of file
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-54xc.init b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-54xc.init
new file mode 100644
index 0000000000..f2e4932b32
--- /dev/null
+++ b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-54xc.init
@@ -0,0 +1,41 @@
+#!/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 S8900-54XC board.
+### END INIT INFO
+
+case "$1" in
+start)
+ echo -n "Setting up board... "
+
+ depmod -a
+
+ echo "done."
+ ;;
+
+stop)
+
+ i2c_utils.sh i2c_deinit
+
+ echo "done."
+
+ ;;
+
+force-reload|restart)
+ echo "Not supported"
+ ;;
+
+*)
+ echo "Usage: /etc/init.d/sonic-platform-ingrasys-s8900-54xc.init {start|stop}"
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-54xc.install b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-54xc.install
deleted file mode 100644
index 38efbef5d8..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-54xc.install
+++ /dev/null
@@ -1,3 +0,0 @@
-lib/systemd/
-usr/sbin/
-etc/
\ No newline at end of file
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-54xc.postinst b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-54xc.postinst
deleted file mode 100644
index d2dc4ea518..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-54xc.postinst
+++ /dev/null
@@ -1,43 +0,0 @@
-# Automatically added by dh_systemd_enable
-# This will only remove masks created by d-s-h on package removal.
-deb-systemd-helper unmask s8900-54xc-monitor.service >/dev/null || true
-# Generate kernel modules.dep and map files for add eeprom_mb.
-depmod -a || true
-# was-enabled defaults to true, so new installations run enable.
-if deb-systemd-helper --quiet was-enabled s8900-54xc-monitor.service; then
- # Enables the unit on first installation, creates new
- # symlinks on upgrades if the unit file has changed.
- deb-systemd-helper enable s8900-54xc-monitor.service >/dev/null || true
-else
- # Update the statefile to add new symlinks (if any), which need to be
- # cleaned up on purge. Also remove old symlinks.
- deb-systemd-helper update-state s8900-54xc-monitor.service >/dev/null || true
-fi
-if deb-systemd-helper --quiet was-enabled qsfp-monitor.service; then
- # Enables the unit on first installation, creates new
- # symlinks on upgrades if the unit file has changed.
- deb-systemd-helper enable qsfp-monitor.service >/dev/null || true
-else
- # Update the statefile to add new symlinks (if any), which need to be
- # cleaned up on purge. Also remove old symlinks.
- deb-systemd-helper update-state qsfp-monitor.service >/dev/null || true
-fi
-
-# End automatically added section
-# Automatically added by dh_installinit
-if [ -x "/etc/init.d/s8900-54xc-monitor" ]; then
- update-rc.d s8900-54xc-monitor defaults >/dev/null
- invoke-rc.d s8900-54xc-monitor start || exit $?
-fi
-if [ -x "/etc/init.d/qsfp-monitor" ]; then
- update-rc.d qsfp-monitor defaults >/dev/null
- invoke-rc.d qsfp-monitor start || exit $?
-fi
-# End automatically added section
-# Automatically added by dh_systemd_start
-if [ -d /run/systemd/system ]; then
- systemctl --system daemon-reload >/dev/null || true
- deb-systemd-invoke start s8900-54xc-monitor.service >/dev/null || true
- deb-systemd-invoke start qsfp-monitor.service >/dev/null || true
-fi
-# End automatically added section
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-54xc.postrm b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-54xc.postrm
deleted file mode 100644
index b4e4ede5d8..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-54xc.postrm
+++ /dev/null
@@ -1,38 +0,0 @@
-# Automatically added by dh_systemd_start
-if [ -d /run/systemd/system ]; then
- systemctl --system daemon-reload >/dev/null || true
- fi
-# End automatically added section
-# Automatically added by dh_installinit
-if [ "$1" = "purge" ] ; then
- update-rc.d s8900-54xc-monitor remove >/dev/null
- update-rc.d qsfp-monitor remove >/dev/null
-fi
-
-
-# In case this system is running systemd, we make systemd reload the unit files
-# to pick up changes.
-if [ -d /run/systemd/system ] ; then
- systemctl --system daemon-reload >/dev/null || true
-fi
-# End automatically added section
-# Automatically added by dh_systemd_enable
-if [ "$1" = "remove" ]; then
- if [ -x "/usr/bin/deb-systemd-helper" ]; then
- deb-systemd-helper mask s8900-54xc-monitor.service >/dev/null
- deb-systemd-helper mask qsfp-monitor.service >/dev/null
- fi
-fi
-
-if [ "$1" = "purge" ]; then
- if [ -x "/usr/bin/deb-systemd-helper" ]; then
- deb-systemd-helper purge s8900-54xc-monitor.service >/dev/null
- deb-systemd-helper unmask s8900-54xc-monitor.service >/dev/null
- deb-systemd-helper purge qsfp-monitor.service >/dev/null
- deb-systemd-helper unmask qsfp-monitor.service >/dev/null
- fi
-fi
-# Generate kernel modules.dep and map files for remove eeprom_mb.
-depmod -a || true
-# End automatically added section
-
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-54xc.prerm b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-54xc.prerm
deleted file mode 100644
index b35262b16c..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-54xc.prerm
+++ /dev/null
@@ -1,17 +0,0 @@
-# Automatically added by dh_systemd_start
-if [ -d /run/systemd/system ]; then
- deb-systemd-invoke stop s8900-54xc-monitor.service >/dev/null
- deb-systemd-invoke stop qsfp-monitor.service >/dev/null
-fi
-# End automatically added section
-# Automatically added by dh_installinit
-if [ -x "/etc/init.d/s8900-54xc-monitor" ]; then
- invoke-rc.d s8900-54xc-monitor stop || exit $?
-fi
-if [ -x "/etc/init.d/qsfp-monitor" ]; then
- invoke-rc.d qsfp-monitor stop || exit $?
-fi
-# Driver deinit
-/usr/sbin/i2c_utils.sh i2c_deinit
-# End automatically added section
-
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-54xc.upstart b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-54xc.upstart
deleted file mode 100644
index cfdfc490fc..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-54xc.upstart
+++ /dev/null
@@ -1,6 +0,0 @@
-description "SONiC platform service"
-
-respawn
-
-exec /usr/sbin/s8900_54xc_monitor.sh
-exec /usr/sbin/qsfp_monitor.sh
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-64xc.dirs b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-64xc.dirs
deleted file mode 100644
index be337bc5ea..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-64xc.dirs
+++ /dev/null
@@ -1,3 +0,0 @@
-usr/sbin
-lib/systemd/system
-etc/
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-64xc.init b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-64xc.init
new file mode 100644
index 0000000000..2790ca3517
--- /dev/null
+++ b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-64xc.init
@@ -0,0 +1,41 @@
+#!/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 S8900-64XC board.
+### END INIT INFO
+
+case "$1" in
+start)
+ echo -n "Setting up board... "
+
+ depmod -a
+
+ echo "done."
+ ;;
+
+stop)
+
+ i2c_utils.sh i2c_deinit
+
+ echo "done."
+
+ ;;
+
+force-reload|restart)
+ echo "Not supported"
+ ;;
+
+*)
+ echo "Usage: /etc/init.d/sonic-platform-ingrasys-s8900-64xc.init {start|stop}"
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-64xc.install b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-64xc.install
deleted file mode 100644
index 1cf6f97b30..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-64xc.install
+++ /dev/null
@@ -1,3 +0,0 @@
-lib/systemd/
-usr/sbin/
-etc/
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-64xc.postinst b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-64xc.postinst
deleted file mode 100644
index dfc789e964..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-64xc.postinst
+++ /dev/null
@@ -1,42 +0,0 @@
-# Automatically added by dh_systemd_enable
-# This will only remove masks created by d-s-h on package removal.
-deb-systemd-helper unmask s8900-64xc-monitor.service >/dev/null || true
-# Generate kernel modules.dep and map files for add eeprom_mb.
-depmod -a || true
-# was-enabled defaults to true, so new installations run enable.
-if deb-systemd-helper --quiet was-enabled s8900-64xc-monitor.service; then
- # Enables the unit on first installation, creates new
- # symlinks on upgrades if the unit file has changed.
- deb-systemd-helper enable s8900-64xc-monitor.service >/dev/null || true
-else
- # Update the statefile to add new symlinks (if any), which need to be
- # cleaned up on purge. Also remove old symlinks.
- deb-systemd-helper update-state s8900-64xc-monitor.service >/dev/null || true
-fi
-if deb-systemd-helper --quiet was-enabled qsfp-monitor.service; then
- # Enables the unit on first installation, creates new
- # symlinks on upgrades if the unit file has changed.
- deb-systemd-helper enable qsfp-monitor.service >/dev/null || true
-else
- # Update the statefile to add new symlinks (if any), which need to be
- # cleaned up on purge. Also remove old symlinks.
- deb-systemd-helper update-state qsfp-monitor.service >/dev/null || true
-fi
-# End automatically added section
-# Automatically added by dh_installinit
-if [ -x "/etc/init.d/s8900-64xc-monitor" ]; then
- update-rc.d s8900-64xc-monitor defaults >/dev/null
- invoke-rc.d s8900-64xc-monitor start || exit $?
-fi
-if [ -x "/etc/init.d/qsfp-monitor" ]; then
- update-rc.d qsfp-monitor defaults >/dev/null
- invoke-rc.d qsfp-monitor start || exit $?
-fi
-# End automatically added section
-# Automatically added by dh_systemd_start
-if [ -d /run/systemd/system ]; then
- systemctl --system daemon-reload >/dev/null || true
- deb-systemd-invoke start s8900-64xc-monitor.service >/dev/null || true
- deb-systemd-invoke start qsfp-monitor.service >/dev/null || true
-fi
-# End automatically added section
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-64xc.postrm b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-64xc.postrm
deleted file mode 100644
index e3dddecc08..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-64xc.postrm
+++ /dev/null
@@ -1,38 +0,0 @@
-# Automatically added by dh_systemd_start
-if [ -d /run/systemd/system ]; then
- systemctl --system daemon-reload >/dev/null || true
- fi
-# End automatically added section
-# Automatically added by dh_installinit
-if [ "$1" = "purge" ] ; then
- update-rc.d s8900-64xc-monitor remove >/dev/null
- update-rc.d qsfp-monitor remove >/dev/null
-fi
-
-
-# In case this system is running systemd, we make systemd reload the unit files
-# to pick up changes.
-if [ -d /run/systemd/system ] ; then
- systemctl --system daemon-reload >/dev/null || true
-fi
-# End automatically added section
-# Automatically added by dh_systemd_enable
-if [ "$1" = "remove" ]; then
- if [ -x "/usr/bin/deb-systemd-helper" ]; then
- deb-systemd-helper mask s8900-64xc-monitor.service >/dev/null
- deb-systemd-helper mask qsfp-monitor.service >/dev/null
- fi
-fi
-
-if [ "$1" = "purge" ]; then
- if [ -x "/usr/bin/deb-systemd-helper" ]; then
- deb-systemd-helper purge s8900-64xc-monitor.service >/dev/null
- deb-systemd-helper unmask s8900-64xc-monitor.service >/dev/null
- deb-systemd-helper purge qsfp-monitor.service >/dev/null
- deb-systemd-helper unmask qsfp-monitor.service >/dev/null
- fi
-fi
-# Generate kernel modules.dep and map files for remove eeprom_mb.
-depmod -a || true
-# End automatically added section
-
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-64xc.prerm b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-64xc.prerm
deleted file mode 100644
index 2168a6c762..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-64xc.prerm
+++ /dev/null
@@ -1,15 +0,0 @@
-# Automatically added by dh_systemd_start
-if [ -d /run/systemd/system ]; then
- deb-systemd-invoke stop s8900-64xc-monitor.service >/dev/null
- deb-systemd-invoke stop qsfp-monitor.service >/dev/null
-fi
-# End automatically added section
-# Automatically added by dh_installinit
-if [ -x "/etc/init.d/s8900-64xc-monitor" ]; then
- invoke-rc.d s8900-64xc-monitor stop || exit $?
- invoke-rc.d qsfp-monitor stop || exit $?
-fi
-# Driver deinit
-/usr/sbin/i2c_utils.sh i2c_deinit
-# End automatically added section
-
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-64xc.upstart b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-64xc.upstart
deleted file mode 100644
index 25510457ec..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s8900-64xc.upstart
+++ /dev/null
@@ -1,6 +0,0 @@
-description "SONiC platform service"
-
-respawn
-
-exec /usr/sbin/s8900_64xc_monitor.sh
-exec /usr/sbin/qsfp-monitor.sh
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9100.dirs b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9100.dirs
deleted file mode 100644
index bec29f1957..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9100.dirs
+++ /dev/null
@@ -1,3 +0,0 @@
-usr/sbin
-lib/systemd/system
-etc/
\ No newline at end of file
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9100.init b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9100.init
new file mode 100644
index 0000000000..0177087087
--- /dev/null
+++ b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9100.init
@@ -0,0 +1,41 @@
+#!/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 S9100 board.
+### END INIT INFO
+
+case "$1" in
+start)
+ echo -n "Setting up board... "
+
+ depmod -a
+
+ echo "done."
+ ;;
+
+stop)
+
+ i2c_utils.sh i2c_deinit
+
+ echo "done."
+
+ ;;
+
+force-reload|restart)
+ echo "Not supported"
+ ;;
+
+*)
+ echo "Usage: /etc/init.d/sonic-platform-ingrasys-s9100.init {start|stop}"
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9100.install b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9100.install
deleted file mode 100644
index 38efbef5d8..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9100.install
+++ /dev/null
@@ -1,3 +0,0 @@
-lib/systemd/
-usr/sbin/
-etc/
\ No newline at end of file
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9100.postinst b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9100.postinst
deleted file mode 100644
index a9bc64e26c..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9100.postinst
+++ /dev/null
@@ -1,43 +0,0 @@
-# Automatically added by dh_systemd_enable
-# This will only remove masks created by d-s-h on package removal.
-deb-systemd-helper unmask s9100-monitor.service >/dev/null || true
-deb-systemd-helper unmask qsfp-monitor.service >/dev/null || true
-# Generate kernel modules.dep and map files for add eeprom_mb.
-depmod -a || true
-# was-enabled defaults to true, so new installations run enable.
-if deb-systemd-helper --quiet was-enabled s9100-monitor.service; then
- # Enables the unit on first installation, creates new
- # symlinks on upgrades if the unit file has changed.
- deb-systemd-helper enable s9100-monitor.service >/dev/null || true
-else
- # Update the statefile to add new symlinks (if any), which need to be
- # cleaned up on purge. Also remove old symlinks.
- deb-systemd-helper update-state s9100-monitor.service >/dev/null || true
-fi
-if deb-systemd-helper --quiet was-enabled qsfp-monitor.service; then
- # Enables the unit on first installation, creates new
- # symlinks on upgrades if the unit file has changed.
- deb-systemd-helper enable qsfp-monitor.service >/dev/null || true
-else
- # Update the statefile to add new symlinks (if any), which need to be
- # cleaned up on purge. Also remove old symlinks.
- deb-systemd-helper update-state qsfp-monitor.service >/dev/null || true
-fi
-# End automatically added section
-# Automatically added by dh_installinit
-if [ -x "/etc/init.d/s9100-monitor" ]; then
- update-rc.d s9100-monitor defaults >/dev/null
- invoke-rc.d s9100-monitor start || exit $?
-fi
-if [ -x "/etc/init.d/qsfp-monitor" ]; then
- update-rc.d qsfp-monitor defaults >/dev/null
- invoke-rc.d qsfp-monitor start || exit $?
-fi
-# End automatically added section
-# Automatically added by dh_systemd_start
-if [ -d /run/systemd/system ]; then
- systemctl --system daemon-reload >/dev/null || true
- deb-systemd-invoke start s9100-monitor.service >/dev/null || true
- deb-systemd-invoke start qsfp-monitor.service >/dev/null || true
-fi
-# End automatically added section
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9100.postrm b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9100.postrm
deleted file mode 100644
index 669179b11e..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9100.postrm
+++ /dev/null
@@ -1,38 +0,0 @@
-# Automatically added by dh_systemd_start
-if [ -d /run/systemd/system ]; then
- systemctl --system daemon-reload >/dev/null || true
- fi
-# End automatically added section
-# Automatically added by dh_installinit
-if [ "$1" = "purge" ] ; then
- update-rc.d s9100-monitor remove >/dev/null
- update-rc.d qsfp-monitor remove >/dev/null
-fi
-
-
-# In case this system is running systemd, we make systemd reload the unit files
-# to pick up changes.
-if [ -d /run/systemd/system ] ; then
- systemctl --system daemon-reload >/dev/null || true
-fi
-# End automatically added section
-# Automatically added by dh_systemd_enable
-if [ "$1" = "remove" ]; then
- if [ -x "/usr/bin/deb-systemd-helper" ]; then
- deb-systemd-helper mask s9100-monitor.service >/dev/null
- deb-systemd-helper mask qsfp-monitor.service >/dev/null
- fi
-fi
-
-if [ "$1" = "purge" ]; then
- if [ -x "/usr/bin/deb-systemd-helper" ]; then
- deb-systemd-helper purge s9100-monitor.service >/dev/null
- deb-systemd-helper unmask s9100-monitor.service >/dev/null
- deb-systemd-helper purge qsfp-monitor.service >/dev/null
- deb-systemd-helper unmask qsfp-monitor.service >/dev/null
- fi
-fi
-# Generate kernel modules.dep and map files for remove eeprom_mb.
-depmod -a || true
-# End automatically added section
-
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9100.prerm b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9100.prerm
deleted file mode 100644
index 2ca8a83b27..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9100.prerm
+++ /dev/null
@@ -1,17 +0,0 @@
-# Automatically added by dh_systemd_start
-if [ -d /run/systemd/system ]; then
- deb-systemd-invoke stop s9100-monitor.service >/dev/null
- deb-systemd-invoke stop qsfp-monitor.service >/dev/null
-fi
-# End automatically added section
-# Automatically added by dh_installinit
-if [ -x "/etc/init.d/s9100-monitor" ]; then
- invoke-rc.d s9100-monitor stop || exit $?
-fi
-if [ -x "/etc/init.d/qsfp-monitor" ]; then
- invoke-rc.d qsfp-monitor stop || exit $?
-fi
-# Driver deinit
-/usr/sbin/i2c_utils.sh i2c_deinit
-# End automatically added section
-
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9100.upstart b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9100.upstart
deleted file mode 100644
index 5d0ba70801..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9100.upstart
+++ /dev/null
@@ -1,6 +0,0 @@
-description "SONiC platform service"
-
-respawn
-
-exec /usr/sbin/s9100_monitor.sh
-exec /usr/sbin/qsfp_monitor.sh
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9200-64x.dirs b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9200-64x.dirs
deleted file mode 100644
index bec29f1957..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9200-64x.dirs
+++ /dev/null
@@ -1,3 +0,0 @@
-usr/sbin
-lib/systemd/system
-etc/
\ No newline at end of file
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9200-64x.init b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9200-64x.init
new file mode 100644
index 0000000000..076838e1aa
--- /dev/null
+++ b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9200-64x.init
@@ -0,0 +1,41 @@
+#!/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 S9200-64X board.
+### END INIT INFO
+
+case "$1" in
+start)
+ echo -n "Setting up board... "
+
+ depmod -a
+
+ echo "done."
+ ;;
+
+stop)
+
+ i2c_utils.sh i2c_deinit
+
+ echo "done."
+
+ ;;
+
+force-reload|restart)
+ echo "Not supported"
+ ;;
+
+*)
+ echo "Usage: /etc/init.d/sonic-platform-ingrasys-s9200-64x.init {start|stop}"
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9200-64x.install b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9200-64x.install
deleted file mode 100644
index 38efbef5d8..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9200-64x.install
+++ /dev/null
@@ -1,3 +0,0 @@
-lib/systemd/
-usr/sbin/
-etc/
\ No newline at end of file
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9200-64x.postinst b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9200-64x.postinst
deleted file mode 100644
index 0605612a11..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9200-64x.postinst
+++ /dev/null
@@ -1,43 +0,0 @@
-# Automatically added by dh_systemd_enable
-# This will only remove masks created by d-s-h on package removal.
-deb-systemd-helper unmask s9200-64x-monitor.service >/dev/null || true
-deb-systemd-helper unmask qsfp-monitor.service >/dev/null || true
-# Generate kernel modules.dep and map files for add eeprom_mb.
-depmod -a || true
-# was-enabled defaults to true, so new installations run enable.
-if deb-systemd-helper --quiet was-enabled s9200-64x-monitor.service; then
- # Enables the unit on first installation, creates new
- # symlinks on upgrades if the unit file has changed.
- deb-systemd-helper enable s9200-64x-monitor.service >/dev/null || true
-else
- # Update the statefile to add new symlinks (if any), which need to be
- # cleaned up on purge. Also remove old symlinks.
- deb-systemd-helper update-state s9200-64x-monitor.service >/dev/null || true
-fi
-if deb-systemd-helper --quiet was-enabled qsfp-monitor.service; then
- # Enables the unit on first installation, creates new
- # symlinks on upgrades if the unit file has changed.
- deb-systemd-helper enable qsfp-monitor.service >/dev/null || true
-else
- # Update the statefile to add new symlinks (if any), which need to be
- # cleaned up on purge. Also remove old symlinks.
- deb-systemd-helper update-state qsfp-monitor.service >/dev/null || true
-fi
-# End automatically added section
-# Automatically added by dh_installinit
-if [ -x "/etc/init.d/s9200-64x-monitor" ]; then
- update-rc.d s9200-64x-monitor defaults >/dev/null
- invoke-rc.d s9200-64x-monitor start || exit $?
-fi
-if [ -x "/etc/init.d/qsfp-monitor" ]; then
- update-rc.d qsfp-monitor defaults >/dev/null
- invoke-rc.d qsfp-monitor start || exit $?
-fi
-# End automatically added section
-# Automatically added by dh_systemd_start
-if [ -d /run/systemd/system ]; then
- systemctl --system daemon-reload >/dev/null || true
- deb-systemd-invoke start s9200-64x-monitor.service >/dev/null || true
- deb-systemd-invoke start qsfp-monitor.service >/dev/null || true
-fi
-# End automatically added section
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9200-64x.postrm b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9200-64x.postrm
deleted file mode 100644
index 3e94940975..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9200-64x.postrm
+++ /dev/null
@@ -1,38 +0,0 @@
-# Automatically added by dh_systemd_start
-if [ -d /run/systemd/system ]; then
- systemctl --system daemon-reload >/dev/null || true
- fi
-# End automatically added section
-# Automatically added by dh_installinit
-if [ "$1" = "purge" ] ; then
- update-rc.d s9200-64x-monitor remove >/dev/null
- update-rc.d qsfp-monitor remove >/dev/null
-fi
-
-
-# In case this system is running systemd, we make systemd reload the unit files
-# to pick up changes.
-if [ -d /run/systemd/system ] ; then
- systemctl --system daemon-reload >/dev/null || true
-fi
-# End automatically added section
-# Automatically added by dh_systemd_enable
-if [ "$1" = "remove" ]; then
- if [ -x "/usr/bin/deb-systemd-helper" ]; then
- deb-systemd-helper mask s9200-64x-monitor.service >/dev/null
- deb-systemd-helper mask qsfp-monitor.service >/dev/null
- fi
-fi
-
-if [ "$1" = "purge" ]; then
- if [ -x "/usr/bin/deb-systemd-helper" ]; then
- deb-systemd-helper purge s9200-64x-monitor.service >/dev/null
- deb-systemd-helper unmask s9200-64x-monitor.service >/dev/null
- deb-systemd-helper purge qsfp-monitor.service >/dev/null
- deb-systemd-helper unmask qsfp-monitor.service >/dev/null
- fi
-fi
-# Generate kernel modules.dep and map files for remove eeprom_mb.
-depmod -a || true
-# End automatically added section
-
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9200-64x.prerm b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9200-64x.prerm
deleted file mode 100644
index 6238dcad78..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9200-64x.prerm
+++ /dev/null
@@ -1,17 +0,0 @@
-# Automatically added by dh_systemd_start
-if [ -d /run/systemd/system ]; then
- deb-systemd-invoke stop s9200-64x-monitor.service >/dev/null
- deb-systemd-invoke stop qsfp-monitor.service >/dev/null
-fi
-# End automatically added section
-# Automatically added by dh_installinit
-if [ -x "/etc/init.d/s9200-64x-monitor" ]; then
- invoke-rc.d s9200-64x-monitor stop || exit $?
-fi
-if [ -x "/etc/init.d/qsfp-monitor" ]; then
- invoke-rc.d qsfp-monitor stop || exit $?
-fi
-# Driver deinit
-/usr/sbin/i2c_utils.sh i2c_deinit
-# End automatically added section
-
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9200-64x.upstart b/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9200-64x.upstart
deleted file mode 100644
index 00803ff5e3..0000000000
--- a/platform/broadcom/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9200-64x.upstart
+++ /dev/null
@@ -1,6 +0,0 @@
-description "SONiC platform service"
-
-respawn
-
-exec /usr/sbin/s9200_64x_monitor.sh
-exec /usr/sbin/qsfp_monitor.sh
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/s8810-32q/utils/i2c_utils.sh b/platform/broadcom/sonic-platform-modules-ingrasys/s8810-32q/utils/i2c_utils.sh
index 98ffb9d8d2..416e631423 100644
--- a/platform/broadcom/sonic-platform-modules-ingrasys/s8810-32q/utils/i2c_utils.sh
+++ b/platform/broadcom/sonic-platform-modules-ingrasys/s8810-32q/utils/i2c_utils.sh
@@ -15,7 +15,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-VERSION="1.0.0"
+# trun on for more debug output
+#DEBUG="on"
+
+VERSION="1.1.0"
TRUE=200
FALSE=404
@@ -165,11 +168,14 @@ REG_CFG_1=7
#Bit Mask
BIT_MASK=(1 2 4 8 16 32 64 128)
+#GPIO Offset
+GPIO_OFFSET=0
# Help usage function
function _help {
echo "========================================================="
echo "# Description: Help Function"
+ echo "# Version : ${VERSION}"
echo "========================================================="
echo "----------------------------------------------------"
echo "EX : ${0} help"
@@ -315,7 +321,9 @@ function _i2c_init {
modprobe gpio-pca953x
_i2c_fan_init
_i2c_io_exp_init
+ rmmod gpio_ich
_i2c_gpio_init
+ modprobe gpio_ich
_i2c_psu_init
_i2c_qsfp_eeprom_init "new"
_i2c_mb_eeprom_init "new"
@@ -576,14 +584,30 @@ function _clear_gpiomap {
rm -rf ${PATH_GPIOMAP}
}
+# To set the global variable GPIO_OFFSET
+function _set_gpio_offset {
+ GPIO_OFFSET=0
+ for d in `ls /sys/class/gpio/ | grep gpiochip`
+ do
+ gpiochip_no=${d##gpiochip}
+ if [ $gpiochip_no -gt 255 ]; then
+ GPIO_OFFSET=256
+ break
+ fi
+ done
+ #echo "set GPIO_OFFSET=${GPIO_OFFSET}"
+}
+
#GPIO Init
function _i2c_gpio_init {
local i=0
#ABS Port 0-31
echo "pca9535 ${I2C_ADDR_MUX_9535_1}" > ${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_1_CHAN1}/new_device
+ _set_gpio_offset
echo "pca9535 ${I2C_ADDR_MUX_9535_0}" > ${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_1_CHAN1}/new_device
- for i in {224..255}
+ #for i in {224..255}
+ for((i=${GPIO_OFFSET}+224;i<=${GPIO_OFFSET}+255;i++));
do
_gpio_export ${i} ${DIR_IN} ${ACTIVE_LOW}
_set_gpiomap ${i} "QSFP$(( i - 223 ))_ABS"
@@ -592,7 +616,8 @@ function _i2c_gpio_init {
#INT Port 0-31
echo "pca9535 ${I2C_ADDR_MUX_9535_3}" > ${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_1_CHAN1}/new_device
echo "pca9535 ${I2C_ADDR_MUX_9535_2}" > ${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_1_CHAN1}/new_device
- for i in {192..223}
+ #for i in {192..223}
+ for((i=${GPIO_OFFSET}+192;i<=${GPIO_OFFSET}+223;i++));
do
_gpio_export ${i} ${DIR_IN} ${ACTIVE_LOW}
_set_gpiomap ${i} "QSFP$(( i - 191 ))_INT"
@@ -601,7 +626,8 @@ function _i2c_gpio_init {
#LP Mode Port 0-31
echo "pca9535 ${I2C_ADDR_MUX_9535_5}" > ${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_1_CHAN2}/new_device
echo "pca9535 ${I2C_ADDR_MUX_9535_4}" > ${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_1_CHAN2}/new_device
- for i in {160..191}
+ #for i in {160..191}
+ for((i=${GPIO_OFFSET}+160;i<=${GPIO_OFFSET}+191;i++));
do
_gpio_export ${i} ${DIR_OUT} ${ACTIVE_HIGH}
_set_gpiomap ${i} "QSFP$(( i - 159 ))_LPMODE"
@@ -610,7 +636,8 @@ function _i2c_gpio_init {
#RST Port 0-31
echo "pca9535 ${I2C_ADDR_MUX_9535_7}" > ${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_1_CHAN2}/new_device
echo "pca9535 ${I2C_ADDR_MUX_9535_6}" > ${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_1_CHAN2}/new_device
- for i in {128..159}
+ #for i in {128..159}
+ for((i=${GPIO_OFFSET}+128;i<=${GPIO_OFFSET}+159;i++));
do
_gpio_export ${i} ${DIR_OUT} ${ACTIVE_LOW}
_set_gpiomap ${i} "QSFP$(( i - 127 ))_RST"
@@ -622,7 +649,8 @@ function _i2c_gpio_init {
#MODSEL Port 0-31
echo "pca9535 ${I2C_ADDR_MUX_9535_9}" > ${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_1_CHAN3}/new_device
echo "pca9535 ${I2C_ADDR_MUX_9535_8}" > ${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_1_CHAN3}/new_device
- for i in {96..127}
+ #for i in {96..127}
+ for((i=${GPIO_OFFSET}+96;i<=${GPIO_OFFSET}+127;i++));
do
_gpio_export ${i} ${DIR_OUT} ${ACTIVE_LOW}
_set_gpiomap ${i} "QSFP$(( i - 95 ))_MODSEL"
@@ -965,31 +993,36 @@ function _qsfp_port_i2c_var_set {
regAddr=0x20
dataAddr=0
eeprombusbase=${NUM_MUX_9548_2_CHAN0}
- gpioBase=224
+ gpioBase=$((${GPIO_OFFSET}+224))
+ #gpioBase=224
;;
9|10|11|12|13|14|15|16)
i2cbus=${NUM_MUX_9548_1_CHAN1}
regAddr=0x20
dataAddr=1
eeprombusbase=${NUM_MUX_9548_3_CHAN0}
- gpioBase=224
+ gpioBase=$((${GPIO_OFFSET}+224))
+ #gpioBase=224
;;
17|18|19|20|21|22|23|24)
i2cbus=${NUM_MUX_9548_1_CHAN1}
regAddr=0x21
dataAddr=0
eeprombusbase=${NUM_MUX_9548_4_CHAN0}
- gpioBase=240
+ gpioBase=$((${GPIO_OFFSET}+240))
+ #gpioBase=240
;;
25|26|27|28|29|30|31|32)
i2cbus=${NUM_MUX_9548_1_CHAN1}
regAddr=0x21
dataAddr=1
eeprombusbase=${NUM_MUX_9548_5_CHAN0}
- gpioBase=240
+ gpioBase=$((${GPIO_OFFSET}+240))
+ #gpioBase=240
;;
*)
echo "Please input 1~32"
+ exit
;;
esac
}
@@ -1366,6 +1399,7 @@ function _main {
start_time_str=`date`
start_time_sec=$(date +%s)
+ _set_gpio_offset
if [ "${EXEC_FUNC}" == "help" ]; then
_help
elif [ "${EXEC_FUNC}" == "i2c_init" ]; then
@@ -1439,14 +1473,17 @@ function _main {
exit ${FALSE}
fi
- end_time_str=`date`
- end_time_sec=$(date +%s)
- diff_time=$[ ${end_time_sec} - ${start_time_sec} ]
- echo "Start Time: ${start_time_str} (${start_time_sec})"
- echo "End Time : ${end_time_str} (${end_time_sec})"
- echo "Total Execution Time: ${diff_time} sec"
+ if [ "$DEBUG" == "on" ]; then
+ echo "-----------------------------------------------------"
+ end_time_str=`date`
+ end_time_sec=$(date +%s)
+ diff_time=$[ ${end_time_sec} - ${start_time_sec} ]
+ echo "Start Time: ${start_time_str} (${start_time_sec})"
+ echo "End Time : ${end_time_str} (${end_time_sec})"
+ echo "Total Execution Time: ${diff_time} sec"
- echo "done!!!"
+ echo "done!!!"
+ fi
}
_main
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/s8900-54xc/utils/i2c_utils.sh b/platform/broadcom/sonic-platform-modules-ingrasys/s8900-54xc/utils/i2c_utils.sh
index eea7b9ba8f..dbea637866 100644
--- a/platform/broadcom/sonic-platform-modules-ingrasys/s8900-54xc/utils/i2c_utils.sh
+++ b/platform/broadcom/sonic-platform-modules-ingrasys/s8900-54xc/utils/i2c_utils.sh
@@ -15,7 +15,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-VERSION="1.0.0"
+# trun on for more debug output
+#DEBUG="on"
+
+VERSION="1.1.0"
TRUE=200
FALSE=404
PORT_START=1
@@ -97,11 +100,14 @@ ZQSFP_PORT0_15_ABS_GPIO_IDX=192
ZQSFP_PORT16_31_ABS_GPIO_IDX=176
ZQSFP_PORT32_47_ABS_GPIO_IDX=160
+#GPIO Offset
+GPIO_OFFSET=0
# Help usage function
function _help {
echo "========================================================="
echo "# Description: Help Function"
+ echo "# Version : ${VERSION}"
echo "========================================================="
echo "----------------------------------------------------"
echo "EX : ${0} help"
@@ -226,7 +232,9 @@ function _i2c_init {
modprobe eeprom_mb
_i2c_fan_init
_i2c_io_exp_init
+ rmmod gpio_ich
_i2c_gpio_init
+ modprobe gpio_ich
_i2c_cpld_init
_i2c_psu_eeprom_init
_i2c_led_psu_status_set
@@ -529,222 +537,279 @@ function _i2c_unmount_sfp_eeprom {
echo "Unmount Port $1 EEPROM"
}
+# To set the global variable GPIO_OFFSET
+function _set_gpio_offset {
+ GPIO_OFFSET=0
+ for d in `ls /sys/class/gpio/ | grep gpiochip`
+ do
+ gpiochip_no=${d##gpiochip}
+ if [ $gpiochip_no -gt 255 ]; then
+ GPIO_OFFSET=256
+ break
+ fi
+ done
+ #echo "set GPIO_OFFSET=${GPIO_OFFSET}"
+}
+
#GPIO Init
function _i2c_gpio_init {
#QSFP/ZQSFP ABS+INT
echo "pca9535 0x23" > /sys/bus/i2c/devices/i2c-${NUM_MUX2_CHAN0_DEVICE}/new_device
+ _set_gpio_offset
+ for((i=${GPIO_OFFSET}+240;i<=${GPIO_OFFSET}+255;i++));
+ do
+ echo $i > /sys/class/gpio/export
+ echo 1 > /sys/class/gpio/gpio${i}/active_low
+ done
- _retry "echo 240 > /sys/class/gpio/export"
- echo 241 > /sys/class/gpio/export
- echo 242 > /sys/class/gpio/export
- echo 243 > /sys/class/gpio/export
- echo 244 > /sys/class/gpio/export
- echo 245 > /sys/class/gpio/export
- echo 246 > /sys/class/gpio/export
- echo 247 > /sys/class/gpio/export
- echo 248 > /sys/class/gpio/export
- echo 249 > /sys/class/gpio/export
- echo 250 > /sys/class/gpio/export
- echo 251 > /sys/class/gpio/export
- echo 252 > /sys/class/gpio/export
- echo 253 > /sys/class/gpio/export
- echo 254 > /sys/class/gpio/export
- echo 255 > /sys/class/gpio/export
-
- echo 1 > /sys/class/gpio/gpio241/active_low #QSFP49 ABS
- echo 1 > /sys/class/gpio/gpio240/active_low #QSFP48 ABS
- echo 1 > /sys/class/gpio/gpio243/active_low #QSFP51 ABS
- echo 1 > /sys/class/gpio/gpio242/active_low #QSFP50 ABS
- echo 1 > /sys/class/gpio/gpio245/active_low #QSFP53 ABS
- echo 1 > /sys/class/gpio/gpio244/active_low #QSFP52 ABS
- echo 1 > /sys/class/gpio/gpio247/active_low #NA
- echo 1 > /sys/class/gpio/gpio246/active_low #NA
- echo 1 > /sys/class/gpio/gpio249/active_low #QSFP49 INT
- echo 1 > /sys/class/gpio/gpio248/active_low #QSFP48 INT
- echo 1 > /sys/class/gpio/gpio251/active_low #QSFP51 INT
- echo 1 > /sys/class/gpio/gpio250/active_low #QSFP50 INT
- echo 1 > /sys/class/gpio/gpio253/active_low #QSFP53 INT
- echo 1 > /sys/class/gpio/gpio252/active_low #QSFP52 INT
- echo 1 > /sys/class/gpio/gpio255/active_low #NA
- echo 1 > /sys/class/gpio/gpio254/active_low #NA
+ #_retry "echo 240 > /sys/class/gpio/export"
+ #echo 241 > /sys/class/gpio/export
+ #echo 242 > /sys/class/gpio/export
+ #echo 243 > /sys/class/gpio/export
+ #echo 244 > /sys/class/gpio/export
+ #echo 245 > /sys/class/gpio/export
+ #echo 246 > /sys/class/gpio/export
+ #echo 247 > /sys/class/gpio/export
+ #echo 248 > /sys/class/gpio/export
+ #echo 249 > /sys/class/gpio/export
+ #echo 250 > /sys/class/gpio/export
+ #echo 251 > /sys/class/gpio/export
+ #echo 252 > /sys/class/gpio/export
+ #echo 253 > /sys/class/gpio/export
+ #echo 254 > /sys/class/gpio/export
+ #echo 255 > /sys/class/gpio/export
+ #echo 1 > /sys/class/gpio/gpio241/active_low #QSFP49 ABS
+ #echo 1 > /sys/class/gpio/gpio240/active_low #QSFP48 ABS
+ #echo 1 > /sys/class/gpio/gpio243/active_low #QSFP51 ABS
+ #echo 1 > /sys/class/gpio/gpio242/active_low #QSFP50 ABS
+ #echo 1 > /sys/class/gpio/gpio245/active_low #QSFP53 ABS
+ #echo 1 > /sys/class/gpio/gpio244/active_low #QSFP52 ABS
+ #echo 1 > /sys/class/gpio/gpio247/active_low #NA
+ #echo 1 > /sys/class/gpio/gpio246/active_low #NA
+ #echo 1 > /sys/class/gpio/gpio249/active_low #QSFP49 INT
+ #echo 1 > /sys/class/gpio/gpio248/active_low #QSFP48 INT
+ #echo 1 > /sys/class/gpio/gpio251/active_low #QSFP51 INT
+ #echo 1 > /sys/class/gpio/gpio250/active_low #QSFP50 INT
+ #echo 1 > /sys/class/gpio/gpio253/active_low #QSFP53 INT
+ #echo 1 > /sys/class/gpio/gpio252/active_low #QSFP52 INT
+ #echo 1 > /sys/class/gpio/gpio255/active_low #NA
+ #echo 1 > /sys/class/gpio/gpio254/active_low #NA
#QSFP/zQSFP LPMODE+MODSEL
echo "pca9535 0x23" > /sys/bus/i2c/devices/i2c-${NUM_MUX2_CHAN3_DEVICE}/new_device
- echo 224 > /sys/class/gpio/export #QSFP0 LPMODE
- echo 225 > /sys/class/gpio/export #QSFP1 LPMODE
- echo 226 > /sys/class/gpio/export #QSFP2 LPMODE
- echo 227 > /sys/class/gpio/export #QSFP3 LPMODE
- echo 228 > /sys/class/gpio/export #QSFP4 LPMODE
- echo 229 > /sys/class/gpio/export #QSFP5 LPMODE
- echo 230 > /sys/class/gpio/export #NA
- echo 231 > /sys/class/gpio/export #NA
- echo 232 > /sys/class/gpio/export #QSFP0 MODSEL
- echo 233 > /sys/class/gpio/export #QSFP1 MODSEL
- echo 234 > /sys/class/gpio/export #QSFP2 MODSEL
- echo 235 > /sys/class/gpio/export #QSFP3 MODSEL
- echo 236 > /sys/class/gpio/export #QSFP4 MODSEL
- echo 237 > /sys/class/gpio/export #QSFP5 MODSEL
- echo 238 > /sys/class/gpio/export #NA
- echo 239 > /sys/class/gpio/export #NA
- echo out > /sys/class/gpio/gpio224/direction
- echo out > /sys/class/gpio/gpio225/direction
- echo out > /sys/class/gpio/gpio226/direction
- echo out > /sys/class/gpio/gpio227/direction
- echo out > /sys/class/gpio/gpio228/direction
- echo out > /sys/class/gpio/gpio229/direction
- echo out > /sys/class/gpio/gpio230/direction
- echo out > /sys/class/gpio/gpio231/direction
- echo out > /sys/class/gpio/gpio232/direction
- echo out > /sys/class/gpio/gpio233/direction
- echo out > /sys/class/gpio/gpio234/direction
- echo out > /sys/class/gpio/gpio235/direction
- echo out > /sys/class/gpio/gpio236/direction
- echo out > /sys/class/gpio/gpio237/direction
- echo out > /sys/class/gpio/gpio238/direction
- echo out > /sys/class/gpio/gpio239/direction
+ for((i=${GPIO_OFFSET}+224;i<=${GPIO_OFFSET}+239;i++));
+ do
+ echo $i > /sys/class/gpio/export
+ echo out > /sys/class/gpio/gpio${i}/direction
+ done
+
+ #echo 224 > /sys/class/gpio/export #QSFP0 LPMODE
+ #echo 225 > /sys/class/gpio/export #QSFP1 LPMODE
+ #echo 226 > /sys/class/gpio/export #QSFP2 LPMODE
+ #echo 227 > /sys/class/gpio/export #QSFP3 LPMODE
+ #echo 228 > /sys/class/gpio/export #QSFP4 LPMODE
+ #echo 229 > /sys/class/gpio/export #QSFP5 LPMODE
+ #echo 230 > /sys/class/gpio/export #NA
+ #echo 231 > /sys/class/gpio/export #NA
+ #echo 232 > /sys/class/gpio/export #QSFP0 MODSEL
+ #echo 233 > /sys/class/gpio/export #QSFP1 MODSEL
+ #echo 234 > /sys/class/gpio/export #QSFP2 MODSEL
+ #echo 235 > /sys/class/gpio/export #QSFP3 MODSEL
+ #echo 236 > /sys/class/gpio/export #QSFP4 MODSEL
+ #echo 237 > /sys/class/gpio/export #QSFP5 MODSEL
+ #echo 238 > /sys/class/gpio/export #NA
+ #echo 239 > /sys/class/gpio/export #NA
+ #echo out > /sys/class/gpio/gpio224/direction
+ #echo out > /sys/class/gpio/gpio225/direction
+ #echo out > /sys/class/gpio/gpio226/direction
+ #echo out > /sys/class/gpio/gpio227/direction
+ #echo out > /sys/class/gpio/gpio228/direction
+ #echo out > /sys/class/gpio/gpio229/direction
+ #echo out > /sys/class/gpio/gpio230/direction
+ #echo out > /sys/class/gpio/gpio231/direction
+ #echo out > /sys/class/gpio/gpio232/direction
+ #echo out > /sys/class/gpio/gpio233/direction
+ #echo out > /sys/class/gpio/gpio234/direction
+ #echo out > /sys/class/gpio/gpio235/direction
+ #echo out > /sys/class/gpio/gpio236/direction
+ #echo out > /sys/class/gpio/gpio237/direction
+ #echo out > /sys/class/gpio/gpio238/direction
+ #echo out > /sys/class/gpio/gpio239/direction
#QSFP RST
echo "pca9535 0x23" > /sys/bus/i2c/devices/i2c-${NUM_MUX2_CHAN5_DEVICE}/new_device
- echo 208 > /sys/class/gpio/export #QSFP0 RST
- echo 209 > /sys/class/gpio/export #QSFP1 RST
- echo 210 > /sys/class/gpio/export #QSFP2 RST
- echo 211 > /sys/class/gpio/export #QSFP3 RST
- echo 212 > /sys/class/gpio/export #QSFP4 RST
- echo 213 > /sys/class/gpio/export #QSFP5 RST
- echo 214 > /sys/class/gpio/export #NA
- echo 215 > /sys/class/gpio/export #NA
- echo 216 > /sys/class/gpio/export #NA
- echo 217 > /sys/class/gpio/export #NA
- echo 218 > /sys/class/gpio/export #NA
- echo 219 > /sys/class/gpio/export #NA
- echo 220 > /sys/class/gpio/export #NA
- echo 221 > /sys/class/gpio/export #NA
- echo 222 > /sys/class/gpio/export #NA
- echo 223 > /sys/class/gpio/export #NA
- echo out > /sys/class/gpio/gpio208/direction
- echo out > /sys/class/gpio/gpio209/direction
- echo out > /sys/class/gpio/gpio210/direction
- echo out > /sys/class/gpio/gpio211/direction
- echo out > /sys/class/gpio/gpio212/direction
- echo out > /sys/class/gpio/gpio213/direction
- echo 1 > /sys/class/gpio/gpio208/active_low
- echo 1 > /sys/class/gpio/gpio209/active_low
- echo 1 > /sys/class/gpio/gpio210/active_low
- echo 1 > /sys/class/gpio/gpio211/active_low
- echo 1 > /sys/class/gpio/gpio212/active_low
- echo 1 > /sys/class/gpio/gpio213/active_low
- echo 0 > /sys/class/gpio/gpio208/value
- echo 0 > /sys/class/gpio/gpio209/value
- echo 0 > /sys/class/gpio/gpio210/value
- echo 0 > /sys/class/gpio/gpio211/value
- echo 0 > /sys/class/gpio/gpio212/value
- echo 0 > /sys/class/gpio/gpio213/value
+ for((i=${GPIO_OFFSET}+208;i<=${GPIO_OFFSET}+213;i++));
+ do
+ echo $i > /sys/class/gpio/export
+ echo 1 > /sys/class/gpio/gpio${i}/active_low
+ echo low > /sys/class/gpio/gpio${i}/direction
+ #echo out > /sys/class/gpio/gpio${i}/direction
+ #echo 0 > /sys/class/gpio/gpio${i}/value
+ done
+ for((i=${GPIO_OFFSET}+214;i<=${GPIO_OFFSET}+223;i++));
+ do
+ echo $i > /sys/class/gpio/export
+ done
+
+ #echo 208 > /sys/class/gpio/export #QSFP0 RST
+ #echo 209 > /sys/class/gpio/export #QSFP1 RST
+ #echo 210 > /sys/class/gpio/export #QSFP2 RST
+ #echo 211 > /sys/class/gpio/export #QSFP3 RST
+ #echo 212 > /sys/class/gpio/export #QSFP4 RST
+ #echo 213 > /sys/class/gpio/export #QSFP5 RST
+ #echo 214 > /sys/class/gpio/export #NA
+ #echo 215 > /sys/class/gpio/export #NA
+ #echo 216 > /sys/class/gpio/export #NA
+ #echo 217 > /sys/class/gpio/export #NA
+ #echo 218 > /sys/class/gpio/export #NA
+ #echo 219 > /sys/class/gpio/export #NA
+ #echo 220 > /sys/class/gpio/export #NA
+ #echo 221 > /sys/class/gpio/export #NA
+ #echo 222 > /sys/class/gpio/export #NA
+ #echo 223 > /sys/class/gpio/export #NA
+ #echo out > /sys/class/gpio/gpio208/direction
+ #echo out > /sys/class/gpio/gpio209/direction
+ #echo out > /sys/class/gpio/gpio210/direction
+ #echo out > /sys/class/gpio/gpio211/direction
+ #echo out > /sys/class/gpio/gpio212/direction
+ #echo out > /sys/class/gpio/gpio213/direction
+ #echo 1 > /sys/class/gpio/gpio208/active_low
+ #echo 1 > /sys/class/gpio/gpio209/active_low
+ #echo 1 > /sys/class/gpio/gpio210/active_low
+ #echo 1 > /sys/class/gpio/gpio211/active_low
+ #echo 1 > /sys/class/gpio/gpio212/active_low
+ #echo 1 > /sys/class/gpio/gpio213/active_low
+ #echo 0 > /sys/class/gpio/gpio208/value
+ #echo 0 > /sys/class/gpio/gpio209/value
+ #echo 0 > /sys/class/gpio/gpio210/value
+ #echo 0 > /sys/class/gpio/gpio211/value
+ #echo 0 > /sys/class/gpio/gpio212/value
+ #echo 0 > /sys/class/gpio/gpio213/value
+
#SFP+ ABS 0-15
echo "pca9535 0x20" > /sys/bus/i2c/devices/i2c-${NUM_MUX2_CHAN0_DEVICE}/new_device
- echo 192 > /sys/class/gpio/export
- echo 193 > /sys/class/gpio/export
- echo 194 > /sys/class/gpio/export
- echo 195 > /sys/class/gpio/export
- echo 196 > /sys/class/gpio/export
- echo 197 > /sys/class/gpio/export
- echo 198 > /sys/class/gpio/export
- echo 199 > /sys/class/gpio/export
- echo 200 > /sys/class/gpio/export
- echo 201 > /sys/class/gpio/export
- echo 202 > /sys/class/gpio/export
- echo 203 > /sys/class/gpio/export
- echo 204 > /sys/class/gpio/export
- echo 205 > /sys/class/gpio/export
- echo 206 > /sys/class/gpio/export
- echo 207 > /sys/class/gpio/export
- echo 1 > /sys/class/gpio/gpio192/active_low #SFP+00
- echo 1 > /sys/class/gpio/gpio193/active_low #SFP+01
- echo 1 > /sys/class/gpio/gpio194/active_low #SFP+02
- echo 1 > /sys/class/gpio/gpio195/active_low #SFP+03
- echo 1 > /sys/class/gpio/gpio196/active_low #SFP+04
- echo 1 > /sys/class/gpio/gpio197/active_low #SFP+05
- echo 1 > /sys/class/gpio/gpio198/active_low #SFP+06
- echo 1 > /sys/class/gpio/gpio199/active_low #SFP+07
- echo 1 > /sys/class/gpio/gpio200/active_low #SFP+08
- echo 1 > /sys/class/gpio/gpio201/active_low #SFP+09
- echo 1 > /sys/class/gpio/gpio202/active_low #SFP+10
- echo 1 > /sys/class/gpio/gpio203/active_low #SFP+11
- echo 1 > /sys/class/gpio/gpio204/active_low #SFP+12
- echo 1 > /sys/class/gpio/gpio205/active_low #SFP+13
- echo 1 > /sys/class/gpio/gpio206/active_low #SFP+14
- echo 1 > /sys/class/gpio/gpio207/active_low #SFP+15
+ for((i=${GPIO_OFFSET}+192;i<=${GPIO_OFFSET}+207;i++));
+ do
+ echo $i > /sys/class/gpio/export
+ echo 1 > /sys/class/gpio/gpio${i}/active_low
+ done
+
+ #echo 192 > /sys/class/gpio/export
+ #echo 193 > /sys/class/gpio/export
+ #echo 194 > /sys/class/gpio/export
+ #echo 195 > /sys/class/gpio/export
+ #echo 196 > /sys/class/gpio/export
+ #echo 197 > /sys/class/gpio/export
+ #echo 198 > /sys/class/gpio/export
+ #echo 199 > /sys/class/gpio/export
+ #echo 200 > /sys/class/gpio/export
+ #echo 201 > /sys/class/gpio/export
+ #echo 202 > /sys/class/gpio/export
+ #echo 203 > /sys/class/gpio/export
+ #echo 204 > /sys/class/gpio/export
+ #echo 205 > /sys/class/gpio/export
+ #echo 206 > /sys/class/gpio/export
+ #echo 207 > /sys/class/gpio/export
+ #echo 1 > /sys/class/gpio/gpio192/active_low #SFP+00
+ #echo 1 > /sys/class/gpio/gpio193/active_low #SFP+01
+ #echo 1 > /sys/class/gpio/gpio194/active_low #SFP+02
+ #echo 1 > /sys/class/gpio/gpio195/active_low #SFP+03
+ #echo 1 > /sys/class/gpio/gpio196/active_low #SFP+04
+ #echo 1 > /sys/class/gpio/gpio197/active_low #SFP+05
+ #echo 1 > /sys/class/gpio/gpio198/active_low #SFP+06
+ #echo 1 > /sys/class/gpio/gpio199/active_low #SFP+07
+ #echo 1 > /sys/class/gpio/gpio200/active_low #SFP+08
+ #echo 1 > /sys/class/gpio/gpio201/active_low #SFP+09
+ #echo 1 > /sys/class/gpio/gpio202/active_low #SFP+10
+ #echo 1 > /sys/class/gpio/gpio203/active_low #SFP+11
+ #echo 1 > /sys/class/gpio/gpio204/active_low #SFP+12
+ #echo 1 > /sys/class/gpio/gpio205/active_low #SFP+13
+ #echo 1 > /sys/class/gpio/gpio206/active_low #SFP+14
+ #echo 1 > /sys/class/gpio/gpio207/active_low #SFP+15
#SFP+ ABS 16-31
echo "pca9535 0x21" > /sys/bus/i2c/devices/i2c-${NUM_MUX2_CHAN0_DEVICE}/new_device
- echo 176 > /sys/class/gpio/export
- echo 177 > /sys/class/gpio/export
- echo 178 > /sys/class/gpio/export
- echo 179 > /sys/class/gpio/export
- echo 180 > /sys/class/gpio/export
- echo 181 > /sys/class/gpio/export
- echo 182 > /sys/class/gpio/export
- echo 183 > /sys/class/gpio/export
- echo 184 > /sys/class/gpio/export
- echo 185 > /sys/class/gpio/export
- echo 186 > /sys/class/gpio/export
- echo 187 > /sys/class/gpio/export
- echo 188 > /sys/class/gpio/export
- echo 189 > /sys/class/gpio/export
- echo 190 > /sys/class/gpio/export
- echo 191 > /sys/class/gpio/export
- echo 1 > /sys/class/gpio/gpio176/active_low #SFP+16
- echo 1 > /sys/class/gpio/gpio177/active_low #SFP+17
- echo 1 > /sys/class/gpio/gpio178/active_low #SFP+18
- echo 1 > /sys/class/gpio/gpio179/active_low #SFP+19
- echo 1 > /sys/class/gpio/gpio180/active_low #SFP+20
- echo 1 > /sys/class/gpio/gpio181/active_low #SFP+21
- echo 1 > /sys/class/gpio/gpio182/active_low #SFP+22
- echo 1 > /sys/class/gpio/gpio183/active_low #SFP+23
- echo 1 > /sys/class/gpio/gpio184/active_low #SFP+24
- echo 1 > /sys/class/gpio/gpio185/active_low #SFP+25
- echo 1 > /sys/class/gpio/gpio186/active_low #SFP+26
- echo 1 > /sys/class/gpio/gpio187/active_low #SFP+27
- echo 1 > /sys/class/gpio/gpio188/active_low #SFP+28
- echo 1 > /sys/class/gpio/gpio189/active_low #SFP+29
- echo 1 > /sys/class/gpio/gpio190/active_low #SFP+30
- echo 1 > /sys/class/gpio/gpio191/active_low #SFP+31
+ for((i=${GPIO_OFFSET}+176;i<=${GPIO_OFFSET}+191;i++));
+ do
+ echo $i > /sys/class/gpio/export
+ echo 1 > /sys/class/gpio/gpio${i}/active_low
+ done
+
+ #echo 176 > /sys/class/gpio/export
+ #echo 177 > /sys/class/gpio/export
+ #echo 178 > /sys/class/gpio/export
+ #echo 179 > /sys/class/gpio/export
+ #echo 180 > /sys/class/gpio/export
+ #echo 181 > /sys/class/gpio/export
+ #echo 182 > /sys/class/gpio/export
+ #echo 183 > /sys/class/gpio/export
+ #echo 184 > /sys/class/gpio/export
+ #echo 185 > /sys/class/gpio/export
+ #echo 186 > /sys/class/gpio/export
+ #echo 187 > /sys/class/gpio/export
+ #echo 188 > /sys/class/gpio/export
+ #echo 189 > /sys/class/gpio/export
+ #echo 190 > /sys/class/gpio/export
+ #echo 191 > /sys/class/gpio/export
+ #echo 1 > /sys/class/gpio/gpio176/active_low #SFP+16
+ #echo 1 > /sys/class/gpio/gpio177/active_low #SFP+17
+ #echo 1 > /sys/class/gpio/gpio178/active_low #SFP+18
+ #echo 1 > /sys/class/gpio/gpio179/active_low #SFP+19
+ #echo 1 > /sys/class/gpio/gpio180/active_low #SFP+20
+ #echo 1 > /sys/class/gpio/gpio181/active_low #SFP+21
+ #echo 1 > /sys/class/gpio/gpio182/active_low #SFP+22
+ #echo 1 > /sys/class/gpio/gpio183/active_low #SFP+23
+ #echo 1 > /sys/class/gpio/gpio184/active_low #SFP+24
+ #echo 1 > /sys/class/gpio/gpio185/active_low #SFP+25
+ #echo 1 > /sys/class/gpio/gpio186/active_low #SFP+26
+ #echo 1 > /sys/class/gpio/gpio187/active_low #SFP+27
+ #echo 1 > /sys/class/gpio/gpio188/active_low #SFP+28
+ #echo 1 > /sys/class/gpio/gpio189/active_low #SFP+29
+ #echo 1 > /sys/class/gpio/gpio190/active_low #SFP+30
+ #echo 1 > /sys/class/gpio/gpio191/active_low #SFP+31
#SFP+ ABS 32-47
echo "pca9535 0x22" > /sys/bus/i2c/devices/i2c-${NUM_MUX2_CHAN0_DEVICE}/new_device
- echo 160 > /sys/class/gpio/export
- echo 161 > /sys/class/gpio/export
- echo 162 > /sys/class/gpio/export
- echo 163 > /sys/class/gpio/export
- echo 164 > /sys/class/gpio/export
- echo 165 > /sys/class/gpio/export
- echo 166 > /sys/class/gpio/export
- echo 167 > /sys/class/gpio/export
- echo 168 > /sys/class/gpio/export
- echo 169 > /sys/class/gpio/export
- echo 170 > /sys/class/gpio/export
- echo 171 > /sys/class/gpio/export
- echo 172 > /sys/class/gpio/export
- echo 173 > /sys/class/gpio/export
- echo 174 > /sys/class/gpio/export
- echo 175 > /sys/class/gpio/export
- echo 1 > /sys/class/gpio/gpio160/active_low #SFP+32
- echo 1 > /sys/class/gpio/gpio161/active_low #SFP+33
- echo 1 > /sys/class/gpio/gpio162/active_low #SFP+34
- echo 1 > /sys/class/gpio/gpio163/active_low #SFP+35
- echo 1 > /sys/class/gpio/gpio164/active_low #SFP+36
- echo 1 > /sys/class/gpio/gpio165/active_low #SFP+37
- echo 1 > /sys/class/gpio/gpio166/active_low #SFP+38
- echo 1 > /sys/class/gpio/gpio167/active_low #SFP+39
- echo 1 > /sys/class/gpio/gpio168/active_low #SFP+40
- echo 1 > /sys/class/gpio/gpio169/active_low #SFP+41
- echo 1 > /sys/class/gpio/gpio170/active_low #SFP+42
- echo 1 > /sys/class/gpio/gpio171/active_low #SFP+43
- echo 1 > /sys/class/gpio/gpio172/active_low #SFP+44
- echo 1 > /sys/class/gpio/gpio173/active_low #SFP+45
- echo 1 > /sys/class/gpio/gpio174/active_low #SFP+46
- echo 1 > /sys/class/gpio/gpio175/active_low #SFP+47
+ for((i=${GPIO_OFFSET}+160;i<=${GPIO_OFFSET}+175;i++));
+ do
+ echo $i > /sys/class/gpio/export
+ echo 1 > /sys/class/gpio/gpio${i}/active_low
+ done
+
+ #echo 160 > /sys/class/gpio/export
+ #echo 161 > /sys/class/gpio/export
+ #echo 162 > /sys/class/gpio/export
+ #echo 163 > /sys/class/gpio/export
+ #echo 164 > /sys/class/gpio/export
+ #echo 165 > /sys/class/gpio/export
+ #echo 166 > /sys/class/gpio/export
+ #echo 167 > /sys/class/gpio/export
+ #echo 168 > /sys/class/gpio/export
+ #echo 169 > /sys/class/gpio/export
+ #echo 170 > /sys/class/gpio/export
+ #echo 171 > /sys/class/gpio/export
+ #echo 172 > /sys/class/gpio/export
+ #echo 173 > /sys/class/gpio/export
+ #echo 174 > /sys/class/gpio/export
+ #echo 175 > /sys/class/gpio/export
+ #echo 1 > /sys/class/gpio/gpio160/active_low #SFP+32
+ #echo 1 > /sys/class/gpio/gpio161/active_low #SFP+33
+ #echo 1 > /sys/class/gpio/gpio162/active_low #SFP+34
+ #echo 1 > /sys/class/gpio/gpio163/active_low #SFP+35
+ #echo 1 > /sys/class/gpio/gpio164/active_low #SFP+36
+ #echo 1 > /sys/class/gpio/gpio165/active_low #SFP+37
+ #echo 1 > /sys/class/gpio/gpio166/active_low #SFP+38
+ #echo 1 > /sys/class/gpio/gpio167/active_low #SFP+39
+ #echo 1 > /sys/class/gpio/gpio168/active_low #SFP+40
+ #echo 1 > /sys/class/gpio/gpio169/active_low #SFP+41
+ #echo 1 > /sys/class/gpio/gpio170/active_low #SFP+42
+ #echo 1 > /sys/class/gpio/gpio171/active_low #SFP+43
+ #echo 1 > /sys/class/gpio/gpio172/active_low #SFP+44
+ #echo 1 > /sys/class/gpio/gpio173/active_low #SFP+45
+ #echo 1 > /sys/class/gpio/gpio174/active_low #SFP+46
+ #echo 1 > /sys/class/gpio/gpio175/active_low #SFP+47
}
@@ -786,7 +851,7 @@ function _i2c_led_fan_tray_status_set {
FAN8_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan8_alarm`
if [ "${FAN1_ALARM}" == "0" ] && [ "${FAN2_ALARM}" == "0" ]; then
- FAN_TRAY=1
+ FAN_TRAY=1
COLOR_LED="green"
ONOFF_LED="on"
echo "${COLOR_LED} ${ONOFF_LED}"
@@ -796,7 +861,7 @@ function _i2c_led_fan_tray_status_set {
echo "${COLOR_LED} ${ONOFF_LED}"
_i2c_fan_tray_led
else
- FAN_TRAY=1
+ FAN_TRAY=1
COLOR_LED="green"
ONOFF_LED="off"
echo "${COLOR_LED} ${ONOFF_LED}"
@@ -808,7 +873,7 @@ function _i2c_led_fan_tray_status_set {
fi
if [ "${FAN3_ALARM}" == "0" ] && [ "${FAN4_ALARM}" == "0" ]; then
- FAN_TRAY=2
+ FAN_TRAY=2
COLOR_LED="green"
ONOFF_LED="on"
echo "${COLOR_LED} ${ONOFF_LED}"
@@ -818,7 +883,7 @@ function _i2c_led_fan_tray_status_set {
echo "${COLOR_LED} ${ONOFF_LED}"
_i2c_fan_tray_led
else
- FAN_TRAY=2
+ FAN_TRAY=2
COLOR_LED="green"
ONOFF_LED="off"
echo "${COLOR_LED} ${ONOFF_LED}"
@@ -830,7 +895,7 @@ function _i2c_led_fan_tray_status_set {
fi
if [ "${FAN5_ALARM}" == "0" ] && [ "${FAN6_ALARM}" == "0" ]; then
- FAN_TRAY=3
+ FAN_TRAY=3
COLOR_LED="green"
ONOFF_LED="on"
echo "${COLOR_LED} ${ONOFF_LED}"
@@ -840,7 +905,7 @@ function _i2c_led_fan_tray_status_set {
echo "${COLOR_LED} ${ONOFF_LED}"
_i2c_fan_tray_led
else
- FAN_TRAY=3
+ FAN_TRAY=3
COLOR_LED="green"
ONOFF_LED="off"
echo "${COLOR_LED} ${ONOFF_LED}"
@@ -852,7 +917,7 @@ function _i2c_led_fan_tray_status_set {
fi
if [ "${FAN7_ALARM}" == "0" ] && [ "${FAN8_ALARM}" == "0" ]; then
- FAN_TRAY=4
+ FAN_TRAY=4
COLOR_LED="green"
ONOFF_LED="on"
echo "${COLOR_LED} ${ONOFF_LED}"
@@ -862,7 +927,7 @@ function _i2c_led_fan_tray_status_set {
echo "${COLOR_LED} ${ONOFF_LED}"
_i2c_fan_tray_led
else
- FAN_TRAY=4
+ FAN_TRAY=4
COLOR_LED="green"
ONOFF_LED="off"
echo "${COLOR_LED} ${ONOFF_LED}"
@@ -1038,43 +1103,50 @@ function _qsfp_port_i2c_var_set {
i2cbus=${NUM_MUX2_CHAN0_DEVICE}
regAddr=0x20
dataAddr=0
- gpioBase=${ZQSFP_PORT0_15_ABS_GPIO_IDX}
+ gpioBase=$((${GPIO_OFFSET}+${ZQSFP_PORT0_15_ABS_GPIO_IDX}))
+ #gpioBase=${ZQSFP_PORT0_15_ABS_GPIO_IDX}
;;
9|10|11|12|13|14|15|16)
i2cbus=${NUM_MUX2_CHAN0_DEVICE}
regAddr=0x20
dataAddr=1
- gpioBase=${ZQSFP_PORT0_15_ABS_GPIO_IDX}
+ gpioBase=$((${GPIO_OFFSET}+${ZQSFP_PORT0_15_ABS_GPIO_IDX}))
+ #gpioBase=${ZQSFP_PORT0_15_ABS_GPIO_IDX}
;;
17|18|19|20|21|22|23|24)
i2cbus=${NUM_MUX2_CHAN0_DEVICE}
regAddr=0x21
dataAddr=0
- gpioBase=${ZQSFP_PORT16_31_ABS_GPIO_IDX}
+ gpioBase=$((${GPIO_OFFSET}+${ZQSFP_PORT16_31_ABS_GPIO_IDX}))
+ #gpioBase=${ZQSFP_PORT16_31_ABS_GPIO_IDX}
;;
25|26|27|28|29|30|31|32)
i2cbus=${NUM_MUX2_CHAN0_DEVICE}
regAddr=0x21
dataAddr=1
- gpioBase=${ZQSFP_PORT16_31_ABS_GPIO_IDX}
+ gpioBase=$((${GPIO_OFFSET}+${ZQSFP_PORT16_31_ABS_GPIO_IDX}))
+ #gpioBase=${ZQSFP_PORT16_31_ABS_GPIO_IDX}
;;
33|34|35|36|37|38|39|40)
i2cbus=${NUM_MUX2_CHAN0_DEVICE}
regAddr=0x22
dataAddr=0
- gpioBase=${ZQSFP_PORT32_47_ABS_GPIO_IDX}
+ gpioBase=$((${GPIO_OFFSET}+${ZQSFP_PORT32_47_ABS_GPIO_IDX}))
+ #gpioBase=${ZQSFP_PORT32_47_ABS_GPIO_IDX}
;;
41|42|43|44|45|46|47|48)
i2cbus=${NUM_MUX2_CHAN0_DEVICE}
regAddr=0x22
dataAddr=1
- gpioBase=${ZQSFP_PORT32_47_ABS_GPIO_IDX}
+ gpioBase=$((${GPIO_OFFSET}+${ZQSFP_PORT32_47_ABS_GPIO_IDX}))
+ #gpioBase=${ZQSFP_PORT32_47_ABS_GPIO_IDX}
;;
49|50|51|52|53|54)
i2cbus=${NUM_MUX2_CHAN0_DEVICE}
regAddr=0x23
dataAddr=0
- gpioBase=$((240 - 48))
+ gpioBase=$((${GPIO_OFFSET}+240-48))
+ #gpioBase=$((240 - 48))
;;
*)
echo "Please input 1~54"
@@ -1399,6 +1471,7 @@ function _main {
tart_time_str=`date`
start_time_sec=$(date +%s)
+ _set_gpio_offset
if [ "${EXEC_FUNC}" == "help" ]; then
_help
elif [ "${EXEC_FUNC}" == "i2c_init" ]; then
@@ -1472,14 +1545,17 @@ function _main {
exit ${FALSE}
fi
- end_time_str=`date`
- end_time_sec=$(date +%s)
- diff_time=$[ ${end_time_sec} - ${start_time_sec} ]
- echo "Start Time: ${start_time_str} (${start_time_sec})"
- echo "End Time : ${end_time_str} (${end_time_sec})"
- echo "Total Execution Time: ${diff_time} sec"
+ if [ "$DEBUG" == "on" ]; then
+ echo "-----------------------------------------------------"
+ end_time_str=`date`
+ end_time_sec=$(date +%s)
+ diff_time=$[ ${end_time_sec} - ${start_time_sec} ]
+ echo "Start Time: ${start_time_str} (${start_time_sec})"
+ echo "End Time : ${end_time_str} (${end_time_sec})"
+ echo "Total Execution Time: ${diff_time} sec"
- echo "done!!!"
+ echo "done!!!"
+ fi
}
_main
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/s8900-64xc/utils/i2c_utils.sh b/platform/broadcom/sonic-platform-modules-ingrasys/s8900-64xc/utils/i2c_utils.sh
index cd33df48bd..e1df54ad0f 100644
--- a/platform/broadcom/sonic-platform-modules-ingrasys/s8900-64xc/utils/i2c_utils.sh
+++ b/platform/broadcom/sonic-platform-modules-ingrasys/s8900-64xc/utils/i2c_utils.sh
@@ -15,6 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
+# trun on for more debug output
+#DEBUG="on"
+
VERSION="1.0.0"
TRUE=200
FALSE=404
@@ -1144,14 +1147,17 @@ function _main {
exit ${FALSE}
fi
- end_time_str=`date`
- end_time_sec=$(date +%s)
- diff_time=$[ ${end_time_sec} - ${start_time_sec} ]
- echo "Start Time: ${start_time_str} (${start_time_sec})"
- echo "End Time : ${end_time_str} (${end_time_sec})"
- echo "Total Execution Time: ${diff_time} sec"
+ if [ "$DEBUG" == "on" ]; then
+ echo "-----------------------------------------------------"
+ end_time_str=`date`
+ end_time_sec=$(date +%s)
+ diff_time=$[ ${end_time_sec} - ${start_time_sec} ]
+ echo "Start Time: ${start_time_str} (${start_time_sec})"
+ echo "End Time : ${end_time_str} (${end_time_sec})"
+ echo "Total Execution Time: ${diff_time} sec"
- echo "done!!!"
+ echo "done!!!"
+ fi
}
_main
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/s9100/utils/i2c_utils.sh b/platform/broadcom/sonic-platform-modules-ingrasys/s9100/utils/i2c_utils.sh
index bdcd4f1d7f..4aefe153a6 100755
--- a/platform/broadcom/sonic-platform-modules-ingrasys/s9100/utils/i2c_utils.sh
+++ b/platform/broadcom/sonic-platform-modules-ingrasys/s9100/utils/i2c_utils.sh
@@ -15,7 +15,10 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
-VERSION="1.0.0"
+# trun on for more debug output
+#DEBUG="on"
+
+VERSION="1.1.0"
TRUE=200
FALSE=404
@@ -78,10 +81,14 @@ PSU_DC_OFF=0
PSU_EXIST=1
PSU_NOT_EXIST=0
+#GPIO Offset
+GPIO_OFFSET=0
+
# Help usage function
function _help {
echo "========================================================="
echo "# Description: Help Function"
+ echo "# Version : ${VERSION}"
echo "========================================================="
echo "----------------------------------------------------"
echo "EX : ${0} help"
@@ -191,7 +198,9 @@ function _i2c_init {
modprobe gpio-pca953x
_i2c_fan_init
_i2c_io_exp_init
+ rmmod gpio_ich
_i2c_gpio_init
+ modprobe gpio_ich
_i2c_cpld_init
_i2c_qsfp_eeprom_init "new"
_i2c_mb_eeprom_init "new"
@@ -367,351 +376,420 @@ function _i2c_io_exp_init {
i2cset -y -r ${NUM_MUX1_CHAN7_DEVICE} 0x20 7 0xCC
}
+# To set the global variable GPIO_OFFSET
+function _set_gpio_offset {
+ GPIO_OFFSET=0
+ for d in `ls /sys/class/gpio/ | grep gpiochip`
+ do
+ gpiochip_no=${d##gpiochip}
+ if [ $gpiochip_no -gt 255 ]; then
+ GPIO_OFFSET=256
+ break
+ fi
+ done
+ #echo "set GPIO_OFFSET=${GPIO_OFFSET}"
+}
+
#GPIO Init
function _i2c_gpio_init {
- #ABS Port 0-15
+ #ABS Port 0-15 (zQSFP00 ~ zQSFP15)
echo "pca9535 0x20" > /sys/bus/i2c/devices/i2c-${NUM_MUX1_CHAN4_DEVICE}/new_device
- echo 240 > /sys/class/gpio/export
- echo 241 > /sys/class/gpio/export
- echo 242 > /sys/class/gpio/export
- echo 243 > /sys/class/gpio/export
- echo 244 > /sys/class/gpio/export
- echo 245 > /sys/class/gpio/export
- echo 246 > /sys/class/gpio/export
- echo 247 > /sys/class/gpio/export
- echo 248 > /sys/class/gpio/export
- echo 249 > /sys/class/gpio/export
- echo 250 > /sys/class/gpio/export
- echo 251 > /sys/class/gpio/export
- echo 252 > /sys/class/gpio/export
- echo 253 > /sys/class/gpio/export
- echo 254 > /sys/class/gpio/export
- echo 255 > /sys/class/gpio/export
- echo 1 > /sys/class/gpio/gpio241/active_low #zQSFP00
- echo 1 > /sys/class/gpio/gpio240/active_low #zQSFP01
- echo 1 > /sys/class/gpio/gpio243/active_low #zQSFP02
- echo 1 > /sys/class/gpio/gpio242/active_low #zQSFP03
- echo 1 > /sys/class/gpio/gpio245/active_low #zQSFP04
- echo 1 > /sys/class/gpio/gpio244/active_low #zQSFP05
- echo 1 > /sys/class/gpio/gpio247/active_low #zQSFP06
- echo 1 > /sys/class/gpio/gpio246/active_low #zQSFP07
- echo 1 > /sys/class/gpio/gpio249/active_low #zQSFP08
- echo 1 > /sys/class/gpio/gpio248/active_low #zQSFP09
- echo 1 > /sys/class/gpio/gpio251/active_low #zQSFP10
- echo 1 > /sys/class/gpio/gpio250/active_low #zQSFP11
- echo 1 > /sys/class/gpio/gpio253/active_low #zQSFP12
- echo 1 > /sys/class/gpio/gpio252/active_low #zQSFP13
- echo 1 > /sys/class/gpio/gpio255/active_low #zQSFP14
- echo 1 > /sys/class/gpio/gpio254/active_low #zQSFP15
+ _set_gpio_offset
+ for((i=${GPIO_OFFSET}+240;i<=${GPIO_OFFSET}+255;i++));
+ do
+ echo $i > /sys/class/gpio/export
+ echo 1 > /sys/class/gpio/gpio${i}/active_low
+ done
- #ABS Port 16-31
+ #echo 240 > /sys/class/gpio/export
+ #echo 241 > /sys/class/gpio/export
+ #echo 242 > /sys/class/gpio/export
+ #echo 243 > /sys/class/gpio/export
+ #echo 244 > /sys/class/gpio/export
+ #echo 245 > /sys/class/gpio/export
+ #echo 246 > /sys/class/gpio/export
+ #echo 247 > /sys/class/gpio/export
+ #echo 248 > /sys/class/gpio/export
+ #echo 249 > /sys/class/gpio/export
+ #echo 250 > /sys/class/gpio/export
+ #echo 251 > /sys/class/gpio/export
+ #echo 252 > /sys/class/gpio/export
+ #echo 253 > /sys/class/gpio/export
+ #echo 254 > /sys/class/gpio/export
+ #echo 255 > /sys/class/gpio/export
+ #echo 1 > /sys/class/gpio/gpio241/active_low #zQSFP00
+ #echo 1 > /sys/class/gpio/gpio240/active_low #zQSFP01
+ #echo 1 > /sys/class/gpio/gpio243/active_low #zQSFP02
+ #echo 1 > /sys/class/gpio/gpio242/active_low #zQSFP03
+ #echo 1 > /sys/class/gpio/gpio245/active_low #zQSFP04
+ #echo 1 > /sys/class/gpio/gpio244/active_low #zQSFP05
+ #echo 1 > /sys/class/gpio/gpio247/active_low #zQSFP06
+ #echo 1 > /sys/class/gpio/gpio246/active_low #zQSFP07
+ #echo 1 > /sys/class/gpio/gpio249/active_low #zQSFP08
+ #echo 1 > /sys/class/gpio/gpio248/active_low #zQSFP09
+ #echo 1 > /sys/class/gpio/gpio251/active_low #zQSFP10
+ #echo 1 > /sys/class/gpio/gpio250/active_low #zQSFP11
+ #echo 1 > /sys/class/gpio/gpio253/active_low #zQSFP12
+ #echo 1 > /sys/class/gpio/gpio252/active_low #zQSFP13
+ #echo 1 > /sys/class/gpio/gpio255/active_low #zQSFP14
+ #echo 1 > /sys/class/gpio/gpio254/active_low #zQSFP15
+
+ #ABS Port 16-31 (zQSFP16 ~ zQSFP31)
echo "pca9535 0x21" > /sys/bus/i2c/devices/i2c-${NUM_MUX1_CHAN4_DEVICE}/new_device
- echo 224 > /sys/class/gpio/export
- echo 225 > /sys/class/gpio/export
- echo 226 > /sys/class/gpio/export
- echo 227 > /sys/class/gpio/export
- echo 228 > /sys/class/gpio/export
- echo 229 > /sys/class/gpio/export
- echo 230 > /sys/class/gpio/export
- echo 231 > /sys/class/gpio/export
- echo 232 > /sys/class/gpio/export
- echo 233 > /sys/class/gpio/export
- echo 234 > /sys/class/gpio/export
- echo 235 > /sys/class/gpio/export
- echo 236 > /sys/class/gpio/export
- echo 237 > /sys/class/gpio/export
- echo 238 > /sys/class/gpio/export
- echo 239 > /sys/class/gpio/export
- echo 1 > /sys/class/gpio/gpio225/active_low #zQSFP16
- echo 1 > /sys/class/gpio/gpio224/active_low #zQSFP17
- echo 1 > /sys/class/gpio/gpio227/active_low #zQSFP18
- echo 1 > /sys/class/gpio/gpio226/active_low #zQSFP19
- echo 1 > /sys/class/gpio/gpio229/active_low #zQSFP20
- echo 1 > /sys/class/gpio/gpio228/active_low #zQSFP21
- echo 1 > /sys/class/gpio/gpio231/active_low #zQSFP22
- echo 1 > /sys/class/gpio/gpio230/active_low #zQSFP23
- echo 1 > /sys/class/gpio/gpio233/active_low #zQSFP24
- echo 1 > /sys/class/gpio/gpio232/active_low #zQSFP25
- echo 1 > /sys/class/gpio/gpio235/active_low #zQSFP26
- echo 1 > /sys/class/gpio/gpio234/active_low #zQSFP27
- echo 1 > /sys/class/gpio/gpio237/active_low #zQSFP28
- echo 1 > /sys/class/gpio/gpio236/active_low #zQSFP29
- echo 1 > /sys/class/gpio/gpio239/active_low #zQSFP30
- echo 1 > /sys/class/gpio/gpio238/active_low #zQSFP31
+ for((i=${GPIO_OFFSET}+224;i<=${GPIO_OFFSET}+239;i++));
+ do
+ echo $i > /sys/class/gpio/export
+ echo 1 > /sys/class/gpio/gpio${i}/active_low
+ done
- #INT Port 0-15
+ #echo 224 > /sys/class/gpio/export
+ #echo 225 > /sys/class/gpio/export
+ #echo 226 > /sys/class/gpio/export
+ #echo 227 > /sys/class/gpio/export
+ #echo 228 > /sys/class/gpio/export
+ #echo 229 > /sys/class/gpio/export
+ #echo 230 > /sys/class/gpio/export
+ #echo 231 > /sys/class/gpio/export
+ #echo 232 > /sys/class/gpio/export
+ #echo 233 > /sys/class/gpio/export
+ #echo 234 > /sys/class/gpio/export
+ #echo 235 > /sys/class/gpio/export
+ #echo 236 > /sys/class/gpio/export
+ #echo 237 > /sys/class/gpio/export
+ #echo 238 > /sys/class/gpio/export
+ #echo 239 > /sys/class/gpio/export
+ #echo 1 > /sys/class/gpio/gpio225/active_low #zQSFP16
+ #echo 1 > /sys/class/gpio/gpio224/active_low #zQSFP17
+ #echo 1 > /sys/class/gpio/gpio227/active_low #zQSFP18
+ #echo 1 > /sys/class/gpio/gpio226/active_low #zQSFP19
+ #echo 1 > /sys/class/gpio/gpio229/active_low #zQSFP20
+ #echo 1 > /sys/class/gpio/gpio228/active_low #zQSFP21
+ #echo 1 > /sys/class/gpio/gpio231/active_low #zQSFP22
+ #echo 1 > /sys/class/gpio/gpio230/active_low #zQSFP23
+ #echo 1 > /sys/class/gpio/gpio233/active_low #zQSFP24
+ #echo 1 > /sys/class/gpio/gpio232/active_low #zQSFP25
+ #echo 1 > /sys/class/gpio/gpio235/active_low #zQSFP26
+ #echo 1 > /sys/class/gpio/gpio234/active_low #zQSFP27
+ #echo 1 > /sys/class/gpio/gpio237/active_low #zQSFP28
+ #echo 1 > /sys/class/gpio/gpio236/active_low #zQSFP29
+ #echo 1 > /sys/class/gpio/gpio239/active_low #zQSFP30
+ #echo 1 > /sys/class/gpio/gpio238/active_low #zQSFP31
+
+ #INT Port 0-15 (zQSFP00 ~ zQSFP15)
echo "pca9535 0x22" > /sys/bus/i2c/devices/i2c-${NUM_MUX1_CHAN4_DEVICE}/new_device
- echo 208 > /sys/class/gpio/export
- echo 209 > /sys/class/gpio/export
- echo 210 > /sys/class/gpio/export
- echo 211 > /sys/class/gpio/export
- echo 212 > /sys/class/gpio/export
- echo 213 > /sys/class/gpio/export
- echo 214 > /sys/class/gpio/export
- echo 215 > /sys/class/gpio/export
- echo 216 > /sys/class/gpio/export
- echo 217 > /sys/class/gpio/export
- echo 218 > /sys/class/gpio/export
- echo 219 > /sys/class/gpio/export
- echo 220 > /sys/class/gpio/export
- echo 221 > /sys/class/gpio/export
- echo 222 > /sys/class/gpio/export
- echo 223 > /sys/class/gpio/export
- echo 1 > /sys/class/gpio/gpio208/active_low
- echo 1 > /sys/class/gpio/gpio209/active_low
- echo 1 > /sys/class/gpio/gpio210/active_low
- echo 1 > /sys/class/gpio/gpio211/active_low
- echo 1 > /sys/class/gpio/gpio212/active_low
- echo 1 > /sys/class/gpio/gpio213/active_low
- echo 1 > /sys/class/gpio/gpio214/active_low
- echo 1 > /sys/class/gpio/gpio215/active_low
- echo 1 > /sys/class/gpio/gpio216/active_low
- echo 1 > /sys/class/gpio/gpio217/active_low
- echo 1 > /sys/class/gpio/gpio218/active_low
- echo 1 > /sys/class/gpio/gpio219/active_low
- echo 1 > /sys/class/gpio/gpio220/active_low
- echo 1 > /sys/class/gpio/gpio221/active_low
- echo 1 > /sys/class/gpio/gpio222/active_low
- echo 1 > /sys/class/gpio/gpio223/active_low
+ for((i=${GPIO_OFFSET}+208;i<=${GPIO_OFFSET}+223;i++));
+ do
+ echo $i > /sys/class/gpio/export
+ echo 1 > /sys/class/gpio/gpio${i}/active_low
+ done
- #INT Port 16-31
+ #echo 208 > /sys/class/gpio/export
+ #echo 209 > /sys/class/gpio/export
+ #echo 210 > /sys/class/gpio/export
+ #echo 211 > /sys/class/gpio/export
+ #echo 212 > /sys/class/gpio/export
+ #echo 213 > /sys/class/gpio/export
+ #echo 214 > /sys/class/gpio/export
+ #echo 215 > /sys/class/gpio/export
+ #echo 216 > /sys/class/gpio/export
+ #echo 217 > /sys/class/gpio/export
+ #echo 218 > /sys/class/gpio/export
+ #echo 219 > /sys/class/gpio/export
+ #echo 220 > /sys/class/gpio/export
+ #echo 221 > /sys/class/gpio/export
+ #echo 222 > /sys/class/gpio/export
+ #echo 223 > /sys/class/gpio/export
+ #echo 1 > /sys/class/gpio/gpio208/active_low
+ #echo 1 > /sys/class/gpio/gpio209/active_low
+ #echo 1 > /sys/class/gpio/gpio210/active_low
+ #echo 1 > /sys/class/gpio/gpio211/active_low
+ #echo 1 > /sys/class/gpio/gpio212/active_low
+ #echo 1 > /sys/class/gpio/gpio213/active_low
+ #echo 1 > /sys/class/gpio/gpio214/active_low
+ #echo 1 > /sys/class/gpio/gpio215/active_low
+ #echo 1 > /sys/class/gpio/gpio216/active_low
+ #echo 1 > /sys/class/gpio/gpio217/active_low
+ #echo 1 > /sys/class/gpio/gpio218/active_low
+ #echo 1 > /sys/class/gpio/gpio219/active_low
+ #echo 1 > /sys/class/gpio/gpio220/active_low
+ #echo 1 > /sys/class/gpio/gpio221/active_low
+ #echo 1 > /sys/class/gpio/gpio222/active_low
+ #echo 1 > /sys/class/gpio/gpio223/active_low
+
+ #INT Port 16-31 (zQSFP16 ~ zQSFP31)
echo "pca9535 0x23" > /sys/bus/i2c/devices/i2c-${NUM_MUX1_CHAN4_DEVICE}/new_device
- echo 192 > /sys/class/gpio/export
- echo 193 > /sys/class/gpio/export
- echo 194 > /sys/class/gpio/export
- echo 195 > /sys/class/gpio/export
- echo 196 > /sys/class/gpio/export
- echo 197 > /sys/class/gpio/export
- echo 198 > /sys/class/gpio/export
- echo 199 > /sys/class/gpio/export
- echo 200 > /sys/class/gpio/export
- echo 201 > /sys/class/gpio/export
- echo 202 > /sys/class/gpio/export
- echo 203 > /sys/class/gpio/export
- echo 204 > /sys/class/gpio/export
- echo 205 > /sys/class/gpio/export
- echo 206 > /sys/class/gpio/export
- echo 207 > /sys/class/gpio/export
- echo 1 > /sys/class/gpio/gpio192/active_low
- echo 1 > /sys/class/gpio/gpio193/active_low
- echo 1 > /sys/class/gpio/gpio194/active_low
- echo 1 > /sys/class/gpio/gpio195/active_low
- echo 1 > /sys/class/gpio/gpio196/active_low
- echo 1 > /sys/class/gpio/gpio197/active_low
- echo 1 > /sys/class/gpio/gpio198/active_low
- echo 1 > /sys/class/gpio/gpio199/active_low
- echo 1 > /sys/class/gpio/gpio200/active_low
- echo 1 > /sys/class/gpio/gpio201/active_low
- echo 1 > /sys/class/gpio/gpio202/active_low
- echo 1 > /sys/class/gpio/gpio203/active_low
- echo 1 > /sys/class/gpio/gpio204/active_low
- echo 1 > /sys/class/gpio/gpio205/active_low
- echo 1 > /sys/class/gpio/gpio206/active_low
- echo 1 > /sys/class/gpio/gpio207/active_low
+ for((i=${GPIO_OFFSET}+192;i<=${GPIO_OFFSET}+207;i++));
+ do
+ echo $i > /sys/class/gpio/export
+ echo 1 > /sys/class/gpio/gpio${i}/active_low
+ done
+
+ #echo 192 > /sys/class/gpio/export
+ #echo 193 > /sys/class/gpio/export
+ #echo 194 > /sys/class/gpio/export
+ #echo 195 > /sys/class/gpio/export
+ #echo 196 > /sys/class/gpio/export
+ #echo 197 > /sys/class/gpio/export
+ #echo 198 > /sys/class/gpio/export
+ #echo 199 > /sys/class/gpio/export
+ #echo 200 > /sys/class/gpio/export
+ #echo 201 > /sys/class/gpio/export
+ #echo 202 > /sys/class/gpio/export
+ #echo 203 > /sys/class/gpio/export
+ #echo 204 > /sys/class/gpio/export
+ #echo 205 > /sys/class/gpio/export
+ #echo 206 > /sys/class/gpio/export
+ #echo 207 > /sys/class/gpio/export
+ #echo 1 > /sys/class/gpio/gpio192/active_low
+ #echo 1 > /sys/class/gpio/gpio193/active_low
+ #echo 1 > /sys/class/gpio/gpio194/active_low
+ #echo 1 > /sys/class/gpio/gpio195/active_low
+ #echo 1 > /sys/class/gpio/gpio196/active_low
+ #echo 1 > /sys/class/gpio/gpio197/active_low
+ #echo 1 > /sys/class/gpio/gpio198/active_low
+ #echo 1 > /sys/class/gpio/gpio199/active_low
+ #echo 1 > /sys/class/gpio/gpio200/active_low
+ #echo 1 > /sys/class/gpio/gpio201/active_low
+ #echo 1 > /sys/class/gpio/gpio202/active_low
+ #echo 1 > /sys/class/gpio/gpio203/active_low
+ #echo 1 > /sys/class/gpio/gpio204/active_low
+ #echo 1 > /sys/class/gpio/gpio205/active_low
+ #echo 1 > /sys/class/gpio/gpio206/active_low
+ #echo 1 > /sys/class/gpio/gpio207/active_low
#LP Mode Port 0-15
echo "pca9535 0x20" > /sys/bus/i2c/devices/i2c-${NUM_MUX1_CHAN5_DEVICE}/new_device
- echo 176 > /sys/class/gpio/export
- echo 177 > /sys/class/gpio/export
- echo 178 > /sys/class/gpio/export
- echo 179 > /sys/class/gpio/export
- echo 180 > /sys/class/gpio/export
- echo 181 > /sys/class/gpio/export
- echo 182 > /sys/class/gpio/export
- echo 183 > /sys/class/gpio/export
- echo 184 > /sys/class/gpio/export
- echo 185 > /sys/class/gpio/export
- echo 186 > /sys/class/gpio/export
- echo 187 > /sys/class/gpio/export
- echo 188 > /sys/class/gpio/export
- echo 189 > /sys/class/gpio/export
- echo 190 > /sys/class/gpio/export
- echo 191 > /sys/class/gpio/export
- echo out > /sys/class/gpio/gpio176/direction
- echo out > /sys/class/gpio/gpio177/direction
- echo out > /sys/class/gpio/gpio178/direction
- echo out > /sys/class/gpio/gpio179/direction
- echo out > /sys/class/gpio/gpio180/direction
- echo out > /sys/class/gpio/gpio181/direction
- echo out > /sys/class/gpio/gpio182/direction
- echo out > /sys/class/gpio/gpio183/direction
- echo out > /sys/class/gpio/gpio184/direction
- echo out > /sys/class/gpio/gpio185/direction
- echo out > /sys/class/gpio/gpio186/direction
- echo out > /sys/class/gpio/gpio187/direction
- echo out > /sys/class/gpio/gpio188/direction
- echo out > /sys/class/gpio/gpio189/direction
- echo out > /sys/class/gpio/gpio190/direction
- echo out > /sys/class/gpio/gpio191/direction
+ for((i=${GPIO_OFFSET}+176;i<=${GPIO_OFFSET}+191;i++));
+ do
+ echo $i > /sys/class/gpio/export
+ echo out > /sys/class/gpio/gpio${i}/direction
+ done
+
+ #echo 176 > /sys/class/gpio/export
+ #echo 177 > /sys/class/gpio/export
+ #echo 178 > /sys/class/gpio/export
+ #echo 179 > /sys/class/gpio/export
+ #echo 180 > /sys/class/gpio/export
+ #echo 181 > /sys/class/gpio/export
+ #echo 182 > /sys/class/gpio/export
+ #echo 183 > /sys/class/gpio/export
+ #echo 184 > /sys/class/gpio/export
+ #echo 185 > /sys/class/gpio/export
+ #echo 186 > /sys/class/gpio/export
+ #echo 187 > /sys/class/gpio/export
+ #echo 188 > /sys/class/gpio/export
+ #echo 189 > /sys/class/gpio/export
+ #echo 190 > /sys/class/gpio/export
+ #echo 191 > /sys/class/gpio/export
+ #echo out > /sys/class/gpio/gpio176/direction
+ #echo out > /sys/class/gpio/gpio177/direction
+ #echo out > /sys/class/gpio/gpio178/direction
+ #echo out > /sys/class/gpio/gpio179/direction
+ #echo out > /sys/class/gpio/gpio180/direction
+ #echo out > /sys/class/gpio/gpio181/direction
+ #echo out > /sys/class/gpio/gpio182/direction
+ #echo out > /sys/class/gpio/gpio183/direction
+ #echo out > /sys/class/gpio/gpio184/direction
+ #echo out > /sys/class/gpio/gpio185/direction
+ #echo out > /sys/class/gpio/gpio186/direction
+ #echo out > /sys/class/gpio/gpio187/direction
+ #echo out > /sys/class/gpio/gpio188/direction
+ #echo out > /sys/class/gpio/gpio189/direction
+ #echo out > /sys/class/gpio/gpio190/direction
+ #echo out > /sys/class/gpio/gpio191/direction
#LP Mode Port 16-31
echo "pca9535 0x21" > /sys/bus/i2c/devices/i2c-${NUM_MUX1_CHAN5_DEVICE}/new_device
- echo 160 > /sys/class/gpio/export
- echo 161 > /sys/class/gpio/export
- echo 162 > /sys/class/gpio/export
- echo 163 > /sys/class/gpio/export
- echo 164 > /sys/class/gpio/export
- echo 165 > /sys/class/gpio/export
- echo 166 > /sys/class/gpio/export
- echo 167 > /sys/class/gpio/export
- echo 168 > /sys/class/gpio/export
- echo 169 > /sys/class/gpio/export
- echo 170 > /sys/class/gpio/export
- echo 171 > /sys/class/gpio/export
- echo 172 > /sys/class/gpio/export
- echo 173 > /sys/class/gpio/export
- echo 174 > /sys/class/gpio/export
- echo 175 > /sys/class/gpio/export
- echo out > /sys/class/gpio/gpio160/direction
- echo out > /sys/class/gpio/gpio161/direction
- echo out > /sys/class/gpio/gpio162/direction
- echo out > /sys/class/gpio/gpio163/direction
- echo out > /sys/class/gpio/gpio164/direction
- echo out > /sys/class/gpio/gpio165/direction
- echo out > /sys/class/gpio/gpio166/direction
- echo out > /sys/class/gpio/gpio167/direction
- echo out > /sys/class/gpio/gpio168/direction
- echo out > /sys/class/gpio/gpio169/direction
- echo out > /sys/class/gpio/gpio170/direction
- echo out > /sys/class/gpio/gpio171/direction
- echo out > /sys/class/gpio/gpio172/direction
- echo out > /sys/class/gpio/gpio173/direction
- echo out > /sys/class/gpio/gpio174/direction
- echo out > /sys/class/gpio/gpio175/direction
+ for((i=${GPIO_OFFSET}+160;i<=${GPIO_OFFSET}+175;i++));
+ do
+ echo $i > /sys/class/gpio/export
+ echo out > /sys/class/gpio/gpio${i}/direction
+ done
+
+ #echo 160 > /sys/class/gpio/export
+ #echo 161 > /sys/class/gpio/export
+ #echo 162 > /sys/class/gpio/export
+ #echo 163 > /sys/class/gpio/export
+ #echo 164 > /sys/class/gpio/export
+ #echo 165 > /sys/class/gpio/export
+ #echo 166 > /sys/class/gpio/export
+ #echo 167 > /sys/class/gpio/export
+ #echo 168 > /sys/class/gpio/export
+ #echo 169 > /sys/class/gpio/export
+ #echo 170 > /sys/class/gpio/export
+ #echo 171 > /sys/class/gpio/export
+ #echo 172 > /sys/class/gpio/export
+ #echo 173 > /sys/class/gpio/export
+ #echo 174 > /sys/class/gpio/export
+ #echo 175 > /sys/class/gpio/export
+ #echo out > /sys/class/gpio/gpio160/direction
+ #echo out > /sys/class/gpio/gpio161/direction
+ #echo out > /sys/class/gpio/gpio162/direction
+ #echo out > /sys/class/gpio/gpio163/direction
+ #echo out > /sys/class/gpio/gpio164/direction
+ #echo out > /sys/class/gpio/gpio165/direction
+ #echo out > /sys/class/gpio/gpio166/direction
+ #echo out > /sys/class/gpio/gpio167/direction
+ #echo out > /sys/class/gpio/gpio168/direction
+ #echo out > /sys/class/gpio/gpio169/direction
+ #echo out > /sys/class/gpio/gpio170/direction
+ #echo out > /sys/class/gpio/gpio171/direction
+ #echo out > /sys/class/gpio/gpio172/direction
+ #echo out > /sys/class/gpio/gpio173/direction
+ #echo out > /sys/class/gpio/gpio174/direction
+ #echo out > /sys/class/gpio/gpio175/direction
#RST Port 0-15
echo "pca9535 0x22" > /sys/bus/i2c/devices/i2c-${NUM_MUX1_CHAN5_DEVICE}/new_device
- echo 144 > /sys/class/gpio/export
- echo 145 > /sys/class/gpio/export
- echo 146 > /sys/class/gpio/export
- echo 147 > /sys/class/gpio/export
- echo 148 > /sys/class/gpio/export
- echo 149 > /sys/class/gpio/export
- echo 150 > /sys/class/gpio/export
- echo 151 > /sys/class/gpio/export
- echo 152 > /sys/class/gpio/export
- echo 153 > /sys/class/gpio/export
- echo 154 > /sys/class/gpio/export
- echo 155 > /sys/class/gpio/export
- echo 156 > /sys/class/gpio/export
- echo 157 > /sys/class/gpio/export
- echo 158 > /sys/class/gpio/export
- echo 159 > /sys/class/gpio/export
- echo out > /sys/class/gpio/gpio144/direction
- echo out > /sys/class/gpio/gpio145/direction
- echo out > /sys/class/gpio/gpio146/direction
- echo out > /sys/class/gpio/gpio147/direction
- echo out > /sys/class/gpio/gpio148/direction
- echo out > /sys/class/gpio/gpio149/direction
- echo out > /sys/class/gpio/gpio150/direction
- echo out > /sys/class/gpio/gpio151/direction
- echo out > /sys/class/gpio/gpio152/direction
- echo out > /sys/class/gpio/gpio153/direction
- echo out > /sys/class/gpio/gpio154/direction
- echo out > /sys/class/gpio/gpio155/direction
- echo out > /sys/class/gpio/gpio156/direction
- echo out > /sys/class/gpio/gpio157/direction
- echo out > /sys/class/gpio/gpio158/direction
- echo out > /sys/class/gpio/gpio159/direction
- echo 1 > /sys/class/gpio/gpio144/active_low
- echo 1 > /sys/class/gpio/gpio145/active_low
- echo 1 > /sys/class/gpio/gpio146/active_low
- echo 1 > /sys/class/gpio/gpio147/active_low
- echo 1 > /sys/class/gpio/gpio148/active_low
- echo 1 > /sys/class/gpio/gpio149/active_low
- echo 1 > /sys/class/gpio/gpio150/active_low
- echo 1 > /sys/class/gpio/gpio151/active_low
- echo 1 > /sys/class/gpio/gpio152/active_low
- echo 1 > /sys/class/gpio/gpio153/active_low
- echo 1 > /sys/class/gpio/gpio154/active_low
- echo 1 > /sys/class/gpio/gpio155/active_low
- echo 1 > /sys/class/gpio/gpio156/active_low
- echo 1 > /sys/class/gpio/gpio157/active_low
- echo 1 > /sys/class/gpio/gpio158/active_low
- echo 1 > /sys/class/gpio/gpio159/active_low
- echo 0 > /sys/class/gpio/gpio144/value
- echo 0 > /sys/class/gpio/gpio145/value
- echo 0 > /sys/class/gpio/gpio146/value
- echo 0 > /sys/class/gpio/gpio147/value
- echo 0 > /sys/class/gpio/gpio148/value
- echo 0 > /sys/class/gpio/gpio149/value
- echo 0 > /sys/class/gpio/gpio150/value
- echo 0 > /sys/class/gpio/gpio151/value
- echo 0 > /sys/class/gpio/gpio152/value
- echo 0 > /sys/class/gpio/gpio153/value
- echo 0 > /sys/class/gpio/gpio154/value
- echo 0 > /sys/class/gpio/gpio155/value
- echo 0 > /sys/class/gpio/gpio156/value
- echo 0 > /sys/class/gpio/gpio157/value
- echo 0 > /sys/class/gpio/gpio158/value
- echo 0 > /sys/class/gpio/gpio159/value
+ for((i=${GPIO_OFFSET}+144;i<=${GPIO_OFFSET}+159;i++));
+ do
+ echo $i > /sys/class/gpio/export
+ echo 1 > /sys/class/gpio/gpio${i}/active_low
+ echo low > /sys/class/gpio/gpio${i}/direction
+ #echo out > /sys/class/gpio/gpio${i}/direction
+ #echo 0 > /sys/class/gpio/gpio${i}/value
+ done
+
+ #echo 144 > /sys/class/gpio/export
+ #echo 145 > /sys/class/gpio/export
+ #echo 146 > /sys/class/gpio/export
+ #echo 147 > /sys/class/gpio/export
+ #echo 148 > /sys/class/gpio/export
+ #echo 149 > /sys/class/gpio/export
+ #echo 150 > /sys/class/gpio/export
+ #echo 151 > /sys/class/gpio/export
+ #echo 152 > /sys/class/gpio/export
+ #echo 153 > /sys/class/gpio/export
+ #echo 154 > /sys/class/gpio/export
+ #echo 155 > /sys/class/gpio/export
+ #echo 156 > /sys/class/gpio/export
+ #echo 157 > /sys/class/gpio/export
+ #echo 158 > /sys/class/gpio/export
+ #echo 159 > /sys/class/gpio/export
+ #echo out > /sys/class/gpio/gpio144/direction
+ #echo out > /sys/class/gpio/gpio145/direction
+ #echo out > /sys/class/gpio/gpio146/direction
+ #echo out > /sys/class/gpio/gpio147/direction
+ #echo out > /sys/class/gpio/gpio148/direction
+ #echo out > /sys/class/gpio/gpio149/direction
+ #echo out > /sys/class/gpio/gpio150/direction
+ #echo out > /sys/class/gpio/gpio151/direction
+ #echo out > /sys/class/gpio/gpio152/direction
+ #echo out > /sys/class/gpio/gpio153/direction
+ #echo out > /sys/class/gpio/gpio154/direction
+ #echo out > /sys/class/gpio/gpio155/direction
+ #echo out > /sys/class/gpio/gpio156/direction
+ #echo out > /sys/class/gpio/gpio157/direction
+ #echo out > /sys/class/gpio/gpio158/direction
+ #echo out > /sys/class/gpio/gpio159/direction
+ #echo 1 > /sys/class/gpio/gpio144/active_low
+ #echo 1 > /sys/class/gpio/gpio145/active_low
+ #echo 1 > /sys/class/gpio/gpio146/active_low
+ #echo 1 > /sys/class/gpio/gpio147/active_low
+ #echo 1 > /sys/class/gpio/gpio148/active_low
+ #echo 1 > /sys/class/gpio/gpio149/active_low
+ #echo 1 > /sys/class/gpio/gpio150/active_low
+ #echo 1 > /sys/class/gpio/gpio151/active_low
+ #echo 1 > /sys/class/gpio/gpio152/active_low
+ #echo 1 > /sys/class/gpio/gpio153/active_low
+ #echo 1 > /sys/class/gpio/gpio154/active_low
+ #echo 1 > /sys/class/gpio/gpio155/active_low
+ #echo 1 > /sys/class/gpio/gpio156/active_low
+ #echo 1 > /sys/class/gpio/gpio157/active_low
+ #echo 1 > /sys/class/gpio/gpio158/active_low
+ #echo 1 > /sys/class/gpio/gpio159/active_low
+ #echo 0 > /sys/class/gpio/gpio144/value
+ #echo 0 > /sys/class/gpio/gpio145/value
+ #echo 0 > /sys/class/gpio/gpio146/value
+ #echo 0 > /sys/class/gpio/gpio147/value
+ #echo 0 > /sys/class/gpio/gpio148/value
+ #echo 0 > /sys/class/gpio/gpio149/value
+ #echo 0 > /sys/class/gpio/gpio150/value
+ #echo 0 > /sys/class/gpio/gpio151/value
+ #echo 0 > /sys/class/gpio/gpio152/value
+ #echo 0 > /sys/class/gpio/gpio153/value
+ #echo 0 > /sys/class/gpio/gpio154/value
+ #echo 0 > /sys/class/gpio/gpio155/value
+ #echo 0 > /sys/class/gpio/gpio156/value
+ #echo 0 > /sys/class/gpio/gpio157/value
+ #echo 0 > /sys/class/gpio/gpio158/value
+ #echo 0 > /sys/class/gpio/gpio159/value
#RST Port 16-31
echo "pca9535 0x23" > /sys/bus/i2c/devices/i2c-${NUM_MUX1_CHAN5_DEVICE}/new_device
- echo 128 > /sys/class/gpio/export
- echo 129 > /sys/class/gpio/export
- echo 130 > /sys/class/gpio/export
- echo 131 > /sys/class/gpio/export
- echo 132 > /sys/class/gpio/export
- echo 133 > /sys/class/gpio/export
- echo 134 > /sys/class/gpio/export
- echo 135 > /sys/class/gpio/export
- echo 136 > /sys/class/gpio/export
- echo 137 > /sys/class/gpio/export
- echo 138 > /sys/class/gpio/export
- echo 139 > /sys/class/gpio/export
- echo 140 > /sys/class/gpio/export
- echo 141 > /sys/class/gpio/export
- echo 142 > /sys/class/gpio/export
- echo 143 > /sys/class/gpio/export
- echo out > /sys/class/gpio/gpio128/direction
- echo out > /sys/class/gpio/gpio129/direction
- echo out > /sys/class/gpio/gpio130/direction
- echo out > /sys/class/gpio/gpio131/direction
- echo out > /sys/class/gpio/gpio132/direction
- echo out > /sys/class/gpio/gpio133/direction
- echo out > /sys/class/gpio/gpio134/direction
- echo out > /sys/class/gpio/gpio135/direction
- echo out > /sys/class/gpio/gpio136/direction
- echo out > /sys/class/gpio/gpio137/direction
- echo out > /sys/class/gpio/gpio138/direction
- echo out > /sys/class/gpio/gpio139/direction
- echo out > /sys/class/gpio/gpio140/direction
- echo out > /sys/class/gpio/gpio141/direction
- echo out > /sys/class/gpio/gpio142/direction
- echo out > /sys/class/gpio/gpio143/direction
- echo 1 > /sys/class/gpio/gpio128/active_low
- echo 1 > /sys/class/gpio/gpio129/active_low
- echo 1 > /sys/class/gpio/gpio130/active_low
- echo 1 > /sys/class/gpio/gpio131/active_low
- echo 1 > /sys/class/gpio/gpio132/active_low
- echo 1 > /sys/class/gpio/gpio133/active_low
- echo 1 > /sys/class/gpio/gpio134/active_low
- echo 1 > /sys/class/gpio/gpio135/active_low
- echo 1 > /sys/class/gpio/gpio136/active_low
- echo 1 > /sys/class/gpio/gpio137/active_low
- echo 1 > /sys/class/gpio/gpio138/active_low
- echo 1 > /sys/class/gpio/gpio139/active_low
- echo 1 > /sys/class/gpio/gpio140/active_low
- echo 1 > /sys/class/gpio/gpio141/active_low
- echo 1 > /sys/class/gpio/gpio142/active_low
- echo 1 > /sys/class/gpio/gpio143/active_low
- echo 0 > /sys/class/gpio/gpio128/value
- echo 0 > /sys/class/gpio/gpio129/value
- echo 0 > /sys/class/gpio/gpio130/value
- echo 0 > /sys/class/gpio/gpio131/value
- echo 0 > /sys/class/gpio/gpio132/value
- echo 0 > /sys/class/gpio/gpio133/value
- echo 0 > /sys/class/gpio/gpio134/value
- echo 0 > /sys/class/gpio/gpio135/value
- echo 0 > /sys/class/gpio/gpio136/value
- echo 0 > /sys/class/gpio/gpio137/value
- echo 0 > /sys/class/gpio/gpio138/value
- echo 0 > /sys/class/gpio/gpio139/value
- echo 0 > /sys/class/gpio/gpio140/value
- echo 0 > /sys/class/gpio/gpio141/value
- echo 0 > /sys/class/gpio/gpio142/value
- echo 0 > /sys/class/gpio/gpio143/value
+ for((i=${GPIO_OFFSET}+128;i<=${GPIO_OFFSET}+143;i++));
+ do
+ echo $i > /sys/class/gpio/export
+ echo 1 > /sys/class/gpio/gpio${i}/active_low
+ echo low > /sys/class/gpio/gpio${i}/direction
+ #echo out > /sys/class/gpio/gpio${i}/direction
+ #echo 0 > /sys/class/gpio/gpio${i}/value
+ done
+
+ #echo 128 > /sys/class/gpio/export
+ #echo 129 > /sys/class/gpio/export
+ #echo 130 > /sys/class/gpio/export
+ #echo 131 > /sys/class/gpio/export
+ #echo 132 > /sys/class/gpio/export
+ #echo 133 > /sys/class/gpio/export
+ #echo 134 > /sys/class/gpio/export
+ #echo 135 > /sys/class/gpio/export
+ #echo 136 > /sys/class/gpio/export
+ #echo 137 > /sys/class/gpio/export
+ #echo 138 > /sys/class/gpio/export
+ #echo 139 > /sys/class/gpio/export
+ #echo 140 > /sys/class/gpio/export
+ #echo 141 > /sys/class/gpio/export
+ #echo 142 > /sys/class/gpio/export
+ #echo 143 > /sys/class/gpio/export
+ #echo out > /sys/class/gpio/gpio128/direction
+ #echo out > /sys/class/gpio/gpio129/direction
+ #echo out > /sys/class/gpio/gpio130/direction
+ #echo out > /sys/class/gpio/gpio131/direction
+ #echo out > /sys/class/gpio/gpio132/direction
+ #echo out > /sys/class/gpio/gpio133/direction
+ #echo out > /sys/class/gpio/gpio134/direction
+ #echo out > /sys/class/gpio/gpio135/direction
+ #echo out > /sys/class/gpio/gpio136/direction
+ #echo out > /sys/class/gpio/gpio137/direction
+ #echo out > /sys/class/gpio/gpio138/direction
+ #echo out > /sys/class/gpio/gpio139/direction
+ #echo out > /sys/class/gpio/gpio140/direction
+ #echo out > /sys/class/gpio/gpio141/direction
+ #echo out > /sys/class/gpio/gpio142/direction
+ #echo out > /sys/class/gpio/gpio143/direction
+ #echo 1 > /sys/class/gpio/gpio128/active_low
+ #echo 1 > /sys/class/gpio/gpio129/active_low
+ #echo 1 > /sys/class/gpio/gpio130/active_low
+ #echo 1 > /sys/class/gpio/gpio131/active_low
+ #echo 1 > /sys/class/gpio/gpio132/active_low
+ #echo 1 > /sys/class/gpio/gpio133/active_low
+ #echo 1 > /sys/class/gpio/gpio134/active_low
+ #echo 1 > /sys/class/gpio/gpio135/active_low
+ #echo 1 > /sys/class/gpio/gpio136/active_low
+ #echo 1 > /sys/class/gpio/gpio137/active_low
+ #echo 1 > /sys/class/gpio/gpio138/active_low
+ #echo 1 > /sys/class/gpio/gpio139/active_low
+ #echo 1 > /sys/class/gpio/gpio140/active_low
+ #echo 1 > /sys/class/gpio/gpio141/active_low
+ #echo 1 > /sys/class/gpio/gpio142/active_low
+ #echo 1 > /sys/class/gpio/gpio143/active_low
+ #echo 0 > /sys/class/gpio/gpio128/value
+ #echo 0 > /sys/class/gpio/gpio129/value
+ #echo 0 > /sys/class/gpio/gpio130/value
+ #echo 0 > /sys/class/gpio/gpio131/value
+ #echo 0 > /sys/class/gpio/gpio132/value
+ #echo 0 > /sys/class/gpio/gpio133/value
+ #echo 0 > /sys/class/gpio/gpio134/value
+ #echo 0 > /sys/class/gpio/gpio135/value
+ #echo 0 > /sys/class/gpio/gpio136/value
+ #echo 0 > /sys/class/gpio/gpio137/value
+ #echo 0 > /sys/class/gpio/gpio138/value
+ #echo 0 > /sys/class/gpio/gpio139/value
+ #echo 0 > /sys/class/gpio/gpio140/value
+ #echo 0 > /sys/class/gpio/gpio141/value
+ #echo 0 > /sys/class/gpio/gpio142/value
+ #echo 0 > /sys/class/gpio/gpio143/value
}
@@ -1008,41 +1086,48 @@ function _qsfp_port_i2c_var_set {
regAddr=0x20
dataAddr=0
eeprombusbase=${NUM_MUX3_CHAN0_DEVICE}
- gpioBase=240
+ gpioBase=$((${GPIO_OFFSET}+240))
+ #gpioBase=240
;;
9|10|11|12|13|14|15|16)
i2cbus=${NUM_MUX1_CHAN4_DEVICE}
regAddr=0x20
dataAddr=1
eeprombusbase=${NUM_MUX4_CHAN0_DEVICE}
- gpioBase=240
+ gpioBase=$((${GPIO_OFFSET}+240))
+ #gpioBase=240
;;
17|18|19|20|21|22|23|24)
i2cbus=${NUM_MUX1_CHAN4_DEVICE}
regAddr=0x21
dataAddr=0
eeprombusbase=${NUM_MUX5_CHAN0_DEVICE}
- gpioBase=$((224 - 16))
+ gpioBase=$((${GPIO_OFFSET}+224-16))
+ #gpioBase=$((224 - 16))
;;
25|26|27|28|29|30|31|32)
i2cbus=${NUM_MUX1_CHAN4_DEVICE}
regAddr=0x21
dataAddr=1
eeprombusbase=${NUM_MUX6_CHAN0_DEVICE}
- gpioBase=$((224 - 16))
- ;;
- 33)
- i2cbus=${NUM_MUX1_CHAN7_DEVICE}
- regAddr=0x22
- dataAddr=0
- ;;
- 34)
- i2cbus=${NUM_MUX1_CHAN7_DEVICE}
- regAddr=0x22
- dataAddr=1
+ gpioBase=$((${GPIO_OFFSET}+224-16))
+ #gpioBase=$((224 - 16))
;;
+ #33)
+ # i2cbus=${NUM_MUX1_CHAN7_DEVICE}
+ # regAddr=0x22
+ # dataAddr=0
+ # gpioBase=${GPIO_OFFSET}
+ #;;
+ #34)
+ # i2cbus=${NUM_MUX1_CHAN7_DEVICE}
+ # regAddr=0x22
+ # dataAddr=1
+ # gpioBase=${GPIO_OFFSET}
+ #;;
*)
echo "Please input 1~32"
+ exit
;;
esac
}
@@ -1428,6 +1513,7 @@ function _main {
tart_time_str=`date`
start_time_sec=$(date +%s)
+ _set_gpio_offset
if [ "${EXEC_FUNC}" == "help" ]; then
_help
elif [ "${EXEC_FUNC}" == "i2c_init" ]; then
@@ -1505,14 +1591,17 @@ function _main {
exit ${FALSE}
fi
- end_time_str=`date`
- end_time_sec=$(date +%s)
- diff_time=$[ ${end_time_sec} - ${start_time_sec} ]
- echo "Start Time: ${start_time_str} (${start_time_sec})"
- echo "End Time : ${end_time_str} (${end_time_sec})"
- echo "Total Execution Time: ${diff_time} sec"
+ if [ "$DEBUG" == "on" ]; then
+ echo "-----------------------------------------------------"
+ end_time_str=`date`
+ end_time_sec=$(date +%s)
+ diff_time=$[ ${end_time_sec} - ${start_time_sec} ]
+ echo "Start Time: ${start_time_str} (${start_time_sec})"
+ echo "End Time : ${end_time_str} (${end_time_sec})"
+ echo "Total Execution Time: ${diff_time} sec"
- echo "done!!!"
+ echo "done!!!"
+ fi
}
_main
diff --git a/platform/broadcom/sonic-platform-modules-ingrasys/s9200-64x/utils/i2c_utils.sh b/platform/broadcom/sonic-platform-modules-ingrasys/s9200-64x/utils/i2c_utils.sh
index d0ca56f4d1..dcb6b91679 100644
--- a/platform/broadcom/sonic-platform-modules-ingrasys/s9200-64x/utils/i2c_utils.sh
+++ b/platform/broadcom/sonic-platform-modules-ingrasys/s9200-64x/utils/i2c_utils.sh
@@ -15,6 +15,9 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see .
+# trun on for more debug output
+#DEBUG="on"
+
VERSION="1.0.0"
TRUE=200
FALSE=404
@@ -602,6 +605,35 @@ function _i2c_io_exp_init {
i2cset -y -r ${i2c_bus} ${i2c_addr} ${REG_CFG_0} 0x00
i2cset -y -r ${i2c_bus} ${i2c_addr} ${REG_CFG_1} $((2#00011111))
+ #PCA9555 on BMC Dummy Board
+ #set SYSTEM_LED_RST_L before init PCA9539 LED BOARD IO Expander
+ echo "Init PCA9555 MUX RST IO Expander"
+ #PCA9555 MUX RST Expander
+ #0.0 FRU_I2C_MUX_RST_L OUT 1
+ #0.1 MAIN_I2C_MUX_RST_L OUT 1
+ #0.2 SYSTEM_LED_RST_L OUT 1
+ #0.3 BMC_TO_UCD_RST_L OUT 1
+ #0.4 BMC_TO_HOST_RST_L OUT 1
+ #0.5 ETHX_RST_L OUT 1
+ #0.6 GPIOF4 IN
+ #0.7 N/A
+ #1.0 CPU_to_FRU_I2C_EN OUT 1
+ #1.1 CPU_to_MAIN_I2C_EN OUT 1
+ #1.2 P3V3_FAN_EN OUT 1
+ #1.3 P3V3_I2C_EN OUT 1
+ #1.4 UCD9090_CNTRL OUT 1
+ #1.5 UART_MUX_SEL OUT 0
+ #1.6 USB_MUX_SEL OUT 0
+ #1.7 ETHX_CPU_EEPROM_SEL OUT 0
+ i2c_bus=${I2C_BUS_MUX_RST}
+ i2c_addr=${I2C_ADDR_MUX_RST}
+ i2cset -y -r ${i2c_bus} ${i2c_addr} ${REG_OUT_0} $((2#00111111))
+ i2cset -y -r ${i2c_bus} ${i2c_addr} ${REG_OUT_1} $((2#00011111))
+ i2cset -y -r ${i2c_bus} ${i2c_addr} ${REG_POLARITY_0} 0x00
+ i2cset -y -r ${i2c_bus} ${i2c_addr} ${REG_POLARITY_1} 0x00
+ i2cset -y -r ${i2c_bus} ${i2c_addr} ${REG_CFG_0} $((2#01000000))
+ i2cset -y -r ${i2c_bus} ${i2c_addr} ${REG_CFG_1} 0x00
+
echo "Init PCA9539 LED BOARD IO Expander"
#PCA9539 LED BOARD
#0.0 SYS_LED_G OUT 1
@@ -721,34 +753,6 @@ function _i2c_io_exp_init {
i2cset -y -r ${i2c_bus} ${i2c_addr} ${REG_CFG_0} $((2#11011011))
i2cset -y -r ${i2c_bus} ${i2c_addr} ${REG_CFG_1} $((2#11100011))
- #PCA9555 on BMC Dummy Board
- echo "Init PCA9555 MUX RST IO Expander"
- #PCA9555 MUX RST Expander
- #0.0 FRU_I2C_MUX_RST_L OUT 1
- #0.1 MAIN_I2C_MUX_RST_L OUT 1
- #0.2 SYSTEM_LED_RST_L OUT 1
- #0.3 BMC_TO_UCD_RST_L OUT 1
- #0.4 BMC_TO_HOST_RST_L OUT 1
- #0.5 ETHX_RST_L OUT 1
- #0.6 GPIOF4 IN
- #0.7 N/A
- #1.0 CPU_to_FRU_I2C_EN OUT 1
- #1.1 CPU_to_MAIN_I2C_EN OUT 1
- #1.2 P3V3_FAN_EN OUT 1
- #1.3 P3V3_I2C_EN OUT 1
- #1.4 UCD9090_CNTRL OUT 1
- #1.5 UART_MUX_SEL OUT 0
- #1.6 USB_MUX_SEL OUT 0
- #1.7 ETHX_CPU_EEPROM_SEL OUT 0
- i2c_bus=${I2C_BUS_MUX_RST}
- i2c_addr=${I2C_ADDR_MUX_RST}
- i2cset -y -r ${i2c_bus} ${i2c_addr} ${REG_OUT_0} $((2#00111111))
- i2cset -y -r ${i2c_bus} ${i2c_addr} ${REG_OUT_1} $((2#00011111))
- i2cset -y -r ${i2c_bus} ${i2c_addr} ${REG_POLARITY_0} 0x00
- i2cset -y -r ${i2c_bus} ${i2c_addr} ${REG_POLARITY_1} 0x00
- i2cset -y -r ${i2c_bus} ${i2c_addr} ${REG_CFG_0} $((2#01000000))
- i2cset -y -r ${i2c_bus} ${i2c_addr} ${REG_CFG_1} 0x00
-
#PCA9539 on CPU Board
echo "Init PCA9539 CPLD IO Expander on CPU"
i2c_bus=${I2C_BUS_MUX_CPU_CPLD}
@@ -1021,6 +1025,17 @@ function _i2c_led_test {
_i2c_fan_led
_pause 'Check [FAN LED] = Amber and Press [Enter] key to continue...'
+ #PSU1 led (green)
+ _i2c_reset_led
+ COLOR_LED="green"
+ _i2c_psu1_led
+ _pause 'Check [PSU1 LED] = Green and Press [Enter] key to continue...'
+ #PSU1 led (amber)
+ _i2c_reset_led
+ COLOR_LED="amber"
+ _i2c_psu1_led
+ _pause 'Check [PSU1 LED] = Amber and Press [Enter] key to continue...'
+
#PSU2 led (green)
_i2c_reset_led
COLOR_LED="green"
@@ -1032,17 +1047,6 @@ function _i2c_led_test {
_i2c_psu2_led
_pause 'Check [PSU2 LED] = Amber and Press [Enter] key to continue...'
- #PSU1 led (green)
- _i2c_reset_led
- COLOR_LED="green"
- _i2c_psu1_led
- _pause 'Check [PSU1 LED] = Green and Press [Enter] key to continue...'
- #PSU2 led (amber)
- _i2c_reset_led
- COLOR_LED="amber"
- _i2c_psu1_led
- _pause 'Check [PSU1 LED] = Amber and Press [Enter] key to continue...'
-
#Turn OFF All LED
_i2c_reset_led
_pause 'Check turn off all LEDs and Press [Enter] key to continue...'
@@ -1090,6 +1094,7 @@ function _qsfp_port_i2c_var_set {
;;
*)
echo "Please input 1~${PORT_NUM}"
+ exit
;;
esac
@@ -1930,13 +1935,17 @@ function _main {
exit ${FALSE}
fi
- end_time_str=`date`
- end_time_sec=$(date +%s)
- diff_time=$[ ${end_time_sec} - ${start_time_sec} ]
- echo "------------------------------"
- echo "Total Execution Time: ${diff_time} sec"
+ if [ "$DEBUG" == "on" ]; then
+ echo "-----------------------------------------------------"
+ end_time_str=`date`
+ end_time_sec=$(date +%s)
+ diff_time=$[ ${end_time_sec} - ${start_time_sec} ]
+ echo "Start Time: ${start_time_str} (${start_time_sec})"
+ echo "End Time : ${end_time_str} (${end_time_sec})"
+ echo "Total Execution Time: ${diff_time} sec"
- echo "DONE"
+ echo "done!!!"
+ fi
}
_main
diff --git a/platform/nephos/sonic-platform-modules-ingrasys b/platform/nephos/sonic-platform-modules-ingrasys
deleted file mode 160000
index 796169e43a..0000000000
--- a/platform/nephos/sonic-platform-modules-ingrasys
+++ /dev/null
@@ -1 +0,0 @@
-Subproject commit 796169e43aee944fdf7b549d04cb181117e0fb89
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/.gitignore b/platform/nephos/sonic-platform-modules-ingrasys/.gitignore
new file mode 100644
index 0000000000..c6127b38c1
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/.gitignore
@@ -0,0 +1,52 @@
+# Prerequisites
+*.d
+
+# Object files
+*.o
+*.ko
+*.obj
+*.elf
+
+# Linker output
+*.ilk
+*.map
+*.exp
+
+# Precompiled Headers
+*.gch
+*.pch
+
+# Libraries
+*.lib
+*.a
+*.la
+*.lo
+
+# Shared objects (inc. Windows DLLs)
+*.dll
+*.so
+*.so.*
+*.dylib
+
+# Executables
+*.exe
+*.out
+*.app
+*.i*86
+*.x86_64
+*.hex
+
+# Debug files
+*.dSYM/
+*.su
+*.idb
+*.pdb
+
+# Kernel Module Compile Results
+*.mod*
+*.cmd
+.tmp_versions/
+modules.order
+Module.symvers
+Mkfile.old
+dkms.conf
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/LICENSE b/platform/nephos/sonic-platform-modules-ingrasys/LICENSE
new file mode 100644
index 0000000000..9cecc1d466
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/LICENSE
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ {one line to give the program's name and a brief idea of what it does.}
+ Copyright (C) {year} {name of author}
+
+ 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 .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ {project} Copyright (C) {year} {fullname}
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+.
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/debian/changelog b/platform/nephos/sonic-platform-modules-ingrasys/debian/changelog
new file mode 100644
index 0000000000..a3e3f92cc7
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/debian/changelog
@@ -0,0 +1,11 @@
+platform-driver (1.0.0) unstable; urgency=low
+
+ * Add support for S9130-32X, S9230-64X series
+
+ -- developer Wed, 29 Mar 2017 11:00:00 +0800
+
+platform-driver (1.0.0) unstable; urgency=low
+
+ * Initial release (Closes: #nnnn)
+
+ -- developer Wed, 05 Oct 2016 16:30:45 +0800
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/debian/compat b/platform/nephos/sonic-platform-modules-ingrasys/debian/compat
new file mode 100644
index 0000000000..ec635144f6
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/debian/compat
@@ -0,0 +1 @@
+9
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/debian/control b/platform/nephos/sonic-platform-modules-ingrasys/debian/control
new file mode 100755
index 0000000000..3db0b5f350
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/debian/control
@@ -0,0 +1,15 @@
+Source: platform-driver
+Section: unknown
+Priority: optional
+Maintainer: Wade He
+Build-Depends: debhelper (>= 9), dh-systemd
+Standards-Version: 1.0.0
+
+Package: sonic-platform-ingrasys-s9130-32x
+Architecture: amd64
+Description: This package contains S9130-32X platform driver utility for SONiC project.
+
+Package: sonic-platform-ingrasys-s9230-64x
+Architecture: amd64
+Description: This package contains S9230-64X platform driver utility for SONiC project.
+
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/debian/rules b/platform/nephos/sonic-platform-modules-ingrasys/debian/rules
new file mode 100755
index 0000000000..f03e1de42c
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/debian/rules
@@ -0,0 +1,42 @@
+#!/usr/bin/make -f
+
+export INSTALL_MOD_DIR:=extra
+
+PACKAGE_PRE_NAME := sonic-platform-ingrasys
+KVERSION ?= $(shell uname -r)
+KERNEL_SRC := /lib/modules/$(KVERSION)
+MOD_SRC_DIR:= $(shell pwd)
+MODULE_DIRS:= s9130-32x s9230-64x
+MODULE_DIR := modules
+UTILS_DIR := utils
+SERVICE_DIR := service
+CONF_DIR := conf
+
+%:
+ dh $@ --with systemd
+
+override_dh_auto_build:
+ (for mod in $(MODULE_DIRS); do \
+ make modules -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules; \
+ done)
+
+override_dh_auto_install:
+ (for mod in $(MODULE_DIRS); do \
+ dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} \
+ $(KERNEL_SRC)/$(INSTALL_MOD_DIR); \
+ cp $(MOD_SRC_DIR)/$${mod}/$(MODULE_DIR)/*.ko \
+ debian/$(PACKAGE_PRE_NAME)-$${mod}/$(KERNEL_SRC)/$(INSTALL_MOD_DIR); \
+ dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} usr/sbin; \
+ cp $(MOD_SRC_DIR)/$${mod}/$(UTILS_DIR)/*.sh \
+ debian/$(PACKAGE_PRE_NAME)-$${mod}/usr/sbin; \
+ dh_installdirs -p$(PACKAGE_PRE_NAME)-$${mod} lib/systemd/system; \
+ cp $(MOD_SRC_DIR)/$${mod}/$(SERVICE_DIR)/*.service \
+ debian/$(PACKAGE_PRE_NAME)-$${mod}/lib/systemd/system; \
+ done)
+
+override_dh_clean:
+ dh_clean
+ (for mod in $(MODULE_DIRS); do \
+ make -C $(KERNEL_SRC)/build M=$(MOD_SRC_DIR)/$${mod}/modules clean; \
+ done)
+
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9130-32x.init b/platform/nephos/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9130-32x.init
new file mode 100644
index 0000000000..a925faf45f
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9130-32x.init
@@ -0,0 +1,41 @@
+#!/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 S9130-32X board.
+### END INIT INFO
+
+case "$1" in
+start)
+ echo -n "Setting up board... "
+
+ depmod -a
+
+ echo "done."
+ ;;
+
+stop)
+
+ i2c_utils.sh i2c_deinit
+
+ echo "done."
+
+ ;;
+
+force-reload|restart)
+ echo "Not supported"
+ ;;
+
+*)
+ echo "Usage: /etc/init.d/sonic-platform-ingrasys-s9130-32x.init {start|stop}"
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9230-64x.init b/platform/nephos/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9230-64x.init
new file mode 100644
index 0000000000..4389aee5f7
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/debian/sonic-platform-ingrasys-s9230-64x.init
@@ -0,0 +1,41 @@
+#!/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 S9230-64X board.
+### END INIT INFO
+
+case "$1" in
+start)
+ echo -n "Setting up board... "
+
+ depmod -a
+
+ echo "done."
+ ;;
+
+stop)
+
+ i2c_utils i2c_deinit
+
+ echo "done."
+
+ ;;
+
+force-reload|restart)
+ echo "Not supported"
+ ;;
+
+*)
+ echo "Usage: /etc/init.d/sonic-platform-ingrasys-s9230-64x.init {start|stop}"
+ exit 1
+ ;;
+esac
+
+exit 0
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/README.md b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/README.md
new file mode 100644
index 0000000000..1b3b14db34
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/README.md
@@ -0,0 +1,167 @@
+# Ingrasys S9130-32X Platform Driver for SONiC
+
+Copyright (C) 2016 Ingrasys, 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 .
+
+
+## Licensing terms
+
+The Licensing terms of the files within this project is split 2 parts.
+The Linux kernel is released under the GNU General Public License version 2.
+All other code is released under the GNU General Public License version 3.
+Please see the LICENSE file for copies of both licenses.
+
+## Contents of this package
+
+ - service/
+ > Service config files for platform initialization and monitoring
+ - utils/
+ > Scripts useful during platform bringup and sysfs function
+ - conf/
+ > Platform configure files.
+
+## Kernel modules and drivers
+
+The driver for interacting with Ingrasys S9130-32X is contained in the I2C
+kernel module and initialization script. The initialization script loads
+the modules in the correct order. It has been built and tested against
+the Linux 3.16 kernel.
+
+The initialization script will modprobe the needed modules, navigate to the
+module's device directory in sysfs, and write configuration data to
+the kernel module.
+
+### IGB
+
+This is OOB Ports on front panel for management plane.
+
+The IGB module must be loaded first on Ingrasys S9130-32X platform.
+
+### I2C i801
+
+The I2C i801 on Ingrasys S9130-32X can be found in
+`/sys/bus/i2c/devices/i2c-0/`
+
+This is I2C bus for power monitor, FAN controller, HWM and thermal sensors.
+
+### I2C PCA9548
+The PCA9548 module on S9130-32X can be found in
+`/sys/bus/i2c/devices/i2c-1/` , `/sys/bus/i2c/devices/i2c-2/`,
+`/sys/bus/i2c/devices/i2c-3/`, `/sys/bus/i2c/devices/i2c-4/`,
+`/sys/bus/i2c/devices/i2c-5/`, `/sys/bus/i2c/devices/i2c-6/`,
+`/sys/bus/i2c/devices/i2c-7/`, `/sys/bus/i2c/devices/i2c-8/`
+
+The pca9548 module for zQSFP module get/set functions, PSU information,
+fan status and EEPROM.
+
+## Hardware components
+
+The hardware components are initialized in the init script on S9130-32X.
+The following describes manual initialization as well as interaction.
+The examples below are just for Ingrasys S9130-32X platform.
+
+### Hardware initialization
+
+When the sonic-platform-ingrasys-s9130-32x package is installed on the S9130-32X,
+it is automatically initialized. If you want to manual initialization, the
+utility command usage as follows:
+```
+ i2c_utils.sh i2c_init
+```
+
+### EEPROM
+
+The EEPROM is including the board SKU, model name, vendor name, serial number,
+and other information can be accessed with the specific eeprom kernel module.
+After using `modprobe eeprom_mb` to detect the eeprom, it will show up in sysfs.
+
+The hexdump utility can be used to decode the raw output of the EEPROM.
+For example,
+```
+ bash# echo "mb_eeprom 0x51" > /sys/bus/i2c/devices/i2c-0/new_device
+ bash# cat /sys/bus/i2c/drivers/mb_eeprom/0-0051/eeprom | hexdump -C
+```
+
+### Front panel LEDs
+
+LEDs can be setup on/off by using i2c utility `/usr/sbin/i2c_utils.sh`.
+Utility function command usage as follows:
+
+```
+Status LED:
+ i2c_utils.sh i2c_sys_led green|amber
+
+Fan status LED:
+ i2c_utils.sh i2c_fan_led green|amber on|off
+
+PSU1 status LED:
+ i2c_utils.sh i2c_psu1_led green|amber on|off
+
+PSU2 status LED:
+ i2c_utils.sh i2c_psu2_led green|amber on|off
+
+```
+QSFP Module Port LEDs control by ASIC library.
+
+
+### Fan speed
+
+Fan speed are controlled by the w83795 kernel module.
+It can be found in `/sys/class/hwmon/hwmon5/device/`.
+If they were compiled as modules, you will need to modprobe w83795 for
+their sysfs entries to show up. Each fan has an `fan_input` file
+for reading the fan speed. And `pwm1` setting fan1 to fan4,
+`pwm2` setting fan5 to fan8.
+
+There is docker-platform-monitor container installed fancontrol package that can
+automatic control platform fan speed.
+
+
+### Temperature sensors
+
+There is docker-platform-monitor container installed lm-sensors package that can
+monitor platform temperature. And `sensors` command can show each
+temperature sensors status.
+
+### Power supplies
+
+Power supplies status and its EEPROM info can be used i2c utility
+`/usr/sbin/i2c_utils.sh` to get.
+The usage as follows:
+```
+PSU EEPROM:
+ i2c_utils.sh i2c_psu_eeprom_get
+ hexdump -C psu0.rom
+ hexdump -C psu1.rom
+
+PSU Status:
+ i2c_utils.sh i2c_psu_status
+```
+
+### QSFPs
+QSFP modules are managed by the pca9548 kernel driver.
+The i2c utility `/usr/sbin/i2c_utils.sh` can be used to get status and
+module EEPROM informations.
+The usage as follows:
+```
+QSFP EEPROM:
+ i2c_utils.sh i2c_qsfp_eeprom_get [1-32]
+
+QSFP Insert Event:
+ i2c_utils.sh i2c_qsfp_eeprom_get [1-32]
+ 0 => not insert
+ 1 => inserted
+```
+
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/modules/Makefile b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/modules/Makefile
new file mode 100755
index 0000000000..688bb46664
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/modules/Makefile
@@ -0,0 +1,2 @@
+obj-m := eeprom_mb.o
+obj-m += ingrasys_s9130_32x_psu.o
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/modules/eeprom_mb.c b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/modules/eeprom_mb.c
new file mode 100755
index 0000000000..528864d933
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/modules/eeprom_mb.c
@@ -0,0 +1,267 @@
+/*
+ * Copyright (C) 1998, 1999 Frodo Looijaard and
+ * Philip Edelbrock
+ * Copyright (C) 2003 Greg Kroah-Hartman
+ * Copyright (C) 2003 IBM Corp.
+ * Copyright (C) 2004 Jean Delvare
+ *
+ * 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.
+ */
+
+/* enable dev_dbg print out */
+//#define DEBUG
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+/* Addresses to scan */
+static const unsigned short normal_i2c[] = { /*0x50, 0x51, 0x52, 0x53, 0x54,
+ 0x55, 0x56, 0x57,*/ I2C_CLIENT_END };
+
+/* Size of EEPROM in bytes */
+#define EEPROM_SIZE 512
+
+#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 mb_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 mb_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++) {
+ mb_eeprom_update_client(client, slice);
+ }
+
+ memcpy(buf, &data->data[off], count);
+
+ return count;
+}
+
+static ssize_t mb_eeprom_write(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);
+ int ret;
+ int i;
+ u8 cmd;
+ u16 value16;
+
+ dev_dbg(&client->dev, "mb_eeprom_write off=%d, count=%d\n", (int)off, (int)count);
+
+ if (off > EEPROM_SIZE) {
+ return 0;
+ }
+ if (off + count > EEPROM_SIZE) {
+ count = EEPROM_SIZE - off;
+ }
+ if (count == 0) {
+ return 0;
+ }
+
+ mutex_lock(&data->update_lock);
+
+ for(i=0; i < count; i++) {
+ /* write command */
+ cmd = (off >> 8) & 0xff;
+ value16 = off & 0xff;
+ value16 |= buf[i] << 8;
+ ret = i2c_smbus_write_word_data(client, cmd, value16);
+
+ if (ret < 0) {
+ dev_err(&client->dev, "write address failed at %d \n", (int)off);
+ goto exit;
+ }
+
+ off++;
+
+ /* need to wait for write complete */
+ udelay(10000);
+ }
+exit:
+ mutex_unlock(&data->update_lock);
+ /* force to update client when reading */
+ for(i=0; i < SLICE_NUM; i++) {
+ data->last_updated[i] = 0;
+ }
+
+ return count;
+}
+
+static struct bin_attribute mb_eeprom_attr = {
+ .attr = {
+ .name = "eeprom",
+ .mode = S_IRUGO | S_IWUSR,
+ },
+ .size = EEPROM_SIZE,
+ .read = mb_eeprom_read,
+ .write = mb_eeprom_write,
+};
+
+/* Return 0 if detection is successful, -ENODEV otherwise */
+static int mb_eeprom_detect(struct i2c_client *client, struct i2c_board_info *info)
+{
+ struct i2c_adapter *adapter = client->adapter;
+
+ /* EDID EEPROMs are often 24C00 EEPROMs, which answer to all
+ addresses 0x50-0x57, but we only care about 0x51 and 0x55. So decline
+ attaching to addresses >= 0x56 on DDC buses */
+ if (!(adapter->class & I2C_CLASS_SPD) && client->addr >= 0x56) {
+ return -ENODEV;
+ }
+
+ if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE)
+ && !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) {
+ return -ENODEV;
+ }
+
+ strlcpy(info->type, "eeprom", I2C_NAME_SIZE);
+
+ return 0;
+}
+
+static int mb_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, &mb_eeprom_attr);
+ if (err) {
+ goto exit_kfree;
+ }
+
+ return 0;
+
+exit_kfree:
+ kfree(data);
+exit:
+ return err;
+}
+
+static int mb_eeprom_remove(struct i2c_client *client)
+{
+ sysfs_remove_bin_file(&client->dev.kobj, &mb_eeprom_attr);
+ kfree(i2c_get_clientdata(client));
+
+ return 0;
+}
+
+static const struct i2c_device_id mb_eeprom_id[] = {
+ { "mb_eeprom", 0 },
+ { }
+};
+
+static struct i2c_driver mb_eeprom_driver = {
+ .driver = {
+ .name = "mb_eeprom",
+ },
+ .probe = mb_eeprom_probe,
+ .remove = mb_eeprom_remove,
+ .id_table = mb_eeprom_id,
+
+ .class = I2C_CLASS_DDC | I2C_CLASS_SPD,
+ .detect = mb_eeprom_detect,
+ .address_list = normal_i2c,
+};
+
+module_i2c_driver(mb_eeprom_driver);
+
+MODULE_AUTHOR("Wade ");
+MODULE_DESCRIPTION("Ingrasys Mother Borad EEPROM driver");
+MODULE_LICENSE("GPL");
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/modules/ingrasys_s9130_32x_platform.h b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/modules/ingrasys_s9130_32x_platform.h
new file mode 100644
index 0000000000..23dcf17a85
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/modules/ingrasys_s9130_32x_platform.h
@@ -0,0 +1,148 @@
+#ifndef _S9130_32X_PLATFORM_H
+#define _S9130_32X_PLATFORM_H
+
+#include
+
+// remove debug before release
+#define DEBUG
+
+enum bus_order {
+ I2C_BUS_MAIN,
+ MUX_9548_0_CH0,
+ MUX_9548_0_CH1,
+ MUX_9548_0_CH2,
+ MUX_9548_0_CH3,
+ MUX_9548_0_CH4,
+ MUX_9548_0_CH5,
+ MUX_9548_0_CH6,
+ MUX_9548_0_CH7,
+ MUX_9548_1_CH0,
+ MUX_9548_1_CH1,
+ MUX_9548_1_CH2,
+ MUX_9548_1_CH3,
+ MUX_9548_1_CH4,
+ MUX_9548_1_CH5,
+ MUX_9548_1_CH6,
+ MUX_9548_1_CH7,
+ MUX_9546_0_CH0,
+ MUX_9546_0_CH1,
+ MUX_9546_0_CH2,
+ MUX_9546_0_CH3,
+ MUX_9546_1_CH0,
+ MUX_9546_1_CH1,
+ MUX_9546_1_CH2,
+ MUX_9546_1_CH3,
+ MUX_9548_2_CH0,
+ MUX_9548_2_CH1,
+ MUX_9548_2_CH2,
+ MUX_9548_2_CH3,
+ MUX_9548_2_CH4,
+ MUX_9548_2_CH5,
+ MUX_9548_2_CH6,
+ MUX_9548_2_CH7,
+ MUX_9548_3_CH0,
+ MUX_9548_3_CH1,
+ MUX_9548_3_CH2,
+ MUX_9548_3_CH3,
+ MUX_9548_3_CH4,
+ MUX_9548_3_CH5,
+ MUX_9548_3_CH6,
+ MUX_9548_3_CH7,
+ MUX_9548_4_CH0,
+ MUX_9548_4_CH1,
+ MUX_9548_4_CH2,
+ MUX_9548_4_CH3,
+ MUX_9548_4_CH4,
+ MUX_9548_4_CH5,
+ MUX_9548_4_CH6,
+ MUX_9548_4_CH7,
+ MUX_9548_5_CH0,
+ MUX_9548_5_CH1,
+ MUX_9548_5_CH2,
+ MUX_9548_5_CH3,
+ MUX_9548_5_CH4,
+ MUX_9548_5_CH5,
+ MUX_9548_5_CH6,
+ MUX_9548_5_CH7,
+ MUX_9548_6_CH0,
+ MUX_9548_6_CH1,
+ MUX_9548_6_CH2,
+ MUX_9548_6_CH3,
+ MUX_9548_6_CH4,
+ MUX_9548_6_CH5,
+ MUX_9548_6_CH6,
+ MUX_9548_6_CH7,
+ MUX_9548_7_CH0,
+ MUX_9548_7_CH1,
+ MUX_9548_7_CH2,
+ MUX_9548_7_CH3,
+ MUX_9548_7_CH4,
+ MUX_9548_7_CH5,
+ MUX_9548_7_CH6,
+ MUX_9548_7_CH7,
+ MUX_9548_8_CH0,
+ MUX_9548_8_CH1,
+ MUX_9548_8_CH2,
+ MUX_9548_8_CH3,
+ MUX_9548_8_CH4,
+ MUX_9548_8_CH5,
+ MUX_9548_8_CH6,
+ MUX_9548_8_CH7,
+ MUX_9548_9_CH0,
+ MUX_9548_9_CH1,
+ MUX_9548_9_CH2,
+ MUX_9548_9_CH3,
+ MUX_9548_9_CH4,
+ MUX_9548_9_CH5,
+ MUX_9548_9_CH6,
+ MUX_9548_9_CH7,
+ MUX_9548_10_CH0,
+ MUX_9548_10_CH1,
+ MUX_9548_10_CH2,
+ MUX_9548_10_CH3,
+ MUX_9548_10_CH4,
+ MUX_9548_10_CH5,
+ MUX_9548_10_CH6,
+ MUX_9548_10_CH7,
+};
+
+#define I2C_ADDR_MUX_9555_0 (0x20)
+#define I2C_ADDR_MUX_9555_1 (0x24)
+#define I2C_ADDR_MUX_9555_2 (0x25)
+#define I2C_ADDR_MUX_9555_3 (0x26)
+#define I2C_ADDR_MUX_9539_0 (0x76)
+#define I2C_ADDR_MUX_9539_1 (0x76)
+#define I2C_BUS_FAN_STATUS (I2C_BUS_MAIN)
+#define I2C_BUS_SYS_LED (MUX_9548_1_CH1)
+
+#define NUM_OF_I2C_MUX (11)
+#define NUM_OF_CPLD (5)
+#define NUM_OF_QSFP_PORT (64)
+#define NUM_OF_SFP_PORT (2)
+#define QSFP_EEPROM_I2C_ADDR (0x50)
+
+enum gpio_reg {
+ REG_PORT0_IN,
+ REG_PORT1_IN,
+ REG_PORT0_OUT,
+ REG_PORT1_OUT,
+ REG_PORT0_POL,
+ REG_PORT1_POL,
+ REG_PORT0_DIR,
+ REG_PORT1_DIR,
+};
+
+struct ing_i2c_board_info {
+ int ch;
+ int size;
+ struct i2c_board_info *board_info;
+};
+
+struct i2c_init_data {
+ __u16 ch;
+ __u16 addr;
+ __u8 reg;
+ __u8 value;
+};
+
+#endif
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/modules/ingrasys_s9130_32x_psu.c b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/modules/ingrasys_s9130_32x_psu.c
new file mode 100644
index 0000000000..edf92b6724
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/modules/ingrasys_s9130_32x_psu.c
@@ -0,0 +1,388 @@
+/*
+ * S9130-32x PSU driver
+ *
+ * Copyright (C) 2017 Ingrasys, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "ingrasys_s9130_32x_platform.h"
+
+static ssize_t show_psu_eeprom(struct device *dev,
+ struct device_attribute *da,
+ char *buf);
+static struct s9130_psu_data *s9130_psu_update_status(struct device *dev);
+static struct s9130_psu_data *s9130_psu_update_eeprom(struct device *dev);
+static int s9130_psu_read_block(struct i2c_client *client,
+ u8 command,
+ u8 *data,
+ int data_len);
+
+
+#define DRIVER_NAME "psu"
+
+// Addresses scanned
+static const unsigned short normal_i2c[] = { 0x50, I2C_CLIENT_END };
+
+/* PSU EEPROM SIZE */
+#define EEPROM_SZ 256
+#define READ_EEPROM 1
+#define NREAD_EEPROM 0
+
+static struct i2c_client pca9555_client;
+
+/* pca9555 gpio pin mapping */
+#define PSU2_PWROK 0
+#define PSU2_PRSNT_L 1
+#define PSU2_PWRON_L 2
+#define PSU1_PWROK 3
+#define PSU1_PRSNT_L 4
+#define PSU1_PWRON_L 5
+#define TMP_75_INT_L 6
+
+/* Driver Private Data */
+struct s9130_psu_data {
+ struct mutex lock;
+ char valid; /* !=0 if registers are valid */
+ unsigned long last_updated; /* In jiffies */
+ u8 index; /* PSU index */
+ s32 status; /* IO expander value */
+ char eeprom[EEPROM_SZ]; /* psu eeprom data */
+ char psuABS; /* PSU absent */
+ char psuPG; /* PSU power good */
+};
+
+enum psu_index
+{
+ s9130_psu1,
+ s9130_psu2
+};
+
+/*
+ * display power good attribute
+ */
+static ssize_t
+show_psu_pg(struct device *dev,
+ struct device_attribute *devattr,
+ char *buf)
+{
+ struct s9130_psu_data *data = s9130_psu_update_status(dev);
+ unsigned int value;
+
+ mutex_lock(&data->lock);
+ value = data->psuPG;
+ mutex_unlock(&data->lock);
+
+ return sprintf(buf, "%d\n", value);
+}
+
+/*
+ * display power absent attribute
+ */
+static ssize_t
+show_psu_abs(struct device *dev,
+ struct device_attribute *devattr,
+ char *buf)
+{
+ struct s9130_psu_data *data = s9130_psu_update_status(dev);
+ unsigned int value;
+
+ mutex_lock(&data->lock);
+ value = data->psuABS;
+ mutex_unlock(&data->lock);
+
+ return sprintf(buf, "%d\n", value);
+}
+
+
+/*
+ * sysfs attributes for psu
+ */
+static DEVICE_ATTR(psu_pg, S_IRUGO, show_psu_pg, NULL);
+static DEVICE_ATTR(psu_abs, S_IRUGO, show_psu_abs, NULL);
+static DEVICE_ATTR(psu_eeprom, S_IRUGO, show_psu_eeprom, NULL);
+
+static struct attribute *s9130_psu_attributes[] = {
+ &dev_attr_psu_pg.attr,
+ &dev_attr_psu_abs.attr,
+ &dev_attr_psu_eeprom.attr,
+ NULL
+};
+
+/*
+ * display psu eeprom content
+ */
+static ssize_t
+show_psu_eeprom(struct device *dev,
+ struct device_attribute *da,
+ char *buf)
+{
+ struct s9130_psu_data *data = s9130_psu_update_eeprom(dev);
+
+ memcpy(buf, (char *)data->eeprom, EEPROM_SZ);
+ return EEPROM_SZ;
+}
+
+static const struct attribute_group s9130_psu_group = {
+ .attrs = s9130_psu_attributes,
+};
+
+/*
+ * check gpio expander is accessible
+ */
+static int
+pca9555_detect(struct i2c_client *client)
+{
+ if (i2c_smbus_read_byte_data(client, REG_PORT0_DIR) < 0) {
+ return -ENODEV;
+ }
+
+ return 0;
+}
+
+/*
+ * client address init
+ */
+static void
+i2c_devices_client_address_init(struct i2c_client *client)
+{
+ pca9555_client = *client;
+ pca9555_client.addr = 0x25;
+}
+
+static int
+s9130_psu_probe(struct i2c_client *client,
+ const struct i2c_device_id *dev_id)
+{
+ struct s9130_psu_data *data;
+ int status, err;
+
+ if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) {
+ status = -EIO;
+ goto exit;
+ }
+
+ data = kzalloc(sizeof(struct s9130_psu_data), GFP_KERNEL);
+ if (!data) {
+ status = -ENOMEM;
+ goto exit;
+ }
+ memset(data, 0, sizeof(struct s9130_psu_data));
+ i2c_set_clientdata(client, data);
+ data->valid = 0;
+ data->index = dev_id->driver_data;
+ mutex_init(&data->lock);
+
+ i2c_devices_client_address_init(client);
+
+ err = pca9555_detect(&pca9555_client);
+ if (err) {
+ return err;
+ }
+
+ dev_info(&client->dev, "chip found\n");
+
+ /* Register sysfs hooks */
+ status = sysfs_create_group(&client->dev.kobj, &s9130_psu_group);
+ if (status) {
+ goto exit_free;
+ }
+
+ return 0;
+
+exit_remove:
+ sysfs_remove_group(&client->dev.kobj, &s9130_psu_group);
+exit_free:
+ kfree(data);
+exit:
+
+ return status;
+}
+
+static int
+s9130_psu_remove(struct i2c_client *client)
+{
+ struct s9130_psu_data *data = i2c_get_clientdata(client);
+
+ sysfs_remove_group(&client->dev.kobj, &s9130_psu_group);
+ kfree(data);
+
+ return 0;
+}
+
+
+/*
+ * psu eeprom read utility
+ */
+static int
+s9130_psu_read_block(struct i2c_client *client,
+ u8 command,
+ u8 *data,
+ int data_len)
+{
+ int i=0, ret=0;
+ int blk_max = 32; //max block read size
+
+ /* read eeprom, 32 * 8 = 256 bytes */
+ for (i=0; i < EEPROM_SZ/blk_max; i++) {
+ ret = i2c_smbus_read_i2c_block_data(client, (i*blk_max), blk_max,
+ data + (i*blk_max));
+ if (ret < 0) {
+ return ret;
+ }
+ }
+ return ret;
+}
+
+/*
+ * update eeprom content
+ */
+static struct s9130_psu_data
+*s9130_psu_update_eeprom(struct device *dev)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct s9130_psu_data *data = i2c_get_clientdata(client);
+ s32 status = 0;
+ int psu_pwrok = 0;
+ int psu_prsnt_l = 0;
+
+ mutex_lock(&data->lock);
+
+ if (time_after(jiffies, data->last_updated + 300 * HZ)
+ || !data->valid) {
+
+ /* Read psu status */
+
+ status = i2c_smbus_read_word_data(&(pca9555_client), REG_PORT0_IN);
+ data->status = status;
+
+ /*read psu status from io expander*/
+
+ if (data->index == s9130_psu1) {
+ psu_pwrok = PSU1_PWROK;
+ psu_prsnt_l = PSU1_PRSNT_L;
+ } else {
+ psu_pwrok = PSU2_PWROK;
+ psu_prsnt_l = PSU2_PRSNT_L;
+ }
+ data->psuPG = (status >> psu_pwrok) & 0x1;
+ data->psuABS = (status >> psu_prsnt_l) & 0x1;
+
+ /* Read eeprom */
+ if (!data->psuABS) {
+ //clear local eeprom data
+ memset(data->eeprom, 0, EEPROM_SZ);
+
+ //read eeprom
+ status = s9130_psu_read_block(client, 0, data->eeprom,
+ ARRAY_SIZE(data->eeprom));
+
+ if (status < 0) {
+ memset(data->eeprom, 0, EEPROM_SZ);
+ dev_err(&client->dev, "Read eeprom failed, status=(%d)\n", status);
+ } else {
+ data->valid = 1;
+ }
+ } else {
+ memset(data->eeprom, 0, EEPROM_SZ);
+ }
+ data->last_updated = jiffies;
+ }
+
+ mutex_unlock(&data->lock);
+
+ return data;
+}
+
+/*
+ * update psu status
+ */
+static struct s9130_psu_data
+*s9130_psu_update_status(struct device *dev)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct s9130_psu_data *data = i2c_get_clientdata(client);
+ s32 status = 0;
+ int psu_pwrok = 0;
+ int psu_prsnt_l = 0;
+
+ mutex_lock(&data->lock);
+
+ /* Read psu status */
+
+ status = i2c_smbus_read_word_data(&(pca9555_client), REG_PORT0_IN);
+ data->status = status;
+
+ /*read psu status from io expander*/
+
+ if (data->index == s9130_psu1) {
+ psu_pwrok = PSU1_PWROK;
+ psu_prsnt_l = PSU1_PRSNT_L;
+ } else {
+ psu_pwrok = PSU2_PWROK;
+ psu_prsnt_l = PSU2_PRSNT_L;
+ }
+ data->psuPG = (status >> psu_pwrok) & 0x1;
+ data->psuABS = (status >> psu_prsnt_l) & 0x1;
+
+ mutex_unlock(&data->lock);
+
+ return data;
+}
+
+static const struct i2c_device_id s9130_psu_id[] = {
+ { "psu1", s9130_psu1 },
+ { "psu2", s9130_psu2 },
+ {}
+};
+
+MODULE_DEVICE_TABLE(i2c, s9130_psu_id);
+
+static struct i2c_driver s9130_psu_driver = {
+ .driver = {
+ .name = DRIVER_NAME,
+ },
+ .probe = s9130_psu_probe,
+ .remove = s9130_psu_remove,
+ .id_table = s9130_psu_id,
+ .address_list = normal_i2c,
+};
+
+static int __init s9130_psu_init(void)
+{
+ return i2c_add_driver(&s9130_psu_driver);
+}
+
+static void __exit s9130_psu_exit(void)
+{
+ i2c_del_driver(&s9130_psu_driver);
+}
+
+module_init(s9130_psu_init);
+module_exit(s9130_psu_exit);
+
+MODULE_AUTHOR("Jason Tsai ");
+MODULE_DESCRIPTION("S9130-32X psu driver");
+MODULE_LICENSE("GPL");
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/service/qsfp-monitor.service b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/service/qsfp-monitor.service
new file mode 100644
index 0000000000..10b48f648b
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/service/qsfp-monitor.service
@@ -0,0 +1,15 @@
+[Unit]
+Description= This QSFP Monitor service is to setup QSFP SI.
+Requires=s9130-32x-monitor.service
+After=s9130-32x-monitor.service
+
+[Service]
+ExecStart=/usr/sbin/qsfp_monitor.sh
+KillSignal=SIGKILL
+SuccessExitStatus=SIGKILL
+
+# Resource Limitations
+LimitCORE=infinity
+
+[Install]
+WantedBy=multi-user.target
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/service/s9130-32x-monitor.service b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/service/s9130-32x-monitor.service
new file mode 100644
index 0000000000..3163b0af6f
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/service/s9130-32x-monitor.service
@@ -0,0 +1,19 @@
+[Unit]
+Description= This Platform Monitor service is to initialize platform and monitor platform.
+Before=platform-monitor.service
+After=sysinit.target
+Wants=fancontrol.service
+Wants=qsfp-monitor.service
+DefaultDependencies=no
+
+[Service]
+ExecStartPre=/usr/sbin/i2c_utils.sh i2c_init
+ExecStart=/usr/sbin/s9130_32x_monitor.sh
+KillSignal=SIGKILL
+SuccessExitStatus=SIGKILL
+
+# Resource Limitations
+LimitCORE=infinity
+
+[Install]
+WantedBy=multi-user.target
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/utils/i2c_utils.sh b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/utils/i2c_utils.sh
new file mode 100755
index 0000000000..ea238e0172
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/utils/i2c_utils.sh
@@ -0,0 +1,1720 @@
+#!/bin/bash
+
+# Copyright (C) 2016 Ingrasys, 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 .
+
+# trun on for more debug output
+#DEBUG="on"
+
+VERSION="1.1.0"
+TRUE=200
+FALSE=404
+
+EXEC_FUNC=${1}
+COLOR_LED=${2}
+QSFP_PORT=${2}
+QSFP_ACTION=${2}
+MB_EEPROM_ACTION=${2}
+ONOFF_LED=${3}
+FAN_TRAY=${4}
+
+############################################################
+# Distributor ID: Debian
+# Description: Debian GNU/Linux 8.6 (jessie)
+# Release: 8.6
+# Codename: jessie
+# Linux debian 3.16.0-4-amd64 #1
+# SMP Debian 3.16.36-1+deb8u1 (2016-09-03) x86_64 GNU/Linux
+############################################################
+
+# Color Definition
+COLOR_TITLE="\e[1;32m" ### Green ###
+COLOR_WARNING="\e[1;33m" ### Yellow ###
+COLOR_ERROR="\e[1;31m" ### Red ###
+COLOR_END="\e[0m" ### END ###
+
+NUM_I801_DEVICE=0
+
+# MAIN MUX PCA9548#0 0x73
+NUM_MUX_9548_0_CH0=$(( ${NUM_I801_DEVICE} + 1 )) # ucd9090 0x34
+NUM_MUX_9548_0_CH1=$(( ${NUM_I801_DEVICE} + 2 )) # PCA9539 0x76 for fp LED & HW ID
+NUM_MUX_9548_0_CH7=$(( ${NUM_I801_DEVICE} + 8 )) # W83795 0x2F
+
+# FRU MUX PCA9545#1 0x72
+NUM_MUX_9545_1_CH0=$(( ${NUM_I801_DEVICE} + 9 )) # PSU2 0x50
+NUM_MUX_9545_1_CH1=$(( ${NUM_I801_DEVICE} + 10 )) # PSU1 0x50
+NUM_MUX_9545_1_CH2=$(( ${NUM_I801_DEVICE} + 11 )) # FAN board IO exander 0x20
+NUM_MUX_9545_1_CH3=$(( ${NUM_I801_DEVICE} + 12 )) # TMP75#0 0x4C TMP75#1 0x49
+
+# HOST MUX PCA9548#2 0X70
+NUM_MUX_9548_2_CH0=$(( ${NUM_I801_DEVICE} + 13 )) # PCA9548#3 0x71
+NUM_MUX_9548_2_CH1=$(( ${NUM_I801_DEVICE} + 14 )) # PCA9548#4 0x71
+NUM_MUX_9548_2_CH2=$(( ${NUM_I801_DEVICE} + 15 )) # PCA9548#5 0x71
+NUM_MUX_9548_2_CH3=$(( ${NUM_I801_DEVICE} + 16 )) # PCA9548#6 0x71
+NUM_MUX_9548_2_CH4=$(( ${NUM_I801_DEVICE} + 17 )) # PCA9535#3~6 0x20~0x23 ZQSFP ABS/INT
+NUM_MUX_9548_2_CH5=$(( ${NUM_I801_DEVICE} + 18 )) # PCA9535#7~10 0x20~0x23 ZQSFP LPMODE/RST
+NUM_MUX_9548_3_CH0=$(( ${NUM_I801_DEVICE} + 21 )) # QSFP 0 EEPROM
+NUM_MUX_9548_4_CH0=$(( ${NUM_I801_DEVICE} + 29 )) # QSFP 8 EEPROM
+NUM_MUX_9548_5_CH0=$(( ${NUM_I801_DEVICE} + 37 )) # QSFP 16 EEPROM
+NUM_MUX_9548_6_CH0=$(( ${NUM_I801_DEVICE} + 45 )) # QSFP 24 EEPROM
+
+# MUX Alias
+I2C_BUS_MAIN=${NUM_I801_DEVICE}
+I2C_BUS_HWM=${NUM_MUX_9548_0_CH7}
+I2C_BUS_FAN_STATUS=${NUM_MUX_9545_1_CH2}
+I2C_BUS_SYS_LED=${NUM_MUX_9548_0_CH1}
+I2C_BUS_HW_ID=${NUM_MUX_9548_0_CH1}
+I2C_BUS_BMC_HW_ID=${I2C_BUS_MAIN}
+I2C_BUS_PSU_STAT=${I2C_BUS_MAIN}
+I2C_BUS_FANTRAY_LED=${NUM_MUX_9545_1_CH2}
+I2C_BUS_MB_EEPROM=${I2C_BUS_MAIN}
+I2C_BUS_CB_EEPROM=${I2C_BUS_MAIN}
+I2C_BUS_PSU1_EEPROM=${NUM_MUX_9545_1_CH1}
+I2C_BUS_PSU2_EEPROM=${NUM_MUX_9545_1_CH0}
+
+PATH_SYS_I2C_DEVICES="/sys/bus/i2c/devices"
+PATH_SYS_GPIO="/sys/class/gpio"
+PATH_HWMON_ROOT_DEVICES="/sys/class/hwmon"
+PATH_HWMON_W83795_DEVICE="${PATH_HWMON_ROOT_DEVICES}/hwmon5"
+PATH_I801_DEVICE="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_I801_DEVICE}"
+PATH_MUX_9548_0_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_0_CH0}"
+PATH_MUX_9548_0_CH1="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_0_CH1}"
+PATH_MUX_9548_0_CH7="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_0_CH7}"
+PATH_MUX_9545_1_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9545_1_CH0}"
+PATH_MUX_9545_1_CH1="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9545_1_CH1}"
+PATH_MUX_9545_1_CH2="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9545_1_CH2}"
+PATH_MUX_9545_1_CH3="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9545_1_CH3}"
+PATH_MUX_9548_2_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH0}"
+PATH_MUX_9548_2_CH1="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH1}"
+PATH_MUX_9548_2_CH2="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH2}"
+PATH_MUX_9548_2_CH3="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH3}"
+PATH_MUX_9548_2_CH4="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH4}"
+PATH_MUX_9548_2_CH5="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH5}"
+PATH_MUX_9548_3_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_3_CH0}"
+PATH_MUX_9548_4_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_4_CH0}"
+PATH_MUX_9548_5_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_5_CH0}"
+PATH_MUX_9548_6_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_6_CH0}"
+
+# I2C Address
+### I2C MUX
+I2C_ADDR_MUX_9548_0=0x73 # MAIN MUX
+I2C_ADDR_MUX_9545_1=0x72 # FRU MUX
+I2C_ADDR_MUX_9548_2=0x70 # HOST MUX
+I2C_ADDR_MUX_9548_3=0x71 # ZQSFP MUX #1 EEPROM
+I2C_ADDR_MUX_9548_4=0x71 # ZQSFP MUX #2 EEPROM
+I2C_ADDR_MUX_9548_5=0x71 # ZQSFP MUX #3 EEPROM
+I2C_ADDR_MUX_9548_6=0x71 # ZQSFP MUX #4 EEPROM
+### GPIO Expander
+I2C_ADDR_MUX_9539_0=0x76 # LED & HW ID
+I2C_ADDR_MUX_9539_1=0x75 # BMC PRSNT & HWM reset
+I2C_ADDR_MUX_9539_2=0x74 # SYS SEL & RST
+I2C_ADDR_MUX_9535_3=0x20 # ZQSFP0~15 ABS
+I2C_ADDR_MUX_9535_4=0x21 # ZQSFP16~31 ABS
+I2C_ADDR_MUX_9535_5=0x22 # ZQSFP0~15 INT
+I2C_ADDR_MUX_9535_6=0x23 # ZQSFP16~31 INT
+I2C_ADDR_MUX_9535_7=0x20 # ZQSFP0~15 LPMODE
+I2C_ADDR_MUX_9535_8=0x21 # ZQSFP16~31 LPMODE
+I2C_ADDR_MUX_9535_9=0x22 # ZQSFP0~15 RST
+I2C_ADDR_MUX_9535_10=0x23 # ZQSFP16~31 RST
+I2C_ADDR_MUX_9535_11=0x20 # on FAN board, fan status and led config
+I2C_ADDR_MUX_9555_12=0x24 # on BMC board, INT and HW ID
+I2C_ADDR_MUX_9555_13=0x25 # on BMC board, PSU status
+I2C_ADDR_MUX_9555_14=0x26 # on BMC board, RST and SEL
+I2C_ADDR_MUX_9539_15=0x77 # on CPU board, STATUS and ERR from CPLD
+### peripheral
+I2C_ADDR_MB_EEPROM=0x55 # on main board
+I2C_ADDR_CB_EEPROM=0x51 # on cpu board
+I2C_ADDR_UCD9090=0x34
+I2C_ADDR_W83795=0x2F
+I2C_ADDR_PSU1_EEPROM=0x50
+I2C_ADDR_PSU2_EEPROM=0x50
+I2C_ADDR_TMP75_REAR=0x4C
+I2C_ADDR_TMP75_FRONT=0x49
+I2C_ADDR_TMP75_CB=0x4F # on cpu board
+I2C_ADDR_TMP75_BB=0x4A # on bmc board
+I2C_ADDR_QSFP_EEPROM=0x50
+
+#sysfs
+PATH_SYSFS_PSU1="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_PSU1_EEPROM}-$(printf "%04x" $I2C_ADDR_PSU1_EEPROM)"
+PATH_SYSFS_PSU2="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_PSU2_EEPROM}-$(printf "%04x" $I2C_ADDR_PSU2_EEPROM)"
+
+#ACTIVE LOW enable flag
+ACTIVE_LOW_EN=1
+ACTIVE_HIGH_EN=0
+#GPIO Direction In/Out
+DIR_IN=in
+DIR_OUT=out
+
+#Power Supply Status
+PSU_DC_ON=1
+PSU_DC_OFF=0
+PSU_EXIST=1
+PSU_NOT_EXIST=0
+
+# IO expander register
+# direction
+REG_PORT0_DIR=6
+REG_PORT1_DIR=7
+# polarity
+REG_PORT0_POL=4
+REG_PORT1_POL=5
+# output
+REG_PORT0_OUT=2
+REG_PORT1_OUT=3
+# input
+REG_PORT0_IN=0
+REG_PORT1_IN=1
+
+#ZQSFP GPIO sysfs index
+ZQSFP_PORT0_ABS_GPIO_IDX=240 # 240~255
+ZQSFP_PORT16_ABS_GPIO_IDX=224 # 224~239
+
+# switch port number range
+MIN_PORT_NUM=1
+MAX_PORT_NUM=32
+
+#GPIO Offset
+GPIO_OFFSET=0
+
+# Help usage function
+function _help {
+ echo "========================================================="
+ echo "# Description: Help Function"
+ echo "# Version : ${VERSION}"
+ echo "========================================================="
+ echo "----------------------------------------------------"
+ echo "EX : ${0} help"
+ echo " : ${0} i2c_init"
+ echo " : ${0} i2c_deinit"
+ echo " : ${0} i2c_fan_speed_init"
+ echo " : ${0} i2c_io_exp_init"
+ echo " : ${0} i2c_gpio_init"
+ echo " : ${0} i2c_gpio_deinit"
+ echo " : ${0} i2c_led_test"
+ echo " : ${0} i2c_psu_eeprom_get"
+ echo " : ${0} i2c_mb_eeprom_get"
+ echo " : ${0} i2c_cb_eeprom_get"
+ echo " : ${0} i2c_eeprom_sync"
+ echo " : ${0} i2c_qsfp_eeprom_get [1-32]"
+ echo " : ${0} i2c_qsfp_eeprom_init new|delete"
+ echo " : ${0} i2c_mb_eeprom_init new|delete"
+ echo " : ${0} i2c_cb_eeprom_init new|delete"
+ echo " : ${0} i2c_qsfp_status_get [1-32]"
+ echo " : ${0} i2c_qsfp_type_get [1-32]"
+ echo " : ${0} i2c_board_type_get"
+ echo " : ${0} i2c_bmc_board_type_get"
+ echo " : ${0} i2c_psu_status"
+ echo " : ${0} i2c_led_psu_status_set"
+ echo " : ${0} i2c_led_fan_status_set"
+ echo " : ${0} i2c_led_fan_tray_status_set"
+ echo " : ${0} i2c_test_all"
+ echo " : ${0} i2c_sys_led green|amber"
+ echo " : ${0} i2c_fan_led green|amber on|off"
+ echo " : ${0} i2c_psu1_led green|amber on|off"
+ echo " : ${0} i2c_psu2_led green|amber on|off"
+ echo " : ${0} i2c_fan_tray_led green|amber on|off [1-4]"
+ echo "----------------------------------------------------"
+}
+
+#Pause function
+function _pause {
+ read -p "$*"
+}
+
+#Retry command function
+function _retry {
+ local i
+ for i in {1..5};
+ do
+ eval "${*}" && break || echo "retry"; sleep 1;
+ done
+}
+
+#I2C Init
+function _i2c_init {
+ echo "========================================================="
+ echo "# Description: I2C Init"
+ echo "========================================================="
+
+ #rmmod i2c_ismt
+ _util_rmmod i2c_i801
+ modprobe i2c_i801 disable_features=0x10
+ modprobe i2c_dev
+ modprobe i2c_mux_pca954x force_deselect_on_exit=1
+
+ # add MUX PCA9548#0 on I801, assume to be i2c-1~8
+ if [ ! -e ${PATH_MUX_9548_0_CH0} ]; then
+ _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_0}' > ${PATH_I801_DEVICE}/new_device"
+ else
+ echo "pca9548 ${I2C_ADDR_MUX_9548_0} already init."
+ fi
+ # add MUX PCA9545#1 on I801, assume to be i2c-9~12
+ if [ ! -e ${PATH_MUX_9545_1_CH0} ]; then
+ _retry "echo 'pca9545 ${I2C_ADDR_MUX_9545_1}' > ${PATH_I801_DEVICE}/new_device"
+ else
+ echo "pca9545 ${I2C_ADDR_MUX_9545_1} already init."
+ fi
+ # add MUX PCA9548#2 on I801, assume to be i2c-13~20
+ if [ ! -e ${PATH_MUX_9548_2_CH0} ]; then
+ _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_2}' > ${PATH_I801_DEVICE}/new_device"
+ else
+ echo "pca9548 ${I2C_ADDR_MUX_9548_2} already init."
+ fi
+ # add MUX PCA9548#3 on PCA9548#2 CH0, assume to be i2c-21~28
+ if [ ! -e ${PATH_MUX_9548_3_CH0} ]; then
+ _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_3}' > ${PATH_MUX_9548_2_CH0}/new_device"
+ else
+ echo "pca9548 ${I2C_ADDR_MUX_9548_3} already init."
+ fi
+ # add MUX PCA9548#4 on PCA9548#2 CH1, assume to be i2c-29~36
+ if [ ! -e ${PATH_MUX_9548_4_CH0} ]; then
+ _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_4}' > ${PATH_MUX_9548_2_CH1}/new_device"
+ else
+ echo "pca9548 ${I2C_ADDR_MUX_9548_4} already init."
+ fi
+ # add MUX PCA9548#5 on PCA9548#2 CH2, assume to be i2c-37~44
+ if [ ! -e ${PATH_MUX_9548_5_CH0} ]; then
+ _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_5}' > ${PATH_MUX_9548_2_CH2}/new_device"
+ else
+ echo "pca9548 ${I2C_ADDR_MUX_9548_5} already init."
+ fi
+ # add MUX PCA9548#6 on PCA9548#2 CH3, assume to be i2c-45~52
+ if [ ! -e ${PATH_MUX_9548_6_CH0} ]; then
+ _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_6}' > ${PATH_MUX_9548_2_CH3}/new_device"
+ else
+ echo "pca9548 ${I2C_ADDR_MUX_9548_6} already init."
+ fi
+
+ _i2c_hwm_init
+ _util_rmmod eeprom
+ modprobe eeprom_mb
+ modprobe gpio-pca953x
+ _i2c_io_exp_init
+ rmmod gpio_ich
+ _i2c_gpio_init
+ modprobe gpio_ich
+ _i2c_sensors_init
+ _i2c_psu_init
+
+ # Init LED_CLR register (pull shift register out of reset), should be after io exp init
+ _port_led_clr_init
+ _i2c_qsfp_eeprom_init "new"
+ _i2c_mb_eeprom_init "new"
+ _i2c_cb_eeprom_init "new"
+ _i2c_fan_speed_init
+ _i2c_led_psu_status_set
+ _i2c_led_fan_status_set
+
+ # sync eeprom content
+ _i2c_eeprom_sync
+
+ # trun on sys led
+ echo "led_sys setup..."
+ COLOR_LED="green"
+ ONOFF_LED="on"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_sys_led
+
+ _config_rmem
+}
+
+#I2C Deinit
+function _i2c_deinit {
+ echo "i2c deinit..."
+ _i2c_gpio_deinit
+ for mod in coretemp jc42 w83795 eeprom eeprom_mb gpio-pca953x i2c_mux_pca954x i2c_i801 ingrasys_s9130_32x_psu;
+ do
+ _util_rmmod $mod
+ done
+ echo "Done"
+}
+
+function _i2c_sensors_init {
+ echo "SENSORS init..."
+ local dev_path
+ # to make sure hwmon index in sysfs as expected,
+ # need to remove kernel module and then probe them in expected order
+ # remove all sensors kernel module
+ _util_rmmod coretemp
+ _util_rmmod jc42
+ _util_rmmod w83795
+ # probe coretemp kernel module
+ modprobe coretemp
+ # probe hwmon kernel module
+ modprobe w83795
+ # add tmp75 to sysfs
+ ####Main board thermal
+ dev_path="${PATH_SYS_I2C_DEVICES}/${NUM_MUX_9545_1_CH3}-$(printf "%04x" ${I2C_ADDR_TMP75_REAR})"
+ if ! [ -L ${dev_path} ]; then
+ echo "tmp75 ${I2C_ADDR_TMP75_REAR}" > ${PATH_MUX_9545_1_CH3}/new_device # hwmon1
+ else
+ echo "${dev_path} already exist"
+ fi
+ sleep 0.5
+ dev_path="${PATH_SYS_I2C_DEVICES}/${NUM_MUX_9545_1_CH3}-$(printf "%04x" ${I2C_ADDR_TMP75_FRONT})"
+ if ! [ -L ${dev_path} ]; then
+ echo "tmp75 ${I2C_ADDR_TMP75_FRONT}" > ${PATH_MUX_9545_1_CH3}/new_device #hwmon2
+ else
+ echo "${dev_path} already exist"
+ fi
+ sleep 0.5
+ ####BMC board thermal
+ dev_path="${PATH_SYS_I2C_DEVICES}/${NUM_MUX_9548_0_CH7}-$(printf "%04x" ${I2C_ADDR_TMP75_BB})"
+ if ! [ -L ${dev_path} ]; then
+ echo "tmp75 ${I2C_ADDR_TMP75_BB}" > ${PATH_MUX_9548_0_CH7}/new_device #hwmon3
+ else
+ echo "${dev_path} already exist"
+ fi
+ sleep 0.5
+ ####CPU board thermal
+ dev_path="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_MAIN}-$(printf "%04x" ${I2C_ADDR_TMP75_CB})"
+ if ! [ -L ${dev_path} ]; then
+ echo "tmp75 ${I2C_ADDR_TMP75_CB}" > ${PATH_I801_DEVICE}/new_device #hwmon4
+ else
+ echo "${dev_path} already exist"
+ fi
+ sleep 0.5
+ # add w83795 to sysfs
+ dev_path="${PATH_SYS_I2C_DEVICES}/${NUM_MUX_9548_0_CH7}-$(printf "%04x" ${I2C_ADDR_W83795})"
+ if ! [ -L ${dev_path} ]; then
+ echo "w83795adg ${I2C_ADDR_W83795}" > ${PATH_MUX_9548_0_CH7}/new_device #hwmon5
+ else
+ echo "${dev_path} already exist"
+ fi
+ sleep 0.5
+
+ # probe jc42 kernel module
+ modprobe jc42
+
+ echo "Done"
+}
+
+function _port_led_clr_init {
+ echo "port led init..."
+ # gpio pin on GPIO MUX PCA9539#2 I/O 0.2
+ # pull high to out of reset
+ output_reg=${REG_PORT0_OUT}
+ mask=0x04
+ value=0x04
+ _util_i2cset -m ${mask} -y ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_2} ${output_reg} ${value}
+ echo "Done"
+}
+
+#FAN Speed Init
+function _i2c_fan_speed_init {
+ echo -n "FAN SPEED INIT..."
+ if [ -e "${PATH_HWMON_W83795_DEVICE}" ]; then
+ # init fan speed
+ echo 120 > ${PATH_HWMON_W83795_DEVICE}/device/pwm1
+ echo 120 > ${PATH_HWMON_W83795_DEVICE}/device/pwm2
+ echo "SUCCESS"
+ else
+ echo "FAIL"
+ fi
+}
+
+# HWM init
+function _i2c_hwm_init {
+ echo "HWM INIT..."
+ # select bank0
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x00 0x80
+ # SW reset, Disable monitor
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x01 0x9C
+ # disable TR5/TR6 DTS
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x04 0x0
+ # enable FANIN1~8
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x06 0xFF
+ # disable FANIN9~14
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x07 0x00
+ # CLKIN clock frequency set as 48Mhz
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x01 0x1C
+ # select bank 2
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x00 0x82
+ # set PWM mode in FOMC
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x0F 0x00
+ # set 25KHz fan output frequency in F1OPFP&F2OPFP
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x18 0x84
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x19 0x84
+}
+
+#Temperature sensor Init
+function _i2c_temp_init {
+ echo "TEMP INIT..."
+ # enable temp monitor on w83795
+ # select bank0
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x00 0x80
+ # enable TR4 temperature monitoring
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x05 0x40
+ # disable TR5/TR6 DTS
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x04 0x0
+ echo "Done"
+}
+
+#VOLMON Init
+function _i2c_volmon_init {
+ echo "VOLMON INIT..."
+ # enable voltage monitor on w83795
+ # VSEN1 P0V9
+ # VSEN2 VDD
+ # VSEN3 P1V2
+ # VSEN4 P1V8
+ # select bank0
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x00 0x80
+ # enable vsen1~4, disable vsen5~8
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x02 0x0F
+ # enable 3VDD,VBAT
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x03 0x50
+ echo "Done"
+}
+
+#FANIN Init
+function _i2c_fan_init {
+ echo "FANIN INIT..."
+ # enable fan monitor on w83795
+ # 4 fantray with 8 FANIN
+ # select bank0
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x00 0x80
+ # enable FANIN1~8
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x06 0xFF
+ # disable FANIN9~14
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x07 0x00
+
+ # select bank 2
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x00 0x82
+ # set PWM mode in FOMC
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x0F 0x00
+
+ echo "Done"
+}
+
+#IO Expander Init
+function _i2c_io_exp_init {
+ echo "========================================================="
+ echo "# Description: I2C IO Expender Init"
+ echo "========================================================="
+
+ # need to init BMC io expander first due to some io expander are reset default
+ echo "Init BMC INT & HW ID IO Expander"
+ # all input
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_12} ${REG_PORT0_DIR} 0xFF
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_12} ${REG_PORT1_DIR} 0xFF
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_12} ${REG_PORT0_POL} 0x00
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_12} ${REG_PORT1_POL} 0x00
+
+ echo "Init BMC PSU status IO Expander"
+ # PWRON default 0 (ACTIVE_LOW)
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_13} ${REG_PORT0_OUT} 0x00
+ # default 0 (ACTIVE_LOW)
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_13} ${REG_PORT1_OUT} 0x00
+ # I/O 0.2 0.5 output(PWRON), rest input
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_13} ${REG_PORT0_DIR} 0xDB
+ # I/O 1.0~1.1 input, 1.2~1.4 output (1.5~1.7 not enable)
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_13} ${REG_PORT1_DIR} 0xE3
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_13} ${REG_PORT0_POL} 0x00
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_13} ${REG_PORT1_POL} 0x00
+
+ echo "Init BMC RST and SEL IO Expander"
+ # RST default is 1 (ACTIVE_LOW)
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_14} ${REG_PORT0_OUT} 0x3F
+ # SEL default is 0 (HOST), EN default is 1 (ACTIVE_HIGH)
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_14} ${REG_PORT1_OUT} 0x1F
+ # I/O 0.0~0.5 output, 0.6~0.7 not use
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_14} ${REG_PORT0_DIR} 0xC0
+ # all output
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_14} ${REG_PORT1_DIR} 0x00
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_14} ${REG_PORT0_POL} 0x00
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_14} ${REG_PORT1_POL} 0x00
+
+ echo "Init System LED & HW ID IO Expander"
+ # I/O_0.x for System LED default 0, I/O_1.x for HW ID
+ _util_i2cset -y -r ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${REG_PORT0_OUT} 0x00
+ # System LED => all output
+ _util_i2cset -y -r ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${REG_PORT0_DIR} 0x00
+ # HW ID => all input
+ _util_i2cset -y -r ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${REG_PORT1_DIR} 0xFF
+ _util_i2cset -y -r ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${REG_PORT0_POL} 0x00
+ _util_i2cset -y -r ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${REG_PORT1_POL} 0x00
+
+ echo "Init System PRSNT and HWM RST IO Expander"
+ # HWM_RST_L default 1 (ACTIVE_LOW)
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_1} ${REG_PORT0_OUT} 0x04
+ # all input expect HWM_RST_L (0.2)
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_1} ${REG_PORT0_DIR} 0xFB
+ # port1 not used
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_1} ${REG_PORT1_DIR} 0xFF
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_1} ${REG_PORT0_POL} 0x00
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_1} ${REG_PORT1_POL} 0x00
+
+ echo "Init System SEL and RST IO Expander"
+ # RST 0.0~0.3 default 1 (ACTIVE low), rest default 0
+ # SEL set to value 0 (host)
+ # LED_CLR also do init in _port_led_clr_init
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_2} ${REG_PORT0_OUT} 0x0F
+ # RST 1.6~1.7 default 1 (ACTIVE low), INT 1.0~1.4 default 1 (ACTIVE low)
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_2} ${REG_PORT1_OUT} 0xDF
+ # all output, but MAC_RST_L 0.0 need to set as input to prevent reboot issue
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_2} ${REG_PORT0_DIR} 0x09
+ # RST 1.5 !~ 1.7 output, rest are input
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_2} ${REG_PORT1_DIR} 0x1F
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_2} ${REG_PORT0_POL} 0x00
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_2} ${REG_PORT1_POL} 0x00
+
+ echo "Init FAN Board Status IO Expander"
+ # LED_G_L set to 0, LED_Y_L set to 1 (ACTIVE_LOW)
+ _util_i2cset -y -r ${I2C_BUS_FAN_STATUS} ${I2C_ADDR_MUX_9535_11} ${REG_PORT0_OUT} 0x22
+ _util_i2cset -y -r ${I2C_BUS_FAN_STATUS} ${I2C_ADDR_MUX_9535_11} ${REG_PORT1_OUT} 0x22
+ # DIR/ABS is input, LED_Y/LED_G is output
+ _util_i2cset -y -r ${I2C_BUS_FAN_STATUS} ${I2C_ADDR_MUX_9535_11} ${REG_PORT0_DIR} 0xCC
+ _util_i2cset -y -r ${I2C_BUS_FAN_STATUS} ${I2C_ADDR_MUX_9535_11} ${REG_PORT1_DIR} 0xCC
+ _util_i2cset -y -r ${I2C_BUS_FAN_STATUS} ${I2C_ADDR_MUX_9535_11} ${REG_PORT0_POL} 0x00
+ _util_i2cset -y -r ${I2C_BUS_FAN_STATUS} ${I2C_ADDR_MUX_9535_11} ${REG_PORT1_POL} 0x00
+
+ echo "Init CPU CPLD IO Expander"
+ # all input
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_15} ${REG_PORT0_DIR} 0xFF
+ # all input
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_15} ${REG_PORT1_DIR} 0xFF
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_15} ${REG_PORT0_POL} 0x00
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_15} ${REG_PORT1_POL} 0x00
+
+ echo "Init ZQSFP IO Expender"
+
+ echo "set ZQSFP ABS"
+ #zQSFP 0-15 ABS
+ # all input
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_3} ${REG_PORT0_DIR} 0xFF
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_3} ${REG_PORT1_DIR} 0xFF
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_3} ${REG_PORT0_POL} 0x00
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_3} ${REG_PORT1_POL} 0x00
+ #zQSFP 16-31 ABS
+ # all input
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_4} ${REG_PORT0_DIR} 0xFF
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_4} ${REG_PORT1_DIR} 0xFF
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_4} ${REG_PORT0_POL} 0x00
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_4} ${REG_PORT1_POL} 0x00
+
+ echo "set ZQSFP INT"
+ #zQSFP 0-15 INT
+ # all input
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_5} ${REG_PORT0_DIR} 0xFF
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_5} ${REG_PORT1_DIR} 0xFF
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_5} ${REG_PORT0_POL} 0x00
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_5} ${REG_PORT1_POL} 0x00
+ #zQSFP 16-31 INT
+ # all input
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_6} ${REG_PORT0_DIR} 0xFF
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_6} ${REG_PORT1_DIR} 0xFF
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_6} ${REG_PORT0_POL} 0x00
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH4} ${I2C_ADDR_MUX_9535_6} ${REG_PORT1_POL} 0x00
+
+ echo "set ZQSFP LP_MODE = 0"
+ #ZQSFP 0-15 LP_MODE
+ # default is 0
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_7} ${REG_PORT0_OUT} 0x00
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_7} ${REG_PORT1_OUT} 0x00
+ # all output
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_7} ${REG_PORT0_DIR} 0x00
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_7} ${REG_PORT1_DIR} 0x00
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_7} ${REG_PORT0_POL} 0x00
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_7} ${REG_PORT1_POL} 0x00
+ #ZQSFP 16-31 LP_MODE
+ # default is 0
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_8} ${REG_PORT0_OUT} 0x00
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_8} ${REG_PORT1_OUT} 0x00
+ # all output
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_8} ${REG_PORT0_DIR} 0x00
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_8} ${REG_PORT1_DIR} 0x00
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_8} ${REG_PORT0_POL} 0x00
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_8} ${REG_PORT1_POL} 0x00
+
+ echo "set ZQSFP RST = 1"
+ #ZQSFP 0-15 RST
+ # default is 1 (ACTIVE_LOW)
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_9} ${REG_PORT0_OUT} 0xFF
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_9} ${REG_PORT1_OUT} 0xFF
+ # all output
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_9} ${REG_PORT0_DIR} 0x00
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_9} ${REG_PORT1_DIR} 0x00
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_9} ${REG_PORT0_POL} 0x00
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_9} ${REG_PORT1_POL} 0x00
+ #ZQSFP 16-31 RST
+ # default is 1 (ACTIVE_LOW)
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_10} ${REG_PORT0_OUT} 0xFF
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_10} ${REG_PORT1_OUT} 0xFF
+ # all output
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_10} ${REG_PORT0_DIR} 0x00
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_10} ${REG_PORT1_DIR} 0x00
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_10} ${REG_PORT0_POL} 0x00
+ _util_i2cset -y -r ${NUM_MUX_9548_2_CH5} ${I2C_ADDR_MUX_9535_10} ${REG_PORT1_POL} 0x00
+
+}
+
+# To set the global variable GPIO_OFFSET
+function _set_gpio_offset {
+ GPIO_OFFSET=0
+ for d in `ls /sys/class/gpio/ | grep gpiochip`
+ do
+ gpiochip_no=${d##gpiochip}
+ if [ $gpiochip_no -gt 255 ]; then
+ GPIO_OFFSET=256
+ break
+ fi
+ done
+ #echo "set GPIO_OFFSET=${GPIO_OFFSET}"
+}
+
+#GPIO Init
+function _i2c_gpio_init {
+ local i=0
+ local start=255
+ local end=255
+ local ch_num=16
+
+ #ABS Port 0-15
+ echo "pca9535 ${I2C_ADDR_MUX_9535_3}" > ${PATH_MUX_9548_2_CH4}/new_device
+ _set_gpio_offset
+ start=$[ ${start}+${GPIO_OFFSET} ]
+ end=$[ ${end}+${GPIO_OFFSET} ]
+ start=$[ ${end}-${ch_num}+1]
+ for (( i=$start; i<=$end; i++ ))
+ do
+ _util_gpio_export ${i} ${DIR_IN} ${ACTIVE_LOW_EN}
+ done
+
+ #ABS Port 16-31
+ end=$[ ${start}-1]
+ echo "pca9535 ${I2C_ADDR_MUX_9535_4}" > ${PATH_MUX_9548_2_CH4}/new_device
+ start=$[ ${end}-${ch_num}+1]
+ for (( i=$start; i<=$end; i++ ))
+ do
+ _util_gpio_export ${i} ${DIR_IN} ${ACTIVE_LOW_EN}
+ done
+
+ #INT Port 0-15
+ end=$[ ${start}-1]
+ echo "pca9535 ${I2C_ADDR_MUX_9535_5}" > ${PATH_MUX_9548_2_CH4}/new_device
+ start=$[ ${end}-${ch_num}+1]
+ for (( i=$start; i<=$end; i++ ))
+ do
+ _util_gpio_export ${i} ${DIR_IN} ${ACTIVE_LOW_EN}
+ done
+
+ #INT Port 16-31
+ end=$[ ${start}-1]
+ echo "pca9535 ${I2C_ADDR_MUX_9535_6}" > ${PATH_MUX_9548_2_CH4}/new_device
+ start=$[ ${end}-${ch_num}+1]
+ for (( i=$start; i<=$end; i++ ))
+ do
+ _util_gpio_export ${i} ${DIR_IN} ${ACTIVE_LOW_EN}
+ done
+
+ #LP Mode Port 0-15
+ end=$[ ${start}-1]
+ echo "pca9535 ${I2C_ADDR_MUX_9535_7}" > ${PATH_MUX_9548_2_CH5}/new_device
+ start=$[ ${end}-${ch_num}+1]
+ for (( i=$start; i<=$end; i++ ))
+ do
+ _util_gpio_export ${i} ${DIR_OUT} ${ACTIVE_HIGH_EN}
+ done
+
+ #LP Mode Port 16-31
+ end=$[ ${start}-1]
+ echo "pca9535 ${I2C_ADDR_MUX_9535_8}" > ${PATH_MUX_9548_2_CH5}/new_device
+ start=$[ ${end}-${ch_num}+1]
+ for (( i=$start; i<=$end; i++ ))
+ do
+ _util_gpio_export ${i} ${DIR_OUT} ${ACTIVE_HIGH_EN}
+ done
+
+ #RESET Port 0-15
+ end=$[ ${start}-1]
+ echo "pca9535 ${I2C_ADDR_MUX_9535_9}" > ${PATH_MUX_9548_2_CH5}/new_device
+ start=$[ ${end}-${ch_num}+1]
+ for (( i=$start; i<=$end; i++ ))
+ do
+ # need to set value to low (became ACTIVE_HIGH) to take port out of reset
+ _util_gpio_export ${i} ${DIR_OUT} ${ACTIVE_LOW_EN} 0
+ done
+
+ #RESET Port 16-31
+ end=$[ ${start}-1]
+ echo "pca9535 ${I2C_ADDR_MUX_9535_10}" > ${PATH_MUX_9548_2_CH5}/new_device
+ start=$[ ${end}-${ch_num}+1]
+ for (( i=$start; i<=$end; i++ ))
+ do
+ # need to set value to low (became ACTIVE_HIGH) to take port out of reset
+ _util_gpio_export ${i} ${DIR_OUT} ${ACTIVE_LOW_EN} 0
+ done
+}
+
+#GPIO DeInit
+function _i2c_gpio_deinit {
+ echo ${I2C_ADDR_MUX_9535_3} > /sys/bus/i2c/devices/i2c-${NUM_MUX_9548_2_CH4}/delete_device
+ echo ${I2C_ADDR_MUX_9535_4} > /sys/bus/i2c/devices/i2c-${NUM_MUX_9548_2_CH4}/delete_device
+ echo ${I2C_ADDR_MUX_9535_5} > /sys/bus/i2c/devices/i2c-${NUM_MUX_9548_2_CH4}/delete_device
+ echo ${I2C_ADDR_MUX_9535_6} > /sys/bus/i2c/devices/i2c-${NUM_MUX_9548_2_CH4}/delete_device
+ echo ${I2C_ADDR_MUX_9535_7} > /sys/bus/i2c/devices/i2c-${NUM_MUX_9548_2_CH5}/delete_device
+ echo ${I2C_ADDR_MUX_9535_8} > /sys/bus/i2c/devices/i2c-${NUM_MUX_9548_2_CH5}/delete_device
+ echo ${I2C_ADDR_MUX_9535_9} > /sys/bus/i2c/devices/i2c-${NUM_MUX_9548_2_CH5}/delete_device
+ echo ${I2C_ADDR_MUX_9535_10} > /sys/bus/i2c/devices/i2c-${NUM_MUX_9548_2_CH5}/delete_device
+}
+
+#Set FAN Tray LED
+function _i2c_led_fan_tray_status_set {
+ echo "FAN Tray Status Setup"
+ #FAN Status get
+ FAN1_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan8_alarm`
+ FAN2_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan7_alarm`
+ FAN3_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan6_alarm`
+ FAN4_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan5_alarm`
+ FAN5_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan4_alarm`
+ FAN6_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan3_alarm`
+ FAN7_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan2_alarm`
+ FAN8_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan1_alarm`
+
+ # check if io expander for fan tray exist
+ result=`i2cget -y ${I2C_BUS_FANTRAY_LED} ${I2C_ADDR_MUX_9535_11} ${REG_PORT0_IN} 2>/dev/null`
+ err_code=$?
+ if [ "$err_code" != "0" ]; then
+ echo "fan tray not exist!"
+ return
+ fi
+
+ if [ "${FAN1_ALARM}" == "0" ] && [ "${FAN2_ALARM}" == "0" ]; then
+ FAN_TRAY=1
+ echo "FAN_TRAY${FAN_TRAY}..."
+ COLOR_LED="green"
+ ONOFF_LED="on"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_fan_tray_led
+ COLOR_LED="amber"
+ ONOFF_LED="off"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_fan_tray_led
+ else
+ FAN_TRAY=1
+ echo "FAN_TRAY${FAN_TRAY}..."
+ COLOR_LED="green"
+ ONOFF_LED="off"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_fan_tray_led
+ COLOR_LED="amber"
+ ONOFF_LED="on"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_fan_tray_led
+ fi
+
+ if [ "${FAN3_ALARM}" == "0" ] && [ "${FAN4_ALARM}" == "0" ]; then
+ FAN_TRAY=2
+ echo "FAN_TRAY${FAN_TRAY}..."
+ COLOR_LED="green"
+ ONOFF_LED="on"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_fan_tray_led
+ COLOR_LED="amber"
+ ONOFF_LED="off"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_fan_tray_led
+ else
+ FAN_TRAY=2
+ echo "FAN_TRAY${FAN_TRAY}..."
+ COLOR_LED="green"
+ ONOFF_LED="off"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_fan_tray_led
+ COLOR_LED="amber"
+ ONOFF_LED="on"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_fan_tray_led
+ fi
+
+ if [ "${FAN5_ALARM}" == "0" ] && [ "${FAN6_ALARM}" == "0" ]; then
+ FAN_TRAY=3
+ echo "FAN_TRAY${FAN_TRAY}..."
+ COLOR_LED="green"
+ ONOFF_LED="on"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_fan_tray_led
+ COLOR_LED="amber"
+ ONOFF_LED="off"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_fan_tray_led
+ else
+ FAN_TRAY=3
+ echo "FAN_TRAY${FAN_TRAY}..."
+ COLOR_LED="green"
+ ONOFF_LED="off"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_fan_tray_led
+ COLOR_LED="amber"
+ ONOFF_LED="on"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_fan_tray_led
+ fi
+
+ if [ "${FAN7_ALARM}" == "0" ] && [ "${FAN8_ALARM}" == "0" ]; then
+ FAN_TRAY=4
+ echo "FAN_TRAY${FAN_TRAY}..."
+ COLOR_LED="green"
+ ONOFF_LED="on"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_fan_tray_led
+ COLOR_LED="amber"
+ ONOFF_LED="off"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_fan_tray_led
+ else
+ FAN_TRAY=4
+ echo "FAN_TRAY${FAN_TRAY}..."
+ COLOR_LED="green"
+ ONOFF_LED="off"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_fan_tray_led
+ COLOR_LED="amber"
+ ONOFF_LED="on"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_fan_tray_led
+ fi
+}
+
+#Set FAN LED
+function _i2c_led_fan_status_set {
+ echo "FAN Status Setup"
+ #PSU Status set
+ FAN1_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan1_alarm`
+ FAN2_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan2_alarm`
+ FAN3_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan3_alarm`
+ FAN4_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan4_alarm`
+ FAN5_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan5_alarm`
+ FAN6_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan6_alarm`
+ FAN7_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan7_alarm`
+ FAN8_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan8_alarm`
+
+ echo "led_fan setup..."
+ # all fan ok
+ if [ "${FAN1_ALARM}" == "0" ] && [ "${FAN2_ALARM}" == "0" ] \
+ && [ "${FAN3_ALARM}" == "0" ] && [ "${FAN4_ALARM}" == "0" ] \
+ && [ "${FAN5_ALARM}" == "0" ] && [ "${FAN6_ALARM}" == "0" ] \
+ && [ "${FAN7_ALARM}" == "0" ] && [ "${FAN8_ALARM}" == "0" ]; then
+ COLOR_LED="green"
+ ONOFF_LED="on"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_fan_led
+ # all fan fail
+ elif [ "${FAN1_ALARM}" == "1" ] && [ "${FAN2_ALARM}" == "1" ] \
+ && [ "${FAN3_ALARM}" == "1" ] && [ "${FAN4_ALARM}" == "1" ] \
+ && [ "${FAN5_ALARM}" == "1" ] && [ "${FAN6_ALARM}" == "1" ] \
+ && [ "${FAN7_ALARM}" == "1" ] && [ "${FAN8_ALARM}" == "1" ]; then
+ COLOR_LED="green"
+ ONOFF_LED="off"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_fan_led
+ # partial fan fail
+ else
+ COLOR_LED="amber"
+ ONOFF_LED="on"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_fan_led
+ fi
+}
+
+#Set Power Supply LED
+function _i2c_led_psu_status_set {
+ echo "PSU LED Status Setup"
+
+ #PSU Status set
+ _i2c_psu_status
+
+ #PSU1 Status
+ echo "led_psu1 setup..."
+ if [ "${psu1Exist}" == ${PSU_EXIST} ]; then
+ if [ "${psu1PwGood}" == ${PSU_DC_ON} ]; then
+ COLOR_LED="green"
+ ONOFF_LED="on"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_psu1_led
+ else
+ COLOR_LED="amber"
+ ONOFF_LED="on"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_psu1_led
+ fi
+ else
+ COLOR_LED="green"
+ ONOFF_LED="off"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_psu1_led
+ fi
+
+ #PSU2 Status
+ echo "led_psu2 setup..."
+ if [ "${psu2Exist}" == ${PSU_EXIST} ]; then
+ if [ "${psu2PwGood}" == ${PSU_DC_ON} ]; then
+ COLOR_LED="green"
+ ONOFF_LED="on"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_psu2_led
+ else
+ COLOR_LED="amber"
+ ONOFF_LED="on"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_psu2_led
+ fi
+ else
+ COLOR_LED="green"
+ ONOFF_LED="off"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_psu2_led
+ fi
+}
+
+#LED Test
+function _i2c_led_test {
+ echo "========================================================="
+ echo "# Description: I2C SYSTEM LED TEST..."
+ echo "========================================================="
+ local output_reg=${REG_PORT0_OUT}
+ local mask=0xFF
+ local value=0xFF
+
+ #sys led (green)
+ # set sys_led_g (0.7) = 1
+ mask=0x80
+ value=0x80
+ _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value}
+ _pause 'Check SYS LED green light and Press [Enter] key to continue...'
+ #sys led (amber)
+ # set sys_led_g (0.7) = 0
+ mask=0x80
+ value=0x00
+ _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value}
+ _pause 'Check SYS LED amber light and Press [Enter] key to continue...'
+
+ #FAN led (green)
+ # set fan_led_en (0.6) = 1 & fan_led_y (0.5) = 0
+ mask=0x60
+ value=0x40
+ _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value}
+ _pause 'Check FAN LED green light and Press [Enter] key to continue...'
+ #FAN led (amber)
+ # set fan_led_en (0.6) = 1 & fan_led_y (0.5) = 1
+ mask=0x60
+ value=0x60
+ _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value}
+ _pause 'Check FAN LED amber light and Press [Enter] key to continue...'
+
+ #PSU1 led (green)
+ # set psu1_pwr_ok_oe (0.4) = 1 & psu1_led_y (0.3) = 0
+ mask=0x18
+ value=0x10
+ _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value}
+ _pause 'Check PSU1 LED green light and Press [Enter] key to continue...'
+ #PSU1 led (amber)
+ # set psu1_pwr_ok_oe (0.4) = 1 & psu1_led_y (0.3) = 1
+ mask=0x18
+ value=0x18
+ _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value}
+ _pause 'Check PSU1 LED amber light and Press [Enter] key to continue...'
+
+ #PSU2 led (green)
+ # set psu0_pwr_ok_oe (0.2) = 1 & psu0_led_y (0.1) = 0
+ mask=0x06
+ value=0x04
+ _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value}
+ _pause 'Check PSU2 LED green light and Press [Enter] key to continue...'
+ #PSU2 led (amber)
+ # set psu0_pwr_ok_oe (0.2) = 1 & psu0_led_y (0.1) = 1
+ mask=0x06
+ value=0x06
+ _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value}
+ _pause 'Check PSU2 LED amber light and Press [Enter] key to continue...'
+
+ #Turn OFF All LED (can't trun off system led)
+ # set set fan_led_en (0.6), psu1_pwr_ok_oe (0.4), psu0_pwr_ok_oe (0.2) = 0
+ mask=0x54
+ value=0x00
+ _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value}
+ _pause 'Check turn off all LEDs (exclude SYS LED) and Press [Enter] key to continue...'
+
+ # restore sys led
+ COLOR_LED="green"
+ ONOFF_LED="on"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_sys_led
+
+ echo "Done"
+}
+
+#Set QSFP Port variable
+function _qsfp_port_i2c_var_set {
+ local port=$1
+ case ${port} in
+ 1|2|3|4|5|6|7|8)
+ i2cbus=${NUM_MUX_9548_2_CH4}
+ eeprombusbase=${NUM_MUX_9548_3_CH0}
+ gpioBase=$((${GPIO_OFFSET}+${ZQSFP_PORT0_ABS_GPIO_IDX}))
+ #gpioBase=${ZQSFP_PORT0_ABS_GPIO_IDX}
+ ;;
+ 9|10|11|12|13|14|15|16)
+ i2cbus=${NUM_MUX_9548_2_CH4}
+ eeprombusbase=${NUM_MUX_9548_4_CH0}
+ gpioBase=$((${GPIO_OFFSET}+${ZQSFP_PORT0_ABS_GPIO_IDX}))
+ #gpioBase=${ZQSFP_PORT0_ABS_GPIO_IDX}
+ ;;
+ 17|18|19|20|21|22|23|24)
+ i2cbus=${NUM_MUX_9548_2_CH4}
+ eeprombusbase=${NUM_MUX_9548_5_CH0}
+ gpioBase=$((${GPIO_OFFSET}+${ZQSFP_PORT16_ABS_GPIO_IDX}))
+ #gpioBase=${ZQSFP_PORT16_ABS_GPIO_IDX}
+ ;;
+ 25|26|27|28|29|30|31|32)
+ i2cbus=${NUM_MUX_9548_2_CH4}
+ eeprombusbase=${NUM_MUX_9548_6_CH0}
+ gpioBase=$((${GPIO_OFFSET}+${ZQSFP_PORT16_ABS_GPIO_IDX}))
+ #gpioBase=${ZQSFP_PORT16_ABS_GPIO_IDX}
+ ;;
+ *)
+ echo "Please input 1~32"
+ exit
+ ;;
+ esac
+}
+
+#Set QSFP Port variable
+function _qsfp_eeprom_var_set {
+ local port=$1
+ # port 1 => zqsfp0
+ # port 2 => zqsfp1
+ # ...
+ eeprombusidx=$(( (${port} - 1) % 8))
+ eeprombus=$(( ${eeprombusbase} + ${eeprombusidx} ))
+ eepromAddr=${I2C_ADDR_QSFP_EEPROM}
+}
+
+#Get QSFP EEPROM Information
+function _i2c_qsfp_eeprom_get {
+
+ # input parameter validation
+ _util_input_check "${QSFP_PORT}" "${MIN_PORT_NUM}" "${MAX_PORT_NUM}"
+
+ _util_get_qsfp_abs
+
+ if [ $status = 0 ]; then
+ exit
+ fi
+
+ _qsfp_eeprom_var_set ${QSFP_PORT}
+
+ cat ${PATH_SYS_I2C_DEVICES}/$eeprombus-$(printf "%04x" $eepromAddr)/eeprom | hexdump -C
+}
+
+#Init QSFP EEPROM
+function _i2c_qsfp_eeprom_init {
+ echo "QSFP EEPROM INIT..."
+
+ #Action check
+ action=$1
+ if [ -z "${action}" ]; then
+ echo "No action, skip"
+ return
+ elif [ "${action}" != "new" ] && [ "${action}" != "delete" ]; then
+ echo "Error action, skip"
+ return
+ fi
+
+ #Init 1-32 ports EEPROM
+ local i
+ for i in {1..32};
+ do
+ _qsfp_port_i2c_var_set ${i}
+
+ _qsfp_eeprom_var_set ${i}
+
+ if [ "${action}" == "new" ] && \
+ ! [ -L ${PATH_SYS_I2C_DEVICES}/$eeprombus-$(printf "%04x" $eepromAddr) ]; then
+ echo "sff8436 $eepromAddr" > ${PATH_SYS_I2C_DEVICES}/i2c-$eeprombus/new_device
+ elif [ "${action}" == "delete" ] && \
+ [ -L ${PATH_SYS_I2C_DEVICES}/$eeprombus-$(printf "%04x" $eepromAddr) ]; then
+ echo "$eepromAddr" > ${PATH_SYS_I2C_DEVICES}/i2c-$eeprombus/delete_device
+ fi
+ done
+ echo "Done"
+}
+
+#Init Main Board EEPROM
+function _i2c_mb_eeprom_init {
+ echo -n "Main Board EEPROM INIT..."
+
+ #Action check
+ action=$1
+ if [ -z "${action}" ]; then
+ echo "No action, skip"
+ return
+ elif [ "${action}" != "new" ] && [ "${action}" != "delete" ]; then
+ echo "Error action, skip"
+ return
+ fi
+
+ #Init mb EEPROM
+ if [ "${action}" == "new" ] && \
+ ! [ -L ${PATH_SYS_I2C_DEVICES}/${I2C_BUS_MB_EEPROM}-$(printf "%04x" $I2C_ADDR_MB_EEPROM) ]; then
+ echo "mb_eeprom ${I2C_ADDR_MB_EEPROM}" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_MB_EEPROM}/new_device
+ elif [ "${action}" == "delete" ] && \
+ [ -L ${PATH_SYS_I2C_DEVICES}/${I2C_BUS_MB_EEPROM}-$(printf "%04x" $I2C_ADDR_MB_EEPROM) ]; then
+ echo "$I2C_ADDR_MB_EEPROM" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_MB_EEPROM}/delete_device
+ fi
+ echo "Done"
+}
+
+#Init CPU Board EEPROM
+function _i2c_cb_eeprom_init {
+ echo -n "CPU Board EEPROM INIT..."
+
+ #Action check
+ action=$1
+ if [ -z "${action}" ]; then
+ echo "No action, skip"
+ return
+ elif [ "${action}" != "new" ] && [ "${action}" != "delete" ]; then
+ echo "Error action, skip"
+ return
+ fi
+
+ #Init cpu EEPROM
+ if [ "${action}" == "new" ] && \
+ ! [ -L ${PATH_SYS_I2C_DEVICES}/${I2C_BUS_CB_EEPROM}-$(printf "%04x" $I2C_ADDR_CB_EEPROM) ]; then
+ echo "mb_eeprom ${I2C_ADDR_CB_EEPROM}" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_CB_EEPROM}/new_device
+ elif [ "${action}" == "delete" ] && \
+ [ -L ${PATH_SYS_I2C_DEVICES}/${I2C_BUS_CB_EEPROM}-$(printf "%04x" $I2C_ADDR_CB_EEPROM) ]; then
+ echo "$I2C_ADDR_CB_EEPROM" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_CB_EEPROM}/delete_device
+ fi
+ echo "Done"
+}
+
+
+#get QSFP Status
+function _i2c_qsfp_status_get {
+
+ # input parameter validation
+ _util_input_check "${QSFP_PORT}" "${MIN_PORT_NUM}" "${MAX_PORT_NUM}"
+
+ local stat
+ _util_get_qsfp_abs
+ echo "status=$status"
+}
+
+#get QSFP Type
+function _i2c_qsfp_type_get {
+
+ # input parameter validation
+ _util_input_check "${QSFP_PORT}" "${MIN_PORT_NUM}" "${MAX_PORT_NUM}"
+
+ _qsfp_port_i2c_var_set ${QSFP_PORT}
+
+ _qsfp_eeprom_var_set ${QSFP_PORT}
+
+ #Get QSFP EEPROM info
+ qsfp_info=$(base64 ${PATH_SYS_I2C_DEVICES}/$eeprombus-$(printf "%04x" $eepromAddr)/eeprom)
+
+ identifier=$(echo $qsfp_info | base64 -d -i | hexdump -s 128 -n 1 -e '"%x"')
+ connector=$(echo $qsfp_info | base64 -d -i | hexdump -s 130 -n 1 -e '"%x"')
+ transceiver=$(echo $qsfp_info | base64 -d -i | hexdump -s 131 -n 1 -e '"%x"')
+
+ echo "identifier=$identifier"
+ echo "connector=$connector"
+ echo "transceiver=$transceiver"
+}
+
+#Init PSU Kernel Module
+function _i2c_psu_init {
+ echo "========================================================="
+ echo "# Description: I2C PSU Init"
+ echo "========================================================="
+ modprobe ingrasys_s9130_32x_psu
+
+ echo "psu1 ${I2C_ADDR_PSU1_EEPROM}" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_PSU1_EEPROM}/new_device
+ echo "psu2 ${I2C_ADDR_PSU2_EEPROM}" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_PSU2_EEPROM}/new_device
+}
+
+#Get PSU EEPROM Information
+function _i2c_psu_eeprom_get {
+ local eeprom_psu1=""
+ local eeprom_psu2=""
+
+ echo "========================================================="
+ echo "# Description: I2C PSU EEPROM Get..."
+ echo "========================================================="
+
+ eeprom_psu1="${PATH_SYSFS_PSU1}/psu_eeprom"
+ cat ${eeprom_psu1} | hexdump -C
+
+ eeprom_psu2="${PATH_SYSFS_PSU2}/psu_eeprom"
+ cat ${eeprom_psu2} | hexdump -C
+}
+
+#Get Main Board EEPROM Information
+function _i2c_mb_eeprom_get {
+ echo "========================================================="
+ echo "# Description: I2C MB EEPROM Get..."
+ echo "========================================================="
+ _i2c_sys_eeprom_get mb
+}
+
+#Get CPU Board EEPROM Information
+function _i2c_cb_eeprom_get {
+ echo "========================================================="
+ echo "# Description: I2C CB EEPROM Get..."
+ echo "========================================================="
+ _i2c_sys_eeprom_get cb
+}
+
+#Get system EEPROM Information
+##input: "cb" for cpu board, "mb" for main board
+function _i2c_sys_eeprom_get {
+ local eeprom_dev
+
+ if [ "$1" == "cb" ]; then
+ eeprom_dev="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_CB_EEPROM}-$(printf "%04x" $I2C_ADDR_CB_EEPROM)/eeprom"
+ elif [ "$1" == "mb" ]; then
+ eeprom_dev="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_MB_EEPROM}-$(printf "%04x" $I2C_ADDR_MB_EEPROM)/eeprom"
+ else
+ echo "wrong eeprom type"
+ return
+ fi
+
+ # check if eeprom device exist in sysfs
+ if [ ! -f ${eeprom_dev} ]; then
+ echo "eeprom device not init"
+ return
+ fi
+
+ cat ${eeprom_dev} | hexdump -C
+ echo "Done"
+}
+
+#sync eeprom content between mb and cb eeprom
+function _i2c_eeprom_sync {
+ echo "========================================================="
+ echo "# Description: EEPROM sync..."
+ echo "========================================================="
+
+ local mb_eeprom_dev="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_MB_EEPROM}-$(printf "%04x" $I2C_ADDR_MB_EEPROM)/eeprom"
+ local cb_eeprom_dev="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_CB_EEPROM}-$(printf "%04x" $I2C_ADDR_CB_EEPROM)/eeprom"
+
+ # check if eeprom device exist in sysfs
+ if [[ ! -f ${mb_eeprom_dev} || ! -f ${cb_eeprom_dev} ]]; then
+ echo "eeprom device not init"
+ return
+ fi
+
+ ## check if MB eeprom is empty
+ if [ ! -z "$(cat ${mb_eeprom_dev} | hexdump -n2 | grep ffff)" ]; then
+ echo "copy cb eeprom to mb eeprom..."
+ cat ${cb_eeprom_dev} > ${mb_eeprom_dev}
+ else
+ echo "no need to sync"
+ fi
+
+ echo "Done"
+}
+
+#Set System Status LED
+function _i2c_sys_led {
+ # only green/amber, on/off can't control
+ if [ "${COLOR_LED}" == "green" ]; then
+ # set sys_led_g (0.7) = 1
+ output_reg=${REG_PORT0_OUT}
+ mask=0x80
+ value=0x80
+ elif [ "${COLOR_LED}" == "amber" ]; then
+ # set sys_led_g (0.7) = 0
+ output_reg=${REG_PORT0_OUT}
+ mask=0x80
+ value=0x00
+ else
+ echo "Invalid Parameters, Exit!!!"
+ _help
+ exit ${FALSE}
+ fi
+
+ #apply to io expander
+ _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value}
+ echo "Done"
+}
+
+#Set FAN LED
+function _i2c_fan_led {
+ if [ "${COLOR_LED}" == "green" ] && [ "${ONOFF_LED}" == "on" ]; then
+ # set fan_led_en (0.6) = 1 & fan_led_y (0.5) = 0
+ output_reg=${REG_PORT0_OUT}
+ mask=0x60
+ value=0x40
+ elif [ "${COLOR_LED}" == "green" ] && [ "${ONOFF_LED}" == "off" ]; then
+ # set fan_led_en (0.6) = 0 & fan_led_y (0.5) = 0
+ output_reg=${REG_PORT0_OUT}
+ mask=0x60
+ value=0x00
+ elif [ "${COLOR_LED}" == "amber" ] && [ "${ONOFF_LED}" == "on" ]; then
+ # set fan_led_en (0.6) = 1 & fan_led_y (0.5) = 1
+ output_reg=${REG_PORT0_OUT}
+ mask=0x60
+ value=0x60
+ elif [ "${COLOR_LED}" == "amber" ] && [ "${ONOFF_LED}" == "off" ]; then
+ # set fan_led_en (0.6) = 0 & fan_led_y (0.5) = 1
+ output_reg=${REG_PORT0_OUT}
+ mask=0x60
+ value=0x20
+ else
+ echo "Invalid Parameters, Exit!!!"
+ _help
+ exit ${FALSE}
+ fi
+
+ #apply to io expander
+ _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value}
+ echo "Done"
+}
+
+#Set PSU1 LED
+function _i2c_psu1_led {
+ if [ "${COLOR_LED}" == "green" ] && [ "${ONOFF_LED}" == "on" ]; then
+ # set psu1_pwr_ok_oe (0.4) = 1 & psu1_led_y (0.3) = 0
+ output_reg=${REG_PORT0_OUT}
+ mask=0x18
+ value=0x10
+ elif [ "${COLOR_LED}" == "green" ] && [ "${ONOFF_LED}" == "off" ]; then
+ # set psu1_pwr_ok_oe (0.4) = 0 & psu1_led_y (0.3) = 0
+ output_reg=${REG_PORT0_OUT}
+ mask=0x18
+ value=0x00
+ elif [ "${COLOR_LED}" == "amber" ] && [ "${ONOFF_LED}" == "on" ]; then
+ # set psu1_pwr_ok_oe (0.4) = 1 & psu1_led_y (0.3) = 1
+ output_reg=${REG_PORT0_OUT}
+ mask=0x18
+ value=0x18
+ elif [ "${COLOR_LED}" == "amber" ] && [ "${ONOFF_LED}" == "off" ]; then
+ # set psu1_pwr_ok_oe (0.4) = 0 & psu1_led_y (0.3) = 1
+ output_reg=${REG_PORT0_OUT}
+ mask=0x18
+ value=0x08
+ else
+ echo "Invalid Parameters, Exit!!!"
+ _help
+ exit ${FALSE}
+ fi
+
+ #apply to io expander
+ _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value}
+ echo "Done"
+}
+
+#Set PSU2 LED
+function _i2c_psu2_led {
+ if [ "${COLOR_LED}" == "green" ] && [ "${ONOFF_LED}" == "on" ]; then
+ # set psu0_pwr_ok_oe (0.2) = 1 & psu0_led_y (0.1) = 0
+ output_reg=${REG_PORT0_OUT}
+ mask=0x06
+ value=0x04
+ elif [ "${COLOR_LED}" == "green" ] && [ "${ONOFF_LED}" == "off" ]; then
+ # set psu0_pwr_ok_oe (0.2) = 0 & psu0_led_y (0.1) = 0
+ output_reg=${REG_PORT0_OUT}
+ mask=0x06
+ value=0x00
+ elif [ "${COLOR_LED}" == "amber" ] && [ "${ONOFF_LED}" == "on" ]; then
+ # set psu0_pwr_ok_oe (0.2) = 1 & psu0_led_y (0.1) = 1
+ output_reg=${REG_PORT0_OUT}
+ mask=0x06
+ value=0x06
+ elif [ "${COLOR_LED}" == "amber" ] && [ "${ONOFF_LED}" == "off" ]; then
+ # set psu0_pwr_ok_oe (0.2) = 0 & psu0_led_y (0.1) = 1
+ output_reg=${REG_PORT0_OUT}
+ mask=0x06
+ value=0x02
+ else
+ echo "Invalid Parameters, Exit!!!"
+ _help
+ exit ${FALSE}
+ fi
+
+ #apply to io expander
+ _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value}
+ echo "Done"
+}
+
+#Set FAN Tray LED
+function _i2c_fan_tray_led {
+
+ i2cAddr=${I2C_ADDR_MUX_9535_11}
+ output_reg=${REG_PORT0_OUT}
+
+ case ${FAN_TRAY} in
+ 4)
+ output_reg=${REG_PORT0_OUT}
+ if [ "${COLOR_LED}" == "green" ]; then
+ mask=0x01
+ elif [ "${COLOR_LED}" == "amber" ]; then
+ mask=0x02
+ fi
+ ;;
+ 3)
+ output_reg=${REG_PORT0_OUT}
+ if [ "${COLOR_LED}" == "green" ]; then
+ mask=0x10
+ elif [ "${COLOR_LED}" == "amber" ]; then
+ mask=0x20
+ fi
+ ;;
+ 2)
+ output_reg=${REG_PORT1_OUT}
+ if [ "${COLOR_LED}" == "green" ]; then
+ mask=0x01
+ elif [ "${COLOR_LED}" == "amber" ]; then
+ mask=0x02
+ fi
+ ;;
+ 1)
+ output_reg=${REG_PORT1_OUT}
+ if [ "${COLOR_LED}" == "green" ]; then
+ mask=0x10
+ elif [ "${COLOR_LED}" == "amber" ]; then
+ mask=0x20
+ fi
+ ;;
+ *)
+ echo "Please input 1~4"
+ exit
+ ;;
+ esac
+
+ if [ "${COLOR_LED}" == "green" ] && [ "${ONOFF_LED}" == "on" ]; then
+ _util_i2cset -m $mask -y -r ${I2C_BUS_FANTRAY_LED} $i2cAddr ${output_reg} 0x00
+ elif [ "${COLOR_LED}" == "green" ] && [ "${ONOFF_LED}" == "off" ]; then
+ _util_i2cset -m $mask -y -r ${I2C_BUS_FANTRAY_LED} $i2cAddr ${output_reg} 0x33
+ elif [ "${COLOR_LED}" == "amber" ] && [ "${ONOFF_LED}" == "on" ]; then
+ _util_i2cset -m $mask -y -r ${I2C_BUS_FANTRAY_LED} $i2cAddr ${output_reg} 0x00
+ elif [ "${COLOR_LED}" == "amber" ] && [ "${ONOFF_LED}" == "off" ]; then
+ _util_i2cset -m $mask -y -r ${I2C_BUS_FANTRAY_LED} $i2cAddr ${output_reg} 0x33
+ else
+ echo "Invalid Parameters, Exit!!!"
+ _help
+ exit ${FALSE}
+ fi
+
+ echo "Done"
+}
+
+#Get Board Version and Type
+function _i2c_board_type_get {
+ # read input port 1 value from io expander
+ input_reg=${REG_PORT1_IN}
+ boardType=`i2cget -y ${I2C_BUS_HW_ID} ${I2C_ADDR_MUX_9539_0} ${input_reg}`
+ boardBuildRev=$((($boardType) & 0x03))
+ boardHwRev=$((($boardType) >> 2 & 0x03))
+ boardId=$((($boardType) >> 4))
+ printf "MAIN_BOARD BOARD_ID is 0x%02x, HW Rev %d, Build Rev %d\n" $boardId $boardHwRev $boardBuildRev
+}
+
+#Get BMC Board Version and Type
+function _i2c_bmc_board_type_get {
+ # read input port 1 value from io expander
+ input_reg=${REG_PORT1_IN}
+ boardType=`i2cget -y ${I2C_BUS_BMC_HW_ID} ${I2C_ADDR_MUX_9555_12} ${input_reg}`
+ boardBuildRev=$((($boardType) & 0x03))
+ boardHwRev=$((($boardType) >> 2 & 0x03))
+ boardId=$((($boardType) >> 4))
+ printf "BMC_BOARD BOARD_ID is 0x%02x, HW Rev %d, Build Rev %d\n" $boardId $boardHwRev $boardBuildRev
+}
+
+#Get PSU Status
+function _i2c_psu_status {
+ local psu_abs=""
+
+ psu1PwGood=`cat ${PATH_SYSFS_PSU1}/psu_pg`
+ psu_abs=`cat ${PATH_SYSFS_PSU1}/psu_abs`
+ if [ "$psu_abs" == "0" ]; then
+ psu1Exist=1
+ else
+ psu1Exist=0
+ fi
+
+ psu2PwGood=`cat ${PATH_SYSFS_PSU2}/psu_pg`
+ psu_abs=`cat ${PATH_SYSFS_PSU2}/psu_abs`
+ if [ "$psu_abs" == "0" ]; then
+ psu2Exist=1
+ else
+ psu2Exist=0
+ fi
+
+ printf "PSU1 Exist:%x PSU1 PW Good:%d\n" $psu1Exist $psu1PwGood
+ printf "PSU2 Exist:%d PSU2 PW Good:%d\n" $psu2Exist $psu2PwGood
+}
+
+#util functions
+function _util_i2cset {
+ if [ "$DEBUG" == "on" ]; then
+ i2cset $@
+ else
+ i2cset $@ 1>/dev/null
+ fi
+}
+
+function _util_rmmod {
+ local mod=$1
+ [ "$(lsmod | grep "^$mod ")" != "" ] && rmmod $mod
+}
+
+# get qsfp presence
+function _util_get_qsfp_abs {
+ _qsfp_port_i2c_var_set ${QSFP_PORT}
+
+ #status: 0 -> Down, 1 -> Up (ACTIVE_LOW_EN)
+ status=`cat /sys/class/gpio/gpio$(( $(($gpioBase + (${QSFP_PORT} - 1) % 16 )) ))/value`
+}
+
+# gpio init util function
+function _util_gpio_export {
+ local gpio_n=$1
+ local direction=$2
+ local active_low=$3
+ local value=$4
+
+ if [ -z "${gpio_n}" ]; then
+ echo "[gpio_init] gpio_n(${gpio_n}) is not provided"
+ return
+ fi
+ if [[ ${gpio_n} < 0 || ${gpio_n} > $(( 255+${GPIO_OFFSET} )) ]]; then
+ echo "[gpio_init] gpio_n(${gpio_n}) is invalid value"
+ return
+ fi
+
+ #export gpio
+ echo ${gpio_n} > /sys/class/gpio/export
+ #set gpio direction
+ echo ${direction} > /sys/class/gpio/gpio${gpio_n}/direction
+ #set gpio active_low
+ echo ${active_low} > /sys/class/gpio/gpio${gpio_n}/active_low
+ #set value
+ if [ ! -z "${value}" ]; then
+ echo ${value} > /sys/class/gpio/gpio${gpio_n}/value
+ fi
+}
+
+# valid input number
+function _util_input_check {
+ # input parameter validation
+ if [[ $1 -lt $2 || $1 -gt $3 ]]; then
+ echo "Please input number $2~$3"
+ exit
+ fi
+}
+
+#Increase read socket buffer for CoPP Test
+function _config_rmem {
+ echo "109430400" > /proc/sys/net/core/rmem_max
+}
+
+#Main Function
+function _main {
+ tart_time_str=`date`
+ start_time_sec=$(date +%s)
+
+ _set_gpio_offset
+ if [ "${EXEC_FUNC}" == "help" ]; then
+ _help
+ elif [ "${EXEC_FUNC}" == "i2c_init" ]; then
+ _i2c_init
+ elif [ "${EXEC_FUNC}" == "i2c_deinit" ]; then
+ _i2c_deinit
+ elif [ "${EXEC_FUNC}" == "i2c_fan_speed_init" ]; then
+ _i2c_fan_speed_init
+ elif [ "${EXEC_FUNC}" == "i2c_io_exp_init" ]; then
+ _i2c_io_exp_init
+ elif [ "${EXEC_FUNC}" == "i2c_gpio_init" ]; then
+ _i2c_gpio_init
+ elif [ "${EXEC_FUNC}" == "i2c_gpio_deinit" ]; then
+ _i2c_gpio_deinit
+ elif [ "${EXEC_FUNC}" == "i2c_led_test" ]; then
+ _i2c_led_test
+ elif [ "${EXEC_FUNC}" == "i2c_mb_eeprom_get" ]; then
+ _i2c_mb_eeprom_get
+ elif [ "${EXEC_FUNC}" == "i2c_cb_eeprom_get" ]; then
+ _i2c_cb_eeprom_get
+ elif [ "${EXEC_FUNC}" == "i2c_eeprom_sync" ]; then
+ _i2c_eeprom_sync
+ elif [ "${EXEC_FUNC}" == "i2c_psu_eeprom_get" ]; then
+ _i2c_psu_eeprom_get
+ elif [ "${EXEC_FUNC}" == "i2c_qsfp_eeprom_get" ]; then
+ _i2c_qsfp_eeprom_get
+ elif [ "${EXEC_FUNC}" == "i2c_qsfp_eeprom_init" ]; then
+ _i2c_qsfp_eeprom_init ${QSFP_ACTION}
+ elif [ "${EXEC_FUNC}" == "i2c_mb_eeprom_init" ]; then
+ _i2c_mb_eeprom_init ${MB_EEPROM_ACTION}
+ elif [ "${EXEC_FUNC}" == "i2c_cb_eeprom_init" ]; then
+ _i2c_cb_eeprom_init ${MB_EEPROM_ACTION}
+ elif [ "${EXEC_FUNC}" == "i2c_qsfp_status_get" ]; then
+ _i2c_qsfp_status_get
+ elif [ "${EXEC_FUNC}" == "i2c_qsfp_type_get" ]; then
+ _i2c_qsfp_type_get
+ elif [ "${EXEC_FUNC}" == "i2c_led_psu_status_set" ]; then
+ _i2c_led_psu_status_set
+ elif [ "${EXEC_FUNC}" == "i2c_led_fan_status_set" ]; then
+ _i2c_led_fan_status_set
+ elif [ "${EXEC_FUNC}" == "i2c_led_fan_tray_status_set" ]; then
+ _i2c_led_fan_tray_status_set
+ elif [ "${EXEC_FUNC}" == "i2c_sys_led" ]; then
+ _i2c_sys_led
+ elif [ "${EXEC_FUNC}" == "i2c_fan_led" ]; then
+ _i2c_fan_led
+ elif [ "${EXEC_FUNC}" == "i2c_fan_tray_led" ]; then
+ _i2c_fan_tray_led
+ elif [ "${EXEC_FUNC}" == "i2c_psu1_led" ]; then
+ _i2c_psu1_led
+ elif [ "${EXEC_FUNC}" == "i2c_psu2_led" ]; then
+ _i2c_psu2_led
+ elif [ "${EXEC_FUNC}" == "i2c_board_type_get" ]; then
+ _i2c_board_type_get
+ elif [ "${EXEC_FUNC}" == "i2c_bmc_board_type_get" ]; then
+ _i2c_bmc_board_type_get
+ elif [ "${EXEC_FUNC}" == "i2c_psu_status" ]; then
+ _i2c_psu_status
+ elif [ "${EXEC_FUNC}" == "i2c_test_all" ]; then
+ _i2c_init
+ _i2c_led_test
+ _i2c_psu_eeprom_get
+ _i2c_mb_eeprom_get
+ _i2c_cb_eeprom_get
+ _i2c_board_type_get
+ _i2c_bmc_board_type_get
+ _i2c_psu_status
+ else
+ echo "Invalid Parameters, Exit!!!"
+ _help
+ exit ${FALSE}
+ fi
+
+ if [ "$DEBUG" == "on" ]; then
+ echo "-----------------------------------------------------"
+ end_time_str=`date`
+ end_time_sec=$(date +%s)
+ diff_time=$[ ${end_time_sec} - ${start_time_sec} ]
+ echo "Start Time: ${start_time_str} (${start_time_sec})"
+ echo "End Time : ${end_time_str} (${end_time_sec})"
+ echo "Total Execution Time: ${diff_time} sec"
+
+ echo "done!!!"
+ fi
+}
+
+_main
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/utils/qsfp_monitor.sh b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/utils/qsfp_monitor.sh
new file mode 100755
index 0000000000..249f179216
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/utils/qsfp_monitor.sh
@@ -0,0 +1,104 @@
+#!/bin/bash
+# Copyright (C) 2017 Ingrasys, 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 .
+
+INTERVAL=3
+I2C_UTILS="/usr/sbin/i2c_utils.sh"
+QSFP_SI_SCRIPT="/usr/sbin/qsfp_si_cfg.sh"
+QSFP_ARRAY=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
+
+#QSFP SI monitor
+function _qsfp_si_monitor {
+ local i
+ local status
+ for i in {0..31};
+ do
+ status=`${I2C_UTILS} i2c_qsfp_status_get $(expr $i + 1) | egrep '^status=.*$' | sed -e 's/status=//g'`
+ if [ "${status}" == "1" ]; then
+ _qsfp_type_check $i
+ fi
+ done
+}
+
+#QSFP type
+function _qsfp_type_check {
+ local port=$1
+ local qsfp_type=`${I2C_UTILS} i2c_qsfp_type_get $(expr $port + 1)`
+ local identifier=`echo "$qsfp_type" | grep '^identifier=.*$' | sed -e 's/identifier=//g'`
+ if [ "${identifier}" == "11" ]; then
+ connector=`echo "$qsfp_type" | grep '^connector=.*$' | sed -e 's/connector=//g'`
+ case ${connector} in
+ 21|23)
+ #DAC
+ if [ "${QSFP_ARRAY[$port]}" != "${connector}" ]; then
+ echo "Change Port $(expr $port + 1) to DAC"
+ QSFP_ARRAY[$port]=${connector}
+ ${QSFP_SI_SCRIPT} dac $port >/dev/null
+ fi
+ ;;
+ *)
+ #Optical
+ if [ "${QSFP_ARRAY[$port]}" != "${connector}" ]; then
+ echo "Change Port $(expr $port + 1) to Optical"
+ QSFP_ARRAY[$port]=${connector}
+ ${QSFP_SI_SCRIPT} optical $port >/dev/null
+ fi
+ ;;
+ esac
+ fi
+}
+
+#Docker exist check
+function _docker_swss_check {
+ while true
+ do
+ # Check if syncd starts
+ result=`docker exec -i swss bash -c "echo -en \"SELECT 1\\nHLEN HIDDEN\" | redis-cli | sed -n 2p"` #TBD FIX ME
+ if [ "$result" == "3" ]; then
+ return
+ fi
+ sleep $INTERVAL
+ done
+}
+
+#Docker exist check
+function _qsfp_si_cfg_script_check {
+
+ if [ -f ${QSFP_SI_SCRIPT} ] && [ -x ${QSFP_SI_SCRIPT} ]; then
+ echo "SI Script exists. Start monitor."
+ return
+ else
+ echo "SI Script not exist. Exit monitor."
+ exit
+ fi
+}
+
+# main function
+function _main {
+ #Check SI Script
+ _qsfp_si_cfg_script_check
+ #Check docker swss is running
+ _docker_swss_check
+ while true
+ do
+ _qsfp_si_monitor
+ # Sleep while still handling signals
+ sleep $INTERVAL &
+ wait $!
+ done
+}
+
+_main
+
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/utils/s9130_32x_monitor.sh b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/utils/s9130_32x_monitor.sh
new file mode 100755
index 0000000000..974da6d500
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/s9130-32x/utils/s9130_32x_monitor.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+# Copyright (C) 2016 Ingrasys, 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 .
+
+INTERVAL=5
+I2C_UTILS="/usr/sbin/i2c_utils.sh"
+
+
+# LED status monitor
+function _led_monitor {
+ ${I2C_UTILS} i2c_led_fan_status_set >/dev/null
+ ${I2C_UTILS} i2c_led_psu_status_set >/dev/null
+ ${I2C_UTILS} i2c_led_fan_tray_status_set >/dev/null
+}
+
+# main function
+function _main {
+ while true
+ do
+ _led_monitor
+ # Sleep while still handling signals
+ sleep $INTERVAL &
+ wait $!
+ done
+}
+
+_main
\ No newline at end of file
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/README.md b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/README.md
new file mode 100644
index 0000000000..d1a2d5464a
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/README.md
@@ -0,0 +1,182 @@
+# Ingrasys S9230-64X Platform Driver for SONiC
+
+Copyright (C) 2016 Ingrasys, 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 .
+
+
+## Licensing terms
+
+The Licensing terms of the files within this project is split 2 parts.
+The Linux kernel is released under the GNU General Public License version 2.
+All other code is released under the GNU General Public License version 3.
+Please see the LICENSE file for copies of both licenses.
+
+## Contents of this package
+
+ - service/
+ > Service config files for platform initialization and monitoring
+ - utils/
+ > Scripts useful during platform bringup and sysfs function
+ - conf/
+ > Platform configure files.
+
+## Kernel modules and drivers
+
+The driver for interacting with Ingrasys S9230-64X is contained in the I2C
+kernel module and initialization script. The initialization script loads
+the modules in the correct order. It has been built and tested against
+the Linux 3.16 kernel.
+
+The initialization script will modprobe the needed modules, navigate to the
+module's device directory in sysfs, and write configuration data to
+the kernel module.
+
+### IGB
+
+This is OOB Ports on front panel for management plane.
+
+The IGB module must be loaded first on Ingrasys S9230-64X platform.
+
+### I2C i801
+
+The I2C i801 on Ingrasys S9230-64X can be found in
+`/sys/bus/i2c/devices/i2c-0/`
+
+This is I2C bus for power monitor, FAN controller, HWM and thermal sensors.
+
+### I2C PCA9548
+The PCA9548 module on S9230-64X can be found in
+`/sys/bus/i2c/devices/i2c-1/` , `/sys/bus/i2c/devices/i2c-2/`,
+`/sys/bus/i2c/devices/i2c-3/`, `/sys/bus/i2c/devices/i2c-4/`,
+`/sys/bus/i2c/devices/i2c-5/`, `/sys/bus/i2c/devices/i2c-6/`,
+`/sys/bus/i2c/devices/i2c-7/`, `/sys/bus/i2c/devices/i2c-8/`
+
+The pca9548 module for CPLD get/set functions, PSU information,
+fan status and EEPROM.
+
+## Hardware components
+
+The hardware components are initialized in the init script on S9230-64X.
+The following describes manual initialization as well as interaction.
+The examples below are just for Ingrasys S9230-64X platform.
+
+### Hardware initialization
+
+When the sonic-platform-ingrasys-s9230-64X package is installed on the S9230-64X,
+it is automatically initialized. If you want to manual initialization, the
+utility command usage as follows:
+```
+ i2c_utils.sh i2c_init
+```
+
+### EEPROM
+
+The EEPROM is including the board SKU, model name, vendor name, serial number,
+and other information can be accessed with the specific eeprom kernel module.
+After using `modprobe eeprom_mb` to detect the eeprom, it will show up in sysfs.
+
+The hexdump utility can be used to decode the raw output of the EEPROM.
+For example,
+```
+ bash# echo "mb_eeprom 0x55" > /sys/bus/i2c/devices/i2c-0/new_device
+ bash# cat /sys/bus/i2c/drivers/mb_eeprom/0-0055/eeprom | hexdump -C
+```
+
+### Front panel LEDs
+
+LEDs can be setup on/off by using i2c utility `/usr/sbin/i2c_utils.sh`.
+Utility function command usage as follows:
+
+```
+Status LED:
+ i2c_utils.sh i2c_sys_led green|amber
+
+Fan status LED:
+ i2c_utils.sh i2c_fan_led green|amber on|off
+
+PSU1 status LED:
+ i2c_utils.sh i2c_psu1_led green|amber on|off
+
+PSU2 status LED:
+ i2c_utils.sh i2c_psu2_led green|amber on|off
+
+```
+QSFP Module Port LEDs control by ASIC library.
+
+
+### Fan speed
+
+Fan speed are controlled by the w83795 kernel module.
+It can be found in `/sys/class/hwmon/hwmon7/device/`.
+If they were compiled as modules, you will need to modprobe w83795 for
+their sysfs entries to show up. Each fan has an `fan_input` file
+for reading the fan speed. And `pwm1` setting fan1 to fan4,
+`pwm2` setting fan5 to fan8.
+
+There is docker-platform-monitor container installed fancontrol package that can
+automatic control platform fan speed.
+
+
+### Temperature sensors
+
+There is docker-platform-monitor container installed lm-sensors package that can
+monitor platform temperature. And `sensors` command can show each
+temperature sensors status.
+
+### Power supplies
+
+Power supplies status and its EEPROM info can be used i2c utility
+`/usr/sbin/i2c_utils.sh` to get.
+The usage as follows:
+```
+PSU EEPROM:
+ i2c_utils.sh i2c_psu_eeprom_get
+ hexdump -C psu0.rom
+ hexdump -C psu1.rom
+
+PSU Status:
+ i2c_utils.sh i2c_psu_status
+```
+
+### QSFPs
+QSFP modules are managed by the CPLD 1~5 according to port number.
+The i2c utility `/usr/sbin/i2c_utils.sh` can be used to get status and
+module EEPROM informations.
+The usage as follows:
+```
+QSFP EEPROM:
+ i2c_utils.sh i2c_qsfp_eeprom_get [1-64]
+
+QSFP Insert Event:
+ i2c_utils.sh i2c_qsfp_status_get [1-64]
+ 0 => not insert
+ 1 => inserted
+```
+
+### SFP+
+SFP+ modules are managed by the CPLD 1~2 according to port number.
+The i2c utility `/usr/sbin/i2c_utils.sh` can be used to get status and
+module EEPROM informations.
+The usage as follows:
+```
+SFP EEPROM:
+ i2c_utils.sh i2c_sfp_eeprom_get [1-2]
+
+SFP Insert Event:
+ i2c_utils.sh i2c_sfp_status_get [1-2]
+ 0 => not insert
+ 1 => inserted
+```
+
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/Makefile b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/Makefile
new file mode 100755
index 0000000000..3107674e87
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/Makefile
@@ -0,0 +1,3 @@
+obj-m := eeprom_mb.o
+obj-m += ingrasys_s9230_64x_i2c_cpld.o
+obj-m += ingrasys_s9230_64x_psu.o
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/eeprom_mb.c b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/eeprom_mb.c
new file mode 100755
index 0000000000..528864d933
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/eeprom_mb.c
@@ -0,0 +1,267 @@
+/*
+ * Copyright (C) 1998, 1999 Frodo Looijaard and
+ * Philip Edelbrock
+ * Copyright (C) 2003 Greg Kroah-Hartman
+ * Copyright (C) 2003 IBM Corp.
+ * Copyright (C) 2004 Jean Delvare
+ *
+ * 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.
+ */
+
+/* enable dev_dbg print out */
+//#define DEBUG
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+
+/* Addresses to scan */
+static const unsigned short normal_i2c[] = { /*0x50, 0x51, 0x52, 0x53, 0x54,
+ 0x55, 0x56, 0x57,*/ I2C_CLIENT_END };
+
+/* Size of EEPROM in bytes */
+#define EEPROM_SIZE 512
+
+#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 mb_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 mb_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++) {
+ mb_eeprom_update_client(client, slice);
+ }
+
+ memcpy(buf, &data->data[off], count);
+
+ return count;
+}
+
+static ssize_t mb_eeprom_write(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);
+ int ret;
+ int i;
+ u8 cmd;
+ u16 value16;
+
+ dev_dbg(&client->dev, "mb_eeprom_write off=%d, count=%d\n", (int)off, (int)count);
+
+ if (off > EEPROM_SIZE) {
+ return 0;
+ }
+ if (off + count > EEPROM_SIZE) {
+ count = EEPROM_SIZE - off;
+ }
+ if (count == 0) {
+ return 0;
+ }
+
+ mutex_lock(&data->update_lock);
+
+ for(i=0; i < count; i++) {
+ /* write command */
+ cmd = (off >> 8) & 0xff;
+ value16 = off & 0xff;
+ value16 |= buf[i] << 8;
+ ret = i2c_smbus_write_word_data(client, cmd, value16);
+
+ if (ret < 0) {
+ dev_err(&client->dev, "write address failed at %d \n", (int)off);
+ goto exit;
+ }
+
+ off++;
+
+ /* need to wait for write complete */
+ udelay(10000);
+ }
+exit:
+ mutex_unlock(&data->update_lock);
+ /* force to update client when reading */
+ for(i=0; i < SLICE_NUM; i++) {
+ data->last_updated[i] = 0;
+ }
+
+ return count;
+}
+
+static struct bin_attribute mb_eeprom_attr = {
+ .attr = {
+ .name = "eeprom",
+ .mode = S_IRUGO | S_IWUSR,
+ },
+ .size = EEPROM_SIZE,
+ .read = mb_eeprom_read,
+ .write = mb_eeprom_write,
+};
+
+/* Return 0 if detection is successful, -ENODEV otherwise */
+static int mb_eeprom_detect(struct i2c_client *client, struct i2c_board_info *info)
+{
+ struct i2c_adapter *adapter = client->adapter;
+
+ /* EDID EEPROMs are often 24C00 EEPROMs, which answer to all
+ addresses 0x50-0x57, but we only care about 0x51 and 0x55. So decline
+ attaching to addresses >= 0x56 on DDC buses */
+ if (!(adapter->class & I2C_CLASS_SPD) && client->addr >= 0x56) {
+ return -ENODEV;
+ }
+
+ if (!i2c_check_functionality(adapter, I2C_FUNC_SMBUS_READ_BYTE)
+ && !i2c_check_functionality(adapter, I2C_FUNC_SMBUS_WRITE_BYTE_DATA)) {
+ return -ENODEV;
+ }
+
+ strlcpy(info->type, "eeprom", I2C_NAME_SIZE);
+
+ return 0;
+}
+
+static int mb_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, &mb_eeprom_attr);
+ if (err) {
+ goto exit_kfree;
+ }
+
+ return 0;
+
+exit_kfree:
+ kfree(data);
+exit:
+ return err;
+}
+
+static int mb_eeprom_remove(struct i2c_client *client)
+{
+ sysfs_remove_bin_file(&client->dev.kobj, &mb_eeprom_attr);
+ kfree(i2c_get_clientdata(client));
+
+ return 0;
+}
+
+static const struct i2c_device_id mb_eeprom_id[] = {
+ { "mb_eeprom", 0 },
+ { }
+};
+
+static struct i2c_driver mb_eeprom_driver = {
+ .driver = {
+ .name = "mb_eeprom",
+ },
+ .probe = mb_eeprom_probe,
+ .remove = mb_eeprom_remove,
+ .id_table = mb_eeprom_id,
+
+ .class = I2C_CLASS_DDC | I2C_CLASS_SPD,
+ .detect = mb_eeprom_detect,
+ .address_list = normal_i2c,
+};
+
+module_i2c_driver(mb_eeprom_driver);
+
+MODULE_AUTHOR("Wade ");
+MODULE_DESCRIPTION("Ingrasys Mother Borad EEPROM driver");
+MODULE_LICENSE("GPL");
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/ingrasys_s9230_64x_i2c_cpld.c b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/ingrasys_s9230_64x_i2c_cpld.c
new file mode 100644
index 0000000000..7d832fc014
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/ingrasys_s9230_64x_i2c_cpld.c
@@ -0,0 +1,1259 @@
+/*
+ * A i2c cpld driver for the ingrasys_s9230_64x
+ *
+ * Copyright (C) 2017 Ingrasys Technology Corporation.
+ * Leo Lin
+ *
+ * Based on ad7414.c
+ * Copyright 2006 Stefan Roese , DENX Software Engineering
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "ingrasys_s9230_64x_i2c_cpld.h"
+
+#ifdef DEBUG
+#define DEBUG_PRINT(fmt, args...) \
+ printk(KERN_INFO "%s:%s[%d]: " fmt "\r\n", \
+ __FILE__, __func__, __LINE__, ##args)
+#else
+#define DEBUG_PRINT(fmt, args...)
+#endif
+
+#define I2C_READ_BYTE_DATA(ret, lock, i2c_client, reg) \
+{ \
+ mutex_lock(lock); \
+ ret = i2c_smbus_read_byte_data(i2c_client, reg); \
+ mutex_unlock(lock); \
+}
+#define I2C_WRITE_BYTE_DATA(ret, lock, i2c_client, reg, val) \
+{ \
+ mutex_lock(lock); \
+ ret = i2c_smbus_write_byte_data(i2c_client, reg, val); \
+ mutex_unlock(lock); \
+}
+
+/* CPLD sysfs attributes index */
+enum s9230_64x_cpld_sysfs_attributes {
+ CPLD_ACCESS_REG,
+ CPLD_REGISTER_VAL,
+ CPLD_PORT_START,
+ CPLD_PORTS,
+ CPLD_VERSION,
+ CPLD_ID,
+ CPLD_BOARD_TYPE,
+ CPLD_EXT_BOARD_TYPE,
+ CPLD_QSFP_PORT_STATUS_1,
+ CPLD_QSFP_PORT_STATUS_2,
+ CPLD_QSFP_PORT_STATUS_3,
+ CPLD_QSFP_PORT_STATUS_4,
+ CPLD_QSFP_PORT_STATUS_5,
+ CPLD_QSFP_PORT_STATUS_6,
+ CPLD_QSFP_PORT_STATUS_7,
+ CPLD_QSFP_PORT_STATUS_8,
+ CPLD_QSFP_PORT_STATUS_9,
+ CPLD_QSFP_PORT_STATUS_10,
+ CPLD_QSFP_PORT_STATUS_11,
+ CPLD_QSFP_PORT_STATUS_12,
+ CPLD_QSFP_PORT_STATUS_13,
+ CPLD_QSFP_PORT_CONFIG_1,
+ CPLD_QSFP_PORT_CONFIG_2,
+ CPLD_QSFP_PORT_CONFIG_3,
+ CPLD_QSFP_PORT_CONFIG_4,
+ CPLD_QSFP_PORT_CONFIG_5,
+ CPLD_QSFP_PORT_CONFIG_6,
+ CPLD_QSFP_PORT_CONFIG_7,
+ CPLD_QSFP_PORT_CONFIG_8,
+ CPLD_QSFP_PORT_CONFIG_9,
+ CPLD_QSFP_PORT_CONFIG_10,
+ CPLD_QSFP_PORT_CONFIG_11,
+ CPLD_QSFP_PORT_CONFIG_12,
+ CPLD_QSFP_PORT_CONFIG_13,
+ CPLD_QSFP_PORT_INTERRUPT,
+ CPLD_SFP_PORT_STATUS,
+ CPLD_SFP_PORT_CONFIG,
+ CPLD_10GMUX_CONFIG,
+ CPLD_BMC_STATUS,
+ CPLD_BMC_WATCHDOG,
+ CPLD_USB_STATUS,
+};
+
+/* CPLD sysfs attributes hook functions */
+static ssize_t read_access_register(struct device *dev,
+ struct device_attribute *da, char *buf);
+static ssize_t write_access_register(struct device *dev,
+ struct device_attribute *da, const char *buf, size_t count);
+static ssize_t read_register_value(struct device *dev,
+ struct device_attribute *da, char *buf);
+static ssize_t write_register_value(struct device *dev,
+ struct device_attribute *da, const char *buf, size_t count);
+static ssize_t get_qsfp_port_start(struct device *dev,
+ struct device_attribute *da, char *buf);
+static ssize_t get_qsfp_ports(struct device *dev,
+ struct device_attribute *da, char *buf);
+static ssize_t read_cpld_version(struct device *dev,
+ struct device_attribute *da, char *buf);
+static ssize_t read_cpld_id(struct device *dev,
+ struct device_attribute *da, char *buf);
+static ssize_t read_board_type(struct device *dev,
+ struct device_attribute *da, char *buf);
+static ssize_t read_ext_board_type(struct device *dev,
+ struct device_attribute *da, char *buf);
+static ssize_t read_qsfp_port_status(struct device *dev,
+ struct device_attribute *da, char *buf);
+static ssize_t read_qsfp_port_config(struct device *dev,
+ struct device_attribute *da, char *buf);
+static ssize_t write_qsfp_port_config(struct device *dev,
+ struct device_attribute *da, const char *buf, size_t count);
+static ssize_t read_qsfp_port_interrupt(struct device *dev,
+ struct device_attribute *da, char *buf);
+static ssize_t read_sfp_port_status(struct device *dev,
+ struct device_attribute *da, char *buf);
+static ssize_t read_sfp_port_config(struct device *dev,
+ struct device_attribute *da, char *buf);
+static ssize_t write_sfp_port_config(struct device *dev,
+ struct device_attribute *da, const char *buf, size_t count);
+static ssize_t read_10gmux_config(struct device *dev,
+ struct device_attribute *da, char *buf);
+static ssize_t write_10gmux_config(struct device *dev,
+ struct device_attribute *da, const char *buf, size_t count);
+static ssize_t read_bmc_status(struct device *dev,
+ struct device_attribute *da, char *buf);
+static ssize_t read_bmc_watchdog(struct device *dev,
+ struct device_attribute *da, char *buf);
+static ssize_t write_bmc_watchdog(struct device *dev,
+ struct device_attribute *da, const char *buf, size_t count);
+static ssize_t read_usb_status(struct device *dev,
+ struct device_attribute *da, char *buf);
+
+static LIST_HEAD(cpld_client_list); /* client list for cpld */
+static struct mutex list_lock; /* mutex for client list */
+
+struct cpld_client_node {
+ struct i2c_client *client;
+ struct list_head list;
+};
+
+struct cpld_data {
+ int index; /* CPLD index */
+ struct mutex access_lock; /* mutex for cpld access */
+ u8 access_reg; /* register to access */
+};
+
+/* CPLD device id and data */
+static const struct i2c_device_id ingrasys_i2c_cpld_id[] = {
+ { "ingrasys_cpld1", cpld1 },
+ { "ingrasys_cpld2", cpld2 },
+ { "ingrasys_cpld3", cpld3 },
+ { "ingrasys_cpld4", cpld4 },
+ { "ingrasys_cpld5", cpld5 },
+ {}
+};
+
+/* Addresses scanned for ingrasys_i2c_cpld */
+static const unsigned short cpld_i2c_addr[] = { 0x33, I2C_CLIENT_END };
+
+/* define all support register access of cpld in attribute */
+static SENSOR_DEVICE_ATTR(cpld_access_register, S_IWUSR | S_IRUGO,
+ read_access_register, write_access_register, CPLD_ACCESS_REG);
+static SENSOR_DEVICE_ATTR(cpld_register_value, S_IWUSR | S_IRUGO,
+ read_register_value, write_register_value, CPLD_REGISTER_VAL);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_start, S_IRUGO,
+ get_qsfp_port_start, NULL, CPLD_PORT_START);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_ports, S_IRUGO,
+ get_qsfp_ports, NULL, CPLD_PORTS);
+static SENSOR_DEVICE_ATTR(cpld_version, S_IRUGO,
+ read_cpld_version, NULL, CPLD_VERSION);
+static SENSOR_DEVICE_ATTR(cpld_id, S_IRUGO, read_cpld_id, NULL, CPLD_ID);
+static SENSOR_DEVICE_ATTR(cpld_board_type, S_IRUGO,
+ read_board_type, NULL, CPLD_BOARD_TYPE);
+static SENSOR_DEVICE_ATTR(cpld_ext_board_type, S_IRUGO,
+ read_ext_board_type, NULL, CPLD_EXT_BOARD_TYPE);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_1, S_IRUGO,
+ read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_1);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_2, S_IRUGO,
+ read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_2);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_3, S_IRUGO,
+ read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_3);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_4, S_IRUGO,
+ read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_4);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_5, S_IRUGO,
+ read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_5);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_6, S_IRUGO,
+ read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_6);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_7, S_IRUGO,
+ read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_7);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_8, S_IRUGO,
+ read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_8);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_9, S_IRUGO,
+ read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_9);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_10, S_IRUGO,
+ read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_10);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_11, S_IRUGO,
+ read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_11);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_12, S_IRUGO,
+ read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_12);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_status_13, S_IRUGO,
+ read_qsfp_port_status, NULL, CPLD_QSFP_PORT_STATUS_13);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_1, S_IWUSR | S_IRUGO,
+ read_qsfp_port_config, write_qsfp_port_config, CPLD_QSFP_PORT_CONFIG_1);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_2, S_IWUSR | S_IRUGO,
+ read_qsfp_port_config, write_qsfp_port_config,
+ CPLD_QSFP_PORT_CONFIG_2);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_3, S_IWUSR | S_IRUGO,
+ read_qsfp_port_config, write_qsfp_port_config,
+ CPLD_QSFP_PORT_CONFIG_3);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_4, S_IWUSR | S_IRUGO,
+ read_qsfp_port_config, write_qsfp_port_config,
+ CPLD_QSFP_PORT_CONFIG_4);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_5, S_IWUSR | S_IRUGO,
+ read_qsfp_port_config, write_qsfp_port_config,
+ CPLD_QSFP_PORT_CONFIG_5);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_6, S_IWUSR | S_IRUGO,
+ read_qsfp_port_config, write_qsfp_port_config,
+ CPLD_QSFP_PORT_CONFIG_6);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_7, S_IWUSR | S_IRUGO,
+ read_qsfp_port_config, write_qsfp_port_config,
+ CPLD_QSFP_PORT_CONFIG_7);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_8, S_IWUSR | S_IRUGO,
+ read_qsfp_port_config, write_qsfp_port_config,
+ CPLD_QSFP_PORT_CONFIG_8);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_9, S_IWUSR | S_IRUGO,
+ read_qsfp_port_config, write_qsfp_port_config,
+ CPLD_QSFP_PORT_CONFIG_9);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_10, S_IWUSR | S_IRUGO,
+ read_qsfp_port_config, write_qsfp_port_config,
+ CPLD_QSFP_PORT_CONFIG_10);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_11, S_IWUSR | S_IRUGO,
+ read_qsfp_port_config, write_qsfp_port_config,
+ CPLD_QSFP_PORT_CONFIG_11);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_12, S_IWUSR | S_IRUGO,
+ read_qsfp_port_config, write_qsfp_port_config,
+ CPLD_QSFP_PORT_CONFIG_12);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_config_13, S_IWUSR | S_IRUGO,
+ read_qsfp_port_config, write_qsfp_port_config,
+ CPLD_QSFP_PORT_CONFIG_13);
+static SENSOR_DEVICE_ATTR(cpld_qsfp_port_interrupt, S_IRUGO,
+ read_qsfp_port_interrupt, NULL, CPLD_QSFP_PORT_INTERRUPT);
+static SENSOR_DEVICE_ATTR(cpld_sfp_port_status, S_IRUGO,
+ read_sfp_port_status, NULL, CPLD_SFP_PORT_STATUS);
+static SENSOR_DEVICE_ATTR(cpld_sfp_port_config, S_IWUSR | S_IRUGO,
+ read_sfp_port_config, write_sfp_port_config, CPLD_SFP_PORT_CONFIG);
+static SENSOR_DEVICE_ATTR(cpld_10gmux_config, S_IWUSR | S_IRUGO,
+ read_10gmux_config, write_10gmux_config,
+ CPLD_10GMUX_CONFIG);
+static SENSOR_DEVICE_ATTR(cpld_bmc_status, S_IRUGO,
+ read_bmc_status, NULL, CPLD_BMC_STATUS);
+static SENSOR_DEVICE_ATTR(cpld_bmc_watchdog, S_IWUSR | S_IRUGO,
+ read_bmc_watchdog, write_bmc_watchdog,
+ CPLD_BMC_WATCHDOG);
+static SENSOR_DEVICE_ATTR(cpld_usb_status, S_IRUGO,
+ read_usb_status, NULL, CPLD_USB_STATUS);
+
+
+/* define support attributes of cpldx , total 5 */
+/* cpld 1 */
+static struct attribute *s9230_64x_cpld1_attributes[] = {
+ &sensor_dev_attr_cpld_access_register.dev_attr.attr,
+ &sensor_dev_attr_cpld_register_value.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_start.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_ports.dev_attr.attr,
+ &sensor_dev_attr_cpld_version.dev_attr.attr,
+ &sensor_dev_attr_cpld_id.dev_attr.attr,
+ &sensor_dev_attr_cpld_board_type.dev_attr.attr,
+ &sensor_dev_attr_cpld_ext_board_type.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_1.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_2.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_3.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_4.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_5.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_6.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_7.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_8.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_9.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_10.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_11.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_12.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_1.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_2.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_3.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_4.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_5.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_6.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_7.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_8.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_9.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_10.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_11.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_12.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_interrupt.dev_attr.attr,
+ &sensor_dev_attr_cpld_sfp_port_status.dev_attr.attr,
+ &sensor_dev_attr_cpld_sfp_port_config.dev_attr.attr,
+ &sensor_dev_attr_cpld_10gmux_config.dev_attr.attr,
+ &sensor_dev_attr_cpld_bmc_status.dev_attr.attr,
+ &sensor_dev_attr_cpld_bmc_watchdog.dev_attr.attr,
+ &sensor_dev_attr_cpld_usb_status.dev_attr.attr,
+ NULL
+};
+/* cpld 2 */
+static struct attribute *s9230_64x_cpld2_attributes[] = {
+ &sensor_dev_attr_cpld_access_register.dev_attr.attr,
+ &sensor_dev_attr_cpld_register_value.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_start.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_ports.dev_attr.attr,
+ &sensor_dev_attr_cpld_version.dev_attr.attr,
+ &sensor_dev_attr_cpld_id.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_1.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_2.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_3.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_4.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_5.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_6.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_7.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_8.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_9.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_10.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_11.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_12.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_13.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_1.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_2.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_3.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_4.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_5.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_6.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_7.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_8.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_9.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_10.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_11.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_12.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_13.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_interrupt.dev_attr.attr,
+ &sensor_dev_attr_cpld_sfp_port_status.dev_attr.attr,
+ &sensor_dev_attr_cpld_sfp_port_config.dev_attr.attr,
+ NULL
+};
+/* cpld 3 / cpld 4 / cpld 5 */
+static struct attribute *s9230_64x_cpld345_attributes[] = {
+&sensor_dev_attr_cpld_access_register.dev_attr.attr,
+ &sensor_dev_attr_cpld_register_value.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_start.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_ports.dev_attr.attr,
+ &sensor_dev_attr_cpld_version.dev_attr.attr,
+ &sensor_dev_attr_cpld_id.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_1.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_2.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_3.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_4.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_5.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_6.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_7.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_8.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_9.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_10.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_11.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_12.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_status_13.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_1.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_2.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_3.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_4.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_5.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_6.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_7.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_8.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_9.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_10.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_11.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_12.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_config_13.dev_attr.attr,
+ &sensor_dev_attr_cpld_qsfp_port_interrupt.dev_attr.attr,
+ NULL
+};
+
+/* cpld 1 attributes group */
+static const struct attribute_group s9230_64x_cpld1_group = {
+ .attrs = s9230_64x_cpld1_attributes,
+};
+/* cpld 2 attributes group */
+static const struct attribute_group s9230_64x_cpld2_group = {
+ .attrs = s9230_64x_cpld2_attributes,
+};
+/* cpld 3/4/5 attributes group */
+static const struct attribute_group s9230_64x_cpld345_group = {
+ .attrs = s9230_64x_cpld345_attributes,
+};
+
+/* read access register from cpld data */
+static ssize_t read_access_register(struct device *dev,
+ struct device_attribute *da,
+ char *buf)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct cpld_data *data = i2c_get_clientdata(client);
+ u8 reg = data->access_reg;
+
+ return sprintf(buf, "0x%x\n", reg);
+}
+
+/* write access register to cpld data */
+static ssize_t write_access_register(struct device *dev,
+ struct device_attribute *da,
+ const char *buf,
+ size_t count)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct cpld_data *data = i2c_get_clientdata(client);
+ u8 reg;
+
+ if (kstrtou8(buf, 0, ®) < 0)
+ return -EINVAL;
+
+ data->access_reg = reg;
+ return count;
+}
+
+/* read the value of access register in cpld data */
+static ssize_t read_register_value(struct device *dev,
+ struct device_attribute *da,
+ char *buf)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct cpld_data *data = i2c_get_clientdata(client);
+ u8 reg = data->access_reg;
+ int reg_val;
+
+ I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg);
+
+ if (reg_val < 0)
+ return -1;
+
+ return sprintf(buf, "0x%x\n", reg_val);
+}
+
+/* wrtie the value to access register in cpld data */
+static ssize_t write_register_value(struct device *dev,
+ struct device_attribute *da,
+ const char *buf,
+ size_t count)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct cpld_data *data = i2c_get_clientdata(client);
+ int ret = -EIO;
+ u8 reg = data->access_reg;
+ u8 reg_val;
+
+ if (kstrtou8(buf, 0, ®_val) < 0)
+ return -EINVAL;
+
+ I2C_WRITE_BYTE_DATA(ret, &data->access_lock, client, reg, reg_val);
+
+ return count;
+}
+
+/* get qsfp port start number of the cpld device */
+/* the start number use to tranlate qsfp port to cpld port */
+/* the cpld port use to access the qsfp port register in cpld */
+static ssize_t get_qsfp_port_start(struct device *dev,
+ struct device_attribute *da,
+ char *buf)
+{
+ 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 port_base_num;
+
+ if (attr->index == CPLD_PORT_START) {
+ if (data->index == cpld1) {
+ port_base_num = 1;
+ } else {
+ port_base_num = CPLD_1_PORT_NUM +
+ CPLD_2_PORT_NUM*(data->index - 1) + 1;
+ }
+ return sprintf(buf, "%d\n", port_base_num);
+ }
+ return -1;
+}
+
+/* get total qsfp port which contain register in the cpld device */
+static ssize_t get_qsfp_ports(struct device *dev,
+ struct device_attribute *da,
+ char *buf)
+{
+ 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 ports;
+
+ if (attr->index == CPLD_PORTS) {
+ if (data->index == cpld1)
+ ports = CPLD_1_PORT_NUM;
+ else
+ ports = CPLD_2_PORT_NUM;
+ return sprintf(buf, "%d\n", ports);
+ }
+ return -1;
+}
+
+/* get cpdl version register value */
+static ssize_t read_cpld_version(struct device *dev,
+ struct device_attribute *da,
+ char *buf)
+{
+ 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 reg;
+ int reg_val;
+
+ if (attr->index == CPLD_VERSION) {
+ reg = CPLD_VERSION_REG;
+ I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg);
+ if (reg_val < 0)
+ return -1;
+ return sprintf(buf, "0x%02x\n", reg_val);
+ }
+ return -1;
+}
+
+/* get cpdl id register value */
+static ssize_t read_cpld_id(struct device *dev,
+ struct device_attribute *da,
+ char *buf)
+{
+ 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 reg;
+ int reg_val;
+
+ if (attr->index == CPLD_ID) {
+ reg = CPLD_ID_REG;
+ I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg);
+ if (reg_val < 0)
+ return -1;
+ return sprintf(buf, "0x%02x\n", reg_val);
+ }
+ return -1;
+}
+
+/* get board type register value */
+static ssize_t read_board_type(struct device *dev,
+ struct device_attribute *da,
+ char *buf)
+{
+ 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 reg;
+ int reg_val;
+
+ if (attr->index == CPLD_BOARD_TYPE) {
+ reg = CPLD_BOARD_TYPE_REG;
+ I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg);
+ if (reg_val < 0)
+ return -1;
+ return sprintf(buf, "0x%02x\n", reg_val);
+ }
+ return -1;
+}
+
+/* get extend board type register value */
+static ssize_t read_ext_board_type(struct device *dev,
+ struct device_attribute *da,
+ char *buf)
+{
+ 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 reg;
+ int reg_val;
+
+ if (attr->index == CPLD_EXT_BOARD_TYPE) {
+ reg = CPLD_EXT_BOARD_TYPE_REG;
+ I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg);
+ if (reg_val < 0)
+ return -1;
+ return sprintf(buf, "0x%02x\n", reg_val);
+ }
+ return -1;
+}
+
+/* get qsfp port status register value */
+static ssize_t read_qsfp_port_status(struct device *dev,
+ struct device_attribute *da,
+ char *buf)
+{
+ 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 reg;
+ int reg_val;
+
+ if (attr->index >= CPLD_QSFP_PORT_STATUS_1 &&
+ attr->index <= CPLD_QSFP_PORT_STATUS_13) {
+ reg = CPLD_QSFP_PORT_STATUS_BASE_REG +
+ (attr->index - CPLD_QSFP_PORT_STATUS_1);
+ I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg);
+ if (reg_val < 0)
+ return -1;
+ return sprintf(buf, "0x%02x\n", reg_val);
+ }
+ return -1;
+}
+
+/* get qsfp port config register value */
+static ssize_t read_qsfp_port_config(struct device *dev,
+ struct device_attribute *da,
+ char *buf)
+{
+ 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 reg;
+ int reg_val;
+
+ if (attr->index >= CPLD_QSFP_PORT_CONFIG_1 &&
+ attr->index <= CPLD_QSFP_PORT_CONFIG_13) {
+ reg = CPLD_QSFP_PORT_CONFIG_BASE_REG +
+ (attr->index - CPLD_QSFP_PORT_CONFIG_1);
+ I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg);
+ if (reg_val < 0)
+ return -1;
+ return sprintf(buf, "0x%02x\n", reg_val);
+ }
+ return -1;
+}
+
+/* set value to qsfp port config register */
+static ssize_t write_qsfp_port_config(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);
+ u8 reg, reg_val;
+ int ret;
+
+ if (kstrtou8(buf, 0, ®_val) < 0)
+ return -EINVAL;
+
+ if (attr->index >= CPLD_QSFP_PORT_CONFIG_1 &&
+ attr->index <= CPLD_QSFP_PORT_CONFIG_13) {
+ reg = CPLD_QSFP_PORT_CONFIG_BASE_REG +
+ (attr->index - CPLD_QSFP_PORT_CONFIG_1);
+ I2C_WRITE_BYTE_DATA(ret, &data->access_lock,
+ client, reg, reg_val);
+ }
+ return count;
+}
+
+/* get qsfp port interrupt register value */
+static ssize_t read_qsfp_port_interrupt(struct device *dev,
+ struct device_attribute *da,
+ char *buf)
+{
+ 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 reg;
+ int reg_val;
+
+ if (attr->index == CPLD_QSFP_PORT_INTERRUPT) {
+ reg = CPLD_QSFP_PORT_INTERRUPT_REG;
+ I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg);
+ if (reg_val < 0)
+ return -1;
+ return sprintf(buf, "0x%02x\n", reg_val);
+ }
+ return -1;
+}
+
+/* get sfp port status register value */
+static ssize_t read_sfp_port_status(struct device *dev,
+ struct device_attribute *da,
+ char *buf)
+{
+ 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 reg;
+ int reg_val;
+
+ if (attr->index == CPLD_SFP_PORT_STATUS) {
+ reg = CPLD_SFP_PORT_STATUS_REG;
+ I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg);
+ if (reg_val < 0)
+ return -1;
+ return sprintf(buf, "0x%02x\n", reg_val);
+ }
+ return -1;
+}
+
+/* get sfp port config register value */
+static ssize_t read_sfp_port_config(struct device *dev,
+ struct device_attribute *da,
+ char *buf)
+{
+ 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 reg;
+ int reg_val;
+
+ if (attr->index == CPLD_SFP_PORT_CONFIG) {
+ reg = CPLD_SFP_PORT_CONFIG_REG;
+ I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg);
+ if (reg_val < 0)
+ return -1;
+ return sprintf(buf, "0x%02x\n", reg_val);
+ }
+ return -1;
+}
+
+/* set value to sfp port config register */
+static ssize_t write_sfp_port_config(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);
+ u8 reg, reg_val;
+ int ret;
+
+ if (kstrtou8(buf, 0, ®_val) < 0)
+ return -EINVAL;
+
+ if (attr->index == CPLD_SFP_PORT_CONFIG) {
+ reg = CPLD_SFP_PORT_CONFIG_REG;
+ I2C_WRITE_BYTE_DATA(ret, &data->access_lock,
+ client, reg, reg_val);
+ }
+ return count;
+}
+
+/* get 10g mux config register value */
+static ssize_t read_10gmux_config(struct device *dev,
+ struct device_attribute *da,
+ char *buf)
+{
+ 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 reg;
+ int reg_val;
+
+ if (attr->index == CPLD_10GMUX_CONFIG) {
+ reg = CPLD_10GMUX_CONFIG_REG;
+ I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg);
+ if (reg_val < 0)
+ return -1;
+ return sprintf(buf, "0x%02x\n", reg_val);
+ }
+ return -1;
+}
+
+/* set value to 10g mux config register */
+static ssize_t write_10gmux_config(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);
+ u8 reg, reg_val;
+ int ret;
+
+ if (kstrtou8(buf, 0, ®_val) < 0)
+ return -EINVAL;
+
+ if (attr->index == CPLD_10GMUX_CONFIG) {
+ reg = CPLD_10GMUX_CONFIG_REG;
+ I2C_WRITE_BYTE_DATA(ret, &data->access_lock,
+ client, reg, reg_val);
+ }
+ return count;
+}
+
+/* get bmc status register value */
+static ssize_t read_bmc_status(struct device *dev,
+ struct device_attribute *da,
+ char *buf)
+{
+ 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 reg;
+ int reg_val;
+
+ if (attr->index == CPLD_BMC_STATUS) {
+ reg = CPLD_BMC_STATUS_REG;
+ I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg);
+ if (reg_val < 0)
+ return -1;
+ return sprintf(buf, "0x%02x\n", reg_val);
+ }
+ return -1;
+}
+
+/* get bmc watchdog register value */
+static ssize_t read_bmc_watchdog(struct device *dev,
+ struct device_attribute *da,
+ char *buf)
+{
+ 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 reg;
+ int reg_val;
+
+ if (attr->index == CPLD_BMC_WATCHDOG) {
+ reg = CPLD_BMC_WATCHDOG_REG;
+ I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg);
+ if (reg_val < 0)
+ return -1;
+ return sprintf(buf, "0x%02x\n", reg_val);
+ }
+ return -1;
+}
+
+/* set value to bmc watchdog register */
+static ssize_t write_bmc_watchdog(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);
+ u8 reg, reg_val;
+ int ret;
+
+ if (kstrtou8(buf, 0, ®_val) < 0)
+ return -EINVAL;
+
+ if (attr->index == CPLD_BMC_WATCHDOG) {
+ reg = CPLD_BMC_WATCHDOG_REG;
+ I2C_WRITE_BYTE_DATA(ret, &data->access_lock,
+ client, reg, reg_val);
+ }
+ return count;
+}
+
+/* get usb status register value */
+static ssize_t read_usb_status(struct device *dev,
+ struct device_attribute *da,
+ char *buf)
+{
+ 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 reg;
+ int reg_val;
+
+ if (attr->index == CPLD_USB_STATUS) {
+ reg = CPLD_USB_STATUS_REG;
+ I2C_READ_BYTE_DATA(reg_val, &data->access_lock, client, reg);
+ if (reg_val < 0)
+ return -1;
+ return sprintf(buf, "0x%02x\n", reg_val);
+ }
+ return -1;
+}
+
+/* add valid cpld client to list */
+static void ingrasys_i2c_cpld_add_client(struct i2c_client *client)
+{
+ struct cpld_client_node *node = NULL;
+
+ node = kzalloc(sizeof(struct cpld_client_node), GFP_KERNEL);
+ if (!node) {
+ dev_info(&client->dev,
+ "Can't allocate cpld_client_node for index %d\n",
+ client->addr);
+ return;
+ }
+
+ node->client = client;
+
+ mutex_lock(&list_lock);
+ list_add(&node->list, &cpld_client_list);
+ mutex_unlock(&list_lock);
+}
+
+/* remove exist cpld client in list */
+static void ingrasys_i2c_cpld_remove_client(struct i2c_client *client)
+{
+ struct list_head *list_node = NULL;
+ struct cpld_client_node *cpld_node = NULL;
+ int found = 0;
+
+ mutex_lock(&list_lock);
+ list_for_each(list_node, &cpld_client_list) {
+ cpld_node = list_entry(list_node,
+ struct cpld_client_node, list);
+
+ if (cpld_node->client == client) {
+ found = 1;
+ break;
+ }
+ }
+
+ if (found) {
+ list_del(list_node);
+ kfree(cpld_node);
+ }
+ mutex_unlock(&list_lock);
+}
+
+/* cpld drvier probe */
+static int ingrasys_i2c_cpld_probe(struct i2c_client *client,
+ const struct i2c_device_id *dev_id)
+{
+ int status;
+ struct cpld_data *data = NULL;
+ int ret = -EPERM;
+ int err;
+ int idx;
+
+ data = kzalloc(sizeof(struct cpld_data), GFP_KERNEL);
+ if (!data)
+ return -ENOMEM;
+
+ /* init cpld data for client */
+ i2c_set_clientdata(client, data);
+ mutex_init(&data->access_lock);
+
+ if (!i2c_check_functionality(client->adapter,
+ I2C_FUNC_SMBUS_BYTE_DATA)) {
+ dev_info(&client->dev,
+ "i2c_check_functionality failed (0x%x)\n",
+ client->addr);
+ status = -EIO;
+ goto exit;
+ }
+
+ /* get cpld id from device */
+ ret = i2c_smbus_read_byte_data(client, CPLD_ID_REG);
+
+ if (ret < 0) {
+ dev_info(&client->dev,
+ "fail to get cpld id (0x%x) at addr (0x%x)\n",
+ CPLD_ID_REG, client->addr);
+ status = -EIO;
+ goto exit;
+ }
+
+ CPLD_ID_ID_GET(ret, idx);
+
+ if (INVALID(idx, cpld1, cpld5)) {
+ dev_info(&client->dev,
+ "cpld id %d(device) not valid\n", idx);
+ //status = -EPERM;
+ //goto exit;
+ }
+
+#if 0
+ /* change client name for each cpld with index */
+ snprintf(client->name, sizeof(client->name), "%s_%d", client->name,
+ data->index);
+#endif
+
+ data->index = dev_id->driver_data;
+
+ /* register sysfs hooks for different cpld group */
+ dev_info(&client->dev, "probe cpld with index %d\n", data->index);
+ switch (data->index) {
+ case cpld1:
+ status = sysfs_create_group(&client->dev.kobj,
+ &s9230_64x_cpld1_group);
+ break;
+ case cpld2:
+ status = sysfs_create_group(&client->dev.kobj,
+ &s9230_64x_cpld2_group);
+ break;
+ case cpld3:
+ case cpld4:
+ case cpld5:
+ status = sysfs_create_group(&client->dev.kobj,
+ &s9230_64x_cpld345_group);
+ break;
+ default:
+ status = -EINVAL;
+ }
+
+ if (status)
+ goto exit;
+
+ dev_info(&client->dev, "chip found\n");
+
+ /* add probe chip to client list */
+ ingrasys_i2c_cpld_add_client(client);
+
+ return 0;
+exit:
+ sysfs_remove_group(&client->dev.kobj, &s9230_64x_cpld345_group);
+ return status;
+}
+
+/* cpld drvier remove */
+static int ingrasys_i2c_cpld_remove(struct i2c_client *client)
+{
+ struct cpld_data *data = i2c_get_clientdata(client);
+
+ switch (data->index) {
+ case cpld1:
+ sysfs_remove_group(&client->dev.kobj, &s9230_64x_cpld1_group);
+ break;
+ case cpld2:
+ sysfs_remove_group(&client->dev.kobj, &s9230_64x_cpld2_group);
+ break;
+ case cpld3:
+ case cpld4:
+ case cpld5:
+ sysfs_remove_group(&client->dev.kobj,
+ &s9230_64x_cpld345_group);
+ break;
+ }
+
+ ingrasys_i2c_cpld_remove_client(client);
+ return 0;
+}
+
+MODULE_DEVICE_TABLE(i2c, ingrasys_i2c_cpld_id);
+
+static struct i2c_driver ingrasys_i2c_cpld_driver = {
+ .class = I2C_CLASS_HWMON,
+ .driver = {
+ .name = "ingrasys_i2c_cpld",
+ },
+ .probe = ingrasys_i2c_cpld_probe,
+ .remove = ingrasys_i2c_cpld_remove,
+ .id_table = ingrasys_i2c_cpld_id,
+ .address_list = cpld_i2c_addr,
+};
+
+/* provid cpld register read */
+/* cpld_idx indicate the index of cpld device */
+int ingrasys_i2c_cpld_read(u8 cpld_idx,
+ u8 reg)
+{
+ struct list_head *list_node = NULL;
+ struct cpld_client_node *cpld_node = NULL;
+ int ret = -EPERM;
+ struct cpld_data *data;
+
+ list_for_each(list_node, &cpld_client_list) {
+ cpld_node = list_entry(list_node,
+ struct cpld_client_node, list);
+ data = i2c_get_clientdata(cpld_node->client);
+ if (data->index == cpld_idx) {
+ DEBUG_PRINT("cpld_idx=%d, read reg 0x%02x",
+ cpld_idx, reg);
+ I2C_READ_BYTE_DATA(ret, &data->access_lock,
+ cpld_node->client, reg);
+ DEBUG_PRINT("cpld_idx=%d, read reg 0x%02x = 0x%02x",
+ cpld_idx, reg, ret);
+ break;
+ }
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL(ingrasys_i2c_cpld_read);
+
+/* provid cpld register write */
+/* cpld_idx indicate the index of cpld device */
+int ingrasys_i2c_cpld_write(u8 cpld_idx,
+ u8 reg,
+ u8 value)
+{
+ struct list_head *list_node = NULL;
+ struct cpld_client_node *cpld_node = NULL;
+ int ret = -EIO;
+ struct cpld_data *data;
+
+ list_for_each(list_node, &cpld_client_list) {
+ cpld_node = list_entry(list_node,
+ struct cpld_client_node, list);
+ data = i2c_get_clientdata(cpld_node->client);
+
+ if (data->index == cpld_idx) {
+ I2C_WRITE_BYTE_DATA(ret, &data->access_lock,
+ cpld_node->client,
+ reg, value);
+ DEBUG_PRINT("cpld_idx=%d, write reg 0x%02x val 0x%02x, ret=%d",
+ cpld_idx, reg, value, ret);
+ break;
+ }
+ }
+
+ return ret;
+}
+EXPORT_SYMBOL(ingrasys_i2c_cpld_write);
+
+/* provid qsfp port status register read */
+/* port_num indicate the front panel qsfp port number */
+int ingrasys_i2c_cpld_get_qsfp_port_status_val(u8 port_num)
+{
+ u8 cpld_idx, cpld_port, reg;
+ int reg_val;
+
+ if (INVALID(port_num, QSFP_MIN_PORT_NUM, QSFP_MAX_PORT_NUM)) {
+ DEBUG_PRINT("invalid input value %d", port_num);
+ return -1;
+ }
+ QSFP_TO_CPLD_IDX(port_num, cpld_idx, cpld_port);
+ reg = QSFP_PORT_STATUS_REG(cpld_port);
+ DEBUG_PRINT("port_num=%d, cpld_idx=%d, cpld_port=%d, reg=0x%x",
+ port_num, cpld_idx, cpld_port, reg);
+ reg_val = ingrasys_i2c_cpld_read(cpld_idx, reg);
+ return reg_val;
+}
+EXPORT_SYMBOL(ingrasys_i2c_cpld_get_qsfp_port_status_val);
+
+/* provid qsfp port config register read */
+/* port_num indicate the front panel qsfp port number */
+int ingrasys_i2c_cpld_get_qsfp_port_config_val(u8 port_num)
+{
+ u8 cpld_idx, cpld_port, reg;
+ int reg_val;
+
+ if (INVALID(port_num, QSFP_MIN_PORT_NUM, QSFP_MAX_PORT_NUM)) {
+ DEBUG_PRINT("invalid input value %d", port_num);
+ return -1;
+ }
+ QSFP_TO_CPLD_IDX(port_num, cpld_idx, cpld_port);
+ reg = QSFP_PORT_CONFIG_REG(cpld_port);
+ DEBUG_PRINT("port_num=%d, cpld_idx=%d, cpld_port=%d, reg=0x%x",
+ port_num, cpld_idx, cpld_port, reg);
+ reg_val = ingrasys_i2c_cpld_read(cpld_idx, reg);
+ return reg_val;
+}
+EXPORT_SYMBOL(ingrasys_i2c_cpld_get_qsfp_port_config_val);
+
+/* provid qsfp port config register write */
+/* port_num indicate the front panel qsfp port number */
+int ingrasys_i2c_cpld_set_qsfp_port_config_val(u8 port_num,
+ u8 reg_val)
+{
+ u8 cpld_idx, cpld_port, reg, ret;
+
+ if (INVALID(port_num, QSFP_MIN_PORT_NUM, QSFP_MAX_PORT_NUM)) {
+ DEBUG_PRINT("invalid input value %d", port_num);
+ return -1;
+ }
+ QSFP_TO_CPLD_IDX(port_num, cpld_idx, cpld_port);
+ reg = QSFP_PORT_CONFIG_REG(cpld_port);
+ DEBUG_PRINT("port_num=%d, cpld_idx=%d, cpld_port=%d, reg=0x%x",
+ port_num, cpld_idx, cpld_port, reg);
+ ret = ingrasys_i2c_cpld_write(cpld_idx, reg, reg_val);
+ return ret;
+}
+EXPORT_SYMBOL(ingrasys_i2c_cpld_set_qsfp_port_config_val);
+
+/* provid sfp port status register read */
+/* port_num indicate the front panel qsfp port number */
+int ingrasys_i2c_cpld_get_sfp_port_status_val(u8 port_num)
+{
+ u8 cpld_idx, reg;
+ int reg_val;
+
+ if (INVALID(port_num, SFP_MIN_PORT_NUM, SFP_MAX_PORT_NUM)) {
+ DEBUG_PRINT("invalid input value %d", port_num);
+ return -1;
+ }
+ SFP_TO_CPLD_IDX(port_num, cpld_idx);
+ reg = CPLD_SFP_PORT_STATUS_REG;
+ DEBUG_PRINT("port_num=%d, cpld_idx=%d, reg=0x%x",
+ port_num, cpld_idx, reg);
+ reg_val = ingrasys_i2c_cpld_read(cpld_idx, reg);
+ return reg_val;
+}
+EXPORT_SYMBOL(ingrasys_i2c_cpld_get_sfp_port_status_val);
+
+/* provid qsfp port config register read */
+/* port_num indicate the front panel qsfp port number */
+int ingrasys_i2c_cpld_get_sfp_port_config_val(u8 port_num)
+{
+ u8 cpld_idx, reg;
+ int reg_val;
+
+ if (INVALID(port_num, SFP_MIN_PORT_NUM, SFP_MAX_PORT_NUM)) {
+ DEBUG_PRINT("invalid input value %d", port_num);
+ return -1;
+ }
+ SFP_TO_CPLD_IDX(port_num, cpld_idx);
+ reg = CPLD_SFP_PORT_CONFIG_REG;
+ DEBUG_PRINT("port_num=%d, cpld_idx=%d, reg=0x%x",
+ port_num, cpld_idx, reg);
+ reg_val = ingrasys_i2c_cpld_read(cpld_idx, reg);
+ return reg_val;
+}
+EXPORT_SYMBOL(ingrasys_i2c_cpld_get_sfp_port_config_val);
+
+/* provid qsfp port config register write */
+/* port_num indicate the front panel qsfp port number */
+int ingrasys_i2c_cpld_set_sfp_port_config_val(u8 port_num,
+ u8 reg_val)
+{
+ u8 cpld_idx, reg, ret;
+
+ if (INVALID(port_num, SFP_MIN_PORT_NUM, SFP_MAX_PORT_NUM)) {
+ DEBUG_PRINT("invalid input value %d", port_num);
+ return -1;
+ }
+ SFP_TO_CPLD_IDX(port_num, cpld_idx);
+ reg = CPLD_SFP_PORT_CONFIG_REG;
+ DEBUG_PRINT("port_num=%d, cpld_idx=%d, reg=0x%x",
+ port_num, cpld_idx, reg);
+ ret = ingrasys_i2c_cpld_write(cpld_idx, reg, reg_val);
+ return ret;
+}
+EXPORT_SYMBOL(ingrasys_i2c_cpld_set_sfp_port_config_val);
+
+static int __init ingrasys_i2c_cpld_init(void)
+{
+ mutex_init(&list_lock);
+ return i2c_add_driver(&ingrasys_i2c_cpld_driver);
+}
+
+static void __exit ingrasys_i2c_cpld_exit(void)
+{
+ i2c_del_driver(&ingrasys_i2c_cpld_driver);
+}
+
+MODULE_AUTHOR("Leo Lin ");
+MODULE_DESCRIPTION("ingrasys_i2c_cpld driver");
+MODULE_LICENSE("GPL");
+
+module_init(ingrasys_i2c_cpld_init);
+module_exit(ingrasys_i2c_cpld_exit);
+
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/ingrasys_s9230_64x_i2c_cpld.h b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/ingrasys_s9230_64x_i2c_cpld.h
new file mode 100644
index 0000000000..e0e53174d6
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/ingrasys_s9230_64x_i2c_cpld.h
@@ -0,0 +1,223 @@
+/* header file for i2c cpld driver of ingrasys_s9230_64x
+ *
+ * Copyright (C) 2017 Ingrasys Technology Corporation.
+ * Leo Lin
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#ifndef INGRASYS_S9230_64X_I2C_CPLD_H
+#define INGRASYS_S9230_64X_I2C_CPLD_H
+
+/* CPLD device index value */
+enum cpld_id {
+ cpld1,
+ cpld2,
+ cpld3,
+ cpld4,
+ cpld5
+};
+
+/* port number on CPLD */
+#define CPLD_1_PORT_NUM 12
+#define CPLD_2_PORT_NUM 13
+
+/* QSFP port number */
+#define QSFP_MAX_PORT_NUM 64
+#define QSFP_MIN_PORT_NUM 1
+
+/* SFP+ port number */
+#define SFP_MAX_PORT_NUM 2
+#define SFP_MIN_PORT_NUM 1
+
+
+/* CPLD registers */
+#define CPLD_BOARD_TYPE_REG 0x0
+#define CPLD_EXT_BOARD_TYPE_REG 0x7
+#define CPLD_VERSION_REG 0x1
+#define CPLD_ID_REG 0x2
+#define CPLD_QSFP_PORT_STATUS_BASE_REG 0x20
+#define CPLD_QSFP_PORT_CONFIG_BASE_REG 0x30
+#define CPLD_QSFP_PORT_INTERRUPT_REG 0x40
+#define CPLD_SFP_PORT_STATUS_REG 0x2F
+#define CPLD_SFP_PORT_CONFIG_REG 0x3F
+#define CPLD_QSFP_PORT_INTERRUPT_REG 0x40
+#define CPLD_10GMUX_CONFIG_REG 0x41
+#define CPLD_BMC_STATUS_REG 0x42
+#define CPLD_BMC_WATCHDOG_REG 0x43
+#define CPLD_USB_STATUS_REG 0x44
+#define CPLD_REST_CONTROL_REG 0x4A
+
+
+/* bit definition for register value */
+enum CPLD_QSFP_PORT_STATUS_BITS {
+ CPLD_QSFP_PORT_STATUS_INT_BIT,
+ CPLD_QSFP_PORT_STATUS_ABS_BIT,
+};
+enum CPLD_QSFP_PORT_CONFIG_BITS {
+ CPLD_QSFP_PORT_CONFIG_RESET_BIT,
+ CPLD_QSFP_PORT_CONFIG_RESERVE_BIT,
+ CPLD_QSFP_PORT_CONFIG_LPMODE_BIT,
+};
+enum CPLD_SFP_PORT_STATUS_BITS {
+ CPLD_SFP_PORT_STATUS_PRESENT_BIT,
+ CPLD_SFP_PORT_STATUS_TXFAULT_BIT,
+ CPLD_SFP_PORT_STATUS_RXLOS_BIT,
+};
+enum CPLD_SFP_PORT_CONFIG_BITS {
+ CPLD_SFP_PORT_CONFIG_TXDIS_BIT,
+ CPLD_SFP_PORT_CONFIG_RS_BIT,
+ CPLD_SFP_PORT_CONFIG_TS_BIT,
+};
+enum CPLD_10GMUX_CONFIG_BITS {
+ CPLD_10GMUX_CONFIG_ENSMB_BIT,
+ CPLD_10GMUX_CONFIG_ENINPUT_BIT,
+ CPLD_10GMUX_CONFIG_SEL1_BIT,
+ CPLD_10GMUX_CONFIG_SEL0_BIT,
+};
+enum CPLD_BMC_WATCHDOG_BITS {
+ CPLD_10GMUX_CONFIG_ENTIMER_BIT,
+ CPLD_10GMUX_CONFIG_TIMEOUT_BIT,
+};
+enum CPLD_RESET_CONTROL_BITS {
+ CPLD_RESET_CONTROL_SWRST_BIT,
+ CPLD_RESET_CONTROL_CP2104RST_BIT,
+ CPLD_RESET_CONTROL_82P33814RST_BIT,
+ CPLD_RESET_CONTROL_BMCRST_BIT,
+};
+
+/* bit field structure for register value */
+struct cpld_reg_board_type_t {
+ u8 build_rev:2;
+ u8 hw_rev:2;
+ u8 board_id:4;
+};
+
+struct cpld_reg_version_t {
+ u8 revision:6;
+ u8 release:1;
+ u8 reserve:1;
+};
+
+struct cpld_reg_id_t {
+ u8 id:3;
+ u8 release:5;
+};
+
+/* common manipulation */
+#define INVALID(i, min, max) ((i < min) || (i > max) ? 1u : 0u)
+#define READ_BIT(val, bit) ((0u == (val & (1<bf_name)
+#define READ_BF_1(bf_struct, val, bf_name, bf_value) \
+ bf_struct bf; \
+ bf.data = val; \
+ bf_value = bf.bf_name
+#define BOARD_TYPE_BUILD_REV_GET(val, res) \
+ READ_BF(cpld_reg_board_type_t, val, build_rev, res)
+#define BOARD_TYPE_HW_REV_GET(val, res) \
+ READ_BF(cpld_reg_board_type_t, val, hw_rev, res)
+#define BOARD_TYPE_BOARD_ID_GET(val, res) \
+ READ_BF(cpld_reg_board_type_t, val, board_id, res)
+#define CPLD_VERSION_REV_GET(val, res) \
+ READ_BF(cpld_reg_version_t, val, revision, res)
+#define CPLD_VERSION_REL_GET(val, res) \
+ READ_BF(cpld_reg_version_t, val, release, res)
+#define CPLD_ID_ID_GET(val, res) \
+ READ_BF(cpld_reg_id_t, val, id, res)
+#define CPLD_ID_REL_GET(val, res) \
+ READ_BF(cpld_reg_id_t, val, release, res)
+/* QSFP/SFP registers manipulation */
+#define QSFP_TO_CPLD_IDX(qsfp_port, cpld_index, cpld_port) \
+{ \
+ if (QSFP_MIN_PORT_NUM <= qsfp_port && qsfp_port <= CPLD_1_PORT_NUM) { \
+ cpld_index = cpld1; \
+ cpld_port = qsfp_port - 1; \
+ } else if (CPLD_1_PORT_NUM < qsfp_port \
+ && qsfp_port <= QSFP_MAX_PORT_NUM) { \
+ cpld_index = cpld2 + (qsfp_port - 1 - CPLD_1_PORT_NUM) \
+ / CPLD_2_PORT_NUM; \
+ cpld_port = (qsfp_port - 1 - CPLD_1_PORT_NUM) % \
+ CPLD_2_PORT_NUM; \
+ } else { \
+ cpld_index = 0; \
+ cpld_port = 0; \
+ } \
+}
+#define SFP_TO_CPLD_IDX(sfp_port, cpld_index) \
+ (cpld_index = sfp_port - SFP_MIN_PORT_NUM)
+#define QSFP_PORT_STATUS_REG(cpld_port) \
+ (CPLD_QSFP_PORT_STATUS_BASE_REG + cpld_port)
+#define QSFP_PORT_CONFIG_REG(cpld_port) \
+ (CPLD_QSFP_PORT_CONFIG_BASE_REG + cpld_port)
+#define QSFP_PORT_INT_BIT_GET(port_status_value) \
+ READ_BIT(port_status_value, CPLD_QSFP_PORT_STATUS_INT_BIT)
+#define QSFP_PORT_ABS_BIT_GET(port_status_value) \
+ READ_BIT(port_status_value, CPLD_QSFP_PORT_STATUS_ABS_BIT)
+#define QSFP_PORT_RESET_BIT_GET(port_config_value) \
+ READ_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_RESET_BIT)
+#define QSFP_PORT_LPMODE_BIT_GET(port_config_value) \
+ READ_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_LPMODE_BIT)
+#define QSFP_PORT_RESET_BIT_SET(port_config_value) \
+ SET_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_RESET_BIT)
+#define QSFP_PORT_RESET_BIT_CLEAR(port_config_value) \
+ CLEAR_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_RESET_BIT)
+#define QSFP_PORT_LPMODE_BIT_SET(port_config_value) \
+ SET_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_LPMODE_BIT)
+#define QSFP_PORT_LPMODE_BIT_CLEAR(port_config_value) \
+ CLEAR_BIT(port_config_value, CPLD_QSFP_PORT_CONFIG_LPMODE_BIT)
+#define SFP_PORT_PRESENT_BIT_GET(port_status_value) \
+ READ_BIT(port_status_value, CPLD_SFP_PORT_STATUS_PRESENT_BIT)
+
+#define SFP_PORT_TXFAULT_BIT_GET(port_status_value) \
+ READ_BIT(port_status_value, CPLD_SFP_PORT_STATUS_TXFAULT_BIT)
+#define SFP_PORT_RXLOS_BIT_GET(port_status_value) \
+ READ_BIT(port_status_value, CPLD_SFP_PORT_STATUS_RXLOS_BIT)
+#define SFP_PORT_TXDIS_BIT_GET(port_status_value) \
+ READ_BIT(port_status_value, CPLD_SFP_PORT_CONFIG_TXDIS_BIT)
+#define SFP_PORT_RS_BIT_GET(port_config_value) \
+ READ_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_RS_BIT)
+#define SFP_PORT_TS_BIT_GET(port_config_value) \
+ READ_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_TS_BIT)
+#define SFP_PORT_TXDIS_BIT_SET(port_config_value) \
+ SET_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_TXDIS_BIT)
+#define SFP_PORT_TXDIS_BIT_CLEAR(port_config_value) \
+ CLEAR_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_TXDIS_BIT)
+#define SFP_PORT_RS_BIT_SET(port_config_value) \
+ SET_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_RS_BIT)
+#define SFP_PORT_RS_BIT_CLEAR(port_config_value) \
+ CLEAR_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_RS_BIT)
+#define SFP_PORT_TS_BIT_SET(port_config_value) \
+ SET_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_TS_BIT)
+#define SFP_PORT_TS_BIT_CLEAR(port_config_value) \
+ CLEAR_BIT(port_config_value, CPLD_SFP_PORT_CONFIG_TS_BIT)
+
+/* CPLD access functions */
+extern int ingrasys_i2c_cpld_get_qsfp_port_status_val(u8 port_num);
+extern int ingrasys_i2c_cpld_get_qsfp_port_config_val(u8 port_num);
+extern int ingrasys_i2c_cpld_set_qsfp_port_config_val(u8 port_num, u8 reg_val);
+extern int ingrasys_i2c_cpld_get_sfp_port_status_val(u8 port_num);
+extern int ingrasys_i2c_cpld_get_sfp_port_config_val(u8 port_num);
+extern int ingrasys_i2c_cpld_set_sfp_port_config_val(u8 port_num, u8 reg_val);
+extern u8 fp_port_to_phy_port(u8 fp_port);
+#endif
+
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/ingrasys_s9230_64x_platform.h b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/ingrasys_s9230_64x_platform.h
new file mode 100644
index 0000000000..a14853fdae
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/ingrasys_s9230_64x_platform.h
@@ -0,0 +1,148 @@
+#ifndef _S9230_64X_PLATFORM_H
+#define _S9230_64X_PLATFORM_H
+
+#include
+
+// remove debug before release
+#define DEBUG
+
+enum bus_order {
+ I2C_BUS_MAIN,
+ MUX_9548_0_CH0,
+ MUX_9548_0_CH1,
+ MUX_9548_0_CH2,
+ MUX_9548_0_CH3,
+ MUX_9548_0_CH4,
+ MUX_9548_0_CH5,
+ MUX_9548_0_CH6,
+ MUX_9548_0_CH7,
+ MUX_9548_1_CH0,
+ MUX_9548_1_CH1,
+ MUX_9548_1_CH2,
+ MUX_9548_1_CH3,
+ MUX_9548_1_CH4,
+ MUX_9548_1_CH5,
+ MUX_9548_1_CH6,
+ MUX_9548_1_CH7,
+ MUX_9546_0_CH0,
+ MUX_9546_0_CH1,
+ MUX_9546_0_CH2,
+ MUX_9546_0_CH3,
+ MUX_9546_1_CH0,
+ MUX_9546_1_CH1,
+ MUX_9546_1_CH2,
+ MUX_9546_1_CH3,
+ MUX_9548_2_CH0,
+ MUX_9548_2_CH1,
+ MUX_9548_2_CH2,
+ MUX_9548_2_CH3,
+ MUX_9548_2_CH4,
+ MUX_9548_2_CH5,
+ MUX_9548_2_CH6,
+ MUX_9548_2_CH7,
+ MUX_9548_3_CH0,
+ MUX_9548_3_CH1,
+ MUX_9548_3_CH2,
+ MUX_9548_3_CH3,
+ MUX_9548_3_CH4,
+ MUX_9548_3_CH5,
+ MUX_9548_3_CH6,
+ MUX_9548_3_CH7,
+ MUX_9548_4_CH0,
+ MUX_9548_4_CH1,
+ MUX_9548_4_CH2,
+ MUX_9548_4_CH3,
+ MUX_9548_4_CH4,
+ MUX_9548_4_CH5,
+ MUX_9548_4_CH6,
+ MUX_9548_4_CH7,
+ MUX_9548_5_CH0,
+ MUX_9548_5_CH1,
+ MUX_9548_5_CH2,
+ MUX_9548_5_CH3,
+ MUX_9548_5_CH4,
+ MUX_9548_5_CH5,
+ MUX_9548_5_CH6,
+ MUX_9548_5_CH7,
+ MUX_9548_6_CH0,
+ MUX_9548_6_CH1,
+ MUX_9548_6_CH2,
+ MUX_9548_6_CH3,
+ MUX_9548_6_CH4,
+ MUX_9548_6_CH5,
+ MUX_9548_6_CH6,
+ MUX_9548_6_CH7,
+ MUX_9548_7_CH0,
+ MUX_9548_7_CH1,
+ MUX_9548_7_CH2,
+ MUX_9548_7_CH3,
+ MUX_9548_7_CH4,
+ MUX_9548_7_CH5,
+ MUX_9548_7_CH6,
+ MUX_9548_7_CH7,
+ MUX_9548_8_CH0,
+ MUX_9548_8_CH1,
+ MUX_9548_8_CH2,
+ MUX_9548_8_CH3,
+ MUX_9548_8_CH4,
+ MUX_9548_8_CH5,
+ MUX_9548_8_CH6,
+ MUX_9548_8_CH7,
+ MUX_9548_9_CH0,
+ MUX_9548_9_CH1,
+ MUX_9548_9_CH2,
+ MUX_9548_9_CH3,
+ MUX_9548_9_CH4,
+ MUX_9548_9_CH5,
+ MUX_9548_9_CH6,
+ MUX_9548_9_CH7,
+ MUX_9548_10_CH0,
+ MUX_9548_10_CH1,
+ MUX_9548_10_CH2,
+ MUX_9548_10_CH3,
+ MUX_9548_10_CH4,
+ MUX_9548_10_CH5,
+ MUX_9548_10_CH6,
+ MUX_9548_10_CH7,
+};
+
+#define I2C_ADDR_MUX_9555_0 (0x20)
+#define I2C_ADDR_MUX_9555_1 (0x24)
+#define I2C_ADDR_MUX_9555_2 (0x25)
+#define I2C_ADDR_MUX_9555_3 (0x26)
+#define I2C_ADDR_MUX_9539_0 (0x76)
+#define I2C_ADDR_MUX_9539_1 (0x76)
+#define I2C_BUS_FAN_STATUS (I2C_BUS_MAIN)
+#define I2C_BUS_SYS_LED (MUX_9548_1_CH1)
+
+#define NUM_OF_I2C_MUX (11)
+#define NUM_OF_CPLD (5)
+#define NUM_OF_QSFP_PORT (64)
+#define NUM_OF_SFP_PORT (2)
+#define QSFP_EEPROM_I2C_ADDR (0x50)
+
+enum gpio_reg {
+ REG_PORT0_IN,
+ REG_PORT1_IN,
+ REG_PORT0_OUT,
+ REG_PORT1_OUT,
+ REG_PORT0_POL,
+ REG_PORT1_POL,
+ REG_PORT0_DIR,
+ REG_PORT1_DIR,
+};
+
+struct ing_i2c_board_info {
+ int ch;
+ int size;
+ struct i2c_board_info *board_info;
+};
+
+struct i2c_init_data {
+ __u16 ch;
+ __u16 addr;
+ __u8 reg;
+ __u8 value;
+};
+
+#endif
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/ingrasys_s9230_64x_psu.c b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/ingrasys_s9230_64x_psu.c
new file mode 100644
index 0000000000..694b57bd74
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/modules/ingrasys_s9230_64x_psu.c
@@ -0,0 +1,388 @@
+/*
+ * S9230-64x PSU driver
+ *
+ * Copyright (C) 2017 Ingrasys, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include
+#include "ingrasys_s9230_64x_platform.h"
+
+static ssize_t show_psu_eeprom(struct device *dev,
+ struct device_attribute *da,
+ char *buf);
+static struct s9230_psu_data *s9230_psu_update_status(struct device *dev);
+static struct s9230_psu_data *s9230_psu_update_eeprom(struct device *dev);
+static int s9230_psu_read_block(struct i2c_client *client,
+ u8 command,
+ u8 *data,
+ int data_len);
+
+
+#define DRIVER_NAME "psu"
+
+// Addresses scanned
+static const unsigned short normal_i2c[] = { 0x50, I2C_CLIENT_END };
+
+/* PSU EEPROM SIZE */
+#define EEPROM_SZ 256
+#define READ_EEPROM 1
+#define NREAD_EEPROM 0
+
+static struct i2c_client pca9555_client;
+
+/* pca9555 gpio pin mapping */
+#define PSU2_PWROK 0
+#define PSU2_PRSNT_L 1
+#define PSU2_PWRON_L 2
+#define PSU1_PWROK 3
+#define PSU1_PRSNT_L 4
+#define PSU1_PWRON_L 5
+#define TMP_75_INT_L 6
+
+/* Driver Private Data */
+struct s9230_psu_data {
+ struct mutex lock;
+ char valid; /* !=0 if registers are valid */
+ unsigned long last_updated; /* In jiffies */
+ u8 index; /* PSU index */
+ s32 status; /* IO expander value */
+ char eeprom[EEPROM_SZ]; /* psu eeprom data */
+ char psuABS; /* PSU absent */
+ char psuPG; /* PSU power good */
+};
+
+enum psu_index
+{
+ s9230_psu1,
+ s9230_psu2
+};
+
+/*
+ * display power good attribute
+ */
+static ssize_t
+show_psu_pg(struct device *dev,
+ struct device_attribute *devattr,
+ char *buf)
+{
+ struct s9230_psu_data *data = s9230_psu_update_status(dev);
+ unsigned int value;
+
+ mutex_lock(&data->lock);
+ value = data->psuPG;
+ mutex_unlock(&data->lock);
+
+ return sprintf(buf, "%d\n", value);
+}
+
+/*
+ * display power absent attribute
+ */
+static ssize_t
+show_psu_abs(struct device *dev,
+ struct device_attribute *devattr,
+ char *buf)
+{
+ struct s9230_psu_data *data = s9230_psu_update_status(dev);
+ unsigned int value;
+
+ mutex_lock(&data->lock);
+ value = data->psuABS;
+ mutex_unlock(&data->lock);
+
+ return sprintf(buf, "%d\n", value);
+}
+
+
+/*
+ * sysfs attributes for psu
+ */
+static DEVICE_ATTR(psu_pg, S_IRUGO, show_psu_pg, NULL);
+static DEVICE_ATTR(psu_abs, S_IRUGO, show_psu_abs, NULL);
+static DEVICE_ATTR(psu_eeprom, S_IRUGO, show_psu_eeprom, NULL);
+
+static struct attribute *s9230_psu_attributes[] = {
+ &dev_attr_psu_pg.attr,
+ &dev_attr_psu_abs.attr,
+ &dev_attr_psu_eeprom.attr,
+ NULL
+};
+
+/*
+ * display psu eeprom content
+ */
+static ssize_t
+show_psu_eeprom(struct device *dev,
+ struct device_attribute *da,
+ char *buf)
+{
+ struct s9230_psu_data *data = s9230_psu_update_eeprom(dev);
+
+ memcpy(buf, (char *)data->eeprom, EEPROM_SZ);
+ return EEPROM_SZ;
+}
+
+static const struct attribute_group s9230_psu_group = {
+ .attrs = s9230_psu_attributes,
+};
+
+/*
+ * check gpio expander is accessible
+ */
+static int
+pca9555_detect(struct i2c_client *client)
+{
+ if (i2c_smbus_read_byte_data(client, REG_PORT0_DIR) < 0) {
+ return -ENODEV;
+ }
+
+ return 0;
+}
+
+/*
+ * client address init
+ */
+static void
+i2c_devices_client_address_init(struct i2c_client *client)
+{
+ pca9555_client = *client;
+ pca9555_client.addr = 0x25;
+}
+
+static int
+s9230_psu_probe(struct i2c_client *client,
+ const struct i2c_device_id *dev_id)
+{
+ struct s9230_psu_data *data;
+ int status, err;
+
+ if (!i2c_check_functionality(client->adapter, I2C_FUNC_SMBUS_I2C_BLOCK)) {
+ status = -EIO;
+ goto exit;
+ }
+
+ data = kzalloc(sizeof(struct s9230_psu_data), GFP_KERNEL);
+ if (!data) {
+ status = -ENOMEM;
+ goto exit;
+ }
+ memset(data, 0, sizeof(struct s9230_psu_data));
+ i2c_set_clientdata(client, data);
+ data->valid = 0;
+ data->index = dev_id->driver_data;
+ mutex_init(&data->lock);
+
+ i2c_devices_client_address_init(client);
+
+ err = pca9555_detect(&pca9555_client);
+ if (err) {
+ return err;
+ }
+
+ dev_info(&client->dev, "chip found\n");
+
+ /* Register sysfs hooks */
+ status = sysfs_create_group(&client->dev.kobj, &s9230_psu_group);
+ if (status) {
+ goto exit_free;
+ }
+
+ return 0;
+
+exit_remove:
+ sysfs_remove_group(&client->dev.kobj, &s9230_psu_group);
+exit_free:
+ kfree(data);
+exit:
+
+ return status;
+}
+
+static int
+s9230_psu_remove(struct i2c_client *client)
+{
+ struct s9230_psu_data *data = i2c_get_clientdata(client);
+
+ sysfs_remove_group(&client->dev.kobj, &s9230_psu_group);
+ kfree(data);
+
+ return 0;
+}
+
+
+/*
+ * psu eeprom read utility
+ */
+static int
+s9230_psu_read_block(struct i2c_client *client,
+ u8 command,
+ u8 *data,
+ int data_len)
+{
+ int i=0, ret=0;
+ int blk_max = 32; //max block read size
+
+ /* read eeprom, 32 * 8 = 256 bytes */
+ for (i=0; i < EEPROM_SZ/blk_max; i++) {
+ ret = i2c_smbus_read_i2c_block_data(client, (i*blk_max), blk_max,
+ data + (i*blk_max));
+ if (ret < 0) {
+ return ret;
+ }
+ }
+ return ret;
+}
+
+/*
+ * update eeprom content
+ */
+static struct s9230_psu_data
+*s9230_psu_update_eeprom(struct device *dev)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct s9230_psu_data *data = i2c_get_clientdata(client);
+ s32 status = 0;
+ int psu_pwrok = 0;
+ int psu_prsnt_l = 0;
+
+ mutex_lock(&data->lock);
+
+ if (time_after(jiffies, data->last_updated + 300 * HZ)
+ || !data->valid) {
+
+ /* Read psu status */
+
+ status = i2c_smbus_read_word_data(&(pca9555_client), REG_PORT0_IN);
+ data->status = status;
+
+ /*read psu status from io expander*/
+
+ if (data->index == s9230_psu1) {
+ psu_pwrok = PSU1_PWROK;
+ psu_prsnt_l = PSU1_PRSNT_L;
+ } else {
+ psu_pwrok = PSU2_PWROK;
+ psu_prsnt_l = PSU2_PRSNT_L;
+ }
+ data->psuPG = (status >> psu_pwrok) & 0x1;
+ data->psuABS = (status >> psu_prsnt_l) & 0x1;
+
+ /* Read eeprom */
+ if (!data->psuABS) {
+ //clear local eeprom data
+ memset(data->eeprom, 0, EEPROM_SZ);
+
+ //read eeprom
+ status = s9230_psu_read_block(client, 0, data->eeprom,
+ ARRAY_SIZE(data->eeprom));
+
+ if (status < 0) {
+ memset(data->eeprom, 0, EEPROM_SZ);
+ dev_err(&client->dev, "Read eeprom failed, status=(%d)\n", status);
+ } else {
+ data->valid = 1;
+ }
+ } else {
+ memset(data->eeprom, 0, EEPROM_SZ);
+ }
+ data->last_updated = jiffies;
+ }
+
+ mutex_unlock(&data->lock);
+
+ return data;
+}
+
+/*
+ * update psu status
+ */
+static struct s9230_psu_data
+*s9230_psu_update_status(struct device *dev)
+{
+ struct i2c_client *client = to_i2c_client(dev);
+ struct s9230_psu_data *data = i2c_get_clientdata(client);
+ s32 status = 0;
+ int psu_pwrok = 0;
+ int psu_prsnt_l = 0;
+
+ mutex_lock(&data->lock);
+
+ /* Read psu status */
+
+ status = i2c_smbus_read_word_data(&(pca9555_client), REG_PORT0_IN);
+ data->status = status;
+
+ /*read psu status from io expander*/
+
+ if (data->index == s9230_psu1) {
+ psu_pwrok = PSU1_PWROK;
+ psu_prsnt_l = PSU1_PRSNT_L;
+ } else {
+ psu_pwrok = PSU2_PWROK;
+ psu_prsnt_l = PSU2_PRSNT_L;
+ }
+ data->psuPG = (status >> psu_pwrok) & 0x1;
+ data->psuABS = (status >> psu_prsnt_l) & 0x1;
+
+ mutex_unlock(&data->lock);
+
+ return data;
+}
+
+static const struct i2c_device_id s9230_psu_id[] = {
+ { "psu1", s9230_psu1 },
+ { "psu2", s9230_psu2 },
+ {}
+};
+
+MODULE_DEVICE_TABLE(i2c, s9230_psu_id);
+
+static struct i2c_driver s9230_psu_driver = {
+ .driver = {
+ .name = DRIVER_NAME,
+ },
+ .probe = s9230_psu_probe,
+ .remove = s9230_psu_remove,
+ .id_table = s9230_psu_id,
+ .address_list = normal_i2c,
+};
+
+static int __init s9230_psu_init(void)
+{
+ return i2c_add_driver(&s9230_psu_driver);
+}
+
+static void __exit s9230_psu_exit(void)
+{
+ i2c_del_driver(&s9230_psu_driver);
+}
+
+module_init(s9230_psu_init);
+module_exit(s9230_psu_exit);
+
+MODULE_AUTHOR("Jason Tsai ");
+MODULE_DESCRIPTION("S9230-64X psu driver");
+MODULE_LICENSE("GPL");
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/service/qsfp-monitor.service b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/service/qsfp-monitor.service
new file mode 100644
index 0000000000..cf4a6a8ad4
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/service/qsfp-monitor.service
@@ -0,0 +1,15 @@
+[Unit]
+Description= This QSFP Monitor service is to setup QSFP SI.
+Requires=s9230-64x-monitor.service
+After=s9230-64x-monitor.service
+
+[Service]
+ExecStart=/usr/sbin/qsfp_monitor.sh
+KillSignal=SIGKILL
+SuccessExitStatus=SIGKILL
+
+# Resource Limitations
+LimitCORE=infinity
+
+[Install]
+WantedBy=multi-user.target
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/service/s9230-64x-monitor.service b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/service/s9230-64x-monitor.service
new file mode 100644
index 0000000000..5caf968e65
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/service/s9230-64x-monitor.service
@@ -0,0 +1,19 @@
+[Unit]
+Description= This Platform Monitor service is to initialize platform and monitor platform.
+Before=platform-monitor.service
+After=sysinit.target
+Wants=fancontrol.service
+Wants=qsfp-monitor.service
+DefaultDependencies=no
+
+[Service]
+ExecStartPre=/usr/sbin/i2c_utils.sh i2c_init
+ExecStart=/usr/sbin/s9230_64x_monitor.sh
+KillSignal=SIGKILL
+SuccessExitStatus=SIGKILL
+
+# Resource Limitations
+LimitCORE=infinity
+
+[Install]
+WantedBy=multi-user.target
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/utils/i2c_utils.sh b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/utils/i2c_utils.sh
new file mode 100755
index 0000000000..e899e64a7c
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/utils/i2c_utils.sh
@@ -0,0 +1,1850 @@
+#!/bin/bash
+
+# Copyright (C) 2016 Ingrasys, 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 .
+
+# trun on for more debug output
+#DEBUG="on"
+
+VERSION="1.0.0"
+TRUE=200
+FALSE=404
+
+EXEC_FUNC=${1}
+COLOR_LED=${2}
+QSFP_PORT=${2}
+SFP_PORT=${2}
+QSFP_ACTION=${2}
+SFP_ACTION=${2}
+MB_EEPROM_ACTION=${2}
+TARGET_10G_MUX=${2}
+ONOFF_LED=${3}
+FAN_TRAY=${4}
+
+############################################################
+# Distributor ID: Debian
+# Description: Debian GNU/Linux 8.6 (jessie)
+# Release: 8.6
+# Codename: jessie
+# Linux debian 3.16.0-4-amd64 #1
+# SMP Debian 3.16.36-1+deb8u1 (2016-09-03) x86_64 GNU/Linux
+############################################################
+
+# Color Definition
+COLOR_TITLE="\e[1;32m" ### Green ###
+COLOR_WARNING="\e[1;33m" ### Yellow ###
+COLOR_ERROR="\e[1;31m" ### Red ###
+COLOR_END="\e[0m" ### END ###
+
+NUM_I801_DEVICE=0
+
+# PCA9548#0 0x70
+NUM_MUX_9548_0_CH0=$(( ${NUM_I801_DEVICE} + 1 )) # CPLD1
+NUM_MUX_9548_0_CH1=$(( ${NUM_I801_DEVICE} + 2 )) # CPLD2
+NUM_MUX_9548_0_CH2=$(( ${NUM_I801_DEVICE} + 3 )) # CPLD3
+NUM_MUX_9548_0_CH3=$(( ${NUM_I801_DEVICE} + 4 )) # CPLD4
+NUM_MUX_9548_0_CH4=$(( ${NUM_I801_DEVICE} + 5 )) # CPLD5
+NUM_MUX_9548_0_CH5=$(( ${NUM_I801_DEVICE} + 6 )) # LM75_1 LM75_2
+NUM_MUX_9548_0_CH6=$(( ${NUM_I801_DEVICE} + 7 )) # LM75_3 LM75_4
+
+# PCA9548#1 0x73
+NUM_MUX_9548_1_CH0=$(( ${NUM_I801_DEVICE} + 9 )) # UCD9090
+NUM_MUX_9548_1_CH1=$(( ${NUM_I801_DEVICE} + 10 )) # PCA9539 0x76 for FP LED & HW ID
+NUM_MUX_9548_1_CH2=$(( ${NUM_I801_DEVICE} + 11 )) # PCA9539 0x76 for SYS control
+NUM_MUX_9548_1_CH4=$(( ${NUM_I801_DEVICE} + 13 )) # 10G Mux
+NUM_MUX_9548_1_CH7=$(( ${NUM_I801_DEVICE} + 16 )) # HWM & TMP75 on BMC
+
+# PCA9546#0 0X72
+NUM_MUX_9546_0_CH0=$(( ${NUM_I801_DEVICE} + 17 )) # PSU1 0x58
+NUM_MUX_9546_0_CH1=$(( ${NUM_I801_DEVICE} + 18 )) # PSU2 0x58
+NUM_MUX_9546_0_CH2=$(( ${NUM_I801_DEVICE} + 19 )) # PCA9548#2 0x71
+NUM_MUX_9546_0_CH3=$(( ${NUM_I801_DEVICE} + 20 )) # PCA9546#1 0x71
+
+# PCA9546#1 0X71
+NUM_MUX_9546_1_CH0=$(( ${NUM_I801_DEVICE} + 21 )) # SFP0 EEPROM 0x50
+NUM_MUX_9546_1_CH1=$(( ${NUM_I801_DEVICE} + 22 )) # SFP1 EEPROM 0x50
+
+# PCA9548#2 0X71
+NUM_MUX_9548_2_CH0=$(( ${NUM_I801_DEVICE} + 25 )) # PCA9548#3 0x74
+NUM_MUX_9548_2_CH1=$(( ${NUM_I801_DEVICE} + 26 )) # PCA9548#4 0x74
+NUM_MUX_9548_2_CH2=$(( ${NUM_I801_DEVICE} + 27 )) # PCA9548#5 0x74
+NUM_MUX_9548_2_CH3=$(( ${NUM_I801_DEVICE} + 28 )) # PCA9548#6 0x74
+NUM_MUX_9548_2_CH4=$(( ${NUM_I801_DEVICE} + 29 )) # PCA9548#7 0x74
+NUM_MUX_9548_2_CH5=$(( ${NUM_I801_DEVICE} + 30 )) # PCA9548#8 0x74
+NUM_MUX_9548_2_CH6=$(( ${NUM_I801_DEVICE} + 31 )) # PCA9548#9 0x74
+NUM_MUX_9548_2_CH7=$(( ${NUM_I801_DEVICE} + 32 )) # PCA9548#10 0x74
+
+# PCA9548#3~10 0X74
+NUM_MUX_9548_3_CH0=$(( ${NUM_I801_DEVICE} + 33 )) # QSFP 0 EEPROM
+NUM_MUX_9548_4_CH0=$(( ${NUM_I801_DEVICE} + 41 )) # QSFP 8 EEPROM
+NUM_MUX_9548_5_CH0=$(( ${NUM_I801_DEVICE} + 49 )) # QSFP 16 EEPROM
+NUM_MUX_9548_6_CH0=$(( ${NUM_I801_DEVICE} + 57 )) # QSFP 24 EEPROM
+NUM_MUX_9548_7_CH0=$(( ${NUM_I801_DEVICE} + 65 )) # QSFP 32 EEPROM
+NUM_MUX_9548_8_CH0=$(( ${NUM_I801_DEVICE} + 73 )) # QSFP 40 EEPROM
+NUM_MUX_9548_9_CH0=$(( ${NUM_I801_DEVICE} + 81 )) # QSFP 48 EEPROM
+NUM_MUX_9548_10_CH0=$(( ${NUM_I801_DEVICE} + 89 )) # QSFP 56 EEPROM
+
+# MUX Alias
+I2C_BUS_MAIN=${NUM_I801_DEVICE}
+I2C_BUS_HWM=${NUM_MUX_9548_1_CH7}
+I2C_BUS_FAN_STATUS=${I2C_BUS_MAIN}
+I2C_BUS_SYS_LED=${NUM_MUX_9548_1_CH1}
+I2C_BUS_HW_ID=${NUM_MUX_9548_1_CH1}
+I2C_BUS_BMC_HW_ID=${I2C_BUS_MAIN}
+I2C_BUS_PSU_STAT=${I2C_BUS_MAIN}
+I2C_BUS_FANTRAY_LED=${I2C_BUS_MAIN}
+I2C_BUS_MB_EEPROM=${I2C_BUS_MAIN}
+I2C_BUS_CB_EEPROM=${I2C_BUS_MAIN}
+I2C_BUS_PSU1_EEPROM=${NUM_MUX_9546_0_CH1}
+I2C_BUS_PSU2_EEPROM=${NUM_MUX_9546_0_CH0}
+I2C_BUS_CPLD1=${NUM_MUX_9548_0_CH0}
+I2C_BUS_CPLD2=${NUM_MUX_9548_0_CH1}
+I2C_BUS_CPLD3=${NUM_MUX_9548_0_CH2}
+I2C_BUS_CPLD4=${NUM_MUX_9548_0_CH3}
+I2C_BUS_CPLD5=${NUM_MUX_9548_0_CH4}
+I2C_BUS_10GMUX=${NUM_MUX_9548_1_CH4}
+
+# I2C BUS path
+PATH_SYS_I2C_DEVICES="/sys/bus/i2c/devices"
+PATH_HWMON_ROOT_DEVICES="/sys/class/hwmon"
+# TODO: need to verify HWM deivce path after board ready
+PATH_HWMON_W83795_DEVICE="${PATH_HWMON_ROOT_DEVICES}/hwmon7"
+PATH_I801_DEVICE="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_I801_DEVICE}"
+PATH_MUX_9548_0_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_0_CH0}"
+PATH_MUX_9548_0_CH1="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_0_CH1}"
+PATH_MUX_9548_0_CH2="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_0_CH2}"
+PATH_MUX_9548_0_CH3="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_0_CH3}"
+PATH_MUX_9548_0_CH4="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_0_CH4}"
+PATH_MUX_9548_0_CH5="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_0_CH5}"
+PATH_MUX_9548_0_CH6="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_0_CH6}"
+PATH_MUX_9548_1_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_1_CH0}"
+PATH_MUX_9548_1_CH1="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_1_CH1}"
+PATH_MUX_9548_1_CH2="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_1_CH2}"
+PATH_MUX_9548_1_CH7="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_1_CH7}"
+PATH_MUX_9546_0_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9546_0_CH0}"
+PATH_MUX_9546_0_CH1="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9546_0_CH1}"
+PATH_MUX_9546_0_CH2="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9546_0_CH2}"
+PATH_MUX_9546_0_CH3="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9546_0_CH3}"
+PATH_MUX_9546_1_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9546_1_CH0}"
+PATH_MUX_9546_1_CH1="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9546_1_CH1}"
+PATH_MUX_9548_2_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH0}"
+PATH_MUX_9548_2_CH1="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH1}"
+PATH_MUX_9548_2_CH2="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH2}"
+PATH_MUX_9548_2_CH3="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH3}"
+PATH_MUX_9548_2_CH4="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH4}"
+PATH_MUX_9548_2_CH5="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH5}"
+PATH_MUX_9548_2_CH6="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH6}"
+PATH_MUX_9548_2_CH7="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_2_CH7}"
+PATH_MUX_9548_3_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_3_CH0}"
+PATH_MUX_9548_4_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_4_CH0}"
+PATH_MUX_9548_5_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_5_CH0}"
+PATH_MUX_9548_6_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_6_CH0}"
+PATH_MUX_9548_7_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_7_CH0}"
+PATH_MUX_9548_8_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_8_CH0}"
+PATH_MUX_9548_9_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_9_CH0}"
+PATH_MUX_9548_10_CH0="${PATH_SYS_I2C_DEVICES}/i2c-${NUM_MUX_9548_10_CH0}"
+PATH_CPLD1_DEVICE="${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_CPLD1}"
+PATH_CPLD2_DEVICE="${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_CPLD2}"
+PATH_CPLD3_DEVICE="${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_CPLD3}"
+PATH_CPLD4_DEVICE="${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_CPLD4}"
+PATH_CPLD5_DEVICE="${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_CPLD5}"
+PATH_10GMUX=${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_10GMUX}
+
+
+# I2C Address
+### I2C MUX
+I2C_ADDR_MUX_9548_0=0x70
+I2C_ADDR_MUX_9548_1=0x73
+I2C_ADDR_MUX_9546_0=0x72
+I2C_ADDR_MUX_9546_1=0x71
+I2C_ADDR_MUX_9548_2=0x71
+I2C_ADDR_MUX_9548_3=0x74
+I2C_ADDR_MUX_9548_4=0x74
+I2C_ADDR_MUX_9548_5=0x74
+I2C_ADDR_MUX_9548_6=0x74
+I2C_ADDR_MUX_9548_7=0x74
+I2C_ADDR_MUX_9548_8=0x74
+I2C_ADDR_MUX_9548_9=0x74
+I2C_ADDR_MUX_9548_10=0x74
+
+### GPIO Expander
+I2C_ADDR_MUX_9539_0=0x76 # LED & HW ID
+I2C_ADDR_MUX_9539_1=0x76 # SYS config
+I2C_ADDR_MUX_9539_2=0x77 # on CPU board, STATUS and ERR from CPLD
+I2C_ADDR_MUX_9555_0=0x20 # on FAN board, fan status and led config
+I2C_ADDR_MUX_9555_1=0x24 # on BMC board, INT and HW ID
+I2C_ADDR_MUX_9555_2=0x25 # on BMC board, PSU status
+I2C_ADDR_MUX_9555_3=0x26 # on BMC board, RST and SEL
+I2C_ADDR_MUX_9555_3=0x26 # on BMC board, RST and SEL
+
+
+### peripheral
+I2C_ADDR_MB_EEPROM=0x55 # on main board
+I2C_ADDR_CB_EEPROM=0x51 # on cpu board
+I2C_ADDR_UCD9090=0x34
+I2C_ADDR_W83795=0x2F
+I2C_ADDR_PSU1_EEPROM=0x50
+I2C_ADDR_PSU2_EEPROM=0x50
+I2C_ADDR_LM75_1=0x4D # Rear Panel
+I2C_ADDR_LM75_2=0x4E # Rear MAC
+I2C_ADDR_LM75_3=0x4D # Front Panel
+I2C_ADDR_LM75_4=0x4E # Front MAC
+I2C_ADDR_TMP75_CB=0x4F # on cpu board
+I2C_ADDR_TMP75_BB=0x4A # on bmc board
+I2C_ADDR_QSFP_EEPROM=0x50
+I2C_ADDR_SFP_EEPROM=0x50
+I2C_ADDR_CPLD=0x33
+I2C_ADDR_10GMUX=0x67
+
+#sysfs
+PATH_SYSFS_PSU1="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_PSU1_EEPROM}-$(printf "%04x" $I2C_ADDR_PSU1_EEPROM)"
+PATH_SYSFS_PSU2="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_PSU2_EEPROM}-$(printf "%04x" $I2C_ADDR_PSU2_EEPROM)"
+
+#ACTIVE LOW enable flag
+ACTIVE_LOW_EN=1
+ACTIVE_HIGH_EN=0
+#GPIO Direction In/Out
+DIR_IN=in
+DIR_OUT=out
+
+#Power Supply Status
+PSU_DC_ON=1
+PSU_DC_OFF=0
+PSU_EXIST=1
+PSU_NOT_EXIST=0
+
+# IO expander register
+# direction
+REG_PORT0_DIR=6
+REG_PORT1_DIR=7
+# polarity
+REG_PORT0_POL=4
+REG_PORT1_POL=5
+# output
+REG_PORT0_OUT=2
+REG_PORT1_OUT=3
+# input
+REG_PORT0_IN=0
+REG_PORT1_IN=1
+
+# qsfp port number range
+MIN_QSFP_PORT_NUM=1
+MAX_QSFP_PORT_NUM=64
+
+# sfp+ port number range
+MIN_SFP_PORT_NUM=1
+MAX_SFP_PORT_NUM=2
+
+# CPLD access
+# port status
+CPLD_QSFP_STATUS_KEY=cpld_qsfp_port_status
+CPLD_SFP_STATUS_KEY=cpld_sfp_port_status
+# bit define
+CPLD_QSFP_STATUS_ABS_BIT=1
+CPLD_SFP_STATUS_PRES_BIT=0
+
+# Help usage function
+function _help {
+ echo "========================================================="
+ echo "# Description: Help Function"
+ echo "========================================================="
+ echo "----------------------------------------------------"
+ echo "EX : ${0} help"
+ echo " : ${0} i2c_init"
+ echo " : ${0} i2c_deinit"
+ echo " : ${0} i2c_fan_speed_init"
+ echo " : ${0} i2c_io_exp_init"
+ echo " : ${0} i2c_led_test"
+ echo " : ${0} i2c_psu_eeprom_get"
+ echo " : ${0} i2c_mb_eeprom_get"
+ echo " : ${0} i2c_cb_eeprom_get"
+ #echo " : ${0} i2c_eeprom_sync"
+ echo " : ${0} i2c_qsfp_eeprom_get [${MIN_QSFP_PORT_NUM}-${MAX_QSFP_PORT_NUM}]"
+ echo " : ${0} i2c_sfp_eeprom_get [${MIN_SFP_PORT_NUM}-${MAX_SFP_PORT_NUM}]"
+ echo " : ${0} i2c_qsfp_eeprom_init new|delete"
+ echo " : ${0} i2c_sfp_eeprom_init new|delete"
+ echo " : ${0} i2c_mb_eeprom_init new|delete"
+ echo " : ${0} i2c_cb_eeprom_init new|delete"
+ echo " : ${0} i2c_qsfp_status_get [${MIN_QSFP_PORT_NUM}-${MAX_QSFP_PORT_NUM}]"
+ echo " : ${0} i2c_sfp_status_get [${MIN_SFP_PORT_NUM}-${MAX_SFP_PORT_NUM}]"
+ echo " : ${0} i2c_qsfp_type_get [${MIN_QSFP_PORT_NUM}-${MAX_QSFP_PORT_NUM}]"
+ echo " : ${0} i2c_sfp_type_get [${MIN_SFP_PORT_NUM}-${MAX_SFP_PORT_NUM}]"
+ echo " : ${0} i2c_board_type_get"
+ echo " : ${0} i2c_bmc_board_type_get"
+ echo " : ${0} i2c_cpld_version"
+ echo " : ${0} i2c_psu_status"
+ echo " : ${0} i2c_led_psu_status_set"
+ echo " : ${0} i2c_led_fan_status_set"
+ echo " : ${0} i2c_led_fan_tray_status_set"
+ echo " : ${0} i2c_test_all"
+ echo " : ${0} i2c_sys_led green|amber"
+ echo " : ${0} i2c_fan_led green|amber|off"
+ echo " : ${0} i2c_psu1_led green|amber|off"
+ echo " : ${0} i2c_psu2_led green|amber|off"
+ echo " : ${0} i2c_fan_tray_led green|amber on|off [1-4]"
+ echo " : ${0} i2c_10g_mux cpu|fp"
+ echo "----------------------------------------------------"
+}
+
+#Pause function
+function _pause {
+ read -p "$*"
+}
+
+#Retry command function
+function _retry {
+ local i
+ for i in {1..5};
+ do
+ eval "${*}" && break || echo "retry"; sleep 1;
+ done
+}
+
+#logical(front panel) to physical (falcon core) port mapping
+function _port_logic2phy {
+
+ local logic_port=$1
+ local phy_port=0
+
+ if (( $logic_port >=1 && $logic_port <= 32 )) ; then
+ phy_port=$(( (logic_port-1)/2*4 + (logic_port-1)%2 + 1))
+ elif (( $logic_port >=33 && $logic_port <= 64 )) ; then
+ phy_port=$(( (((logic_port-1)%32))/2*4 + (logic_port-1)%2 + 3))
+ fi
+
+ echo $phy_port
+}
+
+#I2C Init
+function _i2c_init {
+ echo "========================================================="
+ echo "# Description: I2C Init"
+ echo "========================================================="
+
+ #rmmod i2c_ismt
+ _util_rmmod i2c_i801
+ modprobe i2c_i801
+ modprobe i2c_dev
+ modprobe i2c_mux_pca954x force_deselect_on_exit=1
+
+ # add MUX PCA9548#0 on I801, assume to be i2c-1~8
+ if [ ! -e ${PATH_MUX_9548_0_CH0} ]; then
+ _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_0}' > ${PATH_I801_DEVICE}/new_device"
+ else
+ echo "pca9548 ${I2C_ADDR_MUX_9548_0} already init."
+ fi
+
+ # add MUX PCA9548#1 on I801, assume to be i2c-9~16
+ if [ ! -e ${PATH_MUX_9548_1_CH0} ]; then
+ _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_1}' > ${PATH_I801_DEVICE}/new_device"
+ else
+ echo "pca9548 ${I2C_ADDR_MUX_9548_1} already init."
+ fi
+
+ # add MUX PCA9546#0 on I801, assume to be i2c-17~20
+ if [ ! -e ${PATH_MUX_9546_0_CH0} ]; then
+ _retry "echo 'pca9546 ${I2C_ADDR_MUX_9546_0}' > ${PATH_I801_DEVICE}/new_device"
+ else
+ echo "pca9546 ${I2C_ADDR_MUX_9546_0} already init."
+ fi
+
+ # add MUX PCA9546#1 on PCA9546#0 CH3, assume to be i2c-21~24
+ if [ ! -e ${PATH_MUX_9546_1_CH0} ]; then
+ _retry "echo 'pca9546 ${I2C_ADDR_MUX_9546_1}' > ${PATH_MUX_9546_0_CH3}/new_device"
+ else
+ echo "pca9546 ${I2C_ADDR_MUX_9546_1} already init."
+ fi
+
+ # add MUX PCA9548#2 on PCA9546#0 CH2, assume to be i2c-25~32
+ if [ ! -e ${PATH_MUX_9548_2_CH0} ]; then
+ _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_2}' > ${PATH_MUX_9546_0_CH2}/new_device"
+ else
+ echo "pca9548 ${I2C_ADDR_MUX_9548_2} already init."
+ fi
+
+ # add MUX PCA9548#3 on PCA9548#2 CH0, assume to be i2c-33~40
+ if [ ! -e ${PATH_MUX_9548_3_CH0} ]; then
+ _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_3}' > ${PATH_MUX_9548_2_CH0}/new_device"
+ else
+ echo "pca9548 ${I2C_ADDR_MUX_9548_3} already init."
+ fi
+
+ # add MUX PCA9548#4 on PCA9548#2 CH1, assume to be i2c-41~48
+ if [ ! -e ${PATH_MUX_9548_4_CH0} ]; then
+ _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_4}' > ${PATH_MUX_9548_2_CH1}/new_device"
+ else
+ echo "pca9548 ${I2C_ADDR_MUX_9548_4} already init."
+ fi
+
+ # add MUX PCA9548#5 on PCA9548#2 CH2, assume to be i2c-49~56
+ if [ ! -e ${PATH_MUX_9548_5_CH0} ]; then
+ _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_5}' > ${PATH_MUX_9548_2_CH2}/new_device"
+ else
+ echo "pca9548 ${I2C_ADDR_MUX_9548_5} already init."
+ fi
+
+ # add MUX PCA9548#6 on PCA9548#2 CH3, assume to be i2c-57~64
+ if [ ! -e ${PATH_MUX_9548_6_CH0} ]; then
+ _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_6}' > ${PATH_MUX_9548_2_CH3}/new_device"
+ else
+ echo "pca9548 ${I2C_ADDR_MUX_9548_6} already init."
+ fi
+
+ # add MUX PCA9548#7 on PCA9548#2 CH4, assume to be i2c-65~72
+ if [ ! -e ${PATH_MUX_9548_7_CH0} ]; then
+ _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_7}' > ${PATH_MUX_9548_2_CH4}/new_device"
+ else
+ echo "pca9548 ${I2C_ADDR_MUX_9548_7} already init."
+ fi
+
+ # add MUX PCA9548#8 on PCA9548#2 CH5, assume to be i2c-73~80
+ if [ ! -e ${PATH_MUX_9548_8_CH0} ]; then
+ _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_8}' > ${PATH_MUX_9548_2_CH5}/new_device"
+ else
+ echo "pca9548 ${I2C_ADDR_MUX_9548_8} already init."
+ fi
+
+ # add MUX PCA9548#9 on PCA9548#2 CH6, assume to be i2c-81~88
+ if [ ! -e ${PATH_MUX_9548_9_CH0} ]; then
+ _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_9}' > ${PATH_MUX_9548_2_CH6}/new_device"
+ else
+ echo "pca9548 ${I2C_ADDR_MUX_9548_9} already init."
+ fi
+
+ # add MUX PCA9548#10 on PCA9548#2 CH7, assume to be i2c-89~96
+ if [ ! -e ${PATH_MUX_9548_10_CH0} ]; then
+ _retry "echo 'pca9548 ${I2C_ADDR_MUX_9548_10}' > ${PATH_MUX_9548_2_CH7}/new_device"
+ else
+ echo "pca9548 ${I2C_ADDR_MUX_9548_10} already init."
+ fi
+
+ _i2c_hwm_init
+ _util_rmmod eeprom
+ modprobe eeprom_mb
+ modprobe gpio-pca953x
+ _i2c_io_exp_init
+ _i2c_sensors_init
+ _i2c_cpld_init
+ _i2c_psu_init
+
+ _i2c_qsfp_eeprom_init "new"
+ _i2c_sfp_eeprom_init "new"
+ _i2c_mb_eeprom_init "new"
+ _i2c_cb_eeprom_init "new"
+ _i2c_fan_speed_init
+ _i2c_led_psu_status_set
+ _i2c_led_fan_status_set
+
+ # trun on sys led
+ echo "led_sys setup..."
+ COLOR_LED="green"
+ ONOFF_LED="on"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_sys_led
+
+ _config_rmem
+}
+
+#I2C Deinit
+function _i2c_deinit {
+ echo "i2c deinit..."
+ for mod in coretemp jc42 w83795 eeprom eeprom_mb gpio-pca953x i2c_mux_pca954x i2c_i801 ingrasys_s9230_64x_psu;
+ do
+ _util_rmmod $mod
+ done
+ echo "Done"
+}
+
+function _i2c_cpld_init {
+ echo "CPLD init..."
+ _util_rmmod ingrasys_s9230_64x_i2c_cpld
+ modprobe ingrasys_s9230_64x_i2c_cpld
+
+ # add cpld 1~5 to sysfs
+ for i in {1..5};
+ do
+ local cpld_bus="I2C_BUS_CPLD${i}"
+ local cpld_path="PATH_CPLD${i}_DEVICE"
+ dev_path="${PATH_SYS_I2C_DEVICES}/${!cpld_bus}-$(printf "%04x" ${I2C_ADDR_CPLD})"
+ if ! [ -L ${dev_path} ]; then
+ echo "ingrasys_cpld${i} ${I2C_ADDR_CPLD}" > ${!cpld_path}/new_device
+ else
+ echo "${dev_path} already exist"
+ fi
+ done
+
+ echo "Done"
+}
+
+function _i2c_sensors_init {
+ echo "SENSORS init..."
+ local dev_path
+ # to make sure hwmon index in sysfs as expected,
+ # need to remove kernel module and then probe them in expected order
+ # remove all sensors kernel module
+ _util_rmmod coretemp
+ _util_rmmod jc42
+ _util_rmmod w83795
+ # probe coretemp kernel module
+ modprobe coretemp
+ # probe hwmon kernel module
+ modprobe w83795
+ # add lm75 to sysfs
+ ####Main board thermal
+ ####lm75_1
+ dev_path="${PATH_SYS_I2C_DEVICES}/${NUM_MUX_9548_0_CH5}-$(printf "%04x" ${I2C_ADDR_LM75_1})"
+ if ! [ -L ${dev_path} ]; then
+ echo "lm75 ${I2C_ADDR_LM75_1}" > ${PATH_MUX_9548_0_CH5}/new_device # hwmon1
+ else
+ echo "${dev_path} already exist"
+ fi
+ ####lm75_2
+ dev_path="${PATH_SYS_I2C_DEVICES}/${NUM_MUX_9548_0_CH5}-$(printf "%04x" ${I2C_ADDR_LM75_2})"
+ if ! [ -L ${dev_path} ]; then
+ echo "lm75 ${I2C_ADDR_LM75_2}" > ${PATH_MUX_9548_0_CH5}/new_device #hwmon2
+ else
+ echo "${dev_path} already exist"
+ fi
+ ####lm75_3
+ dev_path="${PATH_SYS_I2C_DEVICES}/${NUM_MUX_9548_0_CH6}-$(printf "%04x" ${I2C_ADDR_LM75_3})"
+ if ! [ -L ${dev_path} ]; then
+ echo "lm75 ${I2C_ADDR_LM75_1}" > ${PATH_MUX_9548_0_CH6}/new_device # hwmon3
+ else
+ echo "${dev_path} already exist"
+ fi
+ ####lm75_4
+ dev_path="${PATH_SYS_I2C_DEVICES}/${NUM_MUX_9548_0_CH6}-$(printf "%04x" ${I2C_ADDR_LM75_4})"
+ if ! [ -L ${dev_path} ]; then
+ echo "lm75 ${I2C_ADDR_LM75_4}" > ${PATH_MUX_9548_0_CH6}/new_device #hwmon4
+ else
+ echo "${dev_path} already exist"
+ fi
+ ####BMC board thermal
+ dev_path="${PATH_SYS_I2C_DEVICES}/${NUM_MUX_9548_1_CH7}-$(printf "%04x" ${I2C_ADDR_TMP75_BB})"
+ if ! [ -L ${dev_path} ]; then
+ echo "tmp75 ${I2C_ADDR_TMP75_BB}" > ${PATH_MUX_9548_1_CH7}/new_device #hwmon5
+ else
+ echo "${dev_path} already exist"
+ fi
+ ####CPU board thermal
+ dev_path="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_MAIN}-$(printf "%04x" ${I2C_ADDR_TMP75_CB})"
+ if ! [ -L ${dev_path} ]; then
+ echo "tmp75 ${I2C_ADDR_TMP75_CB}" > ${PATH_I801_DEVICE}/new_device #hwmon6
+ else
+ echo "${dev_path} already exist"
+ fi
+ # add w83795 to sysfs
+ dev_path="${PATH_SYS_I2C_DEVICES}/${NUM_MUX_9548_1_CH7}-$(printf "%04x" ${I2C_ADDR_W83795})"
+ if ! [ -L ${dev_path} ]; then
+ echo "w83795adg ${I2C_ADDR_W83795}" > ${PATH_MUX_9548_1_CH7}/new_device #hwmon7
+ else
+ echo "${dev_path} already exist"
+ fi
+
+ # probe jc42 kernel module
+ modprobe jc42
+
+ echo "Done"
+}
+
+#FAN Speed Init
+function _i2c_fan_speed_init {
+ echo -n "FAN SPEED INIT..."
+ if [ -e "${PATH_HWMON_W83795_DEVICE}" ]; then
+ # init fan speed
+ echo 120 > ${PATH_HWMON_W83795_DEVICE}/device/pwm2
+ echo "SUCCESS"
+ else
+ echo "FAIL"
+ fi
+}
+
+# HWM init
+function _i2c_hwm_init {
+ echo "HWM INIT..."
+ # select bank0
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x00 0x80
+ # SW reset, Disable monitor
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x01 0x9C
+ # disable TR5/TR6 DTS
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x04 0x0
+ # enable FANIN1~8
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x06 0xFF
+ # disable FANIN9~14
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x07 0x00
+ # CLKIN clock frequency set as 48Mhz
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x01 0x1C
+ # select bank 2
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x00 0x82
+ # set PWM mode in FOMC
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x0F 0x00
+ # set 25KHz fan output frequency in F1OPFP&F2OPFP
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x18 0x84
+ _util_i2cset -y -r ${I2C_BUS_HWM} ${I2C_ADDR_W83795} 0x19 0x84
+}
+
+#IO Expander Init
+function _i2c_io_exp_init {
+ echo "========================================================="
+ echo "# Description: I2C IO Expender Init"
+ echo "========================================================="
+
+ # need to init BMC io expander first due to some io expander are reset default
+ echo "Init BMC INT & HW ID IO Expander"
+ # all input
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_1} ${REG_PORT0_DIR} 0xFF
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_1} ${REG_PORT1_DIR} 0xFF
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_1} ${REG_PORT0_POL} 0x00
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_1} ${REG_PORT1_POL} 0x00
+
+ echo "Init BMC PSU status IO Expander"
+ # PWRON default 0 (ACTIVE_LOW)
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_2} ${REG_PORT0_OUT} 0x00
+ # default 0 (ACTIVE_LOW)
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_2} ${REG_PORT1_OUT} 0x00
+ # I/O 0.2 0.5 output(PWRON), rest input
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_2} ${REG_PORT0_DIR} 0xDB
+ # I/O 1.0~1.1 input, 1.2~1.4 output (1.5~1.7 not enable)
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_2} ${REG_PORT1_DIR} 0xE3
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_2} ${REG_PORT0_POL} 0x00
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_2} ${REG_PORT1_POL} 0x00
+
+ echo "Init BMC RST and SEL IO Expander"
+ # RST default is 1 (ACTIVE_LOW)
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_3} ${REG_PORT0_OUT} 0x3F
+ # SEL default is 0 (HOST), EN default is 1 (ACTIVE_HIGH)
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_3} ${REG_PORT1_OUT} 0x1F
+ # I/O 0.0~0.5 output, 0.6~0.7 not use
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_3} ${REG_PORT0_DIR} 0xC0
+ # all output
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_3} ${REG_PORT1_DIR} 0x00
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_3} ${REG_PORT0_POL} 0x00
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9555_3} ${REG_PORT1_POL} 0x00
+
+ echo "Init System LED & HW ID IO Expander"
+ # I/O_0.x for System LED default 0, I/O_1.x for HW ID
+ _util_i2cset -y -r ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${REG_PORT0_OUT} 0x00
+ # System LED => all output
+ _util_i2cset -y -r ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${REG_PORT0_DIR} 0x00
+ # HW ID => all input
+ _util_i2cset -y -r ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${REG_PORT1_DIR} 0xFF
+ _util_i2cset -y -r ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${REG_PORT0_POL} 0x00
+ _util_i2cset -y -r ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${REG_PORT1_POL} 0x00
+
+ echo "Init FAN Board Status IO Expander"
+ # LED_G_H set to 1, LED_Y_G set to 0 (ACTIVE_HIGH)
+ _util_i2cset -y -r ${I2C_BUS_FAN_STATUS} ${I2C_ADDR_MUX_9555_0} ${REG_PORT0_OUT} 0x11
+ _util_i2cset -y -r ${I2C_BUS_FAN_STATUS} ${I2C_ADDR_MUX_9555_0} ${REG_PORT1_OUT} 0x11
+ # DIR/ABS is input, LED_Y/LED_G is output
+ _util_i2cset -y -r ${I2C_BUS_FAN_STATUS} ${I2C_ADDR_MUX_9555_0} ${REG_PORT0_DIR} 0xCC
+ _util_i2cset -y -r ${I2C_BUS_FAN_STATUS} ${I2C_ADDR_MUX_9555_0} ${REG_PORT1_DIR} 0xCC
+ _util_i2cset -y -r ${I2C_BUS_FAN_STATUS} ${I2C_ADDR_MUX_9555_0} ${REG_PORT0_POL} 0x00
+ _util_i2cset -y -r ${I2C_BUS_FAN_STATUS} ${I2C_ADDR_MUX_9555_0} ${REG_PORT1_POL} 0x00
+
+ echo "Init System SEL and RST IO Expander"
+ # RST 0.0~0.3 default 1 (ACTIVE low), rest default 0
+ # SEL set to value 0 (host)
+ # LED_CLR set to 0 will clear all switch LED bitmap, set to 1 here
+ _util_i2cset -y -r ${NUM_MUX_9548_1_CH2} ${I2C_ADDR_MUX_9539_1} ${REG_PORT0_OUT} 0x0F
+ # RST 1.6~1.7 default 1 (ACTIVE low), INT 1.0~1.4 default 1 (ACTIVE low)
+ _util_i2cset -y -r ${NUM_MUX_9548_1_CH2} ${I2C_ADDR_MUX_9539_1} ${REG_PORT1_OUT} 0xDF
+ # all output, but MAC_RST_L 0.0 need to set as input to prevent reboot issue
+ _util_i2cset -y -r ${NUM_MUX_9548_1_CH2} ${I2C_ADDR_MUX_9539_1} ${REG_PORT0_DIR} 0x09
+ # RST 1.5 !~ 1.7 output, rest are input
+ _util_i2cset -y -r ${NUM_MUX_9548_1_CH2} ${I2C_ADDR_MUX_9539_1} ${REG_PORT1_DIR} 0x1F
+ _util_i2cset -y -r ${NUM_MUX_9548_1_CH2} ${I2C_ADDR_MUX_9539_1} ${REG_PORT0_POL} 0x00
+ _util_i2cset -y -r ${NUM_MUX_9548_1_CH2} ${I2C_ADDR_MUX_9539_1} ${REG_PORT1_POL} 0x00
+
+ echo "Init CPU CPLD IO Expander"
+ # all input
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_2} ${REG_PORT0_DIR} 0xFF
+ # all input
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_2} ${REG_PORT1_DIR} 0xFF
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_2} ${REG_PORT0_POL} 0x00
+ _util_i2cset -y -r ${I2C_BUS_MAIN} ${I2C_ADDR_MUX_9539_2} ${REG_PORT1_POL} 0x00
+}
+
+#Set FAN Tray LED
+function _i2c_led_fan_tray_status_set {
+ echo "FAN Tray Status Setup"
+ #FAN Status get
+ FAN1_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan1_alarm`
+ FAN2_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan3_alarm`
+ FAN3_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan5_alarm`
+ FAN4_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan7_alarm`
+
+ # check if io expander for fan tray exist
+ result=`i2cget -y ${I2C_BUS_FANTRAY_LED} ${I2C_ADDR_MUX_9555_0} ${REG_PORT0_IN} 2>/dev/null`
+ err_code=$?
+ if [ "$err_code" != "0" ]; then
+ echo "fan tray not exist!"
+ return
+ fi
+
+ for FAN_TRAY in {1..4};
+ do
+ FAN_ALARM="FAN${FAN_TRAY}_ALARM"
+ if [ "${!FAN_ALARM}" == "0" ]; then
+ COLOR_LED="green"
+ ONOFF_LED="on"
+ _i2c_fan_tray_led
+
+ COLOR_LED="amber"
+ ONOFF_LED="off"
+ _i2c_fan_tray_led
+
+ echo "set [FAN TRAY ${FAN_TRAY}] [Green]=on [Amber]=off"
+ else
+ COLOR_LED="green"
+ ONOFF_LED="off"
+ _i2c_fan_tray_led
+
+ COLOR_LED="amber"
+ ONOFF_LED="on"
+ _i2c_fan_tray_led
+
+ echo "set [FAN TRAY ${FAN_TRAY}] [Green]=off [Amber]=on"
+ fi
+ done
+}
+
+#Set FAN LED
+function _i2c_led_fan_status_set {
+ echo "FAN Status Setup"
+ #PSU Status set
+ FAN1_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan1_alarm`
+ FAN3_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan3_alarm`
+ FAN5_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan5_alarm`
+ FAN7_ALARM=`cat ${PATH_HWMON_W83795_DEVICE}/device/fan7_alarm`
+
+ echo "led_fan setup..."
+ # all fan ok
+ if [ "${FAN1_ALARM}" == "0" ] \
+ && [ "${FAN3_ALARM}" == "0" ] \
+ && [ "${FAN5_ALARM}" == "0" ] \
+ && [ "${FAN7_ALARM}" == "0" ]; then
+ COLOR_LED="green"
+ echo "${COLOR_LED}"
+ _i2c_fan_led
+ # all fan fail
+ elif [ "${FAN1_ALARM}" == "1" ] \
+ && [ "${FAN3_ALARM}" == "1" ] \
+ && [ "${FAN5_ALARM}" == "1" ] \
+ && [ "${FAN7_ALARM}" == "1" ] ; then
+ COLOR_LED="amber"
+ echo "${COLOR_LED}"
+ _i2c_fan_led
+ # partial fan fail
+ else
+ COLOR_LED="amber"
+ echo "${COLOR_LED}"
+ _i2c_fan_led
+ fi
+}
+
+#Set Power Supply LED
+function _i2c_led_psu_status_set {
+ echo "PSU LED Status Setup"
+
+ #PSU Status set
+ _i2c_psu_status
+
+ #PSU1 Status
+ echo "led_psu1 setup..."
+ if [ "${psu1Exist}" == ${PSU_EXIST} ]; then
+ if [ "${psu1PwGood}" == ${PSU_DC_ON} ]; then
+ COLOR_LED="green"
+ echo "${COLOR_LED}"
+ _i2c_psu1_led
+ else
+ COLOR_LED="amber"
+ echo "${COLOR_LED}"
+ _i2c_psu1_led
+ fi
+ else
+ COLOR_LED="off"
+ echo "${COLOR_LED}"
+ _i2c_psu1_led
+ fi
+
+ #PSU2 Status
+ echo "led_psu2 setup..."
+ if [ "${psu2Exist}" == ${PSU_EXIST} ]; then
+ if [ "${psu2PwGood}" == ${PSU_DC_ON} ]; then
+ COLOR_LED="green"
+ echo "${COLOR_LED}"
+ _i2c_psu2_led
+ else
+ COLOR_LED="amber"
+ echo "${COLOR_LED}"
+ _i2c_psu2_led
+ fi
+ else
+ COLOR_LED="off"
+ echo "${COLOR_LED}"
+ _i2c_psu2_led
+ fi
+}
+
+#LED Test
+function _i2c_led_test {
+ echo "========================================================="
+ echo "# Description: I2C SYSTEM LED TEST..."
+ echo "========================================================="
+ local output_reg=${REG_PORT0_OUT}
+ local mask=0xFF
+ local value=0xFF
+
+ #sys led (green)
+ # set sys_led_g (0.7) = 1
+ mask=0x80
+ value=0x80
+ _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value}
+ _pause 'Check SYS LED green light and Press [Enter] key to continue...'
+ #sys led (amber)
+ # set sys_led_g (0.7) = 0
+ mask=0x80
+ value=0x00
+ _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value}
+ _pause 'Check SYS LED amber light and Press [Enter] key to continue...'
+
+ #FAN led (green)
+ # set fan_led_en (0.6) = 1 & fan_led_y (0.5) = 0
+ mask=0x60
+ value=0x60
+ _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value}
+ _pause 'Check FAN LED green light and Press [Enter] key to continue...'
+ #FAN led (amber)
+ # set fan_led_en (0.6) = 1 & fan_led_y (0.5) = 1
+ mask=0x60
+ value=0x40
+ _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value}
+ _pause 'Check FAN LED amber light and Press [Enter] key to continue...'
+
+ #PSU1 led (green)
+ # set psu1_pwr_ok_oe (0.4) = 1 & psu1_led_y (0.3) = 0
+ mask=0x18
+ value=0x18
+ _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value}
+ _pause 'Check PSU1 LED green light and Press [Enter] key to continue...'
+ #PSU1 led (amber)
+ # set psu1_pwr_ok_oe (0.4) = 1 & psu1_led_y (0.3) = 1
+ mask=0x18
+ value=0x10
+ _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value}
+ _pause 'Check PSU1 LED amber light and Press [Enter] key to continue...'
+
+ #PSU2 led (green)
+ # set psu0_pwr_ok_oe (0.2) = 1 & psu0_led_y (0.1) = 0
+ mask=0x06
+ value=0x06
+ _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value}
+ _pause 'Check PSU2 LED green light and Press [Enter] key to continue...'
+ #PSU2 led (amber)
+ # set psu0_pwr_ok_oe (0.2) = 1 & psu0_led_y (0.1) = 1
+ mask=0x06
+ value=0x04
+ _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value}
+ _pause 'Check PSU2 LED amber light and Press [Enter] key to continue...'
+
+ #Turn OFF All LED (can't trun off system led)
+ # set set fan_led_en (0.6), psu1_pwr_ok_oe (0.4), psu0_pwr_ok_oe (0.2) = 0
+ mask=0xFF
+ value=$((2#00000011))
+ _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value}
+ _pause 'Check turn off all LEDs (exclude SYS LED) and Press [Enter] key to continue...'
+
+ # restore sys led
+ COLOR_LED="green"
+ ONOFF_LED="on"
+ echo "${COLOR_LED} ${ONOFF_LED}"
+ _i2c_sys_led
+}
+
+#Set QSFP Port cpld variable
+function _qsfp_cpld_var_set {
+ local port=$1
+ local reg_port_base
+ local reg_port_shift
+ if [[ $1 -le 12 && $1 -ge 1 ]]; then
+ cpld_index=1
+ reg_port_base=0
+ elif [[ $1 -le 25 && $1 -ge 13 ]]; then
+ cpld_index=2
+ reg_port_base=12
+ elif [[ $1 -le 38 && $1 -ge 26 ]]; then
+ cpld_index=3
+ reg_port_base=25
+ elif [[ $1 -le 51 && $1 -ge 39 ]]; then
+ cpld_index=4
+ reg_port_base=38
+ elif [[ $1 -le 64 && $1 -ge 52 ]]; then
+ cpld_index=5
+ reg_port_base=51
+ else
+ echo "invalid port number"
+ fi
+
+ cpld_port_index=$(( $port - $reg_port_base ))
+}
+
+#Set QSFP Port eeporm variable
+function _qsfp_eeprom_var_set {
+ local port=$1
+ local eeprombusbase
+ local eeprombusshift
+ # port 1 => zqsfp0
+ # port 2 => zqsfp1
+ # ...
+ local port_group=$(( ($port - 1) / 8 ))
+
+ case ${port_group} in
+ 0)
+ eeprombusbase=${NUM_MUX_9548_3_CH0}
+ ;;
+ 1)
+ eeprombusbase=${NUM_MUX_9548_4_CH0}
+ ;;
+ 2)
+ eeprombusbase=${NUM_MUX_9548_5_CH0}
+ ;;
+ 3)
+ eeprombusbase=${NUM_MUX_9548_6_CH0}
+ ;;
+ 4)
+ eeprombusbase=${NUM_MUX_9548_7_CH0}
+ ;;
+ 5)
+ eeprombusbase=${NUM_MUX_9548_8_CH0}
+ ;;
+ 6)
+ eeprombusbase=${NUM_MUX_9548_9_CH0}
+ ;;
+ 7)
+ eeprombusbase=${NUM_MUX_9548_10_CH0}
+ ;;
+ *)
+ ;;
+ esac
+
+ eeprombusshift=$(( (${port} - 1) % 8))
+ eepromBus=$(( ${eeprombusbase} + ${eeprombusshift} ))
+ eepromAddr=${I2C_ADDR_QSFP_EEPROM}
+}
+
+
+#Set SFP Port cpld variable
+function _sfp_cpld_var_set {
+ local port=$1
+ case ${port} in
+ 1)
+ cpld_index=1
+ ;;
+ 2)
+ cpld_index=2
+ ;;
+ *)
+ ;;
+ esac
+}
+
+#Set QSFP Port eeporm variable
+function _sfp_eeprom_var_set {
+ local port=$1
+
+ case ${port} in
+ 1)
+ eepromBus=${NUM_MUX_9546_1_CH0}
+ ;;
+ 2)
+ eepromBus=${NUM_MUX_9546_1_CH1}
+ ;;
+ *)
+ ;;
+ esac
+
+ eepromAddr=${I2C_ADDR_SFP_EEPROM}
+}
+
+#Get QSFP EEPROM Information
+function _i2c_qsfp_eeprom_get {
+ local phy_port=0
+
+ #get physical port
+ phy_port=$(_port_logic2phy $QSFP_PORT)
+
+ # input parameter validation
+ _util_input_check "${QSFP_PORT}" "${MIN_QSFP_PORT_NUM}" "${MAX_QSFP_PORT_NUM}"
+
+ _qsfp_eeprom_var_set ${phy_port}
+
+ _util_get_qsfp_abs
+
+ if [ $status = 0 ]; then
+ exit
+ fi
+
+
+ cat ${PATH_SYS_I2C_DEVICES}/$eepromBus-$(printf "%04x" $eepromAddr)/eeprom | hexdump -C
+}
+
+#Init QSFP EEPROM
+function _i2c_qsfp_eeprom_init {
+ echo "QSFP EEPROM INIT..."
+
+ #Action check
+ action=$1
+ if [ -z "${action}" ]; then
+ echo "No action, skip"
+ return
+ elif [ "${action}" != "new" ] && [ "${action}" != "delete" ]; then
+ echo "Error action, skip"
+ return
+ fi
+
+ #Init 1-64 ports EEPROM
+ local i
+ for i in {1..64};
+ do
+ _qsfp_eeprom_var_set ${i}
+
+ if [ "${action}" == "new" ] && \
+ ! [ -L ${PATH_SYS_I2C_DEVICES}/$eepromBus-$(printf "%04x" $eepromAddr) ]; then
+ echo "sff8436 $eepromAddr" > ${PATH_SYS_I2C_DEVICES}/i2c-$eepromBus/new_device
+ elif [ "${action}" == "delete" ] && \
+ [ -L ${PATH_SYS_I2C_DEVICES}/$eepromBus-$(printf "%04x" $eepromAddr) ]; then
+ echo "$eepromAddr" > ${PATH_SYS_I2C_DEVICES}/i2c-$eepromBus/delete_device
+ fi
+ done
+ echo "Done"
+}
+
+#Get SFP EEPROM Information
+function _i2c_sfp_eeprom_get {
+
+ # input parameter validation
+ _util_input_check "${SFP_PORT}" "${MIN_SFP_PORT_NUM}" "${MAX_SFP_PORT_NUM}"
+ _util_get_sfp_pres
+
+ if [ $status = 0 ]; then
+ exit
+ fi
+
+ _sfp_eeprom_var_set ${SFP_PORT}
+
+ cat ${PATH_SYS_I2C_DEVICES}/$eepromBus-$(printf "%04x" $eepromAddr)/eeprom | hexdump -C
+}
+
+#Init SFP EEPROM
+function _i2c_sfp_eeprom_init {
+ echo "SFP EEPROM INIT..."
+
+ #Action check
+ action=$1
+ if [ -z "${action}" ]; then
+ echo "No action, skip"
+ return
+ elif [ "${action}" != "new" ] && [ "${action}" != "delete" ]; then
+ echo "Error action, skip"
+ return
+ fi
+
+ #Init 1-2 sfp+ EEPROM
+ local i
+ for i in {1..2};
+ do
+ _sfp_eeprom_var_set ${i}
+
+ if [ "${action}" == "new" ] && \
+ ! [ -L ${PATH_SYS_I2C_DEVICES}/$eepromBus-$(printf "%04x" $eepromAddr) ]; then
+ echo "sff8436 $eepromAddr" > ${PATH_SYS_I2C_DEVICES}/i2c-$eepromBus/new_device
+ elif [ "${action}" == "delete" ] && \
+ [ -L ${PATH_SYS_I2C_DEVICES}/$eepromBus-$(printf "%04x" $eepromAddr) ]; then
+ echo "$eepromAddr" > ${PATH_SYS_I2C_DEVICES}/i2c-$eepromBus/delete_device
+ fi
+ done
+ echo "Done"
+}
+
+#Init Main Board EEPROM
+function _i2c_mb_eeprom_init {
+ echo -n "Main Board EEPROM INIT..."
+
+ #Action check
+ action=$1
+ if [ -z "${action}" ]; then
+ echo "No action, skip"
+ return
+ elif [ "${action}" != "new" ] && [ "${action}" != "delete" ]; then
+ echo "Error action, skip"
+ return
+ fi
+
+ #Init mb EEPROM
+ if [ "${action}" == "new" ] && \
+ ! [ -L ${PATH_SYS_I2C_DEVICES}/${I2C_BUS_MB_EEPROM}-$(printf "%04x" $I2C_ADDR_MB_EEPROM) ]; then
+ echo "mb_eeprom ${I2C_ADDR_MB_EEPROM}" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_MB_EEPROM}/new_device
+ elif [ "${action}" == "delete" ] && \
+ [ -L ${PATH_SYS_I2C_DEVICES}/${I2C_BUS_MB_EEPROM}-$(printf "%04x" $I2C_ADDR_MB_EEPROM) ]; then
+ echo "$I2C_ADDR_MB_EEPROM" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_MB_EEPROM}/delete_device
+ fi
+ echo "Done"
+}
+
+#Init CPU Board EEPROM
+function _i2c_cb_eeprom_init {
+ echo -n "CPU Board EEPROM INIT..."
+
+ #Action check
+ action=$1
+ if [ -z "${action}" ]; then
+ echo "No action, skip"
+ return
+ elif [ "${action}" != "new" ] && [ "${action}" != "delete" ]; then
+ echo "Error action, skip"
+ return
+ fi
+
+ #Init cpu EEPROM
+ if [ "${action}" == "new" ] && \
+ ! [ -L ${PATH_SYS_I2C_DEVICES}/${I2C_BUS_CB_EEPROM}-$(printf "%04x" $I2C_ADDR_CB_EEPROM) ]; then
+ echo "mb_eeprom ${I2C_ADDR_CB_EEPROM}" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_CB_EEPROM}/new_device
+ elif [ "${action}" == "delete" ] && \
+ [ -L ${PATH_SYS_I2C_DEVICES}/${I2C_BUS_CB_EEPROM}-$(printf "%04x" $I2C_ADDR_CB_EEPROM) ]; then
+ echo "$I2C_ADDR_CB_EEPROM" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_CB_EEPROM}/delete_device
+ fi
+ echo "Done"
+}
+
+#Init PSU Kernel Module
+function _i2c_psu_init {
+ echo "========================================================="
+ echo "# Description: I2C PSU Init"
+ echo "========================================================="
+ modprobe ingrasys_s9230_64x_psu
+
+ echo "psu1 ${I2C_ADDR_PSU1_EEPROM}" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_PSU1_EEPROM}/new_device
+ echo "psu2 ${I2C_ADDR_PSU2_EEPROM}" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_PSU2_EEPROM}/new_device
+}
+
+#Deinit PSU Kernel Module
+function _i2c_psu_deinit {
+ echo "${I2C_ADDR_PSU1_EEPROM}" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_PSU1_EEPROM}/delete_device
+ echo "${I2C_ADDR_PSU2_EEPROM}" > ${PATH_SYS_I2C_DEVICES}/i2c-${I2C_BUS_PSU2_EEPROM}/delete_device
+ _util_rmmod ingrasys_s9230_64x_psu
+}
+
+#get QSFP Status
+function _i2c_qsfp_status_get {
+
+ # input parameter validation
+ _util_input_check "${QSFP_PORT}" "${MIN_QSFP_PORT_NUM}" "${MAX_QSFP_PORT_NUM}"
+
+ local stat
+ _util_get_qsfp_abs
+ echo "status=$status"
+}
+
+#get QSFP Type
+function _i2c_qsfp_type_get {
+ local phy_port=0
+
+ phy_port=$(_port_logic2phy ${QSFP_PORT})
+
+ # input parameter validation
+ _util_input_check "${QSFP_PORT}" "${MIN_QSFP_PORT_NUM}" "${MAX_QSFP_PORT_NUM}"
+
+ #_qsfp_eeprom_var_set ${QSFP_PORT}
+ _qsfp_eeprom_var_set ${phy_port}
+
+ #Get QSFP EEPROM info
+ qsfp_info=$(base64 ${PATH_SYS_I2C_DEVICES}/$eepromBus-$(printf "%04x" $eepromAddr)/eeprom)
+
+ identifier=$(echo $qsfp_info | base64 -d -i | hexdump -s 128 -n 1 -e '"%x"')
+ connector=$(echo $qsfp_info | base64 -d -i | hexdump -s 130 -n 1 -e '"%x"')
+ transceiver=$(echo $qsfp_info | base64 -d -i | hexdump -s 131 -n 1 -e '"%x"')
+
+ echo "identifier=$identifier"
+ echo "connector=$connector"
+ echo "transceiver=$transceiver"
+}
+
+function _i2c_sfp_status_get {
+
+ # input parameter validation
+ _util_input_check "${SFP_PORT}" "${MIN_SFP_PORT_NUM}" "${MAX_SFP_PORT_NUM}"
+
+ local stat
+ _util_get_sfp_pres
+ #status: 0 -> Down, 1 -> Up
+ if [ $status = 0 ]; then
+ stat="down"
+ else
+ stat="up"
+ fi
+ echo "status is $stat"
+}
+
+#get SFP Type
+function _i2c_sfp_type_get {
+
+ # input parameter validation
+ _util_input_check "${SFP_PORT}" "${MIN_SFP_PORT_NUM}" "${MAX_SFP_PORT_NUM}"
+
+ _sfp_eeprom_var_set ${SFP_PORT}
+
+ #Get QSFP EEPROM info
+ sfp_info=$(base64 ${PATH_SYS_I2C_DEVICES}/$eepromBus-$(printf "%04x" $eepromAddr)/eeprom)
+
+ identifier=$(echo $sfp_info | base64 -d -i | hexdump -s 128 -n 1 -e '"%x"')
+ connector=$(echo $sfp_info | base64 -d -i | hexdump -s 130 -n 1 -e '"%x"')
+ transceiver=$(echo $sfp_info | base64 -d -i | hexdump -s 131 -n 1 -e '"%x"')
+
+ echo "identifier=$identifier"
+ echo "connector=$connector"
+ echo "transceiver=$transceiver"
+}
+
+#Get PSU EEPROM Information
+function _i2c_psu_eeprom_get {
+ local eeprom_psu1=""
+ local eeprom_psu2=""
+
+ echo "========================================================="
+ echo "# Description: I2C PSU EEPROM Get..."
+ echo "========================================================="
+
+ eeprom_psu1="${PATH_SYSFS_PSU1}/psu_eeprom"
+ cat ${eeprom_psu1} | hexdump -C
+
+ eeprom_psu2="${PATH_SYSFS_PSU2}/psu_eeprom"
+ cat ${eeprom_psu2} | hexdump -C
+}
+
+#Get Main Board EEPROM Information
+function _i2c_mb_eeprom_get {
+ echo "========================================================="
+ echo "# Description: I2C MB EEPROM Get..."
+ echo "========================================================="
+ _i2c_sys_eeprom_get mb
+}
+
+#Get CPU Board EEPROM Information
+function _i2c_cb_eeprom_get {
+ echo "========================================================="
+ echo "# Description: I2C CB EEPROM Get..."
+ echo "========================================================="
+ _i2c_sys_eeprom_get cb
+}
+
+#Get system EEPROM Information
+##input: "cb" for cpu board, "mb" for main board
+function _i2c_sys_eeprom_get {
+ local eeprom_dev
+
+ if [ "$1" == "cb" ]; then
+ eeprom_dev="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_CB_EEPROM}-$(printf "%04x" $I2C_ADDR_CB_EEPROM)/eeprom"
+ elif [ "$1" == "mb" ]; then
+ eeprom_dev="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_MB_EEPROM}-$(printf "%04x" $I2C_ADDR_MB_EEPROM)/eeprom"
+ else
+ echo "wrong eeprom type"
+ return
+ fi
+
+ # check if eeprom device exist in sysfs
+ if [ ! -f ${eeprom_dev} ]; then
+ echo "eeprom device not init"
+ return
+ fi
+
+ cat ${eeprom_dev} | hexdump -C
+ echo "Done"
+}
+
+#sync eeprom content between mb and cb eeprom
+function _i2c_eeprom_sync {
+ echo "========================================================="
+ echo "# Description: EEPROM sync..."
+ echo "========================================================="
+
+ local mb_eeprom_dev="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_MB_EEPROM}-$(printf "%04x" $I2C_ADDR_MB_EEPROM)/eeprom"
+ local cb_eeprom_dev="${PATH_SYS_I2C_DEVICES}/${I2C_BUS_CB_EEPROM}-$(printf "%04x" $I2C_ADDR_CB_EEPROM)/eeprom"
+
+ # check if eeprom device exist in sysfs
+ if [[ ! -f ${mb_eeprom_dev} || ! -f ${cb_eeprom_dev} ]]; then
+ echo "eeprom device not init"
+ return
+ fi
+
+ ## check if MB eeprom is empty
+ if [ ! -z "$(cat ${mb_eeprom_dev} | hexdump -n2 | grep ffff)" ]; then
+ echo "copy cb eeprom to mb eeprom..."
+ cat ${cb_eeprom_dev} > ${mb_eeprom_dev}
+ else
+ echo "no need to sync"
+ fi
+
+ echo "Done"
+}
+
+#Set System Status LED
+function _i2c_sys_led {
+ # only green/amber, on/off can't control
+ if [ "${COLOR_LED}" == "green" ]; then
+ # set sys_led_g (0.7) = 1
+ output_reg=${REG_PORT0_OUT}
+ mask=0x80
+ value=0x80
+ elif [ "${COLOR_LED}" == "amber" ]; then
+ # set sys_led_g (0.7) = 0
+ output_reg=${REG_PORT0_OUT}
+ mask=0x80
+ value=0x00
+ else
+ echo "Invalid Parameters, Exit!!!"
+ _help
+ exit ${FALSE}
+ fi
+
+ #apply to io expander
+ _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value}
+ echo "Done"
+}
+
+#Set FAN LED
+function _i2c_fan_led {
+ if [ "${COLOR_LED}" == "green" ]; then
+ # set fan_led_en (0.6) = 1 & fan_led_y (0.5) = 0
+ output_reg=${REG_PORT0_OUT}
+ mask=0x60
+ value=0x60
+ elif [ "${COLOR_LED}" == "amber" ]; then
+ # set fan_led_en (0.6) = 1 & fan_led_y (0.5) = 1
+ output_reg=${REG_PORT0_OUT}
+ mask=0x60
+ value=0x40
+ elif [ "${COLOR_LED}" == "off" ]; then
+ # set fan_led_en (0.6) = 0 & fan_led_y (0.5) = 0
+ output_reg=${REG_PORT0_OUT}
+ mask=0x60
+ value=0x00
+ else
+ echo "Invalid Parameters, Exit!!!"
+ _help
+ exit ${FALSE}
+ fi
+
+ #apply to io expander
+ _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value}
+ echo "Done"
+}
+
+#Set PSU1 LED
+function _i2c_psu1_led {
+ if [ "${COLOR_LED}" == "green" ]; then
+ # set psu1_pwr_ok_oe (0.4) = 1 & psu1_led_y (0.3) = 0
+ output_reg=${REG_PORT0_OUT}
+ mask=0x18
+ value=0x18
+ elif [ "${COLOR_LED}" == "amber" ]; then
+ # set psu1_pwr_ok_oe (0.4) = 1 & psu1_led_y (0.3) = 1
+ output_reg=${REG_PORT0_OUT}
+ mask=0x18
+ value=0x10
+ elif [ "${COLOR_LED}" == "off" ]; then
+ # set psu1_pwr_ok_oe (0.4) = 0 & psu1_led_y (0.3) = 0
+ output_reg=${REG_PORT0_OUT}
+ mask=0x18
+ value=0x00
+ else
+ echo "Invalid Parameters, Exit!!!"
+ _help
+ exit ${FALSE}
+ fi
+
+ #apply to io expander
+ _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value}
+ echo "Done"
+}
+
+#Set PSU2 LED
+function _i2c_psu2_led {
+ if [ "${COLOR_LED}" == "green" ]; then
+ # set psu0_pwr_ok_oe (0.2) = 1 & psu0_led_y (0.1) = 0
+ output_reg=${REG_PORT0_OUT}
+ mask=0x06
+ value=0x06
+ elif [ "${COLOR_LED}" == "amber" ]; then
+ # set psu0_pwr_ok_oe (0.2) = 1 & psu0_led_y (0.1) = 1
+ output_reg=${REG_PORT0_OUT}
+ mask=0x06
+ value=0x04
+ elif [ "${COLOR_LED}" == "off" ]; then
+ # set psu0_pwr_ok_oe (0.2) = 0 & psu0_led_y (0.1) = 0
+ output_reg=${REG_PORT0_OUT}
+ mask=0x06
+ value=0x00
+ else
+ echo "Invalid Parameters, Exit!!!"
+ _help
+ exit ${FALSE}
+ fi
+
+ #apply to io expander
+ _util_i2cset -m ${mask} -y ${I2C_BUS_SYS_LED} ${I2C_ADDR_MUX_9539_0} ${output_reg} ${value}
+ echo "Done"
+}
+
+#Set FAN Tray LED
+function _i2c_fan_tray_led {
+
+ i2cAddr=${I2C_ADDR_MUX_9555_0}
+ output_reg=${REG_PORT0_OUT}
+
+ case ${FAN_TRAY} in
+ 1)
+ output_reg=${REG_PORT0_OUT}
+ if [ "${COLOR_LED}" == "green" ]; then
+ mask=0x01
+ elif [ "${COLOR_LED}" == "amber" ]; then
+ mask=0x02
+ fi
+ ;;
+ 2)
+ output_reg=${REG_PORT0_OUT}
+ if [ "${COLOR_LED}" == "green" ]; then
+ mask=0x10
+ elif [ "${COLOR_LED}" == "amber" ]; then
+ mask=0x20
+ fi
+ ;;
+ 3)
+ output_reg=${REG_PORT1_OUT}
+ if [ "${COLOR_LED}" == "green" ]; then
+ mask=0x01
+ elif [ "${COLOR_LED}" == "amber" ]; then
+ mask=0x02
+ fi
+ ;;
+ 4)
+ output_reg=${REG_PORT1_OUT}
+ if [ "${COLOR_LED}" == "green" ]; then
+ mask=0x10
+ elif [ "${COLOR_LED}" == "amber" ]; then
+ mask=0x20
+ fi
+ ;;
+ *)
+ echo "Please input 1~4"
+ exit
+ ;;
+ esac
+
+ # LED PIN value is ACTIVE HIGH
+ if [ "${COLOR_LED}" == "green" ] && [ "${ONOFF_LED}" == "on" ]; then
+ _util_i2cset -m $mask -y -r ${I2C_BUS_FANTRAY_LED} $i2cAddr ${output_reg} 0xff
+ elif [ "${COLOR_LED}" == "green" ] && [ "${ONOFF_LED}" == "off" ]; then
+ _util_i2cset -m $mask -y -r ${I2C_BUS_FANTRAY_LED} $i2cAddr ${output_reg} 0x00
+ elif [ "${COLOR_LED}" == "amber" ] && [ "${ONOFF_LED}" == "on" ]; then
+ _util_i2cset -m $mask -y -r ${I2C_BUS_FANTRAY_LED} $i2cAddr ${output_reg} 0xff
+ elif [ "${COLOR_LED}" == "amber" ] && [ "${ONOFF_LED}" == "off" ]; then
+ _util_i2cset -m $mask -y -r ${I2C_BUS_FANTRAY_LED} $i2cAddr ${output_reg} 0x00
+ else
+ echo "Invalid Parameters, Exit!!!"
+ _help
+ exit ${FALSE}
+ fi
+
+ echo "Done"
+}
+
+#Get Board Version and Type
+function _i2c_board_type_get {
+ # read input port 1 value from io expander
+ input_reg=${REG_PORT1_IN}
+ boardType=`i2cget -y ${I2C_BUS_HW_ID} ${I2C_ADDR_MUX_9539_0} ${input_reg}`
+ boardBuildRev=$((($boardType) & 0x03))
+ boardHwRev=$((($boardType) >> 2 & 0x03))
+ boardId=$((($boardType) >> 4))
+ printf "MAIN_BOARD BOARD_ID is 0x%02x, HW Rev 0x%02x, Build Rev 0x%02x\n" $boardId $boardHwRev $boardBuildRev
+}
+
+#Get BMC Board Version and Type
+function _i2c_bmc_board_type_get {
+ # read input port 1 value from io expander
+ input_reg=${REG_PORT1_IN}
+ boardType=`i2cget -y ${I2C_BUS_BMC_HW_ID} ${I2C_ADDR_MUX_9555_1} ${input_reg}`
+ boardBuildRev=$((($boardType) & 0x03))
+ boardHwRev=$((($boardType) >> 2 & 0x03))
+ boardId=$((($boardType) >> 4))
+ printf "BMC_BOARD BOARD_ID is 0x%02x, HW Rev 0x%02x, Build Rev 0x%02x\n" $boardId $boardHwRev $boardBuildRev
+}
+
+#Get CPLD Version
+function _i2c_cpld_version {
+ echo "========================================================="
+ echo "# Description: CPLD Version"
+ echo "========================================================="
+
+ for i in {1..5};
+ do
+ local cpld_bus="I2C_BUS_CPLD${i}"
+ local cpld_path="PATH_CPLD${i}_DEVICE"
+ local file_path="${PATH_SYS_I2C_DEVICES}/${!cpld_bus}-$(printf "%04x" ${I2C_ADDR_CPLD})/cpld_version"
+ printf "[CPLD %d] %s\n" ${i} $(cat ${file_path})
+ done
+}
+
+#Get PSU Status
+function _i2c_psu_status {
+ local psu_abs=""
+
+ psu1PwGood=`cat ${PATH_SYSFS_PSU1}/psu_pg`
+ psu_abs=`cat ${PATH_SYSFS_PSU1}/psu_abs`
+ if [ "$psu_abs" == "0" ]; then
+ psu1Exist=1
+ else
+ psu1Exist=0
+ fi
+
+ psu2PwGood=`cat ${PATH_SYSFS_PSU2}/psu_pg`
+ psu_abs=`cat ${PATH_SYSFS_PSU2}/psu_abs`
+ if [ "$psu_abs" == "0" ]; then
+ psu2Exist=1
+ else
+ psu2Exist=0
+ fi
+
+ printf "PSU1 Exist:%x PSU1 PW Good:%d\n" $psu1Exist $psu1PwGood
+ printf "PSU2 Exist:%d PSU2 PW Good:%d\n" $psu2Exist $psu2PwGood
+}
+
+#Get register value from CPLD
+function _i2c_cpld_reg_read {
+ local idx=$1
+ local file_name=$2
+ local cpld_i2c_addr=${I2C_ADDR_CPLD}
+ local reg_file_path
+
+ case ${idx} in
+ 1)
+ cpld_i2c_bus=${I2C_BUS_CPLD1}
+ ;;
+ 2)
+ cpld_i2c_bus=${I2C_BUS_CPLD2}
+ ;;
+ 3)
+ cpld_i2c_bus=${I2C_BUS_CPLD3}
+ ;;
+ 4)
+ cpld_i2c_bus=${I2C_BUS_CPLD4}
+ ;;
+ 5)
+ cpld_i2c_bus=${I2C_BUS_CPLD5}
+ ;;
+ *)
+ echo "invalid cpld index"
+ exit
+ ;;
+ esac
+
+ reg_file_path="${PATH_SYS_I2C_DEVICES}/${cpld_i2c_bus}-$(printf "%04x" ${cpld_i2c_addr})/${file_name}"
+ cpld_reg_val=`cat ${reg_file_path}`
+}
+
+#util functions
+function _util_i2cset {
+ if [ "$DEBUG" == "on" ]; then
+ i2cset $@
+ else
+ i2cset $@ 1>/dev/null
+ fi
+}
+
+function _i2c_set {
+ local i2c_bus=$1
+ local i2c_addr=$2
+ local reg=$3
+ local mask=$4
+ local value=$5
+
+ echo `i2cset -m $mask -y -r ${i2c_bus} ${i2c_addr} ${reg} ${value}`
+}
+
+function _util_rmmod {
+ local mod=$1
+ [ "$(lsmod | grep "^$mod ")" != "" ] && rmmod $mod
+}
+
+# get qsfp presence
+function _util_get_qsfp_abs {
+ local phy_port=0
+
+ #get physical port
+ phy_port=$(_port_logic2phy $QSFP_PORT)
+
+ # read status from cpld
+ #_qsfp_cpld_var_set ${QSFP_PORT}
+ _qsfp_cpld_var_set ${phy_port}
+ cpld_reg_file_name="${CPLD_QSFP_STATUS_KEY}_${cpld_port_index}"
+ _i2c_cpld_reg_read ${cpld_index} ${cpld_reg_file_name}
+ #status: 0 -> Down, 1 -> Up (ACTIVE_LOW in ABS_BIT)
+ status=$(( $(( $((${cpld_reg_val})) & (1 << ($CPLD_QSFP_STATUS_ABS_BIT)) ))?0:1 ))
+}
+
+# get sfp presence
+function _util_get_sfp_pres {
+
+ # read status from cpld
+ _sfp_cpld_var_set ${SFP_PORT}
+ cpld_reg_file_name="${CPLD_SFP_STATUS_KEY}"
+ _i2c_cpld_reg_read ${cpld_index} ${cpld_reg_file_name}
+ #status: 0 -> Down, 1 -> Up (ACTIVE_LOW in PRES_BIT)
+ status=$(( $(( $((${cpld_reg_val})) & (1 << ($CPLD_SFP_STATUS_PRES_BIT)) ))?0:1 ))
+}
+
+# valid input number
+function _util_input_check {
+ # input parameter validation
+ if [[ $1 -lt $2 || $1 -gt $3 ]]; then
+ echo "Please input number $2~$3"
+ exit
+ fi
+}
+
+# clear all switch port led bitmap
+function _util_port_led_clear {
+ echo "port led clear..."
+ # gpio pin on GPIO MUX PCA9539#1 I/O 0.2
+ # pull low to reset bitamp
+ output_reg=${REG_PORT0_OUT}
+ mask=0x04
+ value=0x00
+ _util_i2cset -m ${mask} -y ${NUM_MUX_9548_1_CH2} ${I2C_ADDR_MUX_9539_1} ${output_reg} ${value}
+ echo "Done"
+}
+
+#Increase read socket buffer for CoPP Test
+function _config_rmem {
+ echo "109430400" > /proc/sys/net/core/rmem_max
+}
+
+#Set 10G Mux to CPU or Front Panel
+function _i2c_10g_mux {
+
+ echo "========================================================="
+ echo "# Description: 10G Mux"
+ echo "========================================================="
+
+ local target=${TARGET_10G_MUX}
+ local i2c_bus=${I2C_BUS_10GMUX}
+ local i2c_addr=${I2C_ADDR_10GMUX}
+ local reg=0
+ local mask=0xff
+ local value=0
+ local file_10g_mux="${PATH_CPLD1_DEVICE}/${I2C_BUS_CPLD1}-$(printf "%04x" ${I2C_ADDR_CPLD})/cpld_10gmux_config"
+
+ #get current 10g mux register value on CPLD
+ value=`cat ${file_10g_mux}`
+
+ if [ "${target}" == "cpu" ]; then
+ #Set XE0: slave address access
+ _i2c_set $i2c_bus $i2c_addr 0x06 $mask 0x18
+ #Set XE0: CH4 D_IN0-S_OUTA0 EQ
+ _i2c_set $i2c_bus $i2c_addr 0x2c $mask 0x00
+ #Set XE0: CH5 NC-S_OUTB0 DEM
+ _i2c_set $i2c_bus $i2c_addr 0x35 $mask 0x80
+ #Set XE0: CH5 NC-S_OUTB0 VOD
+ _i2c_set $i2c_bus $i2c_addr 0x34 $mask 0xab
+ #Set XE0: CH1 D_OUT0-S_INB0 EQ
+ _i2c_set $i2c_bus $i2c_addr 0x16 $mask 0x01
+ #Set XE0: CH1 D_OUT0-S_INB0 DEM
+ _i2c_set $i2c_bus $i2c_addr 0x18 0x1f 0x80
+ #Set XE0: CH1 D_OUT0-S_INB0 VOD
+ _i2c_set $i2c_bus $i2c_addr 0x17 $mask 0xab
+ #Set XE1: CH6 D_IN1-S_OUTA1 EQ
+ _i2c_set $i2c_bus $i2c_addr 0x3a $mask 0x00
+ #Set XE1: CH7 NC-S_OUTB1 EQ
+ _i2c_set $i2c_bus $i2c_addr 0x41 $mask 0x00
+ #Set XE1: CH7 NC-S_OUTB1 DEM
+ _i2c_set $i2c_bus $i2c_addr 0x43 $mask 0x80
+ #Set XE1: CH7 NC-S_OUTB1 VOD
+ _i2c_set $i2c_bus $i2c_addr 0x42 $mask 0xab
+ #Set XE1: CH3 D_OUT1-S_INB1 EQ
+ _i2c_set $i2c_bus $i2c_addr 0x24 $mask 0x01
+ #Set XE1: CH3 D_OUT1-S_INB1 DEM
+ _i2c_set $i2c_bus $i2c_addr 0x26 $mask 0x80
+ #Set XE1: CH3 D_OUT1-S_INB1 VOD
+ _i2c_set $i2c_bus $i2c_addr 0x25 $mask 0xab
+ #Enable auto negotiation of XE ports
+ eval "npx_diag 'phy set mdio portlist=129,130 devad=0x7 addr=0x11 data=0x80'"
+ eval "npx_diag 'phy set mdio portlist=129,130 devad=0x7 addr=0x10 data=0x01'"
+ eval "npx_diag 'phy set mdio portlist=129,130 devad=0x7 addr=0x0 data=0x3200'"
+ eval "npx_diag 'phy set mdio portlist=129,130 devad=0x1 addr=0x96 data=0x2'"
+ #delay 1 sec
+ sleep 1
+
+ #switch 10G MUX to cpu on CPLD
+ value=$(( value & 0xf3 ))
+ echo "$(printf 0x"%x" ${value})" > ${file_10g_mux}
+
+ echo "Switch 10G Mux to [CPU]"
+
+ elif [ "${COLOR_LED}" == "fp" ]; then
+ #Set XE0: slave address access
+ _i2c_set $i2c_bus $i2c_addr 0x06 $mask 0x18
+ #Set XE0: CH4 D_IN0-S_OUTA0 EQ
+ _i2c_set $i2c_bus $i2c_addr 0x2c $mask 0x00
+ #Set XE0: CH4 D_IN0-S_OUTA0 DEM
+ _i2c_set $i2c_bus $i2c_addr 0x2e $mask 0x80
+ #Set XE0: CH4 D_IN0-S_OUTA0 VOD
+ _i2c_set $i2c_bus $i2c_addr 0x2d $mask 0xab
+ #Set XE0: CH0 NC-S_INA0 EQ
+ _i2c_set $i2c_bus $i2c_addr 0x0f $mask 0x00
+ #Set XE0: CH1 D_OUT0-S_INB0 DEM
+ _i2c_set $i2c_bus $i2c_addr 0x18 0x18 0x80
+ #Set XE0: CH1 D_OUT0-S_INB0 VOD
+ _i2c_set $i2c_bus $i2c_addr 0x17 $mask 0xab
+ #Set XE1: CH6 D_IN1-S_OUTA1 EQ
+ _i2c_set $i2c_bus $i2c_addr 0x3a $mask 0x00
+ #Set XE1: CH6 D_IN1-S_OUTA1 DEM
+ _i2c_set $i2c_bus $i2c_addr 0x3c $mask 0x80
+ #Set XE1: CH6 D_IN1-S_OUTA1 VOD
+ _i2c_set $i2c_bus $i2c_addr 0x3b $mask 0xab
+ #Set XE1: CH2 NC-S_INA1 EQ
+ _i2c_set $i2c_bus $i2c_addr 0x1d $mask 0x00
+ #Set XE1: CH3 D_OUT1-S_INB1 DEM
+ _i2c_set $i2c_bus $i2c_addr 0x26 $mask 0x80
+ #Set XE1: CH3 D_OUT1-S_INB1 VOD
+ _i2c_set $i2c_bus $i2c_addr 0x25 $mask 0xab
+ #Enable auto negotiation of XE ports
+ eval "npx_diag 'phy set mdio portlist=129,130 devad=0x7 addr=0x11 data=0x0'"
+ eval "npx_diag 'phy set mdio portlist=129,130 devad=0x7 addr=0x10 data=0x0'"
+ eval "npx_diag 'phy set mdio portlist=129,130 devad=0x7 addr=0x0 data=0x2200'"
+ eval "npx_diag 'phy set mdio portlist=129,130 devad=0x1 addr=0x96 data=0x2200'"
+ #delay 1 sec
+ sleep 1
+
+ #switch 10G MUX to front panel on CPLD
+ value=$(( value | 0x0c ))
+ echo "$(printf 0x"%x" ${value})" > ${file_10g_mux}
+
+ echo "Switch 10G Mux to [Front Panel]"
+ else
+ echo "invalid target, please set target to cpu/fp"
+ fi
+}
+
+#Main Function
+function _main {
+ tart_time_str=`date`
+ start_time_sec=$(date +%s)
+
+ if [ "${EXEC_FUNC}" == "help" ]; then
+ _help
+ elif [ "${EXEC_FUNC}" == "i2c_init" ]; then
+ _i2c_init
+ elif [ "${EXEC_FUNC}" == "i2c_deinit" ]; then
+ _i2c_deinit
+ elif [ "${EXEC_FUNC}" == "i2c_fan_speed_init" ]; then
+ _i2c_fan_speed_init
+ elif [ "${EXEC_FUNC}" == "i2c_io_exp_init" ]; then
+ _i2c_io_exp_init
+ elif [ "${EXEC_FUNC}" == "i2c_led_test" ]; then
+ _i2c_led_test
+ elif [ "${EXEC_FUNC}" == "i2c_mb_eeprom_get" ]; then
+ _i2c_mb_eeprom_get
+ elif [ "${EXEC_FUNC}" == "i2c_cb_eeprom_get" ]; then
+ _i2c_cb_eeprom_get
+ elif [ "${EXEC_FUNC}" == "i2c_eeprom_sync" ]; then
+ _i2c_eeprom_sync
+ elif [ "${EXEC_FUNC}" == "i2c_psu_eeprom_get" ]; then
+ _i2c_psu_eeprom_get
+ elif [ "${EXEC_FUNC}" == "i2c_qsfp_eeprom_get" ]; then
+ _i2c_qsfp_eeprom_get
+ elif [ "${EXEC_FUNC}" == "i2c_sfp_eeprom_get" ]; then
+ _i2c_sfp_eeprom_get
+ elif [ "${EXEC_FUNC}" == "i2c_qsfp_eeprom_init" ]; then
+ _i2c_qsfp_eeprom_init ${QSFP_ACTION}
+ elif [ "${EXEC_FUNC}" == "i2c_sfp_eeprom_init" ]; then
+ _i2c_sfp_eeprom_init ${SFP_ACTION}
+ elif [ "${EXEC_FUNC}" == "i2c_mb_eeprom_init" ]; then
+ _i2c_mb_eeprom_init ${MB_EEPROM_ACTION}
+ elif [ "${EXEC_FUNC}" == "i2c_cb_eeprom_init" ]; then
+ _i2c_cb_eeprom_init ${MB_EEPROM_ACTION}
+ elif [ "${EXEC_FUNC}" == "i2c_qsfp_status_get" ]; then
+ _i2c_qsfp_status_get
+ elif [ "${EXEC_FUNC}" == "i2c_sfp_status_get" ]; then
+ _i2c_sfp_status_get
+ elif [ "${EXEC_FUNC}" == "i2c_qsfp_type_get" ]; then
+ _i2c_qsfp_type_get
+ elif [ "${EXEC_FUNC}" == "i2c_sfp_type_get" ]; then
+ _i2c_sfp_type_get
+ elif [ "${EXEC_FUNC}" == "i2c_led_psu_status_set" ]; then
+ _i2c_led_psu_status_set
+ elif [ "${EXEC_FUNC}" == "i2c_led_fan_status_set" ]; then
+ _i2c_led_fan_status_set
+ elif [ "${EXEC_FUNC}" == "i2c_led_fan_tray_status_set" ]; then
+ _i2c_led_fan_tray_status_set
+ elif [ "${EXEC_FUNC}" == "i2c_sys_led" ]; then
+ _i2c_sys_led
+ elif [ "${EXEC_FUNC}" == "i2c_fan_led" ]; then
+ _i2c_fan_led
+ elif [ "${EXEC_FUNC}" == "i2c_fan_tray_led" ]; then
+ _i2c_fan_tray_led
+ elif [ "${EXEC_FUNC}" == "i2c_psu1_led" ]; then
+ _i2c_psu1_led
+ elif [ "${EXEC_FUNC}" == "i2c_psu2_led" ]; then
+ _i2c_psu2_led
+ elif [ "${EXEC_FUNC}" == "i2c_board_type_get" ]; then
+ _i2c_board_type_get
+ elif [ "${EXEC_FUNC}" == "i2c_bmc_board_type_get" ]; then
+ _i2c_bmc_board_type_get
+ elif [ "${EXEC_FUNC}" == "i2c_cpld_version" ]; then
+ _i2c_cpld_version
+ elif [ "${EXEC_FUNC}" == "i2c_psu_status" ]; then
+ _i2c_psu_status
+ elif [ "${EXEC_FUNC}" == "i2c_test_all" ]; then
+ _i2c_init
+ _i2c_led_test
+ _i2c_psu_eeprom_get
+ _i2c_mb_eeprom_get
+ _i2c_cb_eeprom_get
+ _i2c_board_type_get
+ _i2c_bmc_board_type_get
+ _i2c_cpld_version
+ _i2c_psu_status
+ elif [ "${EXEC_FUNC}" == "i2c_10g_mux" ]; then
+ _i2c_10g_mux
+ else
+ echo "Invalid Parameters, Exit!!!"
+ _help
+ exit ${FALSE}
+ fi
+
+ if [ "$DEBUG" == "on" ]; then
+ echo "-----------------------------------------------------"
+ end_time_str=`date`
+ end_time_sec=$(date +%s)
+ diff_time=$[ ${end_time_sec} - ${start_time_sec} ]
+ echo "Start Time: ${start_time_str} (${start_time_sec})"
+ echo "End Time : ${end_time_str} (${end_time_sec})"
+ echo "Total Execution Time: ${diff_time} sec"
+
+ echo "done!!!"
+ fi
+}
+
+_main
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/utils/qsfp_monitor.sh b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/utils/qsfp_monitor.sh
new file mode 100755
index 0000000000..23a3fd066b
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/utils/qsfp_monitor.sh
@@ -0,0 +1,105 @@
+#!/bin/bash
+# Copyright (C) 2017 Ingrasys, 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 .
+
+INTERVAL=3
+I2C_UTILS="/usr/sbin/i2c_utils.sh"
+QSFP_SI_SCRIPT="/usr/sbin/qsfp_si_cfg.sh"
+QSFP_ARRAY=(0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 \
+ 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0)
+
+#QSFP SI monitor
+function _qsfp_si_monitor {
+ local i
+ local status
+ for i in {0..63};
+ do
+ status=`${I2C_UTILS} i2c_qsfp_status_get $(expr $i + 1) | egrep '^status=.*$' | sed -e 's/status=//g'`
+ if [ "${status}" == "1" ]; then
+ _qsfp_type_check $i
+ fi
+ done
+}
+
+#QSFP type
+function _qsfp_type_check {
+ local port=$1
+ local qsfp_type=`${I2C_UTILS} i2c_qsfp_type_get $(expr $port + 1)`
+ local identifier=`echo "$qsfp_type" | grep '^identifier=.*$' | sed -e 's/identifier=//g'`
+ if [ "${identifier}" == "11" ]; then
+ connector=`echo "$qsfp_type" | grep '^connector=.*$' | sed -e 's/connector=//g'`
+ case ${connector} in
+ 21|23)
+ #DAC
+ if [ "${QSFP_ARRAY[$port]}" != "${connector}" ]; then
+ echo "Change Port $(expr $port + 1) to DAC"
+ QSFP_ARRAY[$port]=${connector}
+ ${QSFP_SI_SCRIPT} dac $port >/dev/null
+ fi
+ ;;
+ *)
+ #Optical
+ if [ "${QSFP_ARRAY[$port]}" != "${connector}" ]; then
+ echo "Change Port $(expr $port + 1) to Optical"
+ QSFP_ARRAY[$port]=${connector}
+ ${QSFP_SI_SCRIPT} optical $port >/dev/null
+ fi
+ ;;
+ esac
+ fi
+}
+
+#Docker exist check
+function _docker_swss_check {
+ while true
+ do
+ # Check if syncd starts
+ result=`docker exec -i swss bash -c "echo -en \"SELECT 1\\nHLEN HIDDEN\" | redis-cli | sed -n 2p"` #TBD FIX ME
+ if [ "$result" == "3" ]; then
+ return
+ fi
+ sleep $INTERVAL
+ done
+}
+
+#Docker exist check
+function _qsfp_si_cfg_script_check {
+
+ if [ -f ${QSFP_SI_SCRIPT} ] && [ -x ${QSFP_SI_SCRIPT} ]; then
+ echo "SI Script exists. Start monitor."
+ return
+ else
+ echo "SI Script not exist. Exit monitor."
+ exit
+ fi
+}
+
+# main function
+function _main {
+ #Check SI Script
+ _qsfp_si_cfg_script_check
+ #Check docker swss is running
+ _docker_swss_check
+ while true
+ do
+ _qsfp_si_monitor
+ # Sleep while still handling signals
+ sleep $INTERVAL &
+ wait $!
+ done
+}
+
+_main
+
diff --git a/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/utils/s9230_64x_monitor.sh b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/utils/s9230_64x_monitor.sh
new file mode 100755
index 0000000000..8bfb223280
--- /dev/null
+++ b/platform/nephos/sonic-platform-modules-ingrasys/s9230-64x/utils/s9230_64x_monitor.sh
@@ -0,0 +1,39 @@
+#!/bin/bash
+# Copyright (C) 2016 Ingrasys, 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 .
+
+INTERVAL=5
+I2C_UTILS="/usr/sbin/i2c_utils.sh"
+
+
+# LED status monitor
+function _led_monitor {
+ ${I2C_UTILS} i2c_led_fan_status_set >/dev/null
+ ${I2C_UTILS} i2c_led_psu_status_set >/dev/null
+ ${I2C_UTILS} i2c_led_fan_tray_status_set >/dev/null
+}
+
+# main function
+function _main {
+ while true
+ do
+ _led_monitor
+ # Sleep while still handling signals
+ sleep $INTERVAL &
+ wait $!
+ done
+}
+
+_main