1 /* SPDX-License-Identifier: GPL-2.0-only */
3 * Intel Keem Bay OCS AES Crypto Driver.
5 * Copyright (C) 2018-2020 Intel Corporation
8 #ifndef _CRYPTO_OCS_AES_H
9 #define _CRYPTO_OCS_AES_H
11 #include <linux/dma-mapping.h>
27 enum ocs_instruction
{
35 * struct ocs_aes_dev - AES device context.
36 * @list: List head for insertion into device list hold
38 * @dev: OCS AES device.
40 * @base_reg: IO base address of OCS AES.
41 * @irq_copy_completion: Completion to indicate IRQ has been triggered.
42 * @dma_err_mask: Error reported by OCS DMA interrupts.
43 * @engine: Crypto engine for the device.
46 struct list_head list
;
49 void __iomem
*base_reg
;
50 struct completion irq_completion
;
52 struct crypto_engine
*engine
;
56 * struct ocs_dll_desc - Descriptor of an OCS DMA Linked List.
57 * @vaddr: Virtual address of the linked list head.
58 * @dma_addr: DMA address of the linked list head.
59 * @size: Size (in bytes) of the linked list.
67 int ocs_aes_set_key(struct ocs_aes_dev
*aes_dev
, const u32 key_size
,
68 const u8
*key
, const enum ocs_cipher cipher
);
70 int ocs_aes_op(struct ocs_aes_dev
*aes_dev
,
72 enum ocs_cipher cipher
,
73 enum ocs_instruction instruction
,
74 dma_addr_t dst_dma_list
,
75 dma_addr_t src_dma_list
,
81 * ocs_aes_bypass_op() - Use OCS DMA to copy data.
82 * @aes_dev: The OCS AES device to use.
83 * @dst_dma_list: The OCS DMA list mapping the memory where input data
85 * @src_dma_list: The OCS DMA list mapping input data.
86 * @src_size: The amount of data to copy.
88 static inline int ocs_aes_bypass_op(struct ocs_aes_dev
*aes_dev
,
89 dma_addr_t dst_dma_list
,
90 dma_addr_t src_dma_list
, u32 src_size
)
92 return ocs_aes_op(aes_dev
, OCS_MODE_ECB
, OCS_AES
, OCS_BYPASS
,
93 dst_dma_list
, src_dma_list
, src_size
, NULL
, 0);
96 int ocs_aes_gcm_op(struct ocs_aes_dev
*aes_dev
,
97 enum ocs_cipher cipher
,
98 enum ocs_instruction instruction
,
99 dma_addr_t dst_dma_list
,
100 dma_addr_t src_dma_list
,
103 dma_addr_t aad_dma_list
,
108 int ocs_aes_ccm_op(struct ocs_aes_dev
*aes_dev
,
109 enum ocs_cipher cipher
,
110 enum ocs_instruction instruction
,
111 dma_addr_t dst_dma_list
,
112 dma_addr_t src_dma_list
,
115 dma_addr_t adata_dma_list
,
120 int ocs_create_linked_list_from_sg(const struct ocs_aes_dev
*aes_dev
,
121 struct scatterlist
*sg
,
123 struct ocs_dll_desc
*dll_desc
,
127 irqreturn_t
ocs_aes_irq_handler(int irq
, void *dev_id
);