meta-fii: meta-kudo: Use I2C array definitions in kudo-lib.sh

Adds the I2C bus and address in array form to kudo-lib.sh, and
replaces the hardcoded values with references across Kudo layer.

Signed-off-by: Charles Boyer <Charles.Boyer@fii-usa.com>
Change-Id: I69bbff444e013e61d7f7fd5051612a6d4adc8ded
diff --git a/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw-ver.sh b/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw-ver.sh
index 23a65c1..533fa8e 100644
--- a/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw-ver.sh
+++ b/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw-ver.sh
@@ -10,12 +10,11 @@
 function fw_rev() {
     case $1 in
     cpldb)
-        rsp=($(i2cget -y -f -a 13 0x76 0x00 i 5))
+        rsp=($(i2cget -y -f -a "${I2C_BMC_CPLD[0]}" 0x"${I2C_BMC_CPLD[1]}" 0x00 i 5))
         ver=$(printf '%d.%d.%d.%d' "${rsp[5]}" "${rsp[4]}" "${rsp[3]}" "${rsp[2]}")
         ;;
     cpldm)
-        I2C_BUS_DEV=$(readlink "/sys/bus/i2c/devices/4-0077/channel-2" | cut -c 8-)
-        rsp=($(i2cget -y -f -a "$I2C_BUS_DEV" 0x76 0x00 i 5))
+        rsp=($(i2cget -y -f -a "${I2C_MB_CPLD[0]}" 0x"${I2C_MB_CPLD[1]}" 0x00 i 5))
         ver=$(printf '%d.%d.%d.%d' "${rsp[5]}" "${rsp[4]}" "${rsp[3]}" "${rsp[2]}")
         ;;
     *)
diff --git a/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw.sh b/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw.sh
index 6f9ec72..42e4af8 100644
--- a/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw.sh
+++ b/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-fw.sh
@@ -6,14 +6,12 @@
 # shellcheck disable=SC2086
 source /usr/libexec/kudo-fw/kudo-lib.sh
 
-devpath="/sys/bus/i2c/devices/13-0077/driver"
-
 function fwbios() {
   KERNEL_FIU_ID="c0000000.spi"
   KERNEL_SYSFS_FIU="/sys/bus/platform/drivers/NPCM-FIU"
 
   # switch the SPI mux from Host to BMC
-  i2cset -y -f -a 13 0x76 0x10 0x01
+  i2cset -y -f -a ${I2C_BMC_CPLD[0]} 0x${I2C_BMC_CPLD[1]} 0x10 0x01
 
   # rescan the spi bus
   if [ -d "${KERNEL_SYSFS_FIU}/${KERNEL_FIU_ID}" ]; then
@@ -41,7 +39,7 @@
   if [ -d "${KERNEL_SYSFS_FIU}/${KERNEL_FIU_ID}" ]; then
     echo "${KERNEL_FIU_ID}" > "${KERNEL_SYSFS_FIU}"/unbind
   fi
-  i2cset -y -f -a 13 0x76 0x10 0x00
+  i2cset -y -f -a ${I2C_BMC_CPLD[0]} 0x${I2C_BMC_CPLD[1]} 0x10 0x00
 
   # Disable LPI mode NV_SI_CPU_LPI_FREQ_DISABLE for SCP 1.06 and older.
   if [ "$(nvparm -s 0x1 -o 0x114090)" -ne  0 ]; then
@@ -106,9 +104,7 @@
   scp_eeprom_sel=$(get_gpio_ctrl BACKUP_SCP_SEL)
   set_gpio_ctrl BACKUP_SCP_SEL 1
   set_gpio_ctrl CPU_EEPROM_SEL 0
-  #shellcheck disable=SC2010
-  I2C_BUS_DEV=$(ls -l $devpath/"13-0077/" | grep channel-0 | awk '{ print $11}' | cut -c 8-)
-  if [ "$(ampere_eeprom_prog -b $I2C_BUS_DEV -s 0x50 -p -f $1)" -ne  0 ]; then
+  if [ "$(ampere_eeprom_prog -b ${I2C_CPU_EEPROM[0]} -s 0x${I2C_CPU_EEPROM[1]} -p -f $1)" -ne  0 ]; then
     echo "SCP eeprom update failed" >&2
     return 1
   fi
@@ -125,9 +121,7 @@
   scp_eeprom_sel=$(get_gpio_ctrl BACKUP_SCP_SEL)
   set_gpio_ctrl BACKUP_SCP_SEL 0
   set_gpio_ctrl CPU_EEPROM_SEL 0
-  #shellcheck disable=SC2010
-  I2C_BUS_DEV=$(ls -l $devpath/"13-0077/" | grep channel-0 | awk '{ print $11}' | cut -c 8-)
-  if [ "$(ampere_eeprom_prog -b $I2C_BUS_DEV -s 0x50 -p -f $1)" -ne  0 ]; then
+  if [ "$(ampere_eeprom_prog -b ${I2C_CPU_EEPROM[0]} -s 0x${I2C_CPU_EEPROM[1]} -p -f $1)" -ne  0 ]; then
     echo "SCP BACKUP eeprom update failed" >&2
     return 1
   fi
@@ -149,14 +143,14 @@
     echo "The file $2 file does not exist"
     return 1
   fi
-  echo 32-0040 > /sys/bus/i2c/drivers/adm1266/unbind
-  echo 32-0041 > /sys/bus/i2c/drivers/adm1266/unbind
+  echo ${I2C_MB_PWRSEQ1[0]}-00${I2C_MB_PWRSEQ1[1]} > /sys/bus/i2c/drivers/adm1266/unbind
+  echo ${I2C_MB_PWRSEQ2[0]}-00${I2C_MB_PWRSEQ2[1]} > /sys/bus/i2c/drivers/adm1266/unbind
   if [ "$(adm1266_fw_fx $1 $2)" -ne  0 ]; then
     echo "The power seq flash failed" >&2
     return 1
   fi
-  echo 32-0040 > /sys/bus/i2c/drivers/adm1266/bind
-  echo 32-0041 > /sys/bus/i2c/drivers/adm1266/bind
+  echo ${I2C_MB_PWRSEQ1[0]}-00${I2C_MB_PWRSEQ1[1]} > /sys/bus/i2c/drivers/adm1266/bind
+  echo ${I2C_MB_PWRSEQ2[0]}-00${I2C_MB_PWRSEQ2[1]} > /sys/bus/i2c/drivers/adm1266/bind
 
   return 0
 }
