From: Depei Yang <yangdepei@hygon.cn>
To: <linux-crypto@vger.kernel.org>
Cc: Tom Lendacky <thomas.lendacky@amd.com>,
Herbert Xu <herbert@gondor.apana.org.au>,
"David S. Miller" <davem@davemloft.net>,
Gary R Hook <gary.hook@amd.com>, <linux-kernel@vger.kernel.org>,
Depei Yang <yangdepei@hygon.cn>, Shan Chen <chenshan@hygon.cn>,
Yongwei Xu <xuyongwei@hygon.cn>,
Xiaochen Shen <shenxiaochen@hygon.cn>
Subject: [PATCH 07/11] crypto: ccp - add Hygon CCP device IDs and vdata
Date: Wed, 25 Nov 2026 15:46:05 +0800 [thread overview]
Message-ID: <8a1c16c33938b0e169c282136c85d7b522caedf1.1795588986.git.yangdepei@hygon.cn> (raw)
In-Reply-To: <cover.1795588986.git.yangdepei@hygon.cn>
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@hygon.cn>
Tested-by: Yongwei Xu <xuyongwei@hygon.cn>
Signed-off-by: Depei Yang <yangdepei@hygon.cn>
---
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
next prev parent reply other threads:[~2026-11-25 7:46 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-25 7:45 [PATCH 00/11] crypto: ccp - add Hygon SM3/SM4 support Depei Yang
2026-11-25 7:45 ` [PATCH 01/11] crypto: ccp - fix LSB region mask calculation Depei Yang
2026-11-25 7:46 ` [PATCH 02/11] crypto: ccp - acknowledge queue interrupt before waking waiter Depei Yang
2026-11-25 7:46 ` [PATCH 03/11] crypto: ccp - add engine capability and version information Depei Yang
2026-11-25 7:46 ` [PATCH 04/11] crypto: ccp - register algorithms only for supported engines Depei Yang
2026-11-25 7:46 ` [PATCH 05/11] crypto: ccp - split v5 command submission from queue run Depei Yang
2026-11-25 7:46 ` [PATCH 06/11] crypto: ccp - add SM3/SM4 command definitions Depei Yang
2026-11-25 7:46 ` Depei Yang [this message]
2026-11-25 7:46 ` [PATCH 08/11] crypto: ccp - handle only supported interrupts in v5 irq bh Depei Yang
2026-11-25 7:46 ` [PATCH 09/11] crypto: ccp - detect the Hygon CCP engines from the version register Depei Yang
2026-11-25 7:46 ` [PATCH 10/11] crypto: ccp - add SM4 engine and skcipher algorithms Depei Yang
2026-11-25 7:46 ` [PATCH 11/11] crypto: ccp - add SM3 engine and ahash algorithms Depei Yang
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=8a1c16c33938b0e169c282136c85d7b522caedf1.1795588986.git.yangdepei@hygon.cn \
--to=yangdepei@hygon.cn \
--cc=chenshan@hygon.cn \
--cc=davem@davemloft.net \
--cc=gary.hook@amd.com \
--cc=herbert@gondor.apana.org.au \
--cc=linux-crypto@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=shenxiaochen@hygon.cn \
--cc=thomas.lendacky@amd.com \
--cc=xuyongwei@hygon.cn \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®