control:configs:rainier-4u: Use memory DVFS temps

Instead of hardcoding the increase and decrease temperatures for the
memory related sensors, do the same as what was done for the processor
core and ioring temps and use an offset from the DVFS (dynamic
voltage and frequency scaling) sensor for that sensor type.

This is being done because DDR4 and DDR5 memory have different DVFS
temperatures where the OCC starts throttling/slewing, and so just
hardcoding a single temperature value wouldn't work.

The *_increase_temp and *_decrease_temp modifier values were chosen such that
the final increase and decrease parameter temperature values were the
same as what the hardcoded temperatures were for DDR4.  They were
calculated by subtracting the old increase/decrease temp values from the
DVFS value.

Note: The 4U and 1S4U Use the same values for everything.

Tested:
Checked the parameters that were present on a Rainier-4U:
    "dram_extmb_dvfs_decrease_temp": 63.0,
    "dram_extmb_dvfs_increase_temp": 66.0,
    "pmic_dvfs_decrease_temp": 62.0,
    "pmic_dvfs_increase_temp": 65.0,

Signed-off-by: Matt Spinler <spinler@us.ibm.com>
Change-Id: Ia162046dc376d514284303337ba192a79d705b3d
diff --git a/control/config_files/p10bmc/ibm,rainier-1s4u/events.json b/control/config_files/p10bmc/ibm,rainier-1s4u/events.json
index 75e87af..73cfa0d 100644
--- a/control/config_files/p10bmc/ibm,rainier-1s4u/events.json
+++ b/control/config_files/p10bmc/ibm,rainier-1s4u/events.json
@@ -487,6 +487,216 @@
         ]
     },
     {
+        "name": "Set DRAM DVFS parameter",
+        "groups": [
+            {
+                "name": "dram dvfs 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": "set_parameter_from_group_max",
+                "parameter_name": "dram_dvfs_increase_temp",
+                "modifier": {
+                    "operator": "minus",
+                    "value": 10
+                }
+            },
+            {
+                "name": "set_parameter_from_group_max",
+                "parameter_name": "dram_dvfs_decrease_temp",
+                "modifier": {
+                    "operator": "minus",
+                    "value": 13
+                }
+            }
+        ]
+    },
+    {
+        "name": "Set PMIC DVFS parameter",
+        "groups": [
+            {
+                "name": "pmic dvfs 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": "set_parameter_from_group_max",
+                "parameter_name": "pmic_dvfs_increase_temp",
+                "modifier": {
+                    "operator": "minus",
+                    "value": 10
+                }
+            },
+            {
+                "name": "set_parameter_from_group_max",
+                "parameter_name": "pmic_dvfs_decrease_temp",
+                "modifier": {
+                    "operator": "minus",
+                    "value": 13
+                }
+            }
+        ]
+    },
+    {
+        "name": "Set internal memory buffer DVFS parameter",
+        "groups": [
+            {
+                "name": "internal memory buffer dvfs 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": "set_parameter_from_group_max",
+                "parameter_name": "intmb_dvfs_increase_temp",
+                "modifier": {
+                    "operator": "minus",
+                    "value": 10
+                }
+            },
+            {
+                "name": "set_parameter_from_group_max",
+                "parameter_name": "intmb_dvfs_decrease_temp",
+                "modifier": {
+                    "operator": "minus",
+                    "value": 13
+                }
+            }
+        ]
+    },
+    {
+        "name": "Set DRAM and external memory buffer DVFS parameter",
+        "groups": [
+            {
+                "name": "dram and external memory buffer dvfs 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": "set_parameter_from_group_max",
+                "parameter_name": "dram_extmb_dvfs_increase_temp",
+                "modifier": {
+                    "operator": "minus",
+                    "value": 10
+                }
+            },
+            {
+                "name": "set_parameter_from_group_max",
+                "parameter_name": "dram_extmb_dvfs_decrease_temp",
+                "modifier": {
+                    "operator": "minus",
+                    "value": 13
+                }
+            }
+        ]
+    },
+    {
+        "name": "Set external memory buffer DVFS parameter",
+        "groups": [
+            {
+                "name": "external memory buffer dvfs 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": "set_parameter_from_group_max",
+                "parameter_name": "extmb_dvfs_increase_temp",
+                "modifier": {
+                    "operator": "minus",
+                    "value": 7
+                }
+            },
+            {
+                "name": "set_parameter_from_group_max",
+                "parameter_name": "extmb_dvfs_decrease_temp",
+                "modifier": {
+                    "operator": "minus",
+                    "value": 10
+                }
+            }
+        ]
+    },
+    {
         // Collect group temperatures each iteration the repeating timer expires
         "name": "Fan control timer loop",
         "groups": [
@@ -627,7 +837,7 @@
                         "property": { "name": "Value" }
                     }
                 ],