diff --git a/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-lib.sh b/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-lib.sh
index 063cc55..fd0aa20 100644
--- a/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-lib.sh
+++ b/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-lib.sh
@@ -1,5 +1,8 @@
 #!/bin/bash
 
+# Disable check for usage of the definitions within kudo-lib.sh
+# shellcheck disable=SC2034
+
 # get_gpio_num
 # Dynamically obtains GPIO number from chip base and I2C expanders through line name
 # line-name
@@ -36,3 +39,18 @@
     cat /sys/class/gpio/gpio"$GPIO_NUM"/value
     echo "$GPIO_NUM" > /sys/class/gpio/unexport
 }
+
+# I2C Definitions
+# The array is (<bus> <address>), where address is in hexadecimal.
+I2C_BMC_CPLD=(13 76)
+I2C_MB_CPLD=(34 76)
+I2C_S0_SMPRO=(2 4f)
+I2C_S1_SMPRO=(2 4e)
+I2C_FANCTRL=(18 2c)
+I2C_BMC_PWRSEQ=(14 59)
+I2C_MB_PWRSEQ1=(32 40)
+I2C_MB_PWRSEQ2=(32 41)
+I2C_CPU_EEPROM=(40 50)
+I2C_S1_CLKGEN=(37 68)
+I2C_S1_PCIE_CLKGEN1=(16 6a)
+I2C_S1_PCIE_CLKGEN2=(17 67)
diff --git a/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-boot/init_once.sh b/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-boot/init_once.sh
index fa5395d..5ddd73c 100644
--- a/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-boot/init_once.sh
+++ b/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-boot/init_once.sh
@@ -20,13 +20,13 @@
 
     # SPI control
     # Send command to CPLD to switch the bios spi interface to host
-    i2cset -y -f -a 13 0x76 0x10 0x00
+    i2cset -y -f -a "${I2C_BMC_CPLD[0]}" 0x"${I2C_BMC_CPLD[1]}" 0x10 0x00
 
 }
 
 # 0 - 63 EVT
 # 64 + DVT/PVT
