char: tpm: cr50: Set TPM_FIRMWARE_POWER_MANAGED based on device property
[linux-2.6-microblaze.git] / drivers / char / tpm / tpm_tis_i2c_cr50.c
index c892781..f6c0aff 100644 (file)
@@ -628,6 +628,19 @@ static bool tpm_cr50_i2c_req_canceled(struct tpm_chip *chip, u8 status)
        return status == TPM_STS_COMMAND_READY;
 }
 
+static bool tpm_cr50_i2c_is_firmware_power_managed(struct device *dev)
+{
+       u8 val;
+       int ret;
+
+       /* This flag should default true when the device property is not present */
+       ret = device_property_read_u8(dev, "firmware-power-managed", &val);
+       if (ret)
+               return true;
+
+       return val;
+}
+
 static const struct tpm_class_ops cr50_i2c = {
        .flags = TPM_OPS_AUTO_STARTUP,
        .status = &tpm_cr50_i2c_tis_status,
@@ -686,7 +699,8 @@ static int tpm_cr50_i2c_probe(struct i2c_client *client)
 
        /* cr50 is a TPM 2.0 chip */
        chip->flags |= TPM_CHIP_FLAG_TPM2;
-       chip->flags |= TPM_CHIP_FLAG_FIRMWARE_POWER_MANAGED;
+       if (tpm_cr50_i2c_is_firmware_power_managed(dev))
+               chip->flags |= TPM_CHIP_FLAG_FIRMWARE_POWER_MANAGED;
 
        /* Default timeouts */
        chip->timeout_a = msecs_to_jiffies(TIS_SHORT_TIMEOUT);