blob: 4c8faf14ff15e6182e17bad3ea6228fd06dcf2c2 [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
Neeraj Sonie3af8d52018-09-05 14:32:49 +053064enum ice_capability_index {
65 ICE_CRYPTO_MODE_XTS_128 = 0,
66 ICE_CRYPTO_MODE_CBC_128 = 1,
67 ICE_CRYPTO_MODE_XTS_256 = 3,
68 ICE_CRYPTO_MODE_CBC_256 = 4
69};
70
AnilKumar Chimata20c6b2f2017-04-07 12:18:46 -070071typedef void (*ice_error_cb)(void *, u32 error);
72
73struct qcom_ice_variant_ops *qcom_ice_get_variant_ops(struct device_node *node);
74struct platform_device *qcom_ice_get_pdevice(struct device_node *node);
AnilKumar Chimata20c6b2f2017-04-07 12:18:46 -070075
76#ifdef CONFIG_CRYPTO_DEV_QCOM_ICE
77int qcom_ice_setup_ice_hw(const char *storage_type, int enable);
Neeraj Sonie28f2ae2018-04-30 11:13:17 +053078void qcom_ice_set_fde_flag(int flag);
79int qcom_ice_set_fde_conf(sector_t strt, sector_t size, int idx, int mode);
AnilKumar Chimata20c6b2f2017-04-07 12:18:46 -070080#else
81static inline int qcom_ice_setup_ice_hw(const char *storage_type, int enable)
82{
83 return 0;
84}
Neeraj Sonie28f2ae2018-04-30 11:13:17 +053085static inline void qcom_ice_set_fde_flag(int flag) {}
86static inline int qcom_ice_set_fde_conf(sector_t strt, sector_t size, int idx,
87 int mode)
88{
89 return 0;
90}
AnilKumar Chimata20c6b2f2017-04-07 12:18:46 -070091#endif
92
93struct qcom_ice_variant_ops {
94 const char *name;
95 int (*init)(struct platform_device *, void *, ice_error_cb);
96 int (*reset)(struct platform_device *);
97 int (*resume)(struct platform_device *);
98 int (*suspend)(struct platform_device *);
99 int (*config_start)(struct platform_device *, struct request *,
100 struct ice_data_setting *, bool);
101 int (*config_end)(struct request *);
102 int (*status)(struct platform_device *);
103 void (*debug)(struct platform_device *);
104};
105
106#endif /* _QCOM_INLINE_CRYPTO_ENGINE_H_ */