meta-fii: meta-kudo: Modify virtual sensor config

Add CPU detect to support 1p/2p virtual sensor json configuration
Add new thermal sensors
Add virtual sensor json selection support based on NBM chipset version

Signed-off-by: Mustafa Shehabi <mustafa.shehabi@fii-na.com>
Signed-off-by: Avenash Asai Thambi <avenash.thambi@fii-usa.com>
Change-Id: Ib5a442cc35f2402c521557d908a90a86dd091cc0
diff --git a/meta-fii/meta-kudo/recipes-phosphor/sensors/phosphor-virtual-sensor/virtual_sensor_config2p2G.json b/meta-fii/meta-kudo/recipes-phosphor/sensors/phosphor-virtual-sensor/virtual_sensor_config2p2G.json
new file mode 100644
index 0000000..8516173
--- /dev/null
+++ b/meta-fii/meta-kudo/recipes-phosphor/sensors/phosphor-virtual-sensor/virtual_sensor_config2p2G.json
@@ -0,0 +1,588 @@
+[
+    {
+       "Desc":{
+          "Name":"CPU0_NBM_T",
+          "SensorType":"temperature",
+          "MinValue":0,
+          "MaxValue":160
+       },
+       "Threshold":
+       {
+          "CriticalHigh":110,
+          "WarningHigh":108
+       },
+       "Associations":[
+          [
+             "chassis",
+             "all_sensors",
+             "/xyz/openbmc_project/inventory/system/board/Kudo_Motherboard"
+          ],
+          [
+             "inventory",
+             "sensors",
+             "/xyz/openbmc_project/inventory/system/board/Kudo_Motherboard"
+          ]
+       ],
+       "Params":{
+          "DbusParam":[
+             {
+                "ParamName":"CPU0_NBM4G_TMP_V",
+                "Desc":{
+                   "Name":"CPU0_NBM4G_TMP_V",
+                   "SensorType":"voltage"
+                }
+             }
+          ]
+       },
+       "Expression":"(CPU0_NBM4G_TMP_V == CPU0_NBM4G_TMP_V) ? (CPU0_NBM4G_TMP_V - 2.73) * 100 : NULL"
+    },
+    {
+       "Desc":{
+          "Name":"CPU1_NBM_T",
+          "SensorType":"temperature",
+          "MinValue":0,
+          "MaxValue":160
+       },
+       "Threshold":
+       {
+          "CriticalHigh":110,
+          "WarningHigh":108
+       },
+       "Associations":[
+          [
+             "chassis",
+             "all_sensors",
+             "/xyz/openbmc_project/inventory/system/board/Kudo_Motherboard"
+          ],
+          [
+             "inventory",
+             "sensors",
+             "/xyz/openbmc_project/inventory/system/board/Kudo_Motherboard"
+          ]
+       ],
+       "Params":{
+          "DbusParam":[
+             {
+                "ParamName":"CPU1_NBM4G_TMP_V",
+                "Desc":{
+                   "Name":"CPU1_NBM4G_TMP_V",
+                   "SensorType":"voltage"
+                }
+             }
+          ]
+       },
+       "Expression":"(CPU1_NBM4G_TMP_V == CPU1_NBM4G_TMP_V) ? (CPU1_NBM4G_TMP_V - 2.73) * 100 : NULL"
+    },
+    {
+       "Desc":{
+          "Name":"CPU0_DIMMG_T",
+          "SensorType":"temperature",
+          "MinValue":0,
+          "MaxValue":255
+       },
+       "Threshold":
+       {
+          "CriticalHigh":90,
+          "WarningHigh":85
+       },
+       "Associations":[
+          [
+             "chassis",
+             "all_sensors",
+             "/xyz/openbmc_project/inventory/system/board/Kudo_Motherboard"
+          ],
+          [
+             "inventory",
+             "sensors",
+             "/xyz/openbmc_project/inventory/system/board/Kudo_Motherboard"
+          ]
+       ],
+       "Params":{
+          "DbusParam":[
+             {
+                "ParamName":"CPU0_CH0",
+                "Desc":{
+                   "Name":"CPU0_CH0DIMM_T",
+                   "SensorType":"temperature"
+                }
+             },
+             {
+                "ParamName":"CPU0_CH1",
+                "Desc":{
+                   "Name":"CPU0_CH1DIMM_T",
+                   "SensorType":"temperature"
+                }
+             },
+             {
+                "ParamName":"CPU0_CH2",
+                "Desc":{
+                   "Name":"CPU0_CH2DIMM_T",
+                   "SensorType":"temperature"
+                }
+             },
+             {
+                "ParamName":"CPU0_CH3",
+                "Desc":{
+                   "Name":"CPU0_CH3DIMM_T",
+                   "SensorType":"temperature"
+                }
+             },
+             {
+                "ParamName":"CPU0_CH4",
+                "Desc":{
+                   "Name":"CPU0_CH4DIMM_T",
+                   "SensorType":"temperature"
+                }
+             },
+             {
+                "ParamName":"CPU0_CH5",
+                "Desc":{
+                   "Name":"CPU0_CH5DIMM_T",
+                   "SensorType":"temperature"
+                }
+             },
+             {
+                "ParamName":"CPU0_CH6",
+                "Desc":{
+                   "Name":"CPU0_CH6DIMM_T",
+                   "SensorType":"temperature"
+                }
+             },
+             {
+                "ParamName":"CPU0_CH7",
+                "Desc":{
+                   "Name":"CPU0_CH7DIMM_T",
+                   "SensorType":"temperature"
+                }
+             }
+          ]
+       },
+       "Expression":"var x := max((CPU0_CH0 == CPU0_CH0) ? CPU0_CH0 : 0,(CPU0_CH1 == CPU0_CH1) ? CPU0_CH1 : 0,(CPU0_CH2 == CPU0_CH2) ? CPU0_CH2 : 0,(CPU0_CH3 == CPU0_CH3) ? CPU0_CH3 : 0,(CPU0_CH4 == CPU0_CH4) ? CPU0_CH4 : 0,(CPU0_CH5 == CPU0_CH5) ? CPU0_CH5 : 0,(CPU0_CH6 == CPU0_CH6) ? CPU0_CH6 : 0,(CPU0_CH7 == CPU0_CH7) ? CPU0_CH7 : 0); x == 0 ? NULL : x"
+    },
+    {
+       "Desc":{
+          "Name":"CPU1_DIMMG_T",
+          "SensorType":"temperature",
+          "MinValue":0,
+          "MaxValue":255
+       },
+       "Threshold":
+       {
+          "CriticalHigh":90,
+          "WarningHigh":85
+       },
+       "Associations":[
+          [
+             "chassis",
+             "all_sensors",
+             "/xyz/openbmc_project/inventory/system/board/Kudo_Motherboard"
+          ],
+          [
+             "inventory",
+             "sensors",
+             "/xyz/openbmc_project/inventory/system/board/Kudo_Motherboard"
+          ]
+       ],
+       "Params":{
+          "DbusParam":[
+             {
+                "ParamName":"CPU1_CH0",
+                "Desc":{
+                   "Name":"CPU1_CH0DIMM_T",
+                   "SensorType":"temperature"
+                }
+             },
+             {
+                "ParamName":"CPU1_CH1",
+                "Desc":{
+                   "Name":"CPU1_CH1DIMM_T",
+                   "SensorType":"temperature"
+                }
+             },
+             {
+                "ParamName":"CPU1_CH2",
+                "Desc":{
+                   "Name":"CPU1_CH2DIMM_T",
+                   "SensorType":"temperature"
+                }
+             },
+             {
+                "ParamName":"CPU1_CH3",
+                "Desc":{
+                   "Name":"CPU1_CH3DIMM_T",
+                   "SensorType":"temperature"
+                }
+             },
+             {
+                "ParamName":"CPU1_CH4",
+                "Desc":{
+                   "Name":"CPU1_CH4DIMM_T",
+                   "SensorType":"temperature"
+                }
+             },
+             {
+                "ParamName":"CPU1_CH5",
+                "Desc":{
+                   "Name":"CPU1_CH5DIMM_T",
+                   "SensorType":"temperature"
+                }
+             },
+             {
+                "ParamName":"CPU1_CH6",
+                "Desc":{
+                   "Name":"CPU1_CH6DIMM_T",
+                   "SensorType":"temperature"
+                }
+             },
+             {
+                "ParamName":"CPU1_CH7",
+                "Desc":{
+                   "Name":"CPU1_CH7DIMM_T",
+                   "SensorType":"temperature"
+                }
+             }
+          ]
+       },
+       "Expression":"var x := max((CPU1_CH0 == CPU1_CH0) ? CPU1_CH0 : 0,(CPU1_CH1 == CPU1_CH1) ? CPU1_CH1 : 0,(CPU1_CH2 == CPU1_CH2) ? CPU1_CH2 : 0,(CPU1_CH3 == CPU1_CH3) ? CPU1_CH3 : 0,(CPU1_CH4 == CPU1_CH4) ? CPU1_CH4 : 0,(CPU1_CH5 == CPU1_CH5) ? CPU1_CH5 : 0,(CPU1_CH6 == CPU1_CH6) ? CPU1_CH6 : 0,(CPU1_CH7 == CPU1_CH7) ? CPU1_CH7 : 0); x == 0 ? NULL : x"
+    },
+    {
+       "Desc":{
+          "Name":"CPU0_DIMM_DDR_V",
+          "SensorType":"voltage",
+          "MinValue":0,
+          "MaxValue":5
+       },
+       "Threshold":
+       {
+          "CriticalHigh":2.999
+       },
+       "Associations":[
+          [
+             "chassis",
+             "all_sensors",
+             "/xyz/openbmc_project/inventory/system/board/Kudo_Motherboard"
+          ],
+          [
+             "inventory",
+             "sensors",
+             "/xyz/openbmc_project/inventory/system/board/Kudo_Motherboard"
+          ]
+       ],
+       "Params":{
+          "DbusParam":[
+             {
+                "ParamName":"CPU0_DIMM_VR1_V",
+                "Desc":{
+                   "Name":"CPU0_DIMM_VR1_V",
+                   "SensorType":"voltage"
+                }
+             },
+             {
+                "ParamName":"CPU0_DIMM_VR2_V",
+                "Desc":{
+                   "Name":"CPU0_DIMM_VR2_V",
+                   "SensorType":"voltage"
+                }
+             }
+          ]
+       },
+       "Expression":"(CPU0_DIMM_VR1_V + CPU0_DIMM_VR2_V) >= 0 ? (CPU0_DIMM_VR1_V + CPU0_DIMM_VR2_V) : NULL"
+    },
+    {
+       "Desc":{
+          "Name":"CPU1_DIMM_DDR_V",
+          "SensorType":"voltage",
+          "MinValue":0,
+          "MaxValue":5
+       },
+       "Threshold":
+       {
+          "CriticalHigh":2.999
+       },
+       "Associations":[
+          [
+             "chassis",
+             "all_sensors",
+             "/xyz/openbmc_project/inventory/system/board/Kudo_Motherboard"
+          ],
+          [
+             "inventory",
+             "sensors",
+             "/xyz/openbmc_project/inventory/system/board/Kudo_Motherboard"
+          ]
+       ],
+       "Params":{
+          "DbusParam":[
+             {
+                "ParamName":"CPU1_DIMM_VR1_V",
+                "Desc":{
+                   "Name":"CPU1_DIMM_VR1_V",
+                   "SensorType":"voltage"
+                }
+             },
+             {
+                "ParamName":"CPU1_DIMM_VR2_V",
+                "Desc":{
+                   "Name":"CPU1_DIMM_VR2_V",
+                   "SensorType":"voltage"
+                }
+             }
+          ]
+       },
+       "Expression":"(CPU1_DIMM_VR1_V + CPU1_DIMM_VR2_V) >= 0 ? (CPU1_DIMM_VR1_V + CPU1_DIMM_VR2_V) : NULL"
+    },
+    {
+       "Desc":{
+          "Name":"CPU0_MEM_PW",
+          "SensorType":"power",
+          "MinValue":0,
+          "MaxValue":80
+       },
+       "Threshold":
+       {
+          "CriticalHigh":29.987
+       },
+       "Associations":[
+          [
+             "chassis",
+             "all_sensors",
+             "/xyz/openbmc_project/inventory/system/board/Kudo_Motherboard"
+          ],
+          [
+             "inventory",
+             "sensors",
+             "/xyz/openbmc_project/inventory/system/board/Kudo_Motherboard"
+          ]
+       ],
+       "Params":{
+          "DbusParam":[
+             {
+                "ParamName":"CPU0_DIMM_VR1_PW",
+                "Desc":{
+                   "Name":"CPU0_DIMM_VR1_PW",
+                   "SensorType":"power"
+                }
+             },
+             {
+                "ParamName":"CPU0_DIMM_VR2_PW",
+                "Desc":{
+                   "Name":"CPU0_DIMM_VR2_PW",
+                   "SensorType":"power"
+                }
+             }
+          ]
+       },
+       "Expression":"(CPU0_DIMM_VR1_PW + CPU0_DIMM_VR2_PW) >= 0 ? (CPU0_DIMM_VR1_PW + CPU0_DIMM_VR2_PW) : NULL"
+    },
+    {
+       "Desc":{
+          "Name":"CPU1_MEM_PW",
+          "SensorType":"power",
+          "MinValue":0,
+          "MaxValue":255
+       },
+       "Threshold":
+       {
+          "CriticalHigh":29.987
+       },
+       "Associations":[
+          [
+             "chassis",
+             "all_sensors",
+             "/xyz/openbmc_project/inventory/system/board/Kudo_Motherboard"
+          ],
+          [
+             "inventory",
+             "sensors",
+             "/xyz/openbmc_project/inventory/system/board/Kudo_Motherboard"
+          ]
+       ],
+       "Params":{
+          "DbusParam":[
+             {
+                "ParamName":"CPU1_DIMM_VR1_PW",
+                "Desc":{
+                   "Name":"CPU1_DIMM_VR1_PW",
+                   "SensorType":"power"
+                }
+             },
+             {
+                "ParamName":"CPU1_DIMM_VR2_PW",
+                "Desc":{
+                   "Name":"CPU1_DIMM_VR2_PW",
+                   "SensorType":"power"
+                }
+             }
+          ]
+       },
+       "Expression":"(CPU1_DIMM_VR1_PW + CPU1_DIMM_VR2_PW) >= 0 ? (CPU1_DIMM_VR1_PW + CPU1_DIMM_VR2_PW) : NULL"
+    },
+    {
+       "Desc":{
+          "Name":"CPU0_CPU_PW",
+          "SensorType":"power",
+          "MinValue":0,
+          "MaxValue":550
+       },
+       "Threshold":
+       {
+          "CriticalHigh":500
+       },
+       "Associations":[
+          [
+             "chassis",
+             "all_sensors",
+             "/xyz/openbmc_project/inventory/system/board/Kudo_Motherboard"
+          ],
+          [
+             "inventory",
+             "sensors",
+             "/xyz/openbmc_project/inventory/system/board/Kudo_Motherboard"
+          ]
+       ],
+       "Params":{
+          "DbusParam":[
+             {
+                "ParamName":"CPU0_Core_VRD_PW",
+                "Desc":{
+                   "Name":"CPU0_Core_VRD_PW",
+                   "SensorType":"power"
+                }
+             },
+             {
+                "ParamName":"CPU0_SOC_PW",
+                "Desc":{
+                   "Name":"CPU0_SOC_PW",
+                   "SensorType":"power"
+                }
+             }
+          ]
+       },
+       "Expression":"(CPU0_Core_VRD_PW + CPU0_SOC_PW) >= 0 ? (CPU0_Core_VRD_PW + CPU0_SOC_PW) : NULL"
+    },
+    {
+       "Desc":{
+          "Name":"CPU1_CPU_PW",
+          "SensorType":"power",
+          "MinValue":0,
+          "MaxValue":550
+       },
+       "Threshold":
+       {
+          "CriticalHigh":500
+       },
+       "Associations":[
+          [
+             "chassis",
+             "all_sensors",
+             "/xyz/openbmc_project/inventory/system/board/Kudo_Motherboard"
+          ],
+          [
+             "inventory",
+             "sensors",
+             "/xyz/openbmc_project/inventory/system/board/Kudo_Motherboard"
+          ]
+       ],
+       "Params":{
+          "DbusParam":[
+             {
+                "ParamName":"CPU1_Core_VRD_PW",
+                "Desc":{
+                   "Name":"CPU1_Core_VRD_PW",
+                   "SensorType":"power"
+                }
+             },
+             {
+                "ParamName":"CPU1_SOC_PW",
+                "Desc":{
+                   "Name":"CPU1_SOC_PW",
+                   "SensorType":"power"
+                }
+             }
+          ]
+       },
+       "Expression":"(CPU1_Core_VRD_PW + CPU1_SOC_PW) >= 0 ? (CPU1_Core_VRD_PW + CPU1_SOC_PW) : NULL"
+    },
+    {
+        "Desc":
+        {
+            "Name": "zone0_temp",
+            "SensorType": "temperature",
+            "MinValue": 0,
+            "MaxValue": 300
+        },
+        "Threshold" :
+        {
+            "CriticalHigh": 200,
+            "WarningHigh": 198
+        },
+        "Associations":[
+         [
+            "chassis",
+            "all_sensors",
+            "/xyz/openbmc_project/inventory/system/board/Kudo_Motherboard"
+         ],
+         [
+            "inventory",
+            "sensors",
+            "/xyz/openbmc_project/inventory/system/board/Kudo_Motherboard"
+         ]
+      ],
+        "Params":
+        {
+            "DbusParam":
+            [
+                {
+                    "ParamName": "margin0",
+                    "Desc":
+                    {
+                        "Name": "thermal_zone0",
+                        "SensorType": "temperature"
+                    }
+                }
+            ]
+        },
+        "Expression": "(200 - margin0)"
+    },
+    {
+        "Desc":
+        {
+            "Name": "zone1_temp",
+            "SensorType": "temperature",
+            "MinValue": 0,
+            "MaxValue": 300
+        },
+        "Threshold" :
+        {
+            "CriticalHigh": 200,
+            "WarningHigh": 198
+        },
+        "Associations":[
+         [
+            "chassis",
+            "all_sensors",
+            "/xyz/openbmc_project/inventory/system/board/Kudo_Motherboard"
+         ],
+         [
+            "inventory",
+            "sensors",
+            "/xyz/openbmc_project/inventory/system/board/Kudo_Motherboard"
+         ]
+      ],
+        "Params":
+        {
+            "DbusParam":
+            [
+                {
+                    "ParamName": "margin1",
+                    "Desc":
+                    {
+                        "Name": "thermal_zone1",
+                        "SensorType": "temperature"
+                    }
+                }
+            ]
+        },
+        "Expression": "(200 - margin1)"
+         }
+ ]