AnilKumar Chimata | 20c6b2f | 2017-04-07 12:18:46 -0700 | [diff] [blame^] | 1 | /* 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 | |
| 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 | |
| 52 | typedef void (*ice_error_cb)(void *, u32 error); |
| 53 | |
| 54 | struct qcom_ice_variant_ops *qcom_ice_get_variant_ops(struct device_node *node); |
| 55 | struct platform_device *qcom_ice_get_pdevice(struct device_node *node); |
| 56 | |
| 57 | #ifdef CONFIG_CRYPTO_DEV_QCOM_ICE |
| 58 | int qcom_ice_setup_ice_hw(const char *storage_type, int enable); |
| 59 | #else |
| 60 | static inline int qcom_ice_setup_ice_hw(const char *storage_type, int enable) |
| 61 | { |
| 62 | return 0; |
| 63 | } |
| 64 | #endif |
| 65 | |
| 66 | struct 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_ */ |