meta-ampere: mtjade: Enable Redfish support for on-board sensors

Map FAN, temperature and voltage sensors with Redfish chassis instance
and enables association feature in phosphor-inventory-manager.
The bmcweb looks for the sensors associated with a chassis instance
in the association list. The list, which is associations.json file in
phosphor-inventory-manager, maps the dbus sensor objects to a chassis
inventory.

Tested:
1. Check power/voltage sensors reported in redfish/v1/Chassis/chassis/Power.
2. Check FANs/thermal sensors reported in redfish/v1/Chassis/chassis/Thermal.

Signed-off-by: Thang Q. Nguyen <thang@os.amperecomputing.com>
Change-Id: Ie62a1c1a4edeaf165f834f7456c26711b4b42701
diff --git a/meta-ampere/meta-jade/recipes-phosphor/inventory/inventory-cleanup.bb b/meta-ampere/meta-jade/recipes-phosphor/inventory/inventory-cleanup.bb
new file mode 100644
index 0000000..0c4b56f
--- /dev/null
+++ b/meta-ampere/meta-jade/recipes-phosphor/inventory/inventory-cleanup.bb
@@ -0,0 +1,17 @@
+SUMMARY = "Copy the inventory cleanup yaml for inventory manager"
+PR = "r1"
+LICENSE = "Apache-2.0"
+LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"
+
+inherit allarch
+inherit phosphor-inventory-manager
+
+S = "${WORKDIR}"
+
+SRC_URI = "file://inventory-cleanup.yaml"
+
+do_install() {
+        install -D inventory-cleanup.yaml ${D}${base_datadir}/events.d/inventory-cleanup.yaml
+}
+
+FILES_${PN} += "${base_datadir}/events.d/inventory-cleanup.yaml"
diff --git a/meta-ampere/meta-jade/recipes-phosphor/inventory/inventory-cleanup/inventory-cleanup.yaml b/meta-ampere/meta-jade/recipes-phosphor/inventory/inventory-cleanup/inventory-cleanup.yaml
new file mode 100644
index 0000000..e900ad7
--- /dev/null
+++ b/meta-ampere/meta-jade/recipes-phosphor/inventory/inventory-cleanup/inventory-cleanup.yaml
@@ -0,0 +1,16 @@
+description: >
+    Mt.Jade inventory fixups
+
+events:
+    - name: Add Chassis interface
+      description: >
+          Add the chassis interface on the chassis inventory path
+      type: startup
+      actions:
+          - name: createObjects
+            objs:
+                /system/chassis:
+                  xyz.openbmc_project.Inventory.Item.Chassis:
+                      Type:
+                          value: "RackMount"
+                          type: string
diff --git a/meta-ampere/meta-jade/recipes-phosphor/inventory/phosphor-inventory-manager/associations.json b/meta-ampere/meta-jade/recipes-phosphor/inventory/phosphor-inventory-manager/associations.json
new file mode 100644
index 0000000..bc9cfee
--- /dev/null
+++ b/meta-ampere/meta-jade/recipes-phosphor/inventory/phosphor-inventory-manager/associations.json
@@ -0,0 +1,72 @@
+[
+    {
+        "path": "system/chassis",
+        "endpoints":
+        [
+            {
+                "types":
+                {
+                    "rType": "chassis",
+                    "fType": "all_sensors"
+                },
+                "paths":
+                [
+                    "/xyz/openbmc_project/sensors/fan_tach/FAN3_1",
+                    "/xyz/openbmc_project/sensors/fan_tach/FAN3_2",
+                    "/xyz/openbmc_project/sensors/fan_tach/FAN4_1",
+                    "/xyz/openbmc_project/sensors/fan_tach/FAN4_2",
+                    "/xyz/openbmc_project/sensors/fan_tach/FAN5_1",
+                    "/xyz/openbmc_project/sensors/fan_tach/FAN5_2",
+                    "/xyz/openbmc_project/sensors/fan_tach/FAN6_1",
+                    "/xyz/openbmc_project/sensors/fan_tach/FAN6_2",
+                    "/xyz/openbmc_project/sensors/fan_tach/FAN7_1",
+                    "/xyz/openbmc_project/sensors/fan_tach/FAN7_2",
+                    "/xyz/openbmc_project/sensors/fan_tach/FAN8_1",
+                    "/xyz/openbmc_project/sensors/fan_tach/FAN8_2",
+                    "/xyz/openbmc_project/sensors/fan_tach/PSU0_fan1",
+                    "/xyz/openbmc_project/sensors/fan_tach/PSU1_fan1",
+
+                    "/xyz/openbmc_project/sensors/temperature/TS1_Temp",
+                    "/xyz/openbmc_project/sensors/temperature/TS2_Temp",
+                    "/xyz/openbmc_project/sensors/temperature/TS3_Temp",
+                    "/xyz/openbmc_project/sensors/temperature/TS4_Temp",
+                    "/xyz/openbmc_project/sensors/temperature/TS5_Temp",
+                    "/xyz/openbmc_project/sensors/temperature/TS6_Temp",
+                    "/xyz/openbmc_project/sensors/temperature/PSU0_TEMP",
+                    "/xyz/openbmc_project/sensors/temperature/PSU1_TEMP",
+
+                    "/xyz/openbmc_project/sensors/voltage/S0_0V6_VTT0123",
+                    "/xyz/openbmc_project/sensors/voltage/S0_0V6_VTT4567",
+                    "/xyz/openbmc_project/sensors/voltage/S0_0V75_PCP",
+                    "/xyz/openbmc_project/sensors/voltage/S0_0V8_VDDC_SOC",
+                    "/xyz/openbmc_project/sensors/voltage/S0_0V85_RCA",
+                    "/xyz/openbmc_project/sensors/voltage/S0_1V2_VDDQ0123",
+                    "/xyz/openbmc_project/sensors/voltage/S0_1V2_VDDQ4567",
+                    "/xyz/openbmc_project/sensors/voltage/S0_1V5_VDDH",
+                    "/xyz/openbmc_project/sensors/voltage/S0_1V8_VDDH",
+                    "/xyz/openbmc_project/sensors/voltage/S0_1V8_SOC",
+                    "/xyz/openbmc_project/sensors/voltage/S0_1V8_PCP",
+                    "/xyz/openbmc_project/sensors/voltage/S0_2V5_VPP0123",
+                    "/xyz/openbmc_project/sensors/voltage/S0_2V5_VPP4567",
+                    "/xyz/openbmc_project/sensors/voltage/S0_3V3_SOC",
+                    "/xyz/openbmc_project/sensors/voltage/S1_0V6_VTT0123",
+                    "/xyz/openbmc_project/sensors/voltage/S1_0V6_VTT4567",
+                    "/xyz/openbmc_project/sensors/voltage/S1_0V75_PCP",
+                    "/xyz/openbmc_project/sensors/voltage/S1_0V8_VDDC_SOC",
+                    "/xyz/openbmc_project/sensors/voltage/S1_0V85_RCA",
+                    "/xyz/openbmc_project/sensors/voltage/S1_1V2_VDDQ0123",
+                    "/xyz/openbmc_project/sensors/voltage/S1_1V2_VDDQ4567",
+                    "/xyz/openbmc_project/sensors/voltage/S1_1V5_VDDH",
+                    "/xyz/openbmc_project/sensors/voltage/S1_1V8_VDDH",
+                    "/xyz/openbmc_project/sensors/voltage/S1_1V8_SOC",
+                    "/xyz/openbmc_project/sensors/voltage/S1_1V8_PCP",
+                    "/xyz/openbmc_project/sensors/voltage/S1_2V5_VPP0123",
+                    "/xyz/openbmc_project/sensors/voltage/S1_2V5_VPP4567",
+                    "/xyz/openbmc_project/sensors/voltage/S1_3V3_SOC",
+                    "/xyz/openbmc_project/sensors/voltage/3V3_SB",
+                    "/xyz/openbmc_project/sensors/voltage/VBAT_RTC"
+                ]
+            }
+        ]
+    }
+]
diff --git a/meta-ampere/meta-jade/recipes-phosphor/inventory/phosphor-inventory-manager_%.bbappend b/meta-ampere/meta-jade/recipes-phosphor/inventory/phosphor-inventory-manager_%.bbappend
new file mode 100644
index 0000000..a885680
--- /dev/null
+++ b/meta-ampere/meta-jade/recipes-phosphor/inventory/phosphor-inventory-manager_%.bbappend
@@ -0,0 +1,10 @@
+DEPENDS_append_mtjade = " inventory-cleanup"
+
+FILESEXTRAPATHS_prepend_mtjade := "${THISDIR}/${PN}:"
+PACKAGECONFIG_append_mtjade = " associations"
+SRC_URI_append_mtjade = " file://associations.json"
+
+do_install_append_mtjade() {
+    install -d ${D}${base_datadir}
+    install -m 0755 ${WORKDIR}/associations.json ${D}${base_datadir}
+}