-                "state": 63.0,
+                "state_parameter_name": "dram_dvfs_increase_temp",
                 "delta": 200
             },
             {
@@ -639,7 +849,7 @@
                         "property": { "name": "Value" }
                     }
                 ],
-                "state": 65.0,
+                "state_parameter_name": "pmic_dvfs_increase_temp",
                 "delta": 200
             },
             {
@@ -651,7 +861,7 @@
                         "property": { "name": "Value" }
                     }
                 ],
-                "state": 74.0,
+                "state_parameter_name": "intmb_dvfs_increase_temp",
                 "delta": 200
             },
             {
@@ -663,7 +873,7 @@
                         "property": { "name": "Value" }
                     }
                 ],
-                "state": 66.0,
+                "state_parameter_name": "dram_extmb_dvfs_increase_temp",
                 "delta": 200
             },
             {
@@ -675,7 +885,7 @@
                         "property": { "name": "Value" }
                     }
                 ],
-                "state": 60.0,
+                "state_parameter_name": "extmb_dvfs_increase_temp",
                 "delta": 200
             },
             {
@@ -795,7 +1005,7 @@
                         "property": { "name": "Value" }
                     }
                 ],
-                "state": 60.0,
+                "state_parameter_name": "dram_dvfs_decrease_temp",
                 "delta": 50
             },
             {
@@ -807,7 +1017,7 @@
                         "property": { "name": "Value" }
                     }
                 ],
-                "state": 62.0,
+                "state_parameter_name": "pmic_dvfs_decrease_temp",
                 "delta": 50
             },
             {
@@ -819,7 +1029,7 @@
                         "property": { "name": "Value" }
                     }
                 ],
-                "state": 71.0,
+                "state_parameter_name": "intmb_dvfs_decrease_temp",
                 "delta": 50
             },
             {
@@ -831,7 +1041,7 @@
                         "property": { "name": "Value" }
                     }
                 ],
-                "state": 63.0,
+                "state_parameter_name": "dram_extmb_dvfs_decrease_temp",
                 "delta": 50
             },
             {
@@ -843,7 +1053,7 @@
                         "property": { "name": "Value" }
                     }
                 ],