-boardver=$(printf '%d' "$(awk '{print $6}' /sys/bus/i2c/drivers/fiicpld/34-0076/CMD00)")
+boardver=$(printf '%d' "$(awk '{print $6}' /sys/bus/i2c/drivers/fiicpld/"${I2C_MB_CPLD[0]}"-00"${I2C_MB_CPLD[1]}"/CMD00)")
 
 # On EVT machines, the secondary SCP EEPROM is used.
 # Set BMC_I2C_BACKUP_SEL to secondary.
@@ -59,12 +59,12 @@
         echo EVT system "$boardver"
     else
         echo DVT system "$boardver"
-        i2cset -y -a -f 37 0x68 0x05 0x03
+        i2cset -y -a -f "${I2C_S1_CLKGEN[0]}" 0x"${I2C_S1_CLKGEN[1]}" 0x05 0x03
     fi
     #These i2c deviecs are already installed on EVT systems
-    i2cset -y -a -f 16 0x6a 0 1 0xdf i
-    i2cset -y -a -f 16 0x6a 11 1 0x01 i
-    i2cset -y -a -f 17 0x67 1 2 0x3f 0x0c i
+    i2cset -y -a -f "${I2C_S1_PCIE_CLKGEN1[0]}" 0x"${I2C_S1_PCIE_CLKGEN1[1]}" 0 1 0xdf i
+    i2cset -y -a -f "${I2C_S1_PCIE_CLKGEN1[0]}" 0x"${I2C_S1_PCIE_CLKGEN1[1]}" 11 1 0x01 i
+    i2cset -y -a -f "${I2C_S1_PCIE_CLKGEN2[0]}" 0x"${I2C_S1_PCIE_CLKGEN2[1]}" 1 2 0x3f 0x0c i
 fi
 
 # Create /run/openbmc for system power files
diff --git a/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd/kudo-ras.sh b/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd/kudo-ras.sh
index 551192d..896a979 100644
--- a/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd/kudo-ras.sh
+++ b/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd/kudo-ras.sh
@@ -1,13 +1,17 @@
 #!/bin/bash
 
-powerState=$(i2cget -f -y 0x2 0x4f 0xe0 b)
+# Provide source directive to shellcheck.
+# shellcheck source=meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-lib.sh
+source /usr/libexec/kudo-fw/kudo-lib.sh
+
+powerState=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0xe0 b)
 
 getGPISourceRegisters(){
-    REG60=$(i2cget -f -y 0x2 0x4f 0x60 w)       # GPI Data Set
-    REG61=$(i2cget -f -y 0x2 0x4f 0x61 w)       # GPI DATA Set #0
-    REG62=$(i2cget -f -y 0x2 0x4f 0x62 w)       # GPI DATA Set #1
-    REG63=$(i2cget -f -y 0x2 0x4f 0x63 w)       # GPI DATA Set #2
-    REG64=$(i2cget -f -y 0x2 0x4f 0x64 w)       # GPI DATA Set #3
+    REG60=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x60 w)       # GPI Data Set
+    REG61=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x61 w)       # GPI DATA Set #0
+    REG62=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x62 w)       # GPI DATA Set #1
+    REG63=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x63 w)       # GPI DATA Set #2
+    REG64=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x64 w)       # GPI DATA Set #3
     DS0Pres=$((REG60 & 0x0100))
     DS1Pres=$((REG60 & 0x0200))
     DS2Pres=$((REG60 & 0x0400))
