icnss2.h 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2015-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2023-2024 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef _ICNSS_WLAN_H_
  7. #define _ICNSS_WLAN_H_
  8. #include <linux/interrupt.h>
  9. #include <linux/device.h>
  10. #define ICNSS_MAX_IRQ_REGISTRATIONS 12
  11. #define IWCN_MAX_IRQ_REGISTRATIONS 32
  12. #define ICNSS_MAX_TIMESTAMP_LEN 32
  13. #define ICNSS_WLFW_MAX_BUILD_ID_LEN 128
  14. #define ICNSS_MAX_DEV_MEM_NUM 4
  15. #define DEVICE_NAME_MAX 10
  16. enum icnss_uevent {
  17. ICNSS_UEVENT_FW_CRASHED,
  18. ICNSS_UEVENT_FW_DOWN,
  19. ICNSS_UEVENT_HANG_DATA,
  20. ICNSS_UEVENT_SMMU_FAULT,
  21. };
  22. enum icnss_device_config {
  23. ICNSS_IPA_DISABLED,
  24. };
  25. struct icnss_uevent_hang_data {
  26. void *hang_event_data;
  27. uint16_t hang_event_data_len;
  28. };
  29. struct icnss_uevent_fw_down_data {
  30. bool crashed;
  31. };
  32. struct icnss_uevent_data {
  33. enum icnss_uevent uevent;
  34. void *data;
  35. };
  36. struct icnss_dev_mem_info {
  37. u64 start;
  38. u64 size;
  39. };
  40. /* Device information like supported device ids, etc*/
  41. struct device_info {
  42. char name[DEVICE_NAME_MAX];
  43. uint16_t device_id;
  44. };
  45. struct icnss_driver_ops {
  46. char *name;
  47. struct device_info *dev_info;
  48. unsigned long drv_state;
  49. struct device_driver driver;
  50. int (*probe)(struct device *dev);
  51. void (*remove)(struct device *dev);
  52. void (*shutdown)(struct device *dev);
  53. int (*reinit)(struct device *dev);
  54. void (*crash_shutdown)(void *pdev);
  55. int (*pm_suspend)(struct device *dev);
  56. int (*pm_resume)(struct device *dev);
  57. int (*suspend_noirq)(struct device *dev);
  58. int (*resume_noirq)(struct device *dev);
  59. int (*runtime_suspend)(struct device *dev);
  60. int (*runtime_resume)(struct device *dev);
  61. int (*uevent)(struct device *dev, struct icnss_uevent_data *uevent);
  62. int (*idle_shutdown)(struct device *dev);
  63. int (*idle_restart)(struct device *dev);
  64. int (*set_therm_cdev_state)(struct device *dev,
  65. unsigned long thermal_state,
  66. int tcdev_id);
  67. };
  68. struct ce_tgt_pipe_cfg {
  69. u32 pipe_num;
  70. u32 pipe_dir;
  71. u32 nentries;
  72. u32 nbytes_max;
  73. u32 flags;
  74. u32 reserved;
  75. };
  76. struct ce_svc_pipe_cfg {
  77. u32 service_id;
  78. u32 pipe_dir;
  79. u32 pipe_num;
  80. };
  81. struct icnss_shadow_reg_cfg {
  82. u16 ce_id;
  83. u16 reg_offset;
  84. };
  85. struct icnss_shadow_reg_v2_cfg {
  86. u32 addr;
  87. };
  88. struct icnss_shadow_reg_v3_cfg {
  89. u32 addr;
  90. };
  91. struct icnss_rri_over_ddr_cfg {
  92. u32 base_addr_low;
  93. u32 base_addr_high;
  94. };
  95. /* CE configuration to target */
  96. struct icnss_wlan_enable_cfg {
  97. u32 num_ce_tgt_cfg;
  98. struct ce_tgt_pipe_cfg *ce_tgt_cfg;
  99. u32 num_ce_svc_pipe_cfg;
  100. struct ce_svc_pipe_cfg *ce_svc_cfg;
  101. u32 num_shadow_reg_cfg;
  102. struct icnss_shadow_reg_cfg *shadow_reg_cfg;
  103. u32 num_shadow_reg_v2_cfg;
  104. struct icnss_shadow_reg_v2_cfg *shadow_reg_v2_cfg;
  105. u32 num_shadow_reg_v3_cfg;
  106. struct icnss_shadow_reg_v3_cfg *shadow_reg_v3_cfg;
  107. bool rri_over_ddr_cfg_valid;
  108. struct icnss_rri_over_ddr_cfg rri_over_ddr_cfg;
  109. };
  110. /* driver modes */
  111. enum icnss_driver_mode {
  112. ICNSS_MISSION,
  113. ICNSS_FTM,
  114. ICNSS_EPPING,
  115. ICNSS_WALTEST,
  116. ICNSS_OFF,
  117. ICNSS_CCPM,
  118. ICNSS_QVIT,
  119. ICNSS_CALIBRATION,
  120. };
  121. enum icnss_rd_card_chain_cap {
  122. ICNSS_RD_CARD_CHAIN_CAP_UNSPECIFIED,
  123. ICNSS_RD_CARD_CHAIN_CAP_1x1,
  124. ICNSS_RD_CARD_CHAIN_CAP_2x2,
  125. ICNSS_RD_CARD_CHAIN_CAP_MAX_VAL,
  126. };
  127. enum icnss_phy_he_channel_width_cap {
  128. ICNSS_PHY_HE_CHANNEL_WIDTH_CAP_UNSPECIFIED,
  129. ICNSS_PHY_HE_CHANNEL_WIDTH_CAP_80MHZ,
  130. ICNSS_PHY_HE_CHANNEL_WIDTH_CAP_160MHZ,
  131. ICNSS_PHY_HE_CHANNEL_WIDTH_CAP_MAX_VAL,
  132. };
  133. enum icnss_phy_qam_cap {
  134. ICNSS_PHY_QAM_CAP_UNSPECIFIED,
  135. ICNSS_PHY_QAM_CAP_1K,
  136. ICNSS_PHY_QAM_CAP_4K,
  137. ICNSS_PHY_QAM_CAP_MAX_VAL,
  138. };
  139. struct icnss_soc_info {
  140. void __iomem *v_addr;
  141. phys_addr_t p_addr;
  142. uint32_t chip_id;
  143. uint32_t chip_family;
  144. uint32_t board_id;
  145. uint32_t soc_id;
  146. uint32_t fw_version;
  147. char fw_build_timestamp[ICNSS_MAX_TIMESTAMP_LEN + 1];
  148. char fw_build_id[ICNSS_WLFW_MAX_BUILD_ID_LEN + 1];
  149. enum icnss_rd_card_chain_cap rd_card_chain_cap;
  150. enum icnss_phy_he_channel_width_cap phy_he_channel_width_cap;
  151. enum icnss_phy_qam_cap phy_qam_cap;
  152. struct icnss_dev_mem_info dev_mem_info[ICNSS_MAX_DEV_MEM_NUM];
  153. };
  154. #define icnss_register_driver(ops) \
  155. __icnss_register_driver(ops, THIS_MODULE, KBUILD_MODNAME)
  156. extern int __icnss_register_driver(struct icnss_driver_ops *ops,
  157. struct module *owner, const char *mod_name);
  158. extern int icnss_unregister_driver(struct icnss_driver_ops *ops);
  159. extern int icnss_wlan_enable(struct device *dev,
  160. struct icnss_wlan_enable_cfg *config,
  161. enum icnss_driver_mode mode,
  162. const char *host_version);
  163. extern int icnss_wlan_disable(struct device *dev, enum icnss_driver_mode mode);
  164. extern void icnss_enable_irq(struct device *dev, unsigned int ce_id);
  165. extern void icnss_disable_irq(struct device *dev, unsigned int ce_id);
  166. extern int icnss_get_soc_info(struct device *dev, struct icnss_soc_info *info);
  167. extern int icnss_ce_free_irq(struct device *dev, unsigned int ce_id, void *ctx);
  168. extern int icnss_ce_request_irq(struct device *dev, unsigned int ce_id,
  169. irqreturn_t (*handler)(int, void *),
  170. unsigned long flags, const char *name, void *ctx);
  171. extern int icnss_get_ce_id(struct device *dev, int irq);
  172. extern int icnss_set_fw_log_mode(struct device *dev, uint8_t fw_log_mode);
  173. extern int icnss_athdiag_read(struct device *dev, uint32_t offset,
  174. uint32_t mem_type, uint32_t data_len,
  175. uint8_t *output);
  176. extern int icnss_athdiag_write(struct device *dev, uint32_t offset,
  177. uint32_t mem_type, uint32_t data_len,
  178. uint8_t *input);
  179. extern int icnss_get_irq(struct device *dev, int ce_id);
  180. extern int icnss_power_on(struct device *dev);
  181. extern int icnss_power_off(struct device *dev);
  182. extern struct dma_iommu_mapping *icnss_smmu_get_mapping(struct device *dev);
  183. extern struct iommu_domain *icnss_smmu_get_domain(struct device *dev);
  184. extern int icnss_smmu_map(struct device *dev, phys_addr_t paddr,
  185. uint32_t *iova_addr, size_t size);
  186. extern int icnss_smmu_unmap(struct device *dev,
  187. uint32_t iova_addr, size_t size);
  188. extern unsigned int icnss_socinfo_get_serial_number(struct device *dev);
  189. extern bool icnss_is_qmi_disable(struct device *dev);
  190. extern bool icnss_is_fw_ready(void);
  191. extern bool icnss_is_fw_down(void);
  192. extern bool icnss_is_low_power(void);
  193. extern bool icnss_is_rejuvenate(void);
  194. extern int icnss_trigger_recovery(struct device *dev);
  195. extern void icnss_block_shutdown(bool status);
  196. extern bool icnss_is_pdr(void);
  197. extern int icnss_idle_restart(struct device *dev);
  198. extern int icnss_idle_shutdown(struct device *dev);
  199. extern int icnss_get_user_msi_assignment(struct device *dev, char *user_name,
  200. int *num_vectors, u32 *user_base_data,
  201. u32 *base_vector);
  202. extern int icnss_get_msi_irq(struct device *dev, unsigned int vector);
  203. extern void icnss_get_msi_address(struct device *dev, u32 *msi_addr_low,
  204. u32 *msi_addr_high);
  205. extern int icnss_qmi_send(struct device *dev, int type, void *cmd,
  206. int cmd_len, void *cb_ctx,
  207. int (*cb)(void *ctx, void *event, int event_len));
  208. extern int icnss_force_wake_request(struct device *dev);
  209. extern int icnss_force_wake_release(struct device *dev);
  210. extern int icnss_is_device_awake(struct device *dev);
  211. extern int icnss_thermal_cdev_register(struct device *dev,
  212. unsigned long max_state,
  213. int tcdev_id);
  214. extern void icnss_thermal_cdev_unregister(struct device *dev, int tcdev_id);
  215. extern int icnss_get_curr_therm_cdev_state(struct device *dev,
  216. unsigned long *thermal_state,
  217. int tcdev_id);
  218. extern int icnss_exit_power_save(struct device *dev);
  219. extern int icnss_prevent_l1(struct device *dev);
  220. extern void icnss_allow_l1(struct device *dev);
  221. extern int icnss_get_mhi_state(struct device *dev);
  222. extern int icnss_is_pci_ep_awake(struct device *dev);
  223. extern unsigned long icnss_get_device_config(void);
  224. #endif /* _ICNSS_WLAN_H_ */