1 /* SPDX-License-Identifier: GPL-2.0 */ 2 /* Copyright (c) 2019 HiSilicon Limited. */ 3 #ifndef HISI_ZIP_H 4 #define HISI_ZIP_H 5 6 #undef pr_fmt 7 #define pr_fmt(fmt) "hisi_zip: " fmt 8 9 #include <linux/list.h> 10 #include "../qm.h" 11 #include "../sgl.h" 12 13 /* hisi_zip_sqe dw3 */ 14 #define HZIP_BD_STATUS_M GENMASK(7, 0) 15 /* hisi_zip_sqe dw9 */ 16 #define HZIP_REQ_TYPE_M GENMASK(7, 0) 17 #define HZIP_ALG_TYPE_ZLIB 0x02 18 #define HZIP_ALG_TYPE_GZIP 0x03 19 #define HZIP_BUF_TYPE_M GENMASK(11, 8) 20 #define HZIP_PBUFFER 0x0 21 #define HZIP_SGL 0x1 22 23 enum hisi_zip_error_type { 24 /* negative compression */ 25 HZIP_NC_ERR = 0x0d, 26 }; 27 28 struct hisi_zip_ctrl; 29 30 struct hisi_zip { 31 struct hisi_qm qm; 32 struct list_head list; 33 struct hisi_zip_ctrl *ctrl; 34 }; 35 36 struct hisi_zip_sqe { 37 u32 consumed; 38 u32 produced; 39 u32 comp_data_length; 40 u32 dw3; 41 u32 input_data_length; 42 u32 lba_l; 43 u32 lba_h; 44 u32 dw7; 45 u32 dw8; 46 u32 dw9; 47 u32 dw10; 48 u32 priv_info; 49 u32 dw12; 50 u32 tag; 51 u32 dest_avail_out; 52 u32 rsvd0; 53 u32 comp_head_addr_l; 54 u32 comp_head_addr_h; 55 u32 source_addr_l; 56 u32 source_addr_h; 57 u32 dest_addr_l; 58 u32 dest_addr_h; 59 u32 stream_ctx_addr_l; 60 u32 stream_ctx_addr_h; 61 u32 cipher_key1_addr_l; 62 u32 cipher_key1_addr_h; 63 u32 cipher_key2_addr_l; 64 u32 cipher_key2_addr_h; 65 u32 rsvd1[4]; 66 }; 67 68 struct hisi_zip *find_zip_device(int node); 69 int hisi_zip_register_to_crypto(void); 70 void hisi_zip_unregister_from_crypto(void); 71 #endif 72