@@ -15,14 +19,14 @@
 }
 
 getErrorCount() {
-    MemCE=$(i2cget -f -y 0x2 0x4f 0x90 w)
-    MemUE=$(i2cget -f -y 0x2 0x4f 0x93 w)
-    CoreCE=$(i2cget -f -y 0x2 0x4f 0x80 w)
-    CoreUE=$(i2cget -f -y 0x2 0x4f 0x83 w)
-    PCIeCE=$(i2cget -f -y 0x2 0x4f 0xc0 w)
-    PCIeUE=$(i2cget -f -y 0x2 0x4f 0xc2 w)
-    OtherCE=$(i2cget -f -y 0x2 0x4f 0xd0 w)
-    OtherUE=$(i2cget -f -y 0x2 0x4f 0xd8 w)
+    MemCE=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x90 w)
+    MemUE=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x93 w)
+    CoreCE=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x80 w)
+    CoreUE=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x83 w)
+    PCIeCE=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0xc0 w)
+    PCIeUE=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0xc2 w)
+    OtherCE=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0xd0 w)
+    OtherUE=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0xd8 w)
 }
 
 getReg61Vals() {
@@ -64,14 +68,14 @@
 }
 
 getGPIStatusRegisters(){
-    REG70=$(i2cget -f -y 0x2 0x4f 0x70 w)       # Core, DIMM, SLC, PCIe, and Other errors
-    REG78=$(i2cget -f -y 0x2 0x4f 0x78 w)       # VRD Fault/Warning Error
-    REG79=$(i2cget -f -y 0x2 0x4f 0x79 w)       # VRD Hot
-    REG7A=$(i2cget -f -y 0x2 0x4f 0x7A w)       # DIMM Hot Error
-    REG7B=$(i2cget -f -y 0x2 0x4f 0x7B w)       # Boot #1 Error
-    REG7C=$(i2cget -f -y 0x2 0x4f 0x7C w)       # Boot #2 Error
-    REG7D=$(i2cget -f -y 0x2 0x4f 0x7D w)       # Watchdog/Other Status
-    REG7E=$(i2cget -f -y 0x2 0x4f 0x7E w)       # RAS internal error
+    REG70=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x70 w)       # Core, DIMM, SLC, PCIe, and Other errors
+    REG78=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x78 w)       # VRD Fault/Warning Error
+    REG79=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x79 w)       # VRD Hot
+    REG7A=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x7A w)       # DIMM Hot Error
+    REG7B=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x7B w)       # Boot #1 Error
+    REG7C=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x7C w)       # Boot #2 Error
+    REG7D=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x7D w)       # Watchdog/Other Status
+    REG7E=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x7E w)       # RAS internal error
 }
 
 getReg70Vals() {
@@ -175,11 +179,11 @@
 }
 
 getGPIMaskRegisters(){
-    REG50=$(i2cget -f -y 0x2 0x4f 0x50 w)       # GPI Control #0
-    REG51=$(i2cget -f -y 0x2 0x4f 0x51 w)       # GPI Control #1
-    REG52=$(i2cget -f -y 0x2 0x4f 0x52 w)       # GPI Control #2
-    REG53=$(i2cget -f -y 0x2 0x4f 0x53 w)       # GPI Control #3
-    REG54=$(i2cget -f -y 0x2 0x4f 0x54 w)       # GPI CE/UE Mask
+    REG50=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x50 w)       # GPI Control #0
+    REG51=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x51 w)       # GPI Control #1
+    REG52=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x52 w)       # GPI Control #2
+    REG53=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x53 w)       # GPI Control #3
+    REG54=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x54 w)       # GPI CE/UE Mask
 }
 
 getReg50Vals() {
diff --git a/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd/kudo.sh b/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd/kudo.sh
index 58d0d0e..d32ddac 100644
--- a/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd/kudo.sh
+++ b/meta-fii/meta-kudo/recipes-kudo/kudo-sys-utility/kudo-cmd/kudo.sh
@@ -113,8 +113,8 @@
   echo " BMC: " ${MajorVersion}.${SubMajorVersion}.${MinorVersion}
 
   #BMC PWR Sequencer
-  i2cset -y -f -a 14 0x59 0xfe 0x0000 w
-  cmd=$(i2cget -y -f -a 14 0x59 0xfe i 2 | awk '{print substr($0,3)}')
+  i2cset -y -f -a "${I2C_BMC_PWRSEQ[0]}" 0x"${I2C_BMC_PWRSEQ[1]}" 0xfe 0x0000 w
+  cmd=$(i2cget -y -f -a "${I2C_BMC_PWRSEQ[0]}" 0x"${I2C_BMC_PWRSEQ[1]}" 0xfe i 2 | awk '{print substr($0,3)}')
   echo " BMC PowerSequencer : ${cmd}"
   #only display with smbios exists
   if [[ -e /var/lib/smbios/smbios2 ]]; then
@@ -123,7 +123,7 @@
     echo " Bios: $cmd"
   fi
 
-  cmd=$(i2cget -f -y 2 0x4f 0x1 w);
+  cmd=$(i2cget -f -y "${I2C_S0_SMPRO[0]}" 0x"${I2C_S0_SMPRO[1]}" 0x1 w);
   echo " SCP Firmware: ${cmd}"
 
   adm1266_ver  | grep REVISION
@@ -202,7 +202,7 @@
 
 function ledtoggle() {
 
-    CurrentLED=$( i2cget -y -f -a 34 0x76 0x05 i 1 | cut -d ' ' -f 2)
+    CurrentLED=$( i2cget -y -f -a "${I2C_MB_CPLD[0]}" 0x"${I2C_MB_CPLD[1]}" 0x05 i 1 | cut -d ' ' -f 2)
   case $1 in
     boot)
         cmd=$(((CurrentLED & 0x40) != 0))
@@ -211,20 +211,20 @@
             #turn on LED
             if [[ $cmd -eq 0 ]]; then
                 setValue=$(( 0x40 + CurrentLED ))
-                i2cset -y -f -a 34 0x76 0x10 "$setValue"
+                i2cset -y -f -a "${I2C_MB_CPLD[0]}" 0x"${I2C_MB_CPLD[1]}" 0x10 $setValue
             fi
             ;;
          off)
             #turn off led
             if [[ $cmd -eq 1 ]]; then
                 setValue=$(( 0x80 & CurrentLED ))
