control:p10bmc:ibm,rainier-2u: Fan floor tables

Add the initial floor table using the mapped_floor action based on the
ambient temperature, altitude, and PCIe floor index.

This also includes the pcie_cards.json file that contains the PCIe cards
with their floor indexes.

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: I3d90717e504060e34b4afdce8130b080eb7275c3
diff --git a/control/config_files/p10bmc/ibm,rainier-2u/events.json b/control/config_files/p10bmc/ibm,rainier-2u/events.json
index 3b419a7..72198d6 100644
--- a/control/config_files/p10bmc/ibm,rainier-2u/events.json
+++ b/control/config_files/p10bmc/ibm,rainier-2u/events.json
@@ -1246,5 +1246,197 @@
          "signal": "interfaces_removed"
        }
      ]
+   },
+   {
+     "name": "set pcie floor index",
+     "groups": [
+       {
+         "name": "pcie slots",
+         "interface": "xyz.openbmc_project.State.Decorator.PowerState",
+         "property": {
+           "name": "PowerState"
+         }
+       },
+       {
+         "name": "pcie cards",
+         "interface": "xyz.openbmc_project.Inventory.Item.PCIeDevice",
+         "property": {
+           "name": "Function0DeviceId"
+         }
+       },
+       {
+         "name": "pcie cards",
+         "interface": "xyz.openbmc_project.Inventory.Item.PCIeDevice",
+         "property": {
+           "name": "Function0VendorId"
+         }
+       },
+       {
+         "name": "pcie cards",
+         "interface": "xyz.openbmc_project.Inventory.Item.PCIeDevice",
+         "property": {
+           "name": "Function0SubsystemId"
+         }
+       },
+       {
+         "name": "pcie cards",
+         "interface": "xyz.openbmc_project.Inventory.Item.PCIeDevice",
+         "property": {
+           "name": "Function0SubsystemVendorId"
+         }
+       }
+     ],
+     "triggers": [
+       {
+         "class": "init",
+         "method": "get_properties"
+       },
+       {
+         "class": "signal",
+         "signal": "properties_changed"
+       },
+       {
+         "class": "signal",
+         "signal": "interfaces_added"
+       }
+     ],
+     "actions": [
+       {
+         "name": "pcie_card_floors",
+         "use_config_specific_files": true,
+         "settle_time": 2
+       }
+     ]
+   },
+   {
+     "name": "Fan floors",
+     "groups": [
+      {
+        "name": "altitude",
+        "interface": "xyz.openbmc_project.Sensor.Value",
+        "property": { "name": "Value" }
+      },
+      {
+        "name": "ambient temp",
+        "interface": "xyz.openbmc_project.Sensor.Value",
+        "property": { "name": "Value" }
+      }
+     ],
+     "triggers": [
+       {
+         "class": "init",
+         "method": "get_properties"
+       },
+       {
+         "class": "signal",
+         "signal": "properties_changed"
+       },
+       {
+         "class": "signal",
+         "signal": "interfaces_added"
+       }
+     ],
+     "actions": [
+       {
+         "name": "mapped_floor",
+         "key_group": "ambient temp",
+         "fan_floors": [
+          {
+            // Entry valid for temps < 20
+            "key": 20,
+            "floors": [
+              {
+                "parameter": "pcie_floor_index",
+                "floors": [
+                  { "value": 1, "floor": 6000 },
+                  { "value": 2, "floor": 9300 },
+                  { "value": 3, "floor": 9300 },
+                  { "value": 4, "floor": 9800 },
+                  { "value": 5, "floor": 11300 }
+                ]
+              },
+              {
+                "group": "altitude",
+                "floors": [
+                  { "value": 915, "floor": 6400 },
+                  { "value": 1829, "floor": 11050 },
+                  { "value": 3048, "floor": 17250 }
+                ]
+              }
+            ]
+          },
+          {
+            // Entry valid for temps < 25
+            "key": 25,
+            "floors": [
+              {
+                "parameter": "pcie_floor_index",
+                "floors": [
+                  { "value": 1, "floor": 8400 },
+                  { "value": 2, "floor": 10600 },
+                  { "value": 3, "floor": 12100 },
+                  { "value": 4, "floor": 13500 },
+                  { "value": 5, "floor": 14900 }
+                ]
+              },
+              {
+                "group": "altitude",
+                "floors": [
+                  { "value": 915, "floor": 7500 },
+                  { "value": 1829, "floor": 11679 },
+                  { "value": 3048, "floor": 17250 }
+                ]
+              }
+            ]
+          },
+          {
+            // Entry valid for temps < 30
+            "key": 30,
+            "floors": [
+              {
+                "parameter": "pcie_floor_index",
+                "floors": [
+                  { "value": 1, "floor": 10800 },
+                  { "value": 2, "floor": 12000 },
+                  { "value": 3, "floor": 15600 },
+                  { "value": 4, "floor": 17250 },
+                  { "value": 5, "floor": 17250 }
+                ]
+              },
+              {
+                "group": "altitude",
+                "floors": [
+                  { "value": 915, "floor": 13011 },
+                  { "value": 1829, "floor": 14828 },
+                  { "value": 3048, "floor": 17250 }
+                ]
+              }
+            ]
+          },
+          {
+            // Entry valid for temps < 35
+            "key": 35,
+            "floors": [
+              {
+                "parameter": "pcie_floor_index",
+                "floors": [
+                  { "value": 1, "floor": 13200 },
+                  { "value": 2, "floor": 13300 },
+                  { "value": 3, "floor": 17250 },
+                  { "value": 4, "floor": 17250 },
+                  { "value": 5, "floor": 17250 }
+                ]
+              },
+              {
+                "group": "altitude",
+                "floors": [
+                  { "value": 3048, "floor": 17250 }
+                ]
+              }
+            ]
+          }
+        ]
+       }
+     ]
    }
 ]
