cnss2.h 9.9 KB

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