]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
firmware: zynqmp: Add helper API to self discovery the device
authorHarsh Jain <h.jain@amd.com>
Sat, 20 Dec 2025 15:58:54 +0000 (21:28 +0530)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 23 Jan 2026 05:48:43 +0000 (13:48 +0800)
Add API to get SoC version and family info.

Signed-off-by: Harsh Jain <h.jain@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
drivers/firmware/xilinx/zynqmp-crypto.c
include/linux/firmware/xlnx-zynqmp-crypto.h

index ea9cac6a1052d0722e9d200e060e5dababae1dc5..6d17cb8b27b3539b679de589759a3d7e59f460c6 100644 (file)
@@ -57,3 +57,34 @@ int zynqmp_pm_sha_hash(const u64 address, const u32 size, const u32 flags)
        return zynqmp_pm_invoke_fn(PM_SECURE_SHA, NULL, 4, upper_addr, lower_addr, size, flags);
 }
 EXPORT_SYMBOL_GPL(zynqmp_pm_sha_hash);
+
+/**
+ * xlnx_get_crypto_dev_data() - Get crypto dev data of platform
+ * @feature_map:       List of available feature map of all platform
+ *
+ * Return: Returns crypto dev data, either address crypto dev or ERR PTR
+ */
+void *xlnx_get_crypto_dev_data(struct xlnx_feature *feature_map)
+{
+       struct xlnx_feature *feature;
+       u32 pm_family_code;
+       int ret;
+
+       /* Get the Family code and sub family code of platform */
+       ret = zynqmp_pm_get_family_info(&pm_family_code);
+       if (ret < 0)
+               return ERR_PTR(ret);
+
+       feature = feature_map;
+       for (; feature->family; feature++) {
+               if (feature->family == pm_family_code) {
+                       ret = zynqmp_pm_feature(feature->feature_id);
+                       if (ret < 0)
+                               return ERR_PTR(ret);
+
+                       return feature->data;
+               }
+       }
+       return ERR_PTR(-ENODEV);
+}
+EXPORT_SYMBOL_GPL(xlnx_get_crypto_dev_data);
index f9eb523ba6a022d2aa6e5b16d6ba5da24e14bc29..cb08f412e931101c6deb143d7e6a8ea0fb7186f5 100644 (file)
@@ -9,9 +9,23 @@
 #ifndef __FIRMWARE_XLNX_ZYNQMP_CRYPTO_H__
 #define __FIRMWARE_XLNX_ZYNQMP_CRYPTO_H__
 
+/**
+ * struct xlnx_feature - Feature data
+ * @family:    Family code of platform
+ * @subfamily: Subfamily code of platform
+ * @feature_id:        Feature id of module
+ * @data:      Collection of all supported platform data
+ */
+struct xlnx_feature {
+       u32 family;
+       u32 feature_id;
+       void *data;
+};
+
 #if IS_REACHABLE(CONFIG_ZYNQMP_FIRMWARE)
 int zynqmp_pm_aes_engine(const u64 address, u32 *out);
 int zynqmp_pm_sha_hash(const u64 address, const u32 size, const u32 flags);
+void *xlnx_get_crypto_dev_data(struct xlnx_feature *feature_map);
 #else
 static inline int zynqmp_pm_aes_engine(const u64 address, u32 *out)
 {
@@ -23,6 +37,11 @@ static inline int zynqmp_pm_sha_hash(const u64 address, const u32 size,
 {
        return -ENODEV;
 }
+
+static inline void *xlnx_get_crypto_dev_data(struct xlnx_feature *feature_map)
+{
+       return ERR_PTR(-ENODEV);
+}
 #endif
 
 #endif /* __FIRMWARE_XLNX_ZYNQMP_CRYPTO_H__ */