|
|
|
@ -137,7 +137,7 @@ static bool crb_wait_for_reg_32(u32 __iomem *reg, u32 mask, u32 value, |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* crb_go_idle - request tpm crb device to go the idle state |
|
|
|
|
* __crb_go_idle - request tpm crb device to go the idle state |
|
|
|
|
* |
|
|
|
|
* @dev: crb device |
|
|
|
|
* @priv: crb private data |
|
|
|
@ -151,7 +151,7 @@ static bool crb_wait_for_reg_32(u32 __iomem *reg, u32 mask, u32 value, |
|
|
|
|
* |
|
|
|
|
* Return: 0 always |
|
|
|
|
*/ |
|
|
|
|
static int crb_go_idle(struct device *dev, struct crb_priv *priv) |
|
|
|
|
static int __crb_go_idle(struct device *dev, struct crb_priv *priv) |
|
|
|
|
{ |
|
|
|
|
if ((priv->flags & CRB_FL_ACPI_START) || |
|
|
|
|
(priv->flags & CRB_FL_CRB_SMC_START)) |
|
|
|
@ -166,11 +166,20 @@ static int crb_go_idle(struct device *dev, struct crb_priv *priv) |
|
|
|
|
dev_warn(dev, "goIdle timed out\n"); |
|
|
|
|
return -ETIME; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int crb_go_idle(struct tpm_chip *chip) |
|
|
|
|
{ |
|
|
|
|
struct device *dev = &chip->dev; |
|
|
|
|
struct crb_priv *priv = dev_get_drvdata(dev); |
|
|
|
|
|
|
|
|
|
return __crb_go_idle(dev, priv); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* crb_cmd_ready - request tpm crb device to enter ready state |
|
|
|
|
* __crb_cmd_ready - request tpm crb device to enter ready state |
|
|
|
|
* |
|
|
|
|
* @dev: crb device |
|
|
|
|
* @priv: crb private data |
|
|
|
@ -183,7 +192,7 @@ static int crb_go_idle(struct device *dev, struct crb_priv *priv) |
|
|
|
|
* |
|
|
|
|
* Return: 0 on success -ETIME on timeout; |
|
|
|
|
*/ |
|
|
|
|
static int crb_cmd_ready(struct device *dev, struct crb_priv *priv) |
|
|
|
|
static int __crb_cmd_ready(struct device *dev, struct crb_priv *priv) |
|
|
|
|
{ |
|
|
|
|
if ((priv->flags & CRB_FL_ACPI_START) || |
|
|
|
|
(priv->flags & CRB_FL_CRB_SMC_START)) |
|
|
|
@ -201,6 +210,14 @@ static int crb_cmd_ready(struct device *dev, struct crb_priv *priv) |
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int crb_cmd_ready(struct tpm_chip *chip) |
|
|
|
|
{ |
|
|
|
|
struct device *dev = &chip->dev; |
|
|
|
|
struct crb_priv *priv = dev_get_drvdata(dev); |
|
|
|
|
|
|
|
|
|
return __crb_cmd_ready(dev, priv); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int __crb_request_locality(struct device *dev, |
|
|
|
|
struct crb_priv *priv, int loc) |
|
|
|
|
{ |
|
|
|
@ -393,6 +410,8 @@ static const struct tpm_class_ops tpm_crb = { |
|
|
|
|
.send = crb_send, |
|
|
|
|
.cancel = crb_cancel, |
|
|
|
|
.req_canceled = crb_req_canceled, |
|
|
|
|
.go_idle = crb_go_idle, |
|
|
|
|
.cmd_ready = crb_cmd_ready, |
|
|
|
|
.request_locality = crb_request_locality, |
|
|
|
|
.relinquish_locality = crb_relinquish_locality, |
|
|
|
|
.req_complete_mask = CRB_DRV_STS_COMPLETE, |
|
|
|
@ -508,7 +527,7 @@ static int crb_map_io(struct acpi_device *device, struct crb_priv *priv, |
|
|
|
|
* PTT HW bug w/a: wake up the device to access |
|
|
|
|
* possibly not retained registers. |
|
|
|
|
*/ |
|
|
|
|
ret = crb_cmd_ready(dev, priv); |
|
|
|
|
ret = __crb_cmd_ready(dev, priv); |
|
|
|
|
if (ret) |
|
|
|
|
return ret; |
|
|
|
|
|
|
|
|
@ -553,7 +572,7 @@ out: |
|
|
|
|
if (!ret) |
|
|
|
|
priv->cmd_size = cmd_size; |
|
|
|
|
|
|
|
|
|
crb_go_idle(dev, priv); |
|
|
|
|
__crb_go_idle(dev, priv); |
|
|
|
|
|
|
|
|
|
__crb_relinquish_locality(dev, priv, 0); |
|
|
|
|
|
|
|
|
@ -624,32 +643,7 @@ static int crb_acpi_add(struct acpi_device *device) |
|
|
|
|
chip->acpi_dev_handle = device->handle; |
|
|
|
|
chip->flags = TPM_CHIP_FLAG_TPM2; |
|
|
|
|
|
|
|
|
|
rc = __crb_request_locality(dev, priv, 0); |
|
|
|
|
if (rc) |
|
|
|
|
return rc; |
|
|
|
|
|
|
|
|
|
rc = crb_cmd_ready(dev, priv); |
|
|
|
|
if (rc) |
|
|
|
|
goto out; |
|
|
|
|
|
|
|
|
|
pm_runtime_get_noresume(dev); |
|
|
|
|
pm_runtime_set_active(dev); |
|
|
|
|
pm_runtime_enable(dev); |
|
|
|
|
|
|
|
|
|
rc = tpm_chip_register(chip); |
|
|
|
|
if (rc) { |
|
|
|
|
crb_go_idle(dev, priv); |
|
|
|
|
pm_runtime_put_noidle(dev); |
|
|
|
|
pm_runtime_disable(dev); |
|
|
|
|
goto out; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
pm_runtime_put_sync(dev); |
|
|
|
|
|
|
|
|
|
out: |
|
|
|
|
__crb_relinquish_locality(dev, priv, 0); |
|
|
|
|
|
|
|
|
|
return rc; |
|
|
|
|
return tpm_chip_register(chip); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int crb_acpi_remove(struct acpi_device *device) |
|
|
|
@ -659,52 +653,11 @@ static int crb_acpi_remove(struct acpi_device *device) |
|
|
|
|
|
|
|
|
|
tpm_chip_unregister(chip); |
|
|
|
|
|
|
|
|
|
pm_runtime_disable(dev); |
|
|
|
|
|
|
|
|
|
return 0; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int __maybe_unused crb_pm_runtime_suspend(struct device *dev) |
|
|
|
|
{ |
|
|
|
|
struct tpm_chip *chip = dev_get_drvdata(dev); |
|
|
|
|
struct crb_priv *priv = dev_get_drvdata(&chip->dev); |
|
|
|
|
|
|
|
|
|
return crb_go_idle(dev, priv); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int __maybe_unused crb_pm_runtime_resume(struct device *dev) |
|
|
|
|
{ |
|
|
|
|
struct tpm_chip *chip = dev_get_drvdata(dev); |
|
|
|
|
struct crb_priv *priv = dev_get_drvdata(&chip->dev); |
|
|
|
|
|
|
|
|
|
return crb_cmd_ready(dev, priv); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int __maybe_unused crb_pm_suspend(struct device *dev) |
|
|
|
|
{ |
|
|
|
|
int ret; |
|
|
|
|
|
|
|
|
|
ret = tpm_pm_suspend(dev); |
|
|
|
|
if (ret) |
|
|
|
|
return ret; |
|
|
|
|
|
|
|
|
|
return crb_pm_runtime_suspend(dev); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static int __maybe_unused crb_pm_resume(struct device *dev) |
|
|
|
|
{ |
|
|
|
|
int ret; |
|
|
|
|
|
|
|
|
|
ret = crb_pm_runtime_resume(dev); |
|
|
|
|
if (ret) |
|
|
|
|
return ret; |
|
|
|
|
|
|
|
|
|
return tpm_pm_resume(dev); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
static const struct dev_pm_ops crb_pm = { |
|
|
|
|
SET_SYSTEM_SLEEP_PM_OPS(crb_pm_suspend, crb_pm_resume) |
|
|
|
|
SET_RUNTIME_PM_OPS(crb_pm_runtime_suspend, crb_pm_runtime_resume, NULL) |
|
|
|
|
SET_SYSTEM_SLEEP_PM_OPS(tpm_pm_suspend, tpm_pm_resume) |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
static const struct acpi_device_id crb_device_ids[] = { |
|
|
|
|