cnss2.h 9.6 KB

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