[PATCH 07/11] crypto: ccp - add Hygon CCP device IDs and vdata
From: Depei Yang
Date: Wed Nov 25 2026 - 02:47:17 EST
Hygon CCP devices use the v5 programming model. Add the PCI IDs and a
minimal vdata table. The get_caps callback is a placeholder that
advertises only the SM engines; a later patch replaces it with
register-based detection.
Reviewed-by: Shan Chen <chenshan@xxxxxxxx>
Tested-by: Yongwei Xu <xuyongwei@xxxxxxxx>
Signed-off-by: Depei Yang <yangdepei@xxxxxxxx>
---
drivers/crypto/ccp/ccp-dev-v5.c | 32 ++++++++++++++++++++++++++++++
drivers/crypto/ccp/ccp-dev.h | 2 ++
drivers/crypto/ccp/sp-pci.c | 35 +++++++++++++++++++++++++++++++++
3 files changed, 69 insertions(+)
diff --git a/drivers/crypto/ccp/ccp-dev-v5.c b/drivers/crypto/ccp/ccp-dev-v5.c
index 9b1593703ec5..34832b830785 100644
--- a/drivers/crypto/ccp/ccp-dev-v5.c
+++ b/drivers/crypto/ccp/ccp-dev-v5.c
@@ -1198,3 +1198,35 @@ const struct ccp_vdata ccpv5b = {
.rsamax = CCP5_RSA_MAX_WIDTH,
.get_caps = ccp5_get_caps,
};
+
+/*
+ * Hygon CCP is a v5 derivative with the SM3/SM4 engines added. It
+ * uses the same queue, LSB and interrupt model as the AMD v5 CCP.
+ *
+ * TODO: derive the legacy engines from the Hygon engine register once
+ * its layout is confirmed. Until then only the engines that cannot be
+ * detected from a register are advertised.
+ */
+static void ccp5_hygon_get_caps(struct ccp_device *ccp)
+{
+ ccp->caps.engines = CCP_CAPS_SM3 | CCP_CAPS_SM4 | CCP_CAPS_SM4_CTR;
+}
+
+const struct ccp_vdata ccpv5a_hygon = {
+ .version = CCP_VERSION(5, 0),
+ .setup = ccp5_config,
+ .perform = &ccp5_actions,
+ .offset = 0x0,
+ .rsamax = CCP5_RSA_MAX_WIDTH,
+ .get_caps = ccp5_hygon_get_caps,
+};
+
+const struct ccp_vdata ccpv5b_hygon = {
+ .version = CCP_VERSION(5, 0),
+ .dma_chan_attr = DMA_PRIVATE,
+ .setup = ccp5other_config,
+ .perform = &ccp5_actions,
+ .offset = 0x0,
+ .rsamax = CCP5_RSA_MAX_WIDTH,
+ .get_caps = ccp5_hygon_get_caps,
+};
diff --git a/drivers/crypto/ccp/ccp-dev.h b/drivers/crypto/ccp/ccp-dev.h
index 813a1b20c3c2..f499e6868d82 100644
--- a/drivers/crypto/ccp/ccp-dev.h
+++ b/drivers/crypto/ccp/ccp-dev.h
@@ -694,5 +694,7 @@ extern const struct ccp_vdata ccpv3_platform;
extern const struct ccp_vdata ccpv3;
extern const struct ccp_vdata ccpv5a;
extern const struct ccp_vdata ccpv5b;
+extern const struct ccp_vdata ccpv5a_hygon;
+extern const struct ccp_vdata ccpv5b_hygon;
#endif
diff --git a/drivers/crypto/ccp/sp-pci.c b/drivers/crypto/ccp/sp-pci.c
index ede6ff9ad0c2..dafd934836dc 100644
--- a/drivers/crypto/ccp/sp-pci.c
+++ b/drivers/crypto/ccp/sp-pci.c
@@ -551,6 +551,33 @@ static const struct sp_dev_vdata dev_vdata[] = {
},
};
+
+/*
+ * Hygon secure processor devices. They are CCP v5 derivatives, so
+ * they reuse the v5 CCP programming model. The PSP/CSV side is not
+ * described here.
+ */
+static const struct sp_dev_vdata hygon_dev_vdata[] = {
+ { /* 0 */
+ .bar = 2,
+#ifdef CONFIG_CRYPTO_DEV_SP_CCP
+ .ccp_vdata = &ccpv5a_hygon,
+#endif
+ },
+ { /* 1 */
+ .bar = 2,
+#ifdef CONFIG_CRYPTO_DEV_SP_CCP
+ .ccp_vdata = &ccpv5b_hygon,
+#endif
+ },
+ { /* 2 */
+ .bar = 2,
+#ifdef CONFIG_CRYPTO_DEV_SP_CCP
+ .ccp_vdata = &ccpv5a_hygon,
+#endif
+ },
+};
+
static const struct pci_device_id sp_pci_table[] = {
{ PCI_VDEVICE(AMD, 0x1537), .driver_data = (kernel_ulong_t)&dev_vdata[0] },
{ PCI_VDEVICE(AMD, 0x1456), .driver_data = (kernel_ulong_t)&dev_vdata[1] },
@@ -565,6 +592,14 @@ static const struct pci_device_id sp_pci_table[] = {
{ PCI_VDEVICE(AMD, 0x156E), .driver_data = (kernel_ulong_t)&dev_vdata[8] },
{ PCI_VDEVICE(AMD, 0x17D8), .driver_data = (kernel_ulong_t)&dev_vdata[8] },
{ PCI_VDEVICE(AMD, 0x115A), .driver_data = (kernel_ulong_t)&dev_vdata[9] },
+ { PCI_VDEVICE(HYGON, 0x1456), .driver_data = (kernel_ulong_t)&hygon_dev_vdata[0] },
+ { PCI_VDEVICE(HYGON, 0x1468), .driver_data = (kernel_ulong_t)&hygon_dev_vdata[1] },
+ { PCI_VDEVICE(HYGON, 0x1486), .driver_data = (kernel_ulong_t)&hygon_dev_vdata[2] },
+ { PCI_VDEVICE(HYGON, 0x14b8), .driver_data = (kernel_ulong_t)&hygon_dev_vdata[1] },
+ { PCI_VDEVICE(HYGON, 0x14a6), .driver_data = (kernel_ulong_t)&hygon_dev_vdata[2] },
+ { PCI_VDEVICE(HYGON, 0x14d8), .driver_data = (kernel_ulong_t)&hygon_dev_vdata[1] },
+ { PCI_VDEVICE(HYGON, 0x14c6), .driver_data = (kernel_ulong_t)&hygon_dev_vdata[2] },
+ { PCI_VDEVICE(HYGON, 0x2006), .driver_data = (kernel_ulong_t)&hygon_dev_vdata[2] },
/* Last entry must be zero */
{ }
};
--
2.34.1