Factor PS derating into power cap limit validation

When the BMC sends a system power cap to the host, the host
validates it is in a certain range or it will reject it. So,
the BMC also checks the range before sending it at all.

This range comes out of the MRW (machine readable workbook)
XML, and is stored as output power.  The user, however,
inputs the power cap value as input power, and so the range
the BMC code checks it against must also be in input power.

To support this, the script that pulls the power cap min
and max values out of the MRW for use in settings validation
will now convert those output power values into input power
by applying the power supply derating factor.

Resolves openbmc/openbmc#2944

Tested: Check that the power cap range that the settings manager
        uses is now the input power versions.

Change-Id: Id5c5851d081ad706fda73054b49e67a93d57f76e
Signed-off-by: Matt Spinler <spinler@us.ibm.com>
diff --git a/meta-ibm/meta-witherspoon/recipes-phosphor/settings/phosphor-settings-read-settings-mrw-native.bbappend b/meta-ibm/meta-witherspoon/recipes-phosphor/settings/phosphor-settings-read-settings-mrw-native.bbappend
index 72d991c..aa8149c 100644
--- a/meta-ibm/meta-witherspoon/recipes-phosphor/settings/phosphor-settings-read-settings-mrw-native.bbappend
+++ b/meta-ibm/meta-witherspoon/recipes-phosphor/settings/phosphor-settings-read-settings-mrw-native.bbappend
@@ -1 +1,2 @@
 FILESEXTRAPATHS_prepend := "${THISDIR}/${PN}:"
+MRW_EXPRESSION_VARS = "-v PS_DERATING=${POWER_SUPPLY_DERATING_FACTOR}"
diff --git a/meta-ibm/meta-witherspoon/recipes-phosphor/settings/phosphor-settings-read-settings-mrw-native/mrw-override-settings.yaml b/meta-ibm/meta-witherspoon/recipes-phosphor/settings/phosphor-settings-read-settings-mrw-native/mrw-override-settings.yaml
index 0bfd515..c823896 100644
--- a/meta-ibm/meta-witherspoon/recipes-phosphor/settings/phosphor-settings-read-settings-mrw-native/mrw-override-settings.yaml
+++ b/meta-ibm/meta-witherspoon/recipes-phosphor/settings/phosphor-settings-read-settings-mrw-native/mrw-override-settings.yaml
@@ -5,7 +5,7 @@
               Default: 0
               Validation:
                   Type: "range"
-                  Validator: "MRW_OPEN_POWER_SOFT_MIN_PCAP_WATTS..MRW_OPEN_POWER_N_PLUS_ONE_BULK_POWER_LIMIT_WATTS"
+                  Validator: "[[MRW_OPEN_POWER_SOFT_MIN_PCAP_WATTS/(PS_DERATING/100)]]..[[MRW_OPEN_POWER_N_PLUS_ONE_BULK_POWER_LIMIT_WATTS/(PS_DERATING/100)]]"
                   Unit: "Watts"
           PowerCapEnable:
                Default: 'false'