cnss2.h 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  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_host_dump_type {
  83. CNSS_HOST_WLAN_LOGS,
  84. CNSS_HOST_HTC_CREDIT,
  85. CNSS_HOST_WMI_TX_CMP,
  86. CNSS_HOST_WMI_COMMAND_LOG,
  87. CNSS_HOST_WMI_EVENT_LOG,
  88. CNSS_HOST_WMI_RX_EVENT,
  89. CNSS_HOST_HAL_SOC,
  90. CNSS_HOST_WMI_HANG_DATA,
  91. CNSS_HOST_CE_HANG_EVT,
  92. CNSS_HOST_PEER_MAC_ADDR_HANG_DATA,
  93. CNSS_HOST_CP_VDEV_INFO,
  94. CNSS_HOST_GWLAN_LOGGING,
  95. CNSS_HOST_WMI_DEBUG_LOG_INFO,
  96. CNSS_HOST_HTC_CREDIT_IDX,
  97. CNSS_HOST_HTC_CREDIT_LEN,
  98. CNSS_HOST_WMI_TX_CMP_IDX,
  99. CNSS_HOST_WMI_COMMAND_LOG_IDX,
  100. CNSS_HOST_WMI_EVENT_LOG_IDX,
  101. CNSS_HOST_WMI_RX_EVENT_IDX,
  102. CNSS_HOST_DUMP_TYPE_MAX,
  103. };
  104. enum cnss_bus_event_type {
  105. BUS_EVENT_PCI_LINK_DOWN = 0,
  106. BUS_EVENT_INVALID = 0xFFFF,
  107. };
  108. enum cnss_wfc_mode {
  109. CNSS_WFC_MODE_OFF,
  110. CNSS_WFC_MODE_ON,
  111. };
  112. struct cnss_wfc_cfg {
  113. enum cnss_wfc_mode mode;
  114. };
  115. struct cnss_hang_event {
  116. void *hang_event_data;
  117. u16 hang_event_data_len;
  118. };
  119. struct cnss_bus_event {
  120. enum cnss_bus_event_type etype;
  121. void *event_data;
  122. };
  123. struct cnss_uevent_data {
  124. enum cnss_driver_status status;
  125. void *data;
  126. };
  127. struct cnss_ssr_driver_dump_entry {
  128. char region_name[CNSS_SSR_DRIVER_DUMP_MAX_REGIONS];
  129. void *buffer_pointer;
  130. size_t buffer_size;
  131. };
  132. struct cnss_wlan_driver {
  133. char *name;
  134. int (*probe)(struct pci_dev *pdev, const struct pci_device_id *id);
  135. void (*remove)(struct pci_dev *pdev);
  136. int (*idle_restart)(struct pci_dev *pdev,
  137. const struct pci_device_id *id);
  138. int (*idle_shutdown)(struct pci_dev *pdev);
  139. int (*reinit)(struct pci_dev *pdev, const struct pci_device_id *id);
  140. void (*shutdown)(struct pci_dev *pdev);
  141. void (*crash_shutdown)(struct pci_dev *pdev);
  142. int (*suspend)(struct pci_dev *pdev, pm_message_t state);
  143. int (*resume)(struct pci_dev *pdev);
  144. int (*suspend_noirq)(struct pci_dev *pdev);
  145. int (*resume_noirq)(struct pci_dev *pdev);
  146. void (*modem_status)(struct pci_dev *pdev, int state);
  147. void (*update_status)(struct pci_dev *pdev, uint32_t status);
  148. int (*update_event)(struct pci_dev *pdev,
  149. struct cnss_uevent_data *uevent);
  150. struct cnss_wlan_runtime_ops *runtime_ops;
  151. const struct pci_device_id *id_table;
  152. u32 chip_version;
  153. enum cnss_driver_mode (*get_driver_mode)(void);
  154. int (*collect_driver_dump)(struct pci_dev *pdev,
  155. struct cnss_ssr_driver_dump_entry *input_array,
  156. size_t *num_entries_loaded);
  157. };
  158. struct cnss_ce_tgt_pipe_cfg {
  159. u32 pipe_num;
  160. u32 pipe_dir;
  161. u32 nentries;
  162. u32 nbytes_max;
  163. u32 flags;
  164. u32 reserved;
  165. };
  166. struct cnss_ce_svc_pipe_cfg {
  167. u32 service_id;
  168. u32 pipe_dir;
  169. u32 pipe_num;
  170. };
  171. struct cnss_shadow_reg_cfg {
  172. u16 ce_id;
  173. u16 reg_offset;
  174. };
  175. struct cnss_shadow_reg_v2_cfg {
  176. u32 addr;
  177. };
  178. struct cnss_rri_over_ddr_cfg {
  179. u32 base_addr_low;
  180. u32 base_addr_high;
  181. };
  182. struct cnss_shadow_reg_v3_cfg {
  183. u32 addr;
  184. };
  185. struct cnss_wlan_enable_cfg {
  186. u32 num_ce_tgt_cfg;
  187. struct cnss_ce_tgt_pipe_cfg *ce_tgt_cfg;
  188. u32 num_ce_svc_pipe_cfg;
  189. struct cnss_ce_svc_pipe_cfg *ce_svc_cfg;
  190. u32 num_shadow_reg_cfg;
  191. struct cnss_shadow_reg_cfg *shadow_reg_cfg;
  192. u32 num_shadow_reg_v2_cfg;
  193. struct cnss_shadow_reg_v2_cfg *shadow_reg_v2_cfg;
  194. bool rri_over_ddr_cfg_valid;
  195. struct cnss_rri_over_ddr_cfg rri_over_ddr_cfg;
  196. u32 num_shadow_reg_v3_cfg;
  197. struct cnss_shadow_reg_v3_cfg *shadow_reg_v3_cfg;
  198. };
  199. enum cnss_driver_mode {
  200. CNSS_MISSION,
  201. CNSS_FTM,
  202. CNSS_EPPING,
  203. CNSS_WALTEST,
  204. CNSS_OFF,
  205. CNSS_CCPM,
  206. CNSS_QVIT,
  207. CNSS_CALIBRATION,
  208. CNSS_DRIVER_MODE_MAX,
  209. };
  210. enum cnss_recovery_reason {
  211. CNSS_REASON_DEFAULT,
  212. CNSS_REASON_LINK_DOWN,
  213. CNSS_REASON_RDDM,
  214. CNSS_REASON_TIMEOUT,
  215. };
  216. enum cnss_fw_caps {
  217. CNSS_FW_CAP_DIRECT_LINK_SUPPORT,
  218. };
  219. enum cnss_remote_mem_type {
  220. CNSS_REMOTE_MEM_TYPE_FW,
  221. CNSS_REMOTE_MEM_TYPE_QDSS,
  222. CNSS_REMOTE_MEM_TYPE_MAX,
  223. };
  224. struct cnss_mem_segment {
  225. size_t size;
  226. void *va;
  227. phys_addr_t pa;
  228. };
  229. extern int cnss_wlan_register_driver(struct cnss_wlan_driver *driver);
  230. extern void cnss_wlan_unregister_driver(struct cnss_wlan_driver *driver);
  231. extern void cnss_device_crashed(struct device *dev);
  232. extern int cnss_pci_prevent_l1(struct device *dev);
  233. extern void cnss_pci_allow_l1(struct device *dev);
  234. extern int cnss_pci_link_down(struct device *dev);
  235. extern int cnss_pci_is_device_down(struct device *dev);
  236. extern void cnss_schedule_recovery(struct device *dev,
  237. enum cnss_recovery_reason reason);
  238. extern int cnss_self_recovery(struct device *dev,
  239. enum cnss_recovery_reason reason);
  240. extern int cnss_force_fw_assert(struct device *dev);
  241. extern int cnss_force_collect_rddm(struct device *dev);
  242. extern int cnss_qmi_send_get(struct device *dev);
  243. extern int cnss_qmi_send_put(struct device *dev);
  244. extern int cnss_qmi_send(struct device *dev, int type, void *cmd,
  245. int cmd_len, void *cb_ctx,
  246. int (*cb)(void *ctx, void *event, int event_len));
  247. extern void *cnss_get_virt_ramdump_mem(struct device *dev, unsigned long *size);
  248. extern int cnss_get_fw_files_for_target(struct device *dev,
  249. struct cnss_fw_files *pfw_files,
  250. u32 target_type, u32 target_version);
  251. extern int cnss_get_platform_cap(struct device *dev,
  252. struct cnss_platform_cap *cap);
  253. extern struct iommu_domain *cnss_smmu_get_domain(struct device *dev);
  254. extern int cnss_smmu_map(struct device *dev,
  255. phys_addr_t paddr, uint32_t *iova_addr, size_t size);
  256. extern int cnss_smmu_unmap(struct device *dev, uint32_t iova_addr, size_t size);
  257. extern int cnss_get_soc_info(struct device *dev, struct cnss_soc_info *info);
  258. extern int cnss_request_bus_bandwidth(struct device *dev, int bandwidth);
  259. extern int cnss_power_up(struct device *dev);
  260. extern int cnss_power_down(struct device *dev);
  261. extern int cnss_idle_restart(struct device *dev);
  262. extern int cnss_idle_shutdown(struct device *dev);
  263. extern void cnss_request_pm_qos(struct device *dev, u32 qos_val);
  264. extern void cnss_remove_pm_qos(struct device *dev);
  265. extern void cnss_lock_pm_sem(struct device *dev);
  266. extern void cnss_release_pm_sem(struct device *dev);
  267. extern void cnss_pci_lock_reg_window(struct device *dev, unsigned long *flags);
  268. extern void cnss_pci_unlock_reg_window(struct device *dev,
  269. unsigned long *flags);
  270. extern int cnss_wlan_pm_control(struct device *dev, bool vote);
  271. extern int cnss_auto_suspend(struct device *dev);
  272. extern int cnss_auto_resume(struct device *dev);
  273. extern int cnss_pci_is_drv_connected(struct device *dev);
  274. extern int cnss_pci_force_wake_request_sync(struct device *dev, int timeout);
  275. extern int cnss_pci_force_wake_request(struct device *dev);
  276. extern int cnss_pci_is_device_awake(struct device *dev);
  277. extern int cnss_pci_force_wake_release(struct device *dev);
  278. extern int cnss_get_user_msi_assignment(struct device *dev, char *user_name,
  279. int *num_vectors,
  280. uint32_t *user_base_data,
  281. uint32_t *base_vector);
  282. extern int cnss_get_msi_irq(struct device *dev, unsigned int vector);
  283. extern bool cnss_is_one_msi(struct device *dev);
  284. extern void cnss_get_msi_address(struct device *dev, uint32_t *msi_addr_low,
  285. uint32_t *msi_addr_high);
  286. extern int cnss_wlan_hw_enable(void);
  287. extern int cnss_wlan_enable(struct device *dev,
  288. struct cnss_wlan_enable_cfg *config,
  289. enum cnss_driver_mode mode,
  290. const char *host_version);
  291. extern int cnss_wlan_disable(struct device *dev, enum cnss_driver_mode mode);
  292. extern unsigned int cnss_get_boot_timeout(struct device *dev);
  293. extern int cnss_athdiag_read(struct device *dev, uint32_t offset,
  294. uint32_t mem_type, uint32_t data_len,
  295. uint8_t *output);
  296. extern int cnss_athdiag_write(struct device *dev, uint32_t offset,
  297. uint32_t mem_type, uint32_t data_len,
  298. uint8_t *input);
  299. extern int cnss_set_fw_log_mode(struct device *dev, uint8_t fw_log_mode);
  300. extern int cnss_set_pcie_gen_speed(struct device *dev, u8 pcie_gen_speed);
  301. extern int cnss_get_mem_seg_count(enum cnss_remote_mem_type type, u32 *seg);
  302. extern int cnss_get_mem_segment_info(enum cnss_remote_mem_type type,
  303. struct cnss_mem_segment segment[],
  304. u32 segment_count);
  305. extern int cnss_audio_smmu_map(struct device *dev, phys_addr_t paddr,
  306. dma_addr_t iova, size_t size);
  307. extern void cnss_audio_smmu_unmap(struct device *dev, dma_addr_t iova,
  308. size_t size);
  309. extern int cnss_get_pci_slot(struct device *dev);
  310. extern int cnss_pci_get_reg_dump(struct device *dev, uint8_t *buffer,
  311. uint32_t len);
  312. extern struct kobject *cnss_get_wifi_kobj(struct device *dev);
  313. extern int cnss_send_buffer_to_afcmem(struct device *dev, char *afcdb,
  314. uint32_t len, uint8_t slotid);
  315. extern int cnss_reset_afcmem(struct device *dev, uint8_t slotid);
  316. extern bool cnss_get_fw_cap(struct device *dev, enum cnss_fw_caps fw_cap);
  317. extern int cnss_set_wfc_mode(struct device *dev, struct cnss_wfc_cfg cfg);
  318. #endif /* _NET_CNSS2_H */