meta-ibm: Add phosphor-virtual-sensor

Enable virtual sensor to:
- provide sensor 'total_power'
- expose QSFP temperature sensors to webui

Change-Id: I13c64cd9891aee11019dd85a6fa2158482a38c67
Signed-off-by: Patrick Rudolph <patrick.rudolph@9elements.com>
diff --git a/meta-ibm/meta-sbp1/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend b/meta-ibm/meta-sbp1/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend
index 9bcb719..8933a88 100644
--- a/meta-ibm/meta-sbp1/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend
+++ b/meta-ibm/meta-sbp1/recipes-phosphor/packagegroups/packagegroup-obmc-apps.bbappend
@@ -34,6 +34,7 @@
     phosphor-host-postd \
     phosphor-state-manager-chassis \
     phosphor-hwmon \
+    phosphor-virtual-sensor \
     "
 
 SUMMARY:${PN}-flash = "IBM Flash"
diff --git a/meta-ibm/recipes-phosphor/sensors/phosphor-virtual-sensor/sbp1/virtual_sensor_config.json b/meta-ibm/recipes-phosphor/sensors/phosphor-virtual-sensor/sbp1/virtual_sensor_config.json
new file mode 100644
index 0000000..82f65a1
--- /dev/null
+++ b/meta-ibm/recipes-phosphor/sensors/phosphor-virtual-sensor/sbp1/virtual_sensor_config.json
@@ -0,0 +1,173 @@
+[
+  {
+    "Desc": {
+      "Name": "total_power",
+      "SensorType": "power"
+    },
+    "Associations": [
+      [
+        "chassis",
+        "all_sensors",
+        "/xyz/openbmc_project/inventory/system/board/IBM_SBP1_Baseboard"
+      ],
+      [
+        "inventory",
+        "sensors",
+        "/xyz/openbmc_project/inventory/system/board/IBM_SBP1_Baseboard"
+      ]
+    ],
+    "Params": {
+      "DbusParam": [
+        {
+          "ParamName": "P0",
+          "Desc": {
+            "Name": "BCM0_Input_Power",
+            "SensorType": "power"
+          }
+        },
+        {
+          "ParamName": "P1",
+          "Desc": {
+            "Name": "BCM1_Input_Power",
+            "SensorType": "power"
+          }
+        },
+        {
+          "ParamName": "P2",
+          "Desc": {
+            "Name": "BCM2_Input_Power",
+            "SensorType": "power"
+          }
+        },
+        {
+          "ParamName": "P3",
+          "Desc": {
+            "Name": "BCM3_Input_Power",
+            "SensorType": "power"
+          }
+        }
+      ]
+    },
+    "Expression": "sumIgnoreNaN(P0, P1, P2, P3)"
+  },
+  {
+    "Desc": {
+      "Name": "QSFP1 Temperature",
+      "SensorType": "temperature"
+    },
+    "Associations": [
+      [
+        "chassis",
+        "all_sensors",
+        "/xyz/openbmc_project/inventory/system/board/IBM_SBP1_Baseboard"
+      ],
+      [
+        "inventory",
+        "sensors",
+        "/xyz/openbmc_project/inventory/system/board/IBM_SBP1_Baseboard"
+      ]
+    ],
+    "Params": {
+      "DbusParam": [
+        {
+          "ParamName": "T0",
+          "Desc": {
+            "Name": "QSFP1_TEMP",
+            "SensorType": "temperature"
+          }
+        }
+      ]
+    },
+    "Expression": "ifNan(T0, 0)"
+  },
+  {
+    "Desc": {
+      "Name": "QSFP2 Temperature",
+      "SensorType": "temperature"
+    },
+    "Associations": [
+      [
+        "chassis",
+        "all_sensors",
+        "/xyz/openbmc_project/inventory/system/board/IBM_SBP1_Baseboard"
+      ],
+      [
+        "inventory",
+        "sensors",
+        "/xyz/openbmc_project/inventory/system/board/IBM_SBP1_Baseboard"
+      ]
+    ],
+    "Params": {
+      "DbusParam": [
+        {
+          "ParamName": "T0",
+          "Desc": {
+            "Name": "QSFP2_TEMP",
+            "SensorType": "temperature"
+          }
+        }
+      ]
+    },
+    "Expression": "ifNan(T0, 0)"
+  },
+  {
+    "Desc": {
+      "Name": "QSFP3 Temperature",
+      "SensorType": "temperature"
+    },
+    "Associations": [
+      [
+        "chassis",
+        "all_sensors",
+        "/xyz/openbmc_project/inventory/system/board/IBM_SBP1_Baseboard"
+      ],
+      [
+        "inventory",
+        "sensors",
+        "/xyz/openbmc_project/inventory/system/board/IBM_SBP1_Baseboard"
+      ]
+    ],
+    "Params": {
+      "DbusParam": [
+        {
+          "ParamName": "T0",
+          "Desc": {
+            "Name": "QSFP3_TEMP",
+            "SensorType": "temperature"
+          }
+        }
+      ]
+    },
+    "Expression": "ifNan(T0, 0)"
+  },
+  {
+    "Desc": {
+      "Name": "QSFP4 Temperature",
+      "SensorType": "temperature"
+    },
+    "Associations": [
+      [
+        "chassis",
+        "all_sensors",
+        "/xyz/openbmc_project/inventory/system/board/IBM_SBP1_Baseboard"
+      ],
+      [
+        "inventory",
+        "sensors",
+        "/xyz/openbmc_project/inventory/system/board/IBM_SBP1_Baseboard"
+      ]
+    ],
+    "Params": {
+      "DbusParam": [
+        {
+          "ParamName": "T0",
+          "Desc": {
+            "Name": "QSFP4_TEMP",
+            "SensorType": "temperature"
+          }
+        }
+      ]
+    },
+    "Expression": "ifNan(T0, 0)"
+  }
+]
diff --git a/meta-ibm/recipes-phosphor/sensors/phosphor-virtual-sensor_%.bbappend b/meta-ibm/recipes-phosphor/sensors/phosphor-virtual-sensor_%.bbappend
index 4133684..463df3b 100644
--- a/meta-ibm/recipes-phosphor/sensors/phosphor-virtual-sensor_%.bbappend
+++ b/meta-ibm/recipes-phosphor/sensors/phosphor-virtual-sensor_%.bbappend
@@ -1,5 +1,10 @@
 FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
 SRC_URI:append:p10bmc = " file://virtual_sensor_config.json"
+SRC_URI:append:sbp1 = " file://virtual_sensor_config.json"
+
+do_install:append:sbp1() {
+    install -m 0644 ${WORKDIR}/virtual_sensor_config.json ${D}${datadir}/phosphor-virtual-sensor/
+}
 
 do_install:append:p10bmc() {
     install -m 0644 ${WORKDIR}/virtual_sensor_config.json ${D}${datadir}/phosphor-virtual-sensor/