meta-fii/meta-kudo: support the cpld update feature

1. add kudo-cpld-update package to support cpld update

Signed-off-by: Lancelot Kao <lancelot.kao@fii-usa.com>
Change-Id: Idb0f676ac5a8cc214d65135924431d02bf971c75
Signed-off-by: XP Chen <xiao-peng.chen@fii-na.com>
Signed-off-by: Mohaimen Alsamarai <Mohaimen.alsamarai@fii-na.com>
diff --git a/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-cpld-update.bb b/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-cpld-update.bb
new file mode 100644
index 0000000..b2fd820
--- /dev/null
+++ b/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-cpld-update.bb
@@ -0,0 +1,39 @@
+SUMMARY = "Phosphor OpenBMC Kudo CPLD Firmware Upgrade Command"
+DESCRIPTION = "Phosphor OpenBMC Kudo CPLD Firmware Upgrade Comman Daemon"
+
+PR = "r1"
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
+
+inherit systemd
+inherit obmc-phosphor-systemd
+
+DEPENDS += "systemd"
+DEPENDS += "phosphor-ipmi-flash"
+RDEPENDS_${PN} += "libsystemd"
+RDEPENDS_${PN} += "bash"
+
+FILES_${PN} += "${datadir}/phosphor-ipmi-flash/config-bmccpld.json"
+FILES_${PN} += "${datadir}/phosphor-ipmi-flash/config-mbcpld.json"
+
+SRC_URI_append_kudo = " \
+    file://phosphor-ipmi-flash-bmccpld-update.service \
+    file://phosphor-ipmi-flash-mbcpld-update.service \
+    file://config-bmccpld.json \
+    file://config-mbcpld.json \
+    "
+
+SYSTEMD_PACKAGES = "${PN}"
+SYSTEMD_SERVICE_${PN}_append_kudo = " \
+    phosphor-ipmi-flash-bmccpld-update.service \
+    phosphor-ipmi-flash-mbcpld-update.service \
+    "
+
+do_install () {
+    install -d ${D}${datadir}/phosphor-ipmi-flash
+    install -m 0644 ${WORKDIR}/config-bmccpld.json ${D}${datadir}/phosphor-ipmi-flash
+    install -m 0644 ${WORKDIR}/config-mbcpld.json ${D}${datadir}/phosphor-ipmi-flash
+    install -d ${D}${systemd_system_unitdir}
+    install -m 0644 ${WORKDIR}/phosphor-ipmi-flash-bmccpld-update.service ${D}${systemd_system_unitdir}
+    install -m 0644 ${WORKDIR}/phosphor-ipmi-flash-mbcpld-update.service ${D}${systemd_system_unitdir}
+}
\ No newline at end of file
diff --git a/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-cpld-update/config-bmccpld.json b/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-cpld-update/config-bmccpld.json
new file mode 100644
index 0000000..687aa11
--- /dev/null
+++ b/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-cpld-update/config-bmccpld.json
@@ -0,0 +1,19 @@
+[{
+    "blob": "/flash/bmccpld",
+    "handler": {
+        "type": "file",
+        "path": "/run/initramfs/bmc-cpld.svf"
+    },
+    "actions": {
+        "preparation": {
+            "type": "skip"
+        },
+        "verification": {
+            "type": "skip"
+        },
+        "update": {
+            "type": "systemd",
+            "unit": "phosphor-ipmi-flash-bmccpld-update.service"
+        }
+    }
+}]
diff --git a/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-cpld-update/config-mbcpld.json b/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-cpld-update/config-mbcpld.json
new file mode 100644
index 0000000..f5870bb
--- /dev/null
+++ b/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-cpld-update/config-mbcpld.json
@@ -0,0 +1,20 @@
+[{
+    "blob": "/flash/mbcpld",
+    "handler": {
+        "type": "file",
+        "path": "/run/initramfs/mb-cpld.svf"
+    },
+    "actions": {
+        "preparation": {
+            "type": "skip"
+        },
+        "verification": {
+            "type": "skip"
+        },
+        "update": {
+            "type": "systemd",
+            "unit": "phosphor-ipmi-flash-mbcpld-update.service"
+        }
+    }
+}]
+
diff --git a/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-cpld-update/phosphor-ipmi-flash-bmccpld-update.service b/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-cpld-update/phosphor-ipmi-flash-bmccpld-update.service
new file mode 100644
index 0000000..b4f91f8
--- /dev/null
+++ b/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-cpld-update/phosphor-ipmi-flash-bmccpld-update.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=Phosphor-ipmi-flash update BMC CPLD firmware service
+
+[Service]
+ExecStart=/usr/sbin/kudo-fw.sh bmccpld /run/initramfs/bmc-cpld.svf
+Type=oneshot
+
+[Install]
+WantedBy=phosphor-ipmi-flash-bmccpld-update.target
diff --git a/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-cpld-update/phosphor-ipmi-flash-mbcpld-update.service b/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-cpld-update/phosphor-ipmi-flash-mbcpld-update.service
new file mode 100644
index 0000000..51b6c9c
--- /dev/null
+++ b/meta-fii/meta-kudo/recipes-kudo/kudo-fw-utility/kudo-cpld-update/phosphor-ipmi-flash-mbcpld-update.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=Phosphor-ipmi-flash update MB CPLD firmware service
+
+[Service]
+ExecStart=/usr/sbin/kudo-fw.sh mbcpld /run/initramfs/mb-cpld.svf
+Type=oneshot
+
+[Install]
+WantedBy=phosphor-ipmi-flash-mbcpld-update.target
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 2c50298..498fe7d 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
@@ -19,9 +19,10 @@
         ;;
     esac
 }
+
 fw_rev cpldb
 echo "BMC CPLD version : ${ver}"
 echo "${ver}" > "${BMC_CPLD_VER_FILE}"
 fw_rev cpldm
 echo "MB CPLD version  : ${ver}"
-echo "${ver}" > "${MB_CPLD_VER_FILE}"
+echo "${ver}" > "${MB_CPLD_VER_FILE}"
\ No newline at end of file
diff --git a/meta-fii/meta-kudo/recipes-kudo/packagegroups/packagegroup-kudo-apps.bb b/meta-fii/meta-kudo/recipes-kudo/packagegroups/packagegroup-kudo-apps.bb
index 17bde95..fe93898 100644
--- a/meta-fii/meta-kudo/recipes-kudo/packagegroups/packagegroup-kudo-apps.bb
+++ b/meta-fii/meta-kudo/recipes-kudo/packagegroups/packagegroup-kudo-apps.bb
@@ -29,4 +29,5 @@
     kudo-fw \
     kudo-bios-update \
     kudo-bmc-update \
+    kudo-cpld-update \
     "