blob: 0b8f048f39cbb19d395ee751bf32679d8c8d8679 [file] [log] [blame]
Neeraj Sonib30ac1f2018-04-17 14:48:42 +05301/* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved.
AnilKumar Chimata20c6b2f2017-04-07 12:18:46 -07002 *
3 * This program is free software; you can redistribute it and/or modify
4 * it under the terms of the GNU General Public License version 2 and
5 * only version 2 as published by the Free Software Foundation.
6 *
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
11 */
12
13#ifndef _QCOM_INLINE_CRYPTO_ENGINE_H_
14#define _QCOM_INLINE_CRYPTO_ENGINE_H_
15
16#include <linux/platform_device.h>
17
18struct request;
19
20enum ice_cryto_algo_mode {
21 ICE_CRYPTO_ALGO_MODE_AES_ECB = 0x0,
22 ICE_CRYPTO_ALGO_MODE_AES_XTS = 0x3,
23};
24
25enum ice_crpto_key_size {
26 ICE_CRYPTO_KEY_SIZE_128 = 0x0,
27 ICE_CRYPTO_KEY_SIZE_256 = 0x2,
28};
29
30enum ice_crpto_key_mode {
31 ICE_CRYPTO_USE_KEY0_HW_KEY = 0x0,
32 ICE_CRYPTO_USE_KEY1_HW_KEY = 0x1,
33 ICE_CRYPTO_USE_LUT_SW_KEY0 = 0x2,
34 ICE_CRYPTO_USE_LUT_SW_KEY = 0x3
35};
36
37struct ice_crypto_setting {
38 enum ice_crpto_key_size key_size;
39 enum ice_cryto_algo_mode algo_mode;
40 enum ice_crpto_key_mode key_mode;
41 short key_index;
42
43};
44
45struct ice_data_setting {
46 struct ice_crypto_setting crypto_data;
47 bool sw_forced_context_switch;
48 bool decr_bypass;
49 bool encr_bypass;
50};
51
Neeraj Soniefb33112018-08-17 20:39:35 +053052/* MSM ICE Crypto Data Unit of target DUN of Transfer Request */
53enum ice_crypto_data_unit {
54 ICE_CRYPTO_DATA_UNIT_512_B = 0,
55 ICE_CRYPTO_DATA_UNIT_1_KB = 1,
56 ICE_CRYPTO_DATA_UNIT_2_KB = 2,
57 ICE_CRYPTO_DATA_UNIT_4_KB = 3,
58 ICE_CRYPTO_DATA_UNIT_8_KB = 4,
59 ICE_CRYPTO_DATA_UNIT_16_KB = 5,
60 ICE_CRYPTO_DATA_UNIT_32_KB = 6,
61 ICE_CRYPTO_DATA_UNIT_64_KB = 7,
62};
63
AnilKumar Chimata20c6b2f2017-04-07 12:18:46 -070064typedef void (*ice_error_cb)(void *, u32 error);
65
66struct qcom_ice_variant_ops *qcom_ice_get_variant_ops(struct device_node *node);
67struct platform_device *qcom_ice_get_pdevice(struct device_node *node);
AnilKumar Chimata20c6b2f2017-04-07 12:18:46 -070068
69#ifdef CONFIG_CRYPTO_DEV_QCOM_ICE
70int qcom_ice_setup_ice_hw(const char *storage_type, int enable);
Neeraj Sonie28f2ae2018-04-30 11:13:17 +053071void qcom_ice_set_fde_flag(int flag);
72int qcom_ice_set_fde_conf(sector_t strt, sector_t size, int idx, int mode);
AnilKumar Chimata20c6b2f2017-04-07 12:18:46 -070073#else
74static inline int qcom_ice_setup_ice_hw(const char *storage_type, int enable)
75{
76 return 0;
77}
Neeraj Sonie28f2ae2018-04-30 11:13:17 +053078static inline void qcom_ice_set_fde_flag(int flag) {}
79static inline int qcom_ice_set_fde_conf(sector_t strt, sector_t size, int idx,
80 int mode)
81{
82 return 0;
83}
AnilKumar Chimata20c6b2f2017-04-07 12:18:46 -070084#endif
85
86struct qcom_ice_variant_ops {
87 const char *name;
88 int (*init)(struct platform_device *, void *, ice_error_cb);
89 int (*reset)(struct platform_device *);
90 int (*resume)(struct platform_device *);
91 int (*suspend)(struct platform_device *);
92 int (*config_start)(struct platform_device *, struct request *,
93 struct ice_data_setting *, bool);
94 int (*config_end)(struct request *);
95 int (*status)(struct platform_device *);
96 void (*debug)(struct platform_device *);
97};
98
99#endif /* _QCOM_INLINE_CRYPTO_ENGINE_H_ */