cnss2.h 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  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. #define CNSS_SSR_DRIVER_DUMP_MAX_REGIONS 32
  15. enum cnss_bus_width_type {
  16. CNSS_BUS_WIDTH_NONE,
  17. CNSS_BUS_WIDTH_IDLE,
  18. CNSS_BUS_WIDTH_LOW,
  19. CNSS_BUS_WIDTH_MEDIUM,
  20. CNSS_BUS_WIDTH_HIGH,
  21. CNSS_BUS_WIDTH_VERY_HIGH,
  22. CNSS_BUS_WIDTH_LOW_LATENCY
  23. };
  24. enum cnss_platform_cap_flag {
  25. CNSS_HAS_EXTERNAL_SWREG = 0x01,
  26. CNSS_HAS_UART_ACCESS = 0x02,
  27. CNSS_HAS_DRV_SUPPORT = 0x04,
  28. };
  29. struct cnss_platform_cap {
  30. u32 cap_flag;
  31. };
  32. struct cnss_fw_files {
  33. char image_file[CNSS_MAX_FILE_NAME];
  34. char board_data[CNSS_MAX_FILE_NAME];
  35. char otp_data[CNSS_MAX_FILE_NAME];
  36. char utf_file[CNSS_MAX_FILE_NAME];
  37. char utf_board_data[CNSS_MAX_FILE_NAME];
  38. char epping_file[CNSS_MAX_FILE_NAME];
  39. char evicted_data[CNSS_MAX_FILE_NAME];
  40. };
  41. struct cnss_device_version {
  42. u32 family_number;
  43. u32 device_number;
  44. u32 major_version;
  45. u32 minor_version;
  46. };
  47. struct cnss_dev_mem_info {
  48. u64 start;
  49. u64 size;
  50. };
  51. struct cnss_soc_info {
  52. void __iomem *va;
  53. phys_addr_t pa;
  54. uint32_t chip_id;
  55. uint32_t chip_family;
  56. uint32_t board_id;
  57. uint32_t soc_id;
  58. uint32_t fw_version;
  59. char fw_build_timestamp[CNSS_MAX_TIMESTAMP_LEN + 1];
  60. struct cnss_device_version device_version;
  61. struct cnss_dev_mem_info dev_mem_info[CNSS_MAX_DEV_MEM_NUM];
  62. char fw_build_id[CNSS_WLFW_MAX_BUILD_ID_LEN + 1];
  63. };
  64. struct cnss_wlan_runtime_ops {
  65. int (*runtime_suspend)(struct pci_dev *pdev);
  66. int (*runtime_resume)(struct pci_dev *pdev);
  67. };
  68. enum cnss_driver_status {
  69. CNSS_UNINITIALIZED,
  70. CNSS_INITIALIZED,
  71. CNSS_LOAD_UNLOAD,
  72. CNSS_RECOVERY,
  73. CNSS_FW_DOWN,
  74. CNSS_HANG_EVENT,
  75. CNSS_BUS_EVENT,
  76. CNSS_SYS_REBOOT,
  77. };
  78. enum cnss_host_dump_type {
  79. CNSS_HOST_WLAN_LOGS,
  80. CNSS_HOST_HTC_CREDIT,
  81. CNSS_HOST_WMI_TX_CMP,
  82. CNSS_HOST_WMI_COMMAND_LOG,
  83. CNSS_HOST_WMI_EVENT_LOG,
  84. CNSS_HOST_WMI_RX_EVENT,
  85. CNSS_HOST_HAL_SOC,
  86. CNSS_HOST_GWLAN_LOGGING,
  87. CNSS_HOST_WMI_DEBUG_LOG_INFO,
  88. CNSS_HOST_HTC_CREDIT_IDX,
  89. CNSS_HOST_HTC_CREDIT_LEN,
  90. CNSS_HOST_WMI_TX_CMP_IDX,
  91. CNSS_HOST_WMI_COMMAND_LOG_IDX,
  92. CNSS_HOST_WMI_EVENT_LOG_IDX,
  93. CNSS_HOST_WMI_RX_EVENT_IDX,
  94. CNSS_HOST_HIF_CE_DESC_HISTORY,
  95. CNSS_HOST_HIF_CE_DESC_HISTORY_BUFF,
  96. CNSS_HOST_HANG_EVENT_DATA,
  97. CNSS_HOST_DUMP_TYPE_MAX,
  98. };
  99. enum cnss_bus_event_type {
  100. BUS_EVENT_PCI_LINK_DOWN = 0,
  101. BUS_EVENT_INVALID = 0xFFFF,
  102. };
  103. enum cnss_wfc_mode {
  104. CNSS_WFC_MODE_OFF,
  105. CNSS_WFC_MODE_ON,
  106. };
  107. struct cnss_wfc_cfg {
  108. enum cnss_wfc_mode mode;
  109. };
  110. struct cnss_hang_event {
  111. void *hang_event_data;
  112. u16 hang_event_data_len;
  113. };
  114. struct cnss_bus_event {
  115. enum cnss_bus_event_type etype;
  116. void *event_data;
  117. };
  118. struct cnss_uevent_data {
  119. enum cnss_driver_status status;
  120. void *data;
  121. };
  122. struct cnss_ssr_driver_dump_entry {
  123. char region_name[CNSS_SSR_DRIVER_DUMP_MAX_REGIONS];
  124. void *buffer_pointer;
  125. size_t buffer_size;
  126. };
  127. struct cnss_wlan_driver {
  128. char *name;
  129. int (*probe)(struct pci_dev *pdev, const struct pci_device_id *id);
  130. void (*remove)(struct pci_dev *pdev);
  131. int (*idle_restart)(struct pci_dev *pdev,
  132. const struct pci_device_id *id);
  133. int (*idle_shutdown)(struct pci_dev *pdev);
  134. int (*reinit)(struct pci_dev *pdev, const struct pci_device_id *id);
  135. void (*shutdown)(struct pci_dev *pdev);
  136. void (*crash_shutdown)(struct pci_dev *pdev);
  137. int (*suspend)(struct pci_dev *pdev, pm_message_t state);
  138. int (*resume)(struct pci_dev *pdev);
  139. int (*suspend_noirq)(struct pci_dev *pdev);
  140. int (*resume_noirq)(struct pci_dev *pdev);
  141. void (*modem_status)(struct pci_dev *pdev, int state);
  142. void (*update_status)(struct pci_dev *pdev, uint32_t status);
  143. int (*update_event)(struct pci_dev *pdev,
  144. struct cnss_uevent_data *uevent);
  145. struct cnss_wlan_runtime_ops *runtime_ops;
  146. const struct pci_device_id *id_table;
  147. u32 chip_version;
  148. enum cnss_driver_mode (*get_driver_mode)(void);
  149. int (*collect_driver_dump)(struct pci_dev *pdev,
  150. struct cnss_ssr_driver_dump_entry *input_array,
  151. size_t *num_entries_loaded);
  152. int (*set_therm_cdev_state)(struct pci_dev *pci_dev,
  153. unsigned long thermal_state,
  154. int tcdev_id);
  155. };
  156. struct cnss_ce_tgt_pipe_cfg {
  157. u32 pipe_num;
  158. u32 pipe_dir;
  159. u32 nentries;
  160. u32 nbytes_max;
  161. u32 flags;
  162. u32 reserved;
  163. };
  164. struct cnss_ce_svc_pipe_cfg {
  165. u32 service_id;
  166. u32 pipe_dir;
  167. u32 pipe_num;
  168. };
  169. struct cnss_shadow_reg_cfg {
  170. u16 ce_id;
  171. u16 reg_offset;
  172. };
  173. struct cnss_shadow_reg_v2_cfg {
  174. u32 addr;
  175. };
  176. struct cnss_rri_over_ddr_cfg {
  177. u32 base_addr_low;
  178. u32 base_addr_high;
  179. };
  180. struct cnss_shadow_reg_v3_cfg {
  181. u32 addr;
  182. };
  183. struct cnss_wlan_enable_cfg {
  184. u32 num_ce_tgt_cfg;
  185. struct cnss_ce_tgt_pipe_cfg *ce_tgt_cfg;
  186. u32 num_ce_svc_pipe_cfg;
  187. struct cnss_ce_svc_pipe_cfg *ce_svc_cfg;
  188. u32 num_shadow_reg_cfg;
  189. struct cnss_shadow_reg_cfg *shadow_reg_cfg;
  190. u32 num_shadow_reg_v2_cfg;
  191. struct cnss_shadow_reg_v2_cfg *shadow_reg_v2_cfg;
  192. bool rri_over_ddr_cfg_valid;
  193. struct cnss_rri_over_ddr_cfg rri_over_ddr_cfg;
  194. u32 num_shadow_reg_v3_cfg;
  195. struct cnss_shadow_reg_v3_cfg *shadow_reg_v3_cfg;
  196. bool send_msi_ce;
  197. };
  198. enum cnss_driver_mode {
  199. CNSS_MISSION,
  200. CNSS_FTM,
  201. CNSS_EPPING,
  202. CNSS_WALTEST,
  203. CNSS_OFF,
  204. CNSS_CCPM,
  205. CNSS_QVIT,
  206. CNSS_CALIBRATION,
  207. CNSS_DRIVER_MODE_MAX,
  208. };
  209. enum cnss_recovery_reason {
  210. CNSS_REASON_DEFAULT,
  211. CNSS_REASON_LINK_DOWN,
  212. CNSS_REASON_RDDM,
  213. CNSS_REASON_TIMEOUT,
  214. };
  215. enum cnss_fw_caps {
  216. CNSS_FW_CAP_DIRECT_LINK_SUPPORT,
  217. CNSS_FW_CAP_AUX_UC_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, const uint8_t *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. extern int cnss_thermal_cdev_register(struct device *dev,
  319. unsigned long max_state,
  320. int tcdev_id);
  321. extern void cnss_thermal_cdev_unregister(struct device *dev, int tcdev_id);
  322. extern int cnss_get_curr_therm_cdev_state(struct device *dev,
  323. unsigned long *thermal_state,
  324. int tcdev_id);
  325. extern int cnss_update_time_sync_period(struct device *dev,
  326. uint32_t time_sync_period);
  327. extern int cnss_reset_time_sync_period(struct device *dev);
  328. #endif /* _NET_CNSS2_H */