Commit 91576aca authored by Srinivas Pandruvada's avatar Srinivas Pandruvada Committed by Hans de Goede

platform/x86: ISST: Add suspend/resume callbacks

To support S3/S4 with TPMI interface add suspend/resume callbacks.
Here HW state is stored in suspend callback and restored during
resume callback.

The hardware state which needs to be stored/restored:
- CLOS configuration
- CLOS Association
- SST-CP enable/disable status
- SST-PP perf level setting
Signed-off-by: default avatarSrinivas Pandruvada <srinivas.pandruvada@linux.intel.com>
Suggested-by: default avatarHans de Goede <hdegoede@redhat.com>
Reviewed-by: default avatarZhang Rui <rui.zhang@intel.com>
Tested-by: default avatarPragya Tanwar <pragya.tanwar@intel.com>
Link: https://lore.kernel.org/r/20230308070642.1727167-9-srinivas.pandruvada@linux.intel.comReviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
parent f8e0077a
...@@ -34,6 +34,22 @@ static void intel_sst_remove(struct auxiliary_device *auxdev) ...@@ -34,6 +34,22 @@ static void intel_sst_remove(struct auxiliary_device *auxdev)
tpmi_sst_exit(); tpmi_sst_exit();
} }
static int intel_sst_suspend(struct device *dev)
{
tpmi_sst_dev_suspend(to_auxiliary_dev(dev));
return 0;
}
static int intel_sst_resume(struct device *dev)
{
tpmi_sst_dev_resume(to_auxiliary_dev(dev));
return 0;
}
static DEFINE_SIMPLE_DEV_PM_OPS(intel_sst_pm, intel_sst_suspend, intel_sst_resume);
static const struct auxiliary_device_id intel_sst_id_table[] = { static const struct auxiliary_device_id intel_sst_id_table[] = {
{ .name = "intel_vsec.tpmi-sst" }, { .name = "intel_vsec.tpmi-sst" },
{} {}
...@@ -44,6 +60,9 @@ static struct auxiliary_driver intel_sst_aux_driver = { ...@@ -44,6 +60,9 @@ static struct auxiliary_driver intel_sst_aux_driver = {
.id_table = intel_sst_id_table, .id_table = intel_sst_id_table,
.remove = intel_sst_remove, .remove = intel_sst_remove,
.probe = intel_sst_probe, .probe = intel_sst_probe,
.driver = {
.pm = pm_sleep_ptr(&intel_sst_pm),
},
}; };
module_auxiliary_driver(intel_sst_aux_driver); module_auxiliary_driver(intel_sst_aux_driver);
......
...@@ -229,6 +229,10 @@ struct perf_level { ...@@ -229,6 +229,10 @@ struct perf_level {
* @status_offset: Store the status offset for each PP-level * @status_offset: Store the status offset for each PP-level
* @sst_base: Mapped SST base IO memory * @sst_base: Mapped SST base IO memory
* @auxdev: Auxiliary device instance enumerated this instance * @auxdev: Auxiliary device instance enumerated this instance
* @saved_sst_cp_control: Save SST-CP control configuration to store restore for suspend/resume
* @saved_clos_configs: Save SST-CP CLOS configuration to store restore for suspend/resume
* @saved_clos_assocs: Save SST-CP CLOS association to store restore for suspend/resume
* @saved_pp_control: Save SST-PP control information to store restore for suspend/resume
* *
* This structure is used store complete SST information for a power_domain. This information * This structure is used store complete SST information for a power_domain. This information
* is used to read/write request for any SST IOCTL. Each physical CPU package can have multiple * is used to read/write request for any SST IOCTL. Each physical CPU package can have multiple
...@@ -250,6 +254,10 @@ struct tpmi_per_power_domain_info { ...@@ -250,6 +254,10 @@ struct tpmi_per_power_domain_info {
struct pp_status_offset status_offset; struct pp_status_offset status_offset;
void __iomem *sst_base; void __iomem *sst_base;
struct auxiliary_device *auxdev; struct auxiliary_device *auxdev;
u64 saved_sst_cp_control;
u64 saved_clos_configs[4];
u64 saved_clos_assocs[4];
u64 saved_pp_control;
}; };
/** /**
...@@ -1333,6 +1341,47 @@ void tpmi_sst_dev_remove(struct auxiliary_device *auxdev) ...@@ -1333,6 +1341,47 @@ void tpmi_sst_dev_remove(struct auxiliary_device *auxdev)
} }
EXPORT_SYMBOL_NS_GPL(tpmi_sst_dev_remove, INTEL_TPMI_SST); EXPORT_SYMBOL_NS_GPL(tpmi_sst_dev_remove, INTEL_TPMI_SST);
void tpmi_sst_dev_suspend(struct auxiliary_device *auxdev)
{
struct tpmi_sst_struct *tpmi_sst = auxiliary_get_drvdata(auxdev);
struct tpmi_per_power_domain_info *power_domain_info = tpmi_sst->power_domain_info;
void __iomem *cp_base;
cp_base = power_domain_info->sst_base + power_domain_info->sst_header.cp_offset;
power_domain_info->saved_sst_cp_control = readq(cp_base + SST_CP_CONTROL_OFFSET);
memcpy_fromio(power_domain_info->saved_clos_configs, cp_base + SST_CLOS_CONFIG_0_OFFSET,
sizeof(power_domain_info->saved_clos_configs));
memcpy_fromio(power_domain_info->saved_clos_assocs, cp_base + SST_CLOS_ASSOC_0_OFFSET,
sizeof(power_domain_info->saved_clos_assocs));
power_domain_info->saved_pp_control = readq(power_domain_info->sst_base +
power_domain_info->sst_header.pp_offset +
SST_PP_CONTROL_OFFSET);
}
EXPORT_SYMBOL_NS_GPL(tpmi_sst_dev_suspend, INTEL_TPMI_SST);
void tpmi_sst_dev_resume(struct auxiliary_device *auxdev)
{
struct tpmi_sst_struct *tpmi_sst = auxiliary_get_drvdata(auxdev);
struct tpmi_per_power_domain_info *power_domain_info = tpmi_sst->power_domain_info;
void __iomem *cp_base;
cp_base = power_domain_info->sst_base + power_domain_info->sst_header.cp_offset;
writeq(power_domain_info->saved_sst_cp_control, cp_base + SST_CP_CONTROL_OFFSET);
memcpy_toio(cp_base + SST_CLOS_CONFIG_0_OFFSET, power_domain_info->saved_clos_configs,
sizeof(power_domain_info->saved_clos_configs));
memcpy_toio(cp_base + SST_CLOS_ASSOC_0_OFFSET, power_domain_info->saved_clos_assocs,
sizeof(power_domain_info->saved_clos_assocs));
writeq(power_domain_info->saved_pp_control, power_domain_info->sst_base +
power_domain_info->sst_header.pp_offset + SST_PP_CONTROL_OFFSET);
}
EXPORT_SYMBOL_NS_GPL(tpmi_sst_dev_resume, INTEL_TPMI_SST);
#define ISST_TPMI_API_VERSION 0x02 #define ISST_TPMI_API_VERSION 0x02
int tpmi_sst_init(void) int tpmi_sst_init(void)
......
...@@ -13,4 +13,6 @@ int tpmi_sst_init(void); ...@@ -13,4 +13,6 @@ int tpmi_sst_init(void);
void tpmi_sst_exit(void); void tpmi_sst_exit(void);
int tpmi_sst_dev_add(struct auxiliary_device *auxdev); int tpmi_sst_dev_add(struct auxiliary_device *auxdev);
void tpmi_sst_dev_remove(struct auxiliary_device *auxdev); void tpmi_sst_dev_remove(struct auxiliary_device *auxdev);
void tpmi_sst_dev_suspend(struct auxiliary_device *auxdev);
void tpmi_sst_dev_resume(struct auxiliary_device *auxdev);
#endif #endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment