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.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
 }