cnss2.h 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293
  1. /* SPDX-License-Identifier: GPL-2.0-only */
  2. /*
  3. * Copyright (c) 2016-2021, The Linux Foundation. All rights reserved.
  4. * Copyright (c) 2022 Qualcomm Innovation Center, Inc. All rights reserved.
  5. */
  6. #ifndef _NET_CNSS2_H
  7. #define _NET_CNSS2_H
  8. #include <linux/pci.h>
  9. #define CNSS_MAX_FILE_NAME 20
  10. #define CNSS_MAX_TIMESTAMP_LEN 32
  11. #define CNSS_MAX_DEV_MEM_NUM 4
  12. #define CNSS_CHIP_VER_ANY 0
  13. /*
  14. * Temporary change for compilation, will be removed
  15. * after WLAN host driver switched to use new APIs
  16. */
  17. #define CNSS_API_WITH_DEV
  18. enum cnss_bus_width_type {
  19. CNSS_BUS_WIDTH_NONE,
  20. CNSS_BUS_WIDTH_IDLE,
  21. CNSS_BUS_WIDTH_LOW,
  22. CNSS_BUS_WIDTH_MEDIUM,
  23. CNSS_BUS_WIDTH_HIGH,
  24. CNSS_BUS_WIDTH_VERY_HIGH,
  25. CNSS_BUS_WIDTH_LOW_LATENCY
  26. };
  27. enum cnss_platform_cap_flag {
  28. CNSS_HAS_EXTERNAL_SWREG = 0x01,
  29. CNSS_HAS_UART_ACCESS = 0x02,
  30. CNSS_HAS_DRV_SUPPORT = 0x04,
  31. };
  32. struct cnss_platform_cap {
  33. u32 cap_flag;
  34. };
  35. struct cnss_fw_files {
  36. char image_file[CNSS_MAX_FILE_NAME];
  37. char board_data[CNSS_MAX_FILE_NAME];
  38. char otp_data[CNSS_MAX_FILE_NAME];
  39. char utf_file[CNSS_MAX_FILE_NAME];
  40. char utf_board_data[CNSS_MAX_FILE_NAME];
  41. char epping_file[CNSS_MAX_FILE_NAME];
  42. char evicted_data[CNSS_MAX_FILE_NAME];
  43. };
  44. struct cnss_device_version {
  45. u32 family_number;
  46. u32 device_number;
  47. u32 major_version;
  48. u32 minor_version;
  49. };
  50. struct cnss_dev_mem_info {
  51. u64 start;
  52. u64 size;
  53. };
  54. struct cnss_soc_info {
  55. void __iomem *va;
  56. phys_addr_t pa;
  57. uint32_t chip_id;
  58. uint32_t chip_family;
  59. uint32_t board_id;
  60. uint32_t soc_id;
  61. uint32_t fw_version;
  62. char fw_build_timestamp[CNSS_MAX_TIMESTAMP_LEN + 1];
  63. struct cnss_device_version device_version;
  64. struct cnss_dev_mem_info dev_mem_info[CNSS_MAX_DEV_MEM_NUM];
  65. };
  66. struct cnss_wlan_runtime_ops {
  67. int (*runtime_suspend)(struct pci_dev *pdev);
  68. int (*runtime_resume)(struct pci_dev *pdev);
  69. };
  70. enum cnss_driver_status {
  71. CNSS_UNINITIALIZED,
  72. CNSS_INITIALIZED,
  73. CNSS_LOAD_UNLOAD,
  74. CNSS_RECOVERY,
  75. CNSS_FW_DOWN,
  76. CNSS_HANG_EVENT,
  77. CNSS_BUS_EVENT,
  78. };
  79. enum cnss_bus_event_type {
  80. BUS_EVENT_PCI_LINK_DOWN = 0,
  81. BUS_EVENT_INVALID = 0xFFFF,
  82. };
  83. struct cnss_hang_event {
  84. void *hang_event_data;
  85. u16 hang_event_data_len;
  86. };
  87. struct cnss_bus_event {
  88. enum cnss_bus_event_type etype;
  89. void *event_data;
  90. };
  91. struct cnss_uevent_data {
  92. enum cnss_driver_status status;
  93. void *data;
  94. };
  95. struct cnss_wlan_driver {
  96. char *name;
  97. int (*probe)(struct pci_dev *pdev, const struct pci_device_id *id);
  98. void (*remove)(struct pci_dev *pdev);
  99. int (*idle_restart)(struct pci_dev *pdev,
  100. const struct pci_device_id *id);
  101. int (*idle_shutdown)(struct pci_dev *pdev);
  102. int (*reinit)(struct pci_dev *pdev, const struct pci_device_id *id);
  103. void (*shutdown)(struct pci_dev *pdev);
  104. void (*crash_shutdown)(struct pci_dev *pdev);
  105. int (*suspend)(struct pci_dev *pdev, pm_message_t state);
  106. int (*resume)(struct pci_dev *pdev);
  107. int (*suspend_noirq)(struct pci_dev *pdev);
  108. int (*resume_noirq)(struct pci_dev *pdev);
  109. void (*modem_status)(struct pci_dev *pdev, int state);
  110. void (*update_status)(struct pci_dev *pdev, uint32_t status);
  111. int (*update_event)(struct pci_dev *pdev,
  112. struct cnss_uevent_data *uevent);
  113. struct cnss_wlan_runtime_ops *runtime_ops;
  114. const struct pci_device_id *id_table;
  115. u32 chip_version;
  116. enum cnss_driver_mode (*get_driver_mode)(void);
  117. };
  118. struct cnss_ce_tgt_pipe_cfg {
  119. u32 pipe_num;
  120. u32 pipe_dir;
  121. u32 nentries;
  122. u32 nbytes_max;
  123. u32 flags;
  124. u32 reserved;
  125. };
  126. struct cnss_ce_svc_pipe_cfg {
  127. u32 service_id;
  128. u32 pipe_dir;
  129. u32 pipe_num;
  130. };
  131. struct cnss_shadow_reg_cfg {
  132. u16 ce_id;
  133. u16 reg_offset;
  134. };
  135. struct cnss_shadow_reg_v2_cfg {
  136. u32 addr;
  137. };
  138. struct cnss_rri_over_ddr_cfg {
  139. u32 base_addr_low;
  140. u32 base_addr_high;
  141. };
  142. struct cnss_shadow_reg_v3_cfg {
  143. u32 addr;
  144. };
  145. struct cnss_wlan_enable_cfg {
  146. u32 num_ce_tgt_cfg;
  147. struct cnss_ce_tgt_pipe_cfg *ce_tgt_cfg;
  148. u32 num_ce_svc_pipe_cfg;
  149. struct cnss_ce_svc_pipe_cfg *ce_svc_cfg;
  150. u32 num_shadow_reg_cfg;
  151. struct cnss_shadow_reg_cfg *shadow_reg_cfg;
  152. u32 num_shadow_reg_v2_cfg;
  153. struct cnss_shadow_reg_v2_cfg *shadow_reg_v2_cfg;
  154. bool rri_over_ddr_cfg_valid;
  155. struct cnss_rri_over_ddr_cfg rri_over_ddr_cfg;
  156. u32 num_shadow_reg_v3_cfg;
  157. struct cnss_shadow_reg_v3_cfg *shadow_reg_v3_cfg;
  158. };
  159. enum cnss_driver_mode {
  160. CNSS_MISSION,
  161. CNSS_FTM,
  162. CNSS_EPPING,
  163. CNSS_WALTEST,
  164. CNSS_OFF,
  165. CNSS_CCPM,
  166. CNSS_QVIT,
  167. CNSS_CALIBRATION,
  168. CNSS_DRIVER_MODE_MAX,
  169. };
  170. enum cnss_recovery_reason {
  171. CNSS_REASON_DEFAULT,
  172. CNSS_REASON_LINK_DOWN,
  173. CNSS_REASON_RDDM,
  174. CNSS_REASON_TIMEOUT,
  175. };
  176. enum cnss_remote_mem_type {
  177. CNSS_REMOTE_MEM_TYPE_FW,
  178. CNSS_REMOTE_MEM_TYPE_QDSS,
  179. CNSS_REMOTE_MEM_TYPE_MAX,
  180. };
  181. struct cnss_mem_segment {
  182. size_t size;
  183. void *va;
  184. phys_addr_t pa;
  185. };
  186. extern int cnss_wlan_register_driver(struct cnss_wlan_driver *driver);
  187. extern void cnss_wlan_unregister_driver(struct cnss_wlan_driver *driver);
  188. extern void cnss_device_crashed(struct device *dev);
  189. extern int cnss_pci_prevent_l1(struct device *dev);
  190. extern void cnss_pci_allow_l1(struct device *dev);
  191. extern int cnss_pci_link_down(struct device *dev);
  192. extern int cnss_pci_is_device_down(struct device *dev);
  193. extern void cnss_schedule_recovery(struct device *dev,
  194. enum cnss_recovery_reason reason);
  195. extern int cnss_self_recovery(struct device *dev,
  196. enum cnss_recovery_reason reason);
  197. extern int cnss_force_fw_assert(struct device *dev);
  198. extern int cnss_force_collect_rddm(struct device *dev);
  199. extern int cnss_qmi_send_get(struct device *dev);
  200. extern int cnss_qmi_send_put(struct device *dev);
  201. extern int cnss_qmi_send(struct device *dev, int type, void *cmd,
  202. int cmd_len, void *cb_ctx,
  203. int (*cb)(void *ctx, void *event, int event_len));
  204. extern void *cnss_get_virt_ramdump_mem(struct device *dev, unsigned long *size);
  205. extern int cnss_get_fw_files_for_target(struct device *dev,
  206. struct cnss_fw_files *pfw_files,
  207. u32 target_type, u32 target_version);
  208. extern int cnss_get_platform_cap(struct device *dev,
  209. struct cnss_platform_cap *cap);
  210. extern struct iommu_domain *cnss_smmu_get_domain(struct device *dev);
  211. extern int cnss_smmu_map(struct device *dev,
  212. phys_addr_t paddr, uint32_t *iova_addr, size_t size);
  213. extern int cnss_smmu_unmap(struct device *dev, uint32_t iova_addr, size_t size);
  214. extern int cnss_get_soc_info(struct device *dev, struct cnss_soc_info *info);
  215. extern int cnss_request_bus_bandwidth(struct device *dev, int bandwidth);
  216. extern int cnss_power_up(struct device *dev);
  217. extern int cnss_power_down(struct device *dev);
  218. extern int cnss_idle_restart(struct device *dev);
  219. extern int cnss_idle_shutdown(struct device *dev);
  220. extern void cnss_request_pm_qos(struct device *dev, u32 qos_val);
  221. extern void cnss_remove_pm_qos(struct device *dev);
  222. extern void cnss_lock_pm_sem(struct device *dev);
  223. extern void cnss_release_pm_sem(struct device *dev);
  224. extern void cnss_pci_lock_reg_window(struct device *dev, unsigned long *flags);
  225. extern void cnss_pci_unlock_reg_window(struct device *dev,
  226. unsigned long *flags);
  227. extern int cnss_wlan_pm_control(struct device *dev, bool vote);
  228. extern int cnss_auto_suspend(struct device *dev);
  229. extern int cnss_auto_resume(struct device *dev);
  230. extern int cnss_pci_is_drv_connected(struct device *dev);
  231. extern int cnss_pci_force_wake_request_sync(struct device *dev, int timeout);
  232. extern int cnss_pci_force_wake_request(struct device *dev);
  233. extern int cnss_pci_is_device_awake(struct device *dev);
  234. extern int cnss_pci_force_wake_release(struct device *dev);
  235. extern int cnss_get_user_msi_assignment(struct device *dev, char *user_name,
  236. int *num_vectors,
  237. uint32_t *user_base_data,
  238. uint32_t *base_vector);
  239. extern int cnss_get_msi_irq(struct device *dev, unsigned int vector);
  240. extern void cnss_get_msi_address(struct device *dev, uint32_t *msi_addr_low,
  241. uint32_t *msi_addr_high);
  242. extern int cnss_wlan_hw_enable(void);
  243. extern int cnss_wlan_enable(struct device *dev,
  244. struct cnss_wlan_enable_cfg *config,
  245. enum cnss_driver_mode mode,
  246. const char *host_version);
  247. extern int cnss_wlan_disable(struct device *dev, enum cnss_driver_mode mode);
  248. extern unsigned int cnss_get_boot_timeout(struct device *dev);
  249. extern int cnss_athdiag_read(struct device *dev, uint32_t offset,
  250. uint32_t mem_type, uint32_t data_len,
  251. uint8_t *output);
  252. extern int cnss_athdiag_write(struct device *dev, uint32_t offset,
  253. uint32_t mem_type, uint32_t data_len,
  254. uint8_t *input);
  255. extern int cnss_set_fw_log_mode(struct device *dev, uint8_t fw_log_mode);
  256. extern int cnss_set_pcie_gen_speed(struct device *dev, u8 pcie_gen_speed);
  257. extern int cnss_get_mem_seg_count(enum cnss_remote_mem_type type, u32 *seg);
  258. extern int cnss_get_mem_segment_info(enum cnss_remote_mem_type type,
  259. struct cnss_mem_segment segment[],
  260. u32 segment_count);
  261. extern int cnss_get_pci_slot(struct device *dev);
  262. #endif /* _NET_CNSS2_H */