-                i2cset -y -f -a 34 0x76 0x10 "$setValue"
+                i2cset -y -f -a "${I2C_MB_CPLD[0]}" 0x"${I2C_MB_CPLD[1]}" 0x10 $setValue
             fi
             ;;
         toggle)
             #turn on LED
                 setValue=$(( 0x40 ^ CurrentLED ))
-                i2cset -y -f -a 34 0x76 0x10 "$setValue"
+                i2cset -y -f -a "${I2C_MB_CPLD[0]}" 0x"${I2C_MB_CPLD[1]}" 0x10 $setValue
             ;;
          status)
             #displayLED status
@@ -246,20 +246,20 @@
             #turn on LED
             if [[ $cmd -eq 0 ]]; then
                 setValue=$(( 0x80 + CurrentLED ))
-                i2cset -y -f -a 34 0x76 0x10 "$setValue"
+                i2cset -y -f -a "${I2C_MB_CPLD[0]}" 0x"${I2C_MB_CPLD[1]}" 0x10 $setValue
             fi
             ;;
          off)
             #turn off led
             if [[ $cmd -eq 1 ]]; then
                  setValue=$(( 0x40 & CurrentLED ))
-                i2cset -y -f -a 34 0x76 0x10 "$setValue"
+                i2cset -y -f -a "${I2C_MB_CPLD[0]}" 0x"${I2C_MB_CPLD[1]}" 0x10 $setValue
             fi
             ;;
         toggle)
             #turn on LED
             setValue=$(( 0x80 ^ CurrentLED ))
-            i2cset -y -f -a 34 0x76 0x10 "$setValue"
+            i2cset -y -f -a "${I2C_MB_CPLD[0]}" 0x"${I2C_MB_CPLD[1]}" 0x10 $setValue
             ;;
          status)
             #displayLED status
diff --git a/meta-fii/meta-kudo/recipes-phosphor/fans/pwm-init/bin/pwm_init.sh b/meta-fii/meta-kudo/recipes-phosphor/fans/pwm-init/bin/pwm_init.sh
index 5394cb6..1e0682f 100644
--- a/meta-fii/meta-kudo/recipes-phosphor/fans/pwm-init/bin/pwm_init.sh
+++ b/meta-fii/meta-kudo/recipes-phosphor/fans/pwm-init/bin/pwm_init.sh
@@ -2,6 +2,10 @@
 #
 # Set all fans to pwm mode.
 
+# Provide source directive to shellcheck.
+# shellcheck source=meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-fw/kudo-lib.sh
+source /usr/libexec/kudo-fw/kudo-lib.sh
+
 # Set all pwm_enable to 1
 find /sys/class/hwmon/hwmon*/ -name 'pwm*_enable' -exec bash -c 'echo "$1" && echo 1 > "$1" && cat "$1"' -- {} \;
 
@@ -11,10 +15,10 @@
             awk '{print $1}')
     # Set Fan PWM Rate-of-Change Bits(bits 4:2) to 000b
     # Register 08h to 0Dh
-    oriRegVal=$(i2cget -y -f 18 0x2c \
+    oriRegVal=$(i2cget -y -f "${I2C_FANCTRL[0]}" 0x"${I2C_FANCTRL[1]}" \
         "${fan_pwm_rate_of_change}")
     updateVal=$((oriRegVal & 0xe3))
     updateVal=0x$(printf "%x" ${updateVal})
-    i2cset -y -f 18 0x2c \
+    i2cset -y -f "${I2C_FANCTRL[0]}" 0x"${I2C_FANCTRL[1]}" \
         "${fan_pwm_rate_of_change}" "${updateVal}"
 done