ice.h 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2014-2020, The Linux Foundation. All rights reserved.
  4. */
  5. #ifndef _QCOM_INLINE_CRYPTO_ENGINE_H_
  6. #define _QCOM_INLINE_CRYPTO_ENGINE_H_
  7. #include <linux/platform_device.h>
  8. #include <linux/cdev.h>
  9. struct request;
  10. enum ice_cryto_algo_mode {
  11. ICE_CRYPTO_ALGO_MODE_AES_ECB = 0x0,
  12. ICE_CRYPTO_ALGO_MODE_AES_XTS = 0x3,
  13. };
  14. enum ice_crpto_key_size {
  15. ICE_CRYPTO_KEY_SIZE_128 = 0x0,
  16. ICE_CRYPTO_KEY_SIZE_256 = 0x2,
  17. };
  18. enum ice_crpto_key_mode {
  19. ICE_CRYPTO_USE_KEY0_HW_KEY = 0x0,
  20. ICE_CRYPTO_USE_KEY1_HW_KEY = 0x1,
  21. ICE_CRYPTO_USE_LUT_SW_KEY0 = 0x2,
  22. ICE_CRYPTO_USE_LUT_SW_KEY = 0x3
  23. };
  24. #define QCOM_ICE_TYPE_NAME_LEN 8
  25. typedef void (*ice_error_cb)(void *, u32 error);
  26. struct qcom_ice_bus_vote {
  27. uint32_t client_handle;
  28. uint32_t curr_vote;
  29. int min_bw_vote;
  30. int max_bw_vote;
  31. int saved_vote;
  32. bool is_max_bw_needed;
  33. struct device_attribute max_bus_bw;
  34. };
  35. /*
  36. * ICE HW device structure.
  37. */
  38. struct ice_device {
  39. struct list_head list;
  40. struct device *pdev;
  41. struct cdev cdev;
  42. dev_t device_no;
  43. struct class *driver_class;
  44. void __iomem *mmio;
  45. struct resource *res;
  46. int irq;
  47. bool is_ice_enabled;
  48. bool is_ice_disable_fuse_blown;
  49. ice_error_cb error_cb;
  50. void *host_controller_data; /* UFS/EMMC/other? */
  51. struct list_head clk_list_head;
  52. u32 ice_hw_version;
  53. bool is_ice_clk_available;
  54. char ice_instance_type[QCOM_ICE_TYPE_NAME_LEN];
  55. struct regulator *reg;
  56. bool is_regulator_available;
  57. struct qcom_ice_bus_vote bus_vote;
  58. ktime_t ice_reset_start_time;
  59. ktime_t ice_reset_complete_time;
  60. void *key_table;
  61. };
  62. struct ice_crypto_setting {
  63. enum ice_crpto_key_size key_size;
  64. enum ice_cryto_algo_mode algo_mode;
  65. enum ice_crpto_key_mode key_mode;
  66. short key_index;
  67. };
  68. struct ice_data_setting {
  69. struct ice_crypto_setting crypto_data;
  70. bool sw_forced_context_switch;
  71. bool decr_bypass;
  72. bool encr_bypass;
  73. };
  74. /* MSM ICE Crypto Data Unit of target DUN of Transfer Request */
  75. enum ice_crypto_data_unit {
  76. ICE_CRYPTO_DATA_UNIT_512_B = 0,
  77. ICE_CRYPTO_DATA_UNIT_1_KB = 1,
  78. ICE_CRYPTO_DATA_UNIT_2_KB = 2,
  79. ICE_CRYPTO_DATA_UNIT_4_KB = 3,
  80. ICE_CRYPTO_DATA_UNIT_8_KB = 4,
  81. ICE_CRYPTO_DATA_UNIT_16_KB = 5,
  82. ICE_CRYPTO_DATA_UNIT_32_KB = 6,
  83. ICE_CRYPTO_DATA_UNIT_64_KB = 7,
  84. };
  85. struct qcom_ice_variant_ops *qcom_ice_get_variant_ops(struct device_node *node);
  86. struct platform_device *qcom_ice_get_pdevice(struct device_node *node);
  87. #if IS_ENABLED(CONFIG_CYRPTO_DEV_QCOM_ICE)
  88. int enable_ice_setup(struct ice_device *ice_dev);
  89. int disable_ice_setup(struct ice_device *ice_dev);
  90. int qcom_ice_setup_ice_hw(const char *storage_type, int enable);
  91. void qcom_ice_set_fde_flag(int flag);
  92. struct list_head *get_ice_dev_list(void);
  93. #else
  94. static inline int enable_ice_setup(struct ice_device *ice_dev)
  95. {
  96. return 0;
  97. }
  98. static inline int disable_ice_setup(struct ice_device *ice_dev)
  99. {
  100. return 0;
  101. }
  102. static inline int qcom_ice_setup_ice_hw(const char *storage_type, int enable)
  103. {
  104. return 0;
  105. }
  106. static inline void qcom_ice_set_fde_flag(int flag) {}
  107. static inline struct list_head *get_ice_dev_list(void)
  108. {
  109. return NULL;
  110. }
  111. #endif
  112. struct qcom_ice_variant_ops {
  113. const char *name;
  114. int (*init)(struct platform_device *device_init, void *init_data,
  115. ice_error_cb err);
  116. int (*reset)(struct platform_device *device_reset);
  117. int (*resume)(struct platform_device *device_resume);
  118. int (*suspend)(struct platform_device *device_suspend);
  119. int (*config_start)(struct platform_device *device_start,
  120. struct request *req, struct ice_data_setting *setting,
  121. bool start);
  122. int (*config_end)(struct platform_device *pdev,
  123. struct request *req);
  124. int (*status)(struct platform_device *device_status);
  125. void (*debug)(struct platform_device *device_debug);
  126. };
  127. #endif /* _QCOM_INLINE_CRYPTO_ENGINE_H_ */