Neeraj Soni | b30ac1f | 2018-04-17 14:48:42 +0530 | [diff] [blame] | 1 | /* Copyright (c) 2014-2018, The Linux Foundation. All rights reserved. |
AnilKumar Chimata | 20c6b2f | 2017-04-07 12:18:46 -0700 | [diff] [blame] | 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 | |
| 18 | struct request; |
| 19 | |
| 20 | enum ice_cryto_algo_mode { |
| 21 | ICE_CRYPTO_ALGO_MODE_AES_ECB = 0x0, |
| 22 | ICE_CRYPTO_ALGO_MODE_AES_XTS = 0x3, |
| 23 | }; |
| 24 | |
| 25 | enum ice_crpto_key_size { |
| 26 | ICE_CRYPTO_KEY_SIZE_128 = 0x0, |
| 27 | ICE_CRYPTO_KEY_SIZE_256 = 0x2, |
| 28 | }; |
| 29 | |
| 30 | enum 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 | |
| 37 | struct 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 | |
| 45 | struct 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 Soni | efb3311 | 2018-08-17 20:39:35 +0530 | [diff] [blame^] | 52 | /* MSM ICE Crypto Data Unit of target DUN of Transfer Request */ |
| 53 | enum 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 Chimata | 20c6b2f | 2017-04-07 12:18:46 -0700 | [diff] [blame] | 64 | typedef void (*ice_error_cb)(void *, u32 error); |
| 65 | |
| 66 | struct qcom_ice_variant_ops *qcom_ice_get_variant_ops(struct device_node *node); |
| 67 | struct platform_device *qcom_ice_get_pdevice(struct device_node *node); |
AnilKumar Chimata | 20c6b2f | 2017-04-07 12:18:46 -0700 | [diff] [blame] | 68 | |
| 69 | #ifdef CONFIG_CRYPTO_DEV_QCOM_ICE |
| 70 | int qcom_ice_setup_ice_hw(const char *storage_type, int enable); |
Neeraj Soni | e28f2ae | 2018-04-30 11:13:17 +0530 | [diff] [blame] | 71 | void qcom_ice_set_fde_flag(int flag); |
| 72 | int qcom_ice_set_fde_conf(sector_t strt, sector_t size, int idx, int mode); |
AnilKumar Chimata | 20c6b2f | 2017-04-07 12:18:46 -0700 | [diff] [blame] | 73 | #else |
| 74 | static inline int qcom_ice_setup_ice_hw(const char *storage_type, int enable) |
| 75 | { |
| 76 | return 0; |
| 77 | } |
Neeraj Soni | e28f2ae | 2018-04-30 11:13:17 +0530 | [diff] [blame] | 78 | static inline void qcom_ice_set_fde_flag(int flag) {} |
| 79 | static inline int qcom_ice_set_fde_conf(sector_t strt, sector_t size, int idx, |
| 80 | int mode) |
| 81 | { |
| 82 | return 0; |
| 83 | } |
AnilKumar Chimata | 20c6b2f | 2017-04-07 12:18:46 -0700 | [diff] [blame] | 84 | #endif |
| 85 | |
| 86 | struct 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_ */ |