diff --git a/control/config_files/p10bmc/ibm,rainier-2u/groups.json b/control/config_files/p10bmc/ibm,rainier-2u/groups.json
index 9c42ff1..591197d 100644
--- a/control/config_files/p10bmc/ibm,rainier-2u/groups.json
+++ b/control/config_files/p10bmc/ibm,rainier-2u/groups.json
@@ -527,5 +527,37 @@
    "members": [
       "/xyz/openbmc_project/sensors/altitude/Altitude"
    ]
+ },
+ {
+   "name": "pcie cards",
+   "members": [
+     "/xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot0/pcie_card0",
+     "/xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot1/pcie_card1",
+     "/xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot2/pcie_card2",
+     "/xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot3/pcie_card3",
+     "/xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot4/pcie_card4",
+     "/xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot6/pcie_card6",
+     "/xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot7/pcie_card7",
+     "/xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot8/pcie_card8",
+     "/xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot9/pcie_card9",
+     "/xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot10/pcie_card10",
+     "/xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot11/pcie_card11"
+   ]
+ },
+ {
+   "name": "pcie slots",
+   "members": [
+     "/xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot0",
+     "/xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot1",
+     "/xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot2",
+     "/xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot3",
+     "/xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot4",
+     "/xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot6",
+     "/xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot7",
+     "/xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot8",
+     "/xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot9",
+     "/xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot10",
+     "/xyz/openbmc_project/inventory/system/chassis/motherboard/pcieslot11"
+   ]
  }
 ]
