Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

firmware: zynqmp: Move crypto API's to separate file

For better maintainability move crypto related API's to
new zynqmp-crypto.c file.

Signed-off-by: Harsh Jain <h.jain@amd.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>

authored by

Harsh Jain and committed by
Herbert Xu
c15291e2 1ccc00d7

+89 -63
+1 -1
drivers/firmware/xilinx/Makefile
··· 1 1 # SPDX-License-Identifier: GPL-2.0 2 2 # Makefile for Xilinx firmwares 3 3 4 - obj-$(CONFIG_ZYNQMP_FIRMWARE) += zynqmp.o zynqmp-ufs.o 4 + obj-$(CONFIG_ZYNQMP_FIRMWARE) += zynqmp.o zynqmp-ufs.o zynqmp-crypto.o 5 5 obj-$(CONFIG_ZYNQMP_FIRMWARE_DEBUG) += zynqmp-debug.o
+59
drivers/firmware/xilinx/zynqmp-crypto.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* 3 + * Firmware layer for XilSecure APIs. 4 + * 5 + * Copyright (C) 2014-2022 Xilinx, Inc. 6 + * Copyright (C) 2022-2025 Advanced Micro Devices, Inc. 7 + */ 8 + 9 + #include <linux/firmware/xlnx-zynqmp.h> 10 + #include <linux/module.h> 11 + 12 + /** 13 + * zynqmp_pm_aes_engine - Access AES hardware to encrypt/decrypt the data using 14 + * AES-GCM core. 15 + * @address: Address of the AesParams structure. 16 + * @out: Returned output value 17 + * 18 + * Return: Returns status, either success or error code. 19 + */ 20 + int zynqmp_pm_aes_engine(const u64 address, u32 *out) 21 + { 22 + u32 ret_payload[PAYLOAD_ARG_CNT]; 23 + int ret; 24 + 25 + if (!out) 26 + return -EINVAL; 27 + 28 + ret = zynqmp_pm_invoke_fn(PM_SECURE_AES, ret_payload, 2, upper_32_bits(address), 29 + lower_32_bits(address)); 30 + *out = ret_payload[1]; 31 + 32 + return ret; 33 + } 34 + EXPORT_SYMBOL_GPL(zynqmp_pm_aes_engine); 35 + 36 + /** 37 + * zynqmp_pm_sha_hash - Access the SHA engine to calculate the hash 38 + * @address: Address of the data/ Address of output buffer where 39 + * hash should be stored. 40 + * @size: Size of the data. 41 + * @flags: 42 + * BIT(0) - for initializing csudma driver and SHA3(Here address 43 + * and size inputs can be NULL). 44 + * BIT(1) - to call Sha3_Update API which can be called multiple 45 + * times when data is not contiguous. 46 + * BIT(2) - to get final hash of the whole updated data. 47 + * Hash will be overwritten at provided address with 48 + * 48 bytes. 49 + * 50 + * Return: Returns status, either success or error code. 51 + */ 52 + int zynqmp_pm_sha_hash(const u64 address, const u32 size, const u32 flags) 53 + { 54 + u32 lower_addr = lower_32_bits(address); 55 + u32 upper_addr = upper_32_bits(address); 56 + 57 + return zynqmp_pm_invoke_fn(PM_SECURE_SHA, NULL, 4, upper_addr, lower_addr, size, flags); 58 + } 59 + EXPORT_SYMBOL_GPL(zynqmp_pm_sha_hash);
-49
drivers/firmware/xilinx/zynqmp.c
··· 1522 1522 EXPORT_SYMBOL_GPL(zynqmp_pm_load_pdi); 1523 1523 1524 1524 /** 1525 - * zynqmp_pm_aes_engine - Access AES hardware to encrypt/decrypt the data using 1526 - * AES-GCM core. 1527 - * @address: Address of the AesParams structure. 1528 - * @out: Returned output value 1529 - * 1530 - * Return: Returns status, either success or error code. 1531 - */ 1532 - int zynqmp_pm_aes_engine(const u64 address, u32 *out) 1533 - { 1534 - u32 ret_payload[PAYLOAD_ARG_CNT]; 1535 - int ret; 1536 - 1537 - if (!out) 1538 - return -EINVAL; 1539 - 1540 - ret = zynqmp_pm_invoke_fn(PM_SECURE_AES, ret_payload, 2, upper_32_bits(address), 1541 - lower_32_bits(address)); 1542 - *out = ret_payload[1]; 1543 - 1544 - return ret; 1545 - } 1546 - EXPORT_SYMBOL_GPL(zynqmp_pm_aes_engine); 1547 - 1548 - /** 1549 1525 * zynqmp_pm_efuse_access - Provides access to efuse memory. 1550 1526 * @address: Address of the efuse params structure 1551 1527 * @out: Returned output value ··· 1544 1568 return ret; 1545 1569 } 1546 1570 EXPORT_SYMBOL_GPL(zynqmp_pm_efuse_access); 1547 - 1548 - /** 1549 - * zynqmp_pm_sha_hash - Access the SHA engine to calculate the hash 1550 - * @address: Address of the data/ Address of output buffer where 1551 - * hash should be stored. 1552 - * @size: Size of the data. 1553 - * @flags: 1554 - * BIT(0) - for initializing csudma driver and SHA3(Here address 1555 - * and size inputs can be NULL). 1556 - * BIT(1) - to call Sha3_Update API which can be called multiple 1557 - * times when data is not contiguous. 1558 - * BIT(2) - to get final hash of the whole updated data. 1559 - * Hash will be overwritten at provided address with 1560 - * 48 bytes. 1561 - * 1562 - * Return: Returns status, either success or error code. 1563 - */ 1564 - int zynqmp_pm_sha_hash(const u64 address, const u32 size, const u32 flags) 1565 - { 1566 - u32 lower_addr = lower_32_bits(address); 1567 - u32 upper_addr = upper_32_bits(address); 1568 - 1569 - return zynqmp_pm_invoke_fn(PM_SECURE_SHA, NULL, 4, upper_addr, lower_addr, size, flags); 1570 - } 1571 - EXPORT_SYMBOL_GPL(zynqmp_pm_sha_hash); 1572 1571 1573 1572 /** 1574 1573 * zynqmp_pm_register_notifier() - PM API for register a subsystem
+28
include/linux/firmware/xlnx-zynqmp-crypto.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* 3 + * Firmware layer for XilSECURE APIs. 4 + * 5 + * Copyright (C) 2014-2022 Xilinx, Inc. 6 + * Copyright (C) 2022-2025 Advanced Micro Devices, Inc. 7 + */ 8 + 9 + #ifndef __FIRMWARE_XLNX_ZYNQMP_CRYPTO_H__ 10 + #define __FIRMWARE_XLNX_ZYNQMP_CRYPTO_H__ 11 + 12 + #if IS_REACHABLE(CONFIG_ZYNQMP_FIRMWARE) 13 + int zynqmp_pm_aes_engine(const u64 address, u32 *out); 14 + int zynqmp_pm_sha_hash(const u64 address, const u32 size, const u32 flags); 15 + #else 16 + static inline int zynqmp_pm_aes_engine(const u64 address, u32 *out) 17 + { 18 + return -ENODEV; 19 + } 20 + 21 + static inline int zynqmp_pm_sha_hash(const u64 address, const u32 size, 22 + const u32 flags) 23 + { 24 + return -ENODEV; 25 + } 26 + #endif 27 + 28 + #endif /* __FIRMWARE_XLNX_ZYNQMP_CRYPTO_H__ */
+1 -13
include/linux/firmware/xlnx-zynqmp.h
··· 17 17 18 18 #include <linux/err.h> 19 19 #include <linux/firmware/xlnx-zynqmp-ufs.h> 20 + #include <linux/firmware/xlnx-zynqmp-crypto.h> 20 21 21 22 #define ZYNQMP_PM_VERSION_MAJOR 1 22 23 #define ZYNQMP_PM_VERSION_MINOR 0 ··· 590 589 int zynqmp_pm_set_requirement(const u32 node, const u32 capabilities, 591 590 const u32 qos, 592 591 const enum zynqmp_pm_request_ack ack); 593 - int zynqmp_pm_aes_engine(const u64 address, u32 *out); 594 592 int zynqmp_pm_efuse_access(const u64 address, u32 *out); 595 - int zynqmp_pm_sha_hash(const u64 address, const u32 size, const u32 flags); 596 593 int zynqmp_pm_fpga_load(const u64 address, const u32 size, const u32 flags); 597 594 int zynqmp_pm_fpga_get_status(u32 *value); 598 595 int zynqmp_pm_fpga_get_config_status(u32 *value); ··· 771 772 return -ENODEV; 772 773 } 773 774 774 - static inline int zynqmp_pm_aes_engine(const u64 address, u32 *out) 775 - { 776 - return -ENODEV; 777 - } 778 - 779 775 static inline int zynqmp_pm_efuse_access(const u64 address, u32 *out) 780 - { 781 - return -ENODEV; 782 - } 783 - 784 - static inline int zynqmp_pm_sha_hash(const u64 address, const u32 size, 785 - const u32 flags) 786 776 { 787 777 return -ENODEV; 788 778 }