blob: 558d1366a7893ec42a563dc7ae8f1b7bac5a6f7f [file] [log] [blame]
AnilKumar Chimata20c6b2f2017-04-07 12:18:46 -07001/* Copyright (c) 2014-2017, The Linux Foundation. All rights reserved.
2 *
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
52typedef void (*ice_error_cb)(void *, u32 error);
53
54struct qcom_ice_variant_ops *qcom_ice_get_variant_ops(struct device_node *node);
55struct platform_device *qcom_ice_get_pdevice(struct device_node *node);
56
57#ifdef CONFIG_CRYPTO_DEV_QCOM_ICE
58int qcom_ice_setup_ice_hw(const char *storage_type, int enable);
59#else
60static inline int qcom_ice_setup_ice_hw(const char *storage_type, int enable)
61{
62 return 0;
63}
64#endif
65
66struct qcom_ice_variant_ops {
67 const char *name;
68 int (*init)(struct platform_device *, void *, ice_error_cb);
69 int (*reset)(struct platform_device *);
70 int (*resume)(struct platform_device *);
71 int (*suspend)(struct platform_device *);
72 int (*config_start)(struct platform_device *, struct request *,
73 struct ice_data_setting *, bool);
74 int (*config_end)(struct request *);
75 int (*status)(struct platform_device *);
76 void (*debug)(struct platform_device *);
77};
78
79#endif /* _QCOM_INLINE_CRYPTO_ENGINE_H_ */