diff --git a/control/config_files/p10bmc/ibm,rainier-2u/pcie_cards.json b/control/config_files/p10bmc/ibm,rainier-2u/pcie_cards.json
new file mode 100644
index 0000000..90c7b2f
--- /dev/null
+++ b/control/config_files/p10bmc/ibm,rainier-2u/pcie_cards.json
@@ -0,0 +1,140 @@
+{
+  "cards": [
+    {
+      "name": "PHYP had errors getting IDs",
+      "vendor_id": "0xFFFF",
+      "device_id": "0xFFFF",
+      "subsystem_vendor_id": "0xFFFF",
+      "subsystem_id": "0xFFFF",
+      "floor_index": 5
+    },
+    {
+      "name": "Flett",
+      "vendor_id": "0x1014",
+      "device_id": "0x04F2",
+      "subsystem_vendor_id": "0x1014",
+      "subsystem_id": "0x0007",
+      "has_temp_sensor": true
+    },
+    {
+      "name": "Bear Lake and Bear River",
+      "vendor_id": "0x1014",
+      "device_id": "0x04F2",
+      "subsystem_vendor_id": "0x1014",
+      "subsystem_id": "0x0004",
+      "has_temp_sensor": true
+    },
+    {
+      "name": "Everglades 10Gb 2Port",
+      "vendor_id": "0x15B3",
+      "device_id": "0x1015",
+      "subsystem_vendor_id": "0x1014",
+      "subsystem_id": "0x061F",
+      "floor_index": 1
+    },
+    {
+      "name": "Everglades 25Gb 2Port",
+      "vendor_id": "0x15B3",
+      "device_id": "0x1015",
+      "subsystem_vendor_id": "0x1014",
+      "subsystem_id": "0x061E",
+      "floor_index": 1
+    },
+    {
+      "name": "Cedar Lake 100G 2port",
+      "vendor_id": "0x15B3",
+      "device_id": "0x101D",
+      "subsystem_vendor_id": "0x1014",
+      "subsystem_id": "0x06A6",
+      "floor_index": 5
+    },
+    {
+      "name": "Cedar Lake Crypto 100G 2port",
+      "vendor_id": "0x15B3",
+      "device_id": "0x101D",
+      "subsystem_vendor_id": "0x1014",
+      "subsystem_id": "0x06A5",
+      "floor_index": 5
+    },
+    {
+      "name": "GTO",
+      "vendor_id": "0x1014",
+      "device_id": "0x034A",
+      "subsystem_vendor_id": "0x1014",
+      "subsystem_id": "0x033B",
+      "floor_index": 2
+    },
+    {
+      "name": "Bolt PCIe3 NVMe Flash Adapter II x8 1.6TB",
+      "vendor_id": "0x144D",
+      "device_id": "0xA822",
+      "subsystem_vendor_id": "0x1014",
+      "subsystem_id": "0x0621",
+      "floor_index": 3
+    },
+    {
+      "name": "Bolt PCIe3 NVMe Flash Adapter II x8 3.2TB",
+      "vendor_id": "0x144D",
+      "device_id": "0xA822",
+      "subsystem_vendor_id": "0x1014",
+      "subsystem_id": "0x0622",
+      "floor_index": 4
+    },
+    {
+      "name": "Bolt PCIe3 NVMe Flash Adapter II x8 6.4TB",
+      "vendor_id": "0x144D",
+      "device_id": "0xA822",
+      "subsystem_vendor_id": "0x1014",
+      "subsystem_id": "0x0629",
+      "floor_index": 4
+    },
+    {
+      "name": "Bolt PCIe3 NVMe Flash Adapter III x8 1.6TB",
+      "vendor_id": "0x144D",
+      "device_id": "0xA822",
+      "subsystem_vendor_id": "0x1014",
+      "subsystem_id": "0x064A",
+      "floor_index": 3
+    },
+    {
+      "name": "Bolt PCIe3 NVMe Flash Adapter III x8 3.2TB",
+      "vendor_id": "0x144D",
+      "device_id": "0xA822",
+      "subsystem_vendor_id": "0x1014",
+      "subsystem_id": "0x064B",
+      "floor_index": 4
+    },
+    {
+      "name": "Bolt PCIe3 NVMe Flash Adapter III x8 6.4TB",
+      "vendor_id": "0x144D",
+      "device_id": "0xA822",
+      "subsystem_vendor_id": "0x1014",
+      "subsystem_id": "0x064C",
+      "floor_index": 4
+    },
+    {
+      "name": "Kona PCIe4 NVMe U.2 Flash Adapter x8 1.6TB",
+      "vendor_id": "0x144D",
+      "device_id": "0xA824",
+      "subsystem_vendor_id": "0x1014",
+      "subsystem_id": "0x0682",
+      "floor_index": 4
+    },
+    {
+      "name": "Kona PCIe4 NVMe U.2 Flash Adapter x8 3.2TB",
+      "vendor_id": "0x144D",
+      "device_id": "0xA824",
+      "subsystem_vendor_id": "0x1014",
+      "subsystem_id": "0x0683",
+      "floor_index": 4
+    },
+    {
+      "name": "Kona PCIe4 NVMe U.2 Flash Adapter x8 6.4TB",
+      "vendor_id": "0x144D",
+      "device_id": "0xA824",
+      "subsystem_vendor_id": "0x1014",
+      "subsystem_id": "0x0684",
+      "floor_index": 4
+    }
+  ]
+}