diff --git a/drivers/crypto/ccp/Makefile b/drivers/crypto/ccp/Makefile index 2bed3e926f80..23717a39621d 100644 --- a/drivers/crypto/ccp/Makefile +++ b/drivers/crypto/ccp/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_CRYPTO_DEV_CCP_DD) += ccp.o -ccp-objs := sp-dev.o sp-platform.o +ccp-objs := sp-dev.o sp-platform.o \ + hygon/sp-dev.o ccp-$(CONFIG_CRYPTO_DEV_SP_CCP) += ccp-dev.o \ ccp-ops.o \ ccp-dev-v3.o \ @@ -18,8 +19,7 @@ ccp-$(CONFIG_CRYPTO_DEV_SP_PSP) += psp-dev.o \ hygon/psp-dev.o \ hygon/csv-dev.o \ hygon/ring-buffer.o \ - hygon/vpsp.o \ - hygon/sp-dev.o + hygon/vpsp.o ccp-$(CONFIG_TDM_DEV_HYGON) += hygon/tdm-dev.o diff --git a/drivers/crypto/ccp/hygon/psp-dev.h b/drivers/crypto/ccp/hygon/psp-dev.h index 57dca0b73157..f60a112881be 100644 --- a/drivers/crypto/ccp/hygon/psp-dev.h +++ b/drivers/crypto/ccp/hygon/psp-dev.h @@ -13,7 +13,6 @@ #include #include #include -#include #include "sp-dev.h" @@ -72,10 +71,4 @@ int fixup_hygon_psp_caps(struct psp_device *psp); int sp_request_hygon_psp_irq(struct sp_device *sp, irq_handler_t handler, const char *name, void *data); -#ifdef CONFIG_PM_SLEEP -void hygon_psp_dev_freeze(struct sp_device *sp); -void hygon_psp_dev_thaw(struct sp_device *sp); -void hygon_psp_dev_restore(struct sp_device *sp); -#endif - #endif /* __CCP_HYGON_PSP_DEV_H__ */ diff --git a/drivers/crypto/ccp/hygon/sp-dev.c b/drivers/crypto/ccp/hygon/sp-dev.c index 727ffd16421e..86d666b31f37 100644 --- a/drivers/crypto/ccp/hygon/sp-dev.c +++ b/drivers/crypto/ccp/hygon/sp-dev.c @@ -36,8 +36,10 @@ int hygon_sp_freeze(struct sp_device *sp) if (sp->dev_vdata->ccp_vdata) ccp_dev_suspend(sp); +#ifdef CONFIG_CRYPTO_DEV_SP_PSP if (sp->dev_vdata->psp_vdata) hygon_psp_dev_freeze(sp); +#endif return 0; } @@ -47,8 +49,10 @@ int hygon_sp_thaw(struct sp_device *sp) if (sp->dev_vdata->ccp_vdata) ccp_dev_resume(sp); +#ifdef CONFIG_CRYPTO_DEV_SP_PSP if (sp->dev_vdata->psp_vdata) hygon_psp_dev_thaw(sp); +#endif return 0; } @@ -66,8 +70,10 @@ int hygon_sp_restore(struct sp_device *sp) if (sp->dev_vdata->ccp_vdata) ccp_dev_resume(sp); +#ifdef CONFIG_CRYPTO_DEV_SP_PSP if (sp->dev_vdata->psp_vdata) hygon_psp_dev_restore(sp); +#endif return 0; } diff --git a/drivers/crypto/ccp/hygon/sp-dev.h b/drivers/crypto/ccp/hygon/sp-dev.h index b11c2f225e10..973fdf651878 100644 --- a/drivers/crypto/ccp/hygon/sp-dev.h +++ b/drivers/crypto/ccp/hygon/sp-dev.h @@ -12,10 +12,10 @@ #include #include +#include #include "../ccp-dev.h" #include "../sp-dev.h" -#include "psp-dev.h" #ifdef CONFIG_X86_64 static inline bool is_vendor_hygon(void) @@ -39,6 +39,12 @@ int hygon_sp_restore(struct sp_device *sp); void hygon_set_pm_cb(struct pci_driver *drv); -#endif +#ifdef CONFIG_CRYPTO_DEV_SP_PSP +void hygon_psp_dev_freeze(struct sp_device *sp); +void hygon_psp_dev_thaw(struct sp_device *sp); +void hygon_psp_dev_restore(struct sp_device *sp); +#endif /* CONFIG_CRYPTO_DEV_SP_PSP */ + +#endif /* CONFIG_PM_SLEEP */ #endif /* __CCP_HYGON_SP_DEV_H__ */ diff --git a/include/linux/psp-hygon.h b/include/linux/psp-hygon.h index 0d5163668813..bad8510c9f82 100644 --- a/include/linux/psp-hygon.h +++ b/include/linux/psp-hygon.h @@ -511,6 +511,19 @@ struct vpsp_context { int psp_do_cmd(int cmd, void *data, int *psp_ret); +typedef int (*p2c_notifier_t)(uint32_t id, uint64_t data); + +#ifdef CONFIG_HYGON_PSP2CPU_CMD +int psp_register_cmd_notifier(uint32_t cmd_id, p2c_notifier_t notifier); +int psp_unregister_cmd_notifier(uint32_t cmd_id, p2c_notifier_t notifier); +#else /* !CONFIG_HYGON_PSP2CPU_CMD */ +static int __maybe_unused +psp_register_cmd_notifier(uint32_t cmd_id, p2c_notifier_t notifier) { return -ENODEV; } + +static int __maybe_unused +psp_unregister_cmd_notifier(uint32_t cmd_id, p2c_notifier_t notifier) { return -ENODEV; } +#endif /* CONFIG_HYGON_PSP2CPU_CMD */ + int csv_ring_buffer_queue_init(void); int csv_ring_buffer_queue_free(void); int csv_fill_cmd_queue(int prio, int cmd, void *data, uint16_t flags); @@ -587,18 +600,4 @@ static inline int csv_get_extension_info(void *buf, size_t *size) { return -ENOD #endif /* CONFIG_CRYPTO_DEV_SP_PSP */ -typedef int (*p2c_notifier_t)(uint32_t id, uint64_t data); - -#ifdef CONFIG_HYGON_PSP2CPU_CMD - -int psp_register_cmd_notifier(uint32_t cmd_id, p2c_notifier_t notifier); -int psp_unregister_cmd_notifier(uint32_t cmd_id, p2c_notifier_t notifier); - -#else /* !CONFIG_HYGON_PSP2CPU_CMD */ - -int psp_register_cmd_notifier(uint32_t cmd_id, p2c_notifier_t notifier) { return -ENODEV; } -int psp_unregister_cmd_notifier(uint32_t cmd_id, p2c_notifier_t notifier) { return -ENODEV; } - -#endif /* CONFIG_HYGON_PSP2CPU_CMD */ - #endif /* __PSP_HYGON_H__ */