-                "state": 57.0,
+                "state_parameter_name": "extmb_dvfs_decrease_temp",
                 "delta": 50
             },
             {
diff --git a/control/config_files/p10bmc/ibm,rainier-1s4u/groups.json b/control/config_files/p10bmc/ibm,rainier-1s4u/groups.json
index 491aff2..be00918 100644
--- a/control/config_files/p10bmc/ibm,rainier-1s4u/groups.json
+++ b/control/config_files/p10bmc/ibm,rainier-1s4u/groups.json
@@ -159,6 +159,13 @@
         ]
     },
     {
+        "name": "dram dvfs temp",
+        "service": "org.open_power.OCC.Control",
+        "members": [
+            "/xyz/openbmc_project/sensors/temperature/dimm_dram_dvfs_temp"
+        ]
+    },
+    {
         "name": "pmic temps",
         "service": "org.open_power.OCC.Control",
         "members": [
@@ -181,6 +188,13 @@
         ]
     },
     {
+        "name": "pmic dvfs temp",
+        "service": "org.open_power.OCC.Control",
+        "members": [
+            "/xyz/openbmc_project/sensors/temperature/dimm_pmic_dvfs_temp"
+        ]
+    },
+    {
         "name": "internal memory buffer temps",
         "service": "org.open_power.OCC.Control",
         "members": [
@@ -203,6 +217,13 @@
         ]
     },
     {
+        "name": "internal memory buffer dvfs temp",
+        "service": "org.open_power.OCC.Control",
+        "members": [
+            "/xyz/openbmc_project/sensors/temperature/dimm_intmb_dvfs_temp"
+        ]
+    },
+    {
         // Repurposed as DRAM temperature sensors for 4U DDIMMs
         "name": "dram and external memory buffer temps",
         "service": "org.open_power.OCC.Control",
@@ -226,6 +247,13 @@
         ]
     },
     {
+        "name": "dram and external memory buffer dvfs temp",
+        "service": "org.open_power.OCC.Control",
+        "members": [
+            "/xyz/openbmc_project/sensors/temperature/dimm_dram_extmb_dvfs_temp"
+        ]
+    },
+    {
         // Repurposed as PMIC temperature sensors for 4U DDIMMs
         "name": "external memory buffer temps",
         "service": "org.open_power.OCC.Control",
@@ -249,6 +277,13 @@
         ]
     },
     {
+        "name": "external memory buffer dvfs temp",
+        "service": "org.open_power.OCC.Control",
+        "members": [
+            "/xyz/openbmc_project/sensors/temperature/dimm_extmb_dvfs_temp"
+        ]
+    },
+    {
         "name": "vdd vrm temps",
         "service": "org.open_power.OCC.Control",
         "members": [
diff --git a/control/config_files/p10bmc/ibm,rainier-4u/events.json b/control/config_files/p10bmc/ibm,rainier-4u/events.json
index ec2923f..66c9a23 100644
--- a/control/config_files/p10bmc/ibm,rainier-4u/events.json
+++ b/control/config_files/p10bmc/ibm,rainier-4u/events.json
@@ -686,6 +686,216 @@
         ]
     },
     {
+        "name": "Set DRAM DVFS parameter",
+        "groups": [
+            {
+                "name": "dram dvfs 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": "set_parameter_from_group_max",
+                "parameter_name": "dram_dvfs_increase_temp",
+                "modifier": {
+                    "operator": "minus",
+                    "value": 10
+                }
+            },
+            {
+                "name": "set_parameter_from_group_max",
+                "parameter_name": "dram_dvfs_decrease_temp",
+                "modifier": {
+                    "operator": "minus",
+                    "value": 13
+                }
+            }
+        ]
+    },
+    {
+        "name": "Set PMIC DVFS parameter",
+        "groups": [
+            {
+                "name": "pmic dvfs 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": "set_parameter_from_group_max",
+                "parameter_name": "pmic_dvfs_increase_temp",
+                "modifier": {
+                    "operator": "minus",
+                    "value": 10
+                }
+            },
+            {
+                "name": "set_parameter_from_group_max",
+                "parameter_name": "pmic_dvfs_decrease_temp",
+                "modifier": {
+                    "operator": "minus",
+                    "value": 13
+                }
+            }
+        ]
+    },
+    {
+        "name": "Set internal memory buffer DVFS parameter",
+        "groups": [
+            {
+                "name": "internal memory buffer dvfs 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": "set_parameter_from_group_max",
+                "parameter_name": "intmb_dvfs_increase_temp",
+                "modifier": {
+                    "operator": "minus",
+                    "value": 10
+                }
+            },
+            {
+                "name": "set_parameter_from_group_max",
+                "parameter_name": "intmb_dvfs_decrease_temp",
+                "modifier": {
+                    "operator": "minus",
+                    "value": 13
+                }
+            }
+        ]
+    },
+    {
+        "name": "Set DRAM and external memory buffer DVFS parameter",
+        "groups": [
+            {
+                "name": "dram and external memory buffer dvfs 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": "set_parameter_from_group_max",
+                "parameter_name": "dram_extmb_dvfs_increase_temp",
+                "modifier": {
+                    "operator": "minus",
+                    "value": 10
+                }
+            },
+            {
+                "name": "set_parameter_from_group_max",
+                "parameter_name": "dram_extmb_dvfs_decrease_temp",
+                "modifier": {
+                    "operator": "minus",
+                    "value": 13
+                }
+            }
+        ]
+    },
+    {
+        "name": "Set external memory buffer DVFS parameter",
+        "groups": [
+            {
+                "name": "external memory buffer dvfs 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": "set_parameter_from_group_max",
+                "parameter_name": "extmb_dvfs_increase_temp",
+                "modifier": {
+                    "operator": "minus",
+                    "value": 7
+                }
+            },
+            {
+                "name": "set_parameter_from_group_max",
+                "parameter_name": "extmb_dvfs_decrease_temp",
+                "modifier": {
+                    "operator": "minus",
+                    "value": 10
+                }
+            }
+        ]
+    },
+    {
         // Collect group temperatures each iteration the repeating timer expires
         "name": "Fan control timer loop",
         "groups": [
@@ -894,7 +1104,7 @@
                         "property": { "name": "Value" }
                     }
                 ],
-                "state": 63.0,
+                "state_parameter_name": "dram_dvfs_increase_temp",
                 "delta": 200
             },
             {
@@ -906,7 +1116,7 @@
                         "property": { "name": "Value" }
                     }
                 ],
-                "state": 65.0,
+                "state_parameter_name": "pmic_dvfs_increase_temp",
                 "delta": 200
             },
             {
@@ -918,8 +1128,8 @@
                         "property": { "name": "Value" }
                     }
                 ],
-                "state": 74.0,
-                "delta": 200
+                "state_parameter_name": "intmb_dvfs_increase_temp",
+                "delta": 100
             },
             {
                 "name": "set_net_increase_target",
@@ -930,7 +1140,7 @@
                         "property": { "name": "Value" }
                     }
                 ],
-                "state": 66.0,
+                "state_parameter_name": "dram_extmb_dvfs_increase_temp",
                 "delta": 200
             },
             {
@@ -942,7 +1152,7 @@
                         "property": { "name": "Value" }
                     }
                 ],
-                "state": 60.0,
+                "state_parameter_name": "extmb_dvfs_increase_temp",
                 "delta": 200
             },
             {
@@ -1110,7 +1320,7 @@
                         "property": { "name": "Value" }
                     }
                 ],
-                "state": 60.0,
+                "state_parameter_name": "dram_dvfs_decrease_temp",
                 "delta": 50
             },
             {
@@ -1122,7 +1332,7 @@
                         "property": { "name": "Value" }
                     }
                 ],
-                "state": 62.0,
+                "state_parameter_name": "pmic_dvfs_decrease_temp",
                 "delta": 50
             },
             {
@@ -1134,7 +1344,7 @@
                         "property": { "name": "Value" }
                     }
                 ],
-                "state": 71.0,
+                "state_parameter_name": "intmb_dvfs_decrease_temp",
                 "delta": 50
             },
             {
@@ -1146,7 +1356,7 @@
                         "property": { "name": "Value" }
                     }
                 ],
-                "state": 63.0,
+                "state_parameter_name": "dram_extmb_dvfs_decrease_temp",
                 "delta": 50
             },
             {
@@ -1158,7 +1368,7 @@
                         "property": { "name": "Value" }
                     }
                 ],
-                "state": 57.0,
+                "state_parameter_name": "extmb_dvfs_decrease_temp",
                 "delta": 50
             },
             {
diff --git a/control/config_files/p10bmc/ibm,rainier-4u/groups.json b/control/config_files/p10bmc/ibm,rainier-4u/groups.json
index 3df014d..28549a2 100644
--- a/control/config_files/p10bmc/ibm,rainier-4u/groups.json
+++ b/control/config_files/p10bmc/ibm,rainier-4u/groups.json
@@ -275,6 +275,13 @@
         ]
     },
     {
+        "name": "dram dvfs temp",
+        "service": "org.open_power.OCC.Control",
+        "members": [
+            "/xyz/openbmc_project/sensors/temperature/dimm_dram_dvfs_temp"
+        ]
+    },
+    {
         "name": "pmic temps",
         "service": "org.open_power.OCC.Control",
         "members": [
@@ -313,6 +320,13 @@
         ]
     },
     {
+        "name": "pmic dvfs temp",
+        "service": "org.open_power.OCC.Control",
+        "members": [
+            "/xyz/openbmc_project/sensors/temperature/dimm_pmic_dvfs_temp"
+        ]
+    },
+    {
         "name": "internal memory buffer temps",
         "service": "org.open_power.OCC.Control",
         "members": [
@@ -351,6 +365,13 @@
         ]
     },
     {
+        "name": "internal memory buffer dvfs temp",
+        "service": "org.open_power.OCC.Control",
+        "members": [
+            "/xyz/openbmc_project/sensors/temperature/dimm_intmb_dvfs_temp"
+        ]
+    },
+    {
         // Repurposed as DRAM temperature sensors for 4U DDIMMs
         "name": "dram and external memory buffer temps",
         "service": "org.open_power.OCC.Control",
@@ -390,6 +411,13 @@
         ]
     },
     {
+        "name": "dram and external memory buffer dvfs temp",
+        "service": "org.open_power.OCC.Control",
+        "members": [
+            "/xyz/openbmc_project/sensors/temperature/dimm_dram_extmb_dvfs_temp"
+        ]
+    },
+    {
         // Repurposed as PMIC temperature sensors for 4U DDIMMs
         "name": "external memory buffer temps",
         "service": "org.open_power.OCC.Control",
@@ -429,6 +457,13 @@
         ]
     },
     {
+        "name": "external memory buffer dvfs temp",
+        "service": "org.open_power.OCC.Control",
+        "members": [
+            "/xyz/openbmc_project/sensors/temperature/dimm_extmb_dvfs_temp"
+        ]
+    },
+    {
         "name": "vdd vrm temps",
         "service": "org.open_power.OCC.Control",